{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://cortex-agent.local/schemas/runtime-state/runtime-layout.schema.json",
  "title": "Runtime Layout Descriptor",
  "description": "Frozen descriptor of the resolver output. Consumers and the MS-002 migration planner MUST consult these segment names instead of hard-coding them. Two layouts with identical identities must describe the same logical structure; absolute paths are confined to per-host sections and may legitimately differ across machines.",
  "type": "object",
  "required": ["schema_version", "segments", "portable_namespaces", "legacy_recognised_segments"],
  "additionalProperties": false,
  "properties": {
    "schema_version": { "type": "string", "minLength": 1 },
    "segments": {
      "type": "object",
      "required": [
        "legacy_runtime",
        "agent_dir",
        "contracts_dir",
        "contracts_runtime_state",
        "runtime_dir",
        "hosts_dir",
        "worktrees_dir",
        "handoffs_dir"
      ],
      "additionalProperties": false,
      "properties": {
        "legacy_runtime": { "const": ".agent-runtime" },
        "agent_dir": { "const": ".agent" },
        "contracts_dir": { "const": "contracts" },
        "contracts_runtime_state": { "const": "contracts/runtime-state" },
        "runtime_dir": { "const": "runtime" },
        "hosts_dir": { "const": "hosts" },
        "worktrees_dir": { "const": "worktrees" },
        "handoffs_dir": { "const": "handoffs" }
      }
    },
    "portable_namespaces": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": ["coordination", "dispatch", "cross-project", "continuity", "evidence"]
      }
    },
    "legacy_recognised_segments": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "coordination",
          "cross-project",
          "dispatch",
          "handoffs",
          "runtime-continuity",
          "runtime-evidence"
        ]
      }
    }
  }
}