{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/opensrm/latest.json",
  "title": "OpenSRM",
  "description": "Open Service Reliability Manifest - Define service reliability requirements as code\n<https://github.com/rsionnach/opensrm>",
  "x-lintel": {
    "source": "https://www.schemastore.org/opensrm.json",
    "sourceSha256": "41f0373fcb26021244b7ac8e99263acb4b831d223cb799af3e8b500229a17880",
    "fileMatch": [
      "service.reliability.yaml",
      "service.reliability.yml",
      "*.reliability.yaml",
      "*.reliability.yml",
      ".opensrm.yaml",
      ".opensrm.yml"
    ],
    "parsers": [
      "yaml"
    ]
  },
  "oneOf": [
    {
      "$ref": "#/$defs/ServiceReliabilityManifest"
    },
    {
      "$ref": "#/$defs/Template"
    }
  ],
  "$defs": {
    "Duration": {
      "type": "string",
      "pattern": "^[0-9]+(ms|s|m|h|d|w)$",
      "description": "Duration format: number followed by ms, s, m, h, d, or w"
    },
    "Ratio": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "description": "Ratio value (0.0 - 1.0)"
    },
    "ServiceType": {
      "type": "string",
      "enum": [
        "api",
        "worker",
        "stream",
        "ai-gate",
        "batch",
        "database"
      ],
      "description": "Service operational pattern\n<https://github.com/rsionnach/opensrm#service-types>"
    },
    "Tier": {
      "type": "string",
      "enum": [
        "critical",
        "high",
        "standard",
        "low"
      ],
      "description": "Service criticality tier"
    },
    "AvailabilitySLO": {
      "type": "object",
      "description": "Availability SLO - measures proportion of successful requests",
      "required": [
        "target"
      ],
      "properties": {
        "target": {
          "$ref": "#/$defs/Ratio",
          "description": "Target availability ratio (e.g., 0.9995 for 99.95%)"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "default": "30d",
          "description": "Measurement window"
        }
      },
      "additionalProperties": false
    },
    "LatencySLO": {
      "type": "object",
      "description": "Latency SLO - measures response time at specified percentiles",
      "required": [
        "target"
      ],
      "anyOf": [
        {
          "required": [
            "p50"
          ]
        },
        {
          "required": [
            "p90"
          ]
        },
        {
          "required": [
            "p95"
          ]
        },
        {
          "required": [
            "p99"
          ]
        },
        {
          "required": [
            "p999"
          ]
        }
      ],
      "properties": {
        "p50": {
          "$ref": "#/$defs/Duration",
          "description": "Target median (50th percentile) latency"
        },
        "p90": {
          "$ref": "#/$defs/Duration",
          "description": "Target 90th percentile latency"
        },
        "p95": {
          "$ref": "#/$defs/Duration",
          "description": "Target 95th percentile latency"
        },
        "p99": {
          "$ref": "#/$defs/Duration",
          "description": "Target 99th percentile latency"
        },
        "p999": {
          "$ref": "#/$defs/Duration",
          "description": "Target 99.9th percentile latency"
        },
        "target": {
          "$ref": "#/$defs/Ratio",
          "description": "Ratio of requests meeting the latency threshold"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "default": "30d",
          "description": "Measurement window"
        }
      },
      "additionalProperties": false
    },
    "ErrorRateSLO": {
      "type": "object",
      "description": "Error rate SLO - measures proportion of failed requests",
      "required": [
        "target"
      ],
      "properties": {
        "target": {
          "$ref": "#/$defs/Ratio",
          "description": "Maximum error ratio (e.g., 0.001 for 0.1%)"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "default": "30d",
          "description": "Measurement window"
        }
      },
      "additionalProperties": false
    },
    "ThroughputSLO": {
      "type": "object",
      "description": "Throughput SLO - measures request processing rate",
      "required": [
        "target",
        "unit"
      ],
      "properties": {
        "target": {
          "type": "number",
          "minimum": 0,
          "description": "Minimum throughput"
        },
        "unit": {
          "type": "string",
          "enum": [
            "rps",
            "rpm",
            "rph"
          ],
          "description": "Throughput unit"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "default": "1h",
          "description": "Measurement window"
        }
      },
      "additionalProperties": false
    },
    "ProcessingTimeSLO": {
      "type": "object",
      "description": "Processing time SLO - job completion time for worker services",
      "required": [
        "target"
      ],
      "anyOf": [
        {
          "required": [
            "p50"
          ]
        },
        {
          "required": [
            "p90"
          ]
        },
        {
          "required": [
            "p95"
          ]
        },
        {
          "required": [
            "p99"
          ]
        }
      ],
      "properties": {
        "p50": {
          "$ref": "#/$defs/Duration",
          "description": "Target median processing time"
        },
        "p90": {
          "$ref": "#/$defs/Duration",
          "description": "Target 90th percentile"
        },
        "p95": {
          "$ref": "#/$defs/Duration",
          "description": "Target 95th percentile"
        },
        "p99": {
          "$ref": "#/$defs/Duration",
          "description": "Target 99th percentile"
        },
        "target": {
          "$ref": "#/$defs/Ratio",
          "description": "Ratio of jobs meeting the time threshold"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "default": "7d",
          "description": "Measurement window"
        }
      },
      "additionalProperties": false
    },
    "LagSLO": {
      "type": "object",
      "description": "Lag SLO - consumer lag for stream services",
      "required": [
        "max_seconds",
        "target"
      ],
      "properties": {
        "max_seconds": {
          "type": "number",
          "minimum": 0,
          "description": "Maximum acceptable lag in seconds"
        },
        "target": {
          "$ref": "#/$defs/Ratio",
          "description": "Ratio of time within lag threshold"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "default": "7d",
          "description": "Measurement window"
        }
      },
      "additionalProperties": false
    },
    "SuccessRateSLO": {
      "type": "object",
      "description": "Success rate SLO - measures proportion of successful operations",
      "required": [
        "target"
      ],
      "properties": {
        "target": {
          "$ref": "#/$defs/Ratio",
          "description": "Target success ratio (e.g., 0.995 for 99.5%)"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "default": "7d",
          "description": "Measurement window"
        }
      },
      "additionalProperties": false
    },
    "DurationSLO": {
      "type": "object",
      "description": "Duration SLO - job execution time for batch services",
      "required": [
        "target"
      ],
      "anyOf": [
        {
          "required": [
            "p50"
          ]
        },
        {
          "required": [
            "p90"
          ]
        },
        {
          "required": [
            "p95"
          ]
        },
        {
          "required": [
            "p99"
          ]
        }
      ],
      "properties": {
        "p50": {
          "$ref": "#/$defs/Duration",
          "description": "Target median duration"
        },
        "p90": {
          "$ref": "#/$defs/Duration",
          "description": "Target 90th percentile"
        },
        "p95": {
          "$ref": "#/$defs/Duration",
          "description": "Target 95th percentile"
        },
        "p99": {
          "$ref": "#/$defs/Duration",
          "description": "Target 99th percentile"
        },
        "target": {
          "$ref": "#/$defs/Ratio",
          "description": "Ratio of jobs meeting threshold"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "default": "30d",
          "description": "Measurement window"
        }
      },
      "additionalProperties": false
    },
    "ScheduleAdherenceSLO": {
      "type": "object",
      "description": "Schedule adherence SLO - measures timeliness of batch job starts",
      "required": [
        "max_delay"
      ],
      "properties": {
        "max_delay": {
          "$ref": "#/$defs/Duration",
          "description": "Maximum acceptable delay from scheduled start time"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "default": "7d",
          "description": "Measurement window"
        }
      },
      "additionalProperties": false
    },
    "DataFreshnessSLO": {
      "type": "object",
      "description": "Data freshness SLO - measures staleness of batch output data",
      "required": [
        "max_age"
      ],
      "properties": {
        "max_age": {
          "$ref": "#/$defs/Duration",
          "description": "Maximum acceptable age of output data"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "default": "7d",
          "description": "Measurement window"
        }
      },
      "additionalProperties": false
    },
    "QueryLatencySLO": {
      "type": "object",
      "description": "Query latency SLO - response time for database services",
      "required": [
        "target"
      ],
      "anyOf": [
        {
          "required": [
            "p50"
          ]
        },
        {
          "required": [
            "p90"
          ]
        },
        {
          "required": [
            "p95"
          ]
        },
        {
          "required": [
            "p99"
          ]
        },
        {
          "required": [
            "p999"
          ]
        }
      ],
      "properties": {
        "p50": {
          "$ref": "#/$defs/Duration",
          "description": "Target median query latency"
        },
        "p90": {
          "$ref": "#/$defs/Duration",
          "description": "Target 90th percentile"
        },
        "p95": {
          "$ref": "#/$defs/Duration",
          "description": "Target 95th percentile"
        },
        "p99": {
          "$ref": "#/$defs/Duration",
          "description": "Target 99th percentile"
        },
        "p999": {
          "$ref": "#/$defs/Duration",
          "description": "Target 99.9th percentile"
        },
        "target": {
          "$ref": "#/$defs/Ratio",
          "description": "Ratio of queries meeting threshold"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "default": "30d",
          "description": "Measurement window"
        }
      },
      "additionalProperties": false
    },
    "ReplicationLagSLO": {
      "type": "object",
      "description": "Replication lag SLO for database services",
      "required": [
        "max_lag"
      ],
      "properties": {
        "max_lag": {
          "type": "string",
          "pattern": "^[0-9]+(ms|s|m)$",
          "description": "Maximum acceptable replication lag (e.g., 1s, 500ms, 5m)"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "default": "30d",
          "description": "Measurement window"
        }
      },
      "additionalProperties": false
    },
    "ConnectionAvailabilitySLO": {
      "type": "object",
      "description": "Connection availability SLO for database services",
      "required": [
        "target"
      ],
      "properties": {
        "target": {
          "$ref": "#/$defs/Ratio",
          "description": "Target connection availability ratio (e.g., 0.9999 for 99.99%)"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "default": "30d",
          "description": "Measurement window"
        }
      },
      "additionalProperties": false
    },
    "ReversalRateSLO": {
      "type": "object",
      "description": "Reversal rate SLO - measures how often humans override AI decisions\n<https://github.com/rsionnach/opensrm#judgment-slos>",
      "required": [
        "target",
        "window"
      ],
      "properties": {
        "target": {
          "$ref": "#/$defs/Ratio",
          "description": "Maximum reversal ratio (e.g., 0.05 for 5%)"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "description": "SLO evaluation window"
        },
        "observation_period": {
          "$ref": "#/$defs/Duration",
          "default": "24h",
          "description": "Time to wait for reversals after a decision"
        }
      },
      "additionalProperties": false
    },
    "HighConfidenceFailureSLO": {
      "type": "object",
      "description": "High-confidence failure SLO - measures rate of confident but wrong decisions\n<https://github.com/rsionnach/opensrm#judgment-slos>",
      "required": [
        "target",
        "window"
      ],
      "properties": {
        "target": {
          "$ref": "#/$defs/Ratio",
          "description": "Maximum HCF ratio (e.g., 0.02 for 2%)"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "description": "SLO evaluation window"
        },
        "confidence_threshold": {
          "$ref": "#/$defs/Ratio",
          "default": 0.9,
          "description": "What counts as high confidence"
        }
      },
      "additionalProperties": false
    },
    "CalibrationSLO": {
      "type": "object",
      "description": "Calibration SLO - measures if stated confidence matches actual accuracy (ECE)\n<https://github.com/rsionnach/opensrm#judgment-slos>",
      "required": [
        "target",
        "window"
      ],
      "properties": {
        "target": {
          "$ref": "#/$defs/Ratio",
          "description": "Maximum Expected Calibration Error (e.g., 0.15)"
        },
        "window": {
          "$ref": "#/$defs/Duration",
          "description": "SLO evaluation window"
        }
      },
      "additionalProperties": false
    },
    "FeedbackLatencySLO": {
      "type": "object",
      "description": "Feedback latency SLO - measures time until decision quality is known\n<https://github.com/rsionnach/opensrm#judgment-slos>",
      "properties": {
        "p50": {
          "$ref": "#/$defs/Duration",
          "description": "Target for median feedback latency"
        },
        "p90": {
          "$ref": "#/$defs/Duration",
          "description": "Target for 90th percentile feedback latency"
        }
      },
      "anyOf": [
        {
          "required": [
            "p50"
          ]
        },
        {
          "required": [
            "p90"
          ]
        }
      ],
      "additionalProperties": false
    },
    "JudgmentSLOs": {
      "type": "object",
      "description": "Judgment SLOs for AI gate services - measure decision quality\n<https://github.com/rsionnach/opensrm#judgment-slos>",
      "properties": {
        "reversal_rate": {
          "$ref": "#/$defs/ReversalRateSLO"
        },
        "high_confidence_failure": {
          "$ref": "#/$defs/HighConfidenceFailureSLO"
        },
        "calibration": {
          "$ref": "#/$defs/CalibrationSLO"
        },
        "feedback_latency": {
          "$ref": "#/$defs/FeedbackLatencySLO"
        }
      },
      "additionalProperties": false
    },
    "SLOs": {
      "type": "object",
      "description": "Service Level Objectives",
      "properties": {
        "availability": {
          "$ref": "#/$defs/AvailabilitySLO"
        },
        "latency": {
          "$ref": "#/$defs/LatencySLO"
        },
        "error_rate": {
          "$ref": "#/$defs/ErrorRateSLO"
        },
        "throughput": {
          "$ref": "#/$defs/ThroughputSLO"
        },
        "processing_time": {
          "$ref": "#/$defs/ProcessingTimeSLO"
        },
        "lag": {
          "$ref": "#/$defs/LagSLO"
        },
        "success_rate": {
          "$ref": "#/$defs/SuccessRateSLO"
        },
        "duration": {
          "$ref": "#/$defs/DurationSLO"
        },
        "schedule_adherence": {
          "$ref": "#/$defs/ScheduleAdherenceSLO"
        },
        "data_freshness": {
          "$ref": "#/$defs/DataFreshnessSLO"
        },
        "query_latency": {
          "$ref": "#/$defs/QueryLatencySLO"
        },
        "replication_lag": {
          "$ref": "#/$defs/ReplicationLagSLO"
        },
        "connection_availability": {
          "$ref": "#/$defs/ConnectionAvailabilitySLO"
        },
        "openslo": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "path"
            ],
            "properties": {
              "path": {
                "type": "string",
                "description": "Path to OpenSLO file"
              }
            },
            "additionalProperties": false
          },
          "description": "References to external OpenSLO files"
        },
        "custom": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "name",
              "target"
            ],
            "properties": {
              "name": {
                "type": "string",
                "description": "Custom SLO name"
              },
              "target": {
                "type": "number",
                "description": "Target value"
              },
              "unit": {
                "type": "string",
                "description": "Unit of measurement"
              },
              "description": {
                "type": "string",
                "description": "Human-readable description"
              }
            },
            "additionalProperties": false
          },
          "description": "Custom SLO types"
        },
        "judgment": {
          "$ref": "#/$defs/JudgmentSLOs"
        }
      },
      "additionalProperties": false
    },
    "ContractLatency": {
      "type": "object",
      "description": "Latency guarantees in a contract",
      "properties": {
        "p50": {
          "$ref": "#/$defs/Duration",
          "description": "Promised median latency"
        },
        "p99": {
          "$ref": "#/$defs/Duration",
          "description": "Promised 99th percentile latency"
        },
        "p999": {
          "$ref": "#/$defs/Duration",
          "description": "Promised 99.9th percentile latency"
        }
      },
      "additionalProperties": false
    },
    "ContractThroughput": {
      "type": "object",
      "description": "Throughput guarantees in a contract",
      "properties": {
        "max_rps": {
          "type": "integer",
          "minimum": 1,
          "description": "Maximum sustained requests per second"
        },
        "burst": {
          "type": "integer",
          "minimum": 1,
          "description": "Maximum burst capacity"
        }
      },
      "additionalProperties": false
    },
    "ContractJudgment": {
      "type": "object",
      "description": "Judgment guarantees in a contract for AI gate services",
      "properties": {
        "max_reversal_rate": {
          "$ref": "#/$defs/Ratio",
          "description": "Maximum promised reversal rate"
        },
        "max_hcf_rate": {
          "$ref": "#/$defs/Ratio",
          "description": "Maximum promised high-confidence failure rate"
        },
        "max_feedback_latency": {
          "$ref": "#/$defs/Duration",
          "description": "Maximum promised feedback latency"
        }
      },
      "additionalProperties": false
    },
    "Contract": {
      "type": "object",
      "description": "Reliability guarantees promised to dependents\n<https://github.com/rsionnach/opensrm#contracts>",
      "properties": {
        "availability": {
          "$ref": "#/$defs/Ratio",
          "description": "Promised uptime ratio"
        },
        "latency": {
          "$ref": "#/$defs/ContractLatency"
        },
        "throughput": {
          "$ref": "#/$defs/ContractThroughput"
        },
        "judgment": {
          "$ref": "#/$defs/ContractJudgment"
        }
      },
      "additionalProperties": false
    },
    "Dependency": {
      "type": "object",
      "description": "Upstream dependency and expected guarantees",
      "required": [
        "service"
      ],
      "properties": {
        "service": {
          "type": "string",
          "description": "Dependency identifier (service name)"
        },
        "type": {
          "type": "string",
          "enum": [
            "service",
            "database",
            "cache",
            "queue",
            "external"
          ],
          "description": "Type of dependency"
        },
        "critical": {
          "type": "boolean",
          "default": true,
          "description": "Whether failure causes service failure"
        },
        "expects": {
          "type": "object",
          "description": "Expected guarantees from dependency",
          "properties": {
            "availability": {
              "$ref": "#/$defs/Ratio",
              "description": "Expected availability ratio"
            },
            "latency": {
              "type": "object",
              "properties": {
                "p99": {
                  "$ref": "#/$defs/Duration",
                  "description": "Expected 99th percentile latency"
                }
              },
              "additionalProperties": false
            }
          },
          "additionalProperties": false
        },
        "manifest": {
          "type": "string",
          "format": "uri",
          "description": "URL to dependency's SRM manifest"
        }
      },
      "additionalProperties": false
    },
    "Ownership": {
      "type": "object",
      "description": "Service ownership information",
      "required": [
        "team"
      ],
      "properties": {
        "team": {
          "type": "string",
          "description": "Team identifier"
        },
        "slack": {
          "type": "string",
          "description": "Slack channel for alerts (e.g., '#team-oncall')"
        },
        "email": {
          "type": "string",
          "format": "email",
          "description": "Team email address"
        },
        "escalation": {
          "type": "string",
          "description": "On-call rotation or escalation policy name"
        },
        "pagerduty": {
          "type": "object",
          "description": "PagerDuty integration",
          "properties": {
            "service_id": {
              "type": "string",
              "description": "PagerDuty service ID"
            },
            "escalation_policy_id": {
              "type": "string",
              "description": "PagerDuty escalation policy ID"
            }
          },
          "additionalProperties": false
        },
        "runbook": {
          "type": "string",
          "format": "uri",
          "description": "URL to operational runbook"
        },
        "documentation": {
          "type": "string",
          "format": "uri",
          "description": "URL to service documentation"
        },
        "oncall_required": {
          "type": "boolean",
          "description": "Whether on-call rotation is required"
        }
      },
      "additionalProperties": false
    },
    "Instrumentation": {
      "type": "object",
      "description": "Telemetry configuration for AI gate services",
      "required": [
        "events"
      ],
      "properties": {
        "events": {
          "type": "object",
          "description": "Event name mappings",
          "required": [
            "decision",
            "reversal"
          ],
          "properties": {
            "decision": {
              "type": "string",
              "description": "Event name emitted when AI makes a decision"
            },
            "reversal": {
              "type": "string",
              "description": "Event name emitted when a decision is overridden"
            },
            "outcome": {
              "type": "string",
              "description": "Event name emitted when ground truth is known"
            }
          },
          "additionalProperties": false
        },
        "attributes": {
          "type": "object",
          "description": "Attribute name mappings",
          "properties": {
            "decision_id": {
              "type": "string",
              "default": "decision_id",
              "description": "Field name for decision identifier"
            },
            "confidence": {
              "type": "string",
              "default": "confidence",
              "description": "Field name for confidence score"
            },
            "decision": {
              "type": "string",
              "default": "decision",
              "description": "Field name for decision value"
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "Observability": {
      "type": "object",
      "description": "Observability requirements",
      "properties": {
        "metrics": {
          "type": "object",
          "description": "Metric requirements",
          "properties": {
            "required": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Metric names that must exist"
            },
            "labels": {
              "type": "object",
              "properties": {
                "required": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "Labels that must be present"
                }
              },
              "additionalProperties": false
            },
            "convention": {
              "type": "string",
              "enum": [
                "opentelemetry",
                "prometheus"
              ],
              "default": "opentelemetry",
              "description": "Metric naming convention"
            }
          },
          "additionalProperties": false
        },
        "dashboards": {
          "type": "object",
          "description": "Dashboard requirements",
          "properties": {
            "required": {
              "type": "boolean",
              "description": "Whether dashboards must exist"
            },
            "urls": {
              "type": "array",
              "items": {
                "type": "string",
                "format": "uri"
              },
              "description": "URLs to service dashboards"
            }
          },
          "additionalProperties": false
        },
        "alerts": {
          "type": "object",
          "description": "Alert requirements",
          "properties": {
            "required": {
              "type": "boolean",
              "description": "Whether alerts must be configured"
            },
            "definitions": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "name",
                  "severity"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Alert name"
                  },
                  "severity": {
                    "type": "string",
                    "enum": [
                      "critical",
                      "warning",
                      "info"
                    ],
                    "description": "Alert severity"
                  },
                  "threshold": {
                    "type": "string",
                    "description": "Human-readable threshold description"
                  }
                },
                "additionalProperties": false
              }
            }
          },
          "additionalProperties": false
        },
        "tracing": {
          "type": "object",
          "description": "Distributed tracing requirements",
          "properties": {
            "required": {
              "type": "boolean",
              "description": "Whether distributed tracing must be enabled"
            },
            "sampling_rate": {
              "type": "number",
              "minimum": 0,
              "maximum": 1,
              "description": "Expected sampling rate (0.0 - 1.0)"
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "Deployment": {
      "type": "object",
      "description": "Deployment requirements",
      "properties": {
        "environments": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Environments where service is deployed"
        },
        "gates": {
          "type": "object",
          "description": "Deployment gates",
          "additionalProperties": true,
          "properties": {
            "error_budget": {
              "type": "object",
              "properties": {
                "enabled": {
                  "type": "boolean"
                },
                "threshold": {
                  "type": "number"
                }
              },
              "additionalProperties": false
            },
            "slo_compliance": {
              "type": "object",
              "properties": {
                "enabled": {
                  "type": "boolean"
                },
                "min_compliance": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1
                }
              },
              "additionalProperties": false
            },
            "recent_incidents": {
              "type": "object",
              "properties": {
                "enabled": {
                  "type": "boolean"
                },
                "lookback": {
                  "$ref": "#/$defs/Duration"
                },
                "max_p1": {
                  "type": "integer",
                  "minimum": 0
                },
                "max_p2": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "additionalProperties": false
            }
          },
          "patternProperties": {
            "^x-": {
              "type": "object",
              "description": "Custom deployment gates"
            }
          }
        },
        "rollback": {
          "type": "object",
          "description": "Rollback configuration",
          "properties": {
            "automatic": {
              "type": "boolean",
              "description": "Whether automatic rollback is enabled"
            },
            "criteria": {
              "type": "object",
              "properties": {
                "error_rate_increase": {
                  "type": "string",
                  "description": "Error rate increase threshold"
                },
                "latency_increase": {
                  "type": "string",
                  "description": "Latency increase threshold"
                }
              },
              "additionalProperties": false
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "Metadata": {
      "type": "object",
      "description": "Service identity and classification",
      "required": [
        "name",
        "team",
        "tier"
      ],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[a-z0-9-]+$",
          "description": "Unique service identifier (lowercase alphanumeric with hyphens)"
        },
        "team": {
          "type": "string",
          "description": "Owning team identifier"
        },
        "tier": {
          "$ref": "#/$defs/Tier",
          "description": "Service criticality level"
        },
        "template": {
          "type": "string",
          "description": "Name of template to inherit from"
        },
        "description": {
          "type": "string",
          "description": "Human-readable description"
        },
        "labels": {
          "type": "object",
          "description": "Key-value pairs for filtering/grouping",
          "additionalProperties": {
            "type": "string"
          }
        },
        "annotations": {
          "type": "object",
          "description": "Arbitrary metadata (not used for selection)",
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    },
    "TemplateMetadata": {
      "type": "object",
      "description": "Template identity",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[a-z0-9-]+$",
          "description": "Unique template identifier"
        },
        "description": {
          "type": "string",
          "description": "Human-readable description"
        }
      },
      "additionalProperties": false
    },
    "Spec": {
      "type": "object",
      "description": "Reliability requirements",
      "properties": {
        "type": {
          "$ref": "#/$defs/ServiceType"
        },
        "slos": {
          "$ref": "#/$defs/SLOs"
        },
        "contract": {
          "$ref": "#/$defs/Contract"
        },
        "instrumentation": {
          "$ref": "#/$defs/Instrumentation"
        },
        "dependencies": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Dependency"
          },
          "description": "Upstream dependencies"
        },
        "ownership": {
          "$ref": "#/$defs/Ownership"
        },
        "observability": {
          "$ref": "#/$defs/Observability"
        },
        "deployment": {
          "$ref": "#/$defs/Deployment"
        }
      },
      "additionalProperties": false
    },
    "TemplateSpec": {
      "type": "object",
      "description": "Partial spec for template inheritance",
      "properties": {
        "type": {
          "$ref": "#/$defs/ServiceType"
        },
        "slos": {
          "$ref": "#/$defs/SLOs"
        },
        "ownership": {
          "$ref": "#/$defs/Ownership"
        },
        "instrumentation": {
          "$ref": "#/$defs/Instrumentation"
        }
      },
      "additionalProperties": false
    },
    "ServiceReliabilityManifest": {
      "type": "object",
      "description": "Service Reliability Manifest - defines reliability requirements for a service",
      "required": [
        "apiVersion",
        "kind",
        "metadata",
        "spec"
      ],
      "properties": {
        "apiVersion": {
          "type": "string",
          "const": "srm/v1",
          "description": "Schema version. Must be srm/v1"
        },
        "kind": {
          "type": "string",
          "const": "ServiceReliabilityManifest",
          "description": "Document type"
        },
        "metadata": {
          "$ref": "#/$defs/Metadata"
        },
        "spec": {
          "$ref": "#/$defs/Spec"
        }
      },
      "additionalProperties": false
    },
    "Template": {
      "type": "object",
      "description": "Reusable template for service reliability manifests",
      "required": [
        "apiVersion",
        "kind",
        "metadata",
        "spec"
      ],
      "properties": {
        "apiVersion": {
          "type": "string",
          "const": "srm/v1",
          "description": "Schema version. Must be srm/v1"
        },
        "kind": {
          "type": "string",
          "const": "Template",
          "description": "Document type"
        },
        "metadata": {
          "$ref": "#/$defs/TemplateMetadata"
        },
        "spec": {
          "$ref": "#/$defs/TemplateSpec"
        }
      },
      "additionalProperties": false
    }
  }
}
