{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "A verifiable check-in event for a specific service streak.",
      "key": "tid",
      "record": {
        "properties": {
          "checkinsInInterval": {
            "default": 1,
            "description": "Progress within the current cadence interval (e.g., 2 if this is the second check-in of the week).",
            "type": "integer"
          },
          "createdAt": {
            "description": "Timestamp when this check-in record was created.",
            "format": "datetime",
            "type": "string"
          },
          "freezeDates": {
            "description": "Explicit dates (YYYY-MM-DD) being covered by streak freezes in this check-in.",
            "items": {
              "format": "datetime",
              "type": "string"
            },
            "type": "array"
          },
          "inventoryRef": {
            "description": "CID of the inventory record associated with this check-in.",
            "format": "cid",
            "type": "string"
          },
          "note": {
            "description": "A short note or comment about this check-in (e.g. 'Ran 5km').",
            "maxLength": 300,
            "type": "string"
          },
          "originService": {
            "description": "The NSID of the service where the streak event occurred.",
            "type": "string"
          },
          "policy": {
            "description": "The URI of the policy governing this streak.",
            "format": "at-uri",
            "type": "string"
          },
          "prev": {
            "description": "CID of the previous check-in record in the sequence.",
            "format": "cid",
            "type": "string"
          },
          "streakDate": {
            "description": "The explicit date this check-in is for (YYYY-MM-DD). Useful for handling timezone boundaries manually.",
            "format": "datetime",
            "type": "string"
          },
          "streakSequence": {
            "description": "The current total count of successful intervals/days in this specific streak.",
            "minimum": 1,
            "type": "integer"
          },
          "subject": {
            "description": "The name of the habit (e.g., 'Daily Coding', 'Morning Run').",
            "maxLength": 100,
            "type": "string"
          },
          "value": {
            "description": "An optional numeric metric associated with this check-in (e.g. distance, weight, count).",
            "type": "integer"
          },
          "witness": {
            "description": "Optional third-party attestation of the event.",
            "ref": "lex:app.starrysky.streak.checkin#witness",
            "type": "ref"
          }
        },
        "required": [
          "originService",
          "policy",
          "subject",
          "streakSequence",
          "streakDate",
          "createdAt"
        ],
        "type": "object"
      },
      "type": "record"
    },
    "witness": {
      "description": "A cryptographic attestation from a third-party service.",
      "properties": {
        "did": {
          "description": "The DID of the witness service.",
          "format": "did",
          "type": "string"
        },
        "sig": {
          "description": "The cryptographic signature of the witness.",
          "type": "bytes"
        },
        "subject": {
          "description": "The CID of the record being witnessed.",
          "format": "cid",
          "type": "string"
        }
      },
      "required": [
        "did",
        "sig",
        "subject"
      ],
      "type": "object"
    }
  },
  "id": "app.starrysky.streak.checkin",
  "lexicon": 1
}
