{
  "schemaVersion": "1.0",
  "id": "starter-task-review",
  "title": "Xem lại trước khi tạo",
  "purpose": "Sửa effort/lặp/first due/người nhận của mẫu trước xác nhận.",
  "roles": [
    "adult"
  ],
  "group": "authentication-home-setup",
  "variantOf": null,
  "layout": {
    "canvas": {
      "width": 390,
      "height": 844
    },
    "responsive": {
      "minimumWidth": 360,
      "maximumWidth": 430,
      "scroll": "vertical",
      "safeAreaBottom": true,
      "fontScale": "native dynamic type; reflow without clipping",
      "keyboard": "composer sticky within resized viewport; dialog scrolls; no fixed keyboard overlay"
    },
    "regions": [
      {
        "id": "header",
        "order": 0,
        "type": "safe-area/header",
        "height": "intrinsic"
      },
      {
        "id": "content",
        "order": 1,
        "type": "purpose-specific task",
        "componentIds": [
          "screen-header",
          "starter-task-review-0",
          "starter-task-review-1",
          "starter-task-review-2",
          "starter-task-review-3",
          "starter-task-review-4",
          "starter-task-review-5",
          "screen-actions"
        ]
      },
      {
        "id": "actions",
        "order": 2,
        "type": "one primary + secondary controls"
      },
      {
        "id": "navigation",
        "order": 3,
        "type": "none"
      }
    ]
  },
  "components": [
    {
      "id": "screen-header",
      "type": "Header",
      "props": {
        "homeLabel": "Nhà Lá",
        "scopeGate": "A",
        "backTarget": "setup-starter-tasks",
        "settingsTarget": "settings"
      },
      "tokens": {
        "foreground": "{semantic.light.fg}",
        "darkForeground": "{semantic.dark.fg}"
      },
      "accessibility": {
        "label": "Thanh đầu màn hình",
        "readingOrder": 0,
        "focusOrder": "back then settings"
      }
    },
    {
      "id": "starter-task-review-0",
      "type": "Field",
      "props": {
        "name": "title",
        "label": "Tên việc",
        "type": "text",
        "value": "Rửa bát sau bữa tối",
        "required": true,
        "min": null,
        "max": null,
        "options": null,
        "hint": null,
        "pattern": null
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Tên việc",
        "readingOrder": 1,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "starter-task-review-1",
      "type": "Field",
      "props": {
        "name": "effort",
        "label": "Công sức",
        "type": "number",
        "value": 2,
        "required": true,
        "min": 1,
        "max": 3,
        "options": null,
        "hint": null,
        "pattern": null
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Công sức",
        "readingOrder": 2,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "starter-task-review-2",
      "type": "Field",
      "props": {
        "name": "first_due_local_date",
        "label": "Đến hạn đầu",
        "type": "date",
        "value": "2026-10-14",
        "required": true,
        "min": null,
        "max": null,
        "options": null,
        "hint": null,
        "pattern": null
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Đến hạn đầu",
        "readingOrder": 3,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "starter-task-review-3",
      "type": "Field",
      "props": {
        "name": "intervalDays",
        "label": "Lặp mỗi (ngày)",
        "type": "number",
        "value": 1,
        "required": true,
        "min": 1,
        "max": null,
        "options": null,
        "hint": null,
        "pattern": null
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Lặp mỗi (ngày)",
        "readingOrder": 4,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "starter-task-review-4",
      "type": "ChoiceGroup",
      "props": {
        "legend": "Người phụ trách",
        "name": "assignee",
        "options": [
          [
            "an",
            "An"
          ],
          [
            "minh",
            "Minh"
          ]
        ],
        "multiple": false
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Xem lại trước khi tạo · ChoiceGroup",
        "readingOrder": 5,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "starter-task-review-5",
      "type": "Notice",
      "props": {
        "text": "Bếp chung · cố định. Có thể chuyển sang luân phiên trong chi tiết việc.",
        "tone": ""
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Xem lại trước khi tạo · Notice",
        "readingOrder": 6,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "screen-actions",
      "type": "ActionGroup",
      "props": {
        "actions": [
          {
            "id": "create-starter",
            "label": "Xác nhận tạo bản mẫu",
            "kind": "mutate",
            "target": "setup-complete",
            "confirmationRequired": true
          },
          {
            "id": "link-setup-starter-tasks",
            "label": "Bắt đầu từ vài việc nhỏ",
            "kind": "navigate",
            "target": "setup-starter-tasks",
            "confirmationRequired": false
          },
          {
            "id": "link-settings",
            "label": "Cài đặt",
            "kind": "navigate",
            "target": "settings",
            "confirmationRequired": false
          }
        ],
        "primaryCount": 1
      },
      "tokens": {
        "lightBackground": "{component.light.button.background}",
        "lightForeground": "{component.light.button.foreground}",
        "darkBackground": "{component.dark.button.background}",
        "darkForeground": "{component.dark.button.foreground}",
        "height": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Hành động của màn hình",
        "keyboard": true,
        "focusVisible": true,
        "disabledOnlyLowContrast": true
      }
    }
  ],
  "fields": [
    {
      "id": "title",
      "label": "Tên việc",
      "control": "text",
      "default": "Rửa bát sau bữa tối",
      "options": null,
      "validation": {
        "required": true,
        "trim": true,
        "type": "text",
        "min": null,
        "max": null,
        "pattern": null,
        "serverAuthoritative": true,
        "errorMessage": "Kiểm tra tên việc.",
        "nonBlank": true
      },
      "binding": "title",
      "keyboard": "text",
      "accessibleErrorAssociation": "form error summary via role alert; native bind field-specific error ID"
    },
    {
      "id": "effort",
      "label": "Công sức",
      "control": "number",
      "default": 2,
      "options": null,
      "validation": {
        "required": true,
        "trim": false,
        "type": "number",
        "min": 1,
        "max": 3,
        "pattern": null,
        "serverAuthoritative": true,
        "errorMessage": "Kiểm tra công sức."
      },
      "binding": "effort",
      "keyboard": "numeric",
      "accessibleErrorAssociation": "form error summary via role alert; native bind field-specific error ID"
    },
    {
      "id": "first_due_local_date",
      "label": "Đến hạn đầu",
      "control": "date",
      "default": "2026-10-14",
      "options": null,
      "validation": {
        "required": true,
        "trim": false,
        "type": "date",
        "min": null,
        "max": null,
        "pattern": null,
        "serverAuthoritative": true,
        "errorMessage": "Kiểm tra đến hạn đầu."
      },
      "binding": "first_due_local_date",
      "keyboard": "date",
      "accessibleErrorAssociation": "form error summary via role alert; native bind field-specific error ID"
    },
    {
      "id": "intervalDays",
      "label": "Lặp mỗi (ngày)",
      "control": "number",
      "default": 1,
      "options": null,
      "validation": {
        "required": true,
        "trim": false,
        "type": "number",
        "min": 1,
        "max": null,
        "pattern": null,
        "serverAuthoritative": true,
        "errorMessage": "Kiểm tra lặp mỗi (ngày)."
      },
      "binding": "intervalDays",
      "keyboard": "numeric",
      "accessibleErrorAssociation": "form error summary via role alert; native bind field-specific error ID"
    },
    {
      "id": "assignee",
      "label": "Người phụ trách",
      "control": "radio",
      "options": [
        {
          "value": "an",
          "label": "An"
        },
        {
          "value": "minh",
          "label": "Minh"
        }
      ],
      "validation": {
        "required": true,
        "allowlist": [
          "an",
          "minh"
        ],
        "minSelections": 1,
        "errorMessage": "Chọn ít nhất một mục phù hợp."
      },
      "binding": "assignee",
      "accessibleErrorAssociation": "form error summary via role alert; native bind field-specific error ID"
    }
  ],
  "states": [
    {
      "id": "review",
      "when": "Draft đã chọn",
      "visibleUI": "Tất cả trường tạo được xem trước",
      "availableActions": [
        "create-starter",
        "link-setup-starter-tasks",
        "link-settings"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "invalid",
      "when": "Effort/lặp/ngày sai",
      "visibleUI": "Giữ draft và đánh dấu trường",
      "availableActions": [
        "create-starter",
        "link-setup-starter-tasks",
        "link-settings"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    }
  ],
  "actions": [
    {
      "id": "create-starter",
      "label": "Xác nhận tạo bản mẫu",
      "kind": "mutate",
      "targetScreenId": "setup-complete",
      "permission": "E",
      "confirmationRequired": true,
      "contractRef": "POST /v1/households/{hid}/tasks",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": "Stable actor/household/command key and canonical body; changed payload is a new confirmed intent."
    },
    {
      "id": "link-setup-starter-tasks",
      "label": "Bắt đầu từ vài việc nhỏ",
      "kind": "navigate",
      "targetScreenId": "setup-starter-tasks",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-settings",
      "label": "Cài đặt",
      "kind": "navigate",
      "targetScreenId": "settings",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    }
  ],
  "dataBindings": [
    {
      "source": "POST /v1/households/{hid}/tasks",
      "shape": {
        "task_id": "opaque ID",
        "room_id": "same-home ID",
        "title": "string",
        "effort": "1|2|3",
        "recurrence": "{kind:interval,intervalDays:integer}|{kind:weekdays,weekdays:1..7[]}",
        "anchor_local_date": "date",
        "assignment_mode": "fixed|round_robin|auto",
        "eligible_member_ids": "same-home active ID[]",
        "version": "integer"
      },
      "sample": {
        "task_id": "dishes",
        "room_id": "kitchen",
        "title": "Rửa bát sau bữa tối",
        "effort": 2,
        "recurrence": {
          "kind": "interval",
          "intervalDays": 1
        },
        "anchor_local_date": "2026-10-14",
        "assignment_mode": "fixed",
        "eligible_member_ids": [
          "an"
        ],
        "version": 1
      },
      "sampleOnly": true,
      "actorConstraint": "exact actor allowlist",
      "envelope": "API refs use CommandEnvelope; local review context is not an API property."
    }
  ],
  "copy": {
    "heading": "Xem lại trước khi tạo",
    "primary": "Xác nhận tạo bản mẫu",
    "empty": null,
    "notices": [
      "Bếp chung · cố định. Có thể chuyển sang luân phiên trong chi tiết việc."
    ],
    "locale": "vi",
    "demoLabel": "Bản thiết kế · dữ liệu mẫu · không kết nối dịch vụ"
  },
  "implementation": {
    "nativeRoute": "/design/starter-task-review",
    "nativeRouteStatus": "proposed mapping, verify against implementing native navigator",
    "apiRefs": [
      "POST /v1/households/{hid}/tasks"
    ],
    "newContractRefs": [],
    "notes": [
      "Tất cả ví dụ là dữ liệu thiết kế, không bằng chứng native/API/store đã chạy.",
      "Native route dưới đây là đề xuất mapping cho agent, không tuyên bố route source đã tồn tại.",
      "Mọi mutation dùng envelope {data,version,household_revision,replayed}, stable Idempotency-Key và expected_version khi sửa.",
      "Accepted-day recurrence; occurrence due/effort snapshot bất biến; snooze không đổi anchor; pending không reassign; undo điều chỉnh ledger đúng một lần."
    ],
    "integrationStatus": "design complete; local static/draft interactions; native/API adapters pending",
    "sourceAuthority": [
      "docs/product-brief.md",
      "plans/261013-1409-sweepy-vietnam-mobile/mobile-flows.md",
      "plans/261013-1409-sweepy-vietnam-mobile/api-contracts.md",
      "packages/domain/src/contracts/phase2.ts",
      "packages/domain/src/index.ts",
      "packages/domain/src/contracts/phase3.ts",
      "packages/domain/src/contracts/billing.ts",
      "apps/mobile/src/lib/api.ts"
    ],
    "capability": "A",
    "errors": {
      "401": "Stop queue; adult login or child re-pair without parent account.",
      "403": "Do not retry lost capability. FEATURE_REQUIRED never grants Pro.",
      "409": "Fetch canonical scoped state; review/reconfirm new intent, do not rewrite old replay payload.",
      "422": "Field error with retained draft.",
      "429": "Respect Retry-After.",
      "503": "Backoff only retryable commands with original key."
    }
  }
}
