{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ai-akari-ai/json-schema/ai-akari-ai-commerce-marketplace-history-assessment-schema.json",
  "title": "CommerceMarketplaceHistoryAssessment",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/ai-akari-ai-openapi.json#/components/schemas/CommerceMarketplaceHistoryAssessment",
  "type": "object",
  "properties": {
    "version": {
      "type": "string",
      "const": "commerce-marketplace-history-v1"
    },
    "status": {
      "type": "string",
      "const": "completed"
    },
    "mode": {
      "type": "string",
      "const": "historical_only"
    },
    "org_id": {
      "type": "string",
      "format": "uuid"
    },
    "assessment_id": {
      "type": "string",
      "format": "uuid"
    },
    "connection_id": {
      "type": "string",
      "format": "uuid"
    },
    "connection_revision": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "source": {
      "type": "string",
      "enum": [
        "walmart-marketplace",
        "adobe-commerce"
      ]
    },
    "assessed_at": {
      "type": "string",
      "format": "date-time"
    },
    "observed_at": {
      "type": "string",
      "format": "date-time"
    },
    "window": {
      "type": "object",
      "properties": {
        "days": {
          "type": "number",
          "const": 90
        },
        "start_date": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "end_date_exclusive": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "anchor": {
          "type": "string",
          "const": "server_utc_date"
        }
      },
      "required": [
        "days",
        "start_date",
        "end_date_exclusive",
        "anchor"
      ],
      "additionalProperties": false
    },
    "policy": {
      "type": "object",
      "properties": {
        "bundle_id": {
          "type": "string",
          "format": "uuid"
        },
        "version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "policy_digest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "floor_percent": {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        "max_concurrent_discounts": {
          "type": "integer",
          "minimum": 0,
          "maximum": 32
        },
        "price_tolerance_percent": {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        "price_reference": {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "recorded_order_original_price"
            },
            "max_markdown_percent": {
              "type": "number",
              "minimum": 0,
              "maximum": 100
            }
          },
          "required": [
            "kind",
            "max_markdown_percent"
          ],
          "additionalProperties": false
        },
        "comparison": {
          "type": "string",
          "const": "observed_historical_commerce_checks"
        },
        "full_policy_evaluated": {
          "type": "boolean",
          "const": false
        }
      },
      "required": [
        "bundle_id",
        "version",
        "policy_digest",
        "floor_percent",
        "max_concurrent_discounts",
        "price_tolerance_percent",
        "comparison",
        "full_policy_evaluated"
      ],
      "additionalProperties": false
    },
    "cost_scope": {
      "type": "string",
      "const": "merchandise_margin"
    },
    "summary": {
      "type": "object",
      "properties": {
        "documents_scanned": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "documents_returned": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "records_with_findings": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "fully_assessed": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "partially_or_not_assessed": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "undercost": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "below_margin_floor": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "discount_stacking": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "price_discrepancy": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "missing_cost": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "missing_currency": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "missing_discounts": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "missing_price_reference": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        }
      },
      "required": [
        "documents_scanned",
        "documents_returned",
        "records_with_findings",
        "fully_assessed",
        "partially_or_not_assessed",
        "undercost",
        "below_margin_floor",
        "discount_stacking",
        "price_discrepancy",
        "missing_cost",
        "missing_currency",
        "missing_discounts",
        "missing_price_reference"
      ],
      "additionalProperties": false
    },
    "findings": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "record_id": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "transaction_date": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "date_precision": {
            "type": "string",
            "enum": [
              "day",
              "instant"
            ]
          },
          "currency": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              {
                "type": "null"
              }
            ]
          },
          "checks": {
            "type": "object",
            "properties": {
              "undercost": {
                "type": "object",
                "properties": {
                  "result": {
                    "type": "string",
                    "enum": [
                      "finding",
                      "within_rule",
                      "not_assessed"
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "enum": [
                      "UNDER_COST",
                      "AT_OR_ABOVE_COST",
                      "MARGIN_BELOW_FLOOR",
                      "MARGIN_WITHIN_FLOOR",
                      "DISCOUNT_STACKING_REVIEW",
                      "DISCOUNT_STACKING_WITHIN_LIMIT",
                      "PRICE_DISCREPANCY",
                      "PRICE_WITHIN_TOLERANCE",
                      "ORIGINAL_PRICE_MARKDOWN_EXCEEDED",
                      "ORIGINAL_PRICE_MARKDOWN_WITHIN_LIMIT",
                      "HISTORICAL_COST_UNAVAILABLE",
                      "CURRENCY_UNAVAILABLE",
                      "COST_CURRENCY_MISMATCH",
                      "AMOUNT_UNAVAILABLE",
                      "LINES_INCOMPLETE",
                      "DATE_OUTSIDE_WINDOW",
                      "DUPLICATE_RECORD",
                      "DISCOUNT_EVIDENCE_UNAVAILABLE",
                      "PRICE_REFERENCE_UNAVAILABLE",
                      "PRICE_CURRENCY_MISMATCH",
                      "COMPARISON_UNAVAILABLE"
                    ]
                  },
                  "observed": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "threshold": {
                    "type": "number",
                    "minimum": 0
                  },
                  "basis": {
                    "type": "string",
                    "const": "recorded_order_original_price"
                  }
                },
                "required": [
                  "result",
                  "reason",
                  "observed",
                  "threshold"
                ],
                "additionalProperties": false
              },
              "margin": {
                "type": "object",
                "properties": {
                  "result": {
                    "type": "string",
                    "enum": [
                      "finding",
                      "within_rule",
                      "not_assessed"
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "enum": [
                      "UNDER_COST",
                      "AT_OR_ABOVE_COST",
                      "MARGIN_BELOW_FLOOR",
                      "MARGIN_WITHIN_FLOOR",
                      "DISCOUNT_STACKING_REVIEW",
                      "DISCOUNT_STACKING_WITHIN_LIMIT",
                      "PRICE_DISCREPANCY",
                      "PRICE_WITHIN_TOLERANCE",
                      "ORIGINAL_PRICE_MARKDOWN_EXCEEDED",
                      "ORIGINAL_PRICE_MARKDOWN_WITHIN_LIMIT",
                      "HISTORICAL_COST_UNAVAILABLE",
                      "CURRENCY_UNAVAILABLE",
                      "COST_CURRENCY_MISMATCH",
                      "AMOUNT_UNAVAILABLE",
                      "LINES_INCOMPLETE",
                      "DATE_OUTSIDE_WINDOW",
                      "DUPLICATE_RECORD",
                      "DISCOUNT_EVIDENCE_UNAVAILABLE",
                      "PRICE_REFERENCE_UNAVAILABLE",
                      "PRICE_CURRENCY_MISMATCH",
                      "COMPARISON_UNAVAILABLE"
                    ]
                  },
                  "observed": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "threshold": {
                    "type": "number",
                    "minimum": 0
                  },
                  "basis": {
                    "type": "string",
                    "const": "recorded_order_original_price"
                  }
                },
                "required": [
                  "result",
                  "reason",
                  "observed",
                  "threshold"
                ],
                "additionalProperties": false
              },
              "discount_stacking": {
                "type": "object",
                "properties": {
                  "result": {
                    "type": "string",
                    "enum": [
                      "finding",
                      "within_rule",
                      "not_assessed"
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "enum": [
                      "UNDER_COST",
                      "AT_OR_ABOVE_COST",
                      "MARGIN_BELOW_FLOOR",
                      "MARGIN_WITHIN_FLOOR",
                      "DISCOUNT_STACKING_REVIEW",
                      "DISCOUNT_STACKING_WITHIN_LIMIT",
                      "PRICE_DISCREPANCY",
                      "PRICE_WITHIN_TOLERANCE",
                      "ORIGINAL_PRICE_MARKDOWN_EXCEEDED",
                      "ORIGINAL_PRICE_MARKDOWN_WITHIN_LIMIT",
                      "HISTORICAL_COST_UNAVAILABLE",
                      "CURRENCY_UNAVAILABLE",
                      "COST_CURRENCY_MISMATCH",
                      "AMOUNT_UNAVAILABLE",
                      "LINES_INCOMPLETE",
                      "DATE_OUTSIDE_WINDOW",
                      "DUPLICATE_RECORD",
                      "DISCOUNT_EVIDENCE_UNAVAILABLE",
                      "PRICE_REFERENCE_UNAVAILABLE",
                      "PRICE_CURRENCY_MISMATCH",
                      "COMPARISON_UNAVAILABLE"
                    ]
                  },
                  "observed": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "threshold": {
                    "type": "number",
                    "minimum": 0
                  },
                  "basis": {
                    "type": "string",
                    "const": "recorded_order_original_price"
                  }
                },
                "required": [
                  "result",
                  "reason",
                  "observed",
                  "threshold"
                ],
                "additionalProperties": false
              },
              "price_discrepancy": {
                "type": "object",
                "properties": {
                  "result": {
                    "type": "string",
                    "enum": [
                      "finding",
                      "within_rule",
                      "not_assessed"
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "enum": [
                      "UNDER_COST",
                      "AT_OR_ABOVE_COST",
                      "MARGIN_BELOW_FLOOR",
                      "MARGIN_WITHIN_FLOOR",
                      "DISCOUNT_STACKING_REVIEW",
                      "DISCOUNT_STACKING_WITHIN_LIMIT",
                      "PRICE_DISCREPANCY",
                      "PRICE_WITHIN_TOLERANCE",
                      "ORIGINAL_PRICE_MARKDOWN_EXCEEDED",
                      "ORIGINAL_PRICE_MARKDOWN_WITHIN_LIMIT",
                      "HISTORICAL_COST_UNAVAILABLE",
                      "CURRENCY_UNAVAILABLE",
                      "COST_CURRENCY_MISMATCH",
                      "AMOUNT_UNAVAILABLE",
                      "LINES_INCOMPLETE",
                      "DATE_OUTSIDE_WINDOW",
                      "DUPLICATE_RECORD",
                      "DISCOUNT_EVIDENCE_UNAVAILABLE",
                      "PRICE_REFERENCE_UNAVAILABLE",
                      "PRICE_CURRENCY_MISMATCH",
                      "COMPARISON_UNAVAILABLE"
                    ]
                  },
                  "observed": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "threshold": {
                    "type": "number",
                    "minimum": 0
                  },
                  "basis": {
                    "type": "string",
                    "const": "recorded_order_original_price"
                  }
                },
                "required": [
                  "result",
                  "reason",
                  "observed",
                  "threshold"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "undercost",
              "margin",
              "discount_stacking",
              "price_discrepancy"
            ],
            "additionalProperties": false
          },
          "proof_ref": {
            "type": "null"
          }
        },
        "required": [
          "record_id",
          "transaction_date",
          "date_precision",
          "currency",
          "checks",
          "proof_ref"
        ],
        "additionalProperties": false
      },
      "maxItems": 100
    },
    "coverage": {
      "type": "object",
      "properties": {
        "record_limit": {
          "type": "number",
          "const": 100
        },
        "complete": {
          "type": "boolean"
        },
        "truncated": {
          "type": "boolean"
        },
        "reasons": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "document_limit",
              "line_limit",
              "source_incomplete",
              "historical_cost_unavailable",
              "currency_unavailable",
              "amount_unavailable",
              "discount_evidence_unavailable",
              "price_reference_unavailable",
              "duplicate_document",
              "date_excluded",
              "status_excluded"
            ]
          },
          "maxItems": 11
        }
      },
      "required": [
        "record_limit",
        "complete",
        "truncated",
        "reasons"
      ],
      "additionalProperties": false
    },
    "proof_ref": {
      "type": "null"
    },
    "evidence_verification": {
      "type": "string",
      "const": "unsigned"
    },
    "execution_available": {
      "type": "boolean",
      "const": false
    },
    "no_downstream_action_executed": {
      "type": "boolean",
      "const": true
    }
  },
  "required": [
    "version",
    "status",
    "mode",
    "org_id",
    "assessment_id",
    "connection_id",
    "connection_revision",
    "source",
    "assessed_at",
    "observed_at",
    "window",
    "policy",
    "cost_scope",
    "summary",
    "findings",
    "coverage",
    "proof_ref",
    "evidence_verification",
    "execution_available",
    "no_downstream_action_executed"
  ],
  "additionalProperties": false
}