{
  "schema_version": 2,
  "diagram_type": "workflow",
  "meta": {
    "title": "SOFAI: S1 mặc định, meta-cognition quyết định có gọi S2",
    "quality_profile": "showcase",
    "views": [
      {
        "id": "fast",
        "label": "Đường nhanh",
        "focus": [
          "task",
          "s1",
          "mc1",
          "decision"
        ],
        "note": "S1 trả lời ngay kèm confidence; MC1 nhận luôn nếu confidence đủ so với reward kỳ vọng hoặc không đủ tài nguyên cho MC2."
      },
      {
        "id": "slow",
        "label": "Đường chậm",
        "focus": [
          "mc1",
          "mc2",
          "models",
          "s2",
          "decision"
        ],
        "note": "MC2 gọi S2 khi reward tăng thêm lớn hơn chi phí chạy S2 (dựa trên model of self); ngược lại vẫn dùng lời giải S1."
      }
    ],
    "legend": {
      "mode": "hidden"
    }
  },
  "lanes": [
    {
      "id": "solve",
      "label": "Solver"
    },
    {
      "id": "mc",
      "label": "Meta-cognition"
    },
    {
      "id": "models",
      "label": "Model của hệ thống"
    }
  ],
  "phases": [
    {
      "id": "p-s1",
      "label": "System 1",
      "fromCol": 0,
      "toCol": 1
    },
    {
      "id": "p-mc",
      "label": "MC1 → MC2",
      "fromCol": 2,
      "toCol": 3,
      "variant": "emphasis"
    },
    {
      "id": "p-s2",
      "label": "System 2",
      "fromCol": 4,
      "toCol": 5,
      "variant": "dashed"
    }
  ],
  "mainPath": [
    "task",
    "s1",
    "mc1",
    "mc2",
    "s2",
    "decision"
  ],
  "nodes": [
    {
      "id": "task",
      "lane": "solve",
      "col": 0,
      "type": "external",
      "label": "Task",
      "sublabel": "bài toán mới",
      "width": 132
    },
    {
      "id": "s1",
      "lane": "solve",
      "col": 1,
      "type": "backend",
      "label": "S1 solver",
      "sublabel": "kinh nghiệm, O(1)",
      "width": 132
    },
    {
      "id": "mc1",
      "lane": "mc",
      "col": 2,
      "type": "security",
      "label": "MC1",
      "sublabel": "nhanh, xấp xỉ",
      "width": 132
    },
    {
      "id": "mc2",
      "lane": "mc",
      "col": 3,
      "type": "security",
      "label": "MC2",
      "sublabel": "kỹ, tốn hơn",
      "width": 132
    },
    {
      "id": "s2",
      "lane": "solve",
      "col": 4,
      "type": "backend",
      "label": "S2 solver",
      "sublabel": "suy luận, tìm kiếm",
      "width": 132
    },
    {
      "id": "decision",
      "lane": "solve",
      "col": 5,
      "type": "frontend",
      "label": "Quyết định",
      "sublabel": "lời giải cuối",
      "width": 132
    },
    {
      "id": "models",
      "lane": "models",
      "col": 3,
      "type": "database",
      "label": "Model of self",
      "sublabel": "+ world, others",
      "width": 132
    },
    {
      "id": "updater",
      "lane": "models",
      "col": 1,
      "type": "messagebus",
      "label": "Model updater",
      "sublabel": "chạy nền, train S1",
      "width": 132
    }
  ],
  "edges": [
    {
      "id": "task-s1",
      "from": "task",
      "to": "s1"
    },
    {
      "id": "s1-mc1",
      "from": "s1",
      "to": "mc1",
      "label": "lời giải + confidence",
      "variant": "emphasis"
    },
    {
      "id": "mc1-mc2",
      "from": "mc1",
      "to": "mc2",
      "label": "chưa đủ tin"
    },
    {
      "id": "mc2-s2",
      "from": "mc2",
      "to": "s2",
      "label": "lợi thêm > chi phí",
      "variant": "emphasis"
    },
    {
      "id": "s2-decision",
      "from": "s2",
      "to": "decision"
    },
    {
      "id": "mc1-adopt",
      "from": "mc1",
      "to": "decision",
      "label": "dùng S1",
      "variant": "dashed",
      "role": "branch",
      "route": "up-channel",
      "fromSide": "top",
      "toSide": "top"
    },
    {
      "id": "models-mc2",
      "from": "models",
      "to": "mc2",
      "label": "reward, chi phí cũ",
      "variant": "dashed"
    },
    {
      "id": "updater-models",
      "from": "updater",
      "to": "models"
    },
    {
      "id": "mc2-adopt",
      "from": "mc2",
      "to": "decision",
      "label": "dùng S1",
      "variant": "dashed",
      "role": "branch"
    },
    {
      "id": "updater-s1",
      "from": "updater",
      "to": "s1",
      "label": "train lại",
      "variant": "dashed"
    },
    {
      "id": "models-mc1",
      "from": "models",
      "to": "mc1",
      "label": "reward kỳ vọng",
      "variant": "dashed"
    }
  ],
  "cards": [
    {
      "dot": "cyan",
      "title": "Nguyên tắc",
      "items": [
        "S1 mặc định, S2 chỉ chạy khi MC gọi",
        "S2 không mặc định tốt hơn S1"
      ]
    },
    {
      "dot": "rose",
      "title": "Giới hạn của paper",
      "items": [
        "Short paper, chưa có kết quả thí nghiệm",
        "Giả định 1 solver S1 và 1 solver S2 mỗi task"
      ]
    }
  ]
}