{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.agoragentic.com/ecf-core/local-config.v1.json",
  "title": "ECF Core Local Config",
  "type": "object",
  "required": ["schema_version", "project_name", "scope", "allow", "block", "tool_limits", "handoff"],
  "additionalProperties": true,
  "properties": {
    "schema_version": { "const": "ecf-core.local-config.v1" },
    "project_name": { "type": "string", "minLength": 1 },
    "scope": { "type": "string", "enum": ["local_project", "self_hosted_workspace", "agent_os_preview"] },
    "allow": { "type": "array", "items": { "type": "string" } },
    "block": { "type": "array", "items": { "type": "string" } },
    "max_file_bytes": { "type": "integer", "minimum": 1024 },
    "adapters": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "filesystem": { "$ref": "#/$defs/adapterToggle" },
        "markdown_docs": { "$ref": "#/$defs/adapterToggle" },
        "sqlite_summary": { "$ref": "#/$defs/adapterToggle" },
        "openapi": { "$ref": "#/$defs/adapterToggle" },
        "mcp_context": { "$ref": "#/$defs/adapterToggle" }
      }
    },
    "context_index_providers": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["provider_id", "type", "mode", "capabilities"],
        "additionalProperties": true,
        "properties": {
          "provider_id": { "type": "string" },
          "type": { "type": "string", "enum": ["page_index", "tree_index", "code_graph", "tool_graph", "policy_graph"] },
          "mode": { "type": "string", "enum": ["local_adapter", "external_import"] },
          "capabilities": { "type": "array", "items": { "type": "string" } },
          "outputs": { "type": "array", "items": { "type": "string" } }
        }
      }
    },
    "eval": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "queries": { "type": "array", "items": { "type": "string" } },
        "top_k": { "type": "integer", "minimum": 1 },
        "semantic_lite": { "type": "boolean" },
        "ranking": {
          "type": "object",
          "additionalProperties": true,
          "properties": {
            "provider": {
              "type": "string",
              "enum": ["semantic_lite", "lexical", "local_vector", "qdrant", "chroma", "gitnexus_code_graph", "mcp_context_provider"]
            },
            "mode": {
              "type": "string",
              "enum": ["semantic_lite", "lexical", "local_vector", "qdrant", "chroma", "gitnexus_code_graph", "mcp_context_provider"]
            },
            "fallback": { "type": "string", "enum": ["semantic_lite", "lexical"] },
            "dimensions": { "type": "integer", "minimum": 8, "maximum": 512 },
            "precomputed_results": {
              "type": "object",
              "additionalProperties": {
                "type": "array",
                "items": {
                  "oneOf": [
                    { "type": "string" },
                    {
                      "type": "object",
                      "additionalProperties": true,
                      "properties": {
                        "id": { "type": "string" },
                        "source_id": { "type": "string" },
                        "path": { "type": "string" },
                        "score": { "type": "number" }
                      }
                    }
                  ]
                }
              }
            }
          }
        },
        "grounding_enabled": { "type": "boolean" },
        "grounding_required": { "type": "boolean" },
        "max_retries": { "type": "integer", "minimum": 0 },
        "rewrite_enabled": { "type": "boolean" },
        "unsupported_response": { "type": "string" },
        "grounding_queries": {
          "type": "array",
          "items": {
            "oneOf": [
              { "type": "string" },
              {
                "type": "object",
                "required": ["question"],
                "additionalProperties": true,
                "properties": {
                  "question": { "type": "string" },
                  "expected_sources": { "type": "array", "items": { "type": "string" } }
                }
              }
            ]
          }
        },
        "compression": {
          "type": "object",
          "additionalProperties": true,
          "properties": {
            "enabled": { "type": "boolean" },
            "max_summary_chars": { "type": "integer", "minimum": 24 }
          }
        }
      }
    },
    "tool_limits": {
      "type": "object",
      "required": ["max_calls", "network_allowed", "write_allowed"],
      "additionalProperties": true,
      "properties": {
        "max_calls": { "type": "integer", "minimum": 0 },
        "network_allowed": { "type": "boolean" },
        "write_allowed": { "type": "boolean" }
      }
    },
    "handoff": {
      "type": "object",
      "required": ["agent_os_preview_allowed", "live_deploy_allowed"],
      "additionalProperties": true,
      "properties": {
        "agent_os_preview_allowed": { "type": "boolean" },
        "live_deploy_allowed": { "const": false }
      }
    }
  },
  "$defs": {
    "adapterToggle": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "enabled": { "type": "boolean" }
      }
    }
  }
}
