{
  "schema_version": 1,
  "diagram_type": "dataflow",
  "meta": {
    "title": "Trí nhớ: ghi, cô đọng hằng tuần, cổng tự áp dụng",
    "locale": "vi",
    "output": "diagrams/memory.html",
    "viewBox": [
      1080,
      640
    ],
    "quality_profile": "showcase"
  },
  "stages": [
    {
      "label": "Ai ghi"
    },
    {
      "label": "Đường ghi"
    },
    {
      "label": "Tệp trên đĩa"
    },
    {
      "label": "Cô đọng hằng tuần"
    },
    {
      "label": "Kết quả"
    }
  ],
  "nodes": [
    {
      "id": "chat",
      "type": "frontend",
      "label": "Cuộc trò chuyện",
      "sublabel": "bạn đang có mặt",
      "stage": 0,
      "row": 0,
      "tag": "chat · Telegram",
      "height": 72,
      "yOffset": 9
    },
    {
      "id": "job",
      "type": "external",
      "label": "Job theo lịch",
      "sublabel": "không ai trông",
      "stage": 0,
      "row": 2,
      "tag": "chạy đêm",
      "height": 72
    },
    {
      "id": "note_save",
      "type": "backend",
      "label": "memory_save",
      "sublabel": "nối một dòng HH:MM",
      "stage": 1,
      "row": 0,
      "tag": "không cần duyệt",
      "height": 72,
      "width": 132
    },
    {
      "id": "fact_save",
      "type": "security",
      "label": "user_memory_save",
      "sublabel": "hoà giải bằng code",
      "stage": 1,
      "row": 1,
      "tag": "basis · hiệu lực",
      "height": 72,
      "width": 136
    },
    {
      "id": "proposal",
      "type": "security",
      "label": "Đề xuất",
      "sublabel": "chờ người quyết",
      "stage": 1,
      "row": 2,
      "tag": "memory_proposals",
      "height": 72,
      "width": 132
    },
    {
      "id": "notes",
      "type": "database",
      "label": "Ghi chú ngày",
      "sublabel": "memory/YYYY-MM-DD.md",
      "stage": 2,
      "row": 0,
      "tag": "hôm nay + hôm qua",
      "height": 72,
      "width": 136
    },
    {
      "id": "facts",
      "type": "database",
      "label": "Facts dùng chung",
      "sublabel": "users/owner/facts/",
      "stage": 2,
      "row": 1,
      "tag": "mọi agent đọc",
      "height": 72,
      "width": 136
    },
    {
      "id": "memory_md",
      "type": "database",
      "label": "MEMORY.md",
      "sublabel": "mỗi dòng mang ngày",
      "stage": 4,
      "row": 1,
      "tag": "system prompt",
      "height": 72,
      "width": 136,
      "yOffset": -16
    },
    {
      "id": "rewrite",
      "type": "backend",
      "label": "Viết lại",
      "sublabel": "model, 7 ngày gần nhất",
      "stage": 3,
      "row": 0,
      "tag": "ghi chú + trò chuyện",
      "height": 72,
      "width": 136
    },
    {
      "id": "screen",
      "type": "backend",
      "label": "Sàng dòng mới",
      "sublabel": "NHẬN / BỎ: lý do",
      "stage": 3,
      "row": 1,
      "tag": "khi có ngân sách",
      "height": 72,
      "width": 136
    },
    {
      "id": "gate",
      "type": "security",
      "label": "Cổng tự áp dụng",
      "sublabel": "code so bản cũ và mới",
      "stage": 3,
      "row": 2,
      "tag": "không phải model",
      "height": 72,
      "width": 136
    },
    {
      "id": "held",
      "type": "security",
      "label": "Chờ bạn duyệt",
      "sublabel": "báo một lần lên kênh",
      "stage": 4,
      "row": 2,
      "tag": "bỏ · sửa · ngày lạ",
      "height": 72,
      "width": 136,
      "yOffset": -9
    }
  ],
  "flows": [
    {
      "from": "chat",
      "to": "note_save",
      "label": "điều đáng nhớ",
      "variant": "default"
    },
    {
      "from": "chat",
      "to": "fact_save",
      "label": "ghi ngay",
      "variant": "emphasis"
    },
    {
      "from": "job",
      "to": "proposal",
      "label": "fact mới",
      "variant": "security"
    },
    {
      "from": "note_save",
      "to": "notes",
      "label": "nối",
      "variant": "default"
    },
    {
      "from": "fact_save",
      "to": "facts",
      "label": "hoà giải",
      "variant": "dashed"
    },
    {
      "from": "notes",
      "to": "rewrite",
      "label": "7 ngày",
      "variant": "default"
    },
    {
      "from": "rewrite",
      "to": "screen",
      "label": "dòng mới",
      "variant": "default",
      "labelDy": 25
    },
    {
      "from": "screen",
      "to": "gate",
      "label": "bản viết lại",
      "variant": "default",
      "labelDy": 25
    },
    {
      "from": "gate",
      "to": "memory_md",
      "label": "không mất gì",
      "variant": "emphasis",
      "labelSegment": 1
    },
    {
      "from": "gate",
      "to": "held",
      "label": "có thể mất",
      "variant": "security",
      "labelDy": 16
    },
    {
      "from": "held",
      "to": "memory_md",
      "label": "bạn duyệt",
      "variant": "dashed"
    }
  ],
  "cards": [
    {
      "dot": "cyan",
      "title": "Vào prompt",
      "items": [
        "MEMORY.md và mục lục facts mỗi lượt",
        "Ghi chú hôm nay, hôm qua trước tin mở lượt",
        "Phần còn lại chỉ qua memory_search"
      ]
    },
    {
      "dot": "amber",
      "title": "Hoà giải bằng code",
      "items": [
        "Lời bạn thắng điều agent suy ra",
        "Bản cũ vào lịch sử, có ngày kết thúc",
        "Suy luận trái lời bạn thành đề xuất"
      ]
    },
    {
      "dot": "emerald",
      "title": "Cổng",
      "items": [
        "Thêm dòng, đổi ngày: tự áp dụng",
        "Bỏ, sửa, ngày lạ: chờ duyệt",
        "Fact dùng chung: luôn chờ duyệt"
      ]
    }
  ]
}