{
  "type": "object",
  "properties": {
    "schema_version": {
      "const": "shroom-browser-v2"
    },
    "view_id": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "parent_snapshot_id": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "atlas_snapshot_id": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "generated_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "Z$"
    },
    "evidence_asof": {
      "type": "string",
      "format": "date-time",
      "pattern": "Z$"
    },
    "initial": {
      "type": "object",
      "properties": {
        "encoding": {
          "const": "record-templates-v1"
        },
        "value": {
          "type": "object"
        },
        "tables": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "path": {
                "type": "array",
                "items": {
                  "type": [
                    "string",
                    "integer"
                  ]
                }
              },
              "bases": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "rows": {
                "type": "array",
                "items": {
                  "type": "array",
                  "minItems": 2,
                  "maxItems": 2,
                  "items": [
                    {
                      "type": "integer",
                      "minimum": 0
                    },
                    {
                      "type": "object"
                    }
                  ],
                  "additionalItems": false
                }
              }
            },
            "required": [
              "path",
              "bases",
              "rows"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "encoding",
        "value",
        "tables"
      ],
      "additionalProperties": false
    },
    "details": {
      "type": "object",
      "properties": {
        "parent": {
          "type": "object",
          "properties": {
            "url": {
              "type": "string",
              "pattern": "^data/browser/(parent|atlas)-[a-f0-9]{64}\\.json$"
            },
            "sha256": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "bytes": {
              "type": "integer",
              "minimum": 1,
              "maximum": 134217728
            }
          },
          "required": [
            "url",
            "sha256",
            "bytes"
          ],
          "additionalProperties": false
        },
        "atlas": {
          "type": "object",
          "properties": {
            "url": {
              "type": "string",
              "pattern": "^data/browser/(parent|atlas)-[a-f0-9]{64}\\.json$"
            },
            "sha256": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "bytes": {
              "type": "integer",
              "minimum": 1,
              "maximum": 134217728
            }
          },
          "required": [
            "url",
            "sha256",
            "bytes"
          ],
          "additionalProperties": false
        },
        "treasury": {
          "type": "object",
          "properties": {
            "url": {
              "type": "string",
              "pattern": "^data/treasury/[a-f0-9]{64}\\.json$"
            },
            "sha256": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "bytes": {
              "type": "integer",
              "minimum": 1,
              "maximum": 8388608
            }
          },
          "required": [
            "url",
            "sha256",
            "bytes"
          ],
          "additionalProperties": false
        },
        "pages": {
          "type": "object",
          "properties": {
            "rewards": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "pattern": "^data/pages/[a-f0-9]{64}\\.json$"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "bytes": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 134217728
                }
              },
              "required": [
                "url",
                "sha256",
                "bytes"
              ],
              "additionalProperties": false
            },
            "fees": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "pattern": "^data/pages/[a-f0-9]{64}\\.json$"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "bytes": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 134217728
                }
              },
              "required": [
                "url",
                "sha256",
                "bytes"
              ],
              "additionalProperties": false
            },
            "fees-records": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "pattern": "^data/pages/[a-f0-9]{64}\\.json$"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "bytes": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 134217728
                }
              },
              "required": [
                "url",
                "sha256",
                "bytes"
              ],
              "additionalProperties": false
            },
            "liquidity": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "pattern": "^data/pages/[a-f0-9]{64}\\.json$"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "bytes": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 134217728
                }
              },
              "required": [
                "url",
                "sha256",
                "bytes"
              ],
              "additionalProperties": false
            },
            "liquidity-records": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "pattern": "^data/pages/[a-f0-9]{64}\\.json$"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "bytes": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 134217728
                }
              },
              "required": [
                "url",
                "sha256",
                "bytes"
              ],
              "additionalProperties": false
            },
            "overview": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "pattern": "^data/pages/[a-f0-9]{64}\\.json$"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "bytes": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 134217728
                }
              },
              "required": [
                "url",
                "sha256",
                "bytes"
              ],
              "additionalProperties": false
            },
            "overview-records": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "pattern": "^data/pages/[a-f0-9]{64}\\.json$"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "bytes": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 134217728
                }
              },
              "required": [
                "url",
                "sha256",
                "bytes"
              ],
              "additionalProperties": false
            },
            "learn": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "pattern": "^data/pages/[a-f0-9]{64}\\.json$"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "bytes": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 134217728
                }
              },
              "required": [
                "url",
                "sha256",
                "bytes"
              ],
              "additionalProperties": false
            },
            "status": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "pattern": "^data/pages/[a-f0-9]{64}\\.json$"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "bytes": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 134217728
                }
              },
              "required": [
                "url",
                "sha256",
                "bytes"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "rewards",
            "fees",
            "fees-records",
            "liquidity",
            "liquidity-records",
            "overview",
            "overview-records",
            "learn",
            "status"
          ],
          "additionalProperties": false
        },
        "network": {
          "type": "object",
          "patternProperties": {
            "^[0-9]+:asset:0x[a-f0-9]{40}$": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "pattern": "^data/pages/[a-f0-9]{64}\\.json$"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "bytes": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 134217728
                }
              },
              "required": [
                "url",
                "sha256",
                "bytes"
              ],
              "additionalProperties": false
            }
          },
          "additionalProperties": false
        }
      },
      "required": [
        "parent",
        "atlas"
      ],
      "additionalProperties": false
    },
    "detail_state": {
      "const": "on_demand"
    },
    "limitations": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "schema_version",
    "view_id",
    "parent_snapshot_id",
    "atlas_snapshot_id",
    "generated_at",
    "evidence_asof",
    "initial",
    "details",
    "detail_state",
    "limitations"
  ],
  "additionalProperties": false,
  "definitions": {},
  "$schema": "http://json-schema.org/draft-07/schema#",
  "description": "Expand initial record-templates-v1 by replacing its empty arrays with records merged from JSON.parse(bases[index]) and each row delta. Tables occur in order: parent.history; atlas.assets, pools, positions; then parent.components[i].metrics for every component. Preserve row order and reject duplicate/unknown paths or invalid indices. Encoded initial <= 4 MiB, expanded initial <= 16 MiB; require encoded wire bytes plus cumulative expanded template bytes <= 16 MiB. Validate expanded initial against browser-v1. Canonical full documents remain unchanged."
}
