{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://foggy-projects.dev/schemas/deepseek-harness/connection.schema.json",
  "title": "Foggy DeepSeek Harness connection plan",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "name", "type", "namespace"],
  "properties": {
    "schemaVersion": {"const": "foggy-deepseek-connection/v1"},
    "profile": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$"},
    "name": {"type": "string", "minLength": 1},
    "type": {"enum": ["sqlite", "mysql", "postgres", "postgresql"]},
    "jdbcUrl": {"type": "string", "minLength": 1},
    "username": {"type": "string"},
    "passwordEnv": {"type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"},
    "opaqueProfileId": {"type": "string", "pattern": "^fop_[a-f0-9]{32}$"},
    "opaqueRevision": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"},
    "namespace": {"type": "string", "minLength": 1},
    "schemas": {"type": "array", "items": {"type": "string", "minLength": 1}, "uniqueItems": true},
    "modelsDir": {"type": "string", "minLength": 1, "default": "models"},
    "evidenceDir": {"type": "string", "minLength": 1},
    "readOnlyRecommended": {"type": "boolean", "default": true}
  },
  "oneOf": [
    {
      "required": ["opaqueProfileId", "opaqueRevision"],
      "not": {"anyOf": [
        {"required": ["jdbcUrl"]},
        {"required": ["username"]},
        {"required": ["passwordEnv"]}
      ]}
    },
    {
      "required": ["jdbcUrl"],
      "not": {"anyOf": [
        {"required": ["opaqueProfileId"]},
        {"required": ["opaqueRevision"]}
      ]}
    }
  ],
  "allOf": [
    {
      "if": {
        "required": ["jdbcUrl"],
        "properties": {"type": {"not": {"const": "sqlite"}}}
      },
      "then": {"required": ["passwordEnv"]}
    }
  ]
}
