canonical_id: "cron"
display_name: "定時排程"
category: "logic"
version: "v1"
wasi_target: "preview1"
stability: "floating"
runtime_compat:
  - "cf-workers"
  - "workerd"
  - "wazero"
constraints:
  max_size_kb: 2048
  max_cold_start_ms: 50
  no_network_syscall: true
  no_filesystem_syscall: true
  io_model: "stdin_stdout_json"
input_schema:
  type: object
  required: [cron_expr]
  properties:
    cron_expr:
      type: string
      description: 標準 5 欄位 cron expression，如 0 9 * * *
    description:
      type: string
output_schema:
  type: object
  properties:
    success:
      type: boolean
    data:
      type: object
      properties:
        cron_id:
          type: string
        cron_expr:
          type: string
        enabled:
          type: boolean
        description:
          type: string
gherkin_tests:
  - scenario: "有效 cron expression"
    given: '{"cron_expr":"0 9 * * *","description":"每天早上9點"}'
    then_contains: '"enabled":true'
  - scenario: "無效 cron expression（欄位數不對）"
    given: '{"cron_expr":"0 9 * *"}'
    then_contains: '{"success":false'
  - scenario: "缺少 cron_expr"
    given: '{}'
    then_contains: '{"success":false'
tags: [builtin, cron, schedule, trigger, timer]
description: "驗證 cron expression 格式並回傳 cron_id。實際排程由 Cypher Executor 負責。"
config_example: |
  my_cron:                                # 節點名稱（可自訂）
    cron_expr: "0 9 * * *"               # 標準 5 欄位 cron 表達式（必填），如：每天早上 9 點
    description: "每天早上9點執行"        # 排程說明文字（選填）
