{
  "openapi": "3.1.0",
  "info": {
    "title": "TotalFinance local operations",
    "version": "0.1.4",
    "description": "The local, read-only-by-default, loopback HTTP transport over the TotalFinance operation registry (48 operations across 17 packs). Host and any Origin must match this server's host and bound port; null/foreign origins are refused. JSON POSTs require application/json. Enabled writes (including trade:approve) and job creation/cancellation require a server-owned bearer credential; read-only analytics and discovery remain unauthenticated. A credential does not grant capabilities. Every request body is the operation's own input schema; every error body is one OperationError. Wire byte budget default 65536."
  },
  "servers": [
    {
      "url": "http://127.0.0.1:8787",
      "description": "loopback"
    }
  ],
  "paths": {
    "/operations": {
      "get": {
        "operationId": "listOperations",
        "summary": "Every registered operation, described",
        "responses": {
          "200": {
            "description": "The descriptions, in registry order.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OperationDescription"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        }
      }
    },
    "/operations/{id}": {
      "get": {
        "operationId": "describeOperation",
        "summary": "One operation, described",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The description.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationDescription"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        }
      }
    },
    "/operations/totalfinance.artifact.compare/run": {
      "post": {
        "operationId": "run.totalfinance.artifact.compare",
        "security": [],
        "summary": "Compare two analysis artifacts",
        "description": "Compare a baseline and a candidate artifact of the same type leaf by leaf: value differences with absolute and relative deltas, added and removed paths, whether inputs and producers match, and — when a tolerance is supplied — whether every numeric leaf is within it. The result is compareAnalysisArtifacts(...) verbatim.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.artifact.compare.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.artifact.compare.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "medium",
          "supportsCancellation": false,
          "handleFields": [
            "baseline",
            "candidate"
          ],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.artifact.read/run": {
      "post": {
        "operationId": "run.totalfinance.artifact.read",
        "security": [],
        "summary": "Read an analysis artifact",
        "description": "Validate a Gate B analysis artifact (its envelope, its recomputed inputs hash, and its content-hash identity) and return its identity, type, producer, provenance warnings, table names, and a bounded preview of the stored result — the one read door for any artifact over the wire. Migrations are not registered over the wire; a stored older version is refused with the versions named.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.artifact.read.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.artifact.read.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [
            "artifact"
          ],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.backtest.cross_sectional_run/run": {
      "post": {
        "operationId": "run.totalfinance.backtest.cross_sectional_run",
        "security": [],
        "summary": "Run a cross-sectional backtest",
        "description": "Backtest a point-in-time cross-sectional strategy: a returns dataset with declared features, a universe history with entries and exits, one declarative signal (a versioned factor recipe, a composite score, or a screen), a rebalance schedule, and a portfolio construction (quantile/count/fraction selection on each side; equal, score, inverse-volatility, or risk-budget weights; dollar/sector/beta/factor neutrality; position, weight, turnover, and participation caps — every trim a reported goal). Fills go through the execution policy into the portfolio ledger; the final value reconciles to the ledger NAV. Rebalances, holdings, fills, the ledger, the timeline, attribution, the benchmark block, and the performance summary — crossSectionalBacktest(...) verbatim. Opt-in (backtestPack): payloads and runtime are heavier than the default set; bulk row sets above the row cap travel by handle.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.backtest.cross_sectional_run.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.backtest.cross_sectional_run.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "job",
          "supportsCancellation": false,
          "handleFields": [
            "dataset"
          ],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.backtest.environment_episode/run": {
      "post": {
        "operationId": "run.totalfinance.backtest.environment_episode",
        "security": [],
        "summary": "Bench a baseline policy over one trading-environment episode",
        "description": "Run one of the six maintained baseline policies through the deterministic trading environment over a catalogue episode (or a named declarative definition) at a seed, and return Agent Bench's report for that episode: operational conformance (look-ahead, replay equality, duplicate orders under the retry drive, external-order attempts, reconciliation; the mask and limit counts) apart from strategy quality (return, volatility, Sharpe, Sortino, drawdown, turnover, cost, exposure, violations) — no single score by design. With artifact: 'embed', the recorded episode travels as an `environment` run artifact that replays to its run hash. Declarative inputs only: a TypeScript policy or a reward goal callback is SDK-only. Opt-in (backtestPack).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.backtest.environment_episode.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.backtest.environment_episode.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "job",
          "supportsCancellation": false,
          "handleFields": [
            "episode.definition.marketData"
          ],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.backtest.options_run/run": {
      "post": {
        "operationId": "run.totalfinance.backtest.options_run",
        "security": [],
        "summary": "Run an options backtest",
        "description": "Backtest a declarative options strategy over chain snapshots: structure selection by delta and DTE, exit and roll triggers, optional delta hedging, declarative commission and slippage, American assignment modelling, and the marking policy (current-quote or entry volatility; what a missing mark does). Several rules may hold several trades at once (book), pre-trade limits reject entries with rows, combo or legged fills, quote freshness, split lineage, dividend evidence, the surface summary, and the portfolio ledger the equity reconciles to. Equity points, trades with per-leg attribution and mark counts, settlements, and the standard performance summary. The result is optionsBacktest(...) verbatim. Opt-in (backtestPack): payloads and runtime are heavier than the default set.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.backtest.options_run.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.backtest.options_run.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "job",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.backtest.portfolio_run/run": {
      "post": {
        "operationId": "run.totalfinance.backtest.portfolio_run",
        "security": [],
        "summary": "Run a portfolio backtest",
        "description": "Backtest a multi-asset portfolio through the ledger: instruments with built-in adapters (equity, etf, option, future, fx-forward, crypto-spot, crypto-perpetual, bond), market data by row set, a model or inline targets on a rebalance schedule, an execution policy with settlement lags, external flows, a calendar, and the margin check with forced liquidation. Every fill, flow, lifecycle fact, and liquidation is a portfolio event; the equity is the ledger's net asset value. The result is portfolioBacktest(...) verbatim. Opt-in (backtestPack): payloads and runtime are heavier than the default set; bulk row sets above the row cap travel by handle.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.backtest.portfolio_run.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.backtest.portfolio_run.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "job",
          "supportsCancellation": false,
          "handleFields": [
            "marketData"
          ],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.backtest.vectorized_run/run": {
      "post": {
        "operationId": "run.totalfinance.backtest.vectorized_run",
        "security": [],
        "summary": "Run a vectorized backtest",
        "description": "Run a single-asset vectorized backtest: signal-following fills at close, optional bps fees. Returns final value, turnover, and the performance summary; every hidden policy the run assumed (fill timing, costs, slippage, settlement, calendar, margin) is echoed in `assumptions`, and the implementation-risk warnings (look-ahead, data alignment) ride `diagnostics`. Deliberately opt-in (backtestPack) — payloads and runtime are heavier than the default tools. executionLag shifts signal lookup before rebalance sampling; a month-end target can miss the next monthly sample. Use the SDK researchProtocol and selection-hygiene workflow before comparing candidates; see docs/guides/dogfood-journeys.md.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.backtest.vectorized_run.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.backtest.vectorized_run.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.calendar.sessions/run": {
      "post": {
        "operationId": "run.totalfinance.calendar.sessions",
        "security": [],
        "summary": "Trading sessions & option expirations",
        "description": "Trading days, holidays, and half days for an exchange calendar over a date range (≤ ~13 months), plus option expirations (weekly Fridays / monthly OPEX / quarterly, shifted off holidays from the calendar data) when `expirationKind` is set, and the next expiry after the range start. NYSE/CBOE one-off closure coverage begins 2001-01-01; earlier ranges carry a diagnostic. Rules project other dates, not future emergency closures.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.calendar.sessions.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.calendar.sessions.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.crypto.futures_basis/run": {
      "post": {
        "operationId": "run.totalfinance.crypto.futures_basis",
        "security": [],
        "summary": "Futures basis / cash-and-carry",
        "description": "Annualized basis of a dated future over spot — the cash-and-carry yield. Reports raw and percentage basis, simple and continuously-compounded annualization, contango/backwardation, and flags an arbitrage-sized basis.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.crypto.futures_basis.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.crypto.futures_basis.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.crypto.perpetual_funding/run": {
      "post": {
        "operationId": "run.totalfinance.crypto.perpetual_funding",
        "security": [],
        "summary": "Perpetual funding → implied carry",
        "description": "Annualize a perpetual funding rate into the implied cost-of-carry: the mark/index premium, simple and compounded annualized funding, and an extreme-funding flag. All rates are decimals; the interval defaults to the standard 8 hours.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.crypto.perpetual_funding.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.crypto.perpetual_funding.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.fixed_income.bond_analytics/run": {
      "post": {
        "operationId": "run.totalfinance.fixed_income.bond_analytics",
        "security": [],
        "summary": "Bond price/yield analytics",
        "description": "Full fixed-rate bond analytics from a specification: given a `yield`, price it; given a `price`, solve the yield to maturity — then report clean/dirty price, accrued interest, Macaulay/modified duration, convexity, and DV01. Dates are YYYY-MM-DD; rates are decimals.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.fixed_income.bond_analytics.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.fixed_income.bond_analytics.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.option.greeks/run": {
      "post": {
        "operationId": "run.totalfinance.option.greeks",
        "security": [],
        "summary": "Compute first-order Greeks",
        "description": "Compute first-order Greeks (delta, gamma, theta/day, vega/1%, rho/1%) for a European option under Black–Scholes–Merton. Supply time as timeToExpiryYears (years) or as expiry + asOf (dates).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.option.greeks.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.option.greeks.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.option.implied_volatility/run": {
      "post": {
        "operationId": "run.totalfinance.option.implied_volatility",
        "security": [],
        "summary": "Solve implied volatility",
        "description": "Solve Black–Scholes–Merton implied volatility from an observed option price using the method suite (auto/brent/newton/halley/householder, with an optional Brent fallback). Supply time as timeToExpiryYears (years) or as expiry + asOf (dates). Non-convergence and no-arbitrage failures are reported in diagnostics (converged: false), never fabricated; the method actually used is echoed in diagnostics.method.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.option.implied_volatility.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.option.implied_volatility.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.option.price/run": {
      "post": {
        "operationId": "run.totalfinance.option.price",
        "security": [],
        "summary": "Price an option (Black–Scholes–Merton)",
        "description": "Price a European option with the Black–Scholes–Merton model. Supply time as timeToExpiryYears (years) or as expiry + asOf (dates). Returns the price plus the assumptions (day count, compounding, units, resolved timeToExpiryYears) and diagnostics that produced it.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.option.price.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.option.price.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.performance.analyze/run": {
      "post": {
        "operationId": "run.totalfinance.performance.analyze",
        "security": [],
        "summary": "Full performance summary",
        "description": "Summarize a return series or equity curve: total/annualized return, volatility, Sharpe, Sortino, Calmar, max drawdown, omega, hit rate, profit factor, expectancy — plus beta/alpha/tracking error/information ratio/Treynor when a `benchmark` is supplied. Suspicious inputs (prices passed as returns, returns passed as equity) are flagged in diagnostics.warnings, never silently reported.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.performance.analyze.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.performance.analyze.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.portfolio.analyze/run": {
      "post": {
        "operationId": "run.totalfinance.portfolio.analyze",
        "security": [],
        "summary": "Analyze a portfolio (snapshot, timeline, monitor)",
        "description": "One report of up to three direct results: the valuation snapshot at `asOf` (always), the dated timeline with P&L since each prior mark and drawdown (when `marks` are supplied), and the policy monitor with its alerts and carried state (when `monitor` is supplied). Each result is the direct function verbatim; nothing is aggregated across them, and one `assumptions` says which parts ran and why the others did not.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.portfolio.analyze.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.portfolio.analyze.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "medium",
          "supportsCancellation": false,
          "handleFields": [
            "ledger",
            "market"
          ],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.portfolio.create/run": {
      "post": {
        "operationId": "run.totalfinance.portfolio.create",
        "security": [
          {
            "localBearer": []
          }
        ],
        "summary": "Create and store an explicitly defined portfolio ledger",
        "description": "Start here before portfolio.record_events: supply durable portfolioId, baseCurrency and explicit initial events (an empty array creates no cash). Uses the existing artifact store and ledger reducer. Requires portfolio:write and a writable store. Save the returned handle and open it with portfolio.inspect from portfolioPack (enable both trade and portfolio packs, or use --profile full); subsequent event writes return a new immutable handle. Opt-in (tradePack).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.portfolio.create.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.portfolio.create.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "portfolio-state",
          "authorization": "none",
          "idempotency": "required",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": false,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": true
          }
        }
      }
    },
    "/operations/totalfinance.portfolio.explain_pnl/run": {
      "post": {
        "operationId": "run.totalfinance.portfolio.explain_pnl",
        "security": [],
        "summary": "Explain portfolio P&L between two marks",
        "description": "Explain the change in net asset value between two dated valuation marks: external flows, investment return, and the identity components (realized, unrealized, income, transaction costs, financing, foreign exchange) that reconcile to it with a published residual, by currency and by grouping. The result is portfolioPnl(...) verbatim.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.portfolio.explain_pnl.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.portfolio.explain_pnl.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [
            "ledger",
            "from.market",
            "to.market"
          ],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.portfolio.inspect/run": {
      "post": {
        "operationId": "run.totalfinance.portfolio.inspect",
        "security": [],
        "summary": "Open a portfolio ledger or handle and inspect a bounded page",
        "description": "Open a returned totalfinance://portfolios/... handle through the same configured store, or import an inline serialized ledger for read-only inspection. Revalidates and replays the ledger. Summary returns identity/counts; events, positions and cash return bounded previews (default 20, maximum 100 rows). This does not value the portfolio; use portfolio.snapshot with explicit marks. Opt-in (portfolioPack).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.portfolio.inspect.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.portfolio.inspect.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [
            "portfolio"
          ],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.portfolio.rebalance_proposal/run": {
      "post": {
        "operationId": "run.totalfinance.portfolio.rebalance_proposal",
        "security": [],
        "summary": "Propose a rebalance (a proposal, never an order)",
        "description": "Fold the ledger snapshot to its state, mark it from the market snapshot, and propose the trades that take the portfolio to the policy targets (or only the drifted ones) under the policy limits, lot sizes, minimum notional, transaction-cost estimates, and an optional external flow. The result is proposePortfolioRebalance(...) verbatim: weights before and after, the cash summary, the trades with their estimates, the objective, and every target it could not resolve. Read-only by construction — it returns a proposal and places nothing. Opt-in (portfolioPack).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.portfolio.rebalance_proposal.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.portfolio.rebalance_proposal.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "medium",
          "supportsCancellation": false,
          "handleFields": [
            "ledger",
            "market"
          ],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.portfolio.record_events/run": {
      "post": {
        "operationId": "run.totalfinance.portfolio.record_events",
        "security": [
          {
            "localBearer": []
          }
        ],
        "summary": "Apply events to a ledger and store the new ledger",
        "description": "Fold validated portfolio events (fills from trade.submit, deposits, corporate actions) onto a ledger through the ledger's own reducer and put the new ledger into the artifact store as a content-addressed portfolio handle. The write is the put: an unchanged ledger is the same handle; identical replays fold once and applied counts only new events. Changed event bodies are refused. Requires a writable artifact store and the portfolio:write capability. Opt-in (tradePack).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.portfolio.record_events.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.portfolio.record_events.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "portfolio-state",
          "authorization": "none",
          "idempotency": "required",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [
            "portfolio"
          ],
          "annotations": {
            "readOnlyHint": false,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": true
          }
        }
      }
    },
    "/operations/totalfinance.portfolio.snapshot/run": {
      "post": {
        "operationId": "run.totalfinance.portfolio.snapshot",
        "security": [],
        "summary": "Value a portfolio at an instant",
        "description": "Value every cash balance and position of a portfolio at one instant from a Gate B market snapshot: net asset value in the base currency, per-account cash rows (settled and unsettled), per-position marks, cost basis and unrealized P&L. Supply the portfolio as its serialized ledger envelope (re-hydrated through readPortfolioLedgerSnapshot) or as a derived PortfolioState. The result is portfolioSnapshot(...) verbatim.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.portfolio.snapshot.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.portfolio.snapshot.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [
            "portfolio",
            "market"
          ],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.research.event_study/run": {
      "post": {
        "operationId": "run.totalfinance.research.event_study",
        "security": [],
        "summary": "Run an event study",
        "description": "Measure abnormal returns around dated events under a declared expected-return model (mean-adjusted, market-adjusted, or market model), with explicit session, overlap, and cumulation policies; per-event rows and cumulative abnormal returns, and the average abnormal return by offset with t-statistics. The result is eventStudy(...) verbatim.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.research.event_study.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.research.event_study.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "medium",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.research.rank/run": {
      "post": {
        "operationId": "run.totalfinance.research.rank",
        "security": [],
        "summary": "Rank a universe",
        "description": "Rank a point-in-time universe by one declared numeric field with an explicit tie policy (competition, dense, ordinal) and missing-value policy. The result is rankUniverse(...) verbatim.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.research.rank.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.research.rank.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "medium",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.research.score/run": {
      "post": {
        "operationId": "run.totalfinance.research.score",
        "security": [],
        "summary": "Score a universe",
        "description": "Score a point-in-time universe as a weighted composite of standardized components (z-score or percentile rank, higher- or lower-is-better) with an explicit missing-value policy. The result is scoreUniverse(...) verbatim.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.research.score.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.research.score.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "medium",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.research.screen/run": {
      "post": {
        "operationId": "run.totalfinance.research.screen",
        "security": [],
        "summary": "Screen a universe",
        "description": "Filter a point-in-time universe of instrument observations with a declarative filter tree, order the survivors, and optionally limit them — a replayable screen by construction (no caller predicate crosses the wire). The result is screenUniverse(...) verbatim.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.research.screen.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.research.screen.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "medium",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.risk.optimize/run": {
      "post": {
        "operationId": "run.totalfinance.risk.optimize",
        "security": [],
        "summary": "Portfolio optimization",
        "description": "Solve a portfolio: minVariance, maxSharpe (tangency), meanVariance utility, riskParity (equal risk contribution), hrp (hierarchical risk parity), or kelly. Returns the Computed envelope: value.weights + value.objective, assumptions echo the objective and budget, and diagnostics carry converged/iterations — a non-converged solve adds an optimize.not_converged warning instead of pretending.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.risk.optimize.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.risk.optimize.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.risk.value_at_risk/run": {
      "post": {
        "operationId": "run.totalfinance.risk.value_at_risk",
        "security": [],
        "summary": "Value-at-Risk & Conditional VaR",
        "description": "Estimate Value-at-Risk (VaR) and Conditional VaR / expected shortfall from a return series. Methods: historical (empirical quantile, default), parametric (Gaussian, optional Cornish-Fisher for skew/kurtosis), or monteCarlo. Both are positive loss magnitudes at the given `confidence`; the horizon scales by √-time. The applied confidence/method/horizon ride `assumptions` (with the resolved seed/samples for monteCarlo) and warnings ride `diagnostics`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.risk.value_at_risk.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.risk.value_at_risk.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": false,
          "stochastic": "per-call",
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.scenario.run/run": {
      "post": {
        "operationId": "run.totalfinance.scenario.run",
        "security": [],
        "summary": "Run a scenario set against targets",
        "description": "Revalue every target under every scenario of a Gate B scenario set against a Gate B market snapshot: a scenario-major cell grid with base values, per-cell P&L in local and reporting currency, and per-scenario aggregates. Targets are the serializable kinds — spot assets, Taylor (greeks) positions, and a portfolio bound through Taylor bindings. The result is runScenarios(...) verbatim.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.scenario.run.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.scenario.run.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "large",
          "supportsCancellation": false,
          "handleFields": [
            "scenarioSet",
            "market"
          ],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.strategy.analyze/run": {
      "post": {
        "operationId": "run.totalfinance.strategy.analyze",
        "security": [],
        "summary": "Analyze an options strategy",
        "description": "Build a multi-leg options position from its legs and return breakevens, net debit/credit, max profit, and max loss. Legs may be given without premiums: pass `premiums: \"model\"` with a `market` snapshot (spot, volatility, riskFreeRate, asOf, expiry) and every unpriced leg is priced by the BSM engine — so an iron condor’s P&L and probability-of-profit come from strikes alone. Set `probability: true` (with `market`) to also get probability-of-profit, expected value, risk/reward, and probability-of-touch. `premiumSource` reports whether premiums were user- or model-supplied.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.strategy.analyze.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.strategy.analyze.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.strategy.list/run": {
      "post": {
        "operationId": "run.totalfinance.strategy.list",
        "security": [],
        "summary": "List the named-strategy catalog",
        "description": "Discover every named strategy builder: name, one-line description, whether it spans multiple expiries, and a canonical example input (the exact shape `totalfinance.strategy.analyze` accepts via its `strategy` + `input` form). Agents self-serve the input shapes from here.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.strategy.list.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.strategy.list.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.structure.exposures/run": {
      "post": {
        "operationId": "run.totalfinance.structure.exposures",
        "security": [],
        "summary": "Dealer exposure & levels from an option chain",
        "description": "Compute dealer-positioning exposure (net GEX/DEX at spot) and key levels — call/put walls, zero-gamma flip, max pain, pin risk, and 0DTE/weekly/monthly OPEX walls — from an option chain. Each row needs `strike`, `expiry`, `type`, `openInterest`, and either `impliedVolatility` or `price` (IV is implied from price when omitted). Inferred from open interest and a sign convention (echoed in `assumptions.convention`, with its caveats as `model.limitation` warnings in `diagnostics.warnings`) — it does not know true dealer books.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.structure.exposures.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.structure.exposures.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.structure.flow/run": {
      "post": {
        "operationId": "run.totalfinance.structure.flow",
        "security": [],
        "summary": "Classify options flow (sweeps / blocks / spreads)",
        "description": "Classify option prints into aggressor-side flow: sweeps (multi-print bursts, venue-verified when exchange codes are supplied), blocks, and multi-leg spreads. Aggressor side is NBBO-estimated (Lee–Ready style) — the honest caveats ride diagnostics.warnings as `model.limitation` entries (mirrored as `limitations` strings for quick reading); nothing is presented as exchange-confirmed unless it is.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.structure.flow.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.structure.flow.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.technical_analysis.calculate/run": {
      "post": {
        "operationId": "run.totalfinance.technical_analysis.calculate",
        "security": [],
        "summary": "Calculate a technical indicator",
        "description": "Compute any of TotalFinance’s ~300 registered technical indicators over a price series. Pass canonical core Bar records directly under bars; symbol, timestampMs, vwap and adjusted are declared fields. Source records require open, one symbol and strictly increasing unique timestamps; no stripping or SDK preprocessing is needed. Identity/time are validated before OHLCV projection; retain the original source/provenance alongside the result. Close-based (`series`) indicators take `closes`; bar-based indicators take `bars` (OHLCV objects) or parallel column arrays under `series`; pair indicators (e.g. beta, correl) take `x` and `y`. Use `totalfinance.technical_analysis.list` to discover indicator names, input kinds, and parameters. Output is aligned to input length with null during warmup; `assumptions.parameters` echoes the parameters actually used (declared defaults merged with yours), and `diagnostics.warmup` is the first real index.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.technical_analysis.calculate.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.technical_analysis.calculate.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.technical_analysis.describe/run": {
      "post": {
        "operationId": "run.totalfinance.technical_analysis.describe",
        "security": [],
        "summary": "Describe one technical indicator",
        "description": "Return the full card for a single indicator (alias-aware): category, input kind, parameters, defaults, which parameters are required, its warmup (leading bars before the first real value), and its cross-library aliases. The token-lean way to learn one indicator without listing all ~335. Discover names with `totalfinance.technical_analysis.list`; compute with `totalfinance.technical_analysis.calculate`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.technical_analysis.describe.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.technical_analysis.describe.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.technical_analysis.list/run": {
      "post": {
        "operationId": "run.totalfinance.technical_analysis.list",
        "security": [],
        "summary": "List technical indicators",
        "description": "Discover the technical indicators available to `totalfinance.technical_analysis.calculate`. Returns each indicator’s name, category, input kind (series | bars | pair), parameters, defaults, and which parameters are required. Narrow the ~335-indicator catalog with `search` (matches a name or a TA-Lib/pandas/TradingView alias) and/or `category`, and page it with `limit` (default 50) / `offset` (`total` is the full match count). For one indicator’s full card (including its warmup), use `totalfinance.technical_analysis.describe`. To browse momentum, use { category: \"momentum\" }, rather than searching the name momentum. Then pass a name to `totalfinance.technical_analysis.calculate`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.technical_analysis.list.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.technical_analysis.list.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.trade.authorize/run": {
      "post": {
        "operationId": "run.totalfinance.trade.authorize",
        "security": [
          {
            "localBearer": []
          }
        ],
        "summary": "Mint an authorization grant for a preflighted plan",
        "description": "Bind human authority to one plan and one preflight report: the plan hash, the portfolio and market hashes preflight judged, the market instant and an age allowance, the paper mode, the account, a variance envelope, an expiry, the approver, and a closed set of idempotency keys. Refuses a denied preflight, an unjudged plan, or a stale expiry. The grant is put into the authorization store under its content hash and returned with its handle. Requires the trade:approve capability. Opt-in (tradePack).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.trade.authorize.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.trade.authorize.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "human",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.trade.cancel/run": {
      "post": {
        "operationId": "run.totalfinance.trade.cancel",
        "security": [
          {
            "localBearer": []
          }
        ],
        "summary": "Cancel an open paper order",
        "description": "Journal cancel-requested then cancelled for an open order in the journal store under `<sourceId>:journal`; a terminal order is not cancelled twice (accepted: false, the state says why). Cancelling a combo leg cancels all remaining legs of that plan-local combo. Both the original journal and authorization stores are required to recover pending submissions before cancellation; no new grant is needed. A fill delivered after the cancellation is Decision 6's late-fill path. Paper only; requires trade:paper. Opt-in (tradePack).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.trade.cancel.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.trade.cancel.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "external-order",
          "authorization": "policy",
          "idempotency": "optional",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": false,
            "destructiveHint": true,
            "idempotentHint": false,
            "openWorldHint": true
          }
        }
      }
    },
    "/operations/totalfinance.trade.preflight/run": {
      "post": {
        "operationId": "run.totalfinance.trade.preflight",
        "security": [],
        "summary": "Preflight a trade plan against the ledger, the market, and the policy",
        "description": "Normalize an intent (or take an execution plan) and judge it: the portfolio before and after through the ledger's own fold of hypothetical fills, every policy check with its verdict, declared-rate cost estimates, the monitor's alerts on the after-state, and one decision — allow only when every check passes, deny on any failure, require-approval when evidence is missing; never an allow from missing information. No effect. Opt-in (tradePack).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.trade.preflight.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.trade.preflight.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [
            "portfolio",
            "market"
          ],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.trade.reconcile/run": {
      "post": {
        "operationId": "run.totalfinance.trade.reconcile",
        "security": [
          {
            "localBearer": []
          }
        ],
        "summary": "Reconcile an execution journal to the ledger",
        "description": "Join the journal's order states (from the journal store by `journalId`, or inline events) to the ledger's fills under the execution source in both directions, compare delivered fill quantities per order within an explicit tolerance, list the unresolved orders, and — with an external snapshot — compose reconcilePortfolio verbatim. With planHash, exclude other plans’ journaled orders and fills from both joins; unattributed source fills remain discrepancies. External snapshots are judged over the whole portfolio. reconciled is true only when everything agrees and no order is unresolved. No effect; requires trade:paper. Opt-in (tradePack).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.trade.reconcile.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.trade.reconcile.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [
            "ledger"
          ],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.trade.submit/run": {
      "post": {
        "operationId": "run.totalfinance.trade.submit",
        "security": [
          {
            "localBearer": []
          }
        ],
        "summary": "Submit an authorized plan to the paper broker",
        "description": "Verify the grant against the plan, the portfolio and market hashes, the market instant, the account, and the idempotency key; journal submitted and acknowledged; return the content-addressed receipt — the SAME receipt for a retry with the same key and plan (no second order), trade.idempotency_conflict for the same key with another plan, trade.grant_expired for an expired grant. With `observations`, the open orders meet the market through the engines' own fill path. Top-level fills/events are only this call’s new deltas; the submission receipt is immutable. `currentOrders` is the authoritative journal-derived current state and cumulative filled/remaining quantities for this receipt. `recovery: { fills, events }` contains all persisted normalized fills and reproducible ledger envelopes for this receipt’s orders, including this call’s fills. Retry after a lost response and apply recovery.events with portfolio.record_events; identical events fold once. Recovery grows with later fills without replaying the fill engine. The journal continues transactionally from the required journal store under `<sourceId>:journal`; retries must retain that store and source. A grant atomically records its exact prepared submission before journal commit: a retry with the same key into the same store/journal recovers those events and reads the same receipt; any other submission of the grant is trade.grant_consumed. Every journal write recovers earlier pending submissions before allocating new identities. Inline history must match persisted history exactly. Inline grants must exist unchanged in the trusted authorization store. Paper only; requires trade:paper. Opt-in (tradePack).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.trade.submit.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.trade.submit.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "external-order",
          "authorization": "policy",
          "idempotency": "required",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": false,
            "destructiveHint": true,
            "idempotentHint": true,
            "openWorldHint": true
          }
        }
      }
    },
    "/operations/totalfinance.valuation.company/run": {
      "post": {
        "operationId": "run.totalfinance.valuation.company",
        "security": [],
        "summary": "Value a company from its statements",
        "description": "Project the three statements from explicit drivers, take the free cash flows the valuation basis needs, and discount them under the stated conventions (basis, date, currency, the REQUIRED discount rate, compounding, day count, the terminal value method, the enterprise-to-equity bridge). The result is discountedCashFlowFromStatements(...) verbatim — the projection with its balance-sheet reconciliation, the cash flows used, and the valuation — plus discountedCashFlowSensitivityTable(...) over the same flows when a sensitivity request is supplied. Opt-in (valuationPack).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.valuation.company.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.valuation.company.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "medium",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.volatility.event/run": {
      "post": {
        "operationId": "run.totalfinance.volatility.event",
        "security": [],
        "summary": "Event-volatility decomposition (earnings)",
        "description": "Decompose pre-event implied volatility into base + event variance and the implied one-day event move (the earnings-move read): eventMove = √max(0, atmVolatility²·timeToExpiryYears − baseVolatility²·timeToExpiryYears). Optionally reports the variance risk premium when `realizedVolatility` is supplied.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.volatility.event.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.volatility.event.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.volatility.expected_move/run": {
      "post": {
        "operationId": "run.totalfinance.volatility.expected_move",
        "security": [],
        "summary": "Expected move (1σ)",
        "description": "Compute the expected 1-sigma move of the underlying by expiry — the lognormal ±1σ band and the expected absolute move. Provide `impliedVolatility` + `timeToExpiryYears` to imply it from volatility, or `straddlePrice` to imply it from the ATM straddle. Risk-neutral, not a directional forecast.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.volatility.expected_move.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.volatility.expected_move.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.volatility.metrics/run": {
      "post": {
        "operationId": "run.totalfinance.volatility.metrics",
        "security": [],
        "summary": "IV rank / percentile / stats",
        "description": "Where does the current implied volatility sit against its history? Returns IV rank (min–max position, 0–100), IV percentile (share of history below current, 0–100), and summary statistics — the standard \"is IV high?\" read before selling or buying premium.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.volatility.metrics.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.volatility.metrics.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.volatility.probability_in_the_money/run": {
      "post": {
        "operationId": "run.totalfinance.volatility.probability_in_the_money",
        "security": [],
        "summary": "Probability of finishing in-the-money",
        "description": "Risk-neutral probability that an option finishes in the money at expiry — N(d2) for a call, N(−d2) for a put. This is the model probability P(S_t ⋛ K), not a real-world forecast.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.volatility.probability_in_the_money.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.volatility.probability_in_the_money.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.volatility.probability_of_touch/run": {
      "post": {
        "operationId": "run.totalfinance.volatility.probability_of_touch",
        "security": [],
        "summary": "Probability of touching a level",
        "description": "Risk-neutral probability that the underlying TOUCHES `barrier` at any time before expiry (first-passage probability for geometric Brownian motion). Useful for stop/target and one-touch reasoning.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.volatility.probability_of_touch.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.volatility.probability_of_touch.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/operations/totalfinance.volatility.surface/run": {
      "post": {
        "operationId": "run.totalfinance.volatility.surface",
        "security": [],
        "summary": "Fit an implied-vol surface",
        "description": "Fit an implied-volatility surface from chain quotes (IV given directly, or implied from price) and return the surface rows, per-expiry ATM term structure, and the static-arbitrage report (calendar/butterfly violations). The surface never fabricates: non-convergence and extrapolation are reported in diagnostics/warnings.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/totalfinance.volatility.surface.input"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/totalfinance.volatility.surface.result"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        },
        "x-totalfinance": {
          "sideEffect": "none",
          "authorization": "none",
          "idempotency": "not-applicable",
          "deterministic": true,
          "stochastic": false,
          "costClass": "small",
          "supportsCancellation": false,
          "handleFields": [],
          "annotations": {
            "readOnlyHint": true,
            "destructiveHint": false,
            "idempotentHint": true,
            "openWorldHint": false
          }
        }
      }
    },
    "/jobs": {
      "post": {
        "operationId": "submitJob",
        "security": [
          {
            "localBearer": []
          }
        ],
        "description": "Job creation persists state even for analytics and always requires the server-owned bearer token. Without a configured token, submission is disabled; inline read-only /run calls remain public.",
        "summary": "Submit an operation as a job (a job-class operation runs in a worker; others inline)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "input": {
                    "type": "object"
                  },
                  "seed": {
                    "type": "integer"
                  }
                },
                "required": [
                  "id",
                  "input"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "The accepted (or, inline, terminal) record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobRecord"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        }
      }
    },
    "/jobs/{id}": {
      "get": {
        "operationId": "getJob",
        "summary": "The job record",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobRecord"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        }
      }
    },
    "/jobs/{id}/cancel": {
      "post": {
        "operationId": "cancelJob",
        "security": [
          {
            "localBearer": []
          }
        ],
        "description": "Cancellation mutates persisted job state and always requires the server-owned bearer token. No JSON body is required.",
        "summary": "Cancel a job — the worker is terminated; the record moves to cancelled",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The cancelled (or already terminal) record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobRecord"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer credential (operation.capability_missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "The input exceeds the wire byte budget (operation.input_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "415": {
            "description": "JSON POST requests require Content-Type: application/json (input.wrong_shape).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Internal error (operation.internal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        }
      }
    },
    "/jobs/{id}/result": {
      "get": {
        "operationId": "getJobResult",
        "summary": "The stored OperationResult of a completed job",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The OperationResult.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationResult"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "409": {
            "description": "The job was cancelled (operation.cancelled) or has not finished.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "422": {
            "description": "The operation failed (any other operation error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        }
      }
    },
    "/artifacts/{uri}": {
      "get": {
        "operationId": "getArtifact",
        "summary": "A stored value by handle uri (url-encoded)",
        "parameters": [
          {
            "name": "uri",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The handle and the stored value.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "handle": {
                      "$ref": "#/components/schemas/ResourceHandle"
                    },
                    "value": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "handle",
                    "value"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown operation, job, or handle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        }
      }
    },
    "/capabilities": {
      "get": {
        "operationId": "capabilities",
        "summary": "Packs, budgets, the seed policy, and which stores are attached",
        "responses": {
          "200": {
            "description": "The capabilities.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "openapi",
        "summary": "This document",
        "responses": {
          "200": {
            "description": "The OpenAPI 3.1 document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "The input was refused (an input.* code).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Untrusted Host/Origin, missing server capability, or mutations disabled without a credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "OperationError": {
        "type": "object",
        "description": "Every non-2xx body: the same document the CLI prints and the MCP server returns.",
        "properties": {
          "code": {
            "type": "string",
            "description": "A registered TotalFinance error code (input.*, operation.*, …)"
          },
          "message": {
            "type": "string"
          },
          "context": {
            "type": "object"
          },
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          }
        },
        "required": [
          "code",
          "message",
          "context",
          "operation"
        ]
      },
      "ResourceHandle": {
        "type": "object",
        "properties": {
          "uri": {
            "type": "string",
            "pattern": "^totalfinance://(reports|jobs|portfolios|scenarios|markets|authorizations|journals)/"
          },
          "kind": {
            "type": "string",
            "enum": [
              "report",
              "job",
              "portfolio",
              "scenario",
              "market",
              "authorization",
              "journal"
            ]
          },
          "schema": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "contentHash": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdTimestampMs": {
            "type": "number"
          },
          "expiresTimestampMs": {
            "type": [
              "number",
              "null"
            ]
          },
          "provenance": {
            "type": "object"
          }
        },
        "required": [
          "uri",
          "kind",
          "schema",
          "version",
          "contentHash",
          "createdTimestampMs",
          "expiresTimestampMs",
          "provenance"
        ]
      },
      "JobRecord": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "accepted",
              "queued",
              "running",
              "completed",
              "failed",
              "cancelled"
            ]
          },
          "progress": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "stage": {
                "type": "string"
              },
              "fraction": {
                "type": [
                  "number",
                  "null"
                ]
              }
            }
          },
          "inputsHash": {
            "type": "string"
          },
          "seed": {
            "type": [
              "integer",
              "null"
            ]
          },
          "submittedAt": {
            "type": "string"
          },
          "startedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "finishedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "result": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ResourceHandle"
              },
              {
                "type": "null"
              }
            ]
          },
          "error": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/OperationError"
              },
              {
                "type": "null"
              }
            ]
          },
          "usage": {
            "type": "object",
            "properties": {
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            }
          }
        },
        "required": [
          "id",
          "operation",
          "state",
          "progress",
          "inputsHash",
          "seed",
          "submittedAt",
          "startedAt",
          "finishedAt",
          "result",
          "error",
          "usage"
        ]
      },
      "OperationDescription": {
        "type": "object",
        "description": "describeOperation(...) — the transport-neutral description every adapter renders.",
        "properties": {
          "id": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "inputSchema": {
            "type": "object"
          },
          "outputSchema": {
            "type": [
              "object",
              "null"
            ]
          },
          "sideEffect": {
            "type": "string",
            "enum": [
              "none",
              "portfolio-state",
              "external-order"
            ]
          },
          "authorization": {
            "type": "string",
            "enum": [
              "none",
              "policy",
              "human"
            ]
          },
          "idempotency": {
            "type": "string",
            "enum": [
              "not-applicable",
              "optional",
              "required"
            ]
          },
          "deterministic": {
            "type": "boolean"
          },
          "stochastic": {
            "oneOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string",
                "enum": [
                  "per-call"
                ]
              }
            ]
          },
          "costClass": {
            "type": "string",
            "enum": [
              "small",
              "medium",
              "large",
              "job"
            ]
          },
          "requiredCapabilities": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "supportsCancellation": {
            "type": "boolean"
          },
          "handleFields": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "annotations": {
            "type": "object",
            "properties": {
              "readOnlyHint": {
                "type": "boolean"
              },
              "destructiveHint": {
                "type": "boolean"
              },
              "idempotentHint": {
                "type": "boolean"
              },
              "openWorldHint": {
                "type": "boolean"
              }
            },
            "required": [
              "readOnlyHint",
              "destructiveHint",
              "idempotentHint",
              "openWorldHint"
            ]
          }
        },
        "required": [
          "id",
          "version",
          "title",
          "description",
          "inputSchema",
          "outputSchema",
          "sideEffect",
          "authorization",
          "idempotency",
          "deterministic",
          "stochastic",
          "costClass",
          "requiredCapabilities",
          "supportsCancellation",
          "handleFields",
          "annotations"
        ]
      },
      "OperationResult": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "type": "object"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.artifact.compare.input": {
        "type": "object",
        "properties": {
          "baseline": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.analysis-artifact",
                "type": "string"
              },
              "schemaVersion": {
                "type": "integer"
              },
              "id": {
                "type": "string"
              },
              "artifactType": {
                "type": "string"
              },
              "producedBy": {
                "type": "object",
                "properties": {
                  "operation": {
                    "type": "string"
                  },
                  "libraryVersion": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "operation"
                ]
              },
              "conventionsVersion": {
                "type": "string"
              },
              "inputs": {
                "type": "object",
                "properties": {
                  "inputsHash": {
                    "type": "string"
                  },
                  "snapshotHash": {
                    "type": "string"
                  },
                  "parameters": {}
                },
                "additionalProperties": false,
                "required": [
                  "inputsHash"
                ]
              },
              "createdFrom": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "result": {
                "type": "object",
                "additionalProperties": {}
              },
              "tables": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "additionalProperties": {}
                }
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  },
                  "dataset": {
                    "type": "string"
                  },
                  "asOf": {
                    "type": "number"
                  },
                  "receivedAt": {
                    "type": "number"
                  },
                  "sourceVersion": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "id",
              "artifactType",
              "producedBy",
              "conventionsVersion",
              "inputs",
              "result"
            ],
            "description": "A Gate B analysis artifact (totalfinance.analysis-artifact); hashes are re-verified by the read door"
          },
          "candidate": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.analysis-artifact",
                "type": "string"
              },
              "schemaVersion": {
                "type": "integer"
              },
              "id": {
                "type": "string"
              },
              "artifactType": {
                "type": "string"
              },
              "producedBy": {
                "type": "object",
                "properties": {
                  "operation": {
                    "type": "string"
                  },
                  "libraryVersion": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "operation"
                ]
              },
              "conventionsVersion": {
                "type": "string"
              },
              "inputs": {
                "type": "object",
                "properties": {
                  "inputsHash": {
                    "type": "string"
                  },
                  "snapshotHash": {
                    "type": "string"
                  },
                  "parameters": {}
                },
                "additionalProperties": false,
                "required": [
                  "inputsHash"
                ]
              },
              "createdFrom": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "result": {
                "type": "object",
                "additionalProperties": {}
              },
              "tables": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "additionalProperties": {}
                }
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  },
                  "dataset": {
                    "type": "string"
                  },
                  "asOf": {
                    "type": "number"
                  },
                  "receivedAt": {
                    "type": "number"
                  },
                  "sourceVersion": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "id",
              "artifactType",
              "producedBy",
              "conventionsVersion",
              "inputs",
              "result"
            ],
            "description": "A Gate B analysis artifact (totalfinance.analysis-artifact); hashes are re-verified by the read door"
          },
          "tolerance": {
            "type": "object",
            "properties": {
              "absolute": {
                "type": "number",
                "minimum": 0
              },
              "relative": {
                "type": "number",
                "minimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "absolute",
              "relative"
            ],
            "description": "Two-sided: a leaf is within it when |Δ| ≤ absolute + relative·|baseline|"
          },
          "limits": {
            "type": "object",
            "properties": {
              "maximumDifferences": {
                "type": "integer",
                "exclusiveMinimum": 0
              },
              "maximumLeaves": {
                "type": "integer",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false,
        "required": [
          "baseline",
          "candidate"
        ]
      },
      "totalfinance.artifact.compare.output": {
        "type": "object",
        "properties": {
          "artifactType": {
            "type": "string"
          },
          "identical": {
            "type": "boolean"
          },
          "artifactIds": {
            "type": "object"
          },
          "inputs": {
            "type": "object"
          },
          "producedBy": {
            "type": "object"
          },
          "result": {
            "type": "object"
          },
          "warningCounts": {
            "type": "object"
          },
          "withinTolerance": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "artifactType",
          "identical",
          "artifactIds",
          "inputs",
          "producedBy",
          "result",
          "warningCounts",
          "withinTolerance",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.artifact.compare.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.artifact.compare.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.artifact.read.input": {
        "type": "object",
        "properties": {
          "artifact": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.analysis-artifact",
                "type": "string"
              },
              "schemaVersion": {
                "type": "integer"
              },
              "id": {
                "type": "string"
              },
              "artifactType": {
                "type": "string"
              },
              "producedBy": {
                "type": "object",
                "properties": {
                  "operation": {
                    "type": "string"
                  },
                  "libraryVersion": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "operation"
                ]
              },
              "conventionsVersion": {
                "type": "string"
              },
              "inputs": {
                "type": "object",
                "properties": {
                  "inputsHash": {
                    "type": "string"
                  },
                  "snapshotHash": {
                    "type": "string"
                  },
                  "parameters": {}
                },
                "additionalProperties": false,
                "required": [
                  "inputsHash"
                ]
              },
              "createdFrom": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "result": {
                "type": "object",
                "additionalProperties": {}
              },
              "tables": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "additionalProperties": {}
                }
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  },
                  "dataset": {
                    "type": "string"
                  },
                  "asOf": {
                    "type": "number"
                  },
                  "receivedAt": {
                    "type": "number"
                  },
                  "sourceVersion": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "id",
              "artifactType",
              "producedBy",
              "conventionsVersion",
              "inputs",
              "result"
            ],
            "description": "A Gate B analysis artifact (totalfinance.analysis-artifact); hashes are re-verified by the read door"
          }
        },
        "additionalProperties": false,
        "required": [
          "artifact"
        ]
      },
      "totalfinance.artifact.read.output": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "artifactType": {
            "type": "string"
          },
          "schemaVersion": {
            "type": "integer"
          },
          "producedBy": {
            "type": "object"
          },
          "conventionsVersion": {
            "type": "string"
          },
          "inputs": {
            "type": "object"
          },
          "createdFrom": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tables": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "preview": {
            "type": "object",
            "description": "Top-level keys; scalars inline, containers by size"
          },
          "migrationsApplied": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        },
        "required": [
          "id",
          "artifactType",
          "schemaVersion",
          "producedBy",
          "conventionsVersion",
          "inputs",
          "createdFrom",
          "tables",
          "warnings",
          "preview",
          "migrationsApplied"
        ]
      },
      "totalfinance.artifact.read.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.artifact.read.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.backtest.cross_sectional_run.input": {
        "type": "object",
        "properties": {
          "dataset": {
            "type": "object",
            "properties": {
              "observations": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "instrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "availableTimestampMs": {
                      "type": "number"
                    },
                    "fields": {
                      "type": "object",
                      "additionalProperties": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "string"
                          },
                          {
                            "type": "boolean"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "description": "Declared fields only; null is a stated missing value"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "instrumentId",
                    "availableTimestampMs",
                    "fields"
                  ]
                }
              },
              "fieldDefinitions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "fieldName": {
                      "type": "string",
                      "minLength": 1
                    },
                    "kind": {
                      "type": "string",
                      "enum": [
                        "numeric",
                        "category",
                        "text",
                        "boolean"
                      ]
                    },
                    "unit": {
                      "type": "string"
                    },
                    "description": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "fieldName",
                    "kind"
                  ]
                },
                "minItems": 1
              },
              "returns": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "instrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "tradingSessionDate": {
                      "type": "string",
                      "format": "date"
                    },
                    "simpleReturn": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "instrumentId",
                    "tradingSessionDate",
                    "simpleReturn"
                  ]
                },
                "description": "Per instrument per session; prices are return-index levels (base 100)"
              },
              "benchmarkReturns": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "instrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "tradingSessionDate": {
                      "type": "string",
                      "format": "date"
                    },
                    "simpleReturn": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "instrumentId",
                    "tradingSessionDate",
                    "simpleReturn"
                  ]
                }
              },
              "groups": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              },
              "sizeField": {
                "type": "string"
              },
              "classification": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "additionalProperties": {}
                }
              },
              "averageDailyVolumes": {
                "type": "object",
                "additionalProperties": {
                  "type": "number"
                }
              },
              "betas": {
                "type": "object",
                "additionalProperties": {
                  "type": "number"
                }
              }
            },
            "additionalProperties": false,
            "required": [
              "observations",
              "fieldDefinitions",
              "returns"
            ]
          },
          "universeHistory": {
            "type": "object",
            "properties": {
              "universeId": {
                "type": "string",
                "minLength": 1
              },
              "members": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "instrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "fromTimestampMs": {
                      "type": "number"
                    },
                    "toTimestampMs": {
                      "type": "number"
                    },
                    "exitReason": {
                      "type": "string",
                      "enum": [
                        "removed",
                        "delisted",
                        "merged",
                        "other"
                      ]
                    },
                    "delistingReturn": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "instrumentId",
                    "fromTimestampMs"
                  ]
                },
                "minItems": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "universeId",
              "members"
            ]
          },
          "signal": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "factorRecipe": {
                    "type": "object",
                    "properties": {
                      "recipeName": {
                        "type": "string",
                        "minLength": 1
                      },
                      "recipeVersion": {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      },
                      "disclosure": {
                        "type": "string"
                      },
                      "direction": {
                        "type": "string",
                        "enum": [
                          "higher-is-better",
                          "lower-is-better"
                        ]
                      },
                      "features": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "field": {
                              "type": "string",
                              "minLength": 1
                            },
                            "transform": {
                              "type": "string",
                              "enum": [
                                "raw",
                                "winsorize-then-z-score",
                                "percentile-rank"
                              ]
                            },
                            "weight": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "field",
                            "transform",
                            "weight"
                          ]
                        },
                        "minItems": 1
                      },
                      "lagTradingSessions": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "neutralization": {
                        "type": "string",
                        "enum": [
                          "none",
                          "sector",
                          "sector-and-size"
                        ]
                      },
                      "missingValuePolicy": {
                        "type": "string",
                        "enum": [
                          "exclude",
                          "renormalize-weights"
                        ]
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "recipeName",
                      "recipeVersion",
                      "disclosure",
                      "direction",
                      "features",
                      "lagTradingSessions",
                      "neutralization",
                      "missingValuePolicy"
                    ],
                    "description": "A versioned research FactorRecipe (canonical or caller-authored), validated by the engine"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "factorRecipe"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "score": {
                    "type": "object",
                    "properties": {
                      "components": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "field": {
                              "type": "string"
                            },
                            "weight": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            },
                            "direction": {
                              "type": "string",
                              "enum": [
                                "higher-is-better",
                                "lower-is-better"
                              ]
                            },
                            "standardization": {
                              "type": "string",
                              "enum": [
                                "z-score",
                                "percentile-rank"
                              ]
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "field",
                            "weight",
                            "direction",
                            "standardization"
                          ]
                        },
                        "minItems": 1
                      },
                      "missingValuePolicy": {
                        "type": "string",
                        "enum": [
                          "exclude",
                          "renormalize-weights"
                        ]
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "components",
                      "missingValuePolicy"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "score"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "screen": {
                    "type": "object",
                    "properties": {
                      "filter": {
                        "type": "object",
                        "additionalProperties": {}
                      },
                      "orderBy": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "field": {
                              "type": "string"
                            },
                            "direction": {
                              "type": "string",
                              "enum": [
                                "ascending",
                                "descending"
                              ]
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "field",
                            "direction"
                          ]
                        },
                        "minItems": 1
                      },
                      "missingValuePolicy": {
                        "type": "string",
                        "enum": [
                          "exclude",
                          "evaluate-as-false"
                        ]
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "orderBy",
                      "missingValuePolicy"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "screen"
                ]
              }
            ],
            "description": "The three declarative signal forms; a signal callback is SDK-only"
          },
          "rebalanceSchedule": {
            "type": "object",
            "properties": {
              "frequency": {
                "type": "string",
                "enum": [
                  "daily",
                  "weekly",
                  "monthly",
                  "quarterly"
                ]
              },
              "session": {
                "type": "string",
                "enum": [
                  "open",
                  "close"
                ]
              },
              "bufferBand": {
                "type": "number",
                "minimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "frequency",
              "session"
            ]
          },
          "portfolioConstruction": {
            "type": "object",
            "properties": {
              "method": {
                "type": "string",
                "enum": [
                  "equal-weight",
                  "score-weight",
                  "inverse-volatility",
                  "risk-budget"
                ],
                "description": "'supplied-weights' takes a caller function and is SDK-only"
              },
              "long": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "topQuantile": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "topQuantile"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "count": {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "count"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "fraction": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "fraction"
                    ]
                  }
                ]
              },
              "short": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "bottomQuantile": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "bottomQuantile"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "count": {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "count"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "fraction": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "fraction"
                    ]
                  }
                ]
              },
              "neutrality": {
                "type": "string",
                "enum": [
                  "none",
                  "dollar",
                  "sector",
                  "beta",
                  "factor"
                ]
              },
              "neutralizeAgainst": {
                "type": "object",
                "properties": {
                  "field": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false,
                "required": [
                  "field"
                ]
              },
              "maximumPositions": {
                "type": "integer",
                "exclusiveMinimum": 0
              },
              "maximumPositionWeight": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "minimumPositionWeight": {
                "type": "number",
                "minimum": 0
              },
              "maximumTurnover": {
                "type": "number",
                "minimum": 0
              },
              "maximumParticipation": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "volatilityLookbackSessions": {
                "type": "integer",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "method",
              "long"
            ]
          },
          "execution": {
            "type": "object",
            "properties": {
              "label": {
                "type": "string",
                "minLength": 1
              },
              "ambiguity": {
                "type": "string",
                "enum": [
                  "optimistic",
                  "pessimistic",
                  "deterministic-path",
                  "reject"
                ]
              },
              "costs": {
                "type": "object",
                "properties": {
                  "commission": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "none",
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "bps",
                            "type": "string"
                          },
                          "bps": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "bps"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "perShare",
                            "type": "string"
                          },
                          "amountPerShare": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "amountPerShare"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "fixed",
                            "type": "string"
                          },
                          "amount": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "amount"
                        ]
                      }
                    ],
                    "description": "A declarative commission model (fees.none / bps / perShare / fixed)"
                  },
                  "slippage": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "none",
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "bps",
                            "type": "string"
                          },
                          "bps": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "bps"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "fixed",
                            "type": "string"
                          },
                          "perShare": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "perShare"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "spread",
                            "type": "string"
                          },
                          "spread": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "spread"
                        ]
                      }
                    ],
                    "description": "A declarative slippage model (slippage.none / bps / fixed / spread)"
                  },
                  "spread": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "none",
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "halfSpreadBps",
                            "type": "string"
                          },
                          "bps": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "bps"
                        ]
                      }
                    ]
                  },
                  "marketImpact": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "none",
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "squareRoot",
                            "type": "string"
                          },
                          "coefficient": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "coefficient"
                        ]
                      }
                    ]
                  },
                  "latencySessions": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "participation": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  }
                },
                "additionalProperties": false
              },
              "partialFills": {
                "type": "string",
                "enum": [
                  "allow",
                  "reject"
                ]
              },
              "timeInForce": {
                "type": "object",
                "properties": {
                  "default": {
                    "type": "string",
                    "enum": [
                      "day",
                      "gtc"
                    ]
                  },
                  "expireAtSessionClose": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "default",
                  "expireAtSessionClose"
                ]
              },
              "margin": {
                "type": "object",
                "properties": {
                  "buyingPowerMultiplier": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "initialMarginRate": {
                    "type": "number",
                    "minimum": 0
                  },
                  "maintenanceMarginRate": {
                    "type": "number",
                    "minimum": 0
                  },
                  "forcedLiquidation": {
                    "type": "string",
                    "enum": [
                      "none",
                      "close-largest-loss",
                      "pro-rata"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "buyingPowerMultiplier",
                  "initialMarginRate",
                  "maintenanceMarginRate",
                  "forcedLiquidation"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "label"
            ],
            "description": "A declared execution policy over session bars (execution.declared): the label is the caller's claim; a caller fill model, session rules, and quote/order-book observations are SDK-only"
          },
          "transactionCostModel": {
            "type": "object",
            "properties": {
              "commission": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "none",
                        "type": "string"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "bps",
                        "type": "string"
                      },
                      "bps": {
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model",
                      "bps"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "perShare",
                        "type": "string"
                      },
                      "amountPerShare": {
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model",
                      "amountPerShare"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "fixed",
                        "type": "string"
                      },
                      "amount": {
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model",
                      "amount"
                    ]
                  }
                ],
                "description": "A declarative commission model (fees.none / bps / perShare / fixed)"
              },
              "slippage": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "none",
                        "type": "string"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "bps",
                        "type": "string"
                      },
                      "bps": {
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model",
                      "bps"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "fixed",
                        "type": "string"
                      },
                      "perShare": {
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model",
                      "perShare"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "spread",
                        "type": "string"
                      },
                      "spread": {
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model",
                      "spread"
                    ]
                  }
                ],
                "description": "A declarative slippage model (slippage.none / bps / fixed / spread)"
              }
            },
            "additionalProperties": false
          },
          "initialCapital": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Default 1,000,000"
          },
          "baseCurrency": {
            "type": "string",
            "minLength": 1,
            "description": "Default 'USD'"
          },
          "window": {
            "type": "object",
            "properties": {
              "fromTimestampMs": {
                "type": "number"
              },
              "toTimestampMs": {
                "type": "number"
              }
            },
            "additionalProperties": false
          },
          "periodsPerYear": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Default 252"
          },
          "riskFreeRate": {
            "type": "number",
            "description": "Per-period; default 0"
          },
          "seed": {
            "type": "integer",
            "minimum": 0,
            "description": "Seeds only the bootstrap confidence intervals; absent = none"
          }
        },
        "additionalProperties": false,
        "required": [
          "dataset",
          "universeHistory",
          "signal",
          "rebalanceSchedule",
          "portfolioConstruction"
        ]
      },
      "totalfinance.backtest.cross_sectional_run.output": {
        "type": "object",
        "properties": {
          "rebalances": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "holdings": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "points": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "returns": {
            "type": "array",
            "items": {
              "type": "number"
            }
          },
          "trades": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "fills": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "ledger": {
            "type": "object",
            "description": "The portfolio ledger snapshot (events)"
          },
          "timeline": {
            "type": "object",
            "description": "The ledger timeline"
          },
          "attribution": {
            "type": "object"
          },
          "benchmark": {
            "type": [
              "object",
              "null"
            ]
          },
          "performance": {
            "type": "object",
            "description": "The standard performance summary"
          },
          "performanceConfidence": {
            "type": [
              "object",
              "null"
            ]
          },
          "finalValue": {
            "type": "number"
          },
          "runId": {
            "type": "string"
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "rebalances",
          "holdings",
          "points",
          "returns",
          "trades",
          "fills",
          "ledger",
          "timeline",
          "attribution",
          "benchmark",
          "performance",
          "performanceConfidence",
          "finalValue",
          "runId",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.backtest.cross_sectional_run.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.backtest.cross_sectional_run.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.backtest.environment_episode.input": {
        "type": "object",
        "properties": {
          "episode": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "trending",
                  "mean-reverting",
                  "range-bound",
                  "volatility-expansion",
                  "volatility-contraction",
                  "overnight-gaps",
                  "limit-moves",
                  "stale-data",
                  "missing-data",
                  "duplicated-data",
                  "corrected-data",
                  "out-of-order-data",
                  "wide-spreads",
                  "thin-liquidity",
                  "option-expiration",
                  "margin-pressure",
                  "retry-storm",
                  "corporate-actions",
                  "multi-currency",
                  "model-market-disagreement"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1
                  },
                  "definition": {
                    "type": "object",
                    "properties": {
                      "accounting": {
                        "type": "object",
                        "properties": {
                          "baseCurrency": {
                            "type": "string",
                            "minLength": 1
                          },
                          "initialCash": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "currency": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "amount": {
                                  "type": "number",
                                  "exclusiveMinimum": 0
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "currency",
                                "amount"
                              ]
                            },
                            "minItems": 1
                          },
                          "lotRelief": {
                            "type": "string",
                            "enum": [
                              "fifo",
                              "lifo",
                              "highest-cost",
                              "specific-lot"
                            ]
                          },
                          "settlement": {
                            "type": "object",
                            "additionalProperties": {
                              "type": "string",
                              "enum": [
                                "T+0",
                                "T+1",
                                "T+2"
                              ]
                            }
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "baseCurrency",
                          "initialCash"
                        ]
                      },
                      "instruments": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "enum": [
                                "equity",
                                "etf",
                                "option",
                                "future",
                                "fx-forward",
                                "crypto-spot",
                                "crypto-perpetual",
                                "bond"
                              ],
                              "description": "A built-in kind; 'custom' brings its own adapter and is SDK-only"
                            },
                            "currency": {
                              "type": "string",
                              "minLength": 1
                            },
                            "contractMultiplier": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            },
                            "contract": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "const": "option",
                                      "type": "string"
                                    },
                                    "underlyingInstrumentId": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "right": {
                                      "type": "string",
                                      "enum": [
                                        "call",
                                        "put"
                                      ]
                                    },
                                    "strikePricePerUnit": {
                                      "type": "number",
                                      "exclusiveMinimum": 0
                                    },
                                    "expiryTimestampMs": {
                                      "type": "number"
                                    }
                                  },
                                  "additionalProperties": false,
                                  "required": [
                                    "kind",
                                    "underlyingInstrumentId",
                                    "right",
                                    "strikePricePerUnit",
                                    "expiryTimestampMs"
                                  ]
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "const": "future",
                                      "type": "string"
                                    },
                                    "underlyingInstrumentId": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "expiryTimestampMs": {
                                      "type": "number"
                                    }
                                  },
                                  "additionalProperties": false,
                                  "required": [
                                    "kind",
                                    "underlyingInstrumentId",
                                    "expiryTimestampMs"
                                  ]
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "const": "perpetual",
                                      "type": "string"
                                    },
                                    "underlyingInstrumentId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "additionalProperties": false,
                                  "required": [
                                    "kind",
                                    "underlyingInstrumentId"
                                  ]
                                }
                              ]
                            },
                            "assetClass": {
                              "type": "string",
                              "enum": [
                                "equity",
                                "etf",
                                "option",
                                "future",
                                "fx-forward",
                                "crypto-spot",
                                "crypto-perpetual",
                                "bond",
                                "cash"
                              ]
                            },
                            "classification": {
                              "type": "object",
                              "properties": {
                                "underlying": {
                                  "type": "string"
                                },
                                "assetClass": {
                                  "type": "string"
                                },
                                "strategy": {
                                  "type": "string"
                                },
                                "tags": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "additionalProperties": false
                            },
                            "roll": {
                              "type": "object",
                              "properties": {
                                "toInstrumentId": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "sessionsBeforeExpiry": {
                                  "type": "integer",
                                  "minimum": 0
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "toInstrumentId",
                                "sessionsBeforeExpiry"
                              ]
                            },
                            "coupon": {
                              "type": "object",
                              "properties": {
                                "annualRate": {
                                  "type": "number"
                                },
                                "paymentsPerYear": {
                                  "type": "integer",
                                  "exclusiveMinimum": 0
                                },
                                "faceValuePerUnit": {
                                  "type": "number",
                                  "exclusiveMinimum": 0
                                },
                                "dayCount": {
                                  "type": "string",
                                  "enum": [
                                    "ACT/365F",
                                    "30/360"
                                  ]
                                },
                                "issueDate": {
                                  "type": "string",
                                  "format": "date"
                                },
                                "maturityDate": {
                                  "type": "string",
                                  "format": "date"
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "annualRate",
                                "paymentsPerYear",
                                "issueDate",
                                "maturityDate"
                              ]
                            },
                            "forward": {
                              "type": "object",
                              "properties": {
                                "maturityTimestampMs": {
                                  "type": "number"
                                },
                                "baseCurrency": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "quoteCurrency": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "contractRate": {
                                  "type": "number",
                                  "exclusiveMinimum": 0
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "maturityTimestampMs",
                                "baseCurrency",
                                "quoteCurrency",
                                "contractRate"
                              ]
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "kind",
                            "currency"
                          ],
                          "description": "An instrument specification; the terms each kind needs are validated by the engine"
                        }
                      },
                      "marketData": {
                        "type": "object",
                        "properties": {
                          "bars": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "symbol": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "timestampMs": {
                                  "type": "number"
                                },
                                "open": {
                                  "type": "number"
                                },
                                "high": {
                                  "type": "number"
                                },
                                "low": {
                                  "type": "number"
                                },
                                "close": {
                                  "type": "number"
                                },
                                "volume": {
                                  "type": "number"
                                },
                                "vwap": {
                                  "type": "number"
                                },
                                "adjusted": {
                                  "type": "boolean"
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "symbol",
                                "timestampMs",
                                "open",
                                "high",
                                "low",
                                "close"
                              ]
                            }
                          },
                          "quotes": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "symbol": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "timestampMs": {
                                  "type": "number"
                                },
                                "bid": {
                                  "type": "number"
                                },
                                "ask": {
                                  "type": "number"
                                },
                                "bidSize": {
                                  "type": "number"
                                },
                                "askSize": {
                                  "type": "number"
                                },
                                "exchange": {
                                  "type": "string"
                                },
                                "conditions": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "symbol",
                                "timestampMs",
                                "bid",
                                "ask"
                              ]
                            }
                          },
                          "trades": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "symbol": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "timestampMs": {
                                  "type": "number"
                                },
                                "price": {
                                  "type": "number"
                                },
                                "size": {
                                  "type": "number"
                                },
                                "exchange": {
                                  "type": "string"
                                },
                                "conditions": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                },
                                "sequence": {
                                  "type": "number"
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "symbol",
                                "timestampMs",
                                "price",
                                "size"
                              ]
                            }
                          },
                          "orderBooks": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "symbol": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "timestampMs": {
                                  "type": "number"
                                },
                                "bids": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "price": {
                                        "type": "number"
                                      },
                                      "size": {
                                        "type": "number"
                                      },
                                      "exchange": {
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false,
                                    "required": [
                                      "price",
                                      "size"
                                    ]
                                  }
                                },
                                "asks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "price": {
                                        "type": "number"
                                      },
                                      "size": {
                                        "type": "number"
                                      },
                                      "exchange": {
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false,
                                    "required": [
                                      "price",
                                      "size"
                                    ]
                                  }
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "symbol",
                                "timestampMs",
                                "bids",
                                "asks"
                              ]
                            }
                          },
                          "optionChains": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "asOf": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "string"
                                    }
                                  ],
                                  "description": "Epoch ms, YYYY-MM-DD, or a zoned ISO datetime"
                                },
                                "underlyingPrice": {
                                  "type": "number",
                                  "exclusiveMinimum": 0
                                },
                                "quotes": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "contract": {
                                        "type": "object",
                                        "properties": {
                                          "underlying": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "call",
                                              "put"
                                            ]
                                          },
                                          "style": {
                                            "type": "string",
                                            "enum": [
                                              "european",
                                              "american"
                                            ]
                                          },
                                          "strike": {
                                            "type": "number",
                                            "exclusiveMinimum": 0
                                          },
                                          "expiry": {
                                            "type": "string",
                                            "pattern": "^\\d{4}-\\d{2}-\\d{2}([Tt ]\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?([Zz]|[+-]\\d{2}:?\\d{2}))?$",
                                            "description": "Display label: 'YYYY-MM-DD' or a zoned ISO datetime (matches the builders)"
                                          },
                                          "expiresAt": {
                                            "type": "number",
                                            "description": "Resolved expiration instant (epoch ms) — stamped by the builders"
                                          },
                                          "expiryConvention": {
                                            "type": "string",
                                            "enum": [
                                              "us-equity-close",
                                              "explicit-instant"
                                            ],
                                            "description": "How the label resolved to the instant"
                                          },
                                          "multiplier": {
                                            "type": "number",
                                            "exclusiveMinimum": 0
                                          },
                                          "settlement": {
                                            "type": "string",
                                            "enum": [
                                              "physical",
                                              "cash"
                                            ]
                                          },
                                          "exerciseTime": {
                                            "type": "string",
                                            "enum": [
                                              "AM",
                                              "PM"
                                            ]
                                          },
                                          "currency": {
                                            "type": "string"
                                          },
                                          "root": {
                                            "type": "string"
                                          },
                                          "occSymbol": {
                                            "type": "string"
                                          },
                                          "deliverable": {
                                            "type": "object",
                                            "properties": {
                                              "cash": {
                                                "type": "number"
                                              },
                                              "shares": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "properties": {
                                                    "symbol": {
                                                      "type": "string",
                                                      "minLength": 1
                                                    },
                                                    "quantity": {
                                                      "type": "number"
                                                    }
                                                  },
                                                  "additionalProperties": false,
                                                  "required": [
                                                    "symbol",
                                                    "quantity"
                                                  ]
                                                }
                                              },
                                              "notes": {
                                                "type": "string"
                                              }
                                            },
                                            "additionalProperties": false
                                          },
                                          "adjusted": {
                                            "type": "boolean"
                                          }
                                        },
                                        "additionalProperties": false,
                                        "required": [
                                          "underlying",
                                          "type",
                                          "style",
                                          "strike",
                                          "expiry",
                                          "expiresAt",
                                          "expiryConvention"
                                        ]
                                      },
                                      "timestampMs": {
                                        "type": "number"
                                      },
                                      "bid": {
                                        "type": "number"
                                      },
                                      "ask": {
                                        "type": "number"
                                      },
                                      "bidSize": {
                                        "type": "number",
                                        "minimum": 0
                                      },
                                      "askSize": {
                                        "type": "number",
                                        "minimum": 0
                                      },
                                      "mid": {
                                        "type": "number"
                                      },
                                      "last": {
                                        "type": "number"
                                      },
                                      "mark": {
                                        "type": "number"
                                      },
                                      "volume": {
                                        "type": "number",
                                        "minimum": 0
                                      },
                                      "openInterest": {
                                        "type": "number",
                                        "minimum": 0
                                      },
                                      "underlyingPrice": {
                                        "type": "number",
                                        "exclusiveMinimum": 0
                                      },
                                      "impliedVolatility": {
                                        "type": "number",
                                        "minimum": 0
                                      },
                                      "greeks": {
                                        "type": "object",
                                        "properties": {
                                          "delta": {
                                            "type": "number"
                                          },
                                          "gamma": {
                                            "type": "number"
                                          },
                                          "theta": {
                                            "type": "number"
                                          },
                                          "vega": {
                                            "type": "number"
                                          },
                                          "rho": {
                                            "type": "number"
                                          },
                                          "provenance": {
                                            "type": "object",
                                            "properties": {
                                              "source": {
                                                "type": "string"
                                              },
                                              "model": {
                                                "type": "string"
                                              },
                                              "timestampMs": {
                                                "type": "number"
                                              }
                                            },
                                            "additionalProperties": false,
                                            "required": [
                                              "source"
                                            ]
                                          }
                                        },
                                        "additionalProperties": false,
                                        "required": [
                                          "delta"
                                        ],
                                        "description": "Per-share Greeks in display units (theta per day, vega per vol point, rho per 1%), with optional provenance"
                                      },
                                      "exchange": {
                                        "type": "string"
                                      },
                                      "conditions": {
                                        "type": "array",
                                        "items": {
                                          "type": "string"
                                        }
                                      }
                                    },
                                    "additionalProperties": false,
                                    "required": [
                                      "contract",
                                      "timestampMs"
                                    ]
                                  }
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "asOf",
                                "underlyingPrice",
                                "quotes"
                              ]
                            }
                          },
                          "fxRates": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "timestampMs": {
                                  "type": "number"
                                },
                                "baseCurrency": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "quoteCurrency": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "quotePerBase": {
                                  "type": "number",
                                  "exclusiveMinimum": 0
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "timestampMs",
                                "baseCurrency",
                                "quoteCurrency",
                                "quotePerBase"
                              ]
                            }
                          },
                          "forwardRates": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "instrumentId": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "timestampMs": {
                                  "type": "number"
                                },
                                "forwardRate": {
                                  "type": "number",
                                  "exclusiveMinimum": 0
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "instrumentId",
                                "timestampMs",
                                "forwardRate"
                              ]
                            }
                          },
                          "fundingRates": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "instrumentId": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "timestampMs": {
                                  "type": "number"
                                },
                                "fundingRate": {
                                  "type": "number"
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "instrumentId",
                                "timestampMs",
                                "fundingRate"
                              ]
                            }
                          },
                          "corporateActions": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "symbol": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "effectiveDate": {
                                  "type": "string",
                                  "format": "date"
                                },
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "split",
                                    "reverseSplit",
                                    "dividend",
                                    "symbolChange",
                                    "merger",
                                    "spinoff",
                                    "other"
                                  ]
                                },
                                "ratio": {
                                  "type": "number",
                                  "exclusiveMinimum": 0
                                },
                                "cash": {
                                  "type": "number"
                                },
                                "newSymbol": {
                                  "type": "string"
                                },
                                "details": {
                                  "type": "object",
                                  "additionalProperties": {}
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "symbol",
                                "effectiveDate",
                                "type"
                              ]
                            }
                          },
                          "dividends": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "instrumentId": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "exDate": {
                                  "type": "string",
                                  "format": "date"
                                },
                                "amount": {
                                  "type": "number",
                                  "exclusiveMinimum": 0
                                },
                                "payDate": {
                                  "type": "string",
                                  "format": "date"
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "instrumentId",
                                "exDate",
                                "amount"
                              ]
                            }
                          },
                          "coupons": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "instrumentId": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "paymentDate": {
                                  "type": "string",
                                  "format": "date"
                                },
                                "amountPerUnit": {
                                  "type": "number",
                                  "exclusiveMinimum": 0
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "instrumentId",
                                "paymentDate",
                                "amountPerUnit"
                              ]
                            }
                          }
                        },
                        "additionalProperties": false
                      },
                      "execution": {
                        "type": "object",
                        "properties": {
                          "label": {
                            "type": "string",
                            "minLength": 1
                          },
                          "ambiguity": {
                            "type": "string",
                            "enum": [
                              "optimistic",
                              "pessimistic",
                              "deterministic-path",
                              "reject"
                            ]
                          },
                          "costs": {
                            "type": "object",
                            "properties": {
                              "commission": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "const": "none",
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false,
                                    "required": [
                                      "model"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "const": "bps",
                                        "type": "string"
                                      },
                                      "bps": {
                                        "type": "number",
                                        "minimum": 0
                                      }
                                    },
                                    "additionalProperties": false,
                                    "required": [
                                      "model",
                                      "bps"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "const": "perShare",
                                        "type": "string"
                                      },
                                      "amountPerShare": {
                                        "type": "number",
                                        "minimum": 0
                                      }
                                    },
                                    "additionalProperties": false,
                                    "required": [
                                      "model",
                                      "amountPerShare"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "const": "fixed",
                                        "type": "string"
                                      },
                                      "amount": {
                                        "type": "number",
                                        "minimum": 0
                                      }
                                    },
                                    "additionalProperties": false,
                                    "required": [
                                      "model",
                                      "amount"
                                    ]
                                  }
                                ],
                                "description": "A declarative commission model (fees.none / bps / perShare / fixed)"
                              },
                              "slippage": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "const": "none",
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false,
                                    "required": [
                                      "model"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "const": "bps",
                                        "type": "string"
                                      },
                                      "bps": {
                                        "type": "number",
                                        "minimum": 0
                                      }
                                    },
                                    "additionalProperties": false,
                                    "required": [
                                      "model",
                                      "bps"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "const": "fixed",
                                        "type": "string"
                                      },
                                      "perShare": {
                                        "type": "number",
                                        "minimum": 0
                                      }
                                    },
                                    "additionalProperties": false,
                                    "required": [
                                      "model",
                                      "perShare"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "const": "spread",
                                        "type": "string"
                                      },
                                      "spread": {
                                        "type": "number",
                                        "minimum": 0
                                      }
                                    },
                                    "additionalProperties": false,
                                    "required": [
                                      "model",
                                      "spread"
                                    ]
                                  }
                                ],
                                "description": "A declarative slippage model (slippage.none / bps / fixed / spread)"
                              },
                              "spread": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "const": "none",
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false,
                                    "required": [
                                      "model"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "const": "halfSpreadBps",
                                        "type": "string"
                                      },
                                      "bps": {
                                        "type": "number",
                                        "minimum": 0
                                      }
                                    },
                                    "additionalProperties": false,
                                    "required": [
                                      "model",
                                      "bps"
                                    ]
                                  }
                                ]
                              },
                              "marketImpact": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "const": "none",
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false,
                                    "required": [
                                      "model"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "const": "squareRoot",
                                        "type": "string"
                                      },
                                      "coefficient": {
                                        "type": "number",
                                        "minimum": 0
                                      }
                                    },
                                    "additionalProperties": false,
                                    "required": [
                                      "model",
                                      "coefficient"
                                    ]
                                  }
                                ]
                              },
                              "latencySessions": {
                                "type": "integer",
                                "minimum": 0
                              },
                              "participation": {
                                "type": "number",
                                "exclusiveMinimum": 0
                              }
                            },
                            "additionalProperties": false
                          },
                          "partialFills": {
                            "type": "string",
                            "enum": [
                              "allow",
                              "reject"
                            ]
                          },
                          "timeInForce": {
                            "type": "object",
                            "properties": {
                              "default": {
                                "type": "string",
                                "enum": [
                                  "day",
                                  "gtc"
                                ]
                              },
                              "expireAtSessionClose": {
                                "type": "boolean"
                              }
                            },
                            "additionalProperties": false,
                            "required": [
                              "default",
                              "expireAtSessionClose"
                            ]
                          },
                          "margin": {
                            "type": "object",
                            "properties": {
                              "buyingPowerMultiplier": {
                                "type": "number",
                                "exclusiveMinimum": 0
                              },
                              "initialMarginRate": {
                                "type": "number",
                                "minimum": 0
                              },
                              "maintenanceMarginRate": {
                                "type": "number",
                                "minimum": 0
                              },
                              "forcedLiquidation": {
                                "type": "string",
                                "enum": [
                                  "none",
                                  "close-largest-loss",
                                  "pro-rata"
                                ]
                              }
                            },
                            "additionalProperties": false,
                            "required": [
                              "buyingPowerMultiplier",
                              "initialMarginRate",
                              "maintenanceMarginRate",
                              "forcedLiquidation"
                            ]
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "label"
                        ],
                        "description": "A declared execution policy over session bars (execution.declared): the label is the caller's claim; a caller fill model, session rules, and quote/order-book observations are SDK-only"
                      },
                      "externalFlows": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "number"
                            },
                            "amount": {
                              "type": "number"
                            },
                            "currency": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "timestampMs",
                            "amount",
                            "currency"
                          ]
                        }
                      },
                      "calendar": {
                        "type": "string",
                        "enum": [
                          "NYSE",
                          "CBOE",
                          "ALWAYS_OPEN"
                        ]
                      },
                      "window": {
                        "type": "object",
                        "properties": {
                          "fromTimestampMs": {
                            "type": "number"
                          },
                          "toTimestampMs": {
                            "type": "number"
                          }
                        },
                        "additionalProperties": false
                      },
                      "periodsPerYear": {
                        "type": "number",
                        "exclusiveMinimum": 0,
                        "description": "Default 252"
                      },
                      "seed": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "maximumSteps": {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      },
                      "limits": {
                        "type": "object",
                        "properties": {
                          "maximumPositionWeight": {
                            "type": "number",
                            "maximum": 1,
                            "exclusiveMinimum": 0
                          },
                          "maximumGrossLeverage": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          },
                          "maximumDrawdown": {
                            "type": "number",
                            "maximum": 1,
                            "exclusiveMinimum": 0
                          },
                          "maximumDailyLoss": {
                            "type": "number",
                            "maximum": 1,
                            "exclusiveMinimum": 0
                          },
                          "maximumDaysToLiquidate": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          },
                          "minimumSettledCash": {
                            "type": "number"
                          },
                          "allowUndefinedRiskOptions": {
                            "type": "boolean"
                          },
                          "maximumPositionNotional": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          },
                          "onBreach": {
                            "type": "string",
                            "enum": [
                              "terminate",
                              "reject-and-continue"
                            ]
                          }
                        },
                        "additionalProperties": false
                      },
                      "reward": {
                        "type": "object",
                        "properties": {
                          "pnl": {
                            "type": "number"
                          },
                          "drawdown": {
                            "type": "number"
                          },
                          "turnover": {
                            "type": "number"
                          },
                          "cost": {
                            "type": "number"
                          },
                          "concentration": {
                            "type": "number"
                          },
                          "leverage": {
                            "type": "number"
                          },
                          "riskViolation": {
                            "type": "number"
                          },
                          "benchmark": {
                            "type": "object",
                            "properties": {
                              "weight": {
                                "type": "number"
                              },
                              "instrumentId": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "additionalProperties": false,
                            "required": [
                              "weight",
                              "instrumentId"
                            ]
                          }
                        },
                        "additionalProperties": false,
                        "description": "The declared reward composition; a goal callback is SDK-only"
                      },
                      "features": {
                        "type": "object",
                        "properties": {
                          "lookbackReturns": {
                            "type": "array",
                            "items": {
                              "type": "integer",
                              "exclusiveMinimum": 0
                            },
                            "minItems": 1
                          },
                          "realizedVolatility": {
                            "type": "object",
                            "properties": {
                              "lookbacks": {
                                "type": "array",
                                "items": {
                                  "type": "integer",
                                  "exclusiveMinimum": 0
                                },
                                "minItems": 1
                              },
                              "annualization": {
                                "type": "number",
                                "exclusiveMinimum": 0,
                                "description": "Bars per year scaling the per-bar σ (252 daily, 52 weekly, 12 monthly; 1 = per-bar). Required: the environment never assumes the bar frequency."
                              }
                            },
                            "additionalProperties": false,
                            "required": [
                              "lookbacks",
                              "annualization"
                            ]
                          },
                          "drawdown": {
                            "type": "boolean"
                          }
                        },
                        "additionalProperties": false
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "accounting",
                      "instruments",
                      "marketData"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "id",
                  "definition"
                ]
              }
            ],
            "description": "A catalogue id, or a named declarative definition"
          },
          "policy": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "baseline": {
                    "const": "holdCash",
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "baseline"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "baseline": {
                    "const": "buyAndHold",
                    "type": "string"
                  },
                  "weights": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number",
                      "minimum": 0
                    }
                  }
                },
                "additionalProperties": false,
                "required": [
                  "baseline"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "baseline": {
                    "const": "periodicRebalance",
                    "type": "string"
                  },
                  "everySessions": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  },
                  "weights": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number",
                      "minimum": 0
                    }
                  }
                },
                "additionalProperties": false,
                "required": [
                  "baseline",
                  "everySessions"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "baseline": {
                    "const": "randomValidAction",
                    "type": "string"
                  },
                  "seed": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "baseline",
                  "seed"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "baseline": {
                    "const": "riskParity",
                    "type": "string"
                  },
                  "lookback": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  },
                  "everySessions": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "baseline",
                  "lookback"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "baseline": {
                    "const": "momentumCrossover",
                    "type": "string"
                  },
                  "fast": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  },
                  "slow": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "baseline",
                  "fast",
                  "slow"
                ]
              }
            ],
            "description": "A maintained baseline; a TypeScript policy is SDK-only"
          },
          "seed": {
            "type": "integer",
            "minimum": 0,
            "description": "Default 42"
          },
          "artifact": {
            "type": "string",
            "enum": [
              "none",
              "embed"
            ],
            "description": "Default 'none'; 'embed' returns the recorded episode as an `environment` run artifact"
          }
        },
        "additionalProperties": false,
        "required": [
          "episode",
          "policy"
        ]
      },
      "totalfinance.backtest.environment_episode.output": {
        "type": "object",
        "properties": {
          "policy": {
            "type": "string"
          },
          "episode": {
            "type": "object",
            "description": "The bench report for the one episode: operational and strategy blocks"
          },
          "trace": {
            "type": "object",
            "description": "The recorded episode: runId, engineRunId, traceHash, steps, rewardTotal, terminated, truncated, reason"
          },
          "artifact": {
            "type": [
              "object",
              "null"
            ],
            "description": "The `environment` run artifact when artifact is 'embed'"
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "policy",
          "episode",
          "trace",
          "artifact",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.backtest.environment_episode.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.backtest.environment_episode.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.backtest.options_run.input": {
        "type": "object",
        "properties": {
          "chains": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "asOf": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "string"
                    }
                  ],
                  "description": "Epoch ms, YYYY-MM-DD, or a zoned ISO datetime"
                },
                "underlyingPrice": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "quotes": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "contract": {
                        "type": "object",
                        "properties": {
                          "underlying": {
                            "type": "string",
                            "minLength": 1
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "call",
                              "put"
                            ]
                          },
                          "style": {
                            "type": "string",
                            "enum": [
                              "european",
                              "american"
                            ]
                          },
                          "strike": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          },
                          "expiry": {
                            "type": "string",
                            "pattern": "^\\d{4}-\\d{2}-\\d{2}([Tt ]\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?([Zz]|[+-]\\d{2}:?\\d{2}))?$",
                            "description": "Display label: 'YYYY-MM-DD' or a zoned ISO datetime (matches the builders)"
                          },
                          "expiresAt": {
                            "type": "number",
                            "description": "Resolved expiration instant (epoch ms) — stamped by the builders"
                          },
                          "expiryConvention": {
                            "type": "string",
                            "enum": [
                              "us-equity-close",
                              "explicit-instant"
                            ],
                            "description": "How the label resolved to the instant"
                          },
                          "multiplier": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          },
                          "settlement": {
                            "type": "string",
                            "enum": [
                              "physical",
                              "cash"
                            ]
                          },
                          "exerciseTime": {
                            "type": "string",
                            "enum": [
                              "AM",
                              "PM"
                            ]
                          },
                          "currency": {
                            "type": "string"
                          },
                          "root": {
                            "type": "string"
                          },
                          "occSymbol": {
                            "type": "string"
                          },
                          "deliverable": {
                            "type": "object",
                            "properties": {
                              "cash": {
                                "type": "number"
                              },
                              "shares": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "symbol": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "quantity": {
                                      "type": "number"
                                    }
                                  },
                                  "additionalProperties": false,
                                  "required": [
                                    "symbol",
                                    "quantity"
                                  ]
                                }
                              },
                              "notes": {
                                "type": "string"
                              }
                            },
                            "additionalProperties": false
                          },
                          "adjusted": {
                            "type": "boolean"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "underlying",
                          "type",
                          "style",
                          "strike",
                          "expiry",
                          "expiresAt",
                          "expiryConvention"
                        ]
                      },
                      "timestampMs": {
                        "type": "number"
                      },
                      "bid": {
                        "type": "number"
                      },
                      "ask": {
                        "type": "number"
                      },
                      "bidSize": {
                        "type": "number",
                        "minimum": 0
                      },
                      "askSize": {
                        "type": "number",
                        "minimum": 0
                      },
                      "mid": {
                        "type": "number"
                      },
                      "last": {
                        "type": "number"
                      },
                      "mark": {
                        "type": "number"
                      },
                      "volume": {
                        "type": "number",
                        "minimum": 0
                      },
                      "openInterest": {
                        "type": "number",
                        "minimum": 0
                      },
                      "underlyingPrice": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      },
                      "impliedVolatility": {
                        "type": "number",
                        "minimum": 0
                      },
                      "greeks": {
                        "type": "object",
                        "properties": {
                          "delta": {
                            "type": "number"
                          },
                          "gamma": {
                            "type": "number"
                          },
                          "theta": {
                            "type": "number"
                          },
                          "vega": {
                            "type": "number"
                          },
                          "rho": {
                            "type": "number"
                          },
                          "provenance": {
                            "type": "object",
                            "properties": {
                              "source": {
                                "type": "string"
                              },
                              "model": {
                                "type": "string"
                              },
                              "timestampMs": {
                                "type": "number"
                              }
                            },
                            "additionalProperties": false,
                            "required": [
                              "source"
                            ]
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "delta"
                        ],
                        "description": "Per-share Greeks in display units (theta per day, vega per vol point, rho per 1%), with optional provenance"
                      },
                      "exchange": {
                        "type": "string"
                      },
                      "conditions": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "contract",
                      "timestampMs"
                    ]
                  }
                }
              },
              "additionalProperties": false,
              "required": [
                "asOf",
                "underlyingPrice",
                "quotes"
              ]
            },
            "description": "Chain snapshots (any order; the engine sorts)"
          },
          "marking": {
            "type": "object",
            "properties": {
              "volatility": {
                "type": "string",
                "enum": [
                  "current-quote",
                  "entry"
                ]
              },
              "missingMark": {
                "type": "string",
                "enum": [
                  "refuse",
                  "entry-volatility",
                  "carry-last-volatility"
                ]
              },
              "maximumQuoteAgeMs": {
                "type": "number",
                "minimum": 0
              }
            },
            "additionalProperties": false,
            "description": "Default: re-mark from the current quote; refuse a missing mark"
          },
          "initialCapital": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Default 100,000"
          },
          "riskFreeRate": {
            "type": "number",
            "description": "Continuously-compounded risk-free rate (decimal, e.g. 0.045) pricing every mark — REQUIRED; the engine never assumes a rate"
          },
          "dividendYield": {
            "type": "number",
            "description": "Default 0"
          },
          "entry": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Names the rule in trades and rows"
                  },
                  "when": {
                    "type": "string",
                    "enum": [
                      "flat",
                      "always"
                    ],
                    "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
                  },
                  "daysToExpiry": {
                    "type": "object",
                    "properties": {
                      "target": {
                        "type": "number"
                      },
                      "min": {
                        "type": "number"
                      },
                      "max": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "target"
                    ]
                  },
                  "sizing": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "quantity": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "quantity"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "maxMarginFraction": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "maxMarginFraction"
                        ]
                      }
                    ],
                    "description": "Default { quantity: 1 }"
                  },
                  "price": {
                    "type": "string",
                    "enum": [
                      "bid",
                      "ask",
                      "mid",
                      "last",
                      "mark"
                    ]
                  },
                  "structure": {
                    "const": "ironCondor",
                    "type": "string"
                  },
                  "select": {
                    "type": "object",
                    "properties": {
                      "shortDelta": {
                        "type": "number"
                      },
                      "wingWidth": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "shortDelta",
                      "wingWidth"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "daysToExpiry",
                  "structure",
                  "select"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Names the rule in trades and rows"
                  },
                  "when": {
                    "type": "string",
                    "enum": [
                      "flat",
                      "always"
                    ],
                    "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
                  },
                  "daysToExpiry": {
                    "type": "object",
                    "properties": {
                      "target": {
                        "type": "number"
                      },
                      "min": {
                        "type": "number"
                      },
                      "max": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "target"
                    ]
                  },
                  "sizing": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "quantity": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "quantity"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "maxMarginFraction": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "maxMarginFraction"
                        ]
                      }
                    ],
                    "description": "Default { quantity: 1 }"
                  },
                  "price": {
                    "type": "string",
                    "enum": [
                      "bid",
                      "ask",
                      "mid",
                      "last",
                      "mark"
                    ]
                  },
                  "structure": {
                    "type": "string",
                    "enum": [
                      "bullCallSpread",
                      "bearCallSpread",
                      "bullPutSpread",
                      "bearPutSpread"
                    ]
                  },
                  "select": {
                    "type": "object",
                    "properties": {
                      "shortDelta": {
                        "type": "number"
                      },
                      "width": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "shortDelta",
                      "width"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "daysToExpiry",
                  "structure",
                  "select"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Names the rule in trades and rows"
                  },
                  "when": {
                    "type": "string",
                    "enum": [
                      "flat",
                      "always"
                    ],
                    "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
                  },
                  "daysToExpiry": {
                    "type": "object",
                    "properties": {
                      "target": {
                        "type": "number"
                      },
                      "min": {
                        "type": "number"
                      },
                      "max": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "target"
                    ]
                  },
                  "sizing": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "quantity": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "quantity"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "maxMarginFraction": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "maxMarginFraction"
                        ]
                      }
                    ],
                    "description": "Default { quantity: 1 }"
                  },
                  "price": {
                    "type": "string",
                    "enum": [
                      "bid",
                      "ask",
                      "mid",
                      "last",
                      "mark"
                    ]
                  },
                  "structure": {
                    "const": "strangle",
                    "type": "string"
                  },
                  "select": {
                    "type": "object",
                    "properties": {
                      "shortDelta": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "shortDelta"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "daysToExpiry",
                  "structure",
                  "select"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Names the rule in trades and rows"
                  },
                  "when": {
                    "type": "string",
                    "enum": [
                      "flat",
                      "always"
                    ],
                    "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
                  },
                  "daysToExpiry": {
                    "type": "object",
                    "properties": {
                      "target": {
                        "type": "number"
                      },
                      "min": {
                        "type": "number"
                      },
                      "max": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "target"
                    ]
                  },
                  "sizing": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "quantity": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "quantity"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "maxMarginFraction": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "maxMarginFraction"
                        ]
                      }
                    ],
                    "description": "Default { quantity: 1 }"
                  },
                  "price": {
                    "type": "string",
                    "enum": [
                      "bid",
                      "ask",
                      "mid",
                      "last",
                      "mark"
                    ]
                  },
                  "structure": {
                    "const": "straddle",
                    "type": "string"
                  },
                  "select": {
                    "type": "object",
                    "properties": {
                      "strike": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "additionalProperties": false,
                "required": [
                  "daysToExpiry",
                  "structure"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Names the rule in trades and rows"
                  },
                  "when": {
                    "type": "string",
                    "enum": [
                      "flat",
                      "always"
                    ],
                    "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
                  },
                  "daysToExpiry": {
                    "type": "object",
                    "properties": {
                      "target": {
                        "type": "number"
                      },
                      "min": {
                        "type": "number"
                      },
                      "max": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "target"
                    ]
                  },
                  "sizing": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "quantity": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "quantity"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "maxMarginFraction": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "maxMarginFraction"
                        ]
                      }
                    ],
                    "description": "Default { quantity: 1 }"
                  },
                  "price": {
                    "type": "string",
                    "enum": [
                      "bid",
                      "ask",
                      "mid",
                      "last",
                      "mark"
                    ]
                  },
                  "structure": {
                    "const": "coveredCall",
                    "type": "string"
                  },
                  "select": {
                    "type": "object",
                    "properties": {
                      "shortDelta": {
                        "type": "number"
                      },
                      "stockPrice": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "shortDelta"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "daysToExpiry",
                  "structure",
                  "select"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Names the rule in trades and rows"
                  },
                  "when": {
                    "type": "string",
                    "enum": [
                      "flat",
                      "always"
                    ],
                    "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
                  },
                  "daysToExpiry": {
                    "type": "object",
                    "properties": {
                      "target": {
                        "type": "number"
                      },
                      "min": {
                        "type": "number"
                      },
                      "max": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "target"
                    ]
                  },
                  "sizing": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "quantity": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "quantity"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "maxMarginFraction": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "maxMarginFraction"
                        ]
                      }
                    ],
                    "description": "Default { quantity: 1 }"
                  },
                  "price": {
                    "type": "string",
                    "enum": [
                      "bid",
                      "ask",
                      "mid",
                      "last",
                      "mark"
                    ]
                  },
                  "structure": {
                    "const": "protectivePut",
                    "type": "string"
                  },
                  "select": {
                    "type": "object",
                    "properties": {
                      "shortDelta": {
                        "type": "number"
                      },
                      "stockPrice": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "shortDelta"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "daysToExpiry",
                  "structure",
                  "select"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Names the rule in trades and rows"
                  },
                  "when": {
                    "type": "string",
                    "enum": [
                      "flat",
                      "always"
                    ],
                    "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
                  },
                  "daysToExpiry": {
                    "type": "object",
                    "properties": {
                      "target": {
                        "type": "number"
                      },
                      "min": {
                        "type": "number"
                      },
                      "max": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "target"
                    ]
                  },
                  "sizing": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "quantity": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "quantity"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "maxMarginFraction": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "maxMarginFraction"
                        ]
                      }
                    ],
                    "description": "Default { quantity: 1 }"
                  },
                  "price": {
                    "type": "string",
                    "enum": [
                      "bid",
                      "ask",
                      "mid",
                      "last",
                      "mark"
                    ]
                  },
                  "structure": {
                    "type": "string",
                    "enum": [
                      "calendarCallSpread",
                      "calendarPutSpread",
                      "diagonalCallSpread",
                      "diagonalPutSpread",
                      "doubleDiagonal"
                    ]
                  },
                  "select": {
                    "type": "object",
                    "properties": {
                      "shortDelta": {
                        "type": "number"
                      },
                      "nearDaysToExpiry": {
                        "type": "object",
                        "properties": {
                          "target": {
                            "type": "number"
                          },
                          "min": {
                            "type": "number"
                          },
                          "max": {
                            "type": "number"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "target"
                        ]
                      },
                      "farDaysToExpiry": {
                        "type": "object",
                        "properties": {
                          "target": {
                            "type": "number"
                          },
                          "min": {
                            "type": "number"
                          },
                          "max": {
                            "type": "number"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "target"
                        ]
                      },
                      "width": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "shortDelta",
                      "nearDaysToExpiry",
                      "farDaysToExpiry"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "daysToExpiry",
                  "structure",
                  "select"
                ]
              }
            ],
            "description": "The declarative entry structures; a `build` callback is SDK-only"
          },
          "rules": {
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "description": "Names the rule in trades and rows"
                    },
                    "when": {
                      "type": "string",
                      "enum": [
                        "flat",
                        "always"
                      ],
                      "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
                    },
                    "daysToExpiry": {
                      "type": "object",
                      "properties": {
                        "target": {
                          "type": "number"
                        },
                        "min": {
                          "type": "number"
                        },
                        "max": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "target"
                      ]
                    },
                    "sizing": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "quantity": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "quantity"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "maxMarginFraction": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "maxMarginFraction"
                          ]
                        }
                      ],
                      "description": "Default { quantity: 1 }"
                    },
                    "price": {
                      "type": "string",
                      "enum": [
                        "bid",
                        "ask",
                        "mid",
                        "last",
                        "mark"
                      ]
                    },
                    "structure": {
                      "const": "ironCondor",
                      "type": "string"
                    },
                    "select": {
                      "type": "object",
                      "properties": {
                        "shortDelta": {
                          "type": "number"
                        },
                        "wingWidth": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "shortDelta",
                        "wingWidth"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "daysToExpiry",
                    "structure",
                    "select"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "description": "Names the rule in trades and rows"
                    },
                    "when": {
                      "type": "string",
                      "enum": [
                        "flat",
                        "always"
                      ],
                      "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
                    },
                    "daysToExpiry": {
                      "type": "object",
                      "properties": {
                        "target": {
                          "type": "number"
                        },
                        "min": {
                          "type": "number"
                        },
                        "max": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "target"
                      ]
                    },
                    "sizing": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "quantity": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "quantity"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "maxMarginFraction": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "maxMarginFraction"
                          ]
                        }
                      ],
                      "description": "Default { quantity: 1 }"
                    },
                    "price": {
                      "type": "string",
                      "enum": [
                        "bid",
                        "ask",
                        "mid",
                        "last",
                        "mark"
                      ]
                    },
                    "structure": {
                      "type": "string",
                      "enum": [
                        "bullCallSpread",
                        "bearCallSpread",
                        "bullPutSpread",
                        "bearPutSpread"
                      ]
                    },
                    "select": {
                      "type": "object",
                      "properties": {
                        "shortDelta": {
                          "type": "number"
                        },
                        "width": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "shortDelta",
                        "width"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "daysToExpiry",
                    "structure",
                    "select"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "description": "Names the rule in trades and rows"
                    },
                    "when": {
                      "type": "string",
                      "enum": [
                        "flat",
                        "always"
                      ],
                      "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
                    },
                    "daysToExpiry": {
                      "type": "object",
                      "properties": {
                        "target": {
                          "type": "number"
                        },
                        "min": {
                          "type": "number"
                        },
                        "max": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "target"
                      ]
                    },
                    "sizing": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "quantity": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "quantity"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "maxMarginFraction": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "maxMarginFraction"
                          ]
                        }
                      ],
                      "description": "Default { quantity: 1 }"
                    },
                    "price": {
                      "type": "string",
                      "enum": [
                        "bid",
                        "ask",
                        "mid",
                        "last",
                        "mark"
                      ]
                    },
                    "structure": {
                      "const": "strangle",
                      "type": "string"
                    },
                    "select": {
                      "type": "object",
                      "properties": {
                        "shortDelta": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "shortDelta"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "daysToExpiry",
                    "structure",
                    "select"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "description": "Names the rule in trades and rows"
                    },
                    "when": {
                      "type": "string",
                      "enum": [
                        "flat",
                        "always"
                      ],
                      "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
                    },
                    "daysToExpiry": {
                      "type": "object",
                      "properties": {
                        "target": {
                          "type": "number"
                        },
                        "min": {
                          "type": "number"
                        },
                        "max": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "target"
                      ]
                    },
                    "sizing": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "quantity": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "quantity"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "maxMarginFraction": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "maxMarginFraction"
                          ]
                        }
                      ],
                      "description": "Default { quantity: 1 }"
                    },
                    "price": {
                      "type": "string",
                      "enum": [
                        "bid",
                        "ask",
                        "mid",
                        "last",
                        "mark"
                      ]
                    },
                    "structure": {
                      "const": "straddle",
                      "type": "string"
                    },
                    "select": {
                      "type": "object",
                      "properties": {
                        "strike": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "daysToExpiry",
                    "structure"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "description": "Names the rule in trades and rows"
                    },
                    "when": {
                      "type": "string",
                      "enum": [
                        "flat",
                        "always"
                      ],
                      "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
                    },
                    "daysToExpiry": {
                      "type": "object",
                      "properties": {
                        "target": {
                          "type": "number"
                        },
                        "min": {
                          "type": "number"
                        },
                        "max": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "target"
                      ]
                    },
                    "sizing": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "quantity": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "quantity"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "maxMarginFraction": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "maxMarginFraction"
                          ]
                        }
                      ],
                      "description": "Default { quantity: 1 }"
                    },
                    "price": {
                      "type": "string",
                      "enum": [
                        "bid",
                        "ask",
                        "mid",
                        "last",
                        "mark"
                      ]
                    },
                    "structure": {
                      "const": "coveredCall",
                      "type": "string"
                    },
                    "select": {
                      "type": "object",
                      "properties": {
                        "shortDelta": {
                          "type": "number"
                        },
                        "stockPrice": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "shortDelta"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "daysToExpiry",
                    "structure",
                    "select"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "description": "Names the rule in trades and rows"
                    },
                    "when": {
                      "type": "string",
                      "enum": [
                        "flat",
                        "always"
                      ],
                      "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
                    },
                    "daysToExpiry": {
                      "type": "object",
                      "properties": {
                        "target": {
                          "type": "number"
                        },
                        "min": {
                          "type": "number"
                        },
                        "max": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "target"
                      ]
                    },
                    "sizing": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "quantity": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "quantity"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "maxMarginFraction": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "maxMarginFraction"
                          ]
                        }
                      ],
                      "description": "Default { quantity: 1 }"
                    },
                    "price": {
                      "type": "string",
                      "enum": [
                        "bid",
                        "ask",
                        "mid",
                        "last",
                        "mark"
                      ]
                    },
                    "structure": {
                      "const": "protectivePut",
                      "type": "string"
                    },
                    "select": {
                      "type": "object",
                      "properties": {
                        "shortDelta": {
                          "type": "number"
                        },
                        "stockPrice": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "shortDelta"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "daysToExpiry",
                    "structure",
                    "select"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "description": "Names the rule in trades and rows"
                    },
                    "when": {
                      "type": "string",
                      "enum": [
                        "flat",
                        "always"
                      ],
                      "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
                    },
                    "daysToExpiry": {
                      "type": "object",
                      "properties": {
                        "target": {
                          "type": "number"
                        },
                        "min": {
                          "type": "number"
                        },
                        "max": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "target"
                      ]
                    },
                    "sizing": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "quantity": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "quantity"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "maxMarginFraction": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "maxMarginFraction"
                          ]
                        }
                      ],
                      "description": "Default { quantity: 1 }"
                    },
                    "price": {
                      "type": "string",
                      "enum": [
                        "bid",
                        "ask",
                        "mid",
                        "last",
                        "mark"
                      ]
                    },
                    "structure": {
                      "type": "string",
                      "enum": [
                        "calendarCallSpread",
                        "calendarPutSpread",
                        "diagonalCallSpread",
                        "diagonalPutSpread",
                        "doubleDiagonal"
                      ]
                    },
                    "select": {
                      "type": "object",
                      "properties": {
                        "shortDelta": {
                          "type": "number"
                        },
                        "nearDaysToExpiry": {
                          "type": "object",
                          "properties": {
                            "target": {
                              "type": "number"
                            },
                            "min": {
                              "type": "number"
                            },
                            "max": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "target"
                          ]
                        },
                        "farDaysToExpiry": {
                          "type": "object",
                          "properties": {
                            "target": {
                              "type": "number"
                            },
                            "min": {
                              "type": "number"
                            },
                            "max": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "target"
                          ]
                        },
                        "width": {
                          "type": "number",
                          "exclusiveMinimum": 0
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "shortDelta",
                        "nearDaysToExpiry",
                        "farDaysToExpiry"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "daysToExpiry",
                    "structure",
                    "select"
                  ]
                }
              ],
              "description": "The declarative entry structures; a `build` callback is SDK-only"
            },
            "minItems": 1,
            "description": "Several rules, each a member of the book; exactly one of entry and rules"
          },
          "exit": {
            "type": "object",
            "properties": {
              "profitTarget": {
                "type": "number",
                "description": "Fraction of entry premium, e.g. 0.5"
              },
              "stopLoss": {
                "type": "number",
                "description": "Multiple of entry premium, e.g. 2"
              },
              "daysToExpiry": {
                "type": "number",
                "description": "Close at or below this DTE"
              }
            },
            "additionalProperties": false,
            "description": "A `when` predicate is SDK-only"
          },
          "roll": {
            "type": "object",
            "properties": {
              "when": {
                "type": "object",
                "properties": {
                  "profitTarget": {
                    "type": "number",
                    "description": "Fraction of entry premium, e.g. 0.5"
                  },
                  "stopLoss": {
                    "type": "number",
                    "description": "Multiple of entry premium, e.g. 2"
                  },
                  "daysToExpiry": {
                    "type": "number",
                    "description": "Close at or below this DTE"
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false
          },
          "hedge": {
            "type": "object",
            "properties": {
              "deltaBand": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "commission": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "none",
                        "type": "string"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "bps",
                        "type": "string"
                      },
                      "bps": {
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model",
                      "bps"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "perShare",
                        "type": "string"
                      },
                      "amountPerShare": {
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model",
                      "amountPerShare"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "fixed",
                        "type": "string"
                      },
                      "amount": {
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model",
                      "amount"
                    ]
                  }
                ],
                "description": "A declarative commission model (fees.none / bps / perShare / fixed)"
              },
              "slippage": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "none",
                        "type": "string"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "bps",
                        "type": "string"
                      },
                      "bps": {
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model",
                      "bps"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "fixed",
                        "type": "string"
                      },
                      "perShare": {
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model",
                      "perShare"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "model": {
                        "const": "spread",
                        "type": "string"
                      },
                      "spread": {
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "model",
                      "spread"
                    ]
                  }
                ],
                "description": "A declarative slippage model (slippage.none / bps / fixed / spread)"
              }
            },
            "additionalProperties": false,
            "required": [
              "deltaBand"
            ]
          },
          "commission": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "model": {
                    "const": "none",
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "model"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "model": {
                    "const": "bps",
                    "type": "string"
                  },
                  "bps": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "model",
                  "bps"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "model": {
                    "const": "perShare",
                    "type": "string"
                  },
                  "amountPerShare": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "model",
                  "amountPerShare"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "model": {
                    "const": "fixed",
                    "type": "string"
                  },
                  "amount": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "model",
                  "amount"
                ]
              }
            ],
            "description": "A declarative commission model (fees.none / bps / perShare / fixed)"
          },
          "slippage": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "model": {
                    "const": "none",
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "model"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "model": {
                    "const": "bps",
                    "type": "string"
                  },
                  "bps": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "model",
                  "bps"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "model": {
                    "const": "fixed",
                    "type": "string"
                  },
                  "perShare": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "model",
                  "perShare"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "model": {
                    "const": "spread",
                    "type": "string"
                  },
                  "spread": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "model",
                  "spread"
                ]
              }
            ],
            "description": "A declarative slippage model (slippage.none / bps / fixed / spread)"
          },
          "assignment": {
            "type": "string",
            "enum": [
              "model",
              "none"
            ]
          },
          "periodsPerYear": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Default 252"
          },
          "book": {
            "type": "object",
            "properties": {
              "maximumOpenPositions": {
                "type": "integer",
                "exclusiveMinimum": 0
              },
              "maximumPerUnderlying": {
                "type": "integer",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "description": "Default: one open trade"
          },
          "limits": {
            "type": "object",
            "properties": {
              "maximumMarginFraction": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "maximumNetDelta": {
                "type": "number",
                "minimum": 0
              },
              "maximumNetVega": {
                "type": "number",
                "minimum": 0
              },
              "maximumConcentration": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "scenarioLoss": {
                "type": "object",
                "properties": {
                  "spotShocks": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    },
                    "minItems": 1
                  },
                  "volatilityShocks": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    },
                    "minItems": 1
                  },
                  "maximumLossFraction": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "spotShocks",
                  "volatilityShocks",
                  "maximumLossFraction"
                ]
              }
            },
            "additionalProperties": false,
            "description": "Pre-trade limits on the post-trade book; a breach is a limitRejections row"
          },
          "fillPolicy": {
            "type": "object",
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "combo",
                  "legged"
                ]
              },
              "partialFill": {
                "type": "string",
                "enum": [
                  "reject",
                  "allow"
                ]
              },
              "price": {
                "type": "string",
                "enum": [
                  "bid",
                  "ask",
                  "mid",
                  "last",
                  "mark"
                ]
              }
            },
            "additionalProperties": false
          },
          "quoteFreshness": {
            "type": "object",
            "properties": {
              "maximumQuoteAgeMs": {
                "type": "number",
                "minimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "maximumQuoteAgeMs"
            ]
          },
          "corporateActions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "symbol": {
                  "type": "string",
                  "minLength": 1
                },
                "effectiveDate": {
                  "type": "string",
                  "format": "date"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "split",
                    "reverseSplit",
                    "dividend",
                    "symbolChange",
                    "merger",
                    "spinoff",
                    "other"
                  ]
                },
                "ratio": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "cash": {
                  "type": "number"
                },
                "newSymbol": {
                  "type": "string"
                },
                "details": {
                  "type": "object",
                  "additionalProperties": {}
                }
              },
              "additionalProperties": false,
              "required": [
                "symbol",
                "effectiveDate",
                "type"
              ]
            }
          },
          "dividends": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "underlying": {
                  "type": "string",
                  "minLength": 1
                },
                "exDate": {
                  "type": "string",
                  "format": "date"
                },
                "amount": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "underlying",
                "exDate",
                "amount"
              ]
            }
          },
          "baseCurrency": {
            "type": "string",
            "minLength": 1,
            "description": "Default 'USD'"
          }
        },
        "additionalProperties": false,
        "required": [
          "chains",
          "riskFreeRate",
          "exit"
        ]
      },
      "totalfinance.backtest.options_run.output": {
        "type": "object",
        "properties": {
          "points": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "returns": {
            "type": "array",
            "items": {
              "type": "number"
            }
          },
          "trades": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "settlements": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "finalValue": {
            "type": "number"
          },
          "performance": {
            "type": "object",
            "description": "The standard performance summary"
          },
          "limitRejections": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "fillRejections": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "surface": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "ledger": {
            "type": "object",
            "description": "The portfolio ledger snapshot (events)"
          },
          "timeline": {
            "type": [
              "object",
              "null"
            ],
            "description": "The ledger timeline (null under two marks)"
          },
          "runId": {
            "type": "string"
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "points",
          "returns",
          "trades",
          "settlements",
          "finalValue",
          "performance",
          "limitRejections",
          "fillRejections",
          "surface",
          "ledger",
          "timeline",
          "runId",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.backtest.options_run.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.backtest.options_run.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.backtest.portfolio_run.input": {
        "type": "object",
        "properties": {
          "accounting": {
            "type": "object",
            "properties": {
              "baseCurrency": {
                "type": "string",
                "minLength": 1
              },
              "initialCash": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "currency": {
                      "type": "string",
                      "minLength": 1
                    },
                    "amount": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "currency",
                    "amount"
                  ]
                },
                "minItems": 1
              },
              "lotRelief": {
                "type": "string",
                "enum": [
                  "fifo",
                  "lifo",
                  "highest-cost",
                  "specific-lot"
                ]
              },
              "settlement": {
                "type": "object",
                "additionalProperties": {
                  "type": "string",
                  "enum": [
                    "T+0",
                    "T+1",
                    "T+2"
                  ]
                }
              }
            },
            "additionalProperties": false,
            "required": [
              "baseCurrency",
              "initialCash"
            ]
          },
          "instruments": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "equity",
                    "etf",
                    "option",
                    "future",
                    "fx-forward",
                    "crypto-spot",
                    "crypto-perpetual",
                    "bond"
                  ],
                  "description": "A built-in kind; 'custom' brings its own adapter and is SDK-only"
                },
                "currency": {
                  "type": "string",
                  "minLength": 1
                },
                "contractMultiplier": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "contract": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "const": "option",
                          "type": "string"
                        },
                        "underlyingInstrumentId": {
                          "type": "string",
                          "minLength": 1
                        },
                        "right": {
                          "type": "string",
                          "enum": [
                            "call",
                            "put"
                          ]
                        },
                        "strikePricePerUnit": {
                          "type": "number",
                          "exclusiveMinimum": 0
                        },
                        "expiryTimestampMs": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "kind",
                        "underlyingInstrumentId",
                        "right",
                        "strikePricePerUnit",
                        "expiryTimestampMs"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "const": "future",
                          "type": "string"
                        },
                        "underlyingInstrumentId": {
                          "type": "string",
                          "minLength": 1
                        },
                        "expiryTimestampMs": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "kind",
                        "underlyingInstrumentId",
                        "expiryTimestampMs"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "const": "perpetual",
                          "type": "string"
                        },
                        "underlyingInstrumentId": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "kind",
                        "underlyingInstrumentId"
                      ]
                    }
                  ]
                },
                "assetClass": {
                  "type": "string",
                  "enum": [
                    "equity",
                    "etf",
                    "option",
                    "future",
                    "fx-forward",
                    "crypto-spot",
                    "crypto-perpetual",
                    "bond",
                    "cash"
                  ]
                },
                "classification": {
                  "type": "object",
                  "properties": {
                    "underlying": {
                      "type": "string"
                    },
                    "assetClass": {
                      "type": "string"
                    },
                    "strategy": {
                      "type": "string"
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "additionalProperties": false
                },
                "roll": {
                  "type": "object",
                  "properties": {
                    "toInstrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "sessionsBeforeExpiry": {
                      "type": "integer",
                      "minimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "toInstrumentId",
                    "sessionsBeforeExpiry"
                  ]
                },
                "coupon": {
                  "type": "object",
                  "properties": {
                    "annualRate": {
                      "type": "number"
                    },
                    "paymentsPerYear": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "faceValuePerUnit": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "dayCount": {
                      "type": "string",
                      "enum": [
                        "ACT/365F",
                        "30/360"
                      ]
                    },
                    "issueDate": {
                      "type": "string",
                      "format": "date"
                    },
                    "maturityDate": {
                      "type": "string",
                      "format": "date"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "annualRate",
                    "paymentsPerYear",
                    "issueDate",
                    "maturityDate"
                  ]
                },
                "forward": {
                  "type": "object",
                  "properties": {
                    "maturityTimestampMs": {
                      "type": "number"
                    },
                    "baseCurrency": {
                      "type": "string",
                      "minLength": 1
                    },
                    "quoteCurrency": {
                      "type": "string",
                      "minLength": 1
                    },
                    "contractRate": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "maturityTimestampMs",
                    "baseCurrency",
                    "quoteCurrency",
                    "contractRate"
                  ]
                }
              },
              "additionalProperties": false,
              "required": [
                "kind",
                "currency"
              ],
              "description": "An instrument specification; the terms each kind needs are validated by the engine"
            }
          },
          "marketData": {
            "type": "object",
            "properties": {
              "bars": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "symbol": {
                      "type": "string",
                      "minLength": 1
                    },
                    "timestampMs": {
                      "type": "number"
                    },
                    "open": {
                      "type": "number"
                    },
                    "high": {
                      "type": "number"
                    },
                    "low": {
                      "type": "number"
                    },
                    "close": {
                      "type": "number"
                    },
                    "volume": {
                      "type": "number"
                    },
                    "vwap": {
                      "type": "number"
                    },
                    "adjusted": {
                      "type": "boolean"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "symbol",
                    "timestampMs",
                    "open",
                    "high",
                    "low",
                    "close"
                  ]
                }
              },
              "quotes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "symbol": {
                      "type": "string",
                      "minLength": 1
                    },
                    "timestampMs": {
                      "type": "number"
                    },
                    "bid": {
                      "type": "number"
                    },
                    "ask": {
                      "type": "number"
                    },
                    "bidSize": {
                      "type": "number"
                    },
                    "askSize": {
                      "type": "number"
                    },
                    "exchange": {
                      "type": "string"
                    },
                    "conditions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "symbol",
                    "timestampMs",
                    "bid",
                    "ask"
                  ]
                }
              },
              "trades": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "symbol": {
                      "type": "string",
                      "minLength": 1
                    },
                    "timestampMs": {
                      "type": "number"
                    },
                    "price": {
                      "type": "number"
                    },
                    "size": {
                      "type": "number"
                    },
                    "exchange": {
                      "type": "string"
                    },
                    "conditions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "sequence": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "symbol",
                    "timestampMs",
                    "price",
                    "size"
                  ]
                }
              },
              "orderBooks": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "symbol": {
                      "type": "string",
                      "minLength": 1
                    },
                    "timestampMs": {
                      "type": "number"
                    },
                    "bids": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "price": {
                            "type": "number"
                          },
                          "size": {
                            "type": "number"
                          },
                          "exchange": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "price",
                          "size"
                        ]
                      }
                    },
                    "asks": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "price": {
                            "type": "number"
                          },
                          "size": {
                            "type": "number"
                          },
                          "exchange": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "price",
                          "size"
                        ]
                      }
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "symbol",
                    "timestampMs",
                    "bids",
                    "asks"
                  ]
                }
              },
              "optionChains": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "asOf": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string"
                        }
                      ],
                      "description": "Epoch ms, YYYY-MM-DD, or a zoned ISO datetime"
                    },
                    "underlyingPrice": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "quotes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "contract": {
                            "type": "object",
                            "properties": {
                              "underlying": {
                                "type": "string",
                                "minLength": 1
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "call",
                                  "put"
                                ]
                              },
                              "style": {
                                "type": "string",
                                "enum": [
                                  "european",
                                  "american"
                                ]
                              },
                              "strike": {
                                "type": "number",
                                "exclusiveMinimum": 0
                              },
                              "expiry": {
                                "type": "string",
                                "pattern": "^\\d{4}-\\d{2}-\\d{2}([Tt ]\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?([Zz]|[+-]\\d{2}:?\\d{2}))?$",
                                "description": "Display label: 'YYYY-MM-DD' or a zoned ISO datetime (matches the builders)"
                              },
                              "expiresAt": {
                                "type": "number",
                                "description": "Resolved expiration instant (epoch ms) — stamped by the builders"
                              },
                              "expiryConvention": {
                                "type": "string",
                                "enum": [
                                  "us-equity-close",
                                  "explicit-instant"
                                ],
                                "description": "How the label resolved to the instant"
                              },
                              "multiplier": {
                                "type": "number",
                                "exclusiveMinimum": 0
                              },
                              "settlement": {
                                "type": "string",
                                "enum": [
                                  "physical",
                                  "cash"
                                ]
                              },
                              "exerciseTime": {
                                "type": "string",
                                "enum": [
                                  "AM",
                                  "PM"
                                ]
                              },
                              "currency": {
                                "type": "string"
                              },
                              "root": {
                                "type": "string"
                              },
                              "occSymbol": {
                                "type": "string"
                              },
                              "deliverable": {
                                "type": "object",
                                "properties": {
                                  "cash": {
                                    "type": "number"
                                  },
                                  "shares": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "symbol": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "quantity": {
                                          "type": "number"
                                        }
                                      },
                                      "additionalProperties": false,
                                      "required": [
                                        "symbol",
                                        "quantity"
                                      ]
                                    }
                                  },
                                  "notes": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false
                              },
                              "adjusted": {
                                "type": "boolean"
                              }
                            },
                            "additionalProperties": false,
                            "required": [
                              "underlying",
                              "type",
                              "style",
                              "strike",
                              "expiry",
                              "expiresAt",
                              "expiryConvention"
                            ]
                          },
                          "timestampMs": {
                            "type": "number"
                          },
                          "bid": {
                            "type": "number"
                          },
                          "ask": {
                            "type": "number"
                          },
                          "bidSize": {
                            "type": "number",
                            "minimum": 0
                          },
                          "askSize": {
                            "type": "number",
                            "minimum": 0
                          },
                          "mid": {
                            "type": "number"
                          },
                          "last": {
                            "type": "number"
                          },
                          "mark": {
                            "type": "number"
                          },
                          "volume": {
                            "type": "number",
                            "minimum": 0
                          },
                          "openInterest": {
                            "type": "number",
                            "minimum": 0
                          },
                          "underlyingPrice": {
                            "type": "number",
                            "exclusiveMinimum": 0
                          },
                          "impliedVolatility": {
                            "type": "number",
                            "minimum": 0
                          },
                          "greeks": {
                            "type": "object",
                            "properties": {
                              "delta": {
                                "type": "number"
                              },
                              "gamma": {
                                "type": "number"
                              },
                              "theta": {
                                "type": "number"
                              },
                              "vega": {
                                "type": "number"
                              },
                              "rho": {
                                "type": "number"
                              },
                              "provenance": {
                                "type": "object",
                                "properties": {
                                  "source": {
                                    "type": "string"
                                  },
                                  "model": {
                                    "type": "string"
                                  },
                                  "timestampMs": {
                                    "type": "number"
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "source"
                                ]
                              }
                            },
                            "additionalProperties": false,
                            "required": [
                              "delta"
                            ],
                            "description": "Per-share Greeks in display units (theta per day, vega per vol point, rho per 1%), with optional provenance"
                          },
                          "exchange": {
                            "type": "string"
                          },
                          "conditions": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "contract",
                          "timestampMs"
                        ]
                      }
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "asOf",
                    "underlyingPrice",
                    "quotes"
                  ]
                }
              },
              "fxRates": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "timestampMs": {
                      "type": "number"
                    },
                    "baseCurrency": {
                      "type": "string",
                      "minLength": 1
                    },
                    "quoteCurrency": {
                      "type": "string",
                      "minLength": 1
                    },
                    "quotePerBase": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "timestampMs",
                    "baseCurrency",
                    "quoteCurrency",
                    "quotePerBase"
                  ]
                }
              },
              "forwardRates": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "instrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "timestampMs": {
                      "type": "number"
                    },
                    "forwardRate": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "instrumentId",
                    "timestampMs",
                    "forwardRate"
                  ]
                }
              },
              "fundingRates": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "instrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "timestampMs": {
                      "type": "number"
                    },
                    "fundingRate": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "instrumentId",
                    "timestampMs",
                    "fundingRate"
                  ]
                }
              },
              "corporateActions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "symbol": {
                      "type": "string",
                      "minLength": 1
                    },
                    "effectiveDate": {
                      "type": "string",
                      "format": "date"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "split",
                        "reverseSplit",
                        "dividend",
                        "symbolChange",
                        "merger",
                        "spinoff",
                        "other"
                      ]
                    },
                    "ratio": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "cash": {
                      "type": "number"
                    },
                    "newSymbol": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "symbol",
                    "effectiveDate",
                    "type"
                  ]
                }
              },
              "dividends": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "instrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "exDate": {
                      "type": "string",
                      "format": "date"
                    },
                    "amount": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "payDate": {
                      "type": "string",
                      "format": "date"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "instrumentId",
                    "exDate",
                    "amount"
                  ]
                }
              },
              "coupons": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "instrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "paymentDate": {
                      "type": "string",
                      "format": "date"
                    },
                    "amountPerUnit": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "instrumentId",
                    "paymentDate",
                    "amountPerUnit"
                  ]
                }
              }
            },
            "additionalProperties": false
          },
          "strategy": {
            "type": "object",
            "properties": {
              "model": {
                "anyOf": [
                  {
                    "type": "object",
                    "additionalProperties": {},
                    "description": "A ModelPortfolio artifact"
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "group": {
                          "type": "object",
                          "properties": {
                            "instrumentId": {
                              "type": "string"
                            },
                            "sleeveId": {
                              "type": "string"
                            },
                            "assetClass": {
                              "type": "string"
                            },
                            "currency": {
                              "type": "string"
                            },
                            "tag": {
                              "type": "string"
                            },
                            "underlying": {
                              "type": "string"
                            },
                            "strategy": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false,
                          "description": "Exactly one group key"
                        },
                        "weight": {
                          "type": "number"
                        },
                        "riskBudget": {
                          "type": "number"
                        },
                        "driftBand": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "group"
                      ]
                    },
                    "minItems": 1
                  }
                ]
              },
              "schedule": {
                "type": "object",
                "properties": {
                  "frequency": {
                    "type": "string",
                    "enum": [
                      "daily",
                      "weekly",
                      "monthly",
                      "quarterly"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "frequency"
                ]
              },
              "policy": {
                "type": "object",
                "additionalProperties": {},
                "description": "An InvestmentPolicy (limits, handling); targets come from the model"
              },
              "scope": {
                "type": "string",
                "enum": [
                  "to-target",
                  "drift-only"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "model",
              "schedule"
            ],
            "description": "The declarative strategy; an onSession callback is SDK-only"
          },
          "execution": {
            "type": "object",
            "properties": {
              "label": {
                "type": "string",
                "minLength": 1
              },
              "ambiguity": {
                "type": "string",
                "enum": [
                  "optimistic",
                  "pessimistic",
                  "deterministic-path",
                  "reject"
                ]
              },
              "costs": {
                "type": "object",
                "properties": {
                  "commission": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "none",
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "bps",
                            "type": "string"
                          },
                          "bps": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "bps"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "perShare",
                            "type": "string"
                          },
                          "amountPerShare": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "amountPerShare"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "fixed",
                            "type": "string"
                          },
                          "amount": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "amount"
                        ]
                      }
                    ],
                    "description": "A declarative commission model (fees.none / bps / perShare / fixed)"
                  },
                  "slippage": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "none",
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "bps",
                            "type": "string"
                          },
                          "bps": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "bps"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "fixed",
                            "type": "string"
                          },
                          "perShare": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "perShare"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "spread",
                            "type": "string"
                          },
                          "spread": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "spread"
                        ]
                      }
                    ],
                    "description": "A declarative slippage model (slippage.none / bps / fixed / spread)"
                  },
                  "spread": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "none",
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "halfSpreadBps",
                            "type": "string"
                          },
                          "bps": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "bps"
                        ]
                      }
                    ]
                  },
                  "marketImpact": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "none",
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "model": {
                            "const": "squareRoot",
                            "type": "string"
                          },
                          "coefficient": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "model",
                          "coefficient"
                        ]
                      }
                    ]
                  },
                  "latencySessions": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "participation": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  }
                },
                "additionalProperties": false
              },
              "partialFills": {
                "type": "string",
                "enum": [
                  "allow",
                  "reject"
                ]
              },
              "timeInForce": {
                "type": "object",
                "properties": {
                  "default": {
                    "type": "string",
                    "enum": [
                      "day",
                      "gtc"
                    ]
                  },
                  "expireAtSessionClose": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "default",
                  "expireAtSessionClose"
                ]
              },
              "margin": {
                "type": "object",
                "properties": {
                  "buyingPowerMultiplier": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "initialMarginRate": {
                    "type": "number",
                    "minimum": 0
                  },
                  "maintenanceMarginRate": {
                    "type": "number",
                    "minimum": 0
                  },
                  "forcedLiquidation": {
                    "type": "string",
                    "enum": [
                      "none",
                      "close-largest-loss",
                      "pro-rata"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "buyingPowerMultiplier",
                  "initialMarginRate",
                  "maintenanceMarginRate",
                  "forcedLiquidation"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "label"
            ],
            "description": "A declared execution policy over session bars (execution.declared): the label is the caller's claim; a caller fill model, session rules, and quote/order-book observations are SDK-only"
          },
          "externalFlows": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "timestampMs": {
                  "type": "number"
                },
                "amount": {
                  "type": "number"
                },
                "currency": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "additionalProperties": false,
              "required": [
                "timestampMs",
                "amount",
                "currency"
              ]
            }
          },
          "calendar": {
            "type": "string",
            "enum": [
              "NYSE",
              "CBOE",
              "ALWAYS_OPEN"
            ]
          },
          "window": {
            "type": "object",
            "properties": {
              "fromTimestampMs": {
                "type": "number"
              },
              "toTimestampMs": {
                "type": "number"
              }
            },
            "additionalProperties": false
          },
          "periodsPerYear": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Default 252"
          },
          "seed": {
            "type": "integer",
            "minimum": 0
          }
        },
        "additionalProperties": false,
        "required": [
          "accounting",
          "instruments",
          "marketData",
          "strategy"
        ]
      },
      "totalfinance.backtest.portfolio_run.output": {
        "type": "object",
        "properties": {
          "ledger": {
            "type": "object"
          },
          "timeline": {
            "type": [
              "object",
              "null"
            ]
          },
          "pnl": {
            "type": [
              "object",
              "null"
            ]
          },
          "orders": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "fills": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "rejections": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "liquidations": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "events": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "valuationMarks": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "points": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "returns": {
            "type": "array",
            "items": {
              "type": "number"
            }
          },
          "performance": {
            "type": "object",
            "description": "The standard performance summary"
          },
          "finalValue": {
            "type": "number"
          },
          "runId": {
            "type": "string"
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "ledger",
          "timeline",
          "pnl",
          "orders",
          "fills",
          "rejections",
          "liquidations",
          "events",
          "valuationMarks",
          "points",
          "returns",
          "performance",
          "finalValue",
          "runId",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.backtest.portfolio_run.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.backtest.portfolio_run.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.backtest.vectorized_run.input": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "symbol": {
                  "type": "string",
                  "description": "Ticker (default SYMBOL)"
                },
                "timestampMs": {
                  "type": "number",
                  "description": "Bar timestamp (epoch ms)"
                },
                "open": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "high": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "low": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "close": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "volume": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "timestampMs",
                "open",
                "high",
                "low",
                "close"
              ]
            },
            "description": "OHLC bars, chronological"
          },
          "signal": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "Target position per bar (1 long, 0 flat, -1 short; fractional = sized), aligned to data"
          },
          "initialCapital": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Opening capital (default 1)"
          },
          "feeBps": {
            "type": "number",
            "minimum": 0,
            "description": "Per-trade fee in basis points of traded notional"
          },
          "slippageBps": {
            "type": "number",
            "minimum": 0,
            "description": "Existing slippage.bps model; basis points, zero means no slippage"
          },
          "executionLag": {
            "type": "integer",
            "minimum": 0,
            "description": "Signal-to-fill lag in bars (SDK default 1); 0 carries a look-ahead warning"
          },
          "rebalance": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "everyBar",
                  "daily",
                  "weekly",
                  "monthly"
                ]
              },
              {
                "type": "integer",
                "exclusiveMinimum": 0
              }
            ],
            "description": "Existing SDK sampling schedule; samples signal[i - executionLag] only on rebalance bars"
          },
          "periodsPerYear": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Bars per year for metrics (SDK default 252)"
          },
          "riskFreeRate": {
            "type": "number",
            "description": "Annual risk-free rate as a decimal (SDK default 0)"
          },
          "maxLeverage": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Existing per-asset gross weight cap (SDK default 1)"
          }
        },
        "additionalProperties": false,
        "required": [
          "data",
          "signal"
        ]
      },
      "totalfinance.backtest.vectorized_run.output": {
        "type": "object",
        "properties": {
          "finalValue": {
            "type": "number"
          },
          "turnover": {
            "type": "number",
            "description": "Traded notional ÷ average equity over the run"
          },
          "performance": {
            "type": "object",
            "description": "The standard performance summary"
          },
          "assumptions": {
            "type": "object",
            "description": "The modelling policies the run assumed: initialCapital, fill, cost, slippage, cashSettlement, corporateAction, calendar, margin, conventionsVersion"
          },
          "diagnostics": {
            "type": "object",
            "description": "Implementation-risk warnings (look-ahead / data alignment) + benchmarkFixtureVersion"
          }
        },
        "required": [
          "finalValue",
          "turnover",
          "performance",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.backtest.vectorized_run.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.backtest.vectorized_run.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.calendar.sessions.input": {
        "type": "object",
        "properties": {
          "calendar": {
            "type": "string",
            "enum": [
              "NYSE",
              "CBOE",
              "crypto24x7"
            ],
            "description": "Exchange calendar"
          },
          "from": {
            "type": "string",
            "description": "Range start (ISO YYYY-MM-DD, inclusive)"
          },
          "to": {
            "type": "string",
            "description": "Range end (ISO YYYY-MM-DD, inclusive)"
          },
          "expirationKind": {
            "type": "string",
            "enum": [
              "weekly",
              "monthly",
              "quarterly"
            ],
            "description": "Also return option expirations of this kind (holiday-shifted)"
          }
        },
        "additionalProperties": false,
        "required": [
          "calendar",
          "from",
          "to"
        ]
      },
      "totalfinance.calendar.sessions.output": {
        "type": "object",
        "properties": {
          "tradingDays": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "holidays": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "halfDays": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "expirations": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "nextExpiry": {
            "type": "string"
          },
          "calendar": {
            "type": "object",
            "description": "name/version/timezone and documented closure-data coverage"
          },
          "diagnostics": {
            "type": "object",
            "description": "Warnings when the range crosses the historical coverage floor"
          }
        },
        "required": [
          "tradingDays",
          "holidays",
          "halfDays",
          "calendar"
        ]
      },
      "totalfinance.calendar.sessions.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.calendar.sessions.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.crypto.futures_basis.input": {
        "type": "object",
        "properties": {
          "spot": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Spot price (quote currency)"
          },
          "future": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Dated-futures price (quote currency)"
          },
          "timeToExpiryYears": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Time to futures expiry in YEARS"
          },
          "financingRate": {
            "type": "number",
            "description": "Quote financing rate (annualized decimal) — supply to get fairFuture/richness/carryArbitrage and the cash-and-carry arbitrage flag"
          },
          "coinYield": {
            "type": "number",
            "description": "Base-coin yield (annualized decimal, e.g. staking; default 0)"
          },
          "arbitrageThreshold": {
            "type": "number",
            "description": "|carryArbitrage| above which cash-and-carry is flagged (decimal, default 0.05)"
          }
        },
        "additionalProperties": false,
        "required": [
          "spot",
          "future",
          "timeToExpiryYears"
        ]
      },
      "totalfinance.crypto.futures_basis.output": {
        "type": "object",
        "properties": {
          "value": {
            "description": "The computed result"
          },
          "assumptions": {
            "type": "object",
            "description": "Every applied convention, echoed"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine/method/warnings (+ convergence where iterative)"
          }
        },
        "required": [
          "value",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.crypto.futures_basis.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.crypto.futures_basis.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.crypto.perpetual_funding.input": {
        "type": "object",
        "properties": {
          "markPrice": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Perpetual mark price (quote currency)"
          },
          "indexPrice": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Index / spot price (quote currency)"
          },
          "fundingRate": {
            "type": "number",
            "description": "Realized funding for ONE interval (decimal; 0.0001 = 0.01%). Longs pay when positive"
          },
          "intervalHours": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Funding interval in hours (default 8)"
          }
        },
        "additionalProperties": false,
        "required": [
          "markPrice",
          "indexPrice",
          "fundingRate"
        ]
      },
      "totalfinance.crypto.perpetual_funding.output": {
        "type": "object",
        "properties": {
          "value": {
            "description": "The computed result"
          },
          "assumptions": {
            "type": "object",
            "description": "Every applied convention, echoed"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine/method/warnings (+ convergence where iterative)"
          }
        },
        "required": [
          "value",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.crypto.perpetual_funding.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.crypto.perpetual_funding.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.fixed_income.bond_analytics.input": {
        "type": "object",
        "properties": {
          "issueDate": {
            "type": "string",
            "description": "Dated date / first accrual date, YYYY-MM-DD"
          },
          "maturityDate": {
            "type": "string",
            "description": "Maturity date, YYYY-MM-DD"
          },
          "couponRate": {
            "type": "number",
            "description": "Annualized coupon rate (decimal; 0.05 = 5%)"
          },
          "frequency": {
            "type": "string",
            "enum": [
              "annual",
              "semiannual",
              "quarterly",
              "monthly"
            ],
            "description": "Coupon frequency"
          },
          "faceValue": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Redemption / par value (default 100)"
          },
          "dayCount": {
            "type": "string",
            "enum": [
              "30/360",
              "ACT/360",
              "ACT/365F",
              "ACT/ACT",
              "30E/360"
            ],
            "description": "Accrual day count (default 30/360)"
          },
          "settlementDate": {
            "type": "string",
            "description": "Settlement date, YYYY-MM-DD"
          },
          "yield": {
            "type": "number",
            "description": "Annualized yield (decimal) — provide this OR `price`"
          },
          "price": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Bond price — provide this OR `yield`"
          },
          "priceType": {
            "type": "string",
            "enum": [
              "clean",
              "dirty"
            ],
            "description": "How to read `price` (default clean)"
          }
        },
        "additionalProperties": false,
        "required": [
          "issueDate",
          "maturityDate",
          "couponRate",
          "frequency",
          "settlementDate"
        ]
      },
      "totalfinance.fixed_income.bond_analytics.output": {
        "type": "object",
        "properties": {
          "value": {
            "description": "The computed result"
          },
          "assumptions": {
            "type": "object",
            "description": "Every applied convention, echoed"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine/method/warnings (+ convergence where iterative)"
          }
        },
        "required": [
          "value",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.fixed_income.bond_analytics.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.fixed_income.bond_analytics.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.option.greeks.input": {
        "type": "object",
        "properties": {
          "spot": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Spot price of the underlying"
          },
          "strike": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Strike price"
          },
          "timeToExpiryYears": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Time to expiry in years"
          },
          "riskFreeRate": {
            "type": "number",
            "description": "Continuously-compounded risk-free rate (decimal)"
          },
          "volatility": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Volatility (decimal)"
          },
          "dividendYield": {
            "type": "number",
            "description": "Continuous dividend yield (decimal, default 0)"
          },
          "expiry": {
            "type": "string",
            "description": "Option expiry — YYYY-MM-DD (→ the US close: 16:00 ET, 13:00 ET on early-close days) or a zoned ISO datetime. Supply with asOf instead of timeToExpiryYears."
          },
          "asOf": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ],
            "description": "Valuation instant — epoch ms or a zoned ISO datetime such as \"2026-07-20T10:30:00-04:00\". A bare YYYY-MM-DD is refused: a same-day option's value depends on the time of day. For an end-of-day mark use the 16:00 ET close (13:00 ET on early-close days)."
          },
          "type": {
            "type": "string",
            "enum": [
              "call",
              "put"
            ],
            "description": "Option type"
          }
        },
        "additionalProperties": false,
        "required": [
          "spot",
          "strike",
          "riskFreeRate",
          "volatility",
          "type"
        ]
      },
      "totalfinance.option.greeks.output": {
        "type": "object",
        "properties": {
          "greeks": {
            "type": "object",
            "properties": {
              "delta": {
                "type": "number"
              },
              "gamma": {
                "type": "number"
              },
              "theta": {
                "type": "number"
              },
              "vega": {
                "type": "number"
              },
              "rho": {
                "type": "number"
              }
            }
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "greeks"
        ]
      },
      "totalfinance.option.greeks.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.option.greeks.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.option.implied_volatility.input": {
        "type": "object",
        "properties": {
          "price": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Observed option price to invert"
          },
          "spot": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Spot price of the underlying"
          },
          "strike": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Strike price"
          },
          "timeToExpiryYears": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Time to expiry in years"
          },
          "riskFreeRate": {
            "type": "number",
            "description": "Continuously-compounded risk-free rate (decimal)"
          },
          "type": {
            "type": "string",
            "enum": [
              "call",
              "put"
            ],
            "description": "Option type"
          },
          "dividendYield": {
            "type": "number",
            "description": "Continuous dividend yield (decimal, default 0)"
          },
          "expiry": {
            "type": "string",
            "description": "Option expiry — YYYY-MM-DD (→ the US close: 16:00 ET, 13:00 ET on early-close days) or a zoned ISO datetime. Supply with asOf instead of timeToExpiryYears."
          },
          "asOf": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ],
            "description": "Valuation instant — epoch ms or a zoned ISO datetime such as \"2026-07-20T10:30:00-04:00\". A bare YYYY-MM-DD is refused: a same-day option's value depends on the time of day. For an end-of-day mark use the 16:00 ET close (13:00 ET on early-close days)."
          },
          "method": {
            "type": "string",
            "enum": [
              "auto",
              "brent",
              "newton",
              "halley",
              "householder"
            ],
            "description": "Solver method (default auto = Householder with a Brent fallback)"
          },
          "fallback": {
            "type": "boolean",
            "description": "Fall back to Brent when the chosen method fails (default true)"
          }
        },
        "additionalProperties": false,
        "required": [
          "price",
          "spot",
          "strike",
          "riskFreeRate",
          "type"
        ]
      },
      "totalfinance.option.implied_volatility.output": {
        "type": "object",
        "properties": {
          "value": {
            "type": [
              "number",
              "null"
            ]
          },
          "converged": {
            "type": "boolean"
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "value",
          "converged"
        ]
      },
      "totalfinance.option.implied_volatility.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.option.implied_volatility.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.option.price.input": {
        "type": "object",
        "properties": {
          "spot": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Spot price of the underlying"
          },
          "strike": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Strike price"
          },
          "timeToExpiryYears": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Time to expiry in years"
          },
          "riskFreeRate": {
            "type": "number",
            "description": "Continuously-compounded risk-free rate (decimal)"
          },
          "volatility": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Volatility (decimal)"
          },
          "dividendYield": {
            "type": "number",
            "description": "Continuous dividend yield (decimal, default 0)"
          },
          "expiry": {
            "type": "string",
            "description": "Option expiry — YYYY-MM-DD (→ the US close: 16:00 ET, 13:00 ET on early-close days) or a zoned ISO datetime. Supply with asOf instead of timeToExpiryYears."
          },
          "asOf": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ],
            "description": "Valuation instant — epoch ms or a zoned ISO datetime such as \"2026-07-20T10:30:00-04:00\". A bare YYYY-MM-DD is refused: a same-day option's value depends on the time of day. For an end-of-day mark use the 16:00 ET close (13:00 ET on early-close days)."
          },
          "type": {
            "type": "string",
            "enum": [
              "call",
              "put"
            ],
            "description": "Option type"
          }
        },
        "additionalProperties": false,
        "required": [
          "spot",
          "strike",
          "riskFreeRate",
          "volatility",
          "type"
        ]
      },
      "totalfinance.option.price.output": {
        "type": "object",
        "properties": {
          "value": {
            "type": "number"
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "value"
        ]
      },
      "totalfinance.option.price.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.option.price.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.performance.analyze.input": {
        "type": "object",
        "properties": {
          "returns": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "Per-period returns as decimals (0.01 = +1%) — supply returns OR equity"
          },
          "equity": {
            "type": "array",
            "items": {
              "type": "number",
              "exclusiveMinimum": 0
            },
            "description": "Equity curve (growth of capital, price levels) — supply returns OR equity"
          },
          "periodsPerYear": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Annualization factor (default 252 daily; 12 monthly, 52 weekly)"
          },
          "riskFreeRate": {
            "type": "number",
            "description": "Annualized risk-free rate (decimal, default 0)"
          },
          "benchmark": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "Aligned per-period benchmark returns (decimals); adds beta/alpha/informationRatio/Treynor"
          }
        },
        "additionalProperties": false
      },
      "totalfinance.performance.analyze.output": {
        "type": "object",
        "properties": {
          "value": {
            "description": "The computed result"
          },
          "assumptions": {
            "type": "object",
            "description": "Every applied convention, echoed"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine/method/warnings (+ convergence where iterative)"
          }
        },
        "required": [
          "value",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.performance.analyze.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.performance.analyze.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.portfolio.analyze.input": {
        "type": "object",
        "properties": {
          "ledger": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.portfolio-ledger",
                "type": "string"
              },
              "schemaVersion": {
                "type": "integer"
              },
              "portfolioId": {
                "type": "string"
              },
              "baseCurrency": {
                "type": "string"
              },
              "lotRelief": {
                "type": "string",
                "enum": [
                  "fifo",
                  "lifo",
                  "highest-cost",
                  "specific-lot"
                ]
              },
              "events": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": {}
                },
                "description": "Portfolio event envelopes (each re-validated by readPortfolioLedgerSnapshot)"
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  },
                  "dataset": {
                    "type": "string"
                  },
                  "asOf": {
                    "type": "number"
                  },
                  "receivedAt": {
                    "type": "number"
                  },
                  "sourceVersion": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "baseCurrency",
              "lotRelief",
              "events"
            ],
            "description": "A serialized portfolio ledger (totalfinance.portfolio-ledger, the FC7 JSON form)"
          },
          "asOf": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ],
            "description": "The valuation and monitoring instant"
          },
          "market": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.market-snapshot",
                "type": "string"
              },
              "schemaVersion": {
                "type": "integer"
              },
              "asOf": {
                "type": "number",
                "description": "Epoch ms (resolved on the artifact)"
              },
              "conventions": {
                "type": "object",
                "properties": {
                  "conventionsVersion": {
                    "type": "string"
                  },
                  "asOfConvention": {
                    "type": "string",
                    "enum": [
                      "explicit-instant",
                      "date-midnight-utc"
                    ],
                    "description": "How asOf was expressed at create time (a bare date is refused by option pricing)"
                  },
                  "dayCount": {
                    "type": "string"
                  },
                  "compounding": {
                    "type": "string"
                  },
                  "calendar": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "conventionsVersion",
                  "asOfConvention"
                ]
              },
              "observations": {
                "type": "object",
                "properties": {
                  "spots": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "riskFreeRates": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number"
                    }
                  },
                  "dividendYields": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number"
                    }
                  },
                  "volatilities": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number"
                    }
                  },
                  "curves": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "surfaces": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "chains": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  },
                  "dataset": {
                    "type": "string"
                  },
                  "asOf": {
                    "type": "number"
                  },
                  "receivedAt": {
                    "type": "number"
                  },
                  "sourceVersion": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "asOf",
              "conventions",
              "observations"
            ],
            "description": "A Gate B market snapshot (totalfinance.market-snapshot); its interior is re-validated by the read door"
          },
          "currencyConversions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "baseCurrency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "quoteCurrency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "quotePerBase": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "baseCurrency",
                "quoteCurrency",
                "quotePerBase"
              ]
            }
          },
          "instrumentClassification": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "underlying": {
                  "type": "string"
                },
                "assetClass": {
                  "type": "string"
                },
                "strategy": {
                  "type": "string"
                },
                "tags": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "additionalProperties": false
            },
            "description": "Identity metadata per instrument for grouping; unknown instruments group as unclassified"
          },
          "marks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "valuationDate": {
                  "type": "string",
                  "format": "date",
                  "description": "Strict YYYY-MM-DD; the mark instant is 00:00 UTC"
                },
                "market": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "const": "totalfinance.market-snapshot",
                      "type": "string"
                    },
                    "schemaVersion": {
                      "type": "integer"
                    },
                    "asOf": {
                      "type": "number",
                      "description": "Epoch ms (resolved on the artifact)"
                    },
                    "conventions": {
                      "type": "object",
                      "properties": {
                        "conventionsVersion": {
                          "type": "string"
                        },
                        "asOfConvention": {
                          "type": "string",
                          "enum": [
                            "explicit-instant",
                            "date-midnight-utc"
                          ],
                          "description": "How asOf was expressed at create time (a bare date is refused by option pricing)"
                        },
                        "dayCount": {
                          "type": "string"
                        },
                        "compounding": {
                          "type": "string"
                        },
                        "calendar": {
                          "type": "string"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "conventionsVersion",
                        "asOfConvention"
                      ]
                    },
                    "observations": {
                      "type": "object",
                      "properties": {
                        "spots": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "object",
                            "additionalProperties": {}
                          }
                        },
                        "riskFreeRates": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "number"
                          }
                        },
                        "dividendYields": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "number"
                          }
                        },
                        "volatilities": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "number"
                          }
                        },
                        "curves": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "object",
                            "additionalProperties": {}
                          }
                        },
                        "surfaces": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "object",
                            "additionalProperties": {}
                          }
                        },
                        "chains": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "object",
                            "additionalProperties": {}
                          }
                        }
                      },
                      "additionalProperties": false
                    },
                    "provenance": {
                      "type": "object",
                      "properties": {
                        "provider": {
                          "type": "string"
                        },
                        "dataset": {
                          "type": "string"
                        },
                        "asOf": {
                          "type": "number"
                        },
                        "receivedAt": {
                          "type": "number"
                        },
                        "sourceVersion": {
                          "type": "string"
                        },
                        "requestId": {
                          "type": "string"
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "additionalProperties": {}
                          }
                        }
                      },
                      "additionalProperties": false
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "kind",
                    "schemaVersion",
                    "asOf",
                    "conventions",
                    "observations"
                  ],
                  "description": "A Gate B market snapshot (totalfinance.market-snapshot); its interior is re-validated by the read door"
                },
                "currencyConversions": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "baseCurrency": {
                        "type": "string",
                        "pattern": "^[A-Z]{3}$"
                      },
                      "quoteCurrency": {
                        "type": "string",
                        "pattern": "^[A-Z]{3}$"
                      },
                      "quotePerBase": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "baseCurrency",
                      "quoteCurrency",
                      "quotePerBase"
                    ]
                  }
                }
              },
              "additionalProperties": false,
              "required": [
                "valuationDate",
                "market"
              ]
            },
            "minItems": 2,
            "description": "At least two dated marks, strictly ascending — adds portfolioTimeline when supplied"
          },
          "monitor": {
            "type": "object",
            "properties": {
              "policy": {
                "type": "object",
                "properties": {
                  "targets": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "group": {
                          "type": "object",
                          "properties": {
                            "instrumentId": {
                              "type": "string"
                            },
                            "sleeveId": {
                              "type": "string"
                            },
                            "assetClass": {
                              "type": "string"
                            },
                            "currency": {
                              "type": "string"
                            },
                            "tag": {
                              "type": "string"
                            },
                            "underlying": {
                              "type": "string"
                            },
                            "strategy": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false,
                          "description": "Exactly one group key"
                        },
                        "weight": {
                          "type": "number"
                        },
                        "riskBudget": {
                          "type": "number"
                        },
                        "driftBand": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "group"
                      ]
                    }
                  },
                  "model": {
                    "type": "object",
                    "additionalProperties": {},
                    "description": "A model portfolio envelope (totalfinance.model-portfolio), validated by the policy grammar"
                  },
                  "withinGroupAllocation": {
                    "type": "string",
                    "enum": [
                      "proportional-to-current",
                      "equal"
                    ]
                  },
                  "driftBand": {
                    "type": "number"
                  },
                  "reviewCadenceDays": {
                    "type": "number"
                  },
                  "maximumTurnover": {
                    "type": "number"
                  },
                  "maximumEstimatedTransactionCost": {
                    "type": "number"
                  },
                  "minimumCash": {
                    "type": "number"
                  },
                  "minimumCashWeight": {
                    "type": "number"
                  },
                  "limits": {
                    "type": "object",
                    "properties": {
                      "maximumPositionWeight": {
                        "type": "number"
                      },
                      "maximumGroupWeights": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "group": {
                              "type": "object",
                              "properties": {
                                "instrumentId": {
                                  "type": "string"
                                },
                                "sleeveId": {
                                  "type": "string"
                                },
                                "assetClass": {
                                  "type": "string"
                                },
                                "currency": {
                                  "type": "string"
                                },
                                "tag": {
                                  "type": "string"
                                },
                                "underlying": {
                                  "type": "string"
                                },
                                "strategy": {
                                  "type": "string"
                                }
                              },
                              "additionalProperties": false,
                              "description": "Exactly one group key"
                            },
                            "maximumWeight": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "group",
                            "maximumWeight"
                          ]
                        }
                      },
                      "maximumGrossLeverage": {
                        "type": "number"
                      },
                      "maximumDrawdown": {
                        "type": "number"
                      },
                      "maximumDailyLoss": {
                        "type": "number"
                      },
                      "maximumDaysToLiquidate": {
                        "type": "number"
                      },
                      "minimumSettledCash": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false
                  },
                  "allowedInstruments": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "restrictedInstruments": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "allowedAccounts": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "benchmark": {
                    "type": "object",
                    "properties": {
                      "benchmarkId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "asOf": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "string"
                          }
                        ],
                        "description": "Epoch ms, YYYY-MM-DD, or a zoned ISO datetime"
                      },
                      "constituents": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "instrumentId": {
                              "type": "string"
                            },
                            "weight": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "instrumentId",
                            "weight"
                          ]
                        }
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "benchmarkId"
                    ]
                  },
                  "performanceObjective": {
                    "type": "string"
                  },
                  "contributionHandling": {
                    "type": "string",
                    "enum": [
                      "invest-to-targets",
                      "hold-as-cash"
                    ]
                  },
                  "withdrawalHandling": {
                    "type": "string",
                    "enum": [
                      "raise-from-overweights",
                      "pro-rata"
                    ]
                  },
                  "incomeReinvestment": {
                    "type": "string",
                    "enum": [
                      "reinvest",
                      "hold-as-cash"
                    ]
                  },
                  "lotSelectionObjective": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              },
              "previousState": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "schemaVersion": {
                        "type": "integer"
                      },
                      "asOf": {
                        "type": "number"
                      },
                      "netAssetValue": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "peakNetAssetValue": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "evaluationCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "rules": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "active": {
                              "type": "boolean"
                            },
                            "consecutiveBreaches": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "lastRaisedAtMs": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "acknowledged": {
                              "type": "boolean"
                            },
                            "lastValue": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "active",
                            "consecutiveBreaches",
                            "lastRaisedAtMs",
                            "acknowledged",
                            "lastValue"
                          ]
                        }
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "schemaVersion",
                      "asOf",
                      "netAssetValue",
                      "peakNetAssetValue",
                      "evaluationCount",
                      "rules"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The prior evaluation's state, or null for the first evaluation — required, exactly as monitorPortfolio requires it"
              },
              "rules": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "properties": {
                    "enabled": {
                      "type": "boolean"
                    },
                    "threshold": {
                      "type": "number"
                    },
                    "direction": {
                      "type": "string",
                      "enum": [
                        "above",
                        "below"
                      ]
                    },
                    "hysteresis": {
                      "type": "object",
                      "properties": {
                        "enter": {
                          "type": "number"
                        },
                        "exit": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "enter",
                        "exit"
                      ]
                    },
                    "debounceEvaluations": {
                      "type": "integer",
                      "exclusiveMinimum": 0,
                      "description": "Default 1"
                    },
                    "cooldownMs": {
                      "type": "number",
                      "minimum": 0,
                      "description": "Default 0"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "informational",
                        "warning",
                        "critical"
                      ]
                    }
                  },
                  "additionalProperties": false
                },
                "description": "Per alert family"
              },
              "acknowledgments": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "averageDailyVolumes": {
                "type": "object",
                "additionalProperties": {
                  "type": "number"
                }
              },
              "marketStalenessLimitMs": {
                "type": "number"
              },
              "unusualPnlThreshold": {
                "type": "number"
              },
              "residualTolerance": {
                "type": "number"
              },
              "optionExpirationWarningDays": {
                "type": "number"
              },
              "assignmentRiskMoneyness": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "policy",
              "previousState"
            ],
            "description": "monitorPortfolio inputs beyond the shared portfolio / market / asOf / currencyConversions"
          }
        },
        "additionalProperties": false,
        "required": [
          "ledger",
          "asOf",
          "market"
        ]
      },
      "totalfinance.portfolio.analyze.output": {
        "type": "object",
        "properties": {
          "snapshot": {
            "type": "object",
            "description": "portfolioSnapshot(...) verbatim"
          },
          "timeline": {
            "type": [
              "object",
              "null"
            ],
            "description": "portfolioTimeline(...) verbatim, or null when no marks were supplied"
          },
          "monitor": {
            "type": [
              "object",
              "null"
            ],
            "description": "monitorPortfolio(...) verbatim, or null when no monitor request was supplied"
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "snapshot",
          "timeline",
          "monitor",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.portfolio.analyze.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.portfolio.analyze.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.portfolio.create.input": {
        "type": "object",
        "properties": {
          "portfolioId": {
            "type": "string",
            "minLength": 1
          },
          "baseCurrency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "lotRelief": {
            "type": "string",
            "enum": [
              "fifo",
              "lifo",
              "highest-cost",
              "specific-lot"
            ],
            "description": "Existing ledger default: fifo, echoed in the stored ledger"
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/PortfolioEventEnvelope"
            },
            "maxItems": 100000,
            "description": "Explicit initial events; [] means an empty, unfunded portfolio"
          },
          "provenance": {
            "$ref": "#/$defs/Provenance"
          },
          "createdTimestampMs": {
            "type": "integer",
            "description": "Caller clock in epoch milliseconds"
          }
        },
        "additionalProperties": false,
        "required": [
          "portfolioId",
          "baseCurrency",
          "events",
          "createdTimestampMs"
        ],
        "$id": "https://totalfinance.dev/schemas/portfolio.create.input",
        "$defs": {
          "PortfolioEventEnvelope": {
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "eventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "schemaVersion": {
                    "const": 1,
                    "type": "number"
                  },
                  "sourceId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "accountId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "effectiveTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "recordedTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "correlationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "causationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "reversesEventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "provenance": {
                    "$ref": "#/$defs/Provenance"
                  },
                  "eventType": {},
                  "event": {}
                },
                "additionalProperties": false,
                "required": [
                  "eventId",
                  "schemaVersion",
                  "sourceId",
                  "accountId",
                  "effectiveTimestampMs",
                  "recordedTimestampMs",
                  "provenance",
                  "eventType",
                  "event"
                ]
              },
              {
                "anyOf": [
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.deposit",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashDeposit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.withdrawal",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashWithdrawal"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.conversion",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashConversion"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "trade.fill",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/TradeFill"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cost.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CostCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "income.received",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/IncomeReceived"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "financing.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FinancingCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.split",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSplit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.exercise",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExercise"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.assignment",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeAssignment"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.expiration",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExpiration"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.multiplier-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeMultiplierChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.variation-margin",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeVariationMargin"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.roll",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeRoll"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "fixed-income.redemption",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FixedIncomeRedemption"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.symbol-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSymbolChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.merger",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateMerger"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.spin-off",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSpinOff"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.return-of-capital",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateReturnOfCapital"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.cash-in-lieu",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateCashInLieu"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "position.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/PositionTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.reversal",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.reversal",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.correction",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.correction",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "replacement": {
                            "anyOf": [
                              {
                                "$ref": "#/$defs/CashDeposit"
                              },
                              {
                                "$ref": "#/$defs/CashWithdrawal"
                              },
                              {
                                "$ref": "#/$defs/CashTransfer"
                              },
                              {
                                "$ref": "#/$defs/CashConversion"
                              },
                              {
                                "$ref": "#/$defs/TradeFill"
                              },
                              {
                                "$ref": "#/$defs/CostCharge"
                              },
                              {
                                "$ref": "#/$defs/IncomeReceived"
                              },
                              {
                                "$ref": "#/$defs/FinancingCharge"
                              },
                              {
                                "$ref": "#/$defs/CorporateSplit"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExercise"
                              },
                              {
                                "$ref": "#/$defs/DerivativeAssignment"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExpiration"
                              },
                              {
                                "$ref": "#/$defs/DerivativeMultiplierChange"
                              },
                              {
                                "$ref": "#/$defs/DerivativeVariationMargin"
                              },
                              {
                                "$ref": "#/$defs/DerivativeRoll"
                              },
                              {
                                "$ref": "#/$defs/FixedIncomeRedemption"
                              },
                              {
                                "$ref": "#/$defs/CorporateSymbolChange"
                              },
                              {
                                "$ref": "#/$defs/CorporateMerger"
                              },
                              {
                                "$ref": "#/$defs/CorporateSpinOff"
                              },
                              {
                                "$ref": "#/$defs/CorporateReturnOfCapital"
                              },
                              {
                                "$ref": "#/$defs/CorporateCashInLieu"
                              },
                              {
                                "$ref": "#/$defs/PositionTransfer"
                              }
                            ]
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original",
                          "replacement"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.account-migration",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.account-migration",
                            "type": "string"
                          },
                          "fromAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "toAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "fromAccountId",
                          "toAccountId"
                        ]
                      }
                    }
                  }
                ]
              }
            ]
          },
          "Provenance": {
            "type": "object",
            "properties": {
              "provider": {
                "type": "string"
              },
              "dataset": {
                "type": "string"
              },
              "asOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "receivedAt": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "sourceVersion": {
                "type": "string"
              },
              "requestId": {
                "type": "string"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string",
                      "minLength": 1
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              }
            },
            "additionalProperties": false
          },
          "CashDeposit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.deposit",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashWithdrawal": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.withdrawal",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.transfer",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency",
              "fromAccountId",
              "toAccountId"
            ]
          },
          "CashConversion": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.conversion",
                "type": "string"
              },
              "fromCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "toCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "toAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromCurrency",
              "toCurrency",
              "fromAmount",
              "toAmount"
            ]
          },
          "TradeFill": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "trade.fill",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "side": {
                "type": "string",
                "enum": [
                  "buy",
                  "sell"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              },
              "contractMultiplier": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlementStyle": {
                "type": "string",
                "enum": [
                  "cash-on-trade",
                  "variation-margin"
                ]
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "accruedInterest": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "side",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "LotSelections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "lotId": {
                  "type": "string",
                  "minLength": 1
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "lotId",
                "quantity"
              ]
            },
            "minItems": 1
          },
          "Contract": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "option",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "call",
                      "put"
                    ]
                  },
                  "strikePricePerUnit": {
                    "type": "number"
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "type",
                  "strikePricePerUnit",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "future",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "perpetual",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId"
                ]
              }
            ]
          },
          "CostCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cost.charge",
                "type": "string"
              },
              "costType": {
                "type": "string",
                "enum": [
                  "commission",
                  "exchange-fee",
                  "regulatory-fee",
                  "slippage-adjustment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "costType",
              "amount",
              "currency"
            ]
          },
          "IncomeReceived": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "income.received",
                "type": "string"
              },
              "incomeType": {
                "type": "string",
                "enum": [
                  "dividend",
                  "coupon",
                  "interest",
                  "staking-reward",
                  "funding-receipt"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "incomeType",
              "amount",
              "currency"
            ]
          },
          "FinancingCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "financing.charge",
                "type": "string"
              },
              "financingType": {
                "type": "string",
                "enum": [
                  "margin-interest",
                  "borrow-charge",
                  "funding-payment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "financingType",
              "amount",
              "currency"
            ]
          },
          "CorporateSplit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.split",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesAfterSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "sharesBeforeSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "sharesAfterSplit",
              "sharesBeforeSplit"
            ]
          },
          "DerivativeExercise": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.exercise",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "Settlement": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "physical",
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "cash",
                    "type": "string"
                  },
                  "settlementPricePerUnit": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "settlementPricePerUnit"
                ]
              }
            ]
          },
          "DerivativeAssignment": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.assignment",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "DerivativeExpiration": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.expiration",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity"
            ]
          },
          "DerivativeMultiplierChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.multiplier-change",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "contractMultiplierAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "strikePricePerUnitAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "reason": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "contractMultiplierAfter"
            ]
          },
          "DerivativeVariationMargin": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.variation-margin",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settlementPricePerUnit": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "settlementPricePerUnit"
            ]
          },
          "DerivativeRoll": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.roll",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "closePricePerUnit": {
                "type": "number"
              },
              "openPricePerUnit": {
                "type": "number"
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId",
              "quantity",
              "closePricePerUnit",
              "openPricePerUnit"
            ]
          },
          "FixedIncomeRedemption": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "fixed-income.redemption",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "redemptionType": {
                "type": "string",
                "enum": [
                  "maturity",
                  "call",
                  "principal-paydown",
                  "sinking-fund"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "redemptionType",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "CorporateSymbolChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.symbol-change",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId"
            ]
          },
          "CorporateMerger": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.merger",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "cashPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId"
            ]
          },
          "CorporateSpinOff": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.spin-off",
                "type": "string"
              },
              "parentInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "childInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerParentShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "basisAllocationFraction": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "parentInstrumentId",
              "childInstrumentId",
              "sharesPerParentShare",
              "basisAllocationFraction"
            ]
          },
          "CorporateReturnOfCapital": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.return-of-capital",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "amountPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "amountPerShare",
              "currency"
            ]
          },
          "CorporateCashInLieu": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.cash-in-lieu",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "amount",
              "currency"
            ]
          },
          "PositionTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "position.transfer",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "fromAccountId",
              "toAccountId"
            ]
          }
        }
      },
      "totalfinance.portfolio.create.output": {
        "type": "object",
        "properties": {
          "handle": {
            "type": "object",
            "properties": {
              "uri": {
                "type": "string",
                "minLength": 1
              },
              "kind": {
                "type": "string",
                "enum": [
                  "report",
                  "job",
                  "portfolio",
                  "scenario",
                  "market",
                  "authorization",
                  "journal"
                ]
              },
              "schema": {
                "type": "string",
                "minLength": 1
              },
              "version": {
                "type": "string"
              },
              "contentHash": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "createdTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "expiresTimestampMs": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  },
                  "dataset": {
                    "type": "string"
                  },
                  "asOf": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "receivedAt": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "sourceVersion": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "minLength": 1
                        },
                        "message": {
                          "type": "string"
                        },
                        "severity": {
                          "type": "string",
                          "enum": [
                            "info",
                            "warn",
                            "error"
                          ]
                        },
                        "context": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message",
                        "severity"
                      ]
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "uri",
              "kind",
              "schema",
              "version",
              "contentHash",
              "createdTimestampMs",
              "expiresTimestampMs",
              "provenance"
            ]
          },
          "portfolioId": {
            "type": "string"
          },
          "baseCurrency": {
            "type": "string"
          },
          "eventCount": {
            "type": "integer",
            "minimum": 0
          },
          "lotRelief": {
            "type": "string",
            "enum": [
              "fifo",
              "lifo",
              "highest-cost",
              "specific-lot"
            ]
          },
          "inspectOperation": {
            "const": "totalfinance.portfolio.inspect",
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "handle",
          "portfolioId",
          "baseCurrency",
          "eventCount",
          "lotRelief",
          "inspectOperation"
        ],
        "$id": "https://totalfinance.dev/schemas/portfolio.create.output"
      },
      "totalfinance.portfolio.create.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.portfolio.create.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.portfolio.explain_pnl.input": {
        "type": "object",
        "properties": {
          "ledger": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.portfolio-ledger",
                "type": "string"
              },
              "schemaVersion": {
                "type": "integer"
              },
              "portfolioId": {
                "type": "string"
              },
              "baseCurrency": {
                "type": "string"
              },
              "lotRelief": {
                "type": "string",
                "enum": [
                  "fifo",
                  "lifo",
                  "highest-cost",
                  "specific-lot"
                ]
              },
              "events": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": {}
                },
                "description": "Portfolio event envelopes (each re-validated by readPortfolioLedgerSnapshot)"
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  },
                  "dataset": {
                    "type": "string"
                  },
                  "asOf": {
                    "type": "number"
                  },
                  "receivedAt": {
                    "type": "number"
                  },
                  "sourceVersion": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "baseCurrency",
              "lotRelief",
              "events"
            ],
            "description": "A serialized portfolio ledger (totalfinance.portfolio-ledger, the FC7 JSON form)"
          },
          "from": {
            "type": "object",
            "properties": {
              "valuationDate": {
                "type": "string",
                "format": "date",
                "description": "Strict YYYY-MM-DD; the mark instant is 00:00 UTC"
              },
              "market": {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "totalfinance.market-snapshot",
                    "type": "string"
                  },
                  "schemaVersion": {
                    "type": "integer"
                  },
                  "asOf": {
                    "type": "number",
                    "description": "Epoch ms (resolved on the artifact)"
                  },
                  "conventions": {
                    "type": "object",
                    "properties": {
                      "conventionsVersion": {
                        "type": "string"
                      },
                      "asOfConvention": {
                        "type": "string",
                        "enum": [
                          "explicit-instant",
                          "date-midnight-utc"
                        ],
                        "description": "How asOf was expressed at create time (a bare date is refused by option pricing)"
                      },
                      "dayCount": {
                        "type": "string"
                      },
                      "compounding": {
                        "type": "string"
                      },
                      "calendar": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "conventionsVersion",
                      "asOfConvention"
                    ]
                  },
                  "observations": {
                    "type": "object",
                    "properties": {
                      "spots": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      },
                      "riskFreeRates": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "number"
                        }
                      },
                      "dividendYields": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "number"
                        }
                      },
                      "volatilities": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "number"
                        }
                      },
                      "curves": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      },
                      "surfaces": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      },
                      "chains": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      }
                    },
                    "additionalProperties": false
                  },
                  "provenance": {
                    "type": "object",
                    "properties": {
                      "provider": {
                        "type": "string"
                      },
                      "dataset": {
                        "type": "string"
                      },
                      "asOf": {
                        "type": "number"
                      },
                      "receivedAt": {
                        "type": "number"
                      },
                      "sourceVersion": {
                        "type": "string"
                      },
                      "requestId": {
                        "type": "string"
                      },
                      "warnings": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "schemaVersion",
                  "asOf",
                  "conventions",
                  "observations"
                ],
                "description": "A Gate B market snapshot (totalfinance.market-snapshot); its interior is re-validated by the read door"
              },
              "currencyConversions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "baseCurrency": {
                      "type": "string",
                      "pattern": "^[A-Z]{3}$"
                    },
                    "quoteCurrency": {
                      "type": "string",
                      "pattern": "^[A-Z]{3}$"
                    },
                    "quotePerBase": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "baseCurrency",
                    "quoteCurrency",
                    "quotePerBase"
                  ]
                }
              }
            },
            "additionalProperties": false,
            "required": [
              "valuationDate",
              "market"
            ],
            "description": "The opening valuation mark"
          },
          "to": {
            "type": "object",
            "properties": {
              "valuationDate": {
                "type": "string",
                "format": "date",
                "description": "Strict YYYY-MM-DD; the mark instant is 00:00 UTC"
              },
              "market": {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "totalfinance.market-snapshot",
                    "type": "string"
                  },
                  "schemaVersion": {
                    "type": "integer"
                  },
                  "asOf": {
                    "type": "number",
                    "description": "Epoch ms (resolved on the artifact)"
                  },
                  "conventions": {
                    "type": "object",
                    "properties": {
                      "conventionsVersion": {
                        "type": "string"
                      },
                      "asOfConvention": {
                        "type": "string",
                        "enum": [
                          "explicit-instant",
                          "date-midnight-utc"
                        ],
                        "description": "How asOf was expressed at create time (a bare date is refused by option pricing)"
                      },
                      "dayCount": {
                        "type": "string"
                      },
                      "compounding": {
                        "type": "string"
                      },
                      "calendar": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "conventionsVersion",
                      "asOfConvention"
                    ]
                  },
                  "observations": {
                    "type": "object",
                    "properties": {
                      "spots": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      },
                      "riskFreeRates": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "number"
                        }
                      },
                      "dividendYields": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "number"
                        }
                      },
                      "volatilities": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "number"
                        }
                      },
                      "curves": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      },
                      "surfaces": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      },
                      "chains": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      }
                    },
                    "additionalProperties": false
                  },
                  "provenance": {
                    "type": "object",
                    "properties": {
                      "provider": {
                        "type": "string"
                      },
                      "dataset": {
                        "type": "string"
                      },
                      "asOf": {
                        "type": "number"
                      },
                      "receivedAt": {
                        "type": "number"
                      },
                      "sourceVersion": {
                        "type": "string"
                      },
                      "requestId": {
                        "type": "string"
                      },
                      "warnings": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "schemaVersion",
                  "asOf",
                  "conventions",
                  "observations"
                ],
                "description": "A Gate B market snapshot (totalfinance.market-snapshot); its interior is re-validated by the read door"
              },
              "currencyConversions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "baseCurrency": {
                      "type": "string",
                      "pattern": "^[A-Z]{3}$"
                    },
                    "quoteCurrency": {
                      "type": "string",
                      "pattern": "^[A-Z]{3}$"
                    },
                    "quotePerBase": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "baseCurrency",
                    "quoteCurrency",
                    "quotePerBase"
                  ]
                }
              }
            },
            "additionalProperties": false,
            "required": [
              "valuationDate",
              "market"
            ],
            "description": "The closing valuation mark (strictly after `from`)"
          },
          "instrumentClassification": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "underlying": {
                  "type": "string"
                },
                "assetClass": {
                  "type": "string"
                },
                "strategy": {
                  "type": "string"
                },
                "tags": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "additionalProperties": false
            },
            "description": "Identity metadata per instrument for grouping; unknown instruments group as unclassified"
          }
        },
        "additionalProperties": false,
        "required": [
          "ledger",
          "from",
          "to"
        ]
      },
      "totalfinance.portfolio.explain_pnl.output": {
        "type": "object",
        "properties": {
          "baseCurrency": {
            "type": "string"
          },
          "from": {
            "type": "object"
          },
          "to": {
            "type": "object"
          },
          "netAssetValueChange": {
            "type": "number"
          },
          "externalFlows": {
            "type": "number"
          },
          "investmentReturn": {
            "type": "number"
          },
          "components": {
            "type": "object",
            "description": "realized, unrealized, income, costs, financing, FX, total"
          },
          "residual": {
            "type": "number"
          },
          "byCurrency": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "groupings": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "baseCurrency",
          "from",
          "to",
          "netAssetValueChange",
          "externalFlows",
          "investmentReturn",
          "components",
          "residual",
          "byCurrency",
          "groupings",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.portfolio.explain_pnl.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.portfolio.explain_pnl.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.portfolio.inspect.input": {
        "type": "object",
        "properties": {
          "portfolio": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "totalfinance.portfolio-ledger",
                    "type": "string"
                  },
                  "schemaVersion": {
                    "const": 1,
                    "type": "number"
                  },
                  "portfolioId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "baseCurrency": {
                    "type": "string",
                    "pattern": "^[A-Z]{3}$"
                  },
                  "lotRelief": {
                    "type": "string",
                    "enum": [
                      "fifo",
                      "lifo",
                      "highest-cost",
                      "specific-lot"
                    ]
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "$ref": "#/$defs/PortfolioEventEnvelope"
                    }
                  },
                  "provenance": {
                    "$ref": "#/$defs/Provenance"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "schemaVersion",
                  "baseCurrency",
                  "lotRelief",
                  "events"
                ]
              },
              {
                "type": "string",
                "pattern": "^totalfinance:\\/\\/portfolios\\/"
              },
              {
                "type": "object",
                "properties": {
                  "uri": {
                    "type": "string",
                    "minLength": 1
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "report",
                      "job",
                      "portfolio",
                      "scenario",
                      "market",
                      "authorization",
                      "journal"
                    ]
                  },
                  "schema": {
                    "type": "string",
                    "minLength": 1
                  },
                  "version": {
                    "type": "string"
                  },
                  "contentHash": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "createdTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "expiresTimestampMs": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "provenance": {
                    "$ref": "#/$defs/Provenance"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "uri",
                  "kind",
                  "schema",
                  "version",
                  "contentHash",
                  "createdTimestampMs",
                  "expiresTimestampMs",
                  "provenance"
                ]
              }
            ]
          },
          "section": {
            "type": "string",
            "enum": [
              "summary",
              "events",
              "positions",
              "cash"
            ]
          },
          "offset": {
            "type": "integer",
            "minimum": 0
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          }
        },
        "additionalProperties": false,
        "required": [
          "portfolio"
        ],
        "$id": "https://totalfinance.dev/schemas/portfolio.inspect.input",
        "$defs": {
          "PortfolioEventEnvelope": {
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "eventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "schemaVersion": {
                    "const": 1,
                    "type": "number"
                  },
                  "sourceId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "accountId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "effectiveTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "recordedTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "correlationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "causationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "reversesEventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "provenance": {
                    "$ref": "#/$defs/Provenance"
                  },
                  "eventType": {},
                  "event": {}
                },
                "additionalProperties": false,
                "required": [
                  "eventId",
                  "schemaVersion",
                  "sourceId",
                  "accountId",
                  "effectiveTimestampMs",
                  "recordedTimestampMs",
                  "provenance",
                  "eventType",
                  "event"
                ]
              },
              {
                "anyOf": [
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.deposit",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashDeposit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.withdrawal",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashWithdrawal"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.conversion",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashConversion"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "trade.fill",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/TradeFill"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cost.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CostCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "income.received",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/IncomeReceived"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "financing.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FinancingCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.split",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSplit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.exercise",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExercise"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.assignment",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeAssignment"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.expiration",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExpiration"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.multiplier-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeMultiplierChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.variation-margin",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeVariationMargin"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.roll",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeRoll"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "fixed-income.redemption",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FixedIncomeRedemption"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.symbol-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSymbolChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.merger",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateMerger"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.spin-off",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSpinOff"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.return-of-capital",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateReturnOfCapital"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.cash-in-lieu",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateCashInLieu"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "position.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/PositionTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.reversal",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.reversal",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.correction",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.correction",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "replacement": {
                            "anyOf": [
                              {
                                "$ref": "#/$defs/CashDeposit"
                              },
                              {
                                "$ref": "#/$defs/CashWithdrawal"
                              },
                              {
                                "$ref": "#/$defs/CashTransfer"
                              },
                              {
                                "$ref": "#/$defs/CashConversion"
                              },
                              {
                                "$ref": "#/$defs/TradeFill"
                              },
                              {
                                "$ref": "#/$defs/CostCharge"
                              },
                              {
                                "$ref": "#/$defs/IncomeReceived"
                              },
                              {
                                "$ref": "#/$defs/FinancingCharge"
                              },
                              {
                                "$ref": "#/$defs/CorporateSplit"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExercise"
                              },
                              {
                                "$ref": "#/$defs/DerivativeAssignment"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExpiration"
                              },
                              {
                                "$ref": "#/$defs/DerivativeMultiplierChange"
                              },
                              {
                                "$ref": "#/$defs/DerivativeVariationMargin"
                              },
                              {
                                "$ref": "#/$defs/DerivativeRoll"
                              },
                              {
                                "$ref": "#/$defs/FixedIncomeRedemption"
                              },
                              {
                                "$ref": "#/$defs/CorporateSymbolChange"
                              },
                              {
                                "$ref": "#/$defs/CorporateMerger"
                              },
                              {
                                "$ref": "#/$defs/CorporateSpinOff"
                              },
                              {
                                "$ref": "#/$defs/CorporateReturnOfCapital"
                              },
                              {
                                "$ref": "#/$defs/CorporateCashInLieu"
                              },
                              {
                                "$ref": "#/$defs/PositionTransfer"
                              }
                            ]
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original",
                          "replacement"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.account-migration",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.account-migration",
                            "type": "string"
                          },
                          "fromAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "toAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "fromAccountId",
                          "toAccountId"
                        ]
                      }
                    }
                  }
                ]
              }
            ]
          },
          "Provenance": {
            "type": "object",
            "properties": {
              "provider": {
                "type": "string"
              },
              "dataset": {
                "type": "string"
              },
              "asOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "receivedAt": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "sourceVersion": {
                "type": "string"
              },
              "requestId": {
                "type": "string"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string",
                      "minLength": 1
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              }
            },
            "additionalProperties": false
          },
          "CashDeposit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.deposit",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashWithdrawal": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.withdrawal",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.transfer",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency",
              "fromAccountId",
              "toAccountId"
            ]
          },
          "CashConversion": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.conversion",
                "type": "string"
              },
              "fromCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "toCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "toAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromCurrency",
              "toCurrency",
              "fromAmount",
              "toAmount"
            ]
          },
          "TradeFill": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "trade.fill",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "side": {
                "type": "string",
                "enum": [
                  "buy",
                  "sell"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              },
              "contractMultiplier": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlementStyle": {
                "type": "string",
                "enum": [
                  "cash-on-trade",
                  "variation-margin"
                ]
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "accruedInterest": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "side",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "LotSelections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "lotId": {
                  "type": "string",
                  "minLength": 1
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "lotId",
                "quantity"
              ]
            },
            "minItems": 1
          },
          "Contract": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "option",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "call",
                      "put"
                    ]
                  },
                  "strikePricePerUnit": {
                    "type": "number"
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "type",
                  "strikePricePerUnit",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "future",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "perpetual",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId"
                ]
              }
            ]
          },
          "CostCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cost.charge",
                "type": "string"
              },
              "costType": {
                "type": "string",
                "enum": [
                  "commission",
                  "exchange-fee",
                  "regulatory-fee",
                  "slippage-adjustment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "costType",
              "amount",
              "currency"
            ]
          },
          "IncomeReceived": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "income.received",
                "type": "string"
              },
              "incomeType": {
                "type": "string",
                "enum": [
                  "dividend",
                  "coupon",
                  "interest",
                  "staking-reward",
                  "funding-receipt"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "incomeType",
              "amount",
              "currency"
            ]
          },
          "FinancingCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "financing.charge",
                "type": "string"
              },
              "financingType": {
                "type": "string",
                "enum": [
                  "margin-interest",
                  "borrow-charge",
                  "funding-payment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "financingType",
              "amount",
              "currency"
            ]
          },
          "CorporateSplit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.split",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesAfterSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "sharesBeforeSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "sharesAfterSplit",
              "sharesBeforeSplit"
            ]
          },
          "DerivativeExercise": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.exercise",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "Settlement": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "physical",
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "cash",
                    "type": "string"
                  },
                  "settlementPricePerUnit": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "settlementPricePerUnit"
                ]
              }
            ]
          },
          "DerivativeAssignment": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.assignment",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "DerivativeExpiration": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.expiration",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity"
            ]
          },
          "DerivativeMultiplierChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.multiplier-change",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "contractMultiplierAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "strikePricePerUnitAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "reason": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "contractMultiplierAfter"
            ]
          },
          "DerivativeVariationMargin": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.variation-margin",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settlementPricePerUnit": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "settlementPricePerUnit"
            ]
          },
          "DerivativeRoll": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.roll",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "closePricePerUnit": {
                "type": "number"
              },
              "openPricePerUnit": {
                "type": "number"
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId",
              "quantity",
              "closePricePerUnit",
              "openPricePerUnit"
            ]
          },
          "FixedIncomeRedemption": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "fixed-income.redemption",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "redemptionType": {
                "type": "string",
                "enum": [
                  "maturity",
                  "call",
                  "principal-paydown",
                  "sinking-fund"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "redemptionType",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "CorporateSymbolChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.symbol-change",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId"
            ]
          },
          "CorporateMerger": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.merger",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "cashPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId"
            ]
          },
          "CorporateSpinOff": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.spin-off",
                "type": "string"
              },
              "parentInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "childInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerParentShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "basisAllocationFraction": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "parentInstrumentId",
              "childInstrumentId",
              "sharesPerParentShare",
              "basisAllocationFraction"
            ]
          },
          "CorporateReturnOfCapital": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.return-of-capital",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "amountPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "amountPerShare",
              "currency"
            ]
          },
          "CorporateCashInLieu": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.cash-in-lieu",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "amount",
              "currency"
            ]
          },
          "PositionTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "position.transfer",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "fromAccountId",
              "toAccountId"
            ]
          }
        }
      },
      "totalfinance.portfolio.inspect.output": {
        "type": "object",
        "properties": {
          "portfolioId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "baseCurrency": {
            "type": "string"
          },
          "lotRelief": {
            "type": "string",
            "enum": [
              "fifo",
              "lifo",
              "highest-cost",
              "specific-lot"
            ]
          },
          "eventCount": {
            "type": "integer",
            "minimum": 0
          },
          "accountCount": {
            "type": "integer",
            "minimum": 0
          },
          "lastEffectiveTimestampMs": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "section": {
            "type": "string",
            "enum": [
              "summary",
              "events",
              "positions",
              "cash"
            ]
          },
          "offset": {
            "type": "integer",
            "minimum": 0
          },
          "limit": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "nextOffset": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": {}
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "portfolioId",
          "baseCurrency",
          "lotRelief",
          "eventCount",
          "accountCount",
          "lastEffectiveTimestampMs",
          "section",
          "offset",
          "limit",
          "total",
          "nextOffset",
          "rows"
        ]
      },
      "totalfinance.portfolio.inspect.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.portfolio.inspect.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.portfolio.rebalance_proposal.input": {
        "type": "object",
        "properties": {
          "ledger": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.portfolio-ledger",
                "type": "string"
              },
              "schemaVersion": {
                "type": "integer"
              },
              "portfolioId": {
                "type": "string"
              },
              "baseCurrency": {
                "type": "string"
              },
              "lotRelief": {
                "type": "string",
                "enum": [
                  "fifo",
                  "lifo",
                  "highest-cost",
                  "specific-lot"
                ]
              },
              "events": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": {}
                },
                "description": "Portfolio event envelopes (each re-validated by readPortfolioLedgerSnapshot)"
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  },
                  "dataset": {
                    "type": "string"
                  },
                  "asOf": {
                    "type": "number"
                  },
                  "receivedAt": {
                    "type": "number"
                  },
                  "sourceVersion": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "baseCurrency",
              "lotRelief",
              "events"
            ],
            "description": "A serialized portfolio ledger (totalfinance.portfolio-ledger, the FC7 JSON form)"
          },
          "asOf": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ],
            "description": "The valuation instant the proposal is sized at"
          },
          "market": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.market-snapshot",
                "type": "string"
              },
              "schemaVersion": {
                "type": "integer"
              },
              "asOf": {
                "type": "number",
                "description": "Epoch ms (resolved on the artifact)"
              },
              "conventions": {
                "type": "object",
                "properties": {
                  "conventionsVersion": {
                    "type": "string"
                  },
                  "asOfConvention": {
                    "type": "string",
                    "enum": [
                      "explicit-instant",
                      "date-midnight-utc"
                    ],
                    "description": "How asOf was expressed at create time (a bare date is refused by option pricing)"
                  },
                  "dayCount": {
                    "type": "string"
                  },
                  "compounding": {
                    "type": "string"
                  },
                  "calendar": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "conventionsVersion",
                  "asOfConvention"
                ]
              },
              "observations": {
                "type": "object",
                "properties": {
                  "spots": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "riskFreeRates": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number"
                    }
                  },
                  "dividendYields": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number"
                    }
                  },
                  "volatilities": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number"
                    }
                  },
                  "curves": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "surfaces": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "chains": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  },
                  "dataset": {
                    "type": "string"
                  },
                  "asOf": {
                    "type": "number"
                  },
                  "receivedAt": {
                    "type": "number"
                  },
                  "sourceVersion": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "asOf",
              "conventions",
              "observations"
            ],
            "description": "A Gate B market snapshot (totalfinance.market-snapshot); its interior is re-validated by the read door"
          },
          "currencyConversions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "baseCurrency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "quoteCurrency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "quotePerBase": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "baseCurrency",
                "quoteCurrency",
                "quotePerBase"
              ]
            }
          },
          "policy": {
            "type": "object",
            "properties": {
              "targets": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "group": {
                      "type": "object",
                      "properties": {
                        "instrumentId": {
                          "type": "string"
                        },
                        "sleeveId": {
                          "type": "string"
                        },
                        "assetClass": {
                          "type": "string"
                        },
                        "currency": {
                          "type": "string"
                        },
                        "tag": {
                          "type": "string"
                        },
                        "underlying": {
                          "type": "string"
                        },
                        "strategy": {
                          "type": "string"
                        }
                      },
                      "additionalProperties": false,
                      "description": "Exactly one group key"
                    },
                    "weight": {
                      "type": "number"
                    },
                    "riskBudget": {
                      "type": "number"
                    },
                    "driftBand": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "group"
                  ]
                }
              },
              "model": {
                "type": "object",
                "additionalProperties": {},
                "description": "A model portfolio envelope (totalfinance.model-portfolio), validated by the policy grammar"
              },
              "withinGroupAllocation": {
                "type": "string",
                "enum": [
                  "proportional-to-current",
                  "equal"
                ]
              },
              "driftBand": {
                "type": "number"
              },
              "reviewCadenceDays": {
                "type": "number"
              },
              "maximumTurnover": {
                "type": "number"
              },
              "maximumEstimatedTransactionCost": {
                "type": "number"
              },
              "minimumCash": {
                "type": "number"
              },
              "minimumCashWeight": {
                "type": "number"
              },
              "limits": {
                "type": "object",
                "properties": {
                  "maximumPositionWeight": {
                    "type": "number"
                  },
                  "maximumGroupWeights": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "group": {
                          "type": "object",
                          "properties": {
                            "instrumentId": {
                              "type": "string"
                            },
                            "sleeveId": {
                              "type": "string"
                            },
                            "assetClass": {
                              "type": "string"
                            },
                            "currency": {
                              "type": "string"
                            },
                            "tag": {
                              "type": "string"
                            },
                            "underlying": {
                              "type": "string"
                            },
                            "strategy": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false,
                          "description": "Exactly one group key"
                        },
                        "maximumWeight": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "group",
                        "maximumWeight"
                      ]
                    }
                  },
                  "maximumGrossLeverage": {
                    "type": "number"
                  },
                  "maximumDrawdown": {
                    "type": "number"
                  },
                  "maximumDailyLoss": {
                    "type": "number"
                  },
                  "maximumDaysToLiquidate": {
                    "type": "number"
                  },
                  "minimumSettledCash": {
                    "type": "number"
                  }
                },
                "additionalProperties": false
              },
              "allowedInstruments": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "restrictedInstruments": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "allowedAccounts": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "benchmark": {
                "type": "object",
                "properties": {
                  "benchmarkId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "asOf": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "string"
                      }
                    ],
                    "description": "Epoch ms, YYYY-MM-DD, or a zoned ISO datetime"
                  },
                  "constituents": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "instrumentId": {
                          "type": "string"
                        },
                        "weight": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "instrumentId",
                        "weight"
                      ]
                    }
                  }
                },
                "additionalProperties": false,
                "required": [
                  "benchmarkId"
                ]
              },
              "performanceObjective": {
                "type": "string"
              },
              "contributionHandling": {
                "type": "string",
                "enum": [
                  "invest-to-targets",
                  "hold-as-cash"
                ]
              },
              "withdrawalHandling": {
                "type": "string",
                "enum": [
                  "raise-from-overweights",
                  "pro-rata"
                ]
              },
              "incomeReinvestment": {
                "type": "string",
                "enum": [
                  "reinvest",
                  "hold-as-cash"
                ]
              },
              "lotSelectionObjective": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "description": "Targets come from the policy (inline targets or a model)"
          },
          "instrumentClassification": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "underlying": {
                  "type": "string"
                },
                "assetClass": {
                  "type": "string"
                },
                "strategy": {
                  "type": "string"
                },
                "tags": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "additionalProperties": false
            },
            "description": "Identity metadata per instrument for grouping; unknown instruments group as unclassified"
          },
          "scope": {
            "type": "string",
            "enum": [
              "to-target",
              "drift-only"
            ],
            "description": "'to-target' trades every target to weight; 'drift-only' trades only targets outside their band"
          },
          "externalFlow": {
            "type": "object",
            "properties": {
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "amount",
              "currency"
            ],
            "description": "A contribution (positive) or withdrawal (negative) the proposal sizes around"
          },
          "tradingAccountId": {
            "type": "string"
          },
          "averageDailyVolumes": {
            "type": "object",
            "additionalProperties": {
              "type": "number"
            }
          },
          "lotSizes": {
            "type": "object",
            "additionalProperties": {
              "type": "number"
            }
          },
          "defaultLotSize": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "minimumNotional": {
            "type": "number",
            "minimum": 0
          },
          "transactionCosts": {
            "type": "object",
            "properties": {
              "commissionPerTrade": {
                "type": "number",
                "minimum": 0
              },
              "commissionPerUnit": {
                "type": "number",
                "minimum": 0
              },
              "spreadBasisPoints": {
                "type": "number",
                "minimum": 0
              },
              "slippageBasisPoints": {
                "type": "number",
                "minimum": 0
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false,
        "required": [
          "ledger",
          "asOf",
          "market",
          "policy",
          "scope"
        ]
      },
      "totalfinance.portfolio.rebalance_proposal.output": {
        "type": "object",
        "properties": {
          "asOf": {
            "type": "number"
          },
          "baseCurrency": {
            "type": "string"
          },
          "netAssetValue": {
            "type": "number"
          },
          "netAssetValueAfterFlow": {
            "type": "number"
          },
          "weights": {
            "type": "object"
          },
          "cash": {
            "type": "object"
          },
          "trades": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "estimates": {
            "type": "object"
          },
          "objective": {
            "type": "object"
          },
          "unresolvedTargets": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "asOf",
          "baseCurrency",
          "netAssetValue",
          "netAssetValueAfterFlow",
          "weights",
          "cash",
          "trades",
          "estimates",
          "objective",
          "unresolvedTargets",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.portfolio.rebalance_proposal.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.portfolio.rebalance_proposal.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.portfolio.record_events.input": {
        "type": "object",
        "properties": {
          "portfolio": {
            "anyOf": [
              {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "totalfinance.portfolio-ledger",
                        "type": "string"
                      },
                      "schemaVersion": {
                        "const": 1,
                        "type": "number"
                      },
                      "portfolioId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "baseCurrency": {
                        "type": "string",
                        "pattern": "^[A-Z]{3}$"
                      },
                      "lotRelief": {
                        "type": "string",
                        "enum": [
                          "fifo",
                          "lifo",
                          "highest-cost",
                          "specific-lot"
                        ]
                      },
                      "events": {
                        "type": "array",
                        "items": {
                          "$ref": "#/$defs/PortfolioEventEnvelope"
                        }
                      },
                      "provenance": {
                        "$ref": "#/$defs/Provenance"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "schemaVersion",
                      "baseCurrency",
                      "lotRelief",
                      "events"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "schemaVersion": {
                        "const": 1,
                        "type": "number"
                      },
                      "portfolioId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "baseCurrency": {
                        "type": "string",
                        "pattern": "^[A-Z]{3}$"
                      },
                      "lotRelief": {
                        "type": "string",
                        "enum": [
                          "fifo",
                          "lifo",
                          "highest-cost",
                          "specific-lot"
                        ]
                      },
                      "accounts": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "cashBalances": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "properties": {
                                  "totalAmount": {
                                    "type": "number"
                                  },
                                  "settlementSchedule": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "eventId": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "amount": {
                                          "type": "number"
                                        },
                                        "settleTimestampMs": {
                                          "type": "number",
                                          "description": "Epoch milliseconds"
                                        }
                                      },
                                      "additionalProperties": false,
                                      "required": [
                                        "eventId",
                                        "amount",
                                        "settleTimestampMs"
                                      ]
                                    }
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "totalAmount",
                                  "settlementSchedule"
                                ]
                              }
                            },
                            "positions": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "properties": {
                                  "instrumentId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "currency": {
                                    "type": "string",
                                    "pattern": "^[A-Z]{3}$"
                                  },
                                  "contractMultiplier": {
                                    "type": "number",
                                    "exclusiveMinimum": 0
                                  },
                                  "settlementStyle": {
                                    "type": "string",
                                    "enum": [
                                      "cash-on-trade",
                                      "variation-margin"
                                    ]
                                  },
                                  "contract": {
                                    "$ref": "#/$defs/Contract"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "lots": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "lotId": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "openedByEventId": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "openedTimestampMs": {
                                          "type": "number",
                                          "description": "Epoch milliseconds"
                                        },
                                        "quantity": {
                                          "type": "number"
                                        },
                                        "costBasisPerUnit": {
                                          "type": "number"
                                        }
                                      },
                                      "additionalProperties": false,
                                      "required": [
                                        "lotId",
                                        "openedByEventId",
                                        "openedTimestampMs",
                                        "quantity",
                                        "costBasisPerUnit"
                                      ]
                                    }
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "instrumentId",
                                  "currency",
                                  "contractMultiplier",
                                  "settlementStyle",
                                  "quantity",
                                  "lots"
                                ]
                              }
                            },
                            "realizedPnl": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "incomeReceived": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "transactionCosts": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "financingCosts": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "realizedPnlByInstrument": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "number"
                                }
                              }
                            },
                            "incomeByInstrument": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "number"
                                }
                              }
                            },
                            "transactionCostsByInstrument": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "number"
                                }
                              }
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "cashBalances",
                            "positions",
                            "realizedPnl",
                            "incomeReceived",
                            "transactionCosts",
                            "financingCosts",
                            "realizedPnlByInstrument",
                            "incomeByInstrument",
                            "transactionCostsByInstrument"
                          ]
                        }
                      },
                      "appliedEvents": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      "eventCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "lastEffectiveTimestampMs": {
                        "anyOf": [
                          {
                            "type": "number",
                            "description": "Epoch milliseconds"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "lotSequence": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "fillEffects": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "accountId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "instrumentId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "currency": {
                              "type": "string",
                              "pattern": "^[A-Z]{3}$"
                            },
                            "openedLotIds": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "relievedQuantity": {
                              "type": "number"
                            },
                            "realizedPnl": {
                              "type": "number"
                            },
                            "cashDelta": {
                              "type": "number"
                            },
                            "accruedInterest": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "accountId",
                            "instrumentId",
                            "currency",
                            "openedLotIds",
                            "relievedQuantity",
                            "realizedPnl",
                            "cashDelta",
                            "accruedInterest"
                          ]
                        }
                      },
                      "reversals": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      "accountMigrations": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "eventId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "fromAccountId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "toAccountId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "effectiveTimestampMs": {
                              "type": "number",
                              "description": "Epoch milliseconds"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "eventId",
                            "fromAccountId",
                            "toAccountId",
                            "effectiveTimestampMs"
                          ]
                        }
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "schemaVersion",
                      "baseCurrency",
                      "lotRelief",
                      "accounts",
                      "appliedEvents",
                      "eventCount",
                      "lastEffectiveTimestampMs",
                      "lotSequence",
                      "fillEffects",
                      "reversals",
                      "accountMigrations"
                    ]
                  }
                ]
              },
              {
                "type": "string",
                "pattern": "^totalfinance:\\/\\/portfolios\\/"
              }
            ]
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/PortfolioEventEnvelope"
            },
            "minItems": 1,
            "description": "Portfolio event envelopes to apply, in order"
          },
          "createdTimestampMs": {
            "type": "integer",
            "description": "Epoch ms stamped on the new ledger’s handle — the caller’s clock"
          }
        },
        "additionalProperties": false,
        "required": [
          "portfolio",
          "events",
          "createdTimestampMs"
        ],
        "$id": "https://totalfinance.dev/schemas/portfolio.record_events.input",
        "$defs": {
          "PortfolioEventEnvelope": {
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "eventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "schemaVersion": {
                    "const": 1,
                    "type": "number"
                  },
                  "sourceId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "accountId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "effectiveTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "recordedTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "correlationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "causationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "reversesEventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "provenance": {
                    "$ref": "#/$defs/Provenance"
                  },
                  "eventType": {},
                  "event": {}
                },
                "additionalProperties": false,
                "required": [
                  "eventId",
                  "schemaVersion",
                  "sourceId",
                  "accountId",
                  "effectiveTimestampMs",
                  "recordedTimestampMs",
                  "provenance",
                  "eventType",
                  "event"
                ]
              },
              {
                "anyOf": [
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.deposit",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashDeposit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.withdrawal",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashWithdrawal"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.conversion",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashConversion"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "trade.fill",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/TradeFill"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cost.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CostCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "income.received",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/IncomeReceived"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "financing.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FinancingCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.split",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSplit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.exercise",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExercise"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.assignment",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeAssignment"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.expiration",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExpiration"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.multiplier-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeMultiplierChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.variation-margin",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeVariationMargin"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.roll",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeRoll"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "fixed-income.redemption",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FixedIncomeRedemption"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.symbol-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSymbolChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.merger",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateMerger"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.spin-off",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSpinOff"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.return-of-capital",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateReturnOfCapital"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.cash-in-lieu",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateCashInLieu"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "position.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/PositionTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.reversal",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.reversal",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.correction",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.correction",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "replacement": {
                            "anyOf": [
                              {
                                "$ref": "#/$defs/CashDeposit"
                              },
                              {
                                "$ref": "#/$defs/CashWithdrawal"
                              },
                              {
                                "$ref": "#/$defs/CashTransfer"
                              },
                              {
                                "$ref": "#/$defs/CashConversion"
                              },
                              {
                                "$ref": "#/$defs/TradeFill"
                              },
                              {
                                "$ref": "#/$defs/CostCharge"
                              },
                              {
                                "$ref": "#/$defs/IncomeReceived"
                              },
                              {
                                "$ref": "#/$defs/FinancingCharge"
                              },
                              {
                                "$ref": "#/$defs/CorporateSplit"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExercise"
                              },
                              {
                                "$ref": "#/$defs/DerivativeAssignment"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExpiration"
                              },
                              {
                                "$ref": "#/$defs/DerivativeMultiplierChange"
                              },
                              {
                                "$ref": "#/$defs/DerivativeVariationMargin"
                              },
                              {
                                "$ref": "#/$defs/DerivativeRoll"
                              },
                              {
                                "$ref": "#/$defs/FixedIncomeRedemption"
                              },
                              {
                                "$ref": "#/$defs/CorporateSymbolChange"
                              },
                              {
                                "$ref": "#/$defs/CorporateMerger"
                              },
                              {
                                "$ref": "#/$defs/CorporateSpinOff"
                              },
                              {
                                "$ref": "#/$defs/CorporateReturnOfCapital"
                              },
                              {
                                "$ref": "#/$defs/CorporateCashInLieu"
                              },
                              {
                                "$ref": "#/$defs/PositionTransfer"
                              }
                            ]
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original",
                          "replacement"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.account-migration",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.account-migration",
                            "type": "string"
                          },
                          "fromAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "toAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "fromAccountId",
                          "toAccountId"
                        ]
                      }
                    }
                  }
                ]
              }
            ]
          },
          "Provenance": {
            "type": "object",
            "properties": {
              "provider": {
                "type": "string"
              },
              "dataset": {
                "type": "string"
              },
              "asOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "receivedAt": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "sourceVersion": {
                "type": "string"
              },
              "requestId": {
                "type": "string"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string",
                      "minLength": 1
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              }
            },
            "additionalProperties": false
          },
          "Contract": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "option",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "call",
                      "put"
                    ]
                  },
                  "strikePricePerUnit": {
                    "type": "number"
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "type",
                  "strikePricePerUnit",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "future",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "perpetual",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId"
                ]
              }
            ]
          },
          "CashDeposit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.deposit",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashWithdrawal": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.withdrawal",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.transfer",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency",
              "fromAccountId",
              "toAccountId"
            ]
          },
          "CashConversion": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.conversion",
                "type": "string"
              },
              "fromCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "toCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "toAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromCurrency",
              "toCurrency",
              "fromAmount",
              "toAmount"
            ]
          },
          "TradeFill": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "trade.fill",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "side": {
                "type": "string",
                "enum": [
                  "buy",
                  "sell"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              },
              "contractMultiplier": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlementStyle": {
                "type": "string",
                "enum": [
                  "cash-on-trade",
                  "variation-margin"
                ]
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "accruedInterest": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "side",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "LotSelections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "lotId": {
                  "type": "string",
                  "minLength": 1
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "lotId",
                "quantity"
              ]
            },
            "minItems": 1
          },
          "CostCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cost.charge",
                "type": "string"
              },
              "costType": {
                "type": "string",
                "enum": [
                  "commission",
                  "exchange-fee",
                  "regulatory-fee",
                  "slippage-adjustment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "costType",
              "amount",
              "currency"
            ]
          },
          "IncomeReceived": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "income.received",
                "type": "string"
              },
              "incomeType": {
                "type": "string",
                "enum": [
                  "dividend",
                  "coupon",
                  "interest",
                  "staking-reward",
                  "funding-receipt"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "incomeType",
              "amount",
              "currency"
            ]
          },
          "FinancingCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "financing.charge",
                "type": "string"
              },
              "financingType": {
                "type": "string",
                "enum": [
                  "margin-interest",
                  "borrow-charge",
                  "funding-payment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "financingType",
              "amount",
              "currency"
            ]
          },
          "CorporateSplit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.split",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesAfterSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "sharesBeforeSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "sharesAfterSplit",
              "sharesBeforeSplit"
            ]
          },
          "DerivativeExercise": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.exercise",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "Settlement": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "physical",
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "cash",
                    "type": "string"
                  },
                  "settlementPricePerUnit": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "settlementPricePerUnit"
                ]
              }
            ]
          },
          "DerivativeAssignment": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.assignment",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "DerivativeExpiration": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.expiration",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity"
            ]
          },
          "DerivativeMultiplierChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.multiplier-change",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "contractMultiplierAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "strikePricePerUnitAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "reason": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "contractMultiplierAfter"
            ]
          },
          "DerivativeVariationMargin": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.variation-margin",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settlementPricePerUnit": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "settlementPricePerUnit"
            ]
          },
          "DerivativeRoll": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.roll",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "closePricePerUnit": {
                "type": "number"
              },
              "openPricePerUnit": {
                "type": "number"
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId",
              "quantity",
              "closePricePerUnit",
              "openPricePerUnit"
            ]
          },
          "FixedIncomeRedemption": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "fixed-income.redemption",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "redemptionType": {
                "type": "string",
                "enum": [
                  "maturity",
                  "call",
                  "principal-paydown",
                  "sinking-fund"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "redemptionType",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "CorporateSymbolChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.symbol-change",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId"
            ]
          },
          "CorporateMerger": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.merger",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "cashPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId"
            ]
          },
          "CorporateSpinOff": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.spin-off",
                "type": "string"
              },
              "parentInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "childInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerParentShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "basisAllocationFraction": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "parentInstrumentId",
              "childInstrumentId",
              "sharesPerParentShare",
              "basisAllocationFraction"
            ]
          },
          "CorporateReturnOfCapital": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.return-of-capital",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "amountPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "amountPerShare",
              "currency"
            ]
          },
          "CorporateCashInLieu": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.cash-in-lieu",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "amount",
              "currency"
            ]
          },
          "PositionTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "position.transfer",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "fromAccountId",
              "toAccountId"
            ]
          }
        }
      },
      "totalfinance.portfolio.record_events.output": {
        "type": "object",
        "properties": {
          "handle": {
            "type": "object",
            "properties": {
              "uri": {
                "type": "string",
                "minLength": 1
              },
              "kind": {
                "type": "string",
                "enum": [
                  "report",
                  "job",
                  "portfolio",
                  "scenario",
                  "market",
                  "authorization",
                  "journal"
                ]
              },
              "schema": {
                "type": "string",
                "minLength": 1
              },
              "version": {
                "type": "string"
              },
              "contentHash": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "createdTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "expiresTimestampMs": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  },
                  "dataset": {
                    "type": "string"
                  },
                  "asOf": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "receivedAt": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "sourceVersion": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "minLength": 1
                        },
                        "message": {
                          "type": "string"
                        },
                        "severity": {
                          "type": "string",
                          "enum": [
                            "info",
                            "warn",
                            "error"
                          ]
                        },
                        "context": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message",
                        "severity"
                      ]
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "uri",
              "kind",
              "schema",
              "version",
              "contentHash",
              "createdTimestampMs",
              "expiresTimestampMs",
              "provenance"
            ]
          },
          "applied": {
            "type": "integer",
            "minimum": 0
          },
          "eventCount": {
            "type": "integer",
            "minimum": 0
          },
          "baseCurrency": {
            "type": "string"
          },
          "lastEffectiveTimestampMs": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "handle",
          "applied",
          "eventCount",
          "baseCurrency",
          "lastEffectiveTimestampMs"
        ],
        "$id": "https://totalfinance.dev/schemas/portfolio.record_events.output"
      },
      "totalfinance.portfolio.record_events.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.portfolio.record_events.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.portfolio.snapshot.input": {
        "type": "object",
        "properties": {
          "portfolio": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "totalfinance.portfolio-ledger",
                    "type": "string"
                  },
                  "schemaVersion": {
                    "type": "integer"
                  },
                  "portfolioId": {
                    "type": "string"
                  },
                  "baseCurrency": {
                    "type": "string"
                  },
                  "lotRelief": {
                    "type": "string",
                    "enum": [
                      "fifo",
                      "lifo",
                      "highest-cost",
                      "specific-lot"
                    ]
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": {}
                    },
                    "description": "Portfolio event envelopes (each re-validated by readPortfolioLedgerSnapshot)"
                  },
                  "provenance": {
                    "type": "object",
                    "properties": {
                      "provider": {
                        "type": "string"
                      },
                      "dataset": {
                        "type": "string"
                      },
                      "asOf": {
                        "type": "number"
                      },
                      "receivedAt": {
                        "type": "number"
                      },
                      "sourceVersion": {
                        "type": "string"
                      },
                      "requestId": {
                        "type": "string"
                      },
                      "warnings": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "schemaVersion",
                  "baseCurrency",
                  "lotRelief",
                  "events"
                ],
                "description": "A serialized portfolio ledger (totalfinance.portfolio-ledger, the FC7 JSON form)"
              },
              {
                "type": "object",
                "properties": {
                  "schemaVersion": {
                    "type": "integer"
                  },
                  "portfolioId": {
                    "type": "string"
                  },
                  "baseCurrency": {
                    "type": "string"
                  },
                  "lotRelief": {
                    "type": "string",
                    "enum": [
                      "fifo",
                      "lifo",
                      "highest-cost",
                      "specific-lot"
                    ]
                  },
                  "accounts": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "appliedEvents": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "eventCount": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "lastEffectiveTimestampMs": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "lotSequence": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "fillEffects": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "reversals": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "accountMigrations": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false,
                "required": [
                  "schemaVersion",
                  "baseCurrency",
                  "lotRelief",
                  "accounts",
                  "appliedEvents",
                  "eventCount",
                  "lastEffectiveTimestampMs",
                  "lotSequence",
                  "fillEffects",
                  "reversals",
                  "accountMigrations"
                ],
                "description": "A derived PortfolioState (from applyPortfolioEvents or ledger.state)"
              }
            ],
            "description": "A serialized ledger envelope (re-hydrated through readPortfolioLedgerSnapshot) or a PortfolioState"
          },
          "asOf": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ],
            "description": "The valuation instant"
          },
          "market": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.market-snapshot",
                "type": "string"
              },
              "schemaVersion": {
                "type": "integer"
              },
              "asOf": {
                "type": "number",
                "description": "Epoch ms (resolved on the artifact)"
              },
              "conventions": {
                "type": "object",
                "properties": {
                  "conventionsVersion": {
                    "type": "string"
                  },
                  "asOfConvention": {
                    "type": "string",
                    "enum": [
                      "explicit-instant",
                      "date-midnight-utc"
                    ],
                    "description": "How asOf was expressed at create time (a bare date is refused by option pricing)"
                  },
                  "dayCount": {
                    "type": "string"
                  },
                  "compounding": {
                    "type": "string"
                  },
                  "calendar": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "conventionsVersion",
                  "asOfConvention"
                ]
              },
              "observations": {
                "type": "object",
                "properties": {
                  "spots": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "riskFreeRates": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number"
                    }
                  },
                  "dividendYields": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number"
                    }
                  },
                  "volatilities": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number"
                    }
                  },
                  "curves": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "surfaces": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "chains": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  },
                  "dataset": {
                    "type": "string"
                  },
                  "asOf": {
                    "type": "number"
                  },
                  "receivedAt": {
                    "type": "number"
                  },
                  "sourceVersion": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "asOf",
              "conventions",
              "observations"
            ],
            "description": "A Gate B market snapshot (totalfinance.market-snapshot); its interior is re-validated by the read door"
          },
          "currencyConversions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "baseCurrency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "quoteCurrency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "quotePerBase": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "baseCurrency",
                "quoteCurrency",
                "quotePerBase"
              ]
            },
            "description": "Quotes to the base currency — required exactly when the portfolio holds non-base currency"
          }
        },
        "additionalProperties": false,
        "required": [
          "portfolio",
          "asOf",
          "market"
        ]
      },
      "totalfinance.portfolio.snapshot.output": {
        "type": "object",
        "properties": {
          "asOf": {
            "type": "number"
          },
          "baseCurrency": {
            "type": "string"
          },
          "netAssetValue": {
            "type": "number"
          },
          "cash": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "totalCashBaseCurrencyValue": {
            "type": "number"
          },
          "positions": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "totalPositionsBaseCurrencyValue": {
            "type": "number"
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "asOf",
          "baseCurrency",
          "netAssetValue",
          "cash",
          "totalCashBaseCurrencyValue",
          "positions",
          "totalPositionsBaseCurrencyValue",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.portfolio.snapshot.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.portfolio.snapshot.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.research.event_study.input": {
        "type": "object",
        "properties": {
          "events": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "eventId": {
                  "type": "string",
                  "minLength": 1
                },
                "instrumentId": {
                  "type": "string",
                  "minLength": 1
                },
                "eventType": {
                  "type": "string"
                },
                "announcedTimestampMs": {
                  "type": "number"
                },
                "effectiveTimestampMs": {
                  "type": "number"
                },
                "metadata": {
                  "type": "object",
                  "additionalProperties": {}
                }
              },
              "additionalProperties": false,
              "required": [
                "eventId",
                "instrumentId",
                "eventType",
                "announcedTimestampMs"
              ]
            }
          },
          "returnObservations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "instrumentId": {
                  "type": "string",
                  "minLength": 1
                },
                "tradingSessionDate": {
                  "type": "string",
                  "format": "date"
                },
                "simpleReturn": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "instrumentId",
                "tradingSessionDate",
                "simpleReturn"
              ]
            }
          },
          "marketReturns": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "tradingSessionDate": {
                  "type": "string",
                  "format": "date"
                },
                "simpleReturn": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "tradingSessionDate",
                "simpleReturn"
              ]
            },
            "description": "Required by the 'market-adjusted' and 'market' models"
          },
          "eventWindow": {
            "type": "object",
            "properties": {
              "startTradingSessionOffset": {
                "type": "integer"
              },
              "endTradingSessionOffset": {
                "type": "integer"
              }
            },
            "additionalProperties": false,
            "required": [
              "startTradingSessionOffset",
              "endTradingSessionOffset"
            ]
          },
          "estimationWindow": {
            "type": "object",
            "properties": {
              "startTradingSessionOffset": {
                "type": "integer"
              },
              "endTradingSessionOffset": {
                "type": "integer"
              }
            },
            "additionalProperties": false,
            "required": [
              "startTradingSessionOffset",
              "endTradingSessionOffset"
            ],
            "description": "Required by 'mean-adjusted' and 'market'; must end strictly before the event window starts"
          },
          "expectedReturnModel": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "model": {
                    "const": "mean-adjusted",
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "model"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "model": {
                    "const": "market-adjusted",
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "model"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "model": {
                    "const": "market",
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "model"
                ]
              }
            ],
            "description": "The serializable models; a 'custom' expected-return function is SDK-only"
          },
          "sessionPolicy": {
            "type": "string",
            "enum": [
              "announcement-session",
              "next-session"
            ]
          },
          "overlappingEventPolicy": {
            "type": "string",
            "enum": [
              "reject",
              "allow-contaminated"
            ]
          },
          "cumulativeConvention": {
            "type": "string",
            "enum": [
              "sum",
              "compound"
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "events",
          "returnObservations",
          "eventWindow",
          "expectedReturnModel",
          "overlappingEventPolicy"
        ]
      },
      "totalfinance.research.event_study.output": {
        "type": "object",
        "properties": {
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "averageAbnormalReturns": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        },
        "required": [
          "assumptions",
          "diagnostics",
          "events",
          "averageAbnormalReturns"
        ]
      },
      "totalfinance.research.event_study.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.research.event_study.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.research.rank.input": {
        "type": "object",
        "properties": {
          "universeId": {
            "type": "string",
            "minLength": 1
          },
          "asOf": {
            "type": "number",
            "description": "Epoch ms; the latest observation at or before it is used per instrument"
          },
          "observations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "instrumentId": {
                  "type": "string",
                  "minLength": 1
                },
                "availableTimestampMs": {
                  "type": "number"
                },
                "fields": {
                  "type": "object",
                  "additionalProperties": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "string"
                      },
                      {
                        "type": "boolean"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "description": "Declared fields only; null is a stated missing value"
                }
              },
              "additionalProperties": false,
              "required": [
                "instrumentId",
                "availableTimestampMs",
                "fields"
              ]
            }
          },
          "fieldDefinitions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "fieldName": {
                  "type": "string",
                  "minLength": 1
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "numeric",
                    "category",
                    "text",
                    "boolean"
                  ]
                },
                "unit": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "fieldName",
                "kind"
              ]
            },
            "minItems": 1
          },
          "rankBy": {
            "type": "object",
            "properties": {
              "field": {
                "type": "string"
              },
              "direction": {
                "type": "string",
                "enum": [
                  "ascending",
                  "descending"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "field",
              "direction"
            ]
          },
          "tiePolicy": {
            "type": "string",
            "enum": [
              "competition",
              "dense",
              "ordinal"
            ]
          },
          "missingValuePolicy": {
            "type": "string",
            "enum": [
              "exclude",
              "evaluate-as-false"
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "universeId",
          "asOf",
          "observations",
          "fieldDefinitions",
          "rankBy",
          "tiePolicy",
          "missingValuePolicy"
        ]
      },
      "totalfinance.research.rank.output": {
        "type": "object",
        "properties": {
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "{ instrumentId, value, rank }"
          }
        },
        "required": [
          "assumptions",
          "diagnostics",
          "rows"
        ]
      },
      "totalfinance.research.rank.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.research.rank.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.research.score.input": {
        "type": "object",
        "properties": {
          "universeId": {
            "type": "string",
            "minLength": 1
          },
          "asOf": {
            "type": "number",
            "description": "Epoch ms; the latest observation at or before it is used per instrument"
          },
          "observations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "instrumentId": {
                  "type": "string",
                  "minLength": 1
                },
                "availableTimestampMs": {
                  "type": "number"
                },
                "fields": {
                  "type": "object",
                  "additionalProperties": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "string"
                      },
                      {
                        "type": "boolean"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "description": "Declared fields only; null is a stated missing value"
                }
              },
              "additionalProperties": false,
              "required": [
                "instrumentId",
                "availableTimestampMs",
                "fields"
              ]
            }
          },
          "fieldDefinitions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "fieldName": {
                  "type": "string",
                  "minLength": 1
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "numeric",
                    "category",
                    "text",
                    "boolean"
                  ]
                },
                "unit": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "fieldName",
                "kind"
              ]
            },
            "minItems": 1
          },
          "components": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string"
                },
                "weight": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "direction": {
                  "type": "string",
                  "enum": [
                    "higher-is-better",
                    "lower-is-better"
                  ]
                },
                "standardization": {
                  "type": "string",
                  "enum": [
                    "z-score",
                    "percentile-rank"
                  ]
                }
              },
              "additionalProperties": false,
              "required": [
                "field",
                "weight",
                "direction",
                "standardization"
              ]
            },
            "minItems": 1
          },
          "missingValuePolicy": {
            "type": "string",
            "enum": [
              "exclude",
              "renormalize-weights"
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "universeId",
          "asOf",
          "observations",
          "fieldDefinitions",
          "components",
          "missingValuePolicy"
        ]
      },
      "totalfinance.research.score.output": {
        "type": "object",
        "properties": {
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "{ instrumentId, score, componentsUsed }"
          }
        },
        "required": [
          "assumptions",
          "diagnostics",
          "rows"
        ]
      },
      "totalfinance.research.score.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.research.score.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.research.screen.input": {
        "type": "object",
        "properties": {
          "universeId": {
            "type": "string",
            "minLength": 1
          },
          "asOf": {
            "type": "number",
            "description": "Epoch ms; the latest observation at or before it is used per instrument"
          },
          "observations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "instrumentId": {
                  "type": "string",
                  "minLength": 1
                },
                "availableTimestampMs": {
                  "type": "number"
                },
                "fields": {
                  "type": "object",
                  "additionalProperties": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "string"
                      },
                      {
                        "type": "boolean"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "description": "Declared fields only; null is a stated missing value"
                }
              },
              "additionalProperties": false,
              "required": [
                "instrumentId",
                "availableTimestampMs",
                "fields"
              ]
            }
          },
          "fieldDefinitions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "fieldName": {
                  "type": "string",
                  "minLength": 1
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "numeric",
                    "category",
                    "text",
                    "boolean"
                  ]
                },
                "unit": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "fieldName",
                "kind"
              ]
            },
            "minItems": 1
          },
          "filter": {
            "$id": "https://totalfinance.dev/schemas/research/screen-filter",
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "all": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "$ref": "https://totalfinance.dev/schemas/research/screen-filter"
                    }
                  }
                },
                "required": [
                  "all"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "any": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "$ref": "https://totalfinance.dev/schemas/research/screen-filter"
                    }
                  }
                },
                "required": [
                  "any"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "not": {
                    "$ref": "https://totalfinance.dev/schemas/research/screen-filter"
                  }
                },
                "required": [
                  "not"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "field": {
                    "type": "string"
                  },
                  "operator": {
                    "type": "string",
                    "enum": [
                      "greaterThan",
                      "greaterThanOrEqual",
                      "lessThan",
                      "lessThanOrEqual"
                    ]
                  },
                  "value": {
                    "type": "number"
                  }
                },
                "required": [
                  "field",
                  "operator",
                  "value"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "field": {
                    "type": "string"
                  },
                  "operator": {
                    "type": "string",
                    "enum": [
                      "equals",
                      "notEquals"
                    ]
                  },
                  "value": {
                    "type": [
                      "number",
                      "string",
                      "boolean"
                    ]
                  }
                },
                "required": [
                  "field",
                  "operator",
                  "value"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "field": {
                    "type": "string"
                  },
                  "operator": {
                    "type": "string",
                    "enum": [
                      "between"
                    ]
                  },
                  "from": {
                    "type": "number"
                  },
                  "to": {
                    "type": "number"
                  }
                },
                "required": [
                  "field",
                  "operator",
                  "from",
                  "to"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "field": {
                    "type": "string"
                  },
                  "operator": {
                    "type": "string",
                    "enum": [
                      "in",
                      "notIn"
                    ]
                  },
                  "values": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": [
                        "number",
                        "string"
                      ]
                    }
                  }
                },
                "required": [
                  "field",
                  "operator",
                  "values"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "field": {
                    "type": "string"
                  },
                  "operator": {
                    "type": "string",
                    "enum": [
                      "isPresent",
                      "isMissing"
                    ]
                  }
                },
                "required": [
                  "field",
                  "operator"
                ],
                "additionalProperties": false
              }
            ],
            "description": "Complete ScreenFilter grammar (executable examples: docs/guides/dogfood-journeys.md): ordering operators greaterThan | greaterThanOrEqual | lessThan | lessThanOrEqual require numeric value; equals | notEquals use a number/string/boolean value. No gt/gte aliases. A ScreenFilter tree — { all: [...] } | { any: [...] } | { not: ... } | { field, operator, value } | { field, operator: 'between', from, to } | { field, operator: 'in' | 'notIn', values } | { field, operator: 'isPresent' | 'isMissing' } — validated node by node by screenUniverse; omitted = every eligible row passes"
          },
          "missingValuePolicy": {
            "type": "string",
            "enum": [
              "exclude",
              "evaluate-as-false"
            ]
          },
          "orderBy": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string"
                },
                "direction": {
                  "type": "string",
                  "enum": [
                    "ascending",
                    "descending"
                  ]
                }
              },
              "additionalProperties": false,
              "required": [
                "field",
                "direction"
              ]
            }
          },
          "limit": {
            "type": "integer",
            "minimum": 0
          }
        },
        "additionalProperties": false,
        "required": [
          "universeId",
          "asOf",
          "observations",
          "fieldDefinitions",
          "missingValuePolicy",
          "orderBy"
        ]
      },
      "totalfinance.research.screen.output": {
        "type": "object",
        "properties": {
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "{ instrumentId, availableTimestampMs, fields }"
          }
        },
        "required": [
          "assumptions",
          "diagnostics",
          "rows"
        ]
      },
      "totalfinance.research.screen.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.research.screen.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.risk.optimize.input": {
        "type": "object",
        "properties": {
          "objective": {
            "type": "string",
            "enum": [
              "minVariance",
              "maxSharpe",
              "meanVariance",
              "riskParity",
              "hrp",
              "kelly"
            ],
            "description": "Which portfolio to solve for"
          },
          "covariance": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "number"
              }
            },
            "description": "Asset covariance matrix (per-period, decimal² units), square"
          },
          "mean": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "Per-asset expected returns (decimals) — required for maxSharpe/meanVariance/kelly"
          },
          "riskFreeRatePerPeriod": {
            "type": "number",
            "description": "PER-PERIOD risk-free rate (decimal; maxSharpe only) — the same period as the covariance matrix, NOT annualized. Renamed from `riskFreeRate` because every other risk-free rate in the library is annual, and the two were silently interchangeable here"
          },
          "riskAversion": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "λ for meanVariance (default 1)"
          },
          "fraction": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Kelly fraction (default 1 = full Kelly)"
          },
          "longOnly": {
            "type": "boolean",
            "description": "Forbid short positions"
          },
          "budget": {
            "type": "number",
            "description": "Σw target (default 1 = fully invested)"
          }
        },
        "additionalProperties": false,
        "required": [
          "objective",
          "covariance"
        ]
      },
      "totalfinance.risk.optimize.output": {
        "type": "object",
        "properties": {
          "value": {
            "description": "The computed result"
          },
          "assumptions": {
            "type": "object",
            "description": "Every applied convention, echoed"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine/method/warnings (+ convergence where iterative)"
          }
        },
        "required": [
          "value",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.risk.optimize.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.risk.optimize.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.risk.value_at_risk.input": {
        "type": "object",
        "properties": {
          "returns": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "Periodic returns as decimals (e.g. 0.01 = +1%)"
          },
          "confidence": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Confidence level in (0, 1); default 0.95"
          },
          "method": {
            "type": "string",
            "enum": [
              "historical",
              "parametric",
              "monteCarlo"
            ],
            "description": "Estimation method; default historical"
          },
          "horizonPeriods": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Holding-period horizon in periods; scales by √-time; default 1"
          },
          "cornishFisher": {
            "type": "boolean",
            "description": "Parametric only: Cornish-Fisher adjustment for skew/excess-kurtosis"
          },
          "samples": {
            "type": "integer",
            "maximum": 1000000,
            "exclusiveMinimum": 0,
            "description": "Monte-Carlo only: number of simulated paths; default 10000, capped at 1,000,000 (compute is bounded BEFORE the work starts, not just by the deadline)."
          },
          "seed": {
            "type": "integer",
            "description": "Monte-Carlo only: PRNG seed; default 0"
          }
        },
        "additionalProperties": false,
        "required": [
          "returns"
        ]
      },
      "totalfinance.risk.value_at_risk.output": {
        "type": "object",
        "properties": {
          "value": {
            "type": "object",
            "properties": {
              "valueAtRisk": {
                "type": "number",
                "description": "Positive loss magnitude at `confidence`"
              },
              "conditionalValueAtRisk": {
                "type": "number",
                "description": "Conditional VaR / expected shortfall (≥ valueAtRisk)"
              }
            },
            "required": [
              "valueAtRisk",
              "conditionalValueAtRisk"
            ]
          },
          "assumptions": {
            "type": "object",
            "description": "confidence, method, horizonPeriods, cornishFisher, conventionsVersion (+ seed/samples when method is monteCarlo)"
          },
          "diagnostics": {
            "type": "object",
            "description": "method + warnings"
          }
        },
        "required": [
          "value",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.risk.value_at_risk.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.risk.value_at_risk.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.scenario.run.input": {
        "type": "object",
        "properties": {
          "scenarioSet": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.scenario-set",
                "type": "string"
              },
              "schemaVersion": {
                "type": "integer"
              },
              "name": {
                "type": "string",
                "minLength": 1
              },
              "scenarios": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "minLength": 1
                    },
                    "shocks": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "factor": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "percent",
                              "absolute"
                            ]
                          },
                          "value": {
                            "type": "number"
                          },
                          "target": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "factor",
                          "kind",
                          "value"
                        ]
                      }
                    },
                    "overrides": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "factor": {
                            "type": "string"
                          },
                          "value": {
                            "type": "number"
                          },
                          "target": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "factor",
                          "value"
                        ]
                      }
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "name",
                    "shocks"
                  ]
                },
                "minItems": 1
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  },
                  "dataset": {
                    "type": "string"
                  },
                  "asOf": {
                    "type": "number"
                  },
                  "receivedAt": {
                    "type": "number"
                  },
                  "sourceVersion": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "name",
              "scenarios"
            ],
            "description": "A Gate B scenario set (totalfinance.scenario-set)"
          },
          "market": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.market-snapshot",
                "type": "string"
              },
              "schemaVersion": {
                "type": "integer"
              },
              "asOf": {
                "type": "number",
                "description": "Epoch ms (resolved on the artifact)"
              },
              "conventions": {
                "type": "object",
                "properties": {
                  "conventionsVersion": {
                    "type": "string"
                  },
                  "asOfConvention": {
                    "type": "string",
                    "enum": [
                      "explicit-instant",
                      "date-midnight-utc"
                    ],
                    "description": "How asOf was expressed at create time (a bare date is refused by option pricing)"
                  },
                  "dayCount": {
                    "type": "string"
                  },
                  "compounding": {
                    "type": "string"
                  },
                  "calendar": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "conventionsVersion",
                  "asOfConvention"
                ]
              },
              "observations": {
                "type": "object",
                "properties": {
                  "spots": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "riskFreeRates": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number"
                    }
                  },
                  "dividendYields": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number"
                    }
                  },
                  "volatilities": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number"
                    }
                  },
                  "curves": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "surfaces": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "chains": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  },
                  "dataset": {
                    "type": "string"
                  },
                  "asOf": {
                    "type": "number"
                  },
                  "receivedAt": {
                    "type": "number"
                  },
                  "sourceVersion": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "asOf",
              "conventions",
              "observations"
            ],
            "description": "A Gate B market snapshot (totalfinance.market-snapshot); its interior is re-validated by the read door"
          },
          "targets": {
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "const": "spot",
                      "type": "string"
                    },
                    "id": {
                      "type": "string",
                      "minLength": 1
                    },
                    "symbol": {
                      "type": "string",
                      "minLength": 1
                    },
                    "quantity": {
                      "type": "number"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "strategy": {
                      "type": "string"
                    },
                    "account": {
                      "type": "string"
                    },
                    "book": {
                      "type": "string"
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "kind",
                    "id",
                    "symbol",
                    "quantity",
                    "currency"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "const": "taylor",
                      "type": "string"
                    },
                    "id": {
                      "type": "string",
                      "minLength": 1
                    },
                    "quantity": {
                      "type": "number"
                    },
                    "contractMultiplier": {
                      "type": "number"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "underlying": {
                      "type": "string"
                    },
                    "strategy": {
                      "type": "string"
                    },
                    "account": {
                      "type": "string"
                    },
                    "book": {
                      "type": "string"
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "baseValuePerUnit": {
                      "type": "number"
                    },
                    "greeks": {
                      "type": "object",
                      "properties": {
                        "delta": {
                          "type": "number",
                          "description": "∂V/∂S per $1 of spot"
                        },
                        "gamma": {
                          "type": "number",
                          "description": "∂²V/∂S² per $1²"
                        },
                        "vega": {
                          "type": "number",
                          "description": "∂V/∂σ per 1 volatility POINT (0.01), as option.greeks reports it"
                        },
                        "theta": {
                          "type": "number",
                          "description": "∂V/∂t per CALENDAR DAY, as option.greeks reports it"
                        },
                        "rho": {
                          "type": "number",
                          "description": "∂V/∂r per 1% rate (0.01), as option.greeks reports it"
                        },
                        "vanna": {
                          "type": "number",
                          "description": "∂Δ/∂σ per 1.00 σ per $"
                        },
                        "vomma": {
                          "type": "number",
                          "description": "∂²V/∂σ² per 1.00 σ²"
                        },
                        "charm": {
                          "type": "number",
                          "description": "∂Δ/∂T per year of time-to-expiry (options-package sign)"
                        },
                        "veta": {
                          "type": "number",
                          "description": "∂vega/∂T per year, vega per 1.00 σ"
                        },
                        "vera": {
                          "type": "number",
                          "description": "∂²V/∂σ∂r per 1.00 σ per 1.00 rate"
                        },
                        "deltaRate": {
                          "type": "number",
                          "description": "∂Δ/∂r per $ per 1% rate"
                        },
                        "thetaRate": {
                          "type": "number",
                          "description": "∂Θ/∂r per calendar day per 1% rate"
                        },
                        "rhoConvexity": {
                          "type": "number",
                          "description": "∂²V/∂r² per (1%)²"
                        },
                        "thetaConvexity": {
                          "type": "number",
                          "description": "∂²V/∂t² per calendar day²"
                        },
                        "phi": {
                          "type": "number",
                          "description": "∂V/∂q per 1% dividend yield (dividend rho)"
                        }
                      },
                      "additionalProperties": false
                    },
                    "factors": {
                      "type": "object",
                      "properties": {
                        "spot": {
                          "type": "object",
                          "properties": {
                            "subject": {
                              "type": "string"
                            },
                            "level": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "subject",
                            "level"
                          ]
                        },
                        "volatility": {
                          "type": "object",
                          "properties": {
                            "subject": {
                              "type": "string"
                            },
                            "level": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "subject",
                            "level"
                          ]
                        },
                        "riskFreeRate": {
                          "type": "object",
                          "properties": {
                            "subject": {
                              "type": "string"
                            },
                            "level": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "subject",
                            "level"
                          ]
                        },
                        "dividend": {
                          "type": "object",
                          "properties": {
                            "subject": {
                              "type": "string"
                            },
                            "level": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "subject",
                            "level"
                          ]
                        },
                        "valuationInstant": {
                          "type": "object",
                          "properties": {
                            "level": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "level"
                          ]
                        }
                      },
                      "additionalProperties": false
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "kind",
                    "id",
                    "quantity",
                    "contractMultiplier",
                    "currency",
                    "baseValuePerUnit",
                    "greeks",
                    "factors"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "const": "portfolio",
                      "type": "string"
                    },
                    "portfolio": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "const": "totalfinance.portfolio-ledger",
                              "type": "string"
                            },
                            "schemaVersion": {
                              "type": "integer"
                            },
                            "portfolioId": {
                              "type": "string"
                            },
                            "baseCurrency": {
                              "type": "string"
                            },
                            "lotRelief": {
                              "type": "string",
                              "enum": [
                                "fifo",
                                "lifo",
                                "highest-cost",
                                "specific-lot"
                              ]
                            },
                            "events": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "additionalProperties": {}
                              },
                              "description": "Portfolio event envelopes (each re-validated by readPortfolioLedgerSnapshot)"
                            },
                            "provenance": {
                              "type": "object",
                              "properties": {
                                "provider": {
                                  "type": "string"
                                },
                                "dataset": {
                                  "type": "string"
                                },
                                "asOf": {
                                  "type": "number"
                                },
                                "receivedAt": {
                                  "type": "number"
                                },
                                "sourceVersion": {
                                  "type": "string"
                                },
                                "requestId": {
                                  "type": "string"
                                },
                                "warnings": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "additionalProperties": false
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "kind",
                            "schemaVersion",
                            "baseCurrency",
                            "lotRelief",
                            "events"
                          ],
                          "description": "A serialized portfolio ledger (totalfinance.portfolio-ledger, the FC7 JSON form)"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "schemaVersion": {
                              "type": "integer"
                            },
                            "portfolioId": {
                              "type": "string"
                            },
                            "baseCurrency": {
                              "type": "string"
                            },
                            "lotRelief": {
                              "type": "string",
                              "enum": [
                                "fifo",
                                "lifo",
                                "highest-cost",
                                "specific-lot"
                              ]
                            },
                            "accounts": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "additionalProperties": {}
                              }
                            },
                            "appliedEvents": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "string"
                              }
                            },
                            "eventCount": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "lastEffectiveTimestampMs": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "lotSequence": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "fillEffects": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "additionalProperties": {}
                              }
                            },
                            "reversals": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "string"
                              }
                            },
                            "accountMigrations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "additionalProperties": {}
                              }
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "schemaVersion",
                            "baseCurrency",
                            "lotRelief",
                            "accounts",
                            "appliedEvents",
                            "eventCount",
                            "lastEffectiveTimestampMs",
                            "lotSequence",
                            "fillEffects",
                            "reversals",
                            "accountMigrations"
                          ],
                          "description": "A derived PortfolioState (from applyPortfolioEvents or ledger.state)"
                        }
                      ],
                      "description": "The ledger envelope or PortfolioState whose open positions become targets"
                    },
                    "bindings": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "minLength": 1
                          },
                          "accountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "instrumentId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "strategy": {
                            "type": "string"
                          },
                          "book": {
                            "type": "string"
                          },
                          "tags": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "baseValuePerUnit": {
                            "type": "number"
                          },
                          "greeks": {
                            "type": "object",
                            "properties": {
                              "delta": {
                                "type": "number",
                                "description": "∂V/∂S per $1 of spot"
                              },
                              "gamma": {
                                "type": "number",
                                "description": "∂²V/∂S² per $1²"
                              },
                              "vega": {
                                "type": "number",
                                "description": "∂V/∂σ per 1 volatility POINT (0.01), as option.greeks reports it"
                              },
                              "theta": {
                                "type": "number",
                                "description": "∂V/∂t per CALENDAR DAY, as option.greeks reports it"
                              },
                              "rho": {
                                "type": "number",
                                "description": "∂V/∂r per 1% rate (0.01), as option.greeks reports it"
                              },
                              "vanna": {
                                "type": "number",
                                "description": "∂Δ/∂σ per 1.00 σ per $"
                              },
                              "vomma": {
                                "type": "number",
                                "description": "∂²V/∂σ² per 1.00 σ²"
                              },
                              "charm": {
                                "type": "number",
                                "description": "∂Δ/∂T per year of time-to-expiry (options-package sign)"
                              },
                              "veta": {
                                "type": "number",
                                "description": "∂vega/∂T per year, vega per 1.00 σ"
                              },
                              "vera": {
                                "type": "number",
                                "description": "∂²V/∂σ∂r per 1.00 σ per 1.00 rate"
                              },
                              "deltaRate": {
                                "type": "number",
                                "description": "∂Δ/∂r per $ per 1% rate"
                              },
                              "thetaRate": {
                                "type": "number",
                                "description": "∂Θ/∂r per calendar day per 1% rate"
                              },
                              "rhoConvexity": {
                                "type": "number",
                                "description": "∂²V/∂r² per (1%)²"
                              },
                              "thetaConvexity": {
                                "type": "number",
                                "description": "∂²V/∂t² per calendar day²"
                              },
                              "phi": {
                                "type": "number",
                                "description": "∂V/∂q per 1% dividend yield (dividend rho)"
                              }
                            },
                            "additionalProperties": false
                          },
                          "factors": {
                            "type": "object",
                            "properties": {
                              "spot": {
                                "type": "object",
                                "properties": {
                                  "subject": {
                                    "type": "string"
                                  },
                                  "level": {
                                    "type": "number"
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "subject",
                                  "level"
                                ]
                              },
                              "volatility": {
                                "type": "object",
                                "properties": {
                                  "subject": {
                                    "type": "string"
                                  },
                                  "level": {
                                    "type": "number"
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "subject",
                                  "level"
                                ]
                              },
                              "riskFreeRate": {
                                "type": "object",
                                "properties": {
                                  "subject": {
                                    "type": "string"
                                  },
                                  "level": {
                                    "type": "number"
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "subject",
                                  "level"
                                ]
                              },
                              "dividend": {
                                "type": "object",
                                "properties": {
                                  "subject": {
                                    "type": "string"
                                  },
                                  "level": {
                                    "type": "number"
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "subject",
                                  "level"
                                ]
                              },
                              "valuationInstant": {
                                "type": "object",
                                "properties": {
                                  "level": {
                                    "type": "number"
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "level"
                                ]
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "id",
                          "accountId",
                          "instrumentId",
                          "baseValuePerUnit",
                          "greeks",
                          "factors"
                        ]
                      },
                      "minItems": 1,
                      "description": "Exactly one Taylor binding per open (accountId, instrumentId) position — the serializable binding kind"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "kind",
                    "portfolio",
                    "bindings"
                  ]
                }
              ]
            },
            "minItems": 1,
            "description": "Wire targets: kind 'spot' (scenarioTarget.spot), 'taylor' (scenarioTarget.taylor), or 'portfolio' (scenarioTargetsFromPortfolio with Taylor bindings). A custom pricer target is SDK-only."
          },
          "reportingCurrency": {
            "type": "string"
          },
          "currencyConversions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "baseCurrency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "quoteCurrency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "quotePerBase": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "baseCurrency",
                "quoteCurrency",
                "quotePerBase"
              ]
            }
          },
          "options": {
            "type": "object",
            "properties": {
              "failureMode": {
                "type": "string",
                "enum": [
                  "fail-fast",
                  "collect"
                ]
              },
              "seed": {
                "type": "integer",
                "minimum": 0
              },
              "maximumValuationCells": {
                "type": "integer",
                "exclusiveMinimum": 0
              },
              "maximumWorkUnits": {
                "type": "integer",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "description": "Execution options; market resolvers and factor handlers are SDK-only callbacks"
          }
        },
        "additionalProperties": false,
        "required": [
          "scenarioSet",
          "market",
          "targets"
        ]
      },
      "totalfinance.scenario.run.output": {
        "type": "object",
        "properties": {
          "layout": {
            "type": "object",
            "description": "scenario-major cell layout and the index formula"
          },
          "scenarioAxis": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "targetAxis": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "base": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "cells": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "aggregates": {
            "type": "object"
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "layout",
          "scenarioAxis",
          "targetAxis",
          "base",
          "cells",
          "aggregates",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.scenario.run.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.scenario.run.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.strategy.analyze.input": {
        "type": "object",
        "properties": {
          "legs": {
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "const": "stock",
                      "type": "string"
                    },
                    "quantity": {
                      "type": "number",
                      "description": "Signed shares: positive = long, negative = short"
                    },
                    "price": {
                      "type": "number",
                      "description": "Entry price per share; omit to model-price the leg at `market.spot`"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "kind",
                    "quantity"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "enum": [
                        "call",
                        "put"
                      ]
                    },
                    "strike": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "quantity": {
                      "type": "number",
                      "description": "Signed contracts: positive = long, negative = short"
                    },
                    "premium": {
                      "type": "number",
                      "description": "Entry premium per share; omit to model-price the leg from `market`"
                    },
                    "expiry": {
                      "type": "string",
                      "description": "Per-leg expiry (YYYY-MM-DD or datetime) for calendars/diagonals"
                    },
                    "impliedVolatility": {
                      "type": "number",
                      "exclusiveMinimum": 0,
                      "description": "Per-leg implied volatility (decimal)"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "kind",
                    "strike",
                    "quantity"
                  ]
                }
              ]
            },
            "description": "The option/stock legs of the position — supply legs OR strategy+input"
          },
          "strategy": {
            "type": "string",
            "description": "A named builder from totalfinance.strategy.list (e.g. ironCondor); pair with `input`"
          },
          "input": {
            "type": "object",
            "additionalProperties": {},
            "description": "The named builder's input (shape per totalfinance.strategy.list examples)"
          },
          "premiums": {
            "type": "string",
            "enum": [
              "user",
              "model"
            ],
            "description": "Entry-premium source: 'user' (from the leg premiums, default) or 'model' (price unpriced legs from `market`)"
          },
          "market": {
            "type": "object",
            "properties": {
              "spot": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "volatility": {
                "type": "number",
                "exclusiveMinimum": 0,
                "description": "Annualized implied volatility (decimal, e.g. 0.18)"
              },
              "riskFreeRate": {
                "type": "number",
                "description": "Continuously-compounded risk-free rate (decimal)"
              },
              "asOf": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "string"
                  }
                ],
                "description": "Entry/valuation instant — epoch ms or a zoned ISO datetime (a bare date is refused)"
              },
              "expiry": {
                "type": "string",
                "description": "Default expiry for legs without their own (YYYY-MM-DD → the US close, 16:00 ET or 13:00 ET on early-close days; or a zoned datetime)"
              },
              "dividendYield": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "spot",
              "volatility",
              "riskFreeRate",
              "asOf"
            ],
            "description": "Market snapshot; required for `premiums: model` and for `probability`"
          },
          "probability": {
            "type": "boolean",
            "description": "Also compute probability-of-profit, expected value, risk/reward, and probability-of-touch (needs `market`)"
          },
          "multiplier": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Contract multiplier for option legs (default 100)"
          }
        },
        "additionalProperties": false
      },
      "totalfinance.strategy.analyze.output": {
        "type": "object",
        "properties": {
          "premiumSource": {
            "type": "string",
            "enum": [
              "user",
              "model"
            ]
          },
          "classification": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Named strategies these legs structurally match (derived via classifyStrategy; empty = custom)"
          },
          "metrics": {
            "type": "object",
            "properties": {
              "netDebit": {
                "type": "number"
              },
              "netCredit": {
                "type": "number"
              },
              "maxProfit": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Maximum profit at expiration; null when unbounded (see bounded.profit)"
              },
              "maxLoss": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Maximum loss at expiration (negative); null when unbounded (see bounded.loss)"
              },
              "bounded": {
                "type": "object",
                "properties": {
                  "profit": {
                    "type": "boolean"
                  },
                  "loss": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "profit",
                  "loss"
                ]
              },
              "breakevens": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              }
            },
            "required": [
              "netDebit",
              "netCredit",
              "maxProfit",
              "maxLoss",
              "bounded",
              "breakevens"
            ]
          },
          "legs": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "assumptions": {
            "type": "object",
            "description": "Position-construction assumptions (premium source, multiplier, provenance)"
          },
          "diagnostics": {
            "type": "object",
            "description": "Warnings from the metric/probability computations (empty array when none)"
          },
          "probability": {
            "type": "object",
            "description": "Present when `probability: true` was supplied (requires `market`)",
            "properties": {
              "probabilityOfProfit": {
                "type": "number"
              },
              "expectedValue": {
                "type": "number"
              },
              "riskReward": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "|maxProfit / maxLoss|; null when undefined (an unbounded side or a zero max loss) — see diagnostics"
              },
              "probabilityOfTouch": {
                "type": "array"
              },
              "model": {
                "type": "object"
              },
              "assumptions": {
                "type": "object",
                "description": "Probability-model conventions, including `marketSource` (construction | call | merged)"
              }
            }
          }
        },
        "required": [
          "premiumSource",
          "metrics",
          "legs",
          "classification",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.strategy.analyze.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.strategy.analyze.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.strategy.list.input": {
        "type": "object",
        "properties": {
          "multiExpiry": {
            "type": "boolean",
            "description": "Filter: only multi-expiry (true) or single (false)"
          }
        },
        "additionalProperties": false
      },
      "totalfinance.strategy.list.output": {
        "type": "object",
        "properties": {
          "count": {
            "type": "integer"
          },
          "strategies": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "multiExpiry": {
                  "type": "boolean"
                },
                "example": {
                  "type": "object",
                  "description": "A canonical, buildable input for this builder"
                }
              },
              "required": [
                "name",
                "description",
                "multiExpiry",
                "example"
              ]
            }
          }
        },
        "required": [
          "count",
          "strategies"
        ]
      },
      "totalfinance.strategy.list.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.strategy.list.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.structure.exposures.input": {
        "type": "object",
        "properties": {
          "chain": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "strike": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "expiry": {
                  "type": "string",
                  "description": "ISO date YYYY-MM-DD"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "call",
                    "put"
                  ]
                },
                "openInterest": {
                  "type": "number",
                  "description": "Open interest (contracts)"
                },
                "impliedVolatility": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "description": "Implied volatility (decimal); when omitted, implied from `price`"
                },
                "price": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "description": "Option mid price; used to imply IV when `impliedVolatility` is omitted"
                },
                "multiplier": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "description": "Contract multiplier (default 100)"
                }
              },
              "additionalProperties": false,
              "required": [
                "strike",
                "expiry",
                "type",
                "openInterest"
              ]
            },
            "description": "The option chain: one row per contract"
          },
          "spot": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "riskFreeRate": {
            "type": "number",
            "description": "Continuously-compounded risk-free rate (decimal)"
          },
          "asOf": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ],
            "description": "Valuation instant — epoch ms or a zoned ISO datetime such as \"2026-07-20T10:30:00-04:00\". A bare YYYY-MM-DD is refused: a same-day option's value depends on the time of day. For an end-of-day mark use the 16:00 ET close (13:00 ET on early-close days)."
          },
          "dividendYield": {
            "type": "number"
          },
          "convention": {
            "type": "string",
            "enum": [
              "callsPositivePutsNegative",
              "dealerShortGamma"
            ],
            "description": "Dealer sign convention — REQUIRED, it decides the sign of every exposure number; echoed back with its limitations"
          },
          "style": {
            "type": "string",
            "enum": [
              "american",
              "european"
            ],
            "description": "Exercise style of every contract in the chain — REQUIRED (listed US equity options are 'american'); the library never defaults it"
          },
          "gammaUnit": {
            "type": "string",
            "enum": [
              "per1PercentMove",
              "perPoint"
            ],
            "description": "GEX units: per1PercentMove (default, the specification formula) or perPoint"
          },
          "underlying": {
            "type": "string",
            "description": "Ticker symbol of the chain — REQUIRED, it names every contract"
          },
          "topStrikes": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "description": "How many top-|GEX| strikes to return (default 10)"
          }
        },
        "additionalProperties": false,
        "required": [
          "chain",
          "spot",
          "riskFreeRate",
          "asOf",
          "convention",
          "style",
          "underlying"
        ]
      },
      "totalfinance.structure.exposures.output": {
        "type": "object",
        "properties": {
          "spot": {
            "type": "number"
          },
          "atSpot": {
            "type": "object",
            "description": "Net dealer exposure at spot",
            "properties": {
              "gex": {
                "type": "number"
              },
              "dex": {
                "type": "number"
              }
            },
            "required": [
              "gex",
              "dex"
            ]
          },
          "levels": {
            "type": "object",
            "description": "Walls, zero-gamma, max pain, pin risk, and OPEX walls"
          },
          "netDrift": {
            "type": "object",
            "description": "Gamma regime + pin/trend bias + charm/vanna flow"
          },
          "topStrikes": {
            "type": "array",
            "description": "Highest-|GEX| strikes, most concentrated first",
            "items": {
              "type": "object"
            }
          },
          "assumptions": {
            "type": "object",
            "description": "Every applied convention: the sign `convention`, gammaUnit, priceSource, minTimeToExpiry, defaultMultiplier, …"
          },
          "diagnostics": {
            "type": "object",
            "description": "Warnings, including the model limitations as `model.limitation` entries (positioning is estimated from OI + a sign convention, not true dealer books)"
          }
        },
        "required": [
          "spot",
          "atSpot",
          "levels",
          "netDrift",
          "topStrikes",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.structure.exposures.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.structure.exposures.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.structure.flow.input": {
        "type": "object",
        "properties": {
          "trades": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "timestampMs": {
                  "type": "number",
                  "description": "Print timestamp (epoch ms)"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "call",
                    "put"
                  ]
                },
                "strike": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "expiry": {
                  "type": "string",
                  "description": "ISO date YYYY-MM-DD"
                },
                "price": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "description": "Print price per share"
                },
                "size": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "description": "Print size (contracts)"
                },
                "bid": {
                  "type": "number",
                  "description": "NBBO bid at print time (enables aggressor-side classification)"
                },
                "ask": {
                  "type": "number",
                  "description": "NBBO ask at print time"
                },
                "exchange": {
                  "type": "string",
                  "description": "Venue code (enables venue-verified sweep detection)"
                },
                "openInterest": {
                  "type": "number",
                  "description": "Prior open interest (enables opening detection)"
                }
              },
              "additionalProperties": false,
              "required": [
                "timestampMs",
                "type",
                "strike",
                "expiry",
                "price",
                "size"
              ]
            },
            "description": "Option prints, any order (sorted internally)"
          },
          "underlying": {
            "type": "string",
            "description": "Ticker of the prints — REQUIRED, it names every contract"
          },
          "style": {
            "type": "string",
            "enum": [
              "american",
              "european"
            ],
            "description": "Exercise style of the printed contracts — REQUIRED (listed US equity options are 'american'); the library never defaults it"
          },
          "multiplier": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Contract multiplier (default 100)"
          },
          "blockMinSize": {
            "type": "number",
            "description": "Min contracts for a block (default 100)"
          },
          "blockMinPremium": {
            "type": "number",
            "description": "Min premium $ for a block (default 100,000)"
          },
          "maxDetails": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "description": "Max sweeps/spreads returned in detail (default 25 each)"
          }
        },
        "additionalProperties": false,
        "required": [
          "trades",
          "underlying",
          "style"
        ]
      },
      "totalfinance.structure.flow.output": {
        "type": "object",
        "properties": {
          "counts": {
            "type": "object",
            "description": "trades/sweeps/spreads/buy/sell/unknown totals"
          },
          "sweeps": {
            "type": "array",
            "description": "Detected sweeps (capped by maxDetails)"
          },
          "spreads": {
            "type": "array",
            "description": "Detected multi-leg spreads (capped)"
          },
          "assumptions": {
            "type": "object",
            "description": "The rules/windows the analysis ran under"
          },
          "diagnostics": {
            "type": "object",
            "description": "Warnings, including the heuristic caveats as `model.limitation` entries"
          },
          "limitations": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Convenience view: the `model.limitation` messages from diagnostics.warnings (diagnostics is the source of truth)"
          }
        },
        "required": [
          "counts",
          "sweeps",
          "spreads",
          "assumptions",
          "diagnostics",
          "limitations"
        ]
      },
      "totalfinance.structure.flow.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.structure.flow.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.technical_analysis.calculate.input": {
        "type": "object",
        "properties": {
          "indicator": {
            "type": "string",
            "enum": [
              "typicalPrice",
              "medianPrice",
              "weightedClose",
              "averagePrice",
              "realBody",
              "upperShadow",
              "lowerShadow",
              "candleRange",
              "trueRange",
              "gap",
              "heikinAshi",
              "returns",
              "logReturns",
              "rollingVolatility",
              "sma",
              "ema",
              "wma",
              "rma",
              "dema",
              "tema",
              "trima",
              "t3",
              "kama",
              "hma",
              "zlema",
              "alma",
              "vidya",
              "mcginley",
              "superSmoother",
              "vwma",
              "rollingVwap",
              "anchoredVwap",
              "frama",
              "mama",
              "movingAverage",
              "midpoint",
              "midprice",
              "fwma",
              "sineWma",
              "pascalWma",
              "symmetricWma",
              "jma",
              "holtWinterMovingAverage",
              "rainbowMovingAverage",
              "movingAverageRibbon",
              "gannHighLowActivator",
              "vwapBands",
              "sessionVwap",
              "rollingAnchoredVwap",
              "rsi",
              "macd",
              "roc",
              "rocp",
              "rocr",
              "rocr100",
              "momentum",
              "cmo",
              "apo",
              "ppo",
              "stochRsi",
              "trix",
              "dpo",
              "tsi",
              "kst",
              "connorsRsi",
              "macdExt",
              "macdFix",
              "cci",
              "williamsR",
              "awesomeOscillator",
              "ultimateOscillator",
              "fisherTransform",
              "stochastic",
              "stochFast",
              "bop",
              "bias",
              "cfo",
              "forecastOscillator",
              "coppock",
              "cti",
              "efficiencyRatio",
              "centerOfGravity",
              "psychologicalLine",
              "slope",
              "trixHistogram",
              "smiErgodic",
              "pvo",
              "elderRay",
              "brar",
              "kdj",
              "relativeVigorIndex",
              "pgo",
              "volumeWeightedMacd",
              "inertia",
              "laguerreRsi",
              "qqe",
              "rsx",
              "schaffTrendCycle",
              "squeeze",
              "squeezePro",
              "projectionOscillator",
              "tdSequential",
              "smcSweep",
              "adx",
              "dmi",
              "plusDI",
              "minusDI",
              "plusDM",
              "minusDM",
              "dx",
              "adxr",
              "aroon",
              "aroonOscillator",
              "psar",
              "psarExt",
              "supertrend",
              "ichimoku",
              "vortex",
              "donchianTrend",
              "chandelierExit",
              "linreg",
              "linregSlope",
              "linregIntercept",
              "linregAngle",
              "tsf",
              "choppinessIndex",
              "chandeKrollStop",
              "centralPivotRange",
              "amat",
              "linearDecay",
              "exponentialDecay",
              "increasing",
              "decreasing",
              "longRun",
              "shortRun",
              "pMax",
              "qstick",
              "ttmTrend",
              "verticalHorizontalFilter",
              "trendSignals",
              "crossSignals",
              "atr",
              "natr",
              "keltner",
              "donchian",
              "parkinson",
              "garmanKlass",
              "rogersSatchell",
              "yangZhang",
              "chaikinVolatility",
              "bbands",
              "bollingerBandWidth",
              "bollingerPercentB",
              "standardDeviation",
              "variance",
              "historicalVolatility",
              "realizedVolatility",
              "relativeVolatilityIndex",
              "aberration",
              "accelerationBands",
              "holtWinterChannel",
              "massIndex",
              "priceDistance",
              "elderThermometer",
              "ulcerIndex",
              "atrBands",
              "percentAtr",
              "volatilityStop",
              "obv",
              "vwap",
              "adLine",
              "chaikinOscillator",
              "chaikinMoneyFlow",
              "mfi",
              "pvt",
              "easeOfMovement",
              "forceIndex",
              "nvi",
              "pvi",
              "klinger",
              "vfi",
              "relativeVolume",
              "cvd",
              "archerObv",
              "marketFacilitationIndex",
              "priceVolume",
              "priceVolumeRank",
              "volumeOscillator",
              "williamsAd",
              "efi",
              "emv",
              "kvo",
              "dsp",
              "ebsw",
              "msw",
              "htDcPeriod",
              "htDcPhase",
              "htPhasor",
              "htSine",
              "htTrendMode",
              "htTrendline",
              "beta",
              "correl",
              "rollingMin",
              "rollingMax",
              "rollingSum",
              "rollingMinIndex",
              "rollingMaxIndex",
              "rollingMinMax",
              "rollingMinMaxIndex",
              "shift",
              "lag",
              "diff",
              "change",
              "fractionalChange",
              "cum",
              "zScore",
              "normalize",
              "rescale",
              "rollingMedian",
              "mad",
              "standardError",
              "rollingRank",
              "percentRank",
              "rollingQuantile",
              "winsorize",
              "skew",
              "kurtosis",
              "entropy",
              "covariance",
              "rSquared",
              "rollingRegression",
              "barSince",
              "valueWhen",
              "rollingMean",
              "rollingBeta",
              "rollingCorrelation",
              "highestBars",
              "lowestBars",
              "tosStdevAll",
              "acos",
              "asin",
              "atan",
              "ceil",
              "cos",
              "cosh",
              "exp",
              "floor",
              "ln",
              "log10",
              "sin",
              "sinh",
              "sqrt",
              "tan",
              "tanh",
              "add",
              "sub",
              "mult",
              "div",
              "crossover",
              "crossany",
              "drawdown",
              "cdlDoji",
              "cdlInside",
              "cdlZ",
              "fairValueGaps",
              "orderBlocks",
              "liquiditySweeps",
              "swingTrailingStop",
              "atrTrailingStop",
              "equalHighs",
              "equalLows",
              "divergence",
              "doji",
              "dojiStar",
              "dragonflyDoji",
              "gravestoneDoji",
              "longLeggedDoji",
              "rickshawMan",
              "takuri",
              "marubozu",
              "closingMarubozu",
              "beltHold",
              "spinningTop",
              "highWave",
              "longLine",
              "shortLine",
              "hammer",
              "invertedHammer",
              "hangingMan",
              "shootingStar",
              "engulfing",
              "harami",
              "haramiCross",
              "piercing",
              "darkCloudCover",
              "thrusting",
              "onNeck",
              "inNeck",
              "counterattack",
              "separatingLines",
              "matchingLow",
              "homingPigeon",
              "kicking",
              "kickingByLength",
              "morningStar",
              "eveningStar",
              "morningDojiStar",
              "eveningDojiStar",
              "abandonedBaby",
              "triStar",
              "threeWhiteSoldiers",
              "threeBlackCrows",
              "identicalThreeCrows",
              "threeInside",
              "threeOutside",
              "threeLineStrike",
              "twoCrows",
              "upsideGapTwoCrows",
              "advanceBlock",
              "stalledPattern",
              "threeStarsInSouth",
              "concealBabySwallow",
              "ladderBottom",
              "riseFallThreeMethods",
              "matHold",
              "tasukiGap",
              "gapSideSideWhite",
              "xSideGapThreeMethods",
              "stickSandwich",
              "uniqueThreeRiver",
              "breakaway",
              "hikkake",
              "hikkakeMod",
              "inside"
            ]
          },
          "closes": {
            "type": "array",
            "items": {
              "type": "number"
            }
          },
          "bars": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "open": {
                  "type": "number"
                },
                "high": {
                  "type": "number"
                },
                "low": {
                  "type": "number"
                },
                "close": {
                  "type": "number"
                },
                "volume": {
                  "type": "number"
                },
                "symbol": {
                  "type": "string",
                  "description": "Canonical source Bar symbol; include timestampMs and open on every row"
                },
                "timestampMs": {
                  "type": "number",
                  "description": "Canonical source time in epoch ms; strictly increasing within one symbol"
                },
                "vwap": {
                  "type": "number"
                },
                "adjusted": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false,
              "required": [
                "high",
                "low",
                "close"
              ]
            }
          },
          "series": {
            "type": "object",
            "properties": {
              "open": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              "high": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              "low": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              "close": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              "volume": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              }
            },
            "additionalProperties": false
          },
          "x": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "Pair indicators: the first series (for beta/correl, the ASSET returns)"
          },
          "y": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "Pair indicators: the second series (for beta/correl, the BENCHMARK returns)"
          },
          "parameters": {
            "type": "object",
            "additionalProperties": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                },
                {
                  "type": "boolean"
                }
              ]
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "indicator"
        ]
      },
      "totalfinance.technical_analysis.calculate.output": {
        "type": "object",
        "properties": {
          "indicator": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "inputs": {
            "type": "string",
            "enum": [
              "series",
              "bars",
              "pair"
            ]
          },
          "value": {
            "type": "array",
            "items": {
              "type": [
                "number",
                "object",
                "null"
              ]
            }
          },
          "assumptions": {
            "type": "object",
            "description": "indicator + parameters actually used (declared defaults merged with supplied)"
          },
          "diagnostics": {
            "type": "object",
            "description": "warnings + warmup (first non-null index)"
          }
        },
        "required": [
          "indicator",
          "value",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.technical_analysis.calculate.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.technical_analysis.calculate.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.technical_analysis.describe.input": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Indicator name or a TA-Lib/pandas/TradingView alias (e.g. \"rsi\", \"RSI\", \"STOCH\")"
          }
        },
        "additionalProperties": false,
        "required": [
          "name"
        ]
      },
      "totalfinance.technical_analysis.describe.output": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Canonical indicator name"
          },
          "category": {
            "type": "string"
          },
          "inputs": {
            "type": "string",
            "enum": [
              "series",
              "bars",
              "pair"
            ]
          },
          "parameters": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "defaults": {
            "type": "object",
            "description": "Default per optional parameter ('(derived)' when computed from another parameter)"
          },
          "required": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "warmup": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Leading bars before the first real value (null = warmup exceeds the probe window)"
          },
          "conventions": {
            "type": "object",
            "description": "The choices this indicator made that its parameters do not reveal — smoothing method, what a flat/degenerate window resolves to, how the first value is seeded. Present only where such a choice exists, and the field to read when this indicator disagrees with another library (e.g. RSI on a flat series: TotalFinance 100, TA-Lib 0, pandas-ta NaN)."
          },
          "aliases": {
            "type": "object",
            "description": "Cross-library names (TA-Lib / pandas-ta / TradingView), when known"
          }
        },
        "required": [
          "name",
          "category",
          "inputs",
          "parameters",
          "defaults",
          "required",
          "warmup"
        ]
      },
      "totalfinance.technical_analysis.describe.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.technical_analysis.describe.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.technical_analysis.list.input": {
        "type": "object",
        "properties": {
          "search": {
            "type": "string",
            "description": "Case-insensitive substring of an indicator name OR a TA-Lib/pandas/TradingView alias"
          },
          "category": {
            "type": "string",
            "enum": [
              "transform",
              "moving-average",
              "momentum",
              "trend",
              "volatility",
              "volume",
              "cycle",
              "statistic",
              "math",
              "performance",
              "candlestick",
              "price-action"
            ],
            "description": "Browse a category here, e.g. momentum; search matches indicator names/aliases and does not expand category words"
          },
          "limit": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "description": "Page size (default 50; `total` is the full match count) — narrow with `search` before paging"
          },
          "offset": {
            "type": "integer",
            "minimum": 0,
            "description": "Page offset (default 0)"
          }
        },
        "additionalProperties": false
      },
      "totalfinance.technical_analysis.list.output": {
        "type": "object",
        "properties": {
          "count": {
            "type": "integer",
            "description": "Number of indicators returned in this page"
          },
          "total": {
            "type": "integer",
            "description": "Total matches before pagination"
          },
          "offset": {
            "type": "integer"
          },
          "indicators": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "category": {
                  "type": "string"
                },
                "inputs": {
                  "type": "string",
                  "enum": [
                    "series",
                    "bars",
                    "pair"
                  ]
                },
                "parameters": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "defaults": {
                  "type": "object",
                  "description": "Default per optional parameter ('(derived)' when computed from another parameter)"
                },
                "required": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "Parameters with no default (must be supplied)"
                }
              },
              "required": [
                "name",
                "category",
                "inputs",
                "parameters",
                "defaults",
                "required"
              ]
            }
          }
        },
        "required": [
          "count",
          "indicators"
        ]
      },
      "totalfinance.technical_analysis.list.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.technical_analysis.list.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.trade.authorize.input": {
        "type": "object",
        "properties": {
          "plan": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.execution-plan",
                "type": "string"
              },
              "schemaVersion": {
                "const": 1,
                "type": "number"
              },
              "accountId": {
                "type": "string",
                "minLength": 1
              },
              "asOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "baseCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "portfolioId": {
                "type": "string",
                "minLength": 1
              },
              "orders": {
                "type": "array",
                "items": {
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "instrumentId": {
                          "type": "string",
                          "minLength": 1
                        },
                        "side": {
                          "type": "string",
                          "enum": [
                            "buy",
                            "sell"
                          ]
                        },
                        "timeInForce": {
                          "type": "string",
                          "enum": [
                            "day",
                            "gtc"
                          ],
                          "description": "Default: the paper execution policy’s day time-in-force"
                        },
                        "comboId": {
                          "type": "string",
                          "minLength": 1,
                          "description": "The multi-leg order this is a leg of (B5)"
                        },
                        "orderId": {
                          "type": "string",
                          "minLength": 1
                        },
                        "quantity": {
                          "type": "number",
                          "exclusiveMinimum": 0,
                          "description": "Units/contracts, strictly positive; side carries direction"
                        },
                        "plannedTimestampMs": {
                          "type": "number",
                          "description": "When the plan was made — never when a broker saw the order"
                        },
                        "submittedTimestampMs": {
                          "type": "number",
                          "description": "Epoch milliseconds"
                        },
                        "type": {},
                        "limitPrice": {},
                        "stopPrice": {}
                      },
                      "additionalProperties": false,
                      "required": [
                        "instrumentId",
                        "side",
                        "orderId",
                        "quantity",
                        "plannedTimestampMs",
                        "type"
                      ]
                    },
                    {
                      "anyOf": [
                        {
                          "properties": {
                            "type": {
                              "const": "market",
                              "type": "string"
                            }
                          },
                          "not": {
                            "anyOf": [
                              {
                                "required": [
                                  "limitPrice"
                                ]
                              },
                              {
                                "required": [
                                  "stopPrice"
                                ]
                              }
                            ]
                          }
                        },
                        {
                          "properties": {
                            "type": {
                              "const": "market-on-open",
                              "type": "string"
                            }
                          },
                          "not": {
                            "anyOf": [
                              {
                                "required": [
                                  "limitPrice"
                                ]
                              },
                              {
                                "required": [
                                  "stopPrice"
                                ]
                              }
                            ]
                          }
                        },
                        {
                          "properties": {
                            "type": {
                              "const": "market-on-close",
                              "type": "string"
                            }
                          },
                          "not": {
                            "anyOf": [
                              {
                                "required": [
                                  "limitPrice"
                                ]
                              },
                              {
                                "required": [
                                  "stopPrice"
                                ]
                              }
                            ]
                          }
                        },
                        {
                          "properties": {
                            "type": {
                              "const": "limit",
                              "type": "string"
                            },
                            "limitPrice": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "required": [
                            "limitPrice"
                          ],
                          "not": {
                            "anyOf": [
                              {
                                "required": [
                                  "stopPrice"
                                ]
                              }
                            ]
                          }
                        },
                        {
                          "properties": {
                            "type": {
                              "const": "stop",
                              "type": "string"
                            },
                            "stopPrice": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "required": [
                            "stopPrice"
                          ],
                          "not": {
                            "anyOf": [
                              {
                                "required": [
                                  "limitPrice"
                                ]
                              }
                            ]
                          }
                        },
                        {
                          "properties": {
                            "type": {
                              "const": "stop-limit",
                              "type": "string"
                            },
                            "limitPrice": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            },
                            "stopPrice": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "required": [
                            "limitPrice",
                            "stopPrice"
                          ]
                        }
                      ]
                    }
                  ]
                },
                "minItems": 1,
                "maxItems": 1000
              },
              "combos": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "comboId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "orderIds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 1
                      },
                      "minItems": 2,
                      "description": "The legs, in plan order (at least two)"
                    },
                    "netLimitPrice": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "comboId",
                    "orderIds"
                  ]
                }
              },
              "trades": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "accountId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "instrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "side": {
                      "type": "string",
                      "enum": [
                        "buy",
                        "sell"
                      ]
                    },
                    "quantity": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "currency": {
                      "type": "string",
                      "pattern": "^[A-Z]{3}$"
                    },
                    "referencePricePerUnit": {
                      "type": "number"
                    },
                    "contractMultiplier": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "estimatedNotional": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "accountId",
                    "instrumentId",
                    "side",
                    "quantity",
                    "currency",
                    "referencePricePerUnit",
                    "contractMultiplier",
                    "estimatedNotional"
                  ]
                }
              },
              "source": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "intent",
                        "type": "string"
                      },
                      "intentHash": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "intentHash"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "rebalance-proposal",
                        "type": "string"
                      },
                      "planHash": {
                        "type": "string",
                        "minLength": 1
                      },
                      "policyContentHash": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "planHash",
                      "policyContentHash"
                    ]
                  }
                ]
              },
              "rationale": {
                "type": "string"
              },
              "evidence": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "contentHash": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "accountId",
              "asOf",
              "baseCurrency",
              "orders",
              "combos",
              "trades",
              "source",
              "evidence",
              "contentHash"
            ]
          },
          "preflight": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.preflight-report",
                "type": "string"
              },
              "schemaVersion": {
                "const": 1,
                "type": "number"
              },
              "asOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "planHash": {
                "type": "string",
                "minLength": 1
              },
              "portfolioHash": {
                "type": "string",
                "minLength": 1
              },
              "marketHash": {
                "type": "string",
                "minLength": 1
              },
              "marketAsOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "before": {
                "$ref": "#/$defs/Before"
              },
              "after": {
                "$ref": "#/$defs/Before"
              },
              "hypotheticalFills": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "fillId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "accountId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "instrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "side": {
                      "type": "string",
                      "enum": [
                        "buy",
                        "sell"
                      ]
                    },
                    "quantity": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "pricePerUnit": {
                      "type": "number"
                    },
                    "currency": {
                      "type": "string",
                      "pattern": "^[A-Z]{3}$"
                    },
                    "filledTimestampMs": {
                      "type": "number",
                      "description": "Epoch milliseconds"
                    },
                    "settleTimestampMs": {
                      "type": "number",
                      "description": "Epoch milliseconds"
                    },
                    "contractMultiplier": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "settlementStyle": {
                      "type": "string",
                      "enum": [
                        "cash-on-trade",
                        "variation-margin"
                      ]
                    },
                    "contract": {
                      "$ref": "#/$defs/Contract"
                    },
                    "accruedInterest": {
                      "type": "number"
                    },
                    "executionPriceAdjustment": {
                      "type": "number",
                      "minimum": 0
                    },
                    "costs": {
                      "type": "object",
                      "properties": {
                        "commission": {
                          "type": "number",
                          "minimum": 0
                        },
                        "exchangeFees": {
                          "type": "number",
                          "minimum": 0
                        },
                        "regulatoryFees": {
                          "type": "number",
                          "minimum": 0
                        },
                        "slippageAdjustment": {
                          "type": "number",
                          "minimum": 0
                        }
                      },
                      "additionalProperties": false
                    },
                    "orderId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "venue": {
                      "type": "string"
                    },
                    "liquidity": {
                      "type": "string",
                      "enum": [
                        "maker",
                        "taker",
                        "unknown"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "fillId",
                    "accountId",
                    "instrumentId",
                    "side",
                    "quantity",
                    "pricePerUnit",
                    "currency",
                    "filledTimestampMs"
                  ]
                }
              },
              "hypotheticalEvents": {
                "type": "array",
                "items": {
                  "$ref": "#/$defs/PortfolioEventEnvelope"
                }
              },
              "estimates": {
                "type": "object",
                "properties": {
                  "tradedNotional": {
                    "type": "number"
                  },
                  "commission": {
                    "type": "number"
                  },
                  "spread": {
                    "type": "number"
                  },
                  "slippage": {
                    "type": "number"
                  },
                  "totalCost": {
                    "type": "number"
                  },
                  "turnover": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "tradedNotional",
                  "commission",
                  "spread",
                  "slippage",
                  "totalCost",
                  "turnover"
                ]
              },
              "checks": {
                "$ref": "#/$defs/Checks"
              },
              "alerts": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string",
                      "minLength": 1
                    },
                    "family": {
                      "type": "string",
                      "enum": [
                        "allocation-drift",
                        "concentration-limit",
                        "leverage-limit",
                        "drawdown",
                        "daily-loss",
                        "cash-reserve",
                        "margin-pressure",
                        "liquidity",
                        "option-expiration",
                        "assignment-risk",
                        "stale-market-data",
                        "reconciliation-difference",
                        "unexplained-residual",
                        "unusual-pnl"
                      ]
                    },
                    "subject": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "informational",
                        "warning",
                        "critical"
                      ]
                    },
                    "state": {
                      "type": "string",
                      "enum": [
                        "raised",
                        "active",
                        "acknowledged",
                        "suppressed",
                        "cleared"
                      ]
                    },
                    "value": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "threshold": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "direction": {
                      "type": "string",
                      "enum": [
                        "above",
                        "below"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "evidence": {
                      "type": "object",
                      "additionalProperties": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "key",
                    "family",
                    "subject",
                    "severity",
                    "state",
                    "value",
                    "threshold",
                    "direction",
                    "message",
                    "evidence"
                  ]
                }
              },
              "decision": {
                "allOf": [
                  {
                    "type": "object",
                    "properties": {
                      "verdict": {},
                      "checks": {
                        "$ref": "#/$defs/Checks"
                      },
                      "requiredScope": {}
                    },
                    "additionalProperties": false,
                    "required": [
                      "verdict",
                      "checks"
                    ]
                  },
                  {
                    "anyOf": [
                      {
                        "properties": {
                          "verdict": {
                            "const": "allow",
                            "type": "string"
                          }
                        },
                        "not": {
                          "anyOf": [
                            {
                              "required": [
                                "requiredScope"
                              ]
                            }
                          ]
                        }
                      },
                      {
                        "properties": {
                          "verdict": {
                            "const": "deny",
                            "type": "string"
                          }
                        },
                        "not": {
                          "anyOf": [
                            {
                              "required": [
                                "requiredScope"
                              ]
                            }
                          ]
                        }
                      },
                      {
                        "properties": {
                          "verdict": {
                            "const": "require-approval",
                            "type": "string"
                          },
                          "requiredScope": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "required": [
                          "requiredScope"
                        ]
                      }
                    ]
                  }
                ]
              },
              "unverifiable": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "monitorState": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "schemaVersion": {
                        "const": 1,
                        "type": "number"
                      },
                      "asOf": {
                        "type": "number",
                        "description": "Epoch milliseconds"
                      },
                      "netAssetValue": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "peakNetAssetValue": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "evaluationCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "rules": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "active": {
                              "type": "boolean"
                            },
                            "consecutiveBreaches": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "lastRaisedAtMs": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "acknowledged": {
                              "type": "boolean"
                            },
                            "lastValue": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "active",
                            "consecutiveBreaches",
                            "lastRaisedAtMs",
                            "acknowledged",
                            "lastValue"
                          ]
                        }
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "schemaVersion",
                      "asOf",
                      "netAssetValue",
                      "peakNetAssetValue",
                      "evaluationCount",
                      "rules"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "assumptions": {
                "type": "object",
                "properties": {
                  "conventionsVersion": {
                    "type": "string"
                  },
                  "policyContentHash": {
                    "type": "string"
                  },
                  "mode": {
                    "const": "paper",
                    "type": "string"
                  },
                  "costRates": {
                    "type": "object",
                    "properties": {
                      "commissionBps": {
                        "type": "number",
                        "minimum": 0
                      },
                      "commissionPerOrder": {
                        "type": "number",
                        "minimum": 0
                      },
                      "spreadBps": {
                        "type": "number",
                        "minimum": 0
                      },
                      "slippageBps": {
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "commissionBps",
                      "commissionPerOrder",
                      "spreadBps",
                      "slippageBps"
                    ]
                  },
                  "fillConvention": {
                    "type": "string"
                  },
                  "instrumentSources": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "decisionConvention": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "conventionsVersion",
                  "policyContentHash",
                  "mode",
                  "costRates",
                  "fillConvention",
                  "instrumentSources",
                  "decisionConvention"
                ]
              },
              "diagnostics": {
                "type": "object",
                "properties": {
                  "engine": {
                    "const": "trade-preflight",
                    "type": "string"
                  },
                  "method": {
                    "const": "hypothetical-fold",
                    "type": "string"
                  },
                  "converged": {
                    "const": true,
                    "type": "boolean"
                  },
                  "warnings": {
                    "$ref": "#/$defs/Warnings"
                  },
                  "checkCount": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "failedCount": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "unverifiableCount": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "engine",
                  "method",
                  "converged",
                  "warnings",
                  "checkCount",
                  "failedCount",
                  "unverifiableCount"
                ]
              },
              "contentHash": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "asOf",
              "planHash",
              "portfolioHash",
              "marketHash",
              "marketAsOf",
              "before",
              "after",
              "hypotheticalFills",
              "hypotheticalEvents",
              "estimates",
              "checks",
              "alerts",
              "decision",
              "unverifiable",
              "monitorState",
              "assumptions",
              "diagnostics",
              "contentHash"
            ]
          },
          "approvedBy": {
            "type": "string",
            "minLength": 1
          },
          "expiresAt": {
            "type": "number",
            "description": "Epoch ms"
          },
          "now": {
            "type": "number",
            "description": "Epoch ms — the issue instant, the caller’s clock"
          },
          "variance": {
            "type": "object",
            "properties": {
              "maximumQuantityRatio": {
                "type": "number",
                "minimum": 0
              },
              "maximumNotionalRatio": {
                "type": "number",
                "minimum": 0
              },
              "maximumSlippageBps": {
                "type": "number",
                "minimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "maximumQuantityRatio",
              "maximumNotionalRatio",
              "maximumSlippageBps"
            ]
          },
          "marketMaximumAgeMs": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "idempotencyKeys": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "minItems": 1,
                "maxItems": 1000
              },
              {
                "type": "object",
                "properties": {
                  "prefix": {
                    "type": "string",
                    "minLength": 1
                  },
                  "count": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000
                  }
                },
                "additionalProperties": false,
                "required": [
                  "prefix",
                  "count"
                ]
              }
            ]
          },
          "portfolioHash": {
            "type": "string"
          },
          "marketHash": {
            "type": "string"
          },
          "account": {
            "type": "string"
          },
          "grantId": {
            "type": "string"
          },
          "createdTimestampMs": {
            "type": "integer",
            "description": "Epoch ms stamped on the stored grant’s handle — the caller’s clock"
          }
        },
        "additionalProperties": false,
        "required": [
          "plan",
          "preflight",
          "approvedBy",
          "expiresAt",
          "now",
          "variance",
          "marketMaximumAgeMs",
          "idempotencyKeys",
          "createdTimestampMs"
        ],
        "$id": "https://totalfinance.dev/schemas/trade.authorize.input",
        "$defs": {
          "PortfolioEventEnvelope": {
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "eventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "schemaVersion": {
                    "const": 1,
                    "type": "number"
                  },
                  "sourceId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "accountId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "effectiveTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "recordedTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "correlationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "causationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "reversesEventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "provenance": {
                    "type": "object",
                    "properties": {
                      "provider": {
                        "type": "string"
                      },
                      "dataset": {
                        "type": "string"
                      },
                      "asOf": {
                        "type": "number",
                        "description": "Epoch milliseconds"
                      },
                      "receivedAt": {
                        "type": "number",
                        "description": "Epoch milliseconds"
                      },
                      "sourceVersion": {
                        "type": "string"
                      },
                      "requestId": {
                        "type": "string"
                      },
                      "warnings": {
                        "$ref": "#/$defs/Warnings"
                      }
                    },
                    "additionalProperties": false
                  },
                  "eventType": {},
                  "event": {}
                },
                "additionalProperties": false,
                "required": [
                  "eventId",
                  "schemaVersion",
                  "sourceId",
                  "accountId",
                  "effectiveTimestampMs",
                  "recordedTimestampMs",
                  "provenance",
                  "eventType",
                  "event"
                ]
              },
              {
                "anyOf": [
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.deposit",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashDeposit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.withdrawal",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashWithdrawal"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.conversion",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashConversion"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "trade.fill",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/TradeFill"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cost.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CostCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "income.received",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/IncomeReceived"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "financing.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FinancingCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.split",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSplit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.exercise",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExercise"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.assignment",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeAssignment"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.expiration",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExpiration"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.multiplier-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeMultiplierChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.variation-margin",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeVariationMargin"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.roll",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeRoll"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "fixed-income.redemption",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FixedIncomeRedemption"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.symbol-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSymbolChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.merger",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateMerger"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.spin-off",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSpinOff"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.return-of-capital",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateReturnOfCapital"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.cash-in-lieu",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateCashInLieu"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "position.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/PositionTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.reversal",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.reversal",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.correction",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.correction",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "replacement": {
                            "anyOf": [
                              {
                                "$ref": "#/$defs/CashDeposit"
                              },
                              {
                                "$ref": "#/$defs/CashWithdrawal"
                              },
                              {
                                "$ref": "#/$defs/CashTransfer"
                              },
                              {
                                "$ref": "#/$defs/CashConversion"
                              },
                              {
                                "$ref": "#/$defs/TradeFill"
                              },
                              {
                                "$ref": "#/$defs/CostCharge"
                              },
                              {
                                "$ref": "#/$defs/IncomeReceived"
                              },
                              {
                                "$ref": "#/$defs/FinancingCharge"
                              },
                              {
                                "$ref": "#/$defs/CorporateSplit"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExercise"
                              },
                              {
                                "$ref": "#/$defs/DerivativeAssignment"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExpiration"
                              },
                              {
                                "$ref": "#/$defs/DerivativeMultiplierChange"
                              },
                              {
                                "$ref": "#/$defs/DerivativeVariationMargin"
                              },
                              {
                                "$ref": "#/$defs/DerivativeRoll"
                              },
                              {
                                "$ref": "#/$defs/FixedIncomeRedemption"
                              },
                              {
                                "$ref": "#/$defs/CorporateSymbolChange"
                              },
                              {
                                "$ref": "#/$defs/CorporateMerger"
                              },
                              {
                                "$ref": "#/$defs/CorporateSpinOff"
                              },
                              {
                                "$ref": "#/$defs/CorporateReturnOfCapital"
                              },
                              {
                                "$ref": "#/$defs/CorporateCashInLieu"
                              },
                              {
                                "$ref": "#/$defs/PositionTransfer"
                              }
                            ]
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original",
                          "replacement"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.account-migration",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.account-migration",
                            "type": "string"
                          },
                          "fromAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "toAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "fromAccountId",
                          "toAccountId"
                        ]
                      }
                    }
                  }
                ]
              }
            ]
          },
          "Before": {
            "type": "object",
            "properties": {
              "asOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "baseCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "netAssetValue": {
                "type": "number"
              },
              "cash": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "accountId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "currency": {
                      "type": "string",
                      "pattern": "^[A-Z]{3}$"
                    },
                    "totalAmount": {
                      "type": "number"
                    },
                    "settledAmount": {
                      "type": "number"
                    },
                    "unsettledReceivable": {
                      "type": "number"
                    },
                    "unsettledPayable": {
                      "type": "number"
                    },
                    "baseCurrencyValue": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "accountId",
                    "currency",
                    "totalAmount",
                    "settledAmount",
                    "unsettledReceivable",
                    "unsettledPayable",
                    "baseCurrencyValue"
                  ]
                }
              },
              "totalCashBaseCurrencyValue": {
                "type": "number"
              },
              "positions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "accountId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "instrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "currency": {
                      "type": "string",
                      "pattern": "^[A-Z]{3}$"
                    },
                    "quantity": {
                      "type": "number"
                    },
                    "markPricePerUnit": {
                      "type": "number"
                    },
                    "contractMultiplier": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "settlementStyle": {
                      "type": "string",
                      "enum": [
                        "cash-on-trade",
                        "variation-margin"
                      ]
                    },
                    "marketValue": {
                      "type": "number"
                    },
                    "baseCurrencyMarketValue": {
                      "type": "number"
                    },
                    "notionalValue": {
                      "type": "number"
                    },
                    "baseCurrencyNotionalValue": {
                      "type": "number"
                    },
                    "costBasis": {
                      "type": "number"
                    },
                    "unrealizedPnl": {
                      "type": "number"
                    },
                    "baseCurrencyUnrealizedPnl": {
                      "type": "number"
                    },
                    "lotCount": {
                      "type": "integer",
                      "minimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "accountId",
                    "instrumentId",
                    "currency",
                    "quantity",
                    "markPricePerUnit",
                    "contractMultiplier",
                    "settlementStyle",
                    "marketValue",
                    "baseCurrencyMarketValue",
                    "notionalValue",
                    "baseCurrencyNotionalValue",
                    "costBasis",
                    "unrealizedPnl",
                    "baseCurrencyUnrealizedPnl",
                    "lotCount"
                  ]
                }
              },
              "totalPositionsBaseCurrencyValue": {
                "type": "number"
              },
              "assumptions": {
                "type": "object",
                "properties": {
                  "conventionsVersion": {
                    "type": "string"
                  },
                  "lotRelief": {
                    "type": "string",
                    "enum": [
                      "fifo",
                      "lifo",
                      "highest-cost",
                      "specific-lot"
                    ]
                  },
                  "marketAsOf": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "currencyConversionsUsed": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "baseCurrency": {
                          "type": "string",
                          "pattern": "^[A-Z]{3}$"
                        },
                        "quoteCurrency": {
                          "type": "string",
                          "pattern": "^[A-Z]{3}$"
                        },
                        "quotePerBase": {
                          "type": "number",
                          "exclusiveMinimum": 0
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "baseCurrency",
                        "quoteCurrency",
                        "quotePerBase"
                      ]
                    }
                  },
                  "valuationConvention": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "conventionsVersion",
                  "lotRelief",
                  "marketAsOf",
                  "currencyConversionsUsed",
                  "valuationConvention"
                ]
              },
              "diagnostics": {
                "type": "object",
                "properties": {
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "accountCount": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "positionCount": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "warnings",
                  "accountCount",
                  "positionCount"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "asOf",
              "baseCurrency",
              "netAssetValue",
              "cash",
              "totalCashBaseCurrencyValue",
              "positions",
              "totalPositionsBaseCurrencyValue",
              "assumptions",
              "diagnostics"
            ]
          },
          "Contract": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "option",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "call",
                      "put"
                    ]
                  },
                  "strikePricePerUnit": {
                    "type": "number"
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "type",
                  "strikePricePerUnit",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "future",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "perpetual",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId"
                ]
              }
            ]
          },
          "Checks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "verdict": {
                  "type": "string",
                  "enum": [
                    "pass",
                    "fail",
                    "unverifiable",
                    "require-approval"
                  ]
                },
                "value": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "limit": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "detail": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "name",
                "verdict",
                "value",
                "limit",
                "detail"
              ]
            }
          },
          "Warnings": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "minLength": 1
                },
                "message": {
                  "type": "string"
                },
                "severity": {
                  "type": "string",
                  "enum": [
                    "info",
                    "warn",
                    "error"
                  ]
                },
                "context": {
                  "type": "object",
                  "additionalProperties": {}
                }
              },
              "additionalProperties": false,
              "required": [
                "code",
                "message",
                "severity"
              ]
            }
          },
          "CashDeposit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.deposit",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashWithdrawal": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.withdrawal",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.transfer",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency",
              "fromAccountId",
              "toAccountId"
            ]
          },
          "CashConversion": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.conversion",
                "type": "string"
              },
              "fromCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "toCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "toAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromCurrency",
              "toCurrency",
              "fromAmount",
              "toAmount"
            ]
          },
          "TradeFill": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "trade.fill",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "side": {
                "type": "string",
                "enum": [
                  "buy",
                  "sell"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              },
              "contractMultiplier": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlementStyle": {
                "type": "string",
                "enum": [
                  "cash-on-trade",
                  "variation-margin"
                ]
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "accruedInterest": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "side",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "LotSelections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "lotId": {
                  "type": "string",
                  "minLength": 1
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "lotId",
                "quantity"
              ]
            },
            "minItems": 1
          },
          "CostCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cost.charge",
                "type": "string"
              },
              "costType": {
                "type": "string",
                "enum": [
                  "commission",
                  "exchange-fee",
                  "regulatory-fee",
                  "slippage-adjustment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "costType",
              "amount",
              "currency"
            ]
          },
          "IncomeReceived": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "income.received",
                "type": "string"
              },
              "incomeType": {
                "type": "string",
                "enum": [
                  "dividend",
                  "coupon",
                  "interest",
                  "staking-reward",
                  "funding-receipt"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "incomeType",
              "amount",
              "currency"
            ]
          },
          "FinancingCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "financing.charge",
                "type": "string"
              },
              "financingType": {
                "type": "string",
                "enum": [
                  "margin-interest",
                  "borrow-charge",
                  "funding-payment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "financingType",
              "amount",
              "currency"
            ]
          },
          "CorporateSplit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.split",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesAfterSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "sharesBeforeSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "sharesAfterSplit",
              "sharesBeforeSplit"
            ]
          },
          "DerivativeExercise": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.exercise",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "Settlement": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "physical",
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "cash",
                    "type": "string"
                  },
                  "settlementPricePerUnit": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "settlementPricePerUnit"
                ]
              }
            ]
          },
          "DerivativeAssignment": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.assignment",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "DerivativeExpiration": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.expiration",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity"
            ]
          },
          "DerivativeMultiplierChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.multiplier-change",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "contractMultiplierAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "strikePricePerUnitAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "reason": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "contractMultiplierAfter"
            ]
          },
          "DerivativeVariationMargin": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.variation-margin",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settlementPricePerUnit": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "settlementPricePerUnit"
            ]
          },
          "DerivativeRoll": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.roll",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "closePricePerUnit": {
                "type": "number"
              },
              "openPricePerUnit": {
                "type": "number"
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId",
              "quantity",
              "closePricePerUnit",
              "openPricePerUnit"
            ]
          },
          "FixedIncomeRedemption": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "fixed-income.redemption",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "redemptionType": {
                "type": "string",
                "enum": [
                  "maturity",
                  "call",
                  "principal-paydown",
                  "sinking-fund"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "redemptionType",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "CorporateSymbolChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.symbol-change",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId"
            ]
          },
          "CorporateMerger": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.merger",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "cashPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId"
            ]
          },
          "CorporateSpinOff": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.spin-off",
                "type": "string"
              },
              "parentInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "childInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerParentShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "basisAllocationFraction": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "parentInstrumentId",
              "childInstrumentId",
              "sharesPerParentShare",
              "basisAllocationFraction"
            ]
          },
          "CorporateReturnOfCapital": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.return-of-capital",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "amountPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "amountPerShare",
              "currency"
            ]
          },
          "CorporateCashInLieu": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.cash-in-lieu",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "amount",
              "currency"
            ]
          },
          "PositionTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "position.transfer",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "fromAccountId",
              "toAccountId"
            ]
          }
        }
      },
      "totalfinance.trade.authorize.output": {
        "type": "object",
        "properties": {
          "grant": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.authorization-grant",
                "type": "string"
              },
              "schemaVersion": {
                "const": 1,
                "type": "number"
              },
              "grantId": {
                "type": "string",
                "minLength": 1
              },
              "planHash": {
                "type": "string",
                "minLength": 1
              },
              "preflightHash": {
                "type": "string",
                "minLength": 1
              },
              "portfolioHash": {
                "type": "string",
                "minLength": 1
              },
              "marketHash": {
                "type": "string",
                "minLength": 1
              },
              "marketAsOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "marketMaximumAgeMs": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "mode": {
                "const": "paper",
                "type": "string"
              },
              "accountId": {
                "type": "string",
                "minLength": 1
              },
              "baseCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "orderIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "comboIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "variance": {
                "type": "object",
                "properties": {
                  "maximumQuantityRatio": {
                    "type": "number",
                    "minimum": 0
                  },
                  "maximumNotionalRatio": {
                    "type": "number",
                    "minimum": 0
                  },
                  "maximumSlippageBps": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "maximumQuantityRatio",
                  "maximumNotionalRatio",
                  "maximumSlippageBps"
                ]
              },
              "issuedAt": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "expiresAt": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "approvedBy": {
                "type": "string",
                "minLength": 1
              },
              "requiredScope": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "idempotencyKeys": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "minItems": 1,
                "maxItems": 1000
              },
              "contentHash": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "grantId",
              "planHash",
              "preflightHash",
              "portfolioHash",
              "marketHash",
              "marketAsOf",
              "marketMaximumAgeMs",
              "mode",
              "accountId",
              "baseCurrency",
              "orderIds",
              "comboIds",
              "variance",
              "issuedAt",
              "expiresAt",
              "approvedBy",
              "requiredScope",
              "idempotencyKeys",
              "contentHash"
            ]
          },
          "handle": {
            "type": "object",
            "properties": {
              "uri": {
                "type": "string",
                "minLength": 1
              },
              "kind": {
                "type": "string",
                "enum": [
                  "report",
                  "job",
                  "portfolio",
                  "scenario",
                  "market",
                  "authorization",
                  "journal"
                ]
              },
              "schema": {
                "type": "string",
                "minLength": 1
              },
              "version": {
                "type": "string"
              },
              "contentHash": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "createdTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "expiresTimestampMs": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  },
                  "dataset": {
                    "type": "string"
                  },
                  "asOf": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "receivedAt": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "sourceVersion": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "minLength": 1
                        },
                        "message": {
                          "type": "string"
                        },
                        "severity": {
                          "type": "string",
                          "enum": [
                            "info",
                            "warn",
                            "error"
                          ]
                        },
                        "context": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message",
                        "severity"
                      ]
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "uri",
              "kind",
              "schema",
              "version",
              "contentHash",
              "createdTimestampMs",
              "expiresTimestampMs",
              "provenance"
            ]
          },
          "requiredScope": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "grant",
          "handle",
          "requiredScope"
        ],
        "$id": "https://totalfinance.dev/schemas/trade.authorize.output"
      },
      "totalfinance.trade.authorize.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.trade.authorize.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.trade.cancel.input": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string",
            "minLength": 1
          },
          "now": {
            "type": "number"
          },
          "sourceId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "baseCurrency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "idempotencyKey": {
            "type": "string",
            "minLength": 1
          },
          "journal": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "type": "object",
                  "properties": {
                    "eventId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "journalId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "timestampMs": {
                      "type": "number",
                      "description": "Epoch milliseconds"
                    },
                    "orderId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "planHash": {
                      "type": "string",
                      "minLength": 1
                    },
                    "idempotencyKey": {
                      "type": "string",
                      "minLength": 1
                    },
                    "sourceId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "provenance": {
                      "type": "object",
                      "properties": {
                        "provider": {
                          "type": "string"
                        },
                        "dataset": {
                          "type": "string"
                        },
                        "asOf": {
                          "type": "number",
                          "description": "Epoch milliseconds"
                        },
                        "receivedAt": {
                          "type": "number",
                          "description": "Epoch milliseconds"
                        },
                        "sourceVersion": {
                          "type": "string"
                        },
                        "requestId": {
                          "type": "string"
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "code": {
                                "type": "string",
                                "minLength": 1
                              },
                              "message": {
                                "type": "string"
                              },
                              "severity": {
                                "type": "string",
                                "enum": [
                                  "info",
                                  "warn",
                                  "error"
                                ]
                              },
                              "context": {
                                "type": "object",
                                "additionalProperties": {}
                              }
                            },
                            "additionalProperties": false,
                            "required": [
                              "code",
                              "message",
                              "severity"
                            ]
                          }
                        }
                      },
                      "additionalProperties": false
                    },
                    "eventType": {},
                    "detail": {}
                  },
                  "additionalProperties": false,
                  "required": [
                    "eventId",
                    "journalId",
                    "timestampMs",
                    "orderId",
                    "planHash",
                    "sourceId",
                    "provenance",
                    "eventType",
                    "detail"
                  ]
                },
                {
                  "anyOf": [
                    {
                      "properties": {
                        "eventType": {
                          "const": "proposed",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "preflighted",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "authorized",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "submitted",
                          "type": "string"
                        },
                        "detail": {
                          "type": "object",
                          "properties": {
                            "quantity": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            },
                            "fillId": {
                              "type": "string"
                            },
                            "pricePerUnit": {
                              "type": "number"
                            },
                            "reason": {
                              "type": "string"
                            },
                            "replacementOrderId": {
                              "type": "string"
                            },
                            "artifactHash": {
                              "type": "string"
                            },
                            "note": {
                              "type": "string"
                            },
                            "order": {
                              "allOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "instrumentId": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "side": {
                                      "type": "string",
                                      "enum": [
                                        "buy",
                                        "sell"
                                      ]
                                    },
                                    "timeInForce": {
                                      "type": "string",
                                      "enum": [
                                        "day",
                                        "gtc"
                                      ],
                                      "description": "Default: the paper execution policy’s day time-in-force"
                                    },
                                    "comboId": {
                                      "type": "string",
                                      "minLength": 1,
                                      "description": "The multi-leg order this is a leg of (B5)"
                                    },
                                    "orderId": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "quantity": {
                                      "type": "number",
                                      "exclusiveMinimum": 0,
                                      "description": "Units/contracts, strictly positive; side carries direction"
                                    },
                                    "plannedTimestampMs": {
                                      "type": "number",
                                      "description": "When the plan was made — never when a broker saw the order"
                                    },
                                    "submittedTimestampMs": {
                                      "type": "number",
                                      "description": "Epoch milliseconds"
                                    },
                                    "type": {},
                                    "limitPrice": {},
                                    "stopPrice": {}
                                  },
                                  "additionalProperties": false,
                                  "required": [
                                    "instrumentId",
                                    "side",
                                    "orderId",
                                    "quantity",
                                    "plannedTimestampMs",
                                    "type"
                                  ]
                                },
                                {
                                  "anyOf": [
                                    {
                                      "properties": {
                                        "type": {
                                          "const": "market",
                                          "type": "string"
                                        }
                                      },
                                      "not": {
                                        "anyOf": [
                                          {
                                            "required": [
                                              "limitPrice"
                                            ]
                                          },
                                          {
                                            "required": [
                                              "stopPrice"
                                            ]
                                          }
                                        ]
                                      }
                                    },
                                    {
                                      "properties": {
                                        "type": {
                                          "const": "market-on-open",
                                          "type": "string"
                                        }
                                      },
                                      "not": {
                                        "anyOf": [
                                          {
                                            "required": [
                                              "limitPrice"
                                            ]
                                          },
                                          {
                                            "required": [
                                              "stopPrice"
                                            ]
                                          }
                                        ]
                                      }
                                    },
                                    {
                                      "properties": {
                                        "type": {
                                          "const": "market-on-close",
                                          "type": "string"
                                        }
                                      },
                                      "not": {
                                        "anyOf": [
                                          {
                                            "required": [
                                              "limitPrice"
                                            ]
                                          },
                                          {
                                            "required": [
                                              "stopPrice"
                                            ]
                                          }
                                        ]
                                      }
                                    },
                                    {
                                      "properties": {
                                        "type": {
                                          "const": "limit",
                                          "type": "string"
                                        },
                                        "limitPrice": {
                                          "type": "number",
                                          "exclusiveMinimum": 0
                                        }
                                      },
                                      "required": [
                                        "limitPrice"
                                      ],
                                      "not": {
                                        "anyOf": [
                                          {
                                            "required": [
                                              "stopPrice"
                                            ]
                                          }
                                        ]
                                      }
                                    },
                                    {
                                      "properties": {
                                        "type": {
                                          "const": "stop",
                                          "type": "string"
                                        },
                                        "stopPrice": {
                                          "type": "number",
                                          "exclusiveMinimum": 0
                                        }
                                      },
                                      "required": [
                                        "stopPrice"
                                      ],
                                      "not": {
                                        "anyOf": [
                                          {
                                            "required": [
                                              "limitPrice"
                                            ]
                                          }
                                        ]
                                      }
                                    },
                                    {
                                      "properties": {
                                        "type": {
                                          "const": "stop-limit",
                                          "type": "string"
                                        },
                                        "limitPrice": {
                                          "type": "number",
                                          "exclusiveMinimum": 0
                                        },
                                        "stopPrice": {
                                          "type": "number",
                                          "exclusiveMinimum": 0
                                        }
                                      },
                                      "required": [
                                        "limitPrice",
                                        "stopPrice"
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            "instrument": {
                              "type": "object",
                              "properties": {
                                "currency": {
                                  "type": "string",
                                  "pattern": "^[A-Z]{3}$"
                                },
                                "contractMultiplier": {
                                  "type": "number",
                                  "exclusiveMinimum": 0
                                },
                                "contract": {
                                  "$ref": "#/$defs/Contract"
                                },
                                "settlementStyle": {
                                  "type": "string",
                                  "enum": [
                                    "cash-on-trade",
                                    "variation-margin"
                                  ]
                                },
                                "settlementLag": {
                                  "anyOf": [
                                    {
                                      "const": 0,
                                      "type": "number"
                                    },
                                    {
                                      "const": 1,
                                      "type": "number"
                                    },
                                    {
                                      "const": 2,
                                      "type": "number"
                                    }
                                  ],
                                  "description": "T+n 24-hour days in the paper broker; default 0"
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "currency"
                              ]
                            },
                            "accountId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "baseCurrency": {
                              "type": "string",
                              "pattern": "^[A-Z]{3}$"
                            },
                            "executionPolicyHash": {
                              "type": "string",
                              "minLength": 1
                            },
                            "comboId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "netLimitPrice": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "quantity"
                          ]
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "acknowledged",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "partially-filled",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail2"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "filled",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail2"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "rejected",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "cancel-requested",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "cancelled",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "replaced",
                          "type": "string"
                        },
                        "detail": {
                          "type": "object",
                          "properties": {
                            "quantity": {
                              "type": "number"
                            },
                            "fillId": {
                              "type": "string"
                            },
                            "pricePerUnit": {
                              "type": "number"
                            },
                            "reason": {
                              "type": "string"
                            },
                            "replacementOrderId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "artifactHash": {
                              "type": "string"
                            },
                            "note": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "replacementOrderId"
                          ]
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "expired",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "reconciled",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "unresolved",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    }
                  ]
                }
              ]
            },
            "description": "Optional exact canonical snapshot of the persisted journal; checked inside the transaction. Never imports or replaces history. An execution-journal store is required."
          }
        },
        "additionalProperties": false,
        "required": [
          "orderId",
          "now",
          "sourceId",
          "accountId",
          "baseCurrency"
        ],
        "$id": "https://totalfinance.dev/schemas/trade.cancel.input",
        "$defs": {
          "Detail": {
            "type": "object",
            "properties": {
              "quantity": {
                "type": "number"
              },
              "fillId": {
                "type": "string"
              },
              "pricePerUnit": {
                "type": "number"
              },
              "reason": {
                "type": "string"
              },
              "replacementOrderId": {
                "type": "string"
              },
              "artifactHash": {
                "type": "string"
              },
              "note": {
                "type": "string"
              }
            },
            "additionalProperties": false
          },
          "Contract": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "option",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "call",
                      "put"
                    ]
                  },
                  "strikePricePerUnit": {
                    "type": "number"
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "type",
                  "strikePricePerUnit",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "future",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "perpetual",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId"
                ]
              }
            ]
          },
          "Detail2": {
            "type": "object",
            "properties": {
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "fillId": {
                "type": "string",
                "minLength": 1
              },
              "pricePerUnit": {
                "type": "number"
              },
              "reason": {
                "type": "string"
              },
              "replacementOrderId": {
                "type": "string"
              },
              "artifactHash": {
                "type": "string"
              },
              "note": {
                "type": "string"
              },
              "observationTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "fill": {
                "type": "object",
                "properties": {
                  "fillId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "accountId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "instrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "side": {
                    "type": "string",
                    "enum": [
                      "buy",
                      "sell"
                    ]
                  },
                  "quantity": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "pricePerUnit": {
                    "type": "number"
                  },
                  "currency": {
                    "type": "string",
                    "pattern": "^[A-Z]{3}$"
                  },
                  "filledTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "settleTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "contractMultiplier": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "settlementStyle": {
                    "type": "string",
                    "enum": [
                      "cash-on-trade",
                      "variation-margin"
                    ]
                  },
                  "contract": {
                    "$ref": "#/$defs/Contract"
                  },
                  "accruedInterest": {
                    "type": "number"
                  },
                  "executionPriceAdjustment": {
                    "type": "number",
                    "minimum": 0
                  },
                  "costs": {
                    "type": "object",
                    "properties": {
                      "commission": {
                        "type": "number",
                        "minimum": 0
                      },
                      "exchangeFees": {
                        "type": "number",
                        "minimum": 0
                      },
                      "regulatoryFees": {
                        "type": "number",
                        "minimum": 0
                      },
                      "slippageAdjustment": {
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false
                  },
                  "orderId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "venue": {
                    "type": "string"
                  },
                  "liquidity": {
                    "type": "string",
                    "enum": [
                      "maker",
                      "taker",
                      "unknown"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "fillId",
                  "accountId",
                  "instrumentId",
                  "side",
                  "quantity",
                  "pricePerUnit",
                  "currency",
                  "filledTimestampMs"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "quantity",
              "fillId"
            ]
          }
        }
      },
      "totalfinance.trade.cancel.output": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string"
          },
          "accepted": {
            "type": "boolean"
          },
          "state": {
            "type": "object",
            "properties": {
              "orderId": {
                "type": "string",
                "minLength": 1
              },
              "planHash": {
                "type": "string",
                "minLength": 1
              },
              "state": {
                "type": "string",
                "enum": [
                  "submitted",
                  "acknowledged",
                  "partially-filled",
                  "filled",
                  "cancelled",
                  "rejected",
                  "expired",
                  "unresolved"
                ]
              },
              "submittedQuantity": {
                "type": "number",
                "minimum": 0
              },
              "filledQuantity": {
                "type": "number",
                "minimum": 0
              },
              "remainingQuantity": {
                "type": "number",
                "minimum": 0
              },
              "averageFillPrice": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "fillIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "lateFillIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "lastEventId": {
                "type": "string",
                "minLength": 1
              },
              "lastTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "terminal": {
                "type": "boolean"
              },
              "cancelRequested": {
                "type": "boolean"
              },
              "reason": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "replacedBy": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "reconciledEventId": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "orderId",
              "planHash",
              "state",
              "submittedQuantity",
              "filledQuantity",
              "remainingQuantity",
              "averageFillPrice",
              "fillIds",
              "lateFillIds",
              "lastEventId",
              "lastTimestampMs",
              "terminal",
              "cancelRequested",
              "reason",
              "replacedBy",
              "reconciledEventId"
            ]
          },
          "journal": {
            "type": "object",
            "properties": {
              "journalId": {
                "type": "string",
                "minLength": 1
              },
              "appended": {
                "type": "integer",
                "minimum": 0
              },
              "total": {
                "type": "integer",
                "minimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "journalId",
              "appended",
              "total"
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "orderId",
          "accepted",
          "state",
          "journal"
        ],
        "$id": "https://totalfinance.dev/schemas/trade.cancel.output"
      },
      "totalfinance.trade.cancel.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.trade.cancel.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.trade.preflight.input": {
        "type": "object",
        "properties": {
          "plan": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.execution-plan",
                "type": "string"
              },
              "schemaVersion": {
                "const": 1,
                "type": "number"
              },
              "accountId": {
                "type": "string",
                "minLength": 1
              },
              "asOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "baseCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "portfolioId": {
                "type": "string",
                "minLength": 1
              },
              "orders": {
                "type": "array",
                "items": {
                  "$ref": "#/$defs/Orders"
                },
                "minItems": 1,
                "maxItems": 1000
              },
              "combos": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "comboId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "orderIds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 1
                      },
                      "minItems": 2,
                      "description": "The legs, in plan order (at least two)"
                    },
                    "netLimitPrice": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "comboId",
                    "orderIds"
                  ]
                }
              },
              "trades": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "accountId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "instrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "side": {
                      "type": "string",
                      "enum": [
                        "buy",
                        "sell"
                      ]
                    },
                    "quantity": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "currency": {
                      "type": "string",
                      "pattern": "^[A-Z]{3}$"
                    },
                    "referencePricePerUnit": {
                      "type": "number"
                    },
                    "contractMultiplier": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "estimatedNotional": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "accountId",
                    "instrumentId",
                    "side",
                    "quantity",
                    "currency",
                    "referencePricePerUnit",
                    "contractMultiplier",
                    "estimatedNotional"
                  ]
                }
              },
              "source": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "intent",
                        "type": "string"
                      },
                      "intentHash": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "intentHash"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "rebalance-proposal",
                        "type": "string"
                      },
                      "planHash": {
                        "type": "string",
                        "minLength": 1
                      },
                      "policyContentHash": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "planHash",
                      "policyContentHash"
                    ]
                  }
                ]
              },
              "rationale": {
                "type": "string"
              },
              "evidence": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "contentHash": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "accountId",
              "asOf",
              "baseCurrency",
              "orders",
              "combos",
              "trades",
              "source",
              "evidence",
              "contentHash"
            ]
          },
          "intent": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.trade-intent",
                "type": "string"
              },
              "schemaVersion": {
                "const": 1,
                "type": "number"
              },
              "accountId": {
                "type": "string",
                "minLength": 1
              },
              "asOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "orders": {
                "type": "array",
                "items": {
                  "anyOf": [
                    {
                      "allOf": [
                        {
                          "type": "object",
                          "properties": {
                            "instrumentId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "enum": [
                                "buy",
                                "sell"
                              ]
                            },
                            "timeInForce": {
                              "type": "string",
                              "enum": [
                                "day",
                                "gtc"
                              ],
                              "description": "Default: the paper execution policy’s day time-in-force"
                            },
                            "comboId": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The multi-leg order this is a leg of (B5)"
                            },
                            "quantity": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            },
                            "type": {},
                            "limitPrice": {},
                            "stopPrice": {}
                          },
                          "additionalProperties": false,
                          "required": [
                            "instrumentId",
                            "side",
                            "quantity",
                            "type"
                          ]
                        },
                        {
                          "$ref": "#/$defs/Orders3"
                        }
                      ]
                    },
                    {
                      "allOf": [
                        {
                          "type": "object",
                          "properties": {
                            "instrumentId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "enum": [
                                "buy",
                                "sell"
                              ]
                            },
                            "timeInForce": {
                              "type": "string",
                              "enum": [
                                "day",
                                "gtc"
                              ],
                              "description": "Default: the paper execution policy’s day time-in-force"
                            },
                            "comboId": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The multi-leg order this is a leg of (B5)"
                            },
                            "notionalWeight": {
                              "type": "number",
                              "maximum": 1,
                              "exclusiveMinimum": 0,
                              "description": "Notional as a fraction of NAV at the mark, (0, 1]; mutually exclusive with quantity"
                            },
                            "type": {},
                            "limitPrice": {},
                            "stopPrice": {}
                          },
                          "additionalProperties": false,
                          "required": [
                            "instrumentId",
                            "side",
                            "notionalWeight",
                            "type"
                          ]
                        },
                        {
                          "$ref": "#/$defs/Orders3"
                        }
                      ]
                    }
                  ]
                },
                "minItems": 1,
                "maxItems": 1000
              },
              "combos": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "comboId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "netLimitPrice": {
                      "type": "number",
                      "description": "Net limit per combo unit: debit positive (pay at most), credit negative"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "comboId"
                  ]
                }
              },
              "rationale": {
                "type": "string"
              },
              "evidence": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "accountId",
              "asOf",
              "orders"
            ]
          },
          "portfolio": {
            "anyOf": [
              {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "totalfinance.portfolio-ledger",
                        "type": "string"
                      },
                      "schemaVersion": {
                        "const": 1,
                        "type": "number"
                      },
                      "portfolioId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "baseCurrency": {
                        "type": "string",
                        "pattern": "^[A-Z]{3}$"
                      },
                      "lotRelief": {
                        "type": "string",
                        "enum": [
                          "fifo",
                          "lifo",
                          "highest-cost",
                          "specific-lot"
                        ]
                      },
                      "events": {
                        "type": "array",
                        "items": {
                          "$ref": "#/$defs/PortfolioEventEnvelope"
                        }
                      },
                      "provenance": {
                        "$ref": "#/$defs/Provenance"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "schemaVersion",
                      "baseCurrency",
                      "lotRelief",
                      "events"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "schemaVersion": {
                        "const": 1,
                        "type": "number"
                      },
                      "portfolioId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "baseCurrency": {
                        "type": "string",
                        "pattern": "^[A-Z]{3}$"
                      },
                      "lotRelief": {
                        "type": "string",
                        "enum": [
                          "fifo",
                          "lifo",
                          "highest-cost",
                          "specific-lot"
                        ]
                      },
                      "accounts": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "cashBalances": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "properties": {
                                  "totalAmount": {
                                    "type": "number"
                                  },
                                  "settlementSchedule": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "eventId": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "amount": {
                                          "type": "number"
                                        },
                                        "settleTimestampMs": {
                                          "type": "number",
                                          "description": "Epoch milliseconds"
                                        }
                                      },
                                      "additionalProperties": false,
                                      "required": [
                                        "eventId",
                                        "amount",
                                        "settleTimestampMs"
                                      ]
                                    }
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "totalAmount",
                                  "settlementSchedule"
                                ]
                              }
                            },
                            "positions": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "properties": {
                                  "instrumentId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "currency": {
                                    "type": "string",
                                    "pattern": "^[A-Z]{3}$"
                                  },
                                  "contractMultiplier": {
                                    "type": "number",
                                    "exclusiveMinimum": 0
                                  },
                                  "settlementStyle": {
                                    "type": "string",
                                    "enum": [
                                      "cash-on-trade",
                                      "variation-margin"
                                    ]
                                  },
                                  "contract": {
                                    "$ref": "#/$defs/Contract"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "lots": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "lotId": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "openedByEventId": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "openedTimestampMs": {
                                          "type": "number",
                                          "description": "Epoch milliseconds"
                                        },
                                        "quantity": {
                                          "type": "number"
                                        },
                                        "costBasisPerUnit": {
                                          "type": "number"
                                        }
                                      },
                                      "additionalProperties": false,
                                      "required": [
                                        "lotId",
                                        "openedByEventId",
                                        "openedTimestampMs",
                                        "quantity",
                                        "costBasisPerUnit"
                                      ]
                                    }
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "instrumentId",
                                  "currency",
                                  "contractMultiplier",
                                  "settlementStyle",
                                  "quantity",
                                  "lots"
                                ]
                              }
                            },
                            "realizedPnl": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "incomeReceived": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "transactionCosts": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "financingCosts": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "realizedPnlByInstrument": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "number"
                                }
                              }
                            },
                            "incomeByInstrument": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "number"
                                }
                              }
                            },
                            "transactionCostsByInstrument": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "number"
                                }
                              }
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "cashBalances",
                            "positions",
                            "realizedPnl",
                            "incomeReceived",
                            "transactionCosts",
                            "financingCosts",
                            "realizedPnlByInstrument",
                            "incomeByInstrument",
                            "transactionCostsByInstrument"
                          ]
                        }
                      },
                      "appliedEvents": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      "eventCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "lastEffectiveTimestampMs": {
                        "anyOf": [
                          {
                            "type": "number",
                            "description": "Epoch milliseconds"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "lotSequence": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "fillEffects": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "accountId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "instrumentId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "currency": {
                              "type": "string",
                              "pattern": "^[A-Z]{3}$"
                            },
                            "openedLotIds": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "relievedQuantity": {
                              "type": "number"
                            },
                            "realizedPnl": {
                              "type": "number"
                            },
                            "cashDelta": {
                              "type": "number"
                            },
                            "accruedInterest": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "accountId",
                            "instrumentId",
                            "currency",
                            "openedLotIds",
                            "relievedQuantity",
                            "realizedPnl",
                            "cashDelta",
                            "accruedInterest"
                          ]
                        }
                      },
                      "reversals": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      "accountMigrations": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "eventId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "fromAccountId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "toAccountId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "effectiveTimestampMs": {
                              "type": "number",
                              "description": "Epoch milliseconds"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "eventId",
                            "fromAccountId",
                            "toAccountId",
                            "effectiveTimestampMs"
                          ]
                        }
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "schemaVersion",
                      "baseCurrency",
                      "lotRelief",
                      "accounts",
                      "appliedEvents",
                      "eventCount",
                      "lastEffectiveTimestampMs",
                      "lotSequence",
                      "fillEffects",
                      "reversals",
                      "accountMigrations"
                    ]
                  }
                ]
              },
              {
                "type": "string",
                "pattern": "^totalfinance:\\/\\/portfolios\\/"
              }
            ]
          },
          "market": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "totalfinance.market-snapshot",
                    "type": "string"
                  },
                  "schemaVersion": {
                    "const": 1,
                    "type": "number"
                  },
                  "asOf": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "conventions": {
                    "type": "object",
                    "properties": {
                      "conventionsVersion": {
                        "type": "string"
                      },
                      "asOfConvention": {
                        "type": "string",
                        "enum": [
                          "explicit-instant",
                          "date-midnight-utc"
                        ],
                        "description": "How asOf was expressed at create time: an instant, or a bare date (00:00 UTC of that date — refused by option pricing)"
                      },
                      "dayCount": {
                        "type": "string",
                        "enum": [
                          "ACT/365F",
                          "ACT/360",
                          "30/360"
                        ]
                      },
                      "compounding": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "simple",
                              "continuous",
                              "annual",
                              "semiannual",
                              "quarterly",
                              "monthly"
                            ]
                          },
                          {
                            "$ref": "#/$defs/Compounding"
                          }
                        ]
                      },
                      "calendar": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "conventionsVersion",
                      "asOfConvention"
                    ]
                  },
                  "observations": {
                    "type": "object",
                    "properties": {
                      "spots": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "price": {
                              "type": "number"
                            },
                            "currency": {
                              "type": "string"
                            },
                            "timestampMs": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": true,
                          "required": [
                            "price"
                          ]
                        }
                      },
                      "riskFreeRates": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "number"
                        }
                      },
                      "dividendYields": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "number"
                        }
                      },
                      "volatilities": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "number",
                          "minimum": 0
                        }
                      },
                      "curves": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "currency": {
                              "type": "string",
                              "minLength": 1,
                              "description": "Currency the curve discounts in (e.g. 'USD') — the curve states its own"
                            },
                            "asOf": {
                              "type": "number",
                              "description": "Curve valuation instant (epoch ms); every pillar is at or after it"
                            },
                            "dayCount": {
                              "type": "string",
                              "enum": [
                                "ACT/365F",
                                "ACT/360",
                                "30/360"
                              ],
                              "description": "Day-count convention the zero rates are quoted under"
                            },
                            "compounding": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "simple",
                                    "continuous",
                                    "annual",
                                    "semiannual",
                                    "quarterly",
                                    "monthly"
                                  ]
                                },
                                {
                                  "$ref": "#/$defs/Compounding"
                                }
                              ],
                              "description": "Interest compounding convention: 'simple' | 'continuous' | 'annual' | 'semiannual' | 'quarterly' | 'monthly' or { type: 'periodic', periodsPerYear }"
                            },
                            "points": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "date": {
                                    "type": "string",
                                    "format": "date",
                                    "description": "Pillar date, 'YYYY-MM-DD'"
                                  },
                                  "zeroRate": {
                                    "type": "number",
                                    "description": "Decimal zero rate quoted under the curve's own compounding/dayCount"
                                  }
                                },
                                "additionalProperties": true,
                                "required": [
                                  "date",
                                  "zeroRate"
                                ]
                              },
                              "description": "Pillar points — nonempty and strictly ascending by date (refused with teaching by the semantic validator)"
                            },
                            "interpolation": {
                              "type": "string",
                              "description": "Interpolation-name string when present (e.g. 'linearZero')"
                            }
                          },
                          "additionalProperties": true,
                          "required": [
                            "currency",
                            "asOf",
                            "dayCount",
                            "compounding",
                            "points"
                          ],
                          "description": "A stored RateCurve as plain data: { currency, asOf, dayCount, compounding, points: [{ date: 'YYYY-MM-DD', zeroRate }...], interpolation? } — structural shape above, semantics by core requireRateCurveData (nonempty strictly-ascending pillars at/after asOf, representable discount factors, open to vendor decoration)"
                        }
                      },
                      "surfaces": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "timeToExpiryYears": {
                              "type": "array",
                              "items": {
                                "type": "number",
                                "minimum": 0
                              }
                            },
                            "strikes": {
                              "type": "array",
                              "items": {
                                "type": "number",
                                "exclusiveMinimum": 0
                              }
                            },
                            "impliedVolatilities": {
                              "type": "array",
                              "items": {
                                "type": "array",
                                "items": {
                                  "type": "number",
                                  "minimum": 0
                                }
                              }
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "timeToExpiryYears",
                            "strikes",
                            "impliedVolatilities"
                          ]
                        }
                      },
                      "chains": {
                        "type": "object",
                        "additionalProperties": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "quotes": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "bid": {
                                        "type": "number"
                                      },
                                      "ask": {
                                        "type": "number"
                                      },
                                      "bidSize": {
                                        "type": "number"
                                      },
                                      "askSize": {
                                        "type": "number"
                                      },
                                      "mid": {
                                        "type": "number"
                                      },
                                      "last": {
                                        "type": "number"
                                      },
                                      "mark": {
                                        "type": "number"
                                      },
                                      "price": {
                                        "type": "number"
                                      },
                                      "size": {
                                        "type": "number"
                                      },
                                      "volume": {
                                        "type": "number"
                                      },
                                      "openInterest": {
                                        "type": "number"
                                      },
                                      "underlyingPrice": {
                                        "type": "number"
                                      },
                                      "impliedVolatility": {
                                        "type": "number"
                                      },
                                      "timestampMs": {
                                        "type": "number"
                                      },
                                      "sequence": {
                                        "type": "number"
                                      },
                                      "premium": {
                                        "type": "number"
                                      },
                                      "notional": {
                                        "type": "number"
                                      }
                                    },
                                    "additionalProperties": true
                                  }
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "quotes"
                              ]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "table": {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "const": "totalfinance.table-handle",
                                      "type": "string"
                                    },
                                    "contentHash": {
                                      "type": "string"
                                    },
                                    "rowCount": {
                                      "type": "integer",
                                      "minimum": 0
                                    },
                                    "columnCount": {
                                      "type": "integer",
                                      "minimum": 0
                                    },
                                    "columns": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    },
                                    "locator": {
                                      "type": "string"
                                    },
                                    "mediaType": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false,
                                  "required": [
                                    "kind",
                                    "contentHash",
                                    "rowCount",
                                    "columnCount"
                                  ]
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "table"
                              ]
                            }
                          ]
                        }
                      }
                    },
                    "additionalProperties": false
                  },
                  "provenance": {
                    "$ref": "#/$defs/Provenance"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "schemaVersion",
                  "asOf",
                  "conventions",
                  "observations"
                ]
              },
              {
                "type": "string",
                "pattern": "^totalfinance:\\/\\/markets\\/"
              }
            ]
          },
          "asOf": {
            "type": "number",
            "description": "Epoch ms — the instant the plan is judged at"
          },
          "policy": {
            "type": "object",
            "properties": {
              "mode": {
                "const": "paper",
                "type": "string"
              },
              "limits": {
                "type": "object",
                "properties": {
                  "maximumPositionWeight": {
                    "type": "number",
                    "minimum": 0
                  },
                  "maximumGroupWeights": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "group": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "instrumentId": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "instrumentId"
                              ]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "sleeveId": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "sleeveId"
                              ]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "assetClass": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "assetClass"
                              ]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "currency": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "currency"
                              ]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "tag": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "tag"
                              ]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "underlying": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "underlying"
                              ]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "strategy": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "strategy"
                              ]
                            }
                          ]
                        },
                        "maximumWeight": {
                          "type": "number",
                          "minimum": 0
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "group",
                        "maximumWeight"
                      ]
                    }
                  },
                  "maximumGrossLeverage": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "maximumDrawdown": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "maximumDailyLoss": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "maximumDaysToLiquidate": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "minimumSettledCash": {
                    "type": "number"
                  }
                },
                "additionalProperties": false
              },
              "allowedAccounts": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "allowedAssetClasses": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "allowedInstruments": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "allowedOrderTypes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "market",
                    "limit",
                    "stop",
                    "stop-limit",
                    "market-on-open",
                    "market-on-close"
                  ]
                }
              },
              "maximumOrderQuantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "maximumOrderNotional": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "maximumEstimatedCost": {
                "type": "number",
                "minimum": 0,
                "description": "Absolute base-currency estimated-cost ceiling; zero is a binding zero ceiling"
              },
              "maximumSlippageBps": {
                "type": "number",
                "minimum": 0,
                "description": "Slippage ceiling in basis points; zero permits no positive estimated slippage"
              },
              "maximumParticipation": {
                "type": "number",
                "maximum": 1,
                "exclusiveMinimum": 0
              },
              "allowUndefinedRiskOptions": {
                "type": "boolean",
                "description": "Default false: undefined-risk options are denied"
              },
              "marketMaximumAgeMs": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "maximumTurnover": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "requireApprovalAbove": {
                "type": "object",
                "properties": {
                  "notional": {
                    "type": "number",
                    "minimum": 0
                  },
                  "quantity": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "additionalProperties": false
              },
              "onUnverifiable": {
                "type": "string",
                "enum": [
                  "require-approval",
                  "deny"
                ],
                "description": "Default require-approval; missing evidence never implies allow"
              }
            },
            "additionalProperties": false,
            "required": [
              "mode"
            ]
          },
          "costs": {
            "type": "object",
            "properties": {
              "commissionBps": {
                "type": "number",
                "minimum": 0
              },
              "commissionPerOrder": {
                "type": "number",
                "minimum": 0
              },
              "spreadBps": {
                "type": "number",
                "minimum": 0
              },
              "slippageBps": {
                "type": "number",
                "minimum": 0
              }
            },
            "additionalProperties": false
          },
          "instruments": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "currency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "contractMultiplier": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "contract": {
                  "$ref": "#/$defs/Contract"
                },
                "assetClass": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "currency"
              ]
            }
          },
          "session": {
            "type": "object",
            "properties": {
              "open": {
                "type": "boolean"
              },
              "halted": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "additionalProperties": false,
            "required": [
              "open"
            ]
          },
          "openOrders": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/Orders"
            }
          },
          "volumes": {
            "type": "object",
            "additionalProperties": {
              "type": "number",
              "minimum": 0
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "portfolio",
          "market",
          "asOf",
          "policy"
        ],
        "oneOf": [
          {
            "required": [
              "plan"
            ],
            "not": {
              "required": [
                "intent"
              ]
            }
          },
          {
            "required": [
              "intent"
            ],
            "not": {
              "required": [
                "plan"
              ]
            }
          }
        ],
        "$id": "https://totalfinance.dev/schemas/trade.preflight.input",
        "$defs": {
          "PortfolioEventEnvelope": {
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "eventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "schemaVersion": {
                    "const": 1,
                    "type": "number"
                  },
                  "sourceId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "accountId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "effectiveTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "recordedTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "correlationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "causationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "reversesEventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "provenance": {
                    "$ref": "#/$defs/Provenance"
                  },
                  "eventType": {},
                  "event": {}
                },
                "additionalProperties": false,
                "required": [
                  "eventId",
                  "schemaVersion",
                  "sourceId",
                  "accountId",
                  "effectiveTimestampMs",
                  "recordedTimestampMs",
                  "provenance",
                  "eventType",
                  "event"
                ]
              },
              {
                "anyOf": [
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.deposit",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashDeposit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.withdrawal",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashWithdrawal"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.conversion",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashConversion"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "trade.fill",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/TradeFill"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cost.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CostCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "income.received",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/IncomeReceived"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "financing.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FinancingCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.split",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSplit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.exercise",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExercise"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.assignment",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeAssignment"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.expiration",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExpiration"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.multiplier-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeMultiplierChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.variation-margin",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeVariationMargin"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.roll",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeRoll"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "fixed-income.redemption",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FixedIncomeRedemption"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.symbol-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSymbolChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.merger",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateMerger"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.spin-off",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSpinOff"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.return-of-capital",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateReturnOfCapital"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.cash-in-lieu",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateCashInLieu"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "position.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/PositionTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.reversal",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.reversal",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.correction",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.correction",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "replacement": {
                            "anyOf": [
                              {
                                "$ref": "#/$defs/CashDeposit"
                              },
                              {
                                "$ref": "#/$defs/CashWithdrawal"
                              },
                              {
                                "$ref": "#/$defs/CashTransfer"
                              },
                              {
                                "$ref": "#/$defs/CashConversion"
                              },
                              {
                                "$ref": "#/$defs/TradeFill"
                              },
                              {
                                "$ref": "#/$defs/CostCharge"
                              },
                              {
                                "$ref": "#/$defs/IncomeReceived"
                              },
                              {
                                "$ref": "#/$defs/FinancingCharge"
                              },
                              {
                                "$ref": "#/$defs/CorporateSplit"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExercise"
                              },
                              {
                                "$ref": "#/$defs/DerivativeAssignment"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExpiration"
                              },
                              {
                                "$ref": "#/$defs/DerivativeMultiplierChange"
                              },
                              {
                                "$ref": "#/$defs/DerivativeVariationMargin"
                              },
                              {
                                "$ref": "#/$defs/DerivativeRoll"
                              },
                              {
                                "$ref": "#/$defs/FixedIncomeRedemption"
                              },
                              {
                                "$ref": "#/$defs/CorporateSymbolChange"
                              },
                              {
                                "$ref": "#/$defs/CorporateMerger"
                              },
                              {
                                "$ref": "#/$defs/CorporateSpinOff"
                              },
                              {
                                "$ref": "#/$defs/CorporateReturnOfCapital"
                              },
                              {
                                "$ref": "#/$defs/CorporateCashInLieu"
                              },
                              {
                                "$ref": "#/$defs/PositionTransfer"
                              }
                            ]
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original",
                          "replacement"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.account-migration",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.account-migration",
                            "type": "string"
                          },
                          "fromAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "toAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "fromAccountId",
                          "toAccountId"
                        ]
                      }
                    }
                  }
                ]
              }
            ]
          },
          "Orders": {
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "instrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "side": {
                    "type": "string",
                    "enum": [
                      "buy",
                      "sell"
                    ]
                  },
                  "timeInForce": {
                    "type": "string",
                    "enum": [
                      "day",
                      "gtc"
                    ],
                    "description": "Default: the paper execution policy’s day time-in-force"
                  },
                  "comboId": {
                    "type": "string",
                    "minLength": 1,
                    "description": "The multi-leg order this is a leg of (B5)"
                  },
                  "orderId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "quantity": {
                    "type": "number",
                    "exclusiveMinimum": 0,
                    "description": "Units/contracts, strictly positive; side carries direction"
                  },
                  "plannedTimestampMs": {
                    "type": "number",
                    "description": "When the plan was made — never when a broker saw the order"
                  },
                  "submittedTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "type": {},
                  "limitPrice": {},
                  "stopPrice": {}
                },
                "additionalProperties": false,
                "required": [
                  "instrumentId",
                  "side",
                  "orderId",
                  "quantity",
                  "plannedTimestampMs",
                  "type"
                ]
              },
              {
                "$ref": "#/$defs/Orders3"
              }
            ]
          },
          "Orders3": {
            "anyOf": [
              {
                "properties": {
                  "type": {
                    "const": "market",
                    "type": "string"
                  }
                },
                "not": {
                  "anyOf": [
                    {
                      "required": [
                        "limitPrice"
                      ]
                    },
                    {
                      "required": [
                        "stopPrice"
                      ]
                    }
                  ]
                }
              },
              {
                "properties": {
                  "type": {
                    "const": "market-on-open",
                    "type": "string"
                  }
                },
                "not": {
                  "anyOf": [
                    {
                      "required": [
                        "limitPrice"
                      ]
                    },
                    {
                      "required": [
                        "stopPrice"
                      ]
                    }
                  ]
                }
              },
              {
                "properties": {
                  "type": {
                    "const": "market-on-close",
                    "type": "string"
                  }
                },
                "not": {
                  "anyOf": [
                    {
                      "required": [
                        "limitPrice"
                      ]
                    },
                    {
                      "required": [
                        "stopPrice"
                      ]
                    }
                  ]
                }
              },
              {
                "properties": {
                  "type": {
                    "const": "limit",
                    "type": "string"
                  },
                  "limitPrice": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  }
                },
                "required": [
                  "limitPrice"
                ],
                "not": {
                  "anyOf": [
                    {
                      "required": [
                        "stopPrice"
                      ]
                    }
                  ]
                }
              },
              {
                "properties": {
                  "type": {
                    "const": "stop",
                    "type": "string"
                  },
                  "stopPrice": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  }
                },
                "required": [
                  "stopPrice"
                ],
                "not": {
                  "anyOf": [
                    {
                      "required": [
                        "limitPrice"
                      ]
                    }
                  ]
                }
              },
              {
                "properties": {
                  "type": {
                    "const": "stop-limit",
                    "type": "string"
                  },
                  "limitPrice": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "stopPrice": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  }
                },
                "required": [
                  "limitPrice",
                  "stopPrice"
                ]
              }
            ]
          },
          "Provenance": {
            "type": "object",
            "properties": {
              "provider": {
                "type": "string"
              },
              "dataset": {
                "type": "string"
              },
              "asOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "receivedAt": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "sourceVersion": {
                "type": "string"
              },
              "requestId": {
                "type": "string"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string",
                      "minLength": 1
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              }
            },
            "additionalProperties": false
          },
          "Contract": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "option",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "call",
                      "put"
                    ]
                  },
                  "strikePricePerUnit": {
                    "type": "number"
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "type",
                  "strikePricePerUnit",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "future",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "perpetual",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId"
                ]
              }
            ]
          },
          "Compounding": {
            "type": "object",
            "properties": {
              "type": {
                "const": "periodic",
                "type": "string"
              },
              "periodsPerYear": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": true,
            "required": [
              "type",
              "periodsPerYear"
            ]
          },
          "CashDeposit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.deposit",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashWithdrawal": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.withdrawal",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.transfer",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency",
              "fromAccountId",
              "toAccountId"
            ]
          },
          "CashConversion": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.conversion",
                "type": "string"
              },
              "fromCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "toCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "toAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromCurrency",
              "toCurrency",
              "fromAmount",
              "toAmount"
            ]
          },
          "TradeFill": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "trade.fill",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "side": {
                "type": "string",
                "enum": [
                  "buy",
                  "sell"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              },
              "contractMultiplier": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlementStyle": {
                "type": "string",
                "enum": [
                  "cash-on-trade",
                  "variation-margin"
                ]
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "accruedInterest": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "side",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "LotSelections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "lotId": {
                  "type": "string",
                  "minLength": 1
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "lotId",
                "quantity"
              ]
            },
            "minItems": 1
          },
          "CostCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cost.charge",
                "type": "string"
              },
              "costType": {
                "type": "string",
                "enum": [
                  "commission",
                  "exchange-fee",
                  "regulatory-fee",
                  "slippage-adjustment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "costType",
              "amount",
              "currency"
            ]
          },
          "IncomeReceived": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "income.received",
                "type": "string"
              },
              "incomeType": {
                "type": "string",
                "enum": [
                  "dividend",
                  "coupon",
                  "interest",
                  "staking-reward",
                  "funding-receipt"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "incomeType",
              "amount",
              "currency"
            ]
          },
          "FinancingCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "financing.charge",
                "type": "string"
              },
              "financingType": {
                "type": "string",
                "enum": [
                  "margin-interest",
                  "borrow-charge",
                  "funding-payment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "financingType",
              "amount",
              "currency"
            ]
          },
          "CorporateSplit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.split",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesAfterSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "sharesBeforeSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "sharesAfterSplit",
              "sharesBeforeSplit"
            ]
          },
          "DerivativeExercise": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.exercise",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "Settlement": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "physical",
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "cash",
                    "type": "string"
                  },
                  "settlementPricePerUnit": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "settlementPricePerUnit"
                ]
              }
            ]
          },
          "DerivativeAssignment": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.assignment",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "DerivativeExpiration": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.expiration",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity"
            ]
          },
          "DerivativeMultiplierChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.multiplier-change",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "contractMultiplierAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "strikePricePerUnitAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "reason": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "contractMultiplierAfter"
            ]
          },
          "DerivativeVariationMargin": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.variation-margin",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settlementPricePerUnit": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "settlementPricePerUnit"
            ]
          },
          "DerivativeRoll": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.roll",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "closePricePerUnit": {
                "type": "number"
              },
              "openPricePerUnit": {
                "type": "number"
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId",
              "quantity",
              "closePricePerUnit",
              "openPricePerUnit"
            ]
          },
          "FixedIncomeRedemption": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "fixed-income.redemption",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "redemptionType": {
                "type": "string",
                "enum": [
                  "maturity",
                  "call",
                  "principal-paydown",
                  "sinking-fund"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "redemptionType",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "CorporateSymbolChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.symbol-change",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId"
            ]
          },
          "CorporateMerger": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.merger",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "cashPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId"
            ]
          },
          "CorporateSpinOff": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.spin-off",
                "type": "string"
              },
              "parentInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "childInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerParentShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "basisAllocationFraction": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "parentInstrumentId",
              "childInstrumentId",
              "sharesPerParentShare",
              "basisAllocationFraction"
            ]
          },
          "CorporateReturnOfCapital": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.return-of-capital",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "amountPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "amountPerShare",
              "currency"
            ]
          },
          "CorporateCashInLieu": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.cash-in-lieu",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "amount",
              "currency"
            ]
          },
          "PositionTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "position.transfer",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "fromAccountId",
              "toAccountId"
            ]
          }
        }
      },
      "totalfinance.trade.preflight.output": {
        "type": "object",
        "properties": {
          "kind": {
            "const": "totalfinance.preflight-report",
            "type": "string"
          },
          "schemaVersion": {
            "const": 1,
            "type": "number"
          },
          "asOf": {
            "type": "number",
            "description": "Epoch milliseconds"
          },
          "planHash": {
            "type": "string",
            "minLength": 1
          },
          "portfolioHash": {
            "type": "string",
            "minLength": 1
          },
          "marketHash": {
            "type": "string",
            "minLength": 1
          },
          "marketAsOf": {
            "type": "number",
            "description": "Epoch milliseconds"
          },
          "before": {
            "$ref": "#/$defs/Before"
          },
          "after": {
            "$ref": "#/$defs/Before"
          },
          "hypotheticalFills": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "fillId": {
                  "type": "string",
                  "minLength": 1
                },
                "accountId": {
                  "type": "string",
                  "minLength": 1
                },
                "instrumentId": {
                  "type": "string",
                  "minLength": 1
                },
                "side": {
                  "type": "string",
                  "enum": [
                    "buy",
                    "sell"
                  ]
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "pricePerUnit": {
                  "type": "number"
                },
                "currency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "filledTimestampMs": {
                  "type": "number",
                  "description": "Epoch milliseconds"
                },
                "settleTimestampMs": {
                  "type": "number",
                  "description": "Epoch milliseconds"
                },
                "contractMultiplier": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "settlementStyle": {
                  "type": "string",
                  "enum": [
                    "cash-on-trade",
                    "variation-margin"
                  ]
                },
                "contract": {
                  "$ref": "#/$defs/Contract"
                },
                "accruedInterest": {
                  "type": "number"
                },
                "executionPriceAdjustment": {
                  "type": "number",
                  "minimum": 0
                },
                "costs": {
                  "type": "object",
                  "properties": {
                    "commission": {
                      "type": "number",
                      "minimum": 0
                    },
                    "exchangeFees": {
                      "type": "number",
                      "minimum": 0
                    },
                    "regulatoryFees": {
                      "type": "number",
                      "minimum": 0
                    },
                    "slippageAdjustment": {
                      "type": "number",
                      "minimum": 0
                    }
                  },
                  "additionalProperties": false
                },
                "orderId": {
                  "type": "string",
                  "minLength": 1
                },
                "venue": {
                  "type": "string"
                },
                "liquidity": {
                  "type": "string",
                  "enum": [
                    "maker",
                    "taker",
                    "unknown"
                  ]
                }
              },
              "additionalProperties": false,
              "required": [
                "fillId",
                "accountId",
                "instrumentId",
                "side",
                "quantity",
                "pricePerUnit",
                "currency",
                "filledTimestampMs"
              ]
            }
          },
          "hypotheticalEvents": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/PortfolioEventEnvelope"
            }
          },
          "estimates": {
            "type": "object",
            "properties": {
              "tradedNotional": {
                "type": "number"
              },
              "commission": {
                "type": "number"
              },
              "spread": {
                "type": "number"
              },
              "slippage": {
                "type": "number"
              },
              "totalCost": {
                "type": "number"
              },
              "turnover": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "tradedNotional",
              "commission",
              "spread",
              "slippage",
              "totalCost",
              "turnover"
            ]
          },
          "checks": {
            "$ref": "#/$defs/Checks"
          },
          "alerts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string",
                  "minLength": 1
                },
                "family": {
                  "type": "string",
                  "enum": [
                    "allocation-drift",
                    "concentration-limit",
                    "leverage-limit",
                    "drawdown",
                    "daily-loss",
                    "cash-reserve",
                    "margin-pressure",
                    "liquidity",
                    "option-expiration",
                    "assignment-risk",
                    "stale-market-data",
                    "reconciliation-difference",
                    "unexplained-residual",
                    "unusual-pnl"
                  ]
                },
                "subject": {
                  "type": "string"
                },
                "severity": {
                  "type": "string",
                  "enum": [
                    "informational",
                    "warning",
                    "critical"
                  ]
                },
                "state": {
                  "type": "string",
                  "enum": [
                    "raised",
                    "active",
                    "acknowledged",
                    "suppressed",
                    "cleared"
                  ]
                },
                "value": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "threshold": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "direction": {
                  "type": "string",
                  "enum": [
                    "above",
                    "below"
                  ]
                },
                "message": {
                  "type": "string"
                },
                "evidence": {
                  "type": "object",
                  "additionalProperties": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              },
              "additionalProperties": false,
              "required": [
                "key",
                "family",
                "subject",
                "severity",
                "state",
                "value",
                "threshold",
                "direction",
                "message",
                "evidence"
              ]
            }
          },
          "decision": {
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "verdict": {},
                  "checks": {
                    "$ref": "#/$defs/Checks"
                  },
                  "requiredScope": {}
                },
                "additionalProperties": false,
                "required": [
                  "verdict",
                  "checks"
                ]
              },
              {
                "anyOf": [
                  {
                    "properties": {
                      "verdict": {
                        "const": "allow",
                        "type": "string"
                      }
                    },
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "requiredScope"
                          ]
                        }
                      ]
                    }
                  },
                  {
                    "properties": {
                      "verdict": {
                        "const": "deny",
                        "type": "string"
                      }
                    },
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "requiredScope"
                          ]
                        }
                      ]
                    }
                  },
                  {
                    "properties": {
                      "verdict": {
                        "const": "require-approval",
                        "type": "string"
                      },
                      "requiredScope": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "requiredScope"
                    ]
                  }
                ]
              }
            ]
          },
          "unverifiable": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "monitorState": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "schemaVersion": {
                    "const": 1,
                    "type": "number"
                  },
                  "asOf": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "netAssetValue": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "peakNetAssetValue": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "evaluationCount": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "rules": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "properties": {
                        "active": {
                          "type": "boolean"
                        },
                        "consecutiveBreaches": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "lastRaisedAtMs": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "acknowledged": {
                          "type": "boolean"
                        },
                        "lastValue": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "active",
                        "consecutiveBreaches",
                        "lastRaisedAtMs",
                        "acknowledged",
                        "lastValue"
                      ]
                    }
                  }
                },
                "additionalProperties": false,
                "required": [
                  "schemaVersion",
                  "asOf",
                  "netAssetValue",
                  "peakNetAssetValue",
                  "evaluationCount",
                  "rules"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "assumptions": {
            "type": "object",
            "properties": {
              "conventionsVersion": {
                "type": "string"
              },
              "policyContentHash": {
                "type": "string"
              },
              "mode": {
                "const": "paper",
                "type": "string"
              },
              "costRates": {
                "type": "object",
                "properties": {
                  "commissionBps": {
                    "type": "number",
                    "minimum": 0
                  },
                  "commissionPerOrder": {
                    "type": "number",
                    "minimum": 0
                  },
                  "spreadBps": {
                    "type": "number",
                    "minimum": 0
                  },
                  "slippageBps": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "commissionBps",
                  "commissionPerOrder",
                  "spreadBps",
                  "slippageBps"
                ]
              },
              "fillConvention": {
                "type": "string"
              },
              "instrumentSources": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              },
              "decisionConvention": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "conventionsVersion",
              "policyContentHash",
              "mode",
              "costRates",
              "fillConvention",
              "instrumentSources",
              "decisionConvention"
            ]
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "engine": {
                "const": "trade-preflight",
                "type": "string"
              },
              "method": {
                "const": "hypothetical-fold",
                "type": "string"
              },
              "converged": {
                "const": true,
                "type": "boolean"
              },
              "warnings": {
                "$ref": "#/$defs/Warnings"
              },
              "checkCount": {
                "type": "integer",
                "minimum": 0
              },
              "failedCount": {
                "type": "integer",
                "minimum": 0
              },
              "unverifiableCount": {
                "type": "integer",
                "minimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "engine",
              "method",
              "converged",
              "warnings",
              "checkCount",
              "failedCount",
              "unverifiableCount"
            ]
          },
          "contentHash": {
            "type": "string",
            "minLength": 1
          },
          "plan": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.execution-plan",
                "type": "string"
              },
              "schemaVersion": {
                "const": 1,
                "type": "number"
              },
              "accountId": {
                "type": "string",
                "minLength": 1
              },
              "asOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "baseCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "portfolioId": {
                "type": "string",
                "minLength": 1
              },
              "orders": {
                "type": "array",
                "items": {
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "instrumentId": {
                          "type": "string",
                          "minLength": 1
                        },
                        "side": {
                          "type": "string",
                          "enum": [
                            "buy",
                            "sell"
                          ]
                        },
                        "timeInForce": {
                          "type": "string",
                          "enum": [
                            "day",
                            "gtc"
                          ],
                          "description": "Default: the paper execution policy’s day time-in-force"
                        },
                        "comboId": {
                          "type": "string",
                          "minLength": 1,
                          "description": "The multi-leg order this is a leg of (B5)"
                        },
                        "orderId": {
                          "type": "string",
                          "minLength": 1
                        },
                        "quantity": {
                          "type": "number",
                          "exclusiveMinimum": 0,
                          "description": "Units/contracts, strictly positive; side carries direction"
                        },
                        "plannedTimestampMs": {
                          "type": "number",
                          "description": "When the plan was made — never when a broker saw the order"
                        },
                        "submittedTimestampMs": {
                          "type": "number",
                          "description": "Epoch milliseconds"
                        },
                        "type": {},
                        "limitPrice": {},
                        "stopPrice": {}
                      },
                      "additionalProperties": false,
                      "required": [
                        "instrumentId",
                        "side",
                        "orderId",
                        "quantity",
                        "plannedTimestampMs",
                        "type"
                      ]
                    },
                    {
                      "anyOf": [
                        {
                          "properties": {
                            "type": {
                              "const": "market",
                              "type": "string"
                            }
                          },
                          "not": {
                            "anyOf": [
                              {
                                "required": [
                                  "limitPrice"
                                ]
                              },
                              {
                                "required": [
                                  "stopPrice"
                                ]
                              }
                            ]
                          }
                        },
                        {
                          "properties": {
                            "type": {
                              "const": "market-on-open",
                              "type": "string"
                            }
                          },
                          "not": {
                            "anyOf": [
                              {
                                "required": [
                                  "limitPrice"
                                ]
                              },
                              {
                                "required": [
                                  "stopPrice"
                                ]
                              }
                            ]
                          }
                        },
                        {
                          "properties": {
                            "type": {
                              "const": "market-on-close",
                              "type": "string"
                            }
                          },
                          "not": {
                            "anyOf": [
                              {
                                "required": [
                                  "limitPrice"
                                ]
                              },
                              {
                                "required": [
                                  "stopPrice"
                                ]
                              }
                            ]
                          }
                        },
                        {
                          "properties": {
                            "type": {
                              "const": "limit",
                              "type": "string"
                            },
                            "limitPrice": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "required": [
                            "limitPrice"
                          ],
                          "not": {
                            "anyOf": [
                              {
                                "required": [
                                  "stopPrice"
                                ]
                              }
                            ]
                          }
                        },
                        {
                          "properties": {
                            "type": {
                              "const": "stop",
                              "type": "string"
                            },
                            "stopPrice": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "required": [
                            "stopPrice"
                          ],
                          "not": {
                            "anyOf": [
                              {
                                "required": [
                                  "limitPrice"
                                ]
                              }
                            ]
                          }
                        },
                        {
                          "properties": {
                            "type": {
                              "const": "stop-limit",
                              "type": "string"
                            },
                            "limitPrice": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            },
                            "stopPrice": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            }
                          },
                          "required": [
                            "limitPrice",
                            "stopPrice"
                          ]
                        }
                      ]
                    }
                  ]
                },
                "minItems": 1,
                "maxItems": 1000
              },
              "combos": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "comboId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "orderIds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 1
                      },
                      "minItems": 2,
                      "description": "The legs, in plan order (at least two)"
                    },
                    "netLimitPrice": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "comboId",
                    "orderIds"
                  ]
                }
              },
              "trades": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "accountId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "instrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "side": {
                      "type": "string",
                      "enum": [
                        "buy",
                        "sell"
                      ]
                    },
                    "quantity": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "currency": {
                      "type": "string",
                      "pattern": "^[A-Z]{3}$"
                    },
                    "referencePricePerUnit": {
                      "type": "number"
                    },
                    "contractMultiplier": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "estimatedNotional": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "accountId",
                    "instrumentId",
                    "side",
                    "quantity",
                    "currency",
                    "referencePricePerUnit",
                    "contractMultiplier",
                    "estimatedNotional"
                  ]
                }
              },
              "source": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "intent",
                        "type": "string"
                      },
                      "intentHash": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "intentHash"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "rebalance-proposal",
                        "type": "string"
                      },
                      "planHash": {
                        "type": "string",
                        "minLength": 1
                      },
                      "policyContentHash": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "planHash",
                      "policyContentHash"
                    ]
                  }
                ]
              },
              "rationale": {
                "type": "string"
              },
              "evidence": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "contentHash": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "accountId",
              "asOf",
              "baseCurrency",
              "orders",
              "combos",
              "trades",
              "source",
              "evidence",
              "contentHash"
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "kind",
          "schemaVersion",
          "asOf",
          "planHash",
          "portfolioHash",
          "marketHash",
          "marketAsOf",
          "before",
          "after",
          "hypotheticalFills",
          "hypotheticalEvents",
          "estimates",
          "checks",
          "alerts",
          "decision",
          "unverifiable",
          "monitorState",
          "assumptions",
          "diagnostics",
          "contentHash",
          "plan"
        ],
        "$id": "https://totalfinance.dev/schemas/trade.preflight.output",
        "$defs": {
          "PortfolioEventEnvelope": {
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "eventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "schemaVersion": {
                    "const": 1,
                    "type": "number"
                  },
                  "sourceId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "accountId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "effectiveTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "recordedTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "correlationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "causationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "reversesEventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "provenance": {
                    "type": "object",
                    "properties": {
                      "provider": {
                        "type": "string"
                      },
                      "dataset": {
                        "type": "string"
                      },
                      "asOf": {
                        "type": "number",
                        "description": "Epoch milliseconds"
                      },
                      "receivedAt": {
                        "type": "number",
                        "description": "Epoch milliseconds"
                      },
                      "sourceVersion": {
                        "type": "string"
                      },
                      "requestId": {
                        "type": "string"
                      },
                      "warnings": {
                        "$ref": "#/$defs/Warnings"
                      }
                    },
                    "additionalProperties": false
                  },
                  "eventType": {},
                  "event": {}
                },
                "additionalProperties": false,
                "required": [
                  "eventId",
                  "schemaVersion",
                  "sourceId",
                  "accountId",
                  "effectiveTimestampMs",
                  "recordedTimestampMs",
                  "provenance",
                  "eventType",
                  "event"
                ]
              },
              {
                "anyOf": [
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.deposit",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashDeposit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.withdrawal",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashWithdrawal"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.conversion",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashConversion"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "trade.fill",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/TradeFill"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cost.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CostCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "income.received",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/IncomeReceived"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "financing.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FinancingCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.split",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSplit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.exercise",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExercise"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.assignment",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeAssignment"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.expiration",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExpiration"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.multiplier-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeMultiplierChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.variation-margin",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeVariationMargin"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.roll",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeRoll"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "fixed-income.redemption",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FixedIncomeRedemption"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.symbol-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSymbolChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.merger",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateMerger"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.spin-off",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSpinOff"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.return-of-capital",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateReturnOfCapital"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.cash-in-lieu",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateCashInLieu"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "position.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/PositionTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.reversal",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.reversal",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.correction",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.correction",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "replacement": {
                            "anyOf": [
                              {
                                "$ref": "#/$defs/CashDeposit"
                              },
                              {
                                "$ref": "#/$defs/CashWithdrawal"
                              },
                              {
                                "$ref": "#/$defs/CashTransfer"
                              },
                              {
                                "$ref": "#/$defs/CashConversion"
                              },
                              {
                                "$ref": "#/$defs/TradeFill"
                              },
                              {
                                "$ref": "#/$defs/CostCharge"
                              },
                              {
                                "$ref": "#/$defs/IncomeReceived"
                              },
                              {
                                "$ref": "#/$defs/FinancingCharge"
                              },
                              {
                                "$ref": "#/$defs/CorporateSplit"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExercise"
                              },
                              {
                                "$ref": "#/$defs/DerivativeAssignment"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExpiration"
                              },
                              {
                                "$ref": "#/$defs/DerivativeMultiplierChange"
                              },
                              {
                                "$ref": "#/$defs/DerivativeVariationMargin"
                              },
                              {
                                "$ref": "#/$defs/DerivativeRoll"
                              },
                              {
                                "$ref": "#/$defs/FixedIncomeRedemption"
                              },
                              {
                                "$ref": "#/$defs/CorporateSymbolChange"
                              },
                              {
                                "$ref": "#/$defs/CorporateMerger"
                              },
                              {
                                "$ref": "#/$defs/CorporateSpinOff"
                              },
                              {
                                "$ref": "#/$defs/CorporateReturnOfCapital"
                              },
                              {
                                "$ref": "#/$defs/CorporateCashInLieu"
                              },
                              {
                                "$ref": "#/$defs/PositionTransfer"
                              }
                            ]
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original",
                          "replacement"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.account-migration",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.account-migration",
                            "type": "string"
                          },
                          "fromAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "toAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "fromAccountId",
                          "toAccountId"
                        ]
                      }
                    }
                  }
                ]
              }
            ]
          },
          "Before": {
            "type": "object",
            "properties": {
              "asOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "baseCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "netAssetValue": {
                "type": "number"
              },
              "cash": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "accountId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "currency": {
                      "type": "string",
                      "pattern": "^[A-Z]{3}$"
                    },
                    "totalAmount": {
                      "type": "number"
                    },
                    "settledAmount": {
                      "type": "number"
                    },
                    "unsettledReceivable": {
                      "type": "number"
                    },
                    "unsettledPayable": {
                      "type": "number"
                    },
                    "baseCurrencyValue": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "accountId",
                    "currency",
                    "totalAmount",
                    "settledAmount",
                    "unsettledReceivable",
                    "unsettledPayable",
                    "baseCurrencyValue"
                  ]
                }
              },
              "totalCashBaseCurrencyValue": {
                "type": "number"
              },
              "positions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "accountId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "instrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "currency": {
                      "type": "string",
                      "pattern": "^[A-Z]{3}$"
                    },
                    "quantity": {
                      "type": "number"
                    },
                    "markPricePerUnit": {
                      "type": "number"
                    },
                    "contractMultiplier": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "settlementStyle": {
                      "type": "string",
                      "enum": [
                        "cash-on-trade",
                        "variation-margin"
                      ]
                    },
                    "marketValue": {
                      "type": "number"
                    },
                    "baseCurrencyMarketValue": {
                      "type": "number"
                    },
                    "notionalValue": {
                      "type": "number"
                    },
                    "baseCurrencyNotionalValue": {
                      "type": "number"
                    },
                    "costBasis": {
                      "type": "number"
                    },
                    "unrealizedPnl": {
                      "type": "number"
                    },
                    "baseCurrencyUnrealizedPnl": {
                      "type": "number"
                    },
                    "lotCount": {
                      "type": "integer",
                      "minimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "accountId",
                    "instrumentId",
                    "currency",
                    "quantity",
                    "markPricePerUnit",
                    "contractMultiplier",
                    "settlementStyle",
                    "marketValue",
                    "baseCurrencyMarketValue",
                    "notionalValue",
                    "baseCurrencyNotionalValue",
                    "costBasis",
                    "unrealizedPnl",
                    "baseCurrencyUnrealizedPnl",
                    "lotCount"
                  ]
                }
              },
              "totalPositionsBaseCurrencyValue": {
                "type": "number"
              },
              "assumptions": {
                "type": "object",
                "properties": {
                  "conventionsVersion": {
                    "type": "string"
                  },
                  "lotRelief": {
                    "type": "string",
                    "enum": [
                      "fifo",
                      "lifo",
                      "highest-cost",
                      "specific-lot"
                    ]
                  },
                  "marketAsOf": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "currencyConversionsUsed": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "baseCurrency": {
                          "type": "string",
                          "pattern": "^[A-Z]{3}$"
                        },
                        "quoteCurrency": {
                          "type": "string",
                          "pattern": "^[A-Z]{3}$"
                        },
                        "quotePerBase": {
                          "type": "number",
                          "exclusiveMinimum": 0
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "baseCurrency",
                        "quoteCurrency",
                        "quotePerBase"
                      ]
                    }
                  },
                  "valuationConvention": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "conventionsVersion",
                  "lotRelief",
                  "marketAsOf",
                  "currencyConversionsUsed",
                  "valuationConvention"
                ]
              },
              "diagnostics": {
                "type": "object",
                "properties": {
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "accountCount": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "positionCount": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "warnings",
                  "accountCount",
                  "positionCount"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "asOf",
              "baseCurrency",
              "netAssetValue",
              "cash",
              "totalCashBaseCurrencyValue",
              "positions",
              "totalPositionsBaseCurrencyValue",
              "assumptions",
              "diagnostics"
            ]
          },
          "Contract": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "option",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "call",
                      "put"
                    ]
                  },
                  "strikePricePerUnit": {
                    "type": "number"
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "type",
                  "strikePricePerUnit",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "future",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "perpetual",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId"
                ]
              }
            ]
          },
          "Checks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "verdict": {
                  "type": "string",
                  "enum": [
                    "pass",
                    "fail",
                    "unverifiable",
                    "require-approval"
                  ]
                },
                "value": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "limit": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "detail": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "name",
                "verdict",
                "value",
                "limit",
                "detail"
              ]
            }
          },
          "Warnings": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "minLength": 1
                },
                "message": {
                  "type": "string"
                },
                "severity": {
                  "type": "string",
                  "enum": [
                    "info",
                    "warn",
                    "error"
                  ]
                },
                "context": {
                  "type": "object",
                  "additionalProperties": {}
                }
              },
              "additionalProperties": false,
              "required": [
                "code",
                "message",
                "severity"
              ]
            }
          },
          "CashDeposit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.deposit",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashWithdrawal": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.withdrawal",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.transfer",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency",
              "fromAccountId",
              "toAccountId"
            ]
          },
          "CashConversion": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.conversion",
                "type": "string"
              },
              "fromCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "toCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "toAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromCurrency",
              "toCurrency",
              "fromAmount",
              "toAmount"
            ]
          },
          "TradeFill": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "trade.fill",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "side": {
                "type": "string",
                "enum": [
                  "buy",
                  "sell"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              },
              "contractMultiplier": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlementStyle": {
                "type": "string",
                "enum": [
                  "cash-on-trade",
                  "variation-margin"
                ]
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "accruedInterest": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "side",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "LotSelections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "lotId": {
                  "type": "string",
                  "minLength": 1
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "lotId",
                "quantity"
              ]
            },
            "minItems": 1
          },
          "CostCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cost.charge",
                "type": "string"
              },
              "costType": {
                "type": "string",
                "enum": [
                  "commission",
                  "exchange-fee",
                  "regulatory-fee",
                  "slippage-adjustment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "costType",
              "amount",
              "currency"
            ]
          },
          "IncomeReceived": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "income.received",
                "type": "string"
              },
              "incomeType": {
                "type": "string",
                "enum": [
                  "dividend",
                  "coupon",
                  "interest",
                  "staking-reward",
                  "funding-receipt"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "incomeType",
              "amount",
              "currency"
            ]
          },
          "FinancingCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "financing.charge",
                "type": "string"
              },
              "financingType": {
                "type": "string",
                "enum": [
                  "margin-interest",
                  "borrow-charge",
                  "funding-payment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "financingType",
              "amount",
              "currency"
            ]
          },
          "CorporateSplit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.split",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesAfterSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "sharesBeforeSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "sharesAfterSplit",
              "sharesBeforeSplit"
            ]
          },
          "DerivativeExercise": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.exercise",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "Settlement": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "physical",
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "cash",
                    "type": "string"
                  },
                  "settlementPricePerUnit": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "settlementPricePerUnit"
                ]
              }
            ]
          },
          "DerivativeAssignment": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.assignment",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "DerivativeExpiration": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.expiration",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity"
            ]
          },
          "DerivativeMultiplierChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.multiplier-change",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "contractMultiplierAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "strikePricePerUnitAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "reason": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "contractMultiplierAfter"
            ]
          },
          "DerivativeVariationMargin": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.variation-margin",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settlementPricePerUnit": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "settlementPricePerUnit"
            ]
          },
          "DerivativeRoll": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.roll",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "closePricePerUnit": {
                "type": "number"
              },
              "openPricePerUnit": {
                "type": "number"
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId",
              "quantity",
              "closePricePerUnit",
              "openPricePerUnit"
            ]
          },
          "FixedIncomeRedemption": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "fixed-income.redemption",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "redemptionType": {
                "type": "string",
                "enum": [
                  "maturity",
                  "call",
                  "principal-paydown",
                  "sinking-fund"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "redemptionType",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "CorporateSymbolChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.symbol-change",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId"
            ]
          },
          "CorporateMerger": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.merger",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "cashPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId"
            ]
          },
          "CorporateSpinOff": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.spin-off",
                "type": "string"
              },
              "parentInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "childInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerParentShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "basisAllocationFraction": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "parentInstrumentId",
              "childInstrumentId",
              "sharesPerParentShare",
              "basisAllocationFraction"
            ]
          },
          "CorporateReturnOfCapital": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.return-of-capital",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "amountPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "amountPerShare",
              "currency"
            ]
          },
          "CorporateCashInLieu": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.cash-in-lieu",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "amount",
              "currency"
            ]
          },
          "PositionTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "position.transfer",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "fromAccountId",
              "toAccountId"
            ]
          }
        }
      },
      "totalfinance.trade.preflight.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.trade.preflight.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.trade.reconcile.input": {
        "type": "object",
        "properties": {
          "journalId": {
            "type": "string",
            "minLength": 1
          },
          "journal": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "type": "object",
                  "properties": {
                    "eventId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "journalId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "timestampMs": {
                      "type": "number",
                      "description": "Epoch milliseconds"
                    },
                    "orderId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "planHash": {
                      "type": "string",
                      "minLength": 1
                    },
                    "idempotencyKey": {
                      "type": "string",
                      "minLength": 1
                    },
                    "sourceId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "provenance": {
                      "$ref": "#/$defs/Provenance"
                    },
                    "eventType": {},
                    "detail": {}
                  },
                  "additionalProperties": false,
                  "required": [
                    "eventId",
                    "journalId",
                    "timestampMs",
                    "orderId",
                    "planHash",
                    "sourceId",
                    "provenance",
                    "eventType",
                    "detail"
                  ]
                },
                {
                  "anyOf": [
                    {
                      "properties": {
                        "eventType": {
                          "const": "proposed",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "preflighted",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "authorized",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "submitted",
                          "type": "string"
                        },
                        "detail": {
                          "type": "object",
                          "properties": {
                            "quantity": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            },
                            "fillId": {
                              "type": "string"
                            },
                            "pricePerUnit": {
                              "type": "number"
                            },
                            "reason": {
                              "type": "string"
                            },
                            "replacementOrderId": {
                              "type": "string"
                            },
                            "artifactHash": {
                              "type": "string"
                            },
                            "note": {
                              "type": "string"
                            },
                            "order": {
                              "allOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "instrumentId": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "side": {
                                      "type": "string",
                                      "enum": [
                                        "buy",
                                        "sell"
                                      ]
                                    },
                                    "timeInForce": {
                                      "type": "string",
                                      "enum": [
                                        "day",
                                        "gtc"
                                      ],
                                      "description": "Default: the paper execution policy’s day time-in-force"
                                    },
                                    "comboId": {
                                      "type": "string",
                                      "minLength": 1,
                                      "description": "The multi-leg order this is a leg of (B5)"
                                    },
                                    "orderId": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "quantity": {
                                      "type": "number",
                                      "exclusiveMinimum": 0,
                                      "description": "Units/contracts, strictly positive; side carries direction"
                                    },
                                    "plannedTimestampMs": {
                                      "type": "number",
                                      "description": "When the plan was made — never when a broker saw the order"
                                    },
                                    "submittedTimestampMs": {
                                      "type": "number",
                                      "description": "Epoch milliseconds"
                                    },
                                    "type": {},
                                    "limitPrice": {},
                                    "stopPrice": {}
                                  },
                                  "additionalProperties": false,
                                  "required": [
                                    "instrumentId",
                                    "side",
                                    "orderId",
                                    "quantity",
                                    "plannedTimestampMs",
                                    "type"
                                  ]
                                },
                                {
                                  "anyOf": [
                                    {
                                      "properties": {
                                        "type": {
                                          "const": "market",
                                          "type": "string"
                                        }
                                      },
                                      "not": {
                                        "anyOf": [
                                          {
                                            "required": [
                                              "limitPrice"
                                            ]
                                          },
                                          {
                                            "required": [
                                              "stopPrice"
                                            ]
                                          }
                                        ]
                                      }
                                    },
                                    {
                                      "properties": {
                                        "type": {
                                          "const": "market-on-open",
                                          "type": "string"
                                        }
                                      },
                                      "not": {
                                        "anyOf": [
                                          {
                                            "required": [
                                              "limitPrice"
                                            ]
                                          },
                                          {
                                            "required": [
                                              "stopPrice"
                                            ]
                                          }
                                        ]
                                      }
                                    },
                                    {
                                      "properties": {
                                        "type": {
                                          "const": "market-on-close",
                                          "type": "string"
                                        }
                                      },
                                      "not": {
                                        "anyOf": [
                                          {
                                            "required": [
                                              "limitPrice"
                                            ]
                                          },
                                          {
                                            "required": [
                                              "stopPrice"
                                            ]
                                          }
                                        ]
                                      }
                                    },
                                    {
                                      "properties": {
                                        "type": {
                                          "const": "limit",
                                          "type": "string"
                                        },
                                        "limitPrice": {
                                          "type": "number",
                                          "exclusiveMinimum": 0
                                        }
                                      },
                                      "required": [
                                        "limitPrice"
                                      ],
                                      "not": {
                                        "anyOf": [
                                          {
                                            "required": [
                                              "stopPrice"
                                            ]
                                          }
                                        ]
                                      }
                                    },
                                    {
                                      "properties": {
                                        "type": {
                                          "const": "stop",
                                          "type": "string"
                                        },
                                        "stopPrice": {
                                          "type": "number",
                                          "exclusiveMinimum": 0
                                        }
                                      },
                                      "required": [
                                        "stopPrice"
                                      ],
                                      "not": {
                                        "anyOf": [
                                          {
                                            "required": [
                                              "limitPrice"
                                            ]
                                          }
                                        ]
                                      }
                                    },
                                    {
                                      "properties": {
                                        "type": {
                                          "const": "stop-limit",
                                          "type": "string"
                                        },
                                        "limitPrice": {
                                          "type": "number",
                                          "exclusiveMinimum": 0
                                        },
                                        "stopPrice": {
                                          "type": "number",
                                          "exclusiveMinimum": 0
                                        }
                                      },
                                      "required": [
                                        "limitPrice",
                                        "stopPrice"
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            "instrument": {
                              "type": "object",
                              "properties": {
                                "currency": {
                                  "type": "string",
                                  "pattern": "^[A-Z]{3}$"
                                },
                                "contractMultiplier": {
                                  "type": "number",
                                  "exclusiveMinimum": 0
                                },
                                "contract": {
                                  "$ref": "#/$defs/Contract"
                                },
                                "settlementStyle": {
                                  "type": "string",
                                  "enum": [
                                    "cash-on-trade",
                                    "variation-margin"
                                  ]
                                },
                                "settlementLag": {
                                  "anyOf": [
                                    {
                                      "const": 0,
                                      "type": "number"
                                    },
                                    {
                                      "const": 1,
                                      "type": "number"
                                    },
                                    {
                                      "const": 2,
                                      "type": "number"
                                    }
                                  ],
                                  "description": "T+n 24-hour days in the paper broker; default 0"
                                }
                              },
                              "additionalProperties": false,
                              "required": [
                                "currency"
                              ]
                            },
                            "accountId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "baseCurrency": {
                              "type": "string",
                              "pattern": "^[A-Z]{3}$"
                            },
                            "executionPolicyHash": {
                              "type": "string",
                              "minLength": 1
                            },
                            "comboId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "netLimitPrice": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "quantity"
                          ]
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "acknowledged",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "partially-filled",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail2"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "filled",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail2"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "rejected",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "cancel-requested",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "cancelled",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "replaced",
                          "type": "string"
                        },
                        "detail": {
                          "type": "object",
                          "properties": {
                            "quantity": {
                              "type": "number"
                            },
                            "fillId": {
                              "type": "string"
                            },
                            "pricePerUnit": {
                              "type": "number"
                            },
                            "reason": {
                              "type": "string"
                            },
                            "replacementOrderId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "artifactHash": {
                              "type": "string"
                            },
                            "note": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "replacementOrderId"
                          ]
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "expired",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "reconciled",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "unresolved",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    }
                  ]
                }
              ]
            }
          },
          "ledger": {
            "anyOf": [
              {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "totalfinance.portfolio-ledger",
                        "type": "string"
                      },
                      "schemaVersion": {
                        "const": 1,
                        "type": "number"
                      },
                      "portfolioId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "baseCurrency": {
                        "type": "string",
                        "pattern": "^[A-Z]{3}$"
                      },
                      "lotRelief": {
                        "type": "string",
                        "enum": [
                          "fifo",
                          "lifo",
                          "highest-cost",
                          "specific-lot"
                        ]
                      },
                      "events": {
                        "type": "array",
                        "items": {
                          "$ref": "#/$defs/PortfolioEventEnvelope"
                        }
                      },
                      "provenance": {
                        "$ref": "#/$defs/Provenance"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "schemaVersion",
                      "baseCurrency",
                      "lotRelief",
                      "events"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "schemaVersion": {
                        "const": 1,
                        "type": "number"
                      },
                      "portfolioId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "baseCurrency": {
                        "type": "string",
                        "pattern": "^[A-Z]{3}$"
                      },
                      "lotRelief": {
                        "type": "string",
                        "enum": [
                          "fifo",
                          "lifo",
                          "highest-cost",
                          "specific-lot"
                        ]
                      },
                      "accounts": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "cashBalances": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "properties": {
                                  "totalAmount": {
                                    "type": "number"
                                  },
                                  "settlementSchedule": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "eventId": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "amount": {
                                          "type": "number"
                                        },
                                        "settleTimestampMs": {
                                          "type": "number",
                                          "description": "Epoch milliseconds"
                                        }
                                      },
                                      "additionalProperties": false,
                                      "required": [
                                        "eventId",
                                        "amount",
                                        "settleTimestampMs"
                                      ]
                                    }
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "totalAmount",
                                  "settlementSchedule"
                                ]
                              }
                            },
                            "positions": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "properties": {
                                  "instrumentId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "currency": {
                                    "type": "string",
                                    "pattern": "^[A-Z]{3}$"
                                  },
                                  "contractMultiplier": {
                                    "type": "number",
                                    "exclusiveMinimum": 0
                                  },
                                  "settlementStyle": {
                                    "type": "string",
                                    "enum": [
                                      "cash-on-trade",
                                      "variation-margin"
                                    ]
                                  },
                                  "contract": {
                                    "$ref": "#/$defs/Contract"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "lots": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "lotId": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "openedByEventId": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "openedTimestampMs": {
                                          "type": "number",
                                          "description": "Epoch milliseconds"
                                        },
                                        "quantity": {
                                          "type": "number"
                                        },
                                        "costBasisPerUnit": {
                                          "type": "number"
                                        }
                                      },
                                      "additionalProperties": false,
                                      "required": [
                                        "lotId",
                                        "openedByEventId",
                                        "openedTimestampMs",
                                        "quantity",
                                        "costBasisPerUnit"
                                      ]
                                    }
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "instrumentId",
                                  "currency",
                                  "contractMultiplier",
                                  "settlementStyle",
                                  "quantity",
                                  "lots"
                                ]
                              }
                            },
                            "realizedPnl": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "incomeReceived": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "transactionCosts": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "financingCosts": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "realizedPnlByInstrument": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "number"
                                }
                              }
                            },
                            "incomeByInstrument": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "number"
                                }
                              }
                            },
                            "transactionCostsByInstrument": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "number"
                                }
                              }
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "cashBalances",
                            "positions",
                            "realizedPnl",
                            "incomeReceived",
                            "transactionCosts",
                            "financingCosts",
                            "realizedPnlByInstrument",
                            "incomeByInstrument",
                            "transactionCostsByInstrument"
                          ]
                        }
                      },
                      "appliedEvents": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      "eventCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "lastEffectiveTimestampMs": {
                        "anyOf": [
                          {
                            "type": "number",
                            "description": "Epoch milliseconds"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "lotSequence": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "fillEffects": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "accountId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "instrumentId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "currency": {
                              "type": "string",
                              "pattern": "^[A-Z]{3}$"
                            },
                            "openedLotIds": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "relievedQuantity": {
                              "type": "number"
                            },
                            "realizedPnl": {
                              "type": "number"
                            },
                            "cashDelta": {
                              "type": "number"
                            },
                            "accruedInterest": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "accountId",
                            "instrumentId",
                            "currency",
                            "openedLotIds",
                            "relievedQuantity",
                            "realizedPnl",
                            "cashDelta",
                            "accruedInterest"
                          ]
                        }
                      },
                      "reversals": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      "accountMigrations": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "eventId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "fromAccountId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "toAccountId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "effectiveTimestampMs": {
                              "type": "number",
                              "description": "Epoch milliseconds"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "eventId",
                            "fromAccountId",
                            "toAccountId",
                            "effectiveTimestampMs"
                          ]
                        }
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "schemaVersion",
                      "baseCurrency",
                      "lotRelief",
                      "accounts",
                      "appliedEvents",
                      "eventCount",
                      "lastEffectiveTimestampMs",
                      "lotSequence",
                      "fillEffects",
                      "reversals",
                      "accountMigrations"
                    ]
                  }
                ]
              },
              {
                "type": "string",
                "pattern": "^totalfinance:\\/\\/portfolios\\/"
              }
            ]
          },
          "sourceId": {
            "type": "string",
            "minLength": 1
          },
          "fills": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/Fill"
            }
          },
          "external": {
            "type": "object",
            "properties": {
              "asOf": {
                "anyOf": [
                  {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              "accounts": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "properties": {
                    "cash": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "object",
                        "properties": {
                          "total": {
                            "type": "number"
                          },
                          "settled": {
                            "type": "number"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "total"
                        ]
                      }
                    },
                    "positions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "instrumentId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "quantity": {
                            "type": "number"
                          },
                          "currency": {
                            "type": "string",
                            "pattern": "^[A-Z]{3}$"
                          },
                          "costBasis": {
                            "type": "number"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "instrumentId",
                          "quantity"
                        ]
                      }
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "cash",
                    "positions"
                  ]
                }
              },
              "source": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "asOf",
              "accounts"
            ]
          },
          "asOf": {
            "type": "number"
          },
          "tolerance": {
            "type": "object",
            "properties": {
              "quantity": {
                "type": "number",
                "minimum": 0
              },
              "cashAmount": {
                "type": "number",
                "minimum": 0
              },
              "costBasis": {
                "type": "number",
                "minimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "quantity",
              "cashAmount"
            ]
          },
          "planHash": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "ledger",
          "sourceId",
          "fills",
          "asOf",
          "tolerance"
        ],
        "oneOf": [
          {
            "required": [
              "journalId"
            ],
            "not": {
              "required": [
                "journal"
              ]
            }
          },
          {
            "required": [
              "journal"
            ],
            "not": {
              "required": [
                "journalId"
              ]
            }
          }
        ],
        "$id": "https://totalfinance.dev/schemas/trade.reconcile.input",
        "$defs": {
          "PortfolioEventEnvelope": {
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "eventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "schemaVersion": {
                    "const": 1,
                    "type": "number"
                  },
                  "sourceId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "accountId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "effectiveTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "recordedTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "correlationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "causationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "reversesEventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "provenance": {
                    "$ref": "#/$defs/Provenance"
                  },
                  "eventType": {},
                  "event": {}
                },
                "additionalProperties": false,
                "required": [
                  "eventId",
                  "schemaVersion",
                  "sourceId",
                  "accountId",
                  "effectiveTimestampMs",
                  "recordedTimestampMs",
                  "provenance",
                  "eventType",
                  "event"
                ]
              },
              {
                "anyOf": [
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.deposit",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashDeposit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.withdrawal",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashWithdrawal"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.conversion",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashConversion"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "trade.fill",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/TradeFill"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cost.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CostCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "income.received",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/IncomeReceived"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "financing.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FinancingCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.split",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSplit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.exercise",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExercise"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.assignment",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeAssignment"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.expiration",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExpiration"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.multiplier-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeMultiplierChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.variation-margin",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeVariationMargin"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.roll",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeRoll"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "fixed-income.redemption",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FixedIncomeRedemption"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.symbol-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSymbolChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.merger",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateMerger"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.spin-off",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSpinOff"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.return-of-capital",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateReturnOfCapital"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.cash-in-lieu",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateCashInLieu"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "position.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/PositionTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.reversal",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.reversal",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.correction",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.correction",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "replacement": {
                            "anyOf": [
                              {
                                "$ref": "#/$defs/CashDeposit"
                              },
                              {
                                "$ref": "#/$defs/CashWithdrawal"
                              },
                              {
                                "$ref": "#/$defs/CashTransfer"
                              },
                              {
                                "$ref": "#/$defs/CashConversion"
                              },
                              {
                                "$ref": "#/$defs/TradeFill"
                              },
                              {
                                "$ref": "#/$defs/CostCharge"
                              },
                              {
                                "$ref": "#/$defs/IncomeReceived"
                              },
                              {
                                "$ref": "#/$defs/FinancingCharge"
                              },
                              {
                                "$ref": "#/$defs/CorporateSplit"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExercise"
                              },
                              {
                                "$ref": "#/$defs/DerivativeAssignment"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExpiration"
                              },
                              {
                                "$ref": "#/$defs/DerivativeMultiplierChange"
                              },
                              {
                                "$ref": "#/$defs/DerivativeVariationMargin"
                              },
                              {
                                "$ref": "#/$defs/DerivativeRoll"
                              },
                              {
                                "$ref": "#/$defs/FixedIncomeRedemption"
                              },
                              {
                                "$ref": "#/$defs/CorporateSymbolChange"
                              },
                              {
                                "$ref": "#/$defs/CorporateMerger"
                              },
                              {
                                "$ref": "#/$defs/CorporateSpinOff"
                              },
                              {
                                "$ref": "#/$defs/CorporateReturnOfCapital"
                              },
                              {
                                "$ref": "#/$defs/CorporateCashInLieu"
                              },
                              {
                                "$ref": "#/$defs/PositionTransfer"
                              }
                            ]
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original",
                          "replacement"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.account-migration",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.account-migration",
                            "type": "string"
                          },
                          "fromAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "toAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "fromAccountId",
                          "toAccountId"
                        ]
                      }
                    }
                  }
                ]
              }
            ]
          },
          "Provenance": {
            "type": "object",
            "properties": {
              "provider": {
                "type": "string"
              },
              "dataset": {
                "type": "string"
              },
              "asOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "receivedAt": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "sourceVersion": {
                "type": "string"
              },
              "requestId": {
                "type": "string"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string",
                      "minLength": 1
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              }
            },
            "additionalProperties": false
          },
          "Detail": {
            "type": "object",
            "properties": {
              "quantity": {
                "type": "number"
              },
              "fillId": {
                "type": "string"
              },
              "pricePerUnit": {
                "type": "number"
              },
              "reason": {
                "type": "string"
              },
              "replacementOrderId": {
                "type": "string"
              },
              "artifactHash": {
                "type": "string"
              },
              "note": {
                "type": "string"
              }
            },
            "additionalProperties": false
          },
          "Contract": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "option",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "call",
                      "put"
                    ]
                  },
                  "strikePricePerUnit": {
                    "type": "number"
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "type",
                  "strikePricePerUnit",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "future",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "perpetual",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId"
                ]
              }
            ]
          },
          "Detail2": {
            "type": "object",
            "properties": {
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "fillId": {
                "type": "string",
                "minLength": 1
              },
              "pricePerUnit": {
                "type": "number"
              },
              "reason": {
                "type": "string"
              },
              "replacementOrderId": {
                "type": "string"
              },
              "artifactHash": {
                "type": "string"
              },
              "note": {
                "type": "string"
              },
              "observationTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "fill": {
                "$ref": "#/$defs/Fill"
              }
            },
            "additionalProperties": false,
            "required": [
              "quantity",
              "fillId"
            ]
          },
          "Fill": {
            "type": "object",
            "properties": {
              "fillId": {
                "type": "string",
                "minLength": 1
              },
              "accountId": {
                "type": "string",
                "minLength": 1
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "side": {
                "type": "string",
                "enum": [
                  "buy",
                  "sell"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "filledTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "contractMultiplier": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlementStyle": {
                "type": "string",
                "enum": [
                  "cash-on-trade",
                  "variation-margin"
                ]
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "accruedInterest": {
                "type": "number"
              },
              "executionPriceAdjustment": {
                "type": "number",
                "minimum": 0
              },
              "costs": {
                "type": "object",
                "properties": {
                  "commission": {
                    "type": "number",
                    "minimum": 0
                  },
                  "exchangeFees": {
                    "type": "number",
                    "minimum": 0
                  },
                  "regulatoryFees": {
                    "type": "number",
                    "minimum": 0
                  },
                  "slippageAdjustment": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "additionalProperties": false
              },
              "orderId": {
                "type": "string",
                "minLength": 1
              },
              "venue": {
                "type": "string"
              },
              "liquidity": {
                "type": "string",
                "enum": [
                  "maker",
                  "taker",
                  "unknown"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "fillId",
              "accountId",
              "instrumentId",
              "side",
              "quantity",
              "pricePerUnit",
              "currency",
              "filledTimestampMs"
            ]
          },
          "CashDeposit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.deposit",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashWithdrawal": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.withdrawal",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.transfer",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency",
              "fromAccountId",
              "toAccountId"
            ]
          },
          "CashConversion": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.conversion",
                "type": "string"
              },
              "fromCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "toCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "toAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromCurrency",
              "toCurrency",
              "fromAmount",
              "toAmount"
            ]
          },
          "TradeFill": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "trade.fill",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "side": {
                "type": "string",
                "enum": [
                  "buy",
                  "sell"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              },
              "contractMultiplier": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlementStyle": {
                "type": "string",
                "enum": [
                  "cash-on-trade",
                  "variation-margin"
                ]
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "accruedInterest": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "side",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "LotSelections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "lotId": {
                  "type": "string",
                  "minLength": 1
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "lotId",
                "quantity"
              ]
            },
            "minItems": 1
          },
          "CostCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cost.charge",
                "type": "string"
              },
              "costType": {
                "type": "string",
                "enum": [
                  "commission",
                  "exchange-fee",
                  "regulatory-fee",
                  "slippage-adjustment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "costType",
              "amount",
              "currency"
            ]
          },
          "IncomeReceived": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "income.received",
                "type": "string"
              },
              "incomeType": {
                "type": "string",
                "enum": [
                  "dividend",
                  "coupon",
                  "interest",
                  "staking-reward",
                  "funding-receipt"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "incomeType",
              "amount",
              "currency"
            ]
          },
          "FinancingCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "financing.charge",
                "type": "string"
              },
              "financingType": {
                "type": "string",
                "enum": [
                  "margin-interest",
                  "borrow-charge",
                  "funding-payment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "financingType",
              "amount",
              "currency"
            ]
          },
          "CorporateSplit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.split",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesAfterSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "sharesBeforeSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "sharesAfterSplit",
              "sharesBeforeSplit"
            ]
          },
          "DerivativeExercise": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.exercise",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "Settlement": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "physical",
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "cash",
                    "type": "string"
                  },
                  "settlementPricePerUnit": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "settlementPricePerUnit"
                ]
              }
            ]
          },
          "DerivativeAssignment": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.assignment",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "DerivativeExpiration": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.expiration",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity"
            ]
          },
          "DerivativeMultiplierChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.multiplier-change",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "contractMultiplierAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "strikePricePerUnitAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "reason": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "contractMultiplierAfter"
            ]
          },
          "DerivativeVariationMargin": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.variation-margin",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settlementPricePerUnit": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "settlementPricePerUnit"
            ]
          },
          "DerivativeRoll": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.roll",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "closePricePerUnit": {
                "type": "number"
              },
              "openPricePerUnit": {
                "type": "number"
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId",
              "quantity",
              "closePricePerUnit",
              "openPricePerUnit"
            ]
          },
          "FixedIncomeRedemption": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "fixed-income.redemption",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "redemptionType": {
                "type": "string",
                "enum": [
                  "maturity",
                  "call",
                  "principal-paydown",
                  "sinking-fund"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "redemptionType",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "CorporateSymbolChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.symbol-change",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId"
            ]
          },
          "CorporateMerger": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.merger",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "cashPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId"
            ]
          },
          "CorporateSpinOff": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.spin-off",
                "type": "string"
              },
              "parentInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "childInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerParentShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "basisAllocationFraction": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "parentInstrumentId",
              "childInstrumentId",
              "sharesPerParentShare",
              "basisAllocationFraction"
            ]
          },
          "CorporateReturnOfCapital": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.return-of-capital",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "amountPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "amountPerShare",
              "currency"
            ]
          },
          "CorporateCashInLieu": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.cash-in-lieu",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "amount",
              "currency"
            ]
          },
          "PositionTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "position.transfer",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "fromAccountId",
              "toAccountId"
            ]
          }
        }
      },
      "totalfinance.trade.reconcile.output": {
        "type": "object",
        "properties": {
          "kind": {
            "const": "totalfinance.reconciliation-report",
            "type": "string"
          },
          "schemaVersion": {
            "const": 1,
            "type": "number"
          },
          "asOf": {
            "type": "number",
            "description": "Epoch milliseconds"
          },
          "planHash": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "journalId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "sourceId": {
            "type": "string",
            "minLength": 1
          },
          "reconciled": {
            "type": "boolean"
          },
          "orders": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "orderId": {
                  "type": "string",
                  "minLength": 1
                },
                "planHash": {
                  "type": "string",
                  "minLength": 1
                },
                "state": {
                  "type": "string",
                  "enum": [
                    "submitted",
                    "acknowledged",
                    "partially-filled",
                    "filled",
                    "cancelled",
                    "rejected",
                    "expired",
                    "unresolved"
                  ]
                },
                "submittedQuantity": {
                  "type": "number",
                  "minimum": 0
                },
                "filledQuantity": {
                  "type": "number",
                  "minimum": 0
                },
                "remainingQuantity": {
                  "type": "number",
                  "minimum": 0
                },
                "averageFillPrice": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "fillIds": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "lateFillIds": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "lastEventId": {
                  "type": "string",
                  "minLength": 1
                },
                "lastTimestampMs": {
                  "type": "number",
                  "description": "Epoch milliseconds"
                },
                "terminal": {
                  "type": "boolean"
                },
                "cancelRequested": {
                  "type": "boolean"
                },
                "reason": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "replacedBy": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "reconciledEventId": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "additionalProperties": false,
              "required": [
                "orderId",
                "planHash",
                "state",
                "submittedQuantity",
                "filledQuantity",
                "remainingQuantity",
                "averageFillPrice",
                "fillIds",
                "lateFillIds",
                "lastEventId",
                "lastTimestampMs",
                "terminal",
                "cancelRequested",
                "reason",
                "replacedBy",
                "reconciledEventId"
              ]
            }
          },
          "orderChecks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "orderId": {
                  "type": "string",
                  "minLength": 1
                },
                "state": {
                  "type": "string",
                  "enum": [
                    "submitted",
                    "acknowledged",
                    "partially-filled",
                    "filled",
                    "cancelled",
                    "rejected",
                    "expired",
                    "unresolved"
                  ]
                },
                "journaledQuantity": {
                  "type": "number"
                },
                "fillQuantity": {
                  "type": "number"
                },
                "difference": {
                  "type": "number"
                },
                "withinTolerance": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false,
              "required": [
                "orderId",
                "state",
                "journaledQuantity",
                "fillQuantity",
                "difference",
                "withinTolerance"
              ]
            }
          },
          "fills": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "fillId": {
                  "type": "string",
                  "minLength": 1
                },
                "orderId": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "quantity": {
                  "type": "number"
                },
                "journaled": {
                  "type": "boolean"
                },
                "inLedger": {
                  "type": "boolean"
                },
                "ledgerKey": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "fillId",
                "orderId",
                "quantity",
                "journaled",
                "inLedger",
                "ledgerKey"
              ]
            }
          },
          "journaledNotInLedger": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ledgerNotJournaled": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "unresolved": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "orderId": {
                  "type": "string",
                  "minLength": 1
                },
                "reason": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "orderId",
                "reason"
              ]
            }
          },
          "portfolio": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "asOf": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "baseCurrency": {
                    "type": "string",
                    "pattern": "^[A-Z]{3}$"
                  },
                  "reconciled": {
                    "type": "boolean"
                  },
                  "accounts": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "accountId": {
                          "type": "string",
                          "minLength": 1
                        },
                        "presentInLedger": {
                          "type": "boolean"
                        },
                        "presentInExternal": {
                          "type": "boolean"
                        },
                        "cash": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "currency": {
                                "type": "string",
                                "pattern": "^[A-Z]{3}$"
                              },
                              "ledgerTotal": {
                                "type": "number"
                              },
                              "ledgerSettled": {
                                "type": "number"
                              },
                              "ledgerUnsettledReceivable": {
                                "type": "number"
                              },
                              "ledgerUnsettledPayable": {
                                "type": "number"
                              },
                              "externalTotal": {
                                "type": "number"
                              },
                              "externalSettled": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "totalDifference": {
                                "type": "number"
                              },
                              "settledDifference": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "withinTolerance": {
                                "type": "boolean"
                              },
                              "explanation": {
                                "$ref": "#/$defs/Explanation"
                              }
                            },
                            "additionalProperties": false,
                            "required": [
                              "currency",
                              "ledgerTotal",
                              "ledgerSettled",
                              "ledgerUnsettledReceivable",
                              "ledgerUnsettledPayable",
                              "externalTotal",
                              "externalSettled",
                              "totalDifference",
                              "settledDifference",
                              "withinTolerance"
                            ]
                          }
                        },
                        "positions": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "instrumentId": {
                                "type": "string",
                                "minLength": 1
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "matched",
                                  "quantity-difference",
                                  "missing-in-external",
                                  "extra-in-external"
                                ]
                              },
                              "ledgerQuantity": {
                                "type": "number"
                              },
                              "externalQuantity": {
                                "type": "number"
                              },
                              "quantityDifference": {
                                "type": "number"
                              },
                              "withinTolerance": {
                                "type": "boolean"
                              },
                              "currency": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "currencyMismatch": {
                                "type": "object",
                                "properties": {
                                  "ledger": {
                                    "type": "string"
                                  },
                                  "external": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "ledger",
                                  "external"
                                ]
                              },
                              "costBasis": {
                                "type": "object",
                                "properties": {
                                  "ledger": {
                                    "type": "number"
                                  },
                                  "external": {
                                    "type": "number"
                                  },
                                  "difference": {
                                    "type": "number"
                                  },
                                  "withinTolerance": {
                                    "type": "boolean"
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "ledger",
                                  "external",
                                  "difference",
                                  "withinTolerance"
                                ]
                              },
                              "explanation": {
                                "$ref": "#/$defs/Explanation"
                              }
                            },
                            "additionalProperties": false,
                            "required": [
                              "instrumentId",
                              "kind",
                              "ledgerQuantity",
                              "externalQuantity",
                              "quantityDifference",
                              "withinTolerance",
                              "currency"
                            ]
                          }
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "accountId",
                        "presentInLedger",
                        "presentInExternal",
                        "cash",
                        "positions"
                      ]
                    }
                  },
                  "differenceCount": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "explainedCount": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "suggestedCorrections": {
                    "type": "array",
                    "items": {
                      "$ref": "#/$defs/PortfolioEventEnvelope"
                    }
                  },
                  "undraftable": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "accountId": {
                          "type": "string",
                          "minLength": 1
                        },
                        "subject": {
                          "type": "string"
                        },
                        "reason": {
                          "type": "string"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "accountId",
                        "subject",
                        "reason"
                      ]
                    }
                  },
                  "assumptions": {
                    "type": "object",
                    "properties": {
                      "conventionsVersion": {
                        "type": "string"
                      },
                      "lotRelief": {
                        "type": "string",
                        "enum": [
                          "fifo",
                          "lifo",
                          "highest-cost",
                          "specific-lot"
                        ]
                      },
                      "tolerance": {
                        "$ref": "#/$defs/Tolerance"
                      },
                      "comparisonConvention": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "conventionsVersion",
                      "lotRelief",
                      "tolerance",
                      "comparisonConvention"
                    ]
                  },
                  "diagnostics": {
                    "type": "object",
                    "properties": {
                      "warnings": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "ledgerAccountCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "externalAccountCount": {
                        "type": "integer",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "warnings",
                      "ledgerAccountCount",
                      "externalAccountCount"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "asOf",
                  "baseCurrency",
                  "reconciled",
                  "accounts",
                  "differenceCount",
                  "explainedCount",
                  "suggestedCorrections",
                  "undraftable",
                  "assumptions",
                  "diagnostics"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "assumptions": {
            "type": "object",
            "properties": {
              "conventionsVersion": {
                "type": "string"
              },
              "tolerance": {
                "$ref": "#/$defs/Tolerance"
              },
              "matchConvention": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "conventionsVersion",
              "tolerance",
              "matchConvention"
            ]
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "engine": {
                "const": "trade-reconciliation",
                "type": "string"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "orderCount": {
                "type": "integer",
                "minimum": 0
              },
              "openCount": {
                "type": "integer",
                "minimum": 0
              },
              "fillCount": {
                "type": "integer",
                "minimum": 0
              },
              "ledgerFillCount": {
                "type": "integer",
                "minimum": 0
              },
              "unresolvedCount": {
                "type": "integer",
                "minimum": 0
              },
              "differenceCount": {
                "type": "integer",
                "minimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "engine",
              "warnings",
              "orderCount",
              "openCount",
              "fillCount",
              "ledgerFillCount",
              "unresolvedCount",
              "differenceCount"
            ]
          },
          "contentHash": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": false,
        "required": [
          "kind",
          "schemaVersion",
          "asOf",
          "planHash",
          "journalId",
          "sourceId",
          "reconciled",
          "orders",
          "orderChecks",
          "fills",
          "journaledNotInLedger",
          "ledgerNotJournaled",
          "unresolved",
          "portfolio",
          "assumptions",
          "diagnostics",
          "contentHash"
        ],
        "$id": "https://totalfinance.dev/schemas/trade.reconcile.output",
        "$defs": {
          "PortfolioEventEnvelope": {
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "eventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "schemaVersion": {
                    "const": 1,
                    "type": "number"
                  },
                  "sourceId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "accountId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "effectiveTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "recordedTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "correlationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "causationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "reversesEventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "provenance": {
                    "type": "object",
                    "properties": {
                      "provider": {
                        "type": "string"
                      },
                      "dataset": {
                        "type": "string"
                      },
                      "asOf": {
                        "type": "number",
                        "description": "Epoch milliseconds"
                      },
                      "receivedAt": {
                        "type": "number",
                        "description": "Epoch milliseconds"
                      },
                      "sourceVersion": {
                        "type": "string"
                      },
                      "requestId": {
                        "type": "string"
                      },
                      "warnings": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "minLength": 1
                            },
                            "message": {
                              "type": "string"
                            },
                            "severity": {
                              "type": "string",
                              "enum": [
                                "info",
                                "warn",
                                "error"
                              ]
                            },
                            "context": {
                              "type": "object",
                              "additionalProperties": {}
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "code",
                            "message",
                            "severity"
                          ]
                        }
                      }
                    },
                    "additionalProperties": false
                  },
                  "eventType": {},
                  "event": {}
                },
                "additionalProperties": false,
                "required": [
                  "eventId",
                  "schemaVersion",
                  "sourceId",
                  "accountId",
                  "effectiveTimestampMs",
                  "recordedTimestampMs",
                  "provenance",
                  "eventType",
                  "event"
                ]
              },
              {
                "anyOf": [
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.deposit",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashDeposit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.withdrawal",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashWithdrawal"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.conversion",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashConversion"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "trade.fill",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/TradeFill"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cost.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CostCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "income.received",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/IncomeReceived"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "financing.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FinancingCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.split",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSplit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.exercise",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExercise"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.assignment",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeAssignment"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.expiration",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExpiration"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.multiplier-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeMultiplierChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.variation-margin",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeVariationMargin"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.roll",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeRoll"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "fixed-income.redemption",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FixedIncomeRedemption"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.symbol-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSymbolChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.merger",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateMerger"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.spin-off",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSpinOff"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.return-of-capital",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateReturnOfCapital"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.cash-in-lieu",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateCashInLieu"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "position.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/PositionTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.reversal",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.reversal",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.correction",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.correction",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "replacement": {
                            "anyOf": [
                              {
                                "$ref": "#/$defs/CashDeposit"
                              },
                              {
                                "$ref": "#/$defs/CashWithdrawal"
                              },
                              {
                                "$ref": "#/$defs/CashTransfer"
                              },
                              {
                                "$ref": "#/$defs/CashConversion"
                              },
                              {
                                "$ref": "#/$defs/TradeFill"
                              },
                              {
                                "$ref": "#/$defs/CostCharge"
                              },
                              {
                                "$ref": "#/$defs/IncomeReceived"
                              },
                              {
                                "$ref": "#/$defs/FinancingCharge"
                              },
                              {
                                "$ref": "#/$defs/CorporateSplit"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExercise"
                              },
                              {
                                "$ref": "#/$defs/DerivativeAssignment"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExpiration"
                              },
                              {
                                "$ref": "#/$defs/DerivativeMultiplierChange"
                              },
                              {
                                "$ref": "#/$defs/DerivativeVariationMargin"
                              },
                              {
                                "$ref": "#/$defs/DerivativeRoll"
                              },
                              {
                                "$ref": "#/$defs/FixedIncomeRedemption"
                              },
                              {
                                "$ref": "#/$defs/CorporateSymbolChange"
                              },
                              {
                                "$ref": "#/$defs/CorporateMerger"
                              },
                              {
                                "$ref": "#/$defs/CorporateSpinOff"
                              },
                              {
                                "$ref": "#/$defs/CorporateReturnOfCapital"
                              },
                              {
                                "$ref": "#/$defs/CorporateCashInLieu"
                              },
                              {
                                "$ref": "#/$defs/PositionTransfer"
                              }
                            ]
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original",
                          "replacement"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.account-migration",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.account-migration",
                            "type": "string"
                          },
                          "fromAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "toAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "fromAccountId",
                          "toAccountId"
                        ]
                      }
                    }
                  }
                ]
              }
            ]
          },
          "Explanation": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "pending-settlement",
                    "type": "string"
                  },
                  "detail": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "detail"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "corporate-action-candidate",
                    "type": "string"
                  },
                  "detail": {
                    "type": "string"
                  },
                  "ratio": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "detail",
                  "ratio"
                ]
              }
            ]
          },
          "Tolerance": {
            "type": "object",
            "properties": {
              "quantity": {
                "type": "number",
                "minimum": 0
              },
              "cashAmount": {
                "type": "number",
                "minimum": 0
              },
              "costBasis": {
                "type": "number",
                "minimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "quantity",
              "cashAmount",
              "costBasis"
            ]
          },
          "CashDeposit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.deposit",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashWithdrawal": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.withdrawal",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.transfer",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency",
              "fromAccountId",
              "toAccountId"
            ]
          },
          "CashConversion": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.conversion",
                "type": "string"
              },
              "fromCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "toCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "toAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromCurrency",
              "toCurrency",
              "fromAmount",
              "toAmount"
            ]
          },
          "TradeFill": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "trade.fill",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "side": {
                "type": "string",
                "enum": [
                  "buy",
                  "sell"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              },
              "contractMultiplier": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlementStyle": {
                "type": "string",
                "enum": [
                  "cash-on-trade",
                  "variation-margin"
                ]
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "accruedInterest": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "side",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "LotSelections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "lotId": {
                  "type": "string",
                  "minLength": 1
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "lotId",
                "quantity"
              ]
            },
            "minItems": 1
          },
          "Contract": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "option",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "call",
                      "put"
                    ]
                  },
                  "strikePricePerUnit": {
                    "type": "number"
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "type",
                  "strikePricePerUnit",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "future",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "perpetual",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId"
                ]
              }
            ]
          },
          "CostCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cost.charge",
                "type": "string"
              },
              "costType": {
                "type": "string",
                "enum": [
                  "commission",
                  "exchange-fee",
                  "regulatory-fee",
                  "slippage-adjustment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "costType",
              "amount",
              "currency"
            ]
          },
          "IncomeReceived": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "income.received",
                "type": "string"
              },
              "incomeType": {
                "type": "string",
                "enum": [
                  "dividend",
                  "coupon",
                  "interest",
                  "staking-reward",
                  "funding-receipt"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "incomeType",
              "amount",
              "currency"
            ]
          },
          "FinancingCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "financing.charge",
                "type": "string"
              },
              "financingType": {
                "type": "string",
                "enum": [
                  "margin-interest",
                  "borrow-charge",
                  "funding-payment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "financingType",
              "amount",
              "currency"
            ]
          },
          "CorporateSplit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.split",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesAfterSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "sharesBeforeSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "sharesAfterSplit",
              "sharesBeforeSplit"
            ]
          },
          "DerivativeExercise": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.exercise",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "Settlement": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "physical",
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "cash",
                    "type": "string"
                  },
                  "settlementPricePerUnit": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "settlementPricePerUnit"
                ]
              }
            ]
          },
          "DerivativeAssignment": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.assignment",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "DerivativeExpiration": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.expiration",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity"
            ]
          },
          "DerivativeMultiplierChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.multiplier-change",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "contractMultiplierAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "strikePricePerUnitAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "reason": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "contractMultiplierAfter"
            ]
          },
          "DerivativeVariationMargin": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.variation-margin",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settlementPricePerUnit": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "settlementPricePerUnit"
            ]
          },
          "DerivativeRoll": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.roll",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "closePricePerUnit": {
                "type": "number"
              },
              "openPricePerUnit": {
                "type": "number"
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId",
              "quantity",
              "closePricePerUnit",
              "openPricePerUnit"
            ]
          },
          "FixedIncomeRedemption": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "fixed-income.redemption",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "redemptionType": {
                "type": "string",
                "enum": [
                  "maturity",
                  "call",
                  "principal-paydown",
                  "sinking-fund"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "redemptionType",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "CorporateSymbolChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.symbol-change",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId"
            ]
          },
          "CorporateMerger": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.merger",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "cashPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId"
            ]
          },
          "CorporateSpinOff": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.spin-off",
                "type": "string"
              },
              "parentInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "childInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerParentShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "basisAllocationFraction": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "parentInstrumentId",
              "childInstrumentId",
              "sharesPerParentShare",
              "basisAllocationFraction"
            ]
          },
          "CorporateReturnOfCapital": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.return-of-capital",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "amountPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "amountPerShare",
              "currency"
            ]
          },
          "CorporateCashInLieu": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.cash-in-lieu",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "amount",
              "currency"
            ]
          },
          "PositionTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "position.transfer",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "fromAccountId",
              "toAccountId"
            ]
          }
        }
      },
      "totalfinance.trade.reconcile.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.trade.reconcile.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.trade.submit.input": {
        "type": "object",
        "properties": {
          "plan": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.execution-plan",
                "type": "string"
              },
              "schemaVersion": {
                "const": 1,
                "type": "number"
              },
              "accountId": {
                "type": "string",
                "minLength": 1
              },
              "asOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "baseCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "portfolioId": {
                "type": "string",
                "minLength": 1
              },
              "orders": {
                "type": "array",
                "items": {
                  "$ref": "#/$defs/Orders"
                },
                "minItems": 1,
                "maxItems": 1000
              },
              "combos": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "comboId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "orderIds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 1
                      },
                      "minItems": 2,
                      "description": "The legs, in plan order (at least two)"
                    },
                    "netLimitPrice": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "comboId",
                    "orderIds"
                  ]
                }
              },
              "trades": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "accountId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "instrumentId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "side": {
                      "type": "string",
                      "enum": [
                        "buy",
                        "sell"
                      ]
                    },
                    "quantity": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "currency": {
                      "type": "string",
                      "pattern": "^[A-Z]{3}$"
                    },
                    "referencePricePerUnit": {
                      "type": "number"
                    },
                    "contractMultiplier": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "estimatedNotional": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "accountId",
                    "instrumentId",
                    "side",
                    "quantity",
                    "currency",
                    "referencePricePerUnit",
                    "contractMultiplier",
                    "estimatedNotional"
                  ]
                }
              },
              "source": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "intent",
                        "type": "string"
                      },
                      "intentHash": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "intentHash"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "rebalance-proposal",
                        "type": "string"
                      },
                      "planHash": {
                        "type": "string",
                        "minLength": 1
                      },
                      "policyContentHash": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "planHash",
                      "policyContentHash"
                    ]
                  }
                ]
              },
              "rationale": {
                "type": "string"
              },
              "evidence": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "contentHash": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "accountId",
              "asOf",
              "baseCurrency",
              "orders",
              "combos",
              "trades",
              "source",
              "evidence",
              "contentHash"
            ]
          },
          "grant": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.authorization-grant",
                "type": "string"
              },
              "schemaVersion": {
                "const": 1,
                "type": "number"
              },
              "grantId": {
                "type": "string",
                "minLength": 1
              },
              "planHash": {
                "type": "string",
                "minLength": 1
              },
              "preflightHash": {
                "type": "string",
                "minLength": 1
              },
              "portfolioHash": {
                "type": "string",
                "minLength": 1
              },
              "marketHash": {
                "type": "string",
                "minLength": 1
              },
              "marketAsOf": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "marketMaximumAgeMs": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "mode": {
                "const": "paper",
                "type": "string"
              },
              "accountId": {
                "type": "string",
                "minLength": 1
              },
              "baseCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "orderIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "comboIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "variance": {
                "type": "object",
                "properties": {
                  "maximumQuantityRatio": {
                    "type": "number",
                    "minimum": 0
                  },
                  "maximumNotionalRatio": {
                    "type": "number",
                    "minimum": 0
                  },
                  "maximumSlippageBps": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "maximumQuantityRatio",
                  "maximumNotionalRatio",
                  "maximumSlippageBps"
                ]
              },
              "issuedAt": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "expiresAt": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "approvedBy": {
                "type": "string",
                "minLength": 1
              },
              "requiredScope": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "idempotencyKeys": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "minItems": 1,
                "maxItems": 1000
              },
              "contentHash": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "grantId",
              "planHash",
              "preflightHash",
              "portfolioHash",
              "marketHash",
              "marketAsOf",
              "marketMaximumAgeMs",
              "mode",
              "accountId",
              "baseCurrency",
              "orderIds",
              "comboIds",
              "variance",
              "issuedAt",
              "expiresAt",
              "approvedBy",
              "requiredScope",
              "idempotencyKeys",
              "contentHash"
            ]
          },
          "grantHash": {
            "type": "string"
          },
          "idempotencyKey": {
            "type": "string",
            "minLength": 1
          },
          "now": {
            "type": "number",
            "description": "Epoch ms — the submission instant"
          },
          "portfolioHash": {
            "type": "string"
          },
          "marketHash": {
            "type": "string"
          },
          "marketAsOf": {
            "type": "number"
          },
          "sourceId": {
            "type": "string",
            "minLength": 1,
            "description": "The execution source (`paper:<account>` by convention); the journal id derives from it"
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "baseCurrency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "instruments": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/$defs/Instruments"
            }
          },
          "orders": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/Orders"
            }
          },
          "journal": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "type": "object",
                  "properties": {
                    "eventId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "journalId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "timestampMs": {
                      "type": "number",
                      "description": "Epoch milliseconds"
                    },
                    "orderId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "planHash": {
                      "type": "string",
                      "minLength": 1
                    },
                    "idempotencyKey": {
                      "type": "string",
                      "minLength": 1
                    },
                    "sourceId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "provenance": {
                      "type": "object",
                      "properties": {
                        "provider": {
                          "type": "string"
                        },
                        "dataset": {
                          "type": "string"
                        },
                        "asOf": {
                          "type": "number",
                          "description": "Epoch milliseconds"
                        },
                        "receivedAt": {
                          "type": "number",
                          "description": "Epoch milliseconds"
                        },
                        "sourceVersion": {
                          "type": "string"
                        },
                        "requestId": {
                          "type": "string"
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "code": {
                                "type": "string",
                                "minLength": 1
                              },
                              "message": {
                                "type": "string"
                              },
                              "severity": {
                                "type": "string",
                                "enum": [
                                  "info",
                                  "warn",
                                  "error"
                                ]
                              },
                              "context": {
                                "type": "object",
                                "additionalProperties": {}
                              }
                            },
                            "additionalProperties": false,
                            "required": [
                              "code",
                              "message",
                              "severity"
                            ]
                          }
                        }
                      },
                      "additionalProperties": false
                    },
                    "eventType": {},
                    "detail": {}
                  },
                  "additionalProperties": false,
                  "required": [
                    "eventId",
                    "journalId",
                    "timestampMs",
                    "orderId",
                    "planHash",
                    "sourceId",
                    "provenance",
                    "eventType",
                    "detail"
                  ]
                },
                {
                  "anyOf": [
                    {
                      "properties": {
                        "eventType": {
                          "const": "proposed",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "preflighted",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "authorized",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "submitted",
                          "type": "string"
                        },
                        "detail": {
                          "type": "object",
                          "properties": {
                            "quantity": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            },
                            "fillId": {
                              "type": "string"
                            },
                            "pricePerUnit": {
                              "type": "number"
                            },
                            "reason": {
                              "type": "string"
                            },
                            "replacementOrderId": {
                              "type": "string"
                            },
                            "artifactHash": {
                              "type": "string"
                            },
                            "note": {
                              "type": "string"
                            },
                            "order": {
                              "$ref": "#/$defs/Orders"
                            },
                            "instrument": {
                              "$ref": "#/$defs/Instruments"
                            },
                            "accountId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "baseCurrency": {
                              "type": "string",
                              "pattern": "^[A-Z]{3}$"
                            },
                            "executionPolicyHash": {
                              "type": "string",
                              "minLength": 1
                            },
                            "comboId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "netLimitPrice": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "quantity"
                          ]
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "acknowledged",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "partially-filled",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail2"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "filled",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail2"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "rejected",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "cancel-requested",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "cancelled",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "replaced",
                          "type": "string"
                        },
                        "detail": {
                          "type": "object",
                          "properties": {
                            "quantity": {
                              "type": "number"
                            },
                            "fillId": {
                              "type": "string"
                            },
                            "pricePerUnit": {
                              "type": "number"
                            },
                            "reason": {
                              "type": "string"
                            },
                            "replacementOrderId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "artifactHash": {
                              "type": "string"
                            },
                            "note": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "replacementOrderId"
                          ]
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "expired",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "reconciled",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    },
                    {
                      "properties": {
                        "eventType": {
                          "const": "unresolved",
                          "type": "string"
                        },
                        "detail": {
                          "$ref": "#/$defs/Detail"
                        }
                      }
                    }
                  ]
                }
              ]
            },
            "description": "Optional exact canonical snapshot of the persisted journal; checked inside the transaction. Never imports or replaces history. An execution-journal store is required."
          },
          "observations": {
            "type": "object",
            "additionalProperties": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "const": "bar",
                      "type": "string"
                    },
                    "bar": {
                      "type": "object",
                      "properties": {
                        "symbol": {
                          "type": "string",
                          "minLength": 1
                        },
                        "timestampMs": {
                          "type": "number"
                        },
                        "open": {
                          "type": "number"
                        },
                        "high": {
                          "type": "number"
                        },
                        "low": {
                          "type": "number"
                        },
                        "close": {
                          "type": "number"
                        },
                        "volume": {
                          "type": "number",
                          "minimum": 0
                        },
                        "vwap": {
                          "type": "number"
                        },
                        "adjusted": {
                          "type": "boolean"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "symbol",
                        "timestampMs",
                        "open",
                        "high",
                        "low",
                        "close"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "kind",
                    "bar"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "const": "quote",
                      "type": "string"
                    },
                    "quote": {
                      "type": "object",
                      "properties": {
                        "symbol": {
                          "type": "string",
                          "minLength": 1
                        },
                        "timestampMs": {
                          "type": "number"
                        },
                        "bid": {
                          "type": "number"
                        },
                        "ask": {
                          "type": "number"
                        },
                        "bidSize": {
                          "type": "number",
                          "minimum": 0
                        },
                        "askSize": {
                          "type": "number",
                          "minimum": 0
                        },
                        "exchange": {
                          "type": "string"
                        },
                        "conditions": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "symbol",
                        "timestampMs",
                        "bid",
                        "ask"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "kind",
                    "quote"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "const": "trade",
                      "type": "string"
                    },
                    "trade": {
                      "type": "object",
                      "properties": {
                        "symbol": {
                          "type": "string",
                          "minLength": 1
                        },
                        "timestampMs": {
                          "type": "number"
                        },
                        "price": {
                          "type": "number"
                        },
                        "size": {
                          "type": "number"
                        },
                        "exchange": {
                          "type": "string"
                        },
                        "conditions": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "sequence": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "symbol",
                        "timestampMs",
                        "price",
                        "size"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "kind",
                    "trade"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "const": "order-book",
                      "type": "string"
                    },
                    "book": {
                      "type": "object",
                      "properties": {
                        "symbol": {
                          "type": "string",
                          "minLength": 1
                        },
                        "timestampMs": {
                          "type": "number"
                        },
                        "bids": {
                          "$ref": "#/$defs/Bids"
                        },
                        "asks": {
                          "$ref": "#/$defs/Bids"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "symbol",
                        "timestampMs",
                        "bids",
                        "asks"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "kind",
                    "book"
                  ]
                }
              ]
            }
          },
          "asOf": {
            "type": "number",
            "description": "Epoch ms — the instant the open orders meet the observations (default `now`)"
          }
        },
        "additionalProperties": false,
        "required": [
          "plan",
          "idempotencyKey",
          "now",
          "portfolioHash",
          "marketHash",
          "marketAsOf",
          "sourceId",
          "accountId",
          "baseCurrency"
        ],
        "anyOf": [
          {
            "required": [
              "grant"
            ]
          },
          {
            "required": [
              "grantHash"
            ]
          }
        ],
        "$id": "https://totalfinance.dev/schemas/trade.submit.input",
        "$defs": {
          "Orders": {
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "instrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "side": {
                    "type": "string",
                    "enum": [
                      "buy",
                      "sell"
                    ]
                  },
                  "timeInForce": {
                    "type": "string",
                    "enum": [
                      "day",
                      "gtc"
                    ],
                    "description": "Default: the paper execution policy’s day time-in-force"
                  },
                  "comboId": {
                    "type": "string",
                    "minLength": 1,
                    "description": "The multi-leg order this is a leg of (B5)"
                  },
                  "orderId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "quantity": {
                    "type": "number",
                    "exclusiveMinimum": 0,
                    "description": "Units/contracts, strictly positive; side carries direction"
                  },
                  "plannedTimestampMs": {
                    "type": "number",
                    "description": "When the plan was made — never when a broker saw the order"
                  },
                  "submittedTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "type": {},
                  "limitPrice": {},
                  "stopPrice": {}
                },
                "additionalProperties": false,
                "required": [
                  "instrumentId",
                  "side",
                  "orderId",
                  "quantity",
                  "plannedTimestampMs",
                  "type"
                ]
              },
              {
                "anyOf": [
                  {
                    "properties": {
                      "type": {
                        "const": "market",
                        "type": "string"
                      }
                    },
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "limitPrice"
                          ]
                        },
                        {
                          "required": [
                            "stopPrice"
                          ]
                        }
                      ]
                    }
                  },
                  {
                    "properties": {
                      "type": {
                        "const": "market-on-open",
                        "type": "string"
                      }
                    },
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "limitPrice"
                          ]
                        },
                        {
                          "required": [
                            "stopPrice"
                          ]
                        }
                      ]
                    }
                  },
                  {
                    "properties": {
                      "type": {
                        "const": "market-on-close",
                        "type": "string"
                      }
                    },
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "limitPrice"
                          ]
                        },
                        {
                          "required": [
                            "stopPrice"
                          ]
                        }
                      ]
                    }
                  },
                  {
                    "properties": {
                      "type": {
                        "const": "limit",
                        "type": "string"
                      },
                      "limitPrice": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "required": [
                      "limitPrice"
                    ],
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "stopPrice"
                          ]
                        }
                      ]
                    }
                  },
                  {
                    "properties": {
                      "type": {
                        "const": "stop",
                        "type": "string"
                      },
                      "stopPrice": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "required": [
                      "stopPrice"
                    ],
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "limitPrice"
                          ]
                        }
                      ]
                    }
                  },
                  {
                    "properties": {
                      "type": {
                        "const": "stop-limit",
                        "type": "string"
                      },
                      "limitPrice": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      },
                      "stopPrice": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "required": [
                      "limitPrice",
                      "stopPrice"
                    ]
                  }
                ]
              }
            ]
          },
          "Instruments": {
            "type": "object",
            "properties": {
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "contractMultiplier": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "settlementStyle": {
                "type": "string",
                "enum": [
                  "cash-on-trade",
                  "variation-margin"
                ]
              },
              "settlementLag": {
                "anyOf": [
                  {
                    "const": 0,
                    "type": "number"
                  },
                  {
                    "const": 1,
                    "type": "number"
                  },
                  {
                    "const": 2,
                    "type": "number"
                  }
                ],
                "description": "T+n 24-hour days in the paper broker; default 0"
              }
            },
            "additionalProperties": false,
            "required": [
              "currency"
            ]
          },
          "Contract": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "option",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "call",
                      "put"
                    ]
                  },
                  "strikePricePerUnit": {
                    "type": "number"
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "type",
                  "strikePricePerUnit",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "future",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "perpetual",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId"
                ]
              }
            ]
          },
          "Detail": {
            "type": "object",
            "properties": {
              "quantity": {
                "type": "number"
              },
              "fillId": {
                "type": "string"
              },
              "pricePerUnit": {
                "type": "number"
              },
              "reason": {
                "type": "string"
              },
              "replacementOrderId": {
                "type": "string"
              },
              "artifactHash": {
                "type": "string"
              },
              "note": {
                "type": "string"
              }
            },
            "additionalProperties": false
          },
          "Detail2": {
            "type": "object",
            "properties": {
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "fillId": {
                "type": "string",
                "minLength": 1
              },
              "pricePerUnit": {
                "type": "number"
              },
              "reason": {
                "type": "string"
              },
              "replacementOrderId": {
                "type": "string"
              },
              "artifactHash": {
                "type": "string"
              },
              "note": {
                "type": "string"
              },
              "observationTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "fill": {
                "type": "object",
                "properties": {
                  "fillId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "accountId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "instrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "side": {
                    "type": "string",
                    "enum": [
                      "buy",
                      "sell"
                    ]
                  },
                  "quantity": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "pricePerUnit": {
                    "type": "number"
                  },
                  "currency": {
                    "type": "string",
                    "pattern": "^[A-Z]{3}$"
                  },
                  "filledTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "settleTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "contractMultiplier": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "settlementStyle": {
                    "type": "string",
                    "enum": [
                      "cash-on-trade",
                      "variation-margin"
                    ]
                  },
                  "contract": {
                    "$ref": "#/$defs/Contract"
                  },
                  "accruedInterest": {
                    "type": "number"
                  },
                  "executionPriceAdjustment": {
                    "type": "number",
                    "minimum": 0
                  },
                  "costs": {
                    "type": "object",
                    "properties": {
                      "commission": {
                        "type": "number",
                        "minimum": 0
                      },
                      "exchangeFees": {
                        "type": "number",
                        "minimum": 0
                      },
                      "regulatoryFees": {
                        "type": "number",
                        "minimum": 0
                      },
                      "slippageAdjustment": {
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false
                  },
                  "orderId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "venue": {
                    "type": "string"
                  },
                  "liquidity": {
                    "type": "string",
                    "enum": [
                      "maker",
                      "taker",
                      "unknown"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "fillId",
                  "accountId",
                  "instrumentId",
                  "side",
                  "quantity",
                  "pricePerUnit",
                  "currency",
                  "filledTimestampMs"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "quantity",
              "fillId"
            ]
          },
          "Bids": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "price": {
                  "type": "number"
                },
                "size": {
                  "type": "number",
                  "minimum": 0
                },
                "exchange": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "price",
                "size"
              ]
            }
          }
        }
      },
      "totalfinance.trade.submit.output": {
        "type": "object",
        "properties": {
          "receipt": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "totalfinance.execution-receipt",
                "type": "string"
              },
              "schemaVersion": {
                "const": 1,
                "type": "number"
              },
              "receiptId": {
                "type": "string",
                "minLength": 1
              },
              "planHash": {
                "type": "string",
                "minLength": 1
              },
              "grantHash": {
                "type": "string",
                "minLength": 1
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1
              },
              "adapter": {
                "const": "paper",
                "type": "string"
              },
              "accountId": {
                "type": "string",
                "minLength": 1
              },
              "sourceId": {
                "type": "string",
                "minLength": 1
              },
              "submittedAt": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "orders": {
                "type": "array",
                "items": {
                  "$ref": "#/$defs/Orders"
                }
              },
              "fills": {
                "$ref": "#/$defs/Fills"
              },
              "journalEventIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "assumptions": {
                "type": "object",
                "properties": {
                  "conventionsVersion": {
                    "type": "string"
                  },
                  "mode": {
                    "const": "paper",
                    "type": "string"
                  },
                  "execution": {
                    "type": "object",
                    "properties": {
                      "label": {
                        "type": "string"
                      },
                      "realism": {
                        "type": "string",
                        "enum": [
                          "simplified",
                          "declared"
                        ]
                      },
                      "observation": {
                        "type": "string",
                        "enum": [
                          "bar",
                          "quote",
                          "trade",
                          "order-book"
                        ]
                      },
                      "fill": {
                        "type": "object",
                        "properties": {
                          "label": {
                            "type": "string"
                          },
                          "version": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "label",
                          "version"
                        ]
                      },
                      "ambiguity": {
                        "type": "string",
                        "enum": [
                          "optimistic",
                          "pessimistic",
                          "deterministic-path",
                          "reject"
                        ]
                      },
                      "costs": {
                        "type": "object",
                        "properties": {
                          "commission": {
                            "type": "string"
                          },
                          "slippage": {
                            "type": "string"
                          },
                          "spread": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "marketImpact": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "latencySessions": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "participation": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "borrow": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "commission",
                          "slippage",
                          "spread",
                          "marketImpact",
                          "latencySessions",
                          "participation",
                          "borrow"
                        ]
                      },
                      "staleQuotes": {
                        "type": "object",
                        "properties": {
                          "maximumAgeMs": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "behavior": {
                            "type": "string",
                            "enum": [
                              "reject",
                              "fill-at-last"
                            ]
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "maximumAgeMs",
                          "behavior"
                        ]
                      },
                      "lockedCrossed": {
                        "type": "string",
                        "enum": [
                          "reject",
                          "fill-at-mid"
                        ]
                      },
                      "sessions": {
                        "type": "object",
                        "properties": {
                          "halts": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "priceLimits": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "auction": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "ignore",
                                  "open-close-only"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "halts",
                          "priceLimits",
                          "auction"
                        ]
                      },
                      "partialFills": {
                        "type": "string",
                        "enum": [
                          "allow",
                          "reject"
                        ]
                      },
                      "queue": {
                        "type": "string",
                        "enum": [
                          "none",
                          "depth-approximation"
                        ]
                      },
                      "timeInForce": {
                        "type": "object",
                        "properties": {
                          "default": {
                            "type": "string",
                            "enum": [
                              "day",
                              "gtc"
                            ],
                            "description": "Default: the paper execution policy’s day time-in-force"
                          },
                          "expireAtSessionClose": {
                            "type": "boolean"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "default",
                          "expireAtSessionClose"
                        ]
                      },
                      "margin": {
                        "type": "object",
                        "properties": {
                          "buyingPowerMultiplier": {
                            "type": "number"
                          },
                          "initialMarginRate": {
                            "type": "number"
                          },
                          "maintenanceMarginRate": {
                            "type": "number"
                          },
                          "forcedLiquidation": {
                            "type": "string",
                            "enum": [
                              "none",
                              "close-largest-loss",
                              "pro-rata"
                            ]
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "buyingPowerMultiplier",
                          "initialMarginRate",
                          "maintenanceMarginRate",
                          "forcedLiquidation"
                        ]
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "label",
                      "realism",
                      "observation",
                      "fill",
                      "ambiguity",
                      "costs",
                      "staleQuotes",
                      "lockedCrossed",
                      "sessions",
                      "partialFills",
                      "queue",
                      "timeInForce",
                      "margin"
                    ]
                  },
                  "idempotencyConvention": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "conventionsVersion",
                  "mode",
                  "execution",
                  "idempotencyConvention"
                ]
              },
              "diagnostics": {
                "type": "object",
                "properties": {
                  "engine": {
                    "const": "paper-broker",
                    "type": "string"
                  },
                  "warnings": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "orderCount": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "retried": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "engine",
                  "warnings",
                  "orderCount",
                  "retried"
                ]
              },
              "contentHash": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "schemaVersion",
              "receiptId",
              "planHash",
              "grantHash",
              "idempotencyKey",
              "adapter",
              "accountId",
              "sourceId",
              "submittedAt",
              "orders",
              "fills",
              "journalEventIds",
              "assumptions",
              "diagnostics",
              "contentHash"
            ]
          },
          "currentOrders": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/Orders"
            },
            "description": "Authoritative journal-derived state and cumulative fills for this receipt, distinct from the immutable submission receipt"
          },
          "retried": {
            "type": "boolean"
          },
          "fills": {
            "$ref": "#/$defs/Fills"
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/PortfolioEventEnvelope"
            }
          },
          "recovery": {
            "type": "object",
            "properties": {
              "fills": {
                "$ref": "#/$defs/Fills"
              },
              "events": {
                "type": "array",
                "items": {
                  "$ref": "#/$defs/PortfolioEventEnvelope"
                }
              }
            },
            "additionalProperties": false,
            "required": [
              "fills",
              "events"
            ],
            "description": "Cumulative persisted fills and reproducible ledger events for this receipt; safe to apply idempotently after a lost response. Top-level fills/events remain new deltas."
          },
          "journal": {
            "type": "object",
            "properties": {
              "journalId": {
                "type": "string",
                "minLength": 1
              },
              "appended": {
                "type": "integer",
                "minimum": 0
              },
              "total": {
                "type": "integer",
                "minimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "journalId",
              "appended",
              "total"
            ]
          },
          "open": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "expired": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "unfilled": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "orderId": {
                  "type": "string",
                  "minLength": 1
                },
                "reason": {
                  "type": "string",
                  "enum": [
                    "not-triggered",
                    "no-observation",
                    "wrong-observation-kind",
                    "stale-quote",
                    "locked-crossed",
                    "halted",
                    "zero-quantity",
                    "insufficient-depth",
                    "already-observed"
                  ]
                },
                "detail": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "orderId",
                "reason",
                "detail"
              ]
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "receipt",
          "currentOrders",
          "retried",
          "fills",
          "events",
          "recovery",
          "journal",
          "open",
          "expired",
          "unfilled"
        ],
        "$id": "https://totalfinance.dev/schemas/trade.submit.output",
        "$defs": {
          "PortfolioEventEnvelope": {
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "eventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "schemaVersion": {
                    "const": 1,
                    "type": "number"
                  },
                  "sourceId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "accountId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "effectiveTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "recordedTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  },
                  "correlationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "causationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "reversesEventId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "provenance": {
                    "type": "object",
                    "properties": {
                      "provider": {
                        "type": "string"
                      },
                      "dataset": {
                        "type": "string"
                      },
                      "asOf": {
                        "type": "number",
                        "description": "Epoch milliseconds"
                      },
                      "receivedAt": {
                        "type": "number",
                        "description": "Epoch milliseconds"
                      },
                      "sourceVersion": {
                        "type": "string"
                      },
                      "requestId": {
                        "type": "string"
                      },
                      "warnings": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "minLength": 1
                            },
                            "message": {
                              "type": "string"
                            },
                            "severity": {
                              "type": "string",
                              "enum": [
                                "info",
                                "warn",
                                "error"
                              ]
                            },
                            "context": {
                              "type": "object",
                              "additionalProperties": {}
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "code",
                            "message",
                            "severity"
                          ]
                        }
                      }
                    },
                    "additionalProperties": false
                  },
                  "eventType": {},
                  "event": {}
                },
                "additionalProperties": false,
                "required": [
                  "eventId",
                  "schemaVersion",
                  "sourceId",
                  "accountId",
                  "effectiveTimestampMs",
                  "recordedTimestampMs",
                  "provenance",
                  "eventType",
                  "event"
                ]
              },
              {
                "anyOf": [
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.deposit",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashDeposit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.withdrawal",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashWithdrawal"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cash.conversion",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CashConversion"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "trade.fill",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/TradeFill"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "cost.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CostCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "income.received",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/IncomeReceived"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "financing.charge",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FinancingCharge"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.split",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSplit"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.exercise",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExercise"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.assignment",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeAssignment"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.expiration",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeExpiration"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.multiplier-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeMultiplierChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.variation-margin",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeVariationMargin"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "derivative.roll",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/DerivativeRoll"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "fixed-income.redemption",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/FixedIncomeRedemption"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.symbol-change",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSymbolChange"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.merger",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateMerger"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.spin-off",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateSpinOff"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.return-of-capital",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateReturnOfCapital"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "corporate.cash-in-lieu",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/CorporateCashInLieu"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "position.transfer",
                        "type": "string"
                      },
                      "event": {
                        "$ref": "#/$defs/PositionTransfer"
                      }
                    }
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.reversal",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.reversal",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.correction",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.correction",
                            "type": "string"
                          },
                          "original": {
                            "$ref": "#/$defs/PortfolioEventEnvelope"
                          },
                          "replacement": {
                            "anyOf": [
                              {
                                "$ref": "#/$defs/CashDeposit"
                              },
                              {
                                "$ref": "#/$defs/CashWithdrawal"
                              },
                              {
                                "$ref": "#/$defs/CashTransfer"
                              },
                              {
                                "$ref": "#/$defs/CashConversion"
                              },
                              {
                                "$ref": "#/$defs/TradeFill"
                              },
                              {
                                "$ref": "#/$defs/CostCharge"
                              },
                              {
                                "$ref": "#/$defs/IncomeReceived"
                              },
                              {
                                "$ref": "#/$defs/FinancingCharge"
                              },
                              {
                                "$ref": "#/$defs/CorporateSplit"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExercise"
                              },
                              {
                                "$ref": "#/$defs/DerivativeAssignment"
                              },
                              {
                                "$ref": "#/$defs/DerivativeExpiration"
                              },
                              {
                                "$ref": "#/$defs/DerivativeMultiplierChange"
                              },
                              {
                                "$ref": "#/$defs/DerivativeVariationMargin"
                              },
                              {
                                "$ref": "#/$defs/DerivativeRoll"
                              },
                              {
                                "$ref": "#/$defs/FixedIncomeRedemption"
                              },
                              {
                                "$ref": "#/$defs/CorporateSymbolChange"
                              },
                              {
                                "$ref": "#/$defs/CorporateMerger"
                              },
                              {
                                "$ref": "#/$defs/CorporateSpinOff"
                              },
                              {
                                "$ref": "#/$defs/CorporateReturnOfCapital"
                              },
                              {
                                "$ref": "#/$defs/CorporateCashInLieu"
                              },
                              {
                                "$ref": "#/$defs/PositionTransfer"
                              }
                            ]
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "original",
                          "replacement"
                        ]
                      }
                    },
                    "required": [
                      "reversesEventId"
                    ]
                  },
                  {
                    "properties": {
                      "eventType": {
                        "const": "admin.account-migration",
                        "type": "string"
                      },
                      "event": {
                        "type": "object",
                        "properties": {
                          "eventType": {
                            "const": "admin.account-migration",
                            "type": "string"
                          },
                          "fromAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "toAccountId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "eventType",
                          "fromAccountId",
                          "toAccountId"
                        ]
                      }
                    }
                  }
                ]
              }
            ]
          },
          "Orders": {
            "type": "object",
            "properties": {
              "orderId": {
                "type": "string",
                "minLength": 1
              },
              "planHash": {
                "type": "string",
                "minLength": 1
              },
              "state": {
                "type": "string",
                "enum": [
                  "submitted",
                  "acknowledged",
                  "partially-filled",
                  "filled",
                  "cancelled",
                  "rejected",
                  "expired",
                  "unresolved"
                ]
              },
              "submittedQuantity": {
                "type": "number",
                "minimum": 0
              },
              "filledQuantity": {
                "type": "number",
                "minimum": 0
              },
              "remainingQuantity": {
                "type": "number",
                "minimum": 0
              },
              "averageFillPrice": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "fillIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "lateFillIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "lastEventId": {
                "type": "string",
                "minLength": 1
              },
              "lastTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "terminal": {
                "type": "boolean"
              },
              "cancelRequested": {
                "type": "boolean"
              },
              "reason": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "replacedBy": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "reconciledEventId": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "orderId",
              "planHash",
              "state",
              "submittedQuantity",
              "filledQuantity",
              "remainingQuantity",
              "averageFillPrice",
              "fillIds",
              "lateFillIds",
              "lastEventId",
              "lastTimestampMs",
              "terminal",
              "cancelRequested",
              "reason",
              "replacedBy",
              "reconciledEventId"
            ]
          },
          "Fills": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "fillId": {
                  "type": "string",
                  "minLength": 1
                },
                "accountId": {
                  "type": "string",
                  "minLength": 1
                },
                "instrumentId": {
                  "type": "string",
                  "minLength": 1
                },
                "side": {
                  "type": "string",
                  "enum": [
                    "buy",
                    "sell"
                  ]
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "pricePerUnit": {
                  "type": "number"
                },
                "currency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "filledTimestampMs": {
                  "type": "number",
                  "description": "Epoch milliseconds"
                },
                "settleTimestampMs": {
                  "type": "number",
                  "description": "Epoch milliseconds"
                },
                "contractMultiplier": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "settlementStyle": {
                  "type": "string",
                  "enum": [
                    "cash-on-trade",
                    "variation-margin"
                  ]
                },
                "contract": {
                  "$ref": "#/$defs/Contract"
                },
                "accruedInterest": {
                  "type": "number"
                },
                "executionPriceAdjustment": {
                  "type": "number",
                  "minimum": 0
                },
                "costs": {
                  "type": "object",
                  "properties": {
                    "commission": {
                      "type": "number",
                      "minimum": 0
                    },
                    "exchangeFees": {
                      "type": "number",
                      "minimum": 0
                    },
                    "regulatoryFees": {
                      "type": "number",
                      "minimum": 0
                    },
                    "slippageAdjustment": {
                      "type": "number",
                      "minimum": 0
                    }
                  },
                  "additionalProperties": false
                },
                "orderId": {
                  "type": "string",
                  "minLength": 1
                },
                "venue": {
                  "type": "string"
                },
                "liquidity": {
                  "type": "string",
                  "enum": [
                    "maker",
                    "taker",
                    "unknown"
                  ]
                }
              },
              "additionalProperties": false,
              "required": [
                "fillId",
                "accountId",
                "instrumentId",
                "side",
                "quantity",
                "pricePerUnit",
                "currency",
                "filledTimestampMs"
              ]
            }
          },
          "Contract": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "option",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "call",
                      "put"
                    ]
                  },
                  "strikePricePerUnit": {
                    "type": "number"
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "type",
                  "strikePricePerUnit",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "future",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "expiryTimestampMs": {
                    "type": "number",
                    "description": "Epoch milliseconds"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId",
                  "expiryTimestampMs"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "perpetual",
                    "type": "string"
                  },
                  "underlyingInstrumentId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "underlyingInstrumentId"
                ]
              }
            ]
          },
          "CashDeposit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.deposit",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashWithdrawal": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.withdrawal",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency"
            ]
          },
          "CashTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.transfer",
                "type": "string"
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "amount",
              "currency",
              "fromAccountId",
              "toAccountId"
            ]
          },
          "CashConversion": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cash.conversion",
                "type": "string"
              },
              "fromCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "toCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "fromAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "toAmount": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromCurrency",
              "toCurrency",
              "fromAmount",
              "toAmount"
            ]
          },
          "TradeFill": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "trade.fill",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "side": {
                "type": "string",
                "enum": [
                  "buy",
                  "sell"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              },
              "contractMultiplier": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlementStyle": {
                "type": "string",
                "enum": [
                  "cash-on-trade",
                  "variation-margin"
                ]
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "accruedInterest": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "side",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "LotSelections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "lotId": {
                  "type": "string",
                  "minLength": 1
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "lotId",
                "quantity"
              ]
            },
            "minItems": 1
          },
          "CostCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "cost.charge",
                "type": "string"
              },
              "costType": {
                "type": "string",
                "enum": [
                  "commission",
                  "exchange-fee",
                  "regulatory-fee",
                  "slippage-adjustment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "costType",
              "amount",
              "currency"
            ]
          },
          "IncomeReceived": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "income.received",
                "type": "string"
              },
              "incomeType": {
                "type": "string",
                "enum": [
                  "dividend",
                  "coupon",
                  "interest",
                  "staking-reward",
                  "funding-receipt"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "incomeType",
              "amount",
              "currency"
            ]
          },
          "FinancingCharge": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "financing.charge",
                "type": "string"
              },
              "financingType": {
                "type": "string",
                "enum": [
                  "margin-interest",
                  "borrow-charge",
                  "funding-payment"
                ]
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "financingType",
              "amount",
              "currency"
            ]
          },
          "CorporateSplit": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.split",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesAfterSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "sharesBeforeSplit": {
                "type": "number",
                "exclusiveMinimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "sharesAfterSplit",
              "sharesBeforeSplit"
            ]
          },
          "DerivativeExercise": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.exercise",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "Settlement": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "physical",
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "const": "cash",
                    "type": "string"
                  },
                  "settlementPricePerUnit": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "kind",
                  "settlementPricePerUnit"
                ]
              }
            ]
          },
          "DerivativeAssignment": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.assignment",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlement": {
                "$ref": "#/$defs/Settlement"
              },
              "premiumTreatment": {
                "type": "string",
                "enum": [
                  "fold-into-underlying-basis",
                  "realize"
                ]
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "settlement",
              "premiumTreatment"
            ]
          },
          "DerivativeExpiration": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.expiration",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity"
            ]
          },
          "DerivativeMultiplierChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.multiplier-change",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "contractMultiplierAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "strikePricePerUnitAfter": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "reason": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "contractMultiplierAfter"
            ]
          },
          "DerivativeVariationMargin": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.variation-margin",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "settlementPricePerUnit": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "settlementPricePerUnit"
            ]
          },
          "DerivativeRoll": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "derivative.roll",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "closePricePerUnit": {
                "type": "number"
              },
              "openPricePerUnit": {
                "type": "number"
              },
              "contract": {
                "$ref": "#/$defs/Contract"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId",
              "quantity",
              "closePricePerUnit",
              "openPricePerUnit"
            ]
          },
          "FixedIncomeRedemption": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "fixed-income.redemption",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "redemptionType": {
                "type": "string",
                "enum": [
                  "maturity",
                  "call",
                  "principal-paydown",
                  "sinking-fund"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "pricePerUnit": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "redemptionType",
              "quantity",
              "pricePerUnit",
              "currency"
            ]
          },
          "CorporateSymbolChange": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.symbol-change",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId",
              "toInstrumentId"
            ]
          },
          "CorporateMerger": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.merger",
                "type": "string"
              },
              "fromInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "toInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "cashPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "fromInstrumentId"
            ]
          },
          "CorporateSpinOff": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.spin-off",
                "type": "string"
              },
              "parentInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "childInstrumentId": {
                "type": "string",
                "minLength": 1
              },
              "sharesPerParentShare": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "basisAllocationFraction": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "parentInstrumentId",
              "childInstrumentId",
              "sharesPerParentShare",
              "basisAllocationFraction"
            ]
          },
          "CorporateReturnOfCapital": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.return-of-capital",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "amountPerShare": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "amountPerShare",
              "currency"
            ]
          },
          "CorporateCashInLieu": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "corporate.cash-in-lieu",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "relatesToEventId": {
                "type": "string",
                "minLength": 1
              },
              "settleTimestampMs": {
                "type": "number",
                "description": "Epoch milliseconds"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "amount",
              "currency"
            ]
          },
          "PositionTransfer": {
            "type": "object",
            "properties": {
              "eventType": {
                "const": "position.transfer",
                "type": "string"
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "fromAccountId": {
                "type": "string",
                "minLength": 1
              },
              "toAccountId": {
                "type": "string",
                "minLength": 1
              },
              "lotSelections": {
                "$ref": "#/$defs/LotSelections"
              }
            },
            "additionalProperties": false,
            "required": [
              "eventType",
              "instrumentId",
              "quantity",
              "fromAccountId",
              "toAccountId"
            ]
          }
        }
      },
      "totalfinance.trade.submit.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.trade.submit.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.valuation.company.input": {
        "type": "object",
        "properties": {
          "projection": {
            "type": "object",
            "properties": {
              "baseStatements": {
                "type": "object",
                "properties": {
                  "income": {
                    "type": "object",
                    "properties": {
                      "period": {
                        "type": "object",
                        "properties": {
                          "periodStartDate": {
                            "type": "string",
                            "format": "date"
                          },
                          "periodEndDate": {
                            "type": "string",
                            "format": "date"
                          },
                          "fiscalYear": {
                            "type": "integer"
                          },
                          "fiscalQuarter": {
                            "anyOf": [
                              {
                                "const": 1,
                                "type": "number"
                              },
                              {
                                "const": 2,
                                "type": "number"
                              },
                              {
                                "const": 3,
                                "type": "number"
                              },
                              {
                                "const": 4,
                                "type": "number"
                              }
                            ]
                          },
                          "periodType": {
                            "type": "string",
                            "enum": [
                              "quarter",
                              "year",
                              "trailing-twelve-months"
                            ]
                          },
                          "filedTimestampMs": {
                            "type": "number"
                          },
                          "availableTimestampMs": {
                            "type": "number"
                          },
                          "currency": {
                            "type": "string",
                            "minLength": 1
                          },
                          "monetaryScale": {
                            "anyOf": [
                              {
                                "const": 1,
                                "type": "number"
                              },
                              {
                                "const": 1000,
                                "type": "number"
                              },
                              {
                                "const": 1000000,
                                "type": "number"
                              }
                            ]
                          },
                          "form": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "periodEndDate",
                          "fiscalYear",
                          "periodType",
                          "availableTimestampMs",
                          "currency",
                          "monetaryScale"
                        ]
                      },
                      "revenue": {
                        "type": "number"
                      },
                      "costOfRevenue": {
                        "type": "number"
                      },
                      "grossProfit": {
                        "type": "number"
                      },
                      "operatingExpenses": {
                        "type": "number"
                      },
                      "operatingIncome": {
                        "type": "number"
                      },
                      "interestExpense": {
                        "type": "number"
                      },
                      "incomeTaxExpense": {
                        "type": "number"
                      },
                      "netIncome": {
                        "type": "number"
                      },
                      "incomeFromContinuingOperations": {
                        "type": "number"
                      },
                      "sellingGeneralAdministrativeExpense": {
                        "type": "number"
                      },
                      "dilutedSharesOutstanding": {
                        "type": "number"
                      },
                      "metadata": {
                        "type": "object",
                        "additionalProperties": {}
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "period",
                      "revenue",
                      "operatingIncome",
                      "netIncome"
                    ]
                  },
                  "balance": {
                    "type": "object",
                    "properties": {
                      "period": {
                        "type": "object",
                        "properties": {
                          "periodStartDate": {
                            "type": "string",
                            "format": "date"
                          },
                          "periodEndDate": {
                            "type": "string",
                            "format": "date"
                          },
                          "fiscalYear": {
                            "type": "integer"
                          },
                          "fiscalQuarter": {
                            "anyOf": [
                              {
                                "const": 1,
                                "type": "number"
                              },
                              {
                                "const": 2,
                                "type": "number"
                              },
                              {
                                "const": 3,
                                "type": "number"
                              },
                              {
                                "const": 4,
                                "type": "number"
                              }
                            ]
                          },
                          "periodType": {
                            "type": "string",
                            "enum": [
                              "quarter",
                              "year",
                              "trailing-twelve-months"
                            ]
                          },
                          "filedTimestampMs": {
                            "type": "number"
                          },
                          "availableTimestampMs": {
                            "type": "number"
                          },
                          "currency": {
                            "type": "string",
                            "minLength": 1
                          },
                          "monetaryScale": {
                            "anyOf": [
                              {
                                "const": 1,
                                "type": "number"
                              },
                              {
                                "const": 1000,
                                "type": "number"
                              },
                              {
                                "const": 1000000,
                                "type": "number"
                              }
                            ]
                          },
                          "form": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "periodEndDate",
                          "fiscalYear",
                          "periodType",
                          "availableTimestampMs",
                          "currency",
                          "monetaryScale"
                        ]
                      },
                      "cashAndCashEquivalents": {
                        "type": "number"
                      },
                      "shortTermInvestments": {
                        "type": "number"
                      },
                      "accountsReceivable": {
                        "type": "number"
                      },
                      "inventory": {
                        "type": "number"
                      },
                      "currentAssets": {
                        "type": "number"
                      },
                      "propertyPlantEquipmentNet": {
                        "type": "number"
                      },
                      "otherAssets": {
                        "type": "number"
                      },
                      "totalAssets": {
                        "type": "number"
                      },
                      "currentLiabilities": {
                        "type": "number"
                      },
                      "accountsPayable": {
                        "type": "number"
                      },
                      "shortTermDebt": {
                        "type": "number"
                      },
                      "longTermDebt": {
                        "type": "number"
                      },
                      "otherLiabilities": {
                        "type": "number"
                      },
                      "totalDebt": {
                        "type": "number"
                      },
                      "totalLiabilities": {
                        "type": "number"
                      },
                      "preferredEquity": {
                        "type": "number"
                      },
                      "minorityInterest": {
                        "type": "number"
                      },
                      "totalEquity": {
                        "type": "number"
                      },
                      "metadata": {
                        "type": "object",
                        "additionalProperties": {}
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "period",
                      "cashAndCashEquivalents",
                      "totalAssets",
                      "totalLiabilities",
                      "totalEquity"
                    ]
                  },
                  "cashFlow": {
                    "type": "object",
                    "properties": {
                      "period": {
                        "type": "object",
                        "properties": {
                          "periodStartDate": {
                            "type": "string",
                            "format": "date"
                          },
                          "periodEndDate": {
                            "type": "string",
                            "format": "date"
                          },
                          "fiscalYear": {
                            "type": "integer"
                          },
                          "fiscalQuarter": {
                            "anyOf": [
                              {
                                "const": 1,
                                "type": "number"
                              },
                              {
                                "const": 2,
                                "type": "number"
                              },
                              {
                                "const": 3,
                                "type": "number"
                              },
                              {
                                "const": 4,
                                "type": "number"
                              }
                            ]
                          },
                          "periodType": {
                            "type": "string",
                            "enum": [
                              "quarter",
                              "year",
                              "trailing-twelve-months"
                            ]
                          },
                          "filedTimestampMs": {
                            "type": "number"
                          },
                          "availableTimestampMs": {
                            "type": "number"
                          },
                          "currency": {
                            "type": "string",
                            "minLength": 1
                          },
                          "monetaryScale": {
                            "anyOf": [
                              {
                                "const": 1,
                                "type": "number"
                              },
                              {
                                "const": 1000,
                                "type": "number"
                              },
                              {
                                "const": 1000000,
                                "type": "number"
                              }
                            ]
                          },
                          "form": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "periodEndDate",
                          "fiscalYear",
                          "periodType",
                          "availableTimestampMs",
                          "currency",
                          "monetaryScale"
                        ]
                      },
                      "operatingCashFlow": {
                        "type": "number"
                      },
                      "investingCashFlow": {
                        "type": "number"
                      },
                      "financingCashFlow": {
                        "type": "number"
                      },
                      "capitalExpenditure": {
                        "type": "number"
                      },
                      "depreciationAndAmortization": {
                        "type": "number"
                      },
                      "stockBasedCompensation": {
                        "type": "number"
                      },
                      "acquisitions": {
                        "type": "number"
                      },
                      "dividendsPaid": {
                        "type": "number"
                      },
                      "shareRepurchases": {
                        "type": "number"
                      },
                      "increaseInNetWorkingCapital": {
                        "type": "number"
                      },
                      "netChangeInCash": {
                        "type": "number"
                      },
                      "metadata": {
                        "type": "object",
                        "additionalProperties": {}
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "period",
                      "operatingCashFlow",
                      "investingCashFlow",
                      "financingCashFlow"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "income",
                  "balance",
                  "cashFlow"
                ],
                "description": "The typed historical base (one period of the three statements) the projection rolls forward"
              },
              "periods": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "periodLabel": {
                      "type": "string",
                      "minLength": 1
                    },
                    "revenue": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "amount": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "amount"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "growthRate": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "growthRate"
                          ]
                        }
                      ]
                    },
                    "operatingMargin": {
                      "type": "number"
                    },
                    "taxRate": {
                      "type": "number"
                    },
                    "interestExpense": {
                      "type": "number"
                    },
                    "depreciationAndAmortization": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "amount": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "amount"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "fractionOfRevenue": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "fractionOfRevenue"
                          ]
                        }
                      ]
                    },
                    "capitalExpenditure": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "amount": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "amount"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "fractionOfRevenue": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "fractionOfRevenue"
                          ]
                        }
                      ]
                    },
                    "accountsReceivable": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "amount": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "amount"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "fractionOfRevenue": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "fractionOfRevenue"
                          ]
                        }
                      ]
                    },
                    "inventory": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "amount": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "amount"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "fractionOfRevenue": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "fractionOfRevenue"
                          ]
                        }
                      ]
                    },
                    "accountsPayable": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "amount": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "amount"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "fractionOfRevenue": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "fractionOfRevenue"
                          ]
                        }
                      ]
                    },
                    "netBorrowing": {
                      "type": "number"
                    },
                    "dividendsPaid": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "periodLabel",
                    "revenue",
                    "operatingMargin",
                    "taxRate",
                    "interestExpense",
                    "depreciationAndAmortization",
                    "capitalExpenditure",
                    "accountsReceivable",
                    "inventory",
                    "accountsPayable",
                    "netBorrowing",
                    "dividendsPaid"
                  ]
                },
                "minItems": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "baseStatements",
              "periods"
            ]
          },
          "valuation": {
            "type": "object",
            "properties": {
              "valuationBasis": {
                "type": "string",
                "enum": [
                  "firm",
                  "equity"
                ]
              },
              "valuationDate": {
                "type": "string",
                "format": "date"
              },
              "currency": {
                "type": "string",
                "minLength": 1
              },
              "annualDiscountRate": {
                "type": "number",
                "description": "REQUIRED and explicit — a discount rate is a goal, never a default (FC0)"
              },
              "compounding": {
                "anyOf": [
                  {
                    "type": "string",
                    "enum": [
                      "simple",
                      "continuous",
                      "annual",
                      "semiannual",
                      "quarterly",
                      "monthly"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "periodic",
                        "type": "string"
                      },
                      "periodsPerYear": {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "type",
                      "periodsPerYear"
                    ]
                  }
                ]
              },
              "dayCount": {
                "type": "string",
                "enum": [
                  "ACT/365F",
                  "ACT/360",
                  "30/360"
                ]
              },
              "terminalValueMethod": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "method": {
                        "const": "perpetual-growth",
                        "type": "string"
                      },
                      "terminalCashFlow": {
                        "type": "number"
                      },
                      "perpetualGrowthRate": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "method",
                      "terminalCashFlow",
                      "perpetualGrowthRate"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "method": {
                        "const": "exit-multiple",
                        "type": "string"
                      },
                      "terminalMetricAmount": {
                        "type": "number"
                      },
                      "exitMultiple": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "method",
                      "terminalMetricAmount",
                      "exitMultiple"
                    ]
                  }
                ]
              },
              "enterpriseToEquityBridge": {
                "type": "object",
                "properties": {
                  "cashAndCashEquivalents": {
                    "type": "number"
                  },
                  "totalDebt": {
                    "type": "number"
                  },
                  "preferredEquity": {
                    "type": "number"
                  },
                  "minorityInterest": {
                    "type": "number"
                  },
                  "nonOperatingAssets": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "cashAndCashEquivalents",
                  "totalDebt",
                  "preferredEquity",
                  "minorityInterest",
                  "nonOperatingAssets"
                ]
              },
              "dilutedSharesOutstanding": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "forecastIdentity": {
                    "type": "string"
                  },
                  "statementIdentity": {
                    "type": "string"
                  },
                  "restatementIdentity": {
                    "type": "string"
                  },
                  "source": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "valuationBasis",
              "valuationDate",
              "currency",
              "annualDiscountRate",
              "compounding",
              "terminalValueMethod"
            ],
            "description": "discountedCashFlow's conventions, minus the projected flows the projection supplies"
          },
          "sensitivity": {
            "type": "object",
            "properties": {
              "rowAxis": {
                "type": "object",
                "properties": {
                  "variable": {
                    "type": "string",
                    "enum": [
                      "annual-discount-rate",
                      "perpetual-growth-rate",
                      "exit-multiple"
                    ]
                  },
                  "values": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    },
                    "minItems": 1
                  }
                },
                "additionalProperties": false,
                "required": [
                  "variable",
                  "values"
                ]
              },
              "columnAxis": {
                "type": "object",
                "properties": {
                  "variable": {
                    "type": "string",
                    "enum": [
                      "annual-discount-rate",
                      "perpetual-growth-rate",
                      "exit-multiple"
                    ]
                  },
                  "values": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    },
                    "minItems": 1
                  }
                },
                "additionalProperties": false,
                "required": [
                  "variable",
                  "values"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "rowAxis",
              "columnAxis"
            ],
            "description": "Adds discountedCashFlowSensitivityTable over the same flows when supplied"
          }
        },
        "additionalProperties": false,
        "required": [
          "projection",
          "valuation"
        ]
      },
      "totalfinance.valuation.company.output": {
        "type": "object",
        "properties": {
          "projection": {
            "type": "object",
            "description": "projectFinancialStatements(...) verbatim"
          },
          "cashFlowsUsed": {
            "type": "string",
            "enum": [
              "freeCashFlowToFirm",
              "freeCashFlowToEquity"
            ]
          },
          "valuation": {
            "type": "object",
            "description": "discountedCashFlow(...) verbatim"
          },
          "sensitivity": {
            "type": [
              "object",
              "null"
            ],
            "description": "discountedCashFlowSensitivityTable(...) verbatim, or null when not requested"
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "projection",
          "cashFlowsUsed",
          "valuation",
          "sensitivity",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.valuation.company.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.valuation.company.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.volatility.event.input": {
        "type": "object",
        "properties": {
          "atmVolatility": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Total ATM implied volatility into the event (decimal)"
          },
          "baseVolatility": {
            "type": "number",
            "description": "Baseline (non-event) vol, e.g. post-event or far-month IV (decimal, ≥ 0)"
          },
          "timeToExpiryYears": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Time to expiry in years, e.g. 5/365"
          },
          "realizedVolatility": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "ANNUALIZED realized volatility (decimal, e.g. 0.18 — a per-bar σ × √252 on daily bars) — adds the variance risk premium"
          }
        },
        "additionalProperties": false,
        "required": [
          "atmVolatility",
          "baseVolatility",
          "timeToExpiryYears"
        ]
      },
      "totalfinance.volatility.event.output": {
        "type": "object",
        "properties": {
          "value": {
            "description": "The computed result"
          },
          "assumptions": {
            "type": "object",
            "description": "Every applied convention, echoed"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine/method/warnings (+ convergence where iterative)"
          }
        },
        "required": [
          "value",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.volatility.event.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.volatility.event.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.volatility.expected_move.input": {
        "type": "object",
        "properties": {
          "spot": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "impliedVolatility": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Implied volatility (annualized decimal); with `timeToExpiryYears`, the 1σ move is spot·σ·√timeToExpiryYears"
          },
          "timeToExpiryYears": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Time to expiry in years (required with `impliedVolatility`)"
          },
          "straddlePrice": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "ATM straddle mid-price; when given, the move is implied from the straddle instead of IV"
          }
        },
        "additionalProperties": false,
        "required": [
          "spot"
        ]
      },
      "totalfinance.volatility.expected_move.output": {
        "type": "object",
        "properties": {
          "value": {
            "type": "object",
            "properties": {
              "oneSigma": {
                "type": "number"
              },
              "oneSigmaFraction": {
                "type": "number"
              },
              "expectedAbsolute": {
                "type": "number"
              },
              "lower": {
                "type": "number"
              },
              "upper": {
                "type": "number"
              }
            },
            "required": [
              "oneSigma",
              "oneSigmaFraction",
              "expectedAbsolute",
              "lower",
              "upper"
            ]
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "value"
        ]
      },
      "totalfinance.volatility.expected_move.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.volatility.expected_move.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.volatility.metrics.input": {
        "type": "object",
        "properties": {
          "current": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Current implied volatility (decimal, e.g. 0.22)"
          },
          "history": {
            "type": "array",
            "items": {
              "type": "number",
              "exclusiveMinimum": 0
            },
            "description": "Historical IV series (decimals), e.g. 252 daily ATM IVs"
          }
        },
        "additionalProperties": false,
        "required": [
          "current",
          "history"
        ]
      },
      "totalfinance.volatility.metrics.output": {
        "type": "object",
        "properties": {
          "value": {
            "description": "The computed result"
          },
          "assumptions": {
            "type": "object",
            "description": "Every applied convention, echoed"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine/method/warnings (+ convergence where iterative)"
          }
        },
        "required": [
          "value",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.volatility.metrics.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.volatility.metrics.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.volatility.probability_in_the_money.input": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "call",
              "put"
            ]
          },
          "spot": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "strike": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "timeToExpiryYears": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Time to expiry in years"
          },
          "riskFreeRate": {
            "type": "number",
            "description": "Continuously-compounded risk-free rate (decimal)"
          },
          "volatility": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Implied volatility (annualized decimal)"
          },
          "dividendYield": {
            "type": "number"
          }
        },
        "additionalProperties": false,
        "required": [
          "type",
          "spot",
          "strike",
          "timeToExpiryYears",
          "riskFreeRate",
          "volatility"
        ]
      },
      "totalfinance.volatility.probability_in_the_money.output": {
        "type": "object",
        "properties": {
          "value": {
            "type": "number",
            "description": "Risk-neutral probability in [0, 1]"
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "value"
        ]
      },
      "totalfinance.volatility.probability_in_the_money.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.volatility.probability_in_the_money.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.volatility.probability_of_touch.input": {
        "type": "object",
        "properties": {
          "spot": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "barrier": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "The price level to touch"
          },
          "timeToExpiryYears": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Time to expiry in years"
          },
          "riskFreeRate": {
            "type": "number",
            "description": "Continuously-compounded risk-free rate (decimal)"
          },
          "volatility": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "Implied volatility (annualized decimal)"
          },
          "dividendYield": {
            "type": "number"
          }
        },
        "additionalProperties": false,
        "required": [
          "spot",
          "barrier",
          "timeToExpiryYears",
          "riskFreeRate",
          "volatility"
        ]
      },
      "totalfinance.volatility.probability_of_touch.output": {
        "type": "object",
        "properties": {
          "value": {
            "type": "number",
            "description": "Risk-neutral probability in [0, 1]"
          },
          "assumptions": {
            "type": "object",
            "description": "Applied conventions"
          },
          "diagnostics": {
            "type": "object",
            "description": "Engine, method, warnings"
          }
        },
        "required": [
          "value"
        ]
      },
      "totalfinance.volatility.probability_of_touch.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.volatility.probability_of_touch.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      },
      "totalfinance.volatility.surface.input": {
        "type": "object",
        "properties": {
          "chain": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "strike": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "expiry": {
                  "type": "string",
                  "description": "ISO date YYYY-MM-DD"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "call",
                    "put"
                  ]
                },
                "impliedVolatility": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "description": "Implied volatility (decimal, e.g. 0.22)"
                },
                "price": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "description": "Option mid price (used to imply IV when `impliedVolatility` omitted)"
                }
              },
              "additionalProperties": false,
              "required": [
                "strike",
                "expiry",
                "type"
              ]
            },
            "description": "Chain quotes: one row per contract"
          },
          "spot": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "riskFreeRate": {
            "type": "number",
            "description": "Continuously-compounded risk-free rate (decimal)"
          },
          "asOf": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ],
            "description": "Valuation instant — epoch ms or a zoned ISO datetime such as \"2026-07-20T10:30:00-04:00\". A bare YYYY-MM-DD is refused: a same-day option's value depends on the time of day. For an end-of-day mark use the 16:00 ET close (13:00 ET on early-close days)."
          },
          "dividendYield": {
            "type": "number",
            "description": "Continuous dividend yield (decimal)"
          },
          "model": {
            "type": "string",
            "enum": [
              "interpolated",
              "raw",
              "smoothed",
              "svi",
              "sabr"
            ],
            "description": "Surface model (default interpolated PCHIP; svi/sabr fit parametric smiles)"
          },
          "underlying": {
            "type": "string",
            "description": "Ticker of the chain — REQUIRED, it names every contract"
          },
          "style": {
            "type": "string",
            "enum": [
              "american",
              "european"
            ],
            "description": "Exercise style of every contract in the chain — REQUIRED (listed US equity options are 'american'); the library never defaults it"
          }
        },
        "additionalProperties": false,
        "required": [
          "chain",
          "spot",
          "riskFreeRate",
          "asOf",
          "underlying",
          "style"
        ]
      },
      "totalfinance.volatility.surface.output": {
        "type": "object",
        "properties": {
          "rows": {
            "type": "array",
            "description": "Surface grid rows (expiry × strike × impliedVolatility)"
          },
          "expiries": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "arbitrage": {
            "type": "object",
            "description": "Static-arbitrage report (violations list)"
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object"
          }
        },
        "required": [
          "rows",
          "expiries",
          "arbitrage",
          "assumptions",
          "diagnostics"
        ]
      },
      "totalfinance.volatility.surface.result": {
        "type": "object",
        "description": "runOperation(...) — identity, the structured output (or its spilled handle), assumptions, diagnostics, usage.",
        "properties": {
          "operation": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          },
          "library": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              }
            },
            "required": [
              "version"
            ]
          },
          "summary": {
            "type": "string"
          },
          "structured": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/totalfinance.volatility.surface.output"
              },
              {
                "type": "object",
                "description": "The structured output exceeded the inline byte budget and was stored as a report; read `handle.uri` for the full result.",
                "properties": {
                  "spilled": {
                    "const": true
                  },
                  "handle": {
                    "$ref": "#/components/schemas/ResourceHandle"
                  },
                  "preview": {
                    "type": "object",
                    "description": "Top-level keys with scalars inline and containers summarized by size."
                  }
                },
                "required": [
                  "spilled",
                  "handle",
                  "preview"
                ]
              }
            ]
          },
          "assumptions": {
            "type": "object"
          },
          "diagnostics": {
            "type": "object",
            "properties": {
              "warnings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "context": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "severity"
                  ]
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial"
                ]
              },
              "incomplete": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "warnings",
              "status",
              "incomplete"
            ]
          },
          "identity": {
            "type": "object",
            "properties": {
              "inputsHash": {
                "type": "string"
              },
              "artifactIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "snapshotHash": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "inputsHash",
              "artifactIds",
              "snapshotHash"
            ]
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceHandle"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputBytes": {
                "type": "integer"
              },
              "elapsedMs": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "inputBytes",
              "elapsedMs"
            ]
          },
          "trace": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "requestId"
            ]
          }
        },
        "required": [
          "operation",
          "library",
          "summary",
          "structured",
          "assumptions",
          "diagnostics",
          "identity",
          "artifacts",
          "usage",
          "trace"
        ]
      }
    },
    "securitySchemes": {
      "localBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Server-owned authenticationToken, at least 32 cryptographically random characters. Configure via --token-file or TOTALFINANCE_HTTP_TOKEN; send Authorization: Bearer <token>. Required for enabled writes (including approval), job creation and cancellation. Absent configuration disables job mutations. Read-only analytics remain public. No token is published in this document."
      }
    }
  }
}
