{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "fleet/profile/fiscal.schema.json",
  "title": "Arcodange fiscal profile (fleet/profile/fiscal.yaml)",
  "description": "Machine-readable fiscal profile per PRD agent-catalog 'The document surface agents read': schema'd YAML; every rule carries effective_from/effective_until AND decision: adc-NNN. The bundled validator (scripts/validate.py, stdlib-only) implements the subset {type, properties, required, additionalProperties, items, enum, pattern} used here.",
  "type": "object",
  "additionalProperties": false,
  "required": ["version", "entity", "vat_position", "rules"],
  "properties": {
    "version": { "type": "integer", "enum": [1] },
    "entity": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "legal_form", "siren", "incorporated", "fiscal_year_end", "vat_registered", "b2b_only"],
      "properties": {
        "name": { "type": "string" },
        "legal_form": { "type": "string" },
        "siren": { "type": "string", "pattern": "^[0-9]{9}$" },
        "incorporated": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}(-[0-9]{2})?$" },
        "fiscal_year_end": { "type": "string", "pattern": "^[0-9]{2}-[0-9]{2}$" },
        "vat_registered": { "type": "boolean" },
        "b2b_only": { "type": "boolean" }
      }
    },
    "vat_position": {
      "type": "object",
      "description": "Informational ERP-read position, NOT a rule (no decision field): verify before any filing, never assume (PRD task-inventory T10).",
      "additionalProperties": false,
      "required": ["stance", "as_of", "note"],
      "properties": {
        "stance": { "type": "string", "enum": ["credit", "payable", "nil"] },
        "net_credit_eur_approx_min": { "type": "number" },
        "net_credit_eur_approx_max": { "type": "number" },
        "as_of": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" },
        "note": { "type": "string" }
      }
    },
    "rules": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "title", "category", "statement", "effective_from", "effective_until", "decision", "legal_basis", "source"],
        "properties": {
          "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$" },
          "title": { "type": "string" },
          "category": { "type": "string", "enum": ["vat-regime", "vat-treatment", "bookkeeping"] },
          "statement": { "type": "string" },
          "effective_from": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" },
          "effective_until": { "type": ["string", "null"], "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" },
          "decision": { "type": "string", "pattern": "^adc-[0-9]{3}$" },
          "legal_basis": { "type": "array", "items": { "type": "string" } },
          "source": { "type": "string" },
          "notes": { "type": "string" }
        }
      }
    }
  }
}
