{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://agoragentic.com/schema/local-inference-pack.v1.json",
  "title": "Agent OS Local Inference Pack v1",
  "description": "Optional Local Harness policy artifact for routing low-risk cognition to a local model while Agent OS keeps context, tools, approvals, receipts, budgets, escalation, exposure, and runtime authority.",
  "type": "object",
  "required": [
    "schema",
    "pack_id",
    "name",
    "version",
    "mode",
    "provider",
    "limits",
    "policy",
    "receipt_policy",
    "decision_contract",
    "authority_boundary"
  ],
  "properties": {
    "schema": {
      "const": "agoragentic.agent-os.local-inference-pack.v1"
    },
    "pack_id": { "type": "string", "minLength": 1 },
    "name": { "type": "string", "minLength": 1 },
    "version": { "type": "string", "minLength": 1 },
    "mode": {
      "type": "string",
      "enum": ["disabled", "mock", "ollama", "openai_compatible", "local_http"]
    },
    "provider": {
      "type": "object",
      "required": ["mode", "model", "allowed_hosts", "allow_non_local_endpoints", "timeout_ms"],
      "properties": {
        "mode": {
          "type": "string",
          "enum": ["disabled", "mock", "ollama", "openai_compatible", "local_http"]
        },
        "model": { "type": "string", "minLength": 1 },
        "endpoint_url": {
          "type": ["string", "null"]
        },
        "allowed_hosts": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string", "minLength": 1 }
        },
        "allow_non_local_endpoints": { "type": "boolean" },
        "timeout_ms": { "type": "integer", "minimum": 1 }
      },
      "additionalProperties": false
    },
    "limits": {
      "type": "object",
      "required": ["max_input_tokens", "max_context_tokens", "max_output_tokens"],
      "properties": {
        "max_input_tokens": { "type": "integer", "minimum": 1 },
        "max_context_tokens": { "type": "integer", "minimum": 1 },
        "max_output_tokens": { "type": "integer", "minimum": 1 }
      },
      "additionalProperties": false
    },
    "policy": {
      "type": "object",
      "required": [
        "allowed_task_classes",
        "allowed_context_layers",
        "source_qa_requires_citations",
        "coding_explanation_only",
        "finance_research",
        "web_research",
        "low_confidence_threshold",
        "external_cost_policy",
        "escalate_when"
      ],
      "properties": {
        "allowed_task_classes": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": ["chat", "summarize", "source_qa", "coding", "finance_research", "web_research", "route", "unknown"]
          }
        },
        "allowed_context_layers": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": ["none", "micro_ecf", "ecf_core", "owner_provided_docs", "repository_files"]
          }
        },
        "source_qa_requires_citations": { "type": "boolean" },
        "coding_explanation_only": { "const": true },
        "finance_research": {
          "type": "object",
          "required": ["read_only_only", "live_data_escalates", "personalized_advice_rejected"],
          "properties": {
            "read_only_only": { "const": true },
            "live_data_escalates": { "const": true },
            "personalized_advice_rejected": { "const": true }
          },
          "additionalProperties": true
        },
        "web_research": {
          "type": "object",
          "required": ["governed_tool_path_required"],
          "properties": {
            "governed_tool_path_required": { "const": true }
          },
          "additionalProperties": true
        },
        "low_confidence_threshold": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "external_cost_policy": {
          "type": "string",
          "enum": ["owner_approval_required", "budget_policy_required"]
        },
        "escalate_when": {
          "type": "array",
          "items": { "type": "string", "minLength": 1 }
        }
      },
      "additionalProperties": true
    },
    "receipt_policy": {
      "type": "object",
      "required": ["receipt_required", "store_raw_prompt", "store_raw_output", "redact_inputs", "redact_outputs", "estimate_token_savings"],
      "properties": {
        "receipt_required": { "const": true },
        "store_raw_prompt": { "const": false },
        "store_raw_output": { "const": false },
        "redact_inputs": { "const": true },
        "redact_outputs": { "const": true },
        "estimate_token_savings": { "const": true },
        "baseline_model": { "type": "string" }
      },
      "additionalProperties": true
    },
    "decision_contract": {
      "type": "object",
      "required": [
        "decision",
        "task_class",
        "risk_level",
        "needs_fresh_data",
        "needs_tool",
        "needs_code_execution",
        "local_allowed",
        "stronger_model_allowed",
        "owner_approval_required",
        "reason_codes",
        "receipt_required"
      ],
      "properties": {
        "decision": {
          "type": "string",
          "enum": ["use_local", "use_local_with_context", "escalate", "require_approval", "reject"]
        },
        "task_class": {
          "type": "string",
          "enum": ["chat", "summarize", "source_qa", "coding", "finance_research", "web_research", "route", "unknown"]
        },
        "risk_level": {
          "type": "string",
          "enum": ["low", "medium", "high", "prohibited"]
        },
        "needs_fresh_data": { "type": "boolean" },
        "needs_tool": { "type": "boolean" },
        "needs_code_execution": { "type": "boolean" },
        "local_allowed": { "type": "boolean" },
        "stronger_model_allowed": { "type": "boolean" },
        "owner_approval_required": { "type": "boolean" },
        "reason_codes": {
          "type": "array",
          "items": { "type": "string", "minLength": 1 }
        },
        "receipt_required": { "const": true }
      },
      "additionalProperties": false
    },
    "authority_boundary": {
      "type": "object",
      "required": [
        "agent_os_remains_authority",
        "local_tool_calls_allowed",
        "local_code_execution_allowed",
        "local_repo_mutation_allowed",
        "local_spend_allowed",
        "local_publication_allowed",
        "raw_prompt_logging_allowed",
        "privileged_credentials_allowed",
        "full_ecf_private_internals_excluded"
      ],
      "properties": {
        "agent_os_remains_authority": { "const": true },
        "local_tool_calls_allowed": { "const": false },
        "local_code_execution_allowed": { "const": false },
        "local_repo_mutation_allowed": { "const": false },
        "local_spend_allowed": { "const": false },
        "local_publication_allowed": { "const": false },
        "raw_prompt_logging_allowed": { "const": false },
        "privileged_credentials_allowed": { "const": false },
        "full_ecf_private_internals_excluded": { "const": true }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
