{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:atlas:file:1",
  "title": "Atlas File v1",
  "description": "Portable .ospec and legacy .atlas envelope grammar. atlas-validate.mjs also validates references, feature scopes, layouts and duplicate keys.",
  "type": "object",
  "required": [
    "schemaVersion",
    "model",
    "presentation"
  ],
  "properties": {
    "schemaVersion": {
      "const": "atlas.file/1"
    },
    "requires": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "enum": [
          "model-v1",
          "presentation-v1",
          "exact-column-links",
          "requirements",
          "evidence",
          "feature-lenses-v1"
        ]
      }
    },
    "model": {
      "$ref": "urn:atlas:model:1"
    },
    "presentation": {
      "$ref": "#/$defs/presentation"
    },
    "extensions": {
      "type": "object",
      "properties": {
        "oneview.features": {
          "$ref": "#/$defs/features"
        }
      }
    }
  },
  "$defs": {
    "hex": {
      "type": "string",
      "pattern": "^#[0-9a-fA-F]{6}$"
    },
    "presentation": {
      "type": "object",
      "required": [
        "theme",
        "layers"
      ],
      "properties": {
        "theme": {
          "$ref": "#/$defs/theme"
        },
        "layers": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/layer"
          }
        },
        "layout": {
          "$ref": "#/$defs/layout"
        },
        "canvas": {
          "$ref": "#/$defs/canvas"
        },
        "featureLayouts": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/layout"
          }
        }
      }
    },
    "theme": {
      "type": "object",
      "required": [
        "schemaVersion",
        "tokens"
      ],
      "properties": {
        "schemaVersion": {
          "const": "atlas.theme/1"
        },
        "tokens": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "background",
            "panel",
            "card",
            "row",
            "text",
            "muted",
            "border",
            "accent",
            "header",
            "headerText",
            "typeText",
            "architecture",
            "behavior",
            "interaction",
            "runtime",
            "data",
            "specification",
            "external",
            "fontSize",
            "rowHeight",
            "radius"
          ],
          "properties": {
            "background": {
              "$ref": "#/$defs/hex"
            },
            "panel": {
              "$ref": "#/$defs/hex"
            },
            "card": {
              "$ref": "#/$defs/hex"
            },
            "row": {
              "$ref": "#/$defs/hex"
            },
            "text": {
              "$ref": "#/$defs/hex"
            },
            "muted": {
              "$ref": "#/$defs/hex"
            },
            "border": {
              "$ref": "#/$defs/hex"
            },
            "accent": {
              "$ref": "#/$defs/hex"
            },
            "header": {
              "$ref": "#/$defs/hex"
            },
            "headerText": {
              "$ref": "#/$defs/hex"
            },
            "typeText": {
              "$ref": "#/$defs/hex"
            },
            "architecture": {
              "$ref": "#/$defs/hex"
            },
            "behavior": {
              "$ref": "#/$defs/hex"
            },
            "interaction": {
              "$ref": "#/$defs/hex"
            },
            "runtime": {
              "$ref": "#/$defs/hex"
            },
            "data": {
              "$ref": "#/$defs/hex"
            },
            "specification": {
              "$ref": "#/$defs/hex"
            },
            "external": {
              "$ref": "#/$defs/hex"
            },
            "fontSize": {
              "type": "number",
              "minimum": 11,
              "maximum": 18
            },
            "rowHeight": {
              "type": "number",
              "minimum": 20,
              "maximum": 36
            },
            "radius": {
              "type": "number",
              "minimum": 0,
              "maximum": 20
            }
          }
        },
        "groups": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/hex"
          }
        }
      }
    },
    "layer": {
      "type": "object",
      "required": [
        "kind",
        "label",
        "color",
        "glyph"
      ],
      "properties": {
        "kind": {
          "enum": [
            "map",
            "flow",
            "sequence",
            "deployment",
            "tables",
            "spec"
          ]
        },
        "label": {
          "type": "string",
          "minLength": 1
        },
        "color": {
          "$ref": "#/$defs/hex"
        },
        "glyph": {
          "enum": [
            "agent-tool",
            "agent",
            "anchor",
            "api-contract",
            "api-gateway",
            "api-token",
            "audit-log",
            "backup",
            "batch-job",
            "cache",
            "cdn",
            "certificate",
            "cloud",
            "column",
            "commit",
            "consumer",
            "container-pod",
            "container",
            "data-warehouse",
            "database",
            "dead-letter-queue",
            "dns",
            "document-store",
            "edge-worker",
            "event-bus",
            "event-stream",
            "evidence",
            "external-system",
            "firewall",
            "fit-view",
            "foreign-key",
            "graph-database",
            "identity-provider",
            "index",
            "inspect",
            "key-value-store",
            "kubernetes-cluster",
            "layers",
            "load-balancer",
            "lock",
            "log",
            "mcp-server",
            "metric",
            "migration",
            "network",
            "object-storage",
            "organization",
            "physical-server",
            "primary-key",
            "private-host",
            "process",
            "producer",
            "queue",
            "relational-table",
            "relationship",
            "replica",
            "requirement",
            "retry",
            "reverse-proxy",
            "role",
            "scheduler",
            "search-index",
            "secret",
            "secure-tunnel",
            "serverless",
            "service",
            "share-link",
            "source-code",
            "source-file",
            "stateful-actor",
            "subnet",
            "subscription",
            "team",
            "test",
            "time-series-store",
            "topic",
            "trace",
            "unlock",
            "user",
            "vector-store",
            "version-diff",
            "virtual-machine",
            "volume",
            "webhook",
            "workflow",
            "workspace"
          ]
        }
      }
    },
    "layout": {
      "type": "object",
      "required": [
        "schemaVersion",
        "product",
        "views"
      ],
      "properties": {
        "schemaVersion": {
          "const": "atlas.layout/1"
        },
        "product": {
          "type": "string",
          "minLength": 1
        },
        "views": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/layoutView"
          }
        },
        "spatial": {
          "$ref": "#/$defs/spatial"
        }
      }
    },
    "layoutView": {
      "type": "object",
      "required": [
        "positions"
      ],
      "properties": {
        "positions": {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "minItems": 2,
            "maxItems": 2,
            "items": {
              "type": "number"
            }
          }
        },
        "camera": {
          "$ref": "#/$defs/camera"
        }
      }
    },
    "camera": {
      "type": "object",
      "properties": {
        "x": {
          "type": "number"
        },
        "y": {
          "type": "number"
        },
        "z": {
          "type": "number"
        }
      }
    },
    "spatial": {
      "type": "object",
      "required": [
        "version",
        "cameras"
      ],
      "properties": {
        "version": {
          "const": 1
        },
        "cameras": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/spatialCamera"
          }
        }
      }
    },
    "spatialCamera": {
      "type": "object",
      "properties": {
        "x": {
          "type": "number"
        },
        "y": {
          "type": "number"
        },
        "z": {
          "type": "number"
        },
        "distance": {
          "type": "number"
        },
        "yaw": {
          "type": "number"
        },
        "tilt": {
          "type": "number"
        }
      }
    },
    "canvas": {
      "type": "object",
      "properties": {
        "columns": {
          "enum": [
            "compact",
            "keys",
            "all"
          ]
        },
        "motionMs": {
          "type": "integer",
          "minimum": 0,
          "maximum": 2000
        },
        "overviewTitle": {
          "type": "string",
          "minLength": 1
        },
        "overviewSummary": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "feature": {
      "type": "object",
      "required": [
        "id",
        "title",
        "summary",
        "entryView",
        "entities",
        "relations",
        "views",
        "requirements",
        "evidence"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "summary": {
          "type": "string",
          "minLength": 1
        },
        "entryView": {
          "type": "string",
          "minLength": 1
        },
        "entities": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "relations": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "views": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "requirements": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "evidence": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        }
      }
    },
    "features": {
      "type": "object",
      "required": [
        "schemaVersion",
        "features"
      ],
      "properties": {
        "schemaVersion": {
          "const": "oneview.features/1"
        },
        "features": {
          "type": "array",
          "maxItems": 500,
          "items": {
            "$ref": "#/$defs/feature"
          }
        }
      }
    }
  }
}
