{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/rateapi-dev/json-schema/rateapi-dev-credit-union-eligibility-record-schema.json",
  "title": "CreditUnionEligibilityRecord",
  "description": "Published membership criteria and provenance for one credit union. This is guidance only; the institution makes the final membership determination.",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/rateapi-dev-openapi.json#/components/schemas/CreditUnionEligibilityRecord",
  "type": "object",
  "required": [
    "credit_union_id",
    "eligibility_type",
    "open_to_anyone",
    "geo_states",
    "geo_counties",
    "geo_cities",
    "employers",
    "associations",
    "occupations",
    "disclosure"
  ],
  "properties": {
    "credit_union_id": {
      "type": "string",
      "description": "Canonical identifier of the credit union."
    },
    "eligibility_type": {
      "type": "string",
      "description": "How membership is defined for this credit union — for example community, employer, association, or military."
    },
    "open_to_anyone": {
      "type": "boolean",
      "description": "True when anyone can join, typically via an association or donation path."
    },
    "join_path": {
      "type": [
        "string",
        "null"
      ],
      "description": "How a non-qualifying borrower can still become eligible, or null when no such path is documented."
    },
    "geo_states": {
      "type": "array",
      "description": "US state codes whose residents qualify on geography alone.",
      "items": {
        "type": "string"
      }
    },
    "geo_counties": {
      "type": "array",
      "description": "Counties whose residents qualify on geography alone.",
      "items": {
        "type": "string"
      }
    },
    "geo_cities": {
      "type": "array",
      "description": "Cities whose residents qualify on geography alone.",
      "items": {
        "type": "string"
      }
    },
    "employers": {
      "type": "array",
      "description": "Employers whose staff qualify for membership.",
      "items": {
        "type": "string"
      }
    },
    "associations": {
      "type": "array",
      "description": "Associations whose members qualify, including any that can be joined to gain eligibility.",
      "items": {
        "type": "string"
      }
    },
    "occupations": {
      "type": "array",
      "description": "Occupations that qualify for membership.",
      "items": {
        "type": "string"
      }
    },
    "military": {
      "type": "object",
      "description": "Military-service eligibility, and the evidence it was read from.",
      "properties": {
        "eligible": {
          "type": "boolean",
          "description": "True when military service is a documented path to membership."
        },
        "affiliations": {
          "type": "array",
          "description": "The specific branches, bases, or service statuses that qualify.",
          "items": {
            "type": "string"
          }
        },
        "evidence": {
          "type": "string",
          "description": "The extracted text supporting the military eligibility rule."
        }
      }
    },
    "worship_orgs": {
      "type": "array",
      "description": "Congregations or religious organizations whose members qualify.",
      "items": {
        "type": "string"
      }
    },
    "schools": {
      "type": "array",
      "description": "Schools or districts whose students, staff, or alumni qualify.",
      "items": {
        "type": "string"
      }
    },
    "family_membership": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "True when a family member of an existing member qualifies, or null when unknown."
    },
    "membership_fee_usd": {
      "type": [
        "number",
        "null"
      ],
      "description": "One-time membership fee in US dollars, or null when unknown."
    },
    "min_deposit_usd": {
      "type": [
        "number",
        "null"
      ],
      "description": "Minimum opening share deposit in US dollars, or null when unknown."
    },
    "requirements_summary": {
      "type": [
        "string",
        "null"
      ],
      "description": "Plain-language summary of what membership requires, or null when none was extracted."
    },
    "source": {
      "type": [
        "string",
        "null"
      ],
      "description": "Where the eligibility rules were read from, or null when unattributed."
    },
    "confidence": {
      "type": [
        "number",
        "null"
      ],
      "description": "Confidence in the extracted rules, 0–1, or null when not scored.",
      "minimum": 0,
      "maximum": 1
    },
    "evidence_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "Page the eligibility rules were extracted from, or null when unattributed.",
      "format": "uri"
    },
    "extracted_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "When the eligibility rules were last extracted, or null when unknown.",
      "format": "date-time"
    },
    "updated_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "When this eligibility record was last written, or null when unknown.",
      "format": "date-time"
    },
    "rules": {
      "type": "array",
      "description": "The returned rules we hold. When `publication` is present, these are exactly the active publication's rules; otherwise they are the compatibility/current held set. Bundle integrity does not attest that every possible field-of-membership path is known.",
      "items": {
        "type": "object",
        "required": [
          "rule_id",
          "kind",
          "conditions",
          "verification_status",
          "confidence"
        ],
        "properties": {
          "rule_id": {
            "type": "integer",
            "description": "Stable identifier of this published rule."
          },
          "kind": {
            "type": "string",
            "description": "Membership-path category represented by this rule."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Deterministic human-readable rule description, or null."
          },
          "conditions": {
            "type": "array",
            "description": "Conditions that must all hold for this membership path.",
            "items": {
              "type": "object",
              "required": [
                "kind",
                "text"
              ],
              "properties": {
                "kind": {
                  "type": "string",
                  "description": "Machine-readable condition kind."
                },
                "text": {
                  "type": "string",
                  "description": "Deterministic rendering of this condition."
                },
                "negated": {
                  "type": "boolean",
                  "description": "True when this condition is an exclusion."
                },
                "geo_level": {
                  "type": "string",
                  "description": "Geographic level such as state, county, city, or ZIP."
                },
                "geo_value": {
                  "type": "string",
                  "description": "Canonical geographic key used by the evaluator."
                },
                "org_name": {
                  "type": "string",
                  "description": "Canonical organization name, or the raw name when unresolved."
                },
                "org_unresolved": {
                  "type": "boolean",
                  "description": "True when org_name is evidence text rather than a resolved entity."
                },
                "family_relations": {
                  "type": "array",
                  "description": "Family relationships accepted by this condition.",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "evidence_quote": {
            "type": "string",
            "description": "Verbatim source excerpt supporting this rule."
          },
          "evidence_same_as_rule_id": {
            "type": "integer",
            "description": "Rule carrying the shared quote when duplicate evidence was compacted."
          },
          "source_url": {
            "type": "string",
            "description": "Source URL from which the supporting evidence was captured.",
            "format": "uri"
          },
          "source_type": {
            "type": "string",
            "description": "Acquisition/source role of the supporting artifact."
          },
          "verification_status": {
            "type": "string",
            "description": "How far evidence and semantic verification progressed."
          },
          "confidence": {
            "type": "number",
            "description": "Confidence in this verified rule, from 0 to 1.",
            "minimum": 0,
            "maximum": 1
          },
          "observed_at": {
            "type": "string",
            "description": "When the source evidence was observed.",
            "format": "date-time"
          },
          "last_confirmed_at": {
            "type": "string",
            "description": "Most recent live acquisition that confirmed this rule.",
            "format": "date-time"
          }
        }
      }
    },
    "rules_summary": {
      "type": "object",
      "description": "Deterministic summary of the returned held rules. When `publication` is present, it summarizes that exact active publication; otherwise it summarizes the compatibility/current held set. It is not a closed-world completeness attestation.",
      "required": [
        "total",
        "by_kind",
        "counties_served",
        "last_verified"
      ],
      "properties": {
        "total": {
          "type": "integer",
          "description": "Number of rules in the returned held set."
        },
        "by_kind": {
          "type": "object",
          "description": "Rule counts grouped by membership-path kind.",
          "additionalProperties": {
            "type": "integer"
          }
        },
        "counties_served": {
          "type": "integer",
          "description": "Distinct county conditions represented by the rule set."
        },
        "last_verified": {
          "type": [
            "string",
            "null"
          ],
          "description": "Freshest source confirmation across the rule set, or null.",
          "format": "date-time"
        },
        "compacted": {
          "type": "boolean",
          "description": "True when duplicate evidence quotes were compacted by reference."
        }
      }
    },
    "publication": {
      "$ref": "#/$defs/EligibilityPublicationRef"
    },
    "authority": {
      "type": "object",
      "description": "Present with an active publication. It identifies `rules` as the authoritative immutable generation and marks the older flat record fields as a compatibility projection, not decision proof.",
      "required": [
        "rules",
        "flat_fields",
        "publication_id",
        "ruleset_sha256"
      ],
      "properties": {
        "rules": {
          "type": "string",
          "enum": [
            "active_publication"
          ],
          "description": "Authority used for the returned rules array."
        },
        "flat_fields": {
          "type": "string",
          "enum": [
            "legacy_projection_non_authoritative"
          ],
          "description": "Authority classification of the compatibility flat fields."
        },
        "publication_id": {
          "type": "integer",
          "minimum": 1,
          "description": "Exact active publication that supplied the rules."
        },
        "ruleset_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Immutable identity hash of that publication's ruleset."
        }
      }
    },
    "disclosure": {
      "type": "string",
      "description": "Disclosure text that must be shown with these rules: they are extracted from published sources and the credit union decides eligibility, not this API."
    }
  },
  "$defs": {
    "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"
        }
      }
    }
  }
}