<?xml version="1.0" encoding="UTF-8"?>
<mxfile host="drawio" version="31.0.2">
  <diagram name="Tiered Memory and Nightly Consolidation">
    <mxGraphModel dx="1200" dy="700" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1120" pageHeight="590" background="#ffffff">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />

        <!-- Title -->
        <mxCell id="title" value="Personal Agent 分层记忆与异步后台整合（Dream / Consolidation）机制" style="text;html=1;align=center;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#0f172a;fontFamily=PingFang SC,Microsoft YaHei,Helvetica,Arial;" vertex="1" parent="1">
          <mxGeometry x="30" y="18" width="1060" height="34" as="geometry" />
        </mxCell>
        <mxCell id="sub" value="综合 OpenClaw、Meta Muse（Hatch）、Hermes Agent 与 Anthropic Managed Agents 的记忆工程收敛形态" style="text;html=1;align=center;verticalAlign=middle;fontSize=13;fontColor=#475569;fontFamily=PingFang SC,Microsoft YaHei,Helvetica,Arial;" vertex="1" parent="1">
          <mxGeometry x="30" y="52" width="1060" height="22" as="geometry" />
        </mxCell>

        <!-- Tier 1: Hot Working Context -->
        <mxCell id="t1" value="T1 · 热工作上下文&#xa;（Model Context Window）" style="swimlane;startSize=44;rounded=1;fillColor=#eff6ff;strokeColor=#2563eb;strokeWidth=2;fontSize=13;fontStyle=1;fontColor=#1d4ed8;fontFamily=PingFang SC,Microsoft YaHei,Helvetica,Arial;container=1;pointerEvents=0;" vertex="1" parent="1">
          <mxGeometry x="20" y="100" width="220" height="230" as="geometry" />
        </mxCell>
        <mxCell id="t1_b" value="• 固定系统前缀（保 KV-Cache）&#xa;• SOUL / USER / MEMORY.md&#xa;• 当前会话近期轮次&#xa;• 动态复述 todo.md（防漂移）&#xa;• 保留错误轨迹（促自我纠正）" style="text;html=1;align=left;verticalAlign=top;whiteSpace=wrap;spacing=10;fontSize=13;fontColor=#1e293b;lineHeight=145;fontFamily=PingFang SC,Microsoft YaHei,Helvetica,Arial;" vertex="1" parent="t1">
          <mxGeometry x="6" y="48" width="208" height="174" as="geometry" />
        </mxCell>

        <!-- Tier 2: Durable Session Log -->
        <mxCell id="t2" value="T2 · 不可变会话事件流&#xa;（Append-Only Log）" style="swimlane;startSize=44;rounded=1;fillColor=#f5f3ff;strokeColor=#7c3aed;strokeWidth=2;fontSize=13;fontStyle=1;fontColor=#5b21b6;fontFamily=PingFang SC,Microsoft YaHei,Helvetica,Arial;container=1;pointerEvents=0;" vertex="1" parent="1">
          <mxGeometry x="306" y="100" width="220" height="230" as="geometry" />
        </mxCell>
        <mxCell id="t2_b" value="• 原始消息与工具输出全落盘&#xa;• 不做不可逆销毁式压缩&#xa;• 大网页/文件仅留 URL 路径&#xa;• 支持 getEvents() 切片回放&#xa;• 前沿方向：KV-LTM 持久缓存" style="text;html=1;align=left;verticalAlign=top;whiteSpace=wrap;spacing=10;fontSize=13;fontColor=#1e293b;lineHeight=145;fontFamily=PingFang SC,Microsoft YaHei,Helvetica,Arial;" vertex="1" parent="t2">
          <mxGeometry x="6" y="48" width="208" height="174" as="geometry" />
        </mxCell>

        <!-- Tier 3: Human-Readable Markdown Bank -->
        <mxCell id="t3" value="T3 · 人类可读 Markdown 档案&#xa;（File System as Memory）" style="swimlane;startSize=44;rounded=1;fillColor=#f0fdf4;strokeColor=#16a34a;strokeWidth=2;fontSize=13;fontStyle=1;fontColor=#15803d;fontFamily=PingFang SC,Microsoft YaHei,Helvetica,Arial;container=1;pointerEvents=0;" vertex="1" parent="1">
          <mxGeometry x="592" y="100" width="220" height="230" as="geometry" />
        </mxCell>
        <mxCell id="t3_b" value="• ~/MEMORY.md：事实与承诺&#xa;• ~/memory/YYYY-MM-DD.md&#xa;• memory/bank/：经历与偏好&#xa;• skills/*/SKILL.md：沉淀 SOP&#xa;• 用户可直接审阅、编辑、删改" style="text;html=1;align=left;verticalAlign=top;whiteSpace=wrap;spacing=10;fontSize=13;fontColor=#1e293b;lineHeight=145;fontFamily=PingFang SC,Microsoft YaHei,Helvetica,Arial;" vertex="1" parent="t3">
          <mxGeometry x="6" y="48" width="208" height="174" as="geometry" />
        </mxCell>

        <!-- Tier 4: Indexed Evidence Store -->
        <mxCell id="t4" value="T4 · 混合检索与证据库&#xa;（Postgres / SQLite FTS5）" style="swimlane;startSize=44;rounded=1;fillColor=#fffbeb;strokeColor=#d97706;strokeWidth=2;fontSize=13;fontStyle=1;fontColor=#b45309;fontFamily=PingFang SC,Microsoft YaHei,Helvetica,Arial;container=1;pointerEvents=0;" vertex="1" parent="1">
          <mxGeometry x="878" y="100" width="222" height="230" as="geometry" />
        </mxCell>
        <mxCell id="t4_b" value="• 全文（FTS5）+ 向量 RRF&#xa;• 声明表记录 quote 与行号&#xa;• supersedes_claim_id 覆盖&#xa;• 真正遗忘：撤回+重建索引&#xa;• memory_explain 追溯出处" style="text;html=1;align=left;verticalAlign=top;whiteSpace=wrap;spacing=10;fontSize=13;fontColor=#1e293b;lineHeight=145;fontFamily=PingFang SC,Microsoft YaHei,Helvetica,Arial;" vertex="1" parent="t4">
          <mxGeometry x="6" y="48" width="210" height="174" as="geometry" />
        </mxCell>

        <!-- Horizontal flow arrows between T1 -> T2 -> T3 -> T4 -->
        <mxCell id="f12" value="落盘" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#475569;strokeWidth=2;fontSize=12;fontColor=#334155;labelBackgroundColor=#ffffff;exitX=1;exitY=0.5;entryX=0;entryY=0.5;" edge="1" parent="1" source="t1" target="t2">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="f23" value="提炼" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#475569;strokeWidth=2;fontSize=12;fontColor=#334155;labelBackgroundColor=#ffffff;exitX=1;exitY=0.5;entryX=0;entryY=0.5;" edge="1" parent="1" source="t2" target="t3">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="f34" value="建索引" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#475569;strokeWidth=2;fontSize=12;fontColor=#334155;labelBackgroundColor=#ffffff;exitX=1;exitY=0.5;entryX=0;entryY=0.5;" edge="1" parent="1" source="t3" target="t4">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>

        <!-- Bottom: Async Background Consolidation Jobs -->
        <mxCell id="bg" value="后台异步整合与自我校准引擎（Hourly &amp; Nightly Jobs）" style="swimlane;startSize=34;rounded=1;fillColor=#fdf2f8;strokeColor=#db2777;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#9d174d;fontFamily=PingFang SC,Microsoft YaHei,Helvetica,Arial;container=1;pointerEvents=0;" vertex="1" parent="1">
          <mxGeometry x="30" y="396" width="1060" height="164" as="geometry" />
        </mxCell>

        <mxCell id="bg1" value="&lt;b&gt;① 每小时事实核验与归档&lt;/b&gt;&#xa;比对原始消息与新声明，标注置信度&#xa;决定写入 MEMORY.md 或归入日记" style="rounded=1;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;spacingLeft=12;fillColor=#ffffff;strokeColor=#f472b6;fontSize=13;fontColor=#1e293b;lineHeight=140;fontFamily=PingFang SC,Microsoft YaHei,Helvetica,Arial;" vertex="1" parent="bg">
          <mxGeometry x="18" y="48" width="320" height="96" as="geometry" />
        </mxCell>
        <mxCell id="bg2" value="&lt;b&gt;② 夜间“做梦”反思（Nightly Dream）&lt;/b&gt;&#xa;回顾全天交互习惯（如回复长度/打扰频率）&#xa;生成 ALIGNMENT_SYNTHESIS 指导后续会话" style="rounded=1;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;spacingLeft=12;fillColor=#ffffff;strokeColor=#f472b6;fontSize=13;fontColor=#1e293b;lineHeight=140;fontFamily=PingFang SC,Microsoft YaHei,Helvetica,Arial;" vertex="1" parent="bg">
          <mxGeometry x="370" y="48" width="320" height="96" as="geometry" />
        </mxCell>
        <mxCell id="bg3" value="&lt;b&gt;③ Skill 沉淀与安全回归门控&lt;/b&gt;&#xa;复杂成功任务提炼为可复用 SKILL.md&#xa;通过 Safe Personal RSI 检查后才生效，失败回滚" style="rounded=1;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;spacingLeft=12;fillColor=#ffffff;strokeColor=#f472b6;fontSize=13;fontColor=#1e293b;lineHeight=140;fontFamily=PingFang SC,Microsoft YaHei,Helvetica,Arial;" vertex="1" parent="bg">
          <mxGeometry x="722" y="48" width="320" height="96" as="geometry" />
        </mxCell>

        <!-- Vertical feedback arrows between Tiers and Async Engine -->
        <mxCell id="fb_down" value="读取历史轨迹与证据" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#db2777;strokeWidth=2;fontSize=12;fontColor=#9d174d;labelBackgroundColor=#ffffff;exitX=0.5;exitY=1;entryX=0.39;entryY=0;" edge="1" parent="1" source="t2" target="bg">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="fb_up1" value="按需召回注入" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#2563eb;strokeWidth=2;dashed=1;fontSize=12;fontColor=#1d4ed8;labelBackgroundColor=#ffffff;exitX=0.11;exitY=0;entryX=0.5;entryY=1;" edge="1" parent="1" source="bg" target="t1">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="fb_up2" value="写回偏好与 Skill" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#16a34a;strokeWidth=2;fontSize=12;fontColor=#15803d;labelBackgroundColor=#ffffff;exitX=0.63;exitY=0;entryX=0.5;entryY=1;" edge="1" parent="1" source="bg" target="t3">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="fb_up3" value="同步/撤回索引" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#d97706;strokeWidth=2;fontSize=12;fontColor=#b45309;labelBackgroundColor=#ffffff;exitX=0.89;exitY=0;entryX=0.5;entryY=1;" edge="1" parent="1" source="bg" target="t4">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>

      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
