{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "The authority record defining the rules for a Starrysky verified streak.",
      "key": "tid",
      "record": {
        "properties": {
          "allowedGranters": {
            "description": "An array of DIDs authorized to grant extra streak freezes to the user.",
            "items": {
              "format": "did",
              "type": "string"
            },
            "type": "array"
          },
          "allowedWitnesses": {
            "description": "An array of DIDs authorized to sign attestations for this policy. Required if witnessed.",
            "items": {
              "format": "did",
              "type": "string"
            },
            "type": "array"
          },
          "cadence": {
            "properties": {
              "intervalResetDay": {
                "description": "For weekly: 0-6 (Sun-Sat). For monthly: 1-31. Defines when the window rolls over.",
                "type": "integer"
              },
              "requiredCheckinsPerInterval": {
                "default": 1,
                "description": "Number of check-ins required within the interval to maintain the streak.",
                "type": "integer"
              },
              "type": {
                "description": "The time window during which the required check-ins must occur.",
                "knownValues": [
                  "daily",
                  "weekly",
                  "monthly",
                  "quarterly",
                  "yearly"
                ],
                "type": "string"
              }
            },
            "required": [
              "type",
              "requiredCheckinsPerInterval"
            ],
            "type": "object"
          },
          "createdAt": {
            "description": "Timestamp when this policy record was created.",
            "format": "datetime",
            "type": "string"
          },
          "freezesGrantedAtMilestone": {
            "default": 0,
            "description": "Number of freezes to grant when reaching a milestone (explicit or recurring).",
            "type": "integer"
          },
          "gracePeriodIntervals": {
            "default": 0,
            "description": "The number of intervals a user can skip before needing to use a freeze or breaking their streak.",
            "type": "integer"
          },
          "includeFreezesInStreak": {
            "default": false,
            "description": "If true, frozen intervals are included in the streak sequence count.",
            "type": "boolean"
          },
          "intervalsToEarnFreeze": {
            "description": "Number of successful intervals required to earn 1 freeze.",
            "type": "integer"
          },
          "maxFreezes": {
            "default": 3,
            "description": "The maximum number of freezes a user can bank at one time.",
            "type": "integer"
          },
          "milestones": {
            "description": "Explicit streak counts that trigger a celebration or reward.",
            "items": {
              "type": "integer"
            },
            "type": "array"
          },
          "name": {
            "description": "Human-readable name for this streak (e.g., 'Daily Coding').",
            "maxLength": 100,
            "type": "string"
          },
          "originService": {
            "description": "Optional: The NSID of the service being tracked for automated check-ins (e.g., app.bsky.feed.post).",
            "type": "string"
          },
          "recurringMilestoneInterval": {
            "description": "Interval for repeating milestones (e.g., every 100 days) after explicit milestones are passed.",
            "type": "integer"
          },
          "startingFreezes": {
            "default": 0,
            "description": "Number of freezes granted to the user when they first start the streak.",
            "type": "integer"
          },
          "verificationType": {
            "description": "Whether this streak requires a third-party cryptographic signature.",
            "knownValues": [
              "self-reported",
              "witnessed"
            ],
            "type": "string"
          }
        },
        "required": [
          "name",
          "verificationType",
          "cadence",
          "intervalsToEarnFreeze",
          "createdAt"
        ],
        "type": "object"
      },
      "type": "record"
    }
  },
  "id": "app.starrysky.streak.policy",
  "lexicon": 1
}
