Schedule Windows

analyze_schedule_windows

POST /v1/analyze/schedule-windows. MCP: analyze_schedule_windows. Analyze only the supplied horizon; no commands, cron installation, system clock, network access or external calendars. start and end use YYYY-MM-DDTHH:MM:00Z, years 2000..2099, start inclusive and end exclusive, maximum 31 elapsed days. All timestamps and interval endpoints are exact UTC minutes.

Schedules

schedules: 1..16 records with unique safe ASCII id, type cron or window, timezone (default UTC) and role coverage (default) or blackout. IANA rules come exclusively from the pinned tzdata package; tzdata_version identifies that database, independent of host settings. No locale, timezone abbreviations or system-local default. Unknown zones, fields, invalid calendar dates and coerced values are rejected with sanitized INVALID_INPUT errors. Only optional top-level timeout_ms accepts null as omitted.

Cron: expression has exactly five numeric fields: minute 0..59, hour 0..23, day of month 1..31, month 1..12, day of week 0..7 (0 and 7 mean Sunday). Fields support *, comma lists, ascending inclusive ranges and positive steps on wildcards or ranges; steps start at the range lower bound and never carry across fields. Example: */20 1-5/2 * * 1-5. Single-number steps, reversed/wrapping ranges, names, macros, seconds, years, L, W, #, ?, commands and environment assignments are rejected.

Cron calendar semantics: minute, hour and month must match. If either day field begins with *, both day predicates must match; otherwise day of month OR day of week matches. A stepped wildcard beginning with * retains this wildcard flag. Thus 0 0 1 * 1 means the first day of each month plus every Monday. Impossible dates produce no fires. duration_minutes is 1..1440 (default 1), measured in elapsed UTC minutes from each fire. Fires are UTC-sorted, deduplicated and include pre-horizon fires whose durations intersect the horizon; a fire exactly at end is excluded. Overlapping executions within one schedule merge into intervals; fires preserve their separate starts.

Window: weekdays is a unique nonempty list 0..6 (Monday 0, Sunday 6), start_time and end_time use HH:MM. Membership is start-inclusive, end-exclusive in local wall time. When end_time <= start_time the window crosses midnight and weekdays refer to the starting day; equal times mean a full local day. Windows have no cron fire events, so fires is empty. This is recurring wall-clock membership, not endpoint pairing or fixed elapsed duration.

DST and boundaries

Nonexistent local minutes are skipped. Both occurrences of a repeated local minute are included. No catch-up, shifting or coalescing of repeated cron fires. Window membership follows each actual UTC minute through its local clock; a narrow window can split into two disjoint intervals during a repeated hour. Overnight windows can last more or less than 24 elapsed hours. Non-hour transitions and non-integer-hour UTC offsets use the same rules. Touching intervals merge within one schedule or gap list, but two schedules touching at one endpoint do not overlap.

Verified results

complete requires verified=true and analysis. analysis.schedules preserves input order, with each id, all contributing cron fires and maximal merged intervals clipped to the horizon. overlaps lists every nonempty pair intersection in input-pair order, including pairs of blackouts. blackout_conflicts is the subset with one coverage role and one blackout role. uncovered_gaps is the maximal complement of available coverage: union(coverage) minus union(blackouts). Blackouts therefore create uncovered gaps even when a coverage schedule is active. With only blackout schedules, the full horizon is uncovered. No claim extends beyond the supplied horizon.

The proposal enumerates local dates and independently round-trips both fold choices to UTC, then uses interval algebra. A separate verifier walks the UTC timeline, evaluates the original cron fields with a separate matcher and the original window predicates, and rebuilds all fires, intervals, pair intersections and gaps using minute masks. Exact equality checks completeness, including every empty result and gap. Both implementations share the pinned IANA database and standard Gregorian calendar/timezone primitives; this does not certify the database or reproduce every cron daemon dialect.

Limits: timeout_ms 100..5000 (default 3000), shared across proposal and verification; 2000000 counted calendar/interval steps; 1024 total output records counting fires, schedule intervals, pair intervals, conflict intervals and gaps. Dense or long schedules may exceed these limits. Budget/cap exhaustion or mismatch returns unknown; deadline expiry returns timeout. Both have verified=false and analysis=null with no partial findings. Same isolated child, no worker disk writes, no payload retention, payment boundary, three slots, memory/CPU limits, 65536-byte request and 262144-byte response caps; an oversized response returns RESOURCE_LIMIT_EXCEEDED.

Schedule schemas

analyze_schedule_windows request

