{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/rateapi-dev/json-schema/rateapi-dev-eligibility-check-verdict-schema.json",
  "title": "EligibilityCheckVerdict",
  "description": "One credit union's membership verdict against the supplied user context. Current web-derived records never assert ineligibility: non-matches verdict `unknown` with an actionable `unknown_reason`.",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/rateapi-dev-openapi.json#/components/schemas/EligibilityCheckVerdict",
  "type": "object",
  "required": [
    "credit_union_id",
    "status",
    "eligibility_type",
    "confidence",
    "record_confidence"
  ],
  "properties": {
    "credit_union_id": {
      "type": "string",
      "description": "Canonical identifier of the credit union this verdict is about."
    },
    "status": {
      "type": "string",
      "enum": [
        "open_to_anyone",
        "likely_eligible",
        "eligible_via_employer",
        "eligible_via_military",
        "geo_mismatch",
        "unknown"
      ],
      "description": "The same status vocabulary used to annotate ranked offers on /v1/decisions, /v1/league-table, and /v1/rates. `geo_mismatch` is retained for compatibility but current responses normalize unattested geographic non-matches to `unknown`."
    },
    "matched_rule": {
      "type": "object",
      "description": "Which concrete rule produced the status. Purely explanatory; absent on `geo_mismatch` and `unknown`.",
      "properties": {
        "type": {
          "type": "string",
          "description": "Which category of membership rule the borrower satisfied.",
          "enum": [
            "county",
            "state",
            "employer",
            "occupation",
            "association_open",
            "military",
            "school",
            "worship"
          ]
        },
        "detail": {
          "type": "string",
          "description": "The specific value that matched — the county, employer, association, or school named by the rule."
        }
      }
    },
    "unknown_reason": {
      "type": "string",
      "enum": [
        "charter_type_not_geo_matchable",
        "no_membership_record",
        "low_confidence_record",
        "geo_inputs_missing",
        "fom_completeness_unaffirmed",
        "publication_authority_unavailable"
      ],
      "description": "Present only when `status` is `unknown`. Names the missing input, incomplete evidence, or unavailable authoritative publication that prevented a positive verdict."
    },
    "join_path": {
      "type": "string",
      "deprecated": true,
      "description": "Reserved legacy field; current person-specific verdicts omit unbound flat join steps. Read the full eligibility profile or a graph `conditional_on` path instead."
    },
    "requirements_summary": {
      "type": "string",
      "deprecated": true,
      "description": "Reserved legacy field; current person-specific verdicts omit whole-record summaries because they are not bound to the matched path."
    },
    "membership_fee_usd": {
      "type": "number",
      "deprecated": true,
      "description": "Reserved legacy field; current person-specific verdicts omit unbound global fees."
    },
    "min_deposit_usd": {
      "type": "number",
      "deprecated": true,
      "description": "Reserved legacy field; current person-specific verdicts omit unbound global deposits."
    },
    "join_cost_usd": {
      "type": "number",
      "deprecated": true,
      "description": "Reserved legacy field; current person-specific verdicts expose actionable cost only on a graph conditionally-eligible path."
    },
    "eligibility_type": {
      "type": "string",
      "description": "Legacy charter shape for flat annotations. When an active graph publication is authoritative, this is the neutral value `graph` rather than a possibly stale flat path label."
    },
    "confidence": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "deprecated": true,
      "description": "Deprecated alias of `record_confidence` (same value, kept for compatibility). On graph-authoritative results both mirror graph verdict confidence; otherwise they reflect flat-record confidence."
    },
    "record_confidence": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "description": "Flat-record confidence on legacy results. On graph-authoritative results this instead mirrors the exact graph verdict confidence so stale flat confidence cannot contradict the publication."
    },
    "evidence_url": {
      "type": "string",
      "format": "uri",
      "description": "The credit union's own membership page — the source of every claim."
    },
    "details": {
      "type": "string",
      "description": "Relative path to the full record (GET /v1/credit-unions/{id}/eligibility). Absent when no record exists."
    },
    "graph": {
      "$ref": "#/$defs/EligibilityGraphVerdict"
    },
    "missing_facts": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/EligibilityMissingFact"
      },
      "description": "The question(s) to ask about this named institution. A check that returns unknown for every id AND a question for each is a successful call, not a failure."
    }
  },
  "$defs": {
    "EligibilityGraphPath": {
      "type": "object",
      "description": "One membership path through the eligibility graph, and how the supplied facts scored against it.",
      "required": [
        "rule_id",
        "kind",
        "reason",
        "conditions_matched"
      ],
      "properties": {
        "rule_id": {
          "type": "integer",
          "description": "Id of the published rule this path came from."
        },
        "kind": {
          "type": "string",
          "description": "Rule family (e.g. community_geo, employer, association, military, school, worship, family)."
        },
        "reason": {
          "type": "string",
          "description": "Deterministic sentence describing the path."
        },
        "conditions_matched": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Canonical condition ids the supplied facts satisfied."
        },
        "conditions_unknown": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Condition ids left unresolved — what to supply to decide this path."
        },
        "status": {
          "type": "string",
          "enum": [
            "eligible",
            "conditionally_eligible",
            "possibly_eligible",
            "ineligible",
            "unknown"
          ],
          "description": "Set on non-positive paths so callers can explain the gap. `ineligible` is reserved for compatibility; current customer-safe projections normalize unattested path negatives to `unknown`."
        },
        "conditional_on": {
          "type": "object",
          "description": "The one further step that would make this path apply.",
          "properties": {
            "type": {
              "type": "string",
              "description": "The kind of action the borrower must take to satisfy this path.",
              "enum": [
                "join_association",
                "family_link",
                "deposit_or_donation"
              ]
            },
            "org_id": {
              "type": "string",
              "description": "Identifier of the association, employer, or organization the borrower must join or link to."
            },
            "cost_usd": {
              "type": "number",
              "description": "Up-front cost of the step, when published."
            },
            "join_url": {
              "type": "string",
              "description": "Page where the borrower can complete the joining step.",
              "format": "uri"
            }
          }
        }
      }
    },
    "EligibilityGraphVerdict": {
      "type": "object",
      "description": "Eligibility-graph verdict. When `publication` is present, this exact immutable generation is authoritative and the v1 top-level status is its compatibility projection. Without `publication`, the object is additive compatibility output. `ineligible` remains in the enum for wire compatibility but is not emitted from current web-derived publications without a future typed closed-world attestation.",
      "required": [
        "status",
        "confidence",
        "paths",
        "explain"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "eligible",
            "conditionally_eligible",
            "possibly_eligible",
            "ineligible",
            "unknown"
          ],
          "description": "Five-value graph vocabulary retained for compatibility. Current open-world web-derived rules emit `unknown`, never `ineligible`, when no held path matches. `unknown` NEVER means no."
        },
        "confidence": {
          "type": "number",
          "description": "Confidence in this verdict, 0–1. Lower values mean the underlying rule was extracted with less certainty; an unknown is never reported as ineligible.",
          "minimum": 0,
          "maximum": 1
        },
        "paths": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/EligibilityGraphPath"
          },
          "description": "Only paths at the verdict's winning status, with what matched or remained unresolved. Lower-ranked alternative OR paths are omitted."
        },
        "unknown_reason": {
          "type": "string",
          "enum": [
            "no_rules",
            "geo_inputs_missing",
            "org_inputs_missing",
            "inputs_missing",
            "low_confidence_rules",
            "incomplete_fom",
            "fom_completeness_unaffirmed",
            "unmodeled_condition"
          ],
          "description": "Present when the verdict is not positive. Machine-readable so a dead end becomes a next step."
        },
        "explain": {
          "type": "string",
          "description": "Deterministic one-sentence explanation of the verdict. Never model prose."
        },
        "publication": {
          "$ref": "#/$defs/EligibilityPublicationRef"
        }
      }
    },
    "EligibilityMissingFact": {
      "type": "object",
      "description": "One question to ask the person next, bound to the one institution and the one membership condition it would unlock. Emitted on `unknown` and `possibly_eligible` entries only; an already-open door needs no question. Absent (never an empty array) when no question would help — see the response-level `unanswerable`.",
      "required": [
        "cu_id",
        "condition_id",
        "kind",
        "question",
        "fact_field",
        "why",
        "resolves_reason"
      ],
      "properties": {
        "cu_id": {
          "type": "string",
          "description": "The institution this question would unlock."
        },
        "condition_id": {
          "type": "integer",
          "description": "The membership condition that evaluated unknown. Stable across calls for a given publication."
        },
        "kind": {
          "type": "string",
          "description": "The evaluator condition kind, verbatim (`geo_residence`, `employee_of`, `military_affiliation`, …), so a caller can group questions without parsing prose."
        },
        "question": {
          "type": "string",
          "description": "The question to ask the person, in the second person, answerable in one breath. Composed in code from a fixed template; never model prose."
        },
        "fact_field": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The request field(s) an answer populates. Always at least one, and always a field this endpoint accepts — merge the answers into the same request body and call again."
        },
        "why": {
          "type": "string",
          "description": "Why we are asking, in one deterministic sentence naming the door."
        },
        "evidence_quote": {
          "type": "string",
          "description": "Verbatim from the INSTITUTION's own page, via the rule's evidence quote, truncated on a word boundary at 240 characters. Absent when the backing rule carries no quote. This is never the person's own words."
        },
        "resolves_reason": {
          "type": "string",
          "enum": [
            "no_rules",
            "geo_inputs_missing",
            "org_inputs_missing",
            "inputs_missing",
            "low_confidence_rules",
            "incomplete_fom",
            "fom_completeness_unaffirmed",
            "unmodeled_condition"
          ],
          "description": "The `unknown_reason` an answer to this question would resolve."
        }
      }
    },
    "EligibilityProposalCoverage": {
      "type": "object",
      "description": "How many model-proposed claims from the source page survived evidence verification. This is not an attestation that every real-world field-of-membership path is known.",
      "required": [
        "scope",
        "proposed_claims",
        "verified_claims",
        "published_rules",
        "withheld_claims",
        "proposal_survival",
        "withheld_reasons"
      ],
      "properties": {
        "scope": {
          "type": "string",
          "enum": [
            "source_page_model_proposals"
          ],
          "description": "Metric scope, explicitly limited to model proposals extracted from reviewed source pages."
        },
        "proposed_claims": {
          "type": "integer",
          "minimum": 0,
          "description": "Claims proposed by extraction from the reviewed source pages."
        },
        "verified_claims": {
          "type": "integer",
          "minimum": 0,
          "description": "Proposed claims that passed evidence verification."
        },
        "published_rules": {
          "type": "integer",
          "minimum": 0,
          "description": "Verified graph rules published from the candidate."
        },
        "withheld_claims": {
          "type": "integer",
          "minimum": 0,
          "description": "Proposed claims withheld because verification did not pass."
        },
        "proposal_survival": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0,
          "maximum": 1,
          "description": "Verified claims divided by proposed claims, or null when no claims were proposed."
        },
        "withheld_reasons": {
          "type": "object",
          "description": "Withheld claim counts grouped by machine-readable verification reason.",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        }
      }
    },
    "EligibilityPublicationRef": {
      "type": "object",
      "description": "Exact immutable active eligibility generation evaluated for this response.",
      "required": [
        "publication_id",
        "ruleset_sha256",
        "activated_at"
      ],
      "properties": {
        "publication_id": {
          "type": "integer",
          "description": "Database identifier of the active publication."
        },
        "ruleset_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "SHA-256 digest of the complete ordered rule set."
        },
        "activated_at": {
          "type": "string",
          "format": "date-time",
          "description": "When this generation became serving authority."
        },
        "proposal_coverage": {
          "$ref": "#/$defs/EligibilityProposalCoverage"
        }
      }
    }
  }
}