{
  "schemaVersion": "1.0",
  "id": "schedule-conflicts",
  "title": "Cần xem lại một vài việc",
  "purpose": "Conflict handling không chuyển pending hoặc tự map IDs sai.",
  "roles": [
    "adult"
  ],
  "group": "calendar-scheduling",
  "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 forecast",
        "componentIds": [
          "screen-header",
          "schedule-conflicts-0",
          "schedule-conflicts-1",
          "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": "E+Pro",
        "backTarget": "schedule-preview",
        "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": "schedule-conflicts-0",
      "type": "ConflictList",
      "props": {
        "contentText": "Lau sàn phòng khách  Vượt công sức ngày  Ngày 15/10 cần 5, ngân sách mẫu là 4. Chọn ngày khác hoặc sửa ngân sách.    Tưới cây nhỏ  Giữ nguyên · chờ duyệt  Không chuyển người hoặc ngày khi Bông đang chờ phụ huynh xem."
      },
      "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ần xem lại một vài việc · ConflictList",
        "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": "schedule-conflicts-1",
      "type": "Notice",
      "props": {
        "text": "Nếu người đủ điều kiện đã rời hộ, chọn lại bằng ID hợp lệ, không tự chọn theo tên.",
        "tone": "warn"
      },
      "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ần xem lại một vài việc · Notice",
        "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": "screen-actions",
      "type": "ActionGroup",
      "props": {
        "actions": [
          {
            "id": "navigate-0",
            "label": "Sửa ngân sách",
            "kind": "navigate",
            "target": "schedule-preferences",
            "confirmationRequired": false
          },
          {
            "id": "navigate-1",
            "label": "Xem lại đề xuất",
            "kind": "navigate",
            "target": "schedule-preview",
            "confirmationRequired": false
          },
          {
            "id": "navigate-2",
            "label": "Phân công thủ công",
            "kind": "navigate",
            "target": "task-assignment",
            "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": [],
  "states": [
    {
      "id": "budget",
      "when": "BUDGET_EXCEEDED",
      "visibleUI": "Row nêu required/budget",
      "availableActions": [
        "navigate-0",
        "navigate-1",
        "navigate-2",
        "link-settings"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "eligible",
      "when": "NO_ELIGIBLE_MEMBER",
      "visibleUI": "Không apply candidate",
      "availableActions": [
        "navigate-0",
        "navigate-1",
        "navigate-2",
        "link-settings"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "stale",
      "when": "Template stale references",
      "visibleUI": "Sửa refs chính xác",
      "availableActions": [
        "navigate-0",
        "navigate-1",
        "navigate-2",
        "link-settings"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    }
  ],
  "actions": [
    {
      "id": "navigate-0",
      "label": "Sửa ngân sách",
      "kind": "navigate",
      "targetScreenId": "schedule-preferences",
      "permission": "E+Pro",
      "confirmationRequired": false,
      "contractRef": "local navigation",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": null
    },
    {
      "id": "navigate-1",
      "label": "Xem lại đề xuất",
      "kind": "navigate",
      "targetScreenId": "schedule-preview",
      "permission": "E+Pro",
      "confirmationRequired": false,
      "contractRef": "local navigation",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": null
    },
    {
      "id": "navigate-2",
      "label": "Phân công thủ công",
      "kind": "navigate",
      "targetScreenId": "task-assignment",
      "permission": "E+Pro",
      "confirmationRequired": false,
      "contractRef": "local navigation",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": null
    },
    {
      "id": "link-settings",
      "label": "Cài đặt",
      "kind": "navigate",
      "targetScreenId": "settings",
      "permission": "E+Pro",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    }
  ],
  "dataBindings": [
    {
      "source": "POST /v1/households/{hid}/schedule/preview",
      "shape": {
        "input_revision": "integer",
        "household_version": "integer",
        "preferences_version": "integer",
        "algorithm_version": "string",
        "start_local_date": "date",
        "days": "1..14",
        "choices": "ScheduleChoiceDto[] (locked respected)",
        "conflicts": "ScheduleConflictDto[]"
      },
      "sample": {
        "input_revision": 1,
        "household_version": 1,
        "preferences_version": 1,
        "algorithm_version": "design-example",
        "start_local_date": "2026-10-14",
        "days": 7,
        "choices": [],
        "conflicts": [
          {
            "candidate_id": "floor",
            "reason": "BUDGET_EXCEEDED"
          }
        ]
      },
      "sampleOnly": true,
      "actorConstraint": "exact actor allowlist",
      "envelope": "API refs use CommandEnvelope; local review context is not an API property."
    }
  ],
  "copy": {
    "heading": "Cần xem lại một vài việc",
    "primary": "Sửa ngân sách",
    "empty": null,
    "notices": [
      "Nếu người đủ điều kiện đã rời hộ, chọn lại bằng ID hợp lệ, không tự chọn theo tên."
    ],
    "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/schedule-conflicts",
    "nativeRouteStatus": "proposed mapping, verify against implementing native navigator",
    "apiRefs": [
      "POST /v1/households/{hid}/schedule/preview"
    ],
    "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."
    ],
    "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": "E+Pro",
    "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."
    }
  }
}