{
  "$defs": {
    "CronSchedule": {
      "additionalProperties": false,
      "properties": {
        "duration_minutes": {
          "default": 1,
          "maximum": 1440,
          "minimum": 1,
          "type": "integer"
        },
        "expression": {
          "maxLength": 256,
          "minLength": 9,
          "type": "string"
        },
        "id": {
          "$ref": "#/$defs/VarName"
        },
        "role": {
          "default": "coverage",
          "enum": [
            "coverage",
            "blackout"
          ],
          "type": "string"
        },
        "timezone": {
          "default": "UTC",
          "maxLength": 64,
          "minLength": 1,
          "type": "string"
        },
        "type": {
          "const": "cron",
          "type": "string"
        }
      },
      "required": [
        "type",
        "id",
        "expression"
      ],
      "type": "object"
    },
    "VarName": {
      "maxLength": 64,
      "minLength": 1,
      "pattern": "^[A-Za-z_][A-Za-z0-9_.\\-\\[\\]]*$",
      "type": "string"
    },
    "WindowSchedule": {
      "additionalProperties": false,
      "properties": {
        "end_time": {
          "pattern": "^(?:[01][0-9]|2[0-3]):[0-5][0-9]$",
          "type": "string"
        },
        "id": {
          "$ref": "#/$defs/VarName"
        },
        "role": {
          "default": "coverage",
          "enum": [
            "coverage",
            "blackout"
          ],
          "type": "string"
        },
        "start_time": {
          "pattern": "^(?:[01][0-9]|2[0-3]):[0-5][0-9]$",
          "type": "string"
        },
        "timezone": {
          "default": "UTC",
          "maxLength": 64,
          "minLength": 1,
          "type": "string"
        },
        "type": {
          "const": "window",
          "type": "string"
        },
        "weekdays": {
          "items": {
            "maximum": 6,
            "minimum": 0,
            "type": "integer"
          },
          "maxItems": 7,
          "minItems": 1,
          "type": "array"
        }
      },
      "required": [
        "type",
        "id",
        "weekdays",
        "start_time",
        "end_time"
      ],
      "type": "object"
    }
  },
  "additionalProperties": false,
  "properties": {
    "end": {
      "maxLength": 20,
      "minLength": 20,
      "pattern": "^20[0-9]{2}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:00Z$",
      "type": "string"
    },
    "schedules": {
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/CronSchedule"
          },
          {
            "$ref": "#/$defs/WindowSchedule"
          }
        ]
      },
      "maxItems": 16,
      "minItems": 1,
      "type": "array"
    },
    "start": {
      "maxLength": 20,
      "minLength": 20,
      "pattern": "^20[0-9]{2}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:00Z$",
      "type": "string"
    },
    "timeout_ms": {
      "anyOf": [
        {
          "maximum": 5000,
          "minimum": 100,
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": 3000
    }
  },
  "required": [
    "start",
    "end",
    "schedules"
  ],
  "type": "object"
}

analyze_schedule_windows response

{
  "$defs": {
    "ScheduleAnalysis": {
      "additionalProperties": false,
      "properties": {
        "blackout_conflicts": {
          "items": {
            "$ref": "#/$defs/ScheduleOverlap"
          },
          "type": "array"
        },
        "overlaps": {
          "items": {
            "$ref": "#/$defs/ScheduleOverlap"
          },
          "type": "array"
        },
        "schedules": {
          "items": {
            "$ref": "#/$defs/ScheduleRecord"
          },
          "type": "array"
        },
        "uncovered_gaps": {
          "items": {
            "$ref": "#/$defs/TimeSpan"
          },
          "type": "array"
        }
      },
      "required": [
        "schedules",
        "overlaps",
        "blackout_conflicts",
        "uncovered_gaps"
      ],
      "type": "object"
    },
    "ScheduleOverlap": {
      "additionalProperties": false,
      "properties": {
        "intervals": {
          "items": {
            "$ref": "#/$defs/TimeSpan"
          },
          "type": "array"
        },
        "left": {
          "$ref": "#/$defs/VarName"
        },
        "right": {
          "$ref": "#/$defs/VarName"
        }
      },
      "required": [
        "left",
        "right",
        "intervals"
      ],
      "type": "object"
    },
    "ScheduleRecord": {
      "additionalProperties": false,
      "properties": {
        "fires": {
          "items": {
            "maxLength": 20,
            "minLength": 20,
            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:00Z$",
            "type": "string"
          },
          "type": "array"
        },
        "id": {
          "$ref": "#/$defs/VarName"
        },
        "intervals": {
          "items": {
            "$ref": "#/$defs/TimeSpan"
          },
          "type": "array"
        }
      },
      "required": [
        "id",
        "fires",
        "intervals"
      ],
      "type": "object"
    },
    "Stats": {
      "additionalProperties": false,
      "properties": {
        "elapsed_ms": {
          "minimum": 0,
          "type": "integer"
        },
        "timed_out": {
          "type": "boolean"
        }
      },
      "required": [
        "elapsed_ms",
        "timed_out"
      ],
      "type": "object"
    },
    "TimeSpan": {
      "additionalProperties": false,
      "properties": {
        "end": {
          "maxLength": 20,
          "minLength": 20,
          "pattern": "^20[0-9]{2}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:00Z$",
          "type": "string"
        },
        "start": {
          "maxLength": 20,
          "minLength": 20,
          "pattern": "^20[0-9]{2}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:00Z$",
          "type": "string"
        }
      },
      "required": [
        "start",
        "end"
      ],
      "type": "object"
    },
    "VarName": {
      "maxLength": 64,
      "minLength": 1,
      "pattern": "^[A-Za-z_][A-Za-z0-9_.\\-\\[\\]]*$",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "properties": {
    "analysis": {
      "anyOf": [
        {
          "$ref": "#/$defs/ScheduleAnalysis"
        },
        {
          "type": "null"
        }
      ]
    },
    "stats": {
      "$ref": "#/$defs/Stats"
    },
    "tzdata_version": {
      "type": "string"
    },
    "verdict": {
      "enum": [
        "complete",
        "unknown",
        "timeout"
      ],
      "type": "string"
    },
    "verified": {
      "type": "boolean"
    }
  },
  "required": [
    "verdict",
    "tzdata_version",
    "verified",
    "stats"
  ],
  "type": "object"
}