{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "A single task in a chalky.town weekly planner. Stored in the author's repo. Field names mirror app.attodo.task where the concept is shared (title/description/completed/completedAt and the rec* recurrence fields); chalky-specific fields (day, order, color, subtasks, updatedAt) extend it. A recurring task is a template that projects occurrences onto later matching days; per-occurrence state (done/skipped) lives in separate town.chalky.occurrence records that reference this one.",
      "key": "tid",
      "record": {
        "properties": {
          "color": {
            "description": "Id of a color in the author's editable palette (town.chalky.config#colors). knownValues lists the five built-in defaults; any other palette color id is also valid since the field is open.",
            "knownValues": [
              "salmon",
              "chardonnay",
              "witch-haze",
              "mint-green",
              "melrose"
            ],
            "type": "string"
          },
          "completed": {
            "default": false,
            "type": "boolean"
          },
          "completedAt": {
            "description": "When `completed` last flipped to true (non-recurring tasks only; recurring tasks track per-occurrence completion in completedDates).",
            "format": "datetime",
            "type": "string"
          },
          "createdAt": {
            "format": "datetime",
            "type": "string"
          },
          "day": {
            "description": "Local calendar day the task sits on, as YYYY-MM-DD. Omit for the Someday bucket.",
            "type": "string"
          },
          "description": {
            "description": "Optional longer notes. May contain block-level Markdown (headings, lists, links, code, etc.); clients that don't render Markdown can show it as plain text.",
            "maxLength": 3000,
            "type": "string"
          },
          "isRecurring": {
            "default": false,
            "description": "Whether this task is a recurring template.",
            "type": "boolean"
          },
          "movedAt": {
            "description": "When rank (or, on a legacy record, movedRank) was last set.",
            "format": "datetime",
            "type": "string"
          },
          "movedRank": {
            "description": "Legacy, read-only: the malleable sort strategy's pinned position on the small unscaled color-rank axis, written by clients built before `rank` existed. Current clients read this (scaled up) only when `rank` is absent, and never write it — write `rank` instead.",
            "type": "integer"
          },
          "order": {
            "description": "Sort key within a day; lower sorts higher. Integer, atproto's data model allows no other numeric type — clients must never write a fractional value here.",
            "type": "integer"
          },
          "rank": {
            "description": "The malleable sort strategy's pinned position, on the same numeric axis as color rank scaled by RANK_SCALE (1024) — see the app's config.ts. Set when the user drags this task while that strategy is active; cleared when its color changes, rejoining the color grouping. Supersedes the legacy `movedRank` field, which used an unscaled axis with no integer headroom to halve into.",
            "type": "integer"
          },
          "recByMonth": {
            "description": "Yearly only: the month (1=January … 12=December). Omitted means the anchor's month.",
            "maximum": 12,
            "minimum": 1,
            "type": "integer"
          },
          "recByMonthDay": {
            "description": "Monthly & yearly \"day\" mode: the date-of-month. Omitted means the anchor's date. Months without this day are skipped.",
            "maximum": 31,
            "minimum": 1,
            "type": "integer"
          },
          "recByWeekday": {
            "description": "Weekly only: weekdays the series lands on (0=Sunday … 6=Saturday). Omitted means just the anchor day's weekday.",
            "items": {
              "maximum": 6,
              "minimum": 0,
              "type": "integer"
            },
            "type": "array"
          },
          "recCount": {
            "description": "Optional: end the series after this many occurrences, counted from the anchor (inclusive).",
            "minimum": 1,
            "type": "integer"
          },
          "recFrequency": {
            "description": "How often the task recurs.",
            "enum": [
              "daily",
              "weekly",
              "monthly",
              "yearly"
            ],
            "type": "string"
          },
          "recInterval": {
            "description": "Recur every N frequency units (e.g. every 2 weeks).",
            "minimum": 1,
            "type": "integer"
          },
          "recMonthly": {
            "description": "Monthly & yearly: land on the calendar date-of-month (\"day\") or the anchor's nth weekday (\"weekday\", e.g. the 2nd Friday). Omitted means \"day\".",
            "enum": [
              "day",
              "weekday"
            ],
            "type": "string"
          },
          "recUntil": {
            "description": "Optional last occurrence day (YYYY-MM-DD), inclusive. Set directly or kept in sync as the concrete stop date when recCount is used.",
            "type": "string"
          },
          "stamps": {
            "ref": "#stamps",
            "type": "ref"
          },
          "subtasks": {
            "items": {
              "ref": "#subtask",
              "type": "ref"
            },
            "type": "array"
          },
          "title": {
            "description": "The task title. May contain inline Markdown (links and emphasis); clients that don't render Markdown can show it as plain text.",
            "maxLength": 500,
            "type": "string"
          },
          "updatedAt": {
            "description": "Last local edit; used as the whole-record last-write-wins clock during sync. The physical component of a hybrid logical clock, so it is monotonic per device.",
            "format": "datetime",
            "type": "string"
          }
        },
        "required": [
          "title",
          "completed",
          "order",
          "createdAt",
          "updatedAt"
        ],
        "type": "object"
      },
      "type": "record"
    },
    "stamps": {
      "description": "Per-field-group hybrid-logical-clock stamps (an approach borrowed from the CRDT ideas behind automerge.org), enabling field-level last-write-wins merges: two devices editing different groups of the same task both keep their edits. Each value is '<ISO datetime>.<counter hex4>.<device id>', totally ordered by plain string comparison. Absent on a group (or entirely, on records from before stamps existed) means updatedAt stands in for it. Clients that don't merge field-wise can ignore this and compare updatedAt whole-record.",
      "properties": {
        "color": {
          "description": "Covers color.",
          "type": "string"
        },
        "done": {
          "description": "Covers completed and completedAt.",
          "type": "string"
        },
        "notes": {
          "description": "Covers description.",
          "type": "string"
        },
        "place": {
          "description": "Covers day, order, movedRank, and movedAt, which move together.",
          "type": "string"
        },
        "recurrence": {
          "description": "Covers isRecurring and every rec* field.",
          "type": "string"
        },
        "subtasks": {
          "description": "Covers subtasks.",
          "type": "string"
        },
        "text": {
          "description": "Covers title.",
          "type": "string"
        }
      },
      "type": "object"
    },
    "subtask": {
      "properties": {
        "completedAt": {
          "description": "When `done` last flipped to true. Used to order completed subtasks by completion time.",
          "format": "datetime",
          "type": "string"
        },
        "done": {
          "default": false,
          "type": "boolean"
        },
        "id": {
          "type": "string"
        },
        "text": {
          "maxLength": 500,
          "type": "string"
        }
      },
      "required": [
        "id",
        "text",
        "done"
      ],
      "type": "object"
    }
  },
  "id": "town.chalky.task",
  "lexicon": 1
}
