# 07．記憶編譯型母 AI

## 從 Episode、Skill 到 Compiled Cognitive Topology

### 《母 AI 與區域認知體：AI 中心動態認知系統》第七篇

**作者：Neo.K × Aletheia**  
**版本：v0.1**  
**日期：2026-08-01**  
**文件性質：公開命題論文／Mother AI Memory Compilation 架構研究**

---

## 摘要

前六篇建立了 Mother AI 的持續認知核心、世界狀態機、可動態重構的 Sub-AI Fabric、二階控制、Persistent Runtime 與 Agent Lifecycle。這些機制讓 Mother AI 能在不同世界狀態下生成、組合、替換與回收不同子 AI。

但如果每一次世界事件仍然要求 Mother AI 從零判斷：

- 需要哪些 Agent；
- 使用哪個模型；
- 讀哪段記憶；
- 建立什麼拓撲；
- 分配多少預算；
- 採用哪條驗證路徑；
- 需要什麼權限；

那麼 Mother AI 依然會重複支付大量 Meta-Control 成本。

本文因此提出：

$$
\boxed{
\text{Memory-Compiled Mother AI}
}
$$

即「記憶編譯型母 AI」。

其核心不是單純保存過去的答案，而是將已完成的世界—認知—行動歷史：

$$
\tau_i
=
(
W_i,
M_i,
S_i,
G_i,
A_i,
R_i
)
$$

持續壓縮為：

$$
\boxed{
B_i
=
(
c_i,
\mathcal O_i^C,
\Theta_i,
V_i,
P_i,
w_i,
v_i,
t_i
)
}
$$

其中：

- $c_i$ ：world-state class；
- $\mathcal O_i^C$ ：Cognitive Option；
- $\Theta_i$ ：適用條件；
- $V_i$ ：驗證器；
- $P_i$ ：provenance／evidence；
- $w_i$ ：信心／效用權重；
- $v_i$ ：版本；
- $t_i$ ：時間與失效資訊。

Cognitive Option 不只是「做什麼」，而是：

$$
\mathcal O_i^C
=
(
\mathcal A_i,
\mathcal L_i,
\mathcal M_i^v,
G_i^C,
B_i,
\Gamma_i,
V_i,
\beta_i
)
$$

即：

- 應喚起哪些 Agent；
- 各 Agent 使用什麼模型；
- 取得哪些記憶切片；
- 採用什麼認知拓撲；
- 使用多少算力／時間；
- 哪些權限有效；
- 經過哪些驗證；
- 何時終止或退出快速通道。

因此本文把記憶編譯重新定義為：

$$
\boxed{
\text{歷史計算}
\rightarrow
\text{可重用的認知控制配置}
}
$$

而非：

$$
\text{歷史對話}
\rightarrow
\text{文字摘要}.
$$

2026 年 ProcMEM 已直接研究如何把 episodic interaction experience 轉成可重用 procedural skills，並用 activation、execution、termination 條件確保技能可執行；AFTER benchmark 亦顯示 procedural memory 在企業型任務中能跨任務、角色與模型帶來可量測的重用收益；MemCon 則把「何時取回、取多少、何時重取、何時 consolidation、何時 forget」本身建模為控制問題。更早的 Voyager 也已證明 executable skill library 可以累積、重用與組合複雜行為。

但本文同時採取比「持續總結一切」更保守的立場。2026 年研究已顯示，LLM 對 episodic traces 進行持續 consolidated-memory rewriting 可能產生失真，甚至讓原本有用的記憶隨更新而退化；原始 episodes 應保留為一級證據，而 consolidation 應有明確 gate。這與本文的基本原則一致：

$$
\boxed{
\text{Compiled Memory}
\neq
\text{Ground Truth}.
}
$$

因此 Mother AI 的記憶系統必須同時保存：

$$
\mathcal M
=
\mathcal M_E
\oplus
\mathcal M_S
\oplus
\mathcal M_P
\oplus
\mathcal M_T
\oplus
\mathcal M_M
$$

分別表示 episodic、semantic、procedural、topological 與 meta-memory。

本文提出完整編譯流程：

$$
\boxed{
\text{Record}
\rightarrow
\text{Validate}
\rightarrow
\text{Segment}
\rightarrow
\text{Deduplicate}
\rightarrow
\text{Classify}
\rightarrow
\text{Abstract}
\rightarrow
\text{Compile}
\rightarrow
\text{Shadow Test}
\rightarrow
\text{Promote}
\rightarrow
\text{Index}
}
$$

並要求任何 compiled item 都可以：

$$
\boxed{
\text{decompile}
\rightarrow
\text{revalidate}
\rightarrow
\text{recompile}.
}
$$

本文最終將 Mother AI 的成熟智能重新表述為：

$$
\boxed{
\text{已知世界狀態}
\rightarrow
\text{快速取回已編譯認知結構}
}
$$

$$
\boxed{
\text{真正未知}
\rightarrow
\text{重新生成與探索認知結構}
}
$$

所以「已知則編譯，未知則展開」在 Mother AI 中不只控制答案生成，而控制整個認知生態如何被組織。

**關鍵詞：** Mother AI、Memory Compilation、Procedural Memory、Episodic Memory、Cognitive Option、Skill Library、Memory Consolidation、Meta-Memory、Agent Topology、Long-Term Agent Memory

---

# 一、Mother AI 仍然可能重複支付計算成本

假設世界出現：

$$
W_t.
$$

Mother AI 重新決定：

$$
\mathcal C_t
=
(
Agent,
Model,
Memory,
Topology,
Budget,
Authority,
Verification
).
$$

即使以前遇過：

$$
W_{t-k}\sim W_t,
$$

如果系統完全重新 meta-reasoning，

則：

$$
K_{\mathrm{repeat}}
\approx
K_{\mathrm{first}}.
$$

這表示：

$$
\boxed{
\text{Persistent State}
\neq
\text{Reusable Cognition}.
}
$$

---

# 二、真正需要編譯的是「如何思考」

普通記憶：

> 上次答案是 X。

Mother AI 記憶：

> 上次這種狀態需要 Research Agent＋Legal Agent；先查兩個資料源，再由 Verifier 驗證；只有結果一致時才進入低權限執行。

因此真正可重用的是：

$$
\boxed{
\text{Cognitive Configuration}.
}
$$

---

# 三、認知軌跡

定義一次完整歷史：

$$
\tau_i
=
(
W_i,
Z_i^M,
S_i,
\mathcal C_i,
A_i,
W_i',
R_i
).
$$

其中：

- $W_i$ ：起始世界狀態；
- $Z_i^M$ ：Mother Meta-State；
- $S_i$ ：Sub-AI Fabric；
- $\mathcal C_i$ ：認知配置；
- $A_i$ ：實際世界行動；
- $W_i'$ ：後續世界狀態；
- $R_i$ ：結果／回饋。

這才是一個完整 episode。

---

# 四、Episode 不是一段聊天紀錄

聊天紀錄可能只保存：

$$
\text{text}.
$$

但 episode 還要保存：

- 世界狀態；
- 使用的 Agent；
- 模型；
- 工具；
- 記憶切片；
- 成本；
- 權限；
- 驗證；
- 執行結果；
- 實際 state change。

因此：

$$
\boxed{
\text{Agent Episode}
>
\text{Conversation Transcript}.
}
$$

---

# 五、五種記憶層

本文定義：

$$
\boxed{
\mathcal M
=
\mathcal M_E
\oplus
\mathcal M_S
\oplus
\mathcal M_P
\oplus
\mathcal M_T
\oplus
\mathcal M_M.
}
$$

---

# 六、Episodic Memory

$$
\mathcal M_E
$$

保存：

> 發生過什麼？

基本元素：

$$
E_i
=
(
state,
action,
agents,
outcome,
time,
evidence
).
$$

它是最接近原始經驗的記憶。

---

# 七、Semantic Memory

$$
\mathcal M_S
$$

保存：

> 世界有哪些相對穩定事實與概念？

例如：

- 客戶 A 的合約條款；
- 服務 X 的依賴；
- 某法規要求；
- 某系統架構。

它不必綁定某一次 episode。

---

# 八、Procedural Memory

$$
\mathcal M_P
$$

保存：

> 這類事情通常怎麼做？

例如：

$$
p_i
=
(
activation,
procedure,
termination,
validation
).
$$

這正是 ProcMEM 類研究所強調的可重用 skill。

---

# 九、Topological Memory

本文新增：

$$
\boxed{
\mathcal M_T.
}
$$

它保存：

> 這類事情應該由什麼 Agent constellation、通信圖與驗證圖處理？

例如：

$$
T_i
=
(
V_i,
E_i,
\Omega_i,
termination
).
$$

這是 Mother AI 特有的重點。

---

# 十、Meta-Memory

$$
\mathcal M_M
$$

保存：

> 我為什麼相信這份記憶？它在哪裡有效？何時應失效？

例如：

$$
m_i^M
=
(
source,
confidence,
scope,
version,
expiry,
dependency,
failure\ history
).
$$

所以：

$$
\boxed{
\text{記憶也需要自己的記憶。}
}
$$

---

# 十一、Cognitive Option

第四篇已提出：

$$
\mathcal O_i^C
=
(
\Theta_i,
A_i,
L_i,
M_i,
G_i,
B_i,
\Gamma_i,
V_i,
\beta_i
).
$$

現在正式把它放進 procedural／topological memory。

---

# 十二、Cognitive Option 不是固定 Workflow

固定 workflow：

$$
f_1\rightarrow f_2\rightarrow f_3.
$$

Cognitive Option 可以有：

- dynamic routing；
- conditional branch；
- parallel agents；
- optional verifier；
- authority gate；
- termination conditions。

因此：

$$
\boxed{
\text{Cognitive Option}
=
\text{可調用的認知策略結構}.
}
$$

---

# 十三、ProcMEM 提供直接工程參照

2026 年 ProcMEM 將：

$$
\text{episodic narratives}
$$

轉成：

$$
\text{executable skills}.
$$

每個 skill 定義：

- activation；
- execution；
- termination。

這與：

$$
\mathcal O_i^C
$$

非常接近。

它的重要訊號是：

$$
\boxed{
\text{Agent experience 可以非參數化地轉化成可重用 procedural memory}.
}
$$

---

# 十四、Mother AI 比 ProcMEM 多一層

單一 Agent skill：

$$
x\rightarrow procedure.
$$

Mother AI compiled option：

$$
x
\rightarrow
(
Agent\ team,
models,
memories,
topology,
budget,
authority,
verification
).
$$

所以：

$$
\boxed{
\text{Procedural Skill}
\subset
\text{Cognitive Option}.
}
$$

---

# 十五、Voyager 的 Skill Library 是更早的證據

Voyager 建立：

$$
\text{ever-growing executable skill library}.
$$

並能：

- retrieve；
- compose；
- reuse。

這證明：

$$
\boxed{
\text{歷史行動可以被儲存成可執行能力，而不只文字回憶}.
}
$$

---

# 十六、Skill Library 與 Mother AI Memory Library

Voyager 保存：

$$
\text{code skills}.
$$

Mother AI 要保存：

$$
\boxed{
\text{cognitive organization skills}.
}
$$

也就是：

> 如何組織一群智能資源來處理某類世界狀態。

---

# 十七、Memory Compiler

本文定義：

$$
\boxed{
\mathfrak C_M:
\{\tau_1,\ldots,\tau_n\}
\rightarrow
\{B_1,\ldots,B_k\}.
}
$$

其中：

$$
B_i
=
(
c_i,
\mathcal O_i^C,
\Theta_i,
V_i,
P_i,
w_i,
v_i,
t_i
).
$$

---

# 十八、 $c_i$ ：狀態類

不是保存一個精確 world snapshot：

$$
W_i.
$$

而是：

$$
c_i
=
[W]_{\sim}.
$$

若：

$$
W_a\sim W_b
$$

表示：

> 它們在 response-relevant dimensions 上可使用近似認知策略。

這延續前一系列的 quotient-space 思路。

---

# 十九、什麼叫 response-relevant？

例如兩台伺服器：

- hostname 不同；
- IP 不同；

但同樣：

- disk > 95%；
- backup available；
- low traffic；
- reversible cleanup。

則可屬同類：

$$
c_{\mathrm{disk\ pressure}}.
$$

不需要每個 hostname 建新 memory。

---

# 二十、編譯不是 memorize exact trajectory

如果保存：

$$
\tau_1,
\tau_2,\ldots
$$

並每次 nearest-neighbor replay，

仍然容易：

- 記憶爆炸；
- 過擬合；
- context cost 高。

真正編譯：

$$
\boxed{
\{\tau_i\}
\rightarrow
\text{equivalence class + reusable structure}.
}
$$

---

# 二十一、Memory Compilation Pipeline

本文提出：

$$
\boxed{
\text{Record}
\rightarrow
\text{Validate}
\rightarrow
\text{Segment}
\rightarrow
\text{Deduplicate}
\rightarrow
\text{Classify}
\rightarrow
\text{Abstract}
\rightarrow
\text{Compile}
\rightarrow
\text{Shadow Test}
\rightarrow
\text{Promote}
\rightarrow
\text{Index}.
}
$$

---

# 二十二、Record

先保存：

$$
\tau_i.
$$

重要原則：

$$
\boxed{
\text{先保存證據，再做摘要。}
}
$$

不能先摘要後把原始 episode 丟掉。

---

# 二十三、Validate

不是每次成功都值得學。

需檢查：

$$
V(\tau_i)
\in
\{pass,fail,uncertain\}.
$$

例如：

- outcome 是否真的成功；
- 是否只是偶然；
- 是否造成副作用；
- 是否有 hidden failure。

---

# 二十四、Segment

長 trajectory：

$$
\tau
$$

可以切成：

$$
\tau^{(1)},
\tau^{(2)},\ldots.
$$

因為不同部分可能對應不同 reusable skill。

---

# 二十五、Deduplicate

若：

$$
O(\tau_i,\tau_j)>\tau_o,
$$

不必同時編譯兩份。

保留：

- representative；
- counter；
- outcome variance；
- exceptions。

---

# 二十六、Classify

將 episode 對應到：

$$
c_i.
$$

若沒有合適 class：

$$
C(\tau)=\bot.
$$

保留到：

$$
\mathcal M_\bot.
$$

未知 episode 不要硬塞進既有類。

---

# 二十七、Abstract

從多個 episode 抽象：

$$
\text{irrelevant details}
\rightarrow
0.
$$

留下：

$$
\text{response-relevant structure}.
$$

這是最危險但最有價值的步驟。

---

# 二十八、Compile

形成：

$$
B_i.
$$

即：

$$
c_i
\Rightarrow
\mathcal O_i^C.
$$

---

# 二十九、Shadow Test

新 compiled memory 不應立即進 production fast path。

先：

$$
\boxed{
\text{shadow mode}.
}
$$

即：

> 用新 memory 預測應該怎麼做，但不真正控制主要決策。

和實際結果比較。

---

# 三十、Promote

若：

$$
Q(B_i)>\tau_Q
$$

且：

$$
R(B_i)<\tau_R,
$$

才：

$$
candidate
\rightarrow
compiled.
$$

---

# 三十一、Index

最後建立：

$$
I(B_i).
$$

使：

$$
K_{\mathrm{retrieve}}
$$

足夠低。

否則：

$$
|\mathcal M|\uparrow
$$

會讓記憶反而拖慢系統。

---

# 三十二、MemGPT 提供記憶階層的重要參照

MemGPT 把有限 context 視為：

$$
\text{fast memory},
$$

外部 storage 視為：

$$
\text{slow memory},
$$

透過類似 virtual memory 的方式在多層記憶間搬移資訊。

這與 Mother AI 的：

$$
hot/warm/cold
$$

memory hierarchy 相容。

但本文進一步關心：

> 不只哪段 memory 進 context，而是哪種 memory 應該成為可重用認知策略。

---

# 三十三、Memory Retrieval 不是固定函式

傳統：

$$
R(q)=\operatorname{TopK}(q).
$$

但 MemCon 2026 指出：

$$
\boxed{
\text{optimal memory behavior is context-dependent}.
}
$$

有時：

- 少取；
- 多取；
- 重取；
- 取 distilled plan；
- consolidation；
- forget。

都可能是正確策略。

---

# 三十四、記憶本身也需要二階控制

因此：

$$
\Pi_{\mathrm{mem}}
:
Z_t
\rightarrow
a_t^{mem}.
$$

其中：

$$
a_t^{mem}
\in
\{
retrieve,
reretrieve,
inject\_plan,
consolidate,
forget,
retain
\}.
$$

所以：

$$
\boxed{
\text{Memory Management}
}
$$

本身也是 Mother AI Meta-Control 的子空間。

---

# 三十五、MemCon 與 Mother AI 的重要交點

MemCon 把 memory operation 當成 MDP。

Mother AI 可以更一般：

$$
\boxed{
\text{memory state}
+
\text{cognitive topology state}
+
\text{world state}
}
$$

共同決定：

$$
\text{retrieve / compile / forget / explore}.
$$

---

# 三十六、Procedural Memory 確實可以跨任務重用

2026 年 AFTER benchmark：

- 382 個 realistic enterprise tasks；
- 六種 professional roles；
- 22 種 procedural skills。

研究結果顯示 procedural memory 能產生：

- local improvement；
- cross-task transfer；
- cross-role transfer；
- cross-model generalization。

這對企業 Mother AI 非常重要。

因為：

$$
\boxed{
\text{程序知識可以跨 Agent instance 與模型保存}.
}
$$

---

# 三十七、這意味著 Mother AI Identity 可以跨模型

若：

$$
L_A\rightarrow L_B,
$$

但：

$$
\mathcal M_P,\mathcal M_T
$$

仍保留，

大量組織能力仍可延續。

所以：

$$
\boxed{
\text{模型換代}
\neq
\text{組織失憶}.
}
$$

---

# 三十八、但 procedural skill 並非都能泛化

AFTER 也指出：

某些 skill 可廣泛轉移，

某些則會：

$$
\text{role-specific over-specialization}.
$$

因此每個：

$$
B_i
$$

必須保存：

$$
scope_i.
$$

---

# 三十九、Scope

$$
\Theta_i
=
(
domain,
state\ region,
model\ compatibility,
authority,
resource,
time
).
$$

只有：

$$
x\in\Theta_i
$$

才允許 fast path。

---

# 四十、Compiled Memory 不是 Universal Rule

所以：

$$
\boxed{
B_i
\neq
\text{永恆規則}.
}
$$

更準確：

$$
B_i
=
\text{conditional computational asset}.
$$

---

# 四十一、Continuous Consolidation 的風險

2026 年研究發現：

將有用 episodic traces 持續由 LLM 進行 consolidated-memory rewriting，

可能出現：

$$
\boxed{
\text{memory utility}
\uparrow
\rightarrow
\downarrow.
}
$$

也就是一開始整理有幫助，

後來持續重寫反而失真。

---

# 四十二、這是一個非常重要的反例

它表示：

$$
\text{more consolidation}
\not\Rightarrow
\text{better memory}.
$$

甚至：

$$
\boxed{
\text{Useful Episode}
\rightarrow
\text{Faulty Abstraction}
}
$$

可能發生。

---

# 四十三、因此 Raw Episode 必須是 First-Class Evidence

本文要求：

$$
\boxed{
\mathcal M_E
\text{ 不因 }
\mathcal M_P
\text{ 產生而自動刪除}.
}
$$

即使 procedural memory 已建立，

仍保留足夠原始證據。

---

# 四十四、編譯記憶應保存 Provenance

每個：

$$
B_i
$$

附：

$$
P_i
=
\{
\tau_{j_1},\ldots,\tau_{j_k}
\}.
$$

因此可以追問：

> 這條策略是從哪些 episode 編譯出來？

---

# 四十五、Evidence Dependency

如果十個 episode：

$$
\tau_1,\ldots,\tau_{10}
$$

其實都來自同一份錯誤來源，

不能當：

$$
10
$$

份獨立證據。

所以：

$$
Dep(\tau_i,\tau_j)
$$

必須保存。

---

# 四十六、Compiled Confidence

可以定義：

$$
w_i
=
F(
N_{\mathrm{independent}},
success,
variance,
recency,
scope,
validation
).
$$

不是：

$$
w_i=N_{\mathrm{repetition}}.
$$

---

# 四十七、編譯 Gate

只有：

$$
G_C(\tau_{1:n})=1
$$

才允許：

$$
\operatorname{Compile}.
$$

Gate 可以檢查：

- independent episodes；
- sufficient repetitions；
- stable outcome；
- low conflict；
- clear scope。

---

# 四十八、不確定時應該 Retain，不是 Compile

如果：

$$
U_C>\tau,
$$

則：

$$
\boxed{
\text{retain episodic evidence}.
}
$$

不要急著抽象。

這直接吸收 2026 consolidation failure 的教訓。

---

# 四十九、三種記憶狀態

一個 pattern 可以處於：

$$
\boxed{
\text{Episodic}
\rightarrow
\text{Candidate}
\rightarrow
\text{Compiled}.
}
$$

不是：

$$
episode\rightarrow compiled
$$

一步完成。

---

# 五十、Candidate Memory

$$
B_i^{cand}
$$

可以：

- shadow use；
- compare；
- collect counterexamples。

只有成熟後：

$$
B_i^{cand}
\rightarrow B_i^{prod}.
$$

---

# 五十一、Counterexample Buffer

如果某 episode：

$$
\tau_j
$$

違反：

$$
B_i,
$$

加入：

$$
E_i^{exception}.
$$

所以 compiled item：

$$
B_i
=
(
c_i,
\mathcal O_i,
\Theta_i,
V_i,
E_i^{exception}
).
$$

---

# 五十二、例外記憶和主策略同等重要

高速直覺：

$$
c_i\rightarrow\mathcal O_i
$$

安全的前提是：

$$
\boxed{
\text{也能快速記得哪些情況不能用}.
}
$$

這延續前一系列「直覺安全性來自快速記得例外」。

---

# 五十三、Fast Path Gate

定義：

$$
F_i(x)=1
$$

只有當：

$$
P(c_i\mid x)>\tau_c,
$$

$$
D(x,E_i^{exception})>\tau_e,
$$

$$
Fresh(B_i)=1.
$$

才直接使用：

$$
\mathcal O_i^C.
$$

---

# 五十四、Compiled Cognitive Topology

Mother AI 記憶最特殊的部分：

$$
\boxed{
T_i^C
=
(
V_i^A,
E_i^A,
\Omega_i^A,
\Gamma_i,
V_i
).
}
$$

即：

- 哪些 Agent；
- 怎麼連；
- 各自權限；
- 哪些驗證；
- 邊權如何設。

這就是：

$$
\boxed{
\text{Compiled Response Topology}.
}
$$

---

# 五十五、世界狀態映射到 Agent Constellation

$$
c_i
\Rightarrow
\mathcal C_A^{(i)}.
$$

例如：

$$
c_{\mathrm{contract\ risk}}
\Rightarrow
\{
A_{\mathrm{legal}},
A_{\mathrm{finance}},
A_{\mathrm{verifier}}
\}.
$$

不是每次重新想：

> 要找誰？

---

# 五十六、還可以映射到 Model Policy

$$
c_i
\Rightarrow
L_i^{policy}.
$$

例如：

已知簡單：

$$
L_{\mathrm{small}}.
$$

高風險：

$$
L_{\mathrm{strong}}.
$$

所以：

$$
\boxed{
\text{Model routing}
}
$$

也能被編譯。

---

# 五十七、Memory View 也能被編譯

$$
c_i
\Rightarrow
M_i^v.
$$

也就是：

> 這類任務通常需要哪些記憶域？

例如：

$$
M_i^v
=
M_{\mathrm{contract}}
\oplus
M_{\mathrm{customer}}
\oplus
M_{\mathrm{law}}.
$$

---

# 五十八、Budget 也能被編譯

$$
c_i
\Rightarrow
B_i.
$$

成熟低風險：

$$
B_i\downarrow.
$$

未知高風險：

$$
B_i\uparrow.
$$

所以歷史能直接改變未來算力需求。

---

# 五十九、Authority Path 也能被編譯

$$
c_i
\Rightarrow
\Gamma_i^{path}.
$$

例如：

> 建議可自動；實際付款需財務人員批准。

這使：

$$
\boxed{
\text{認知配置}
}
$$

和治理結構同步重用。

---

# 六十、Termination 也要記

一個 skill 若沒有：

$$
\beta_i,
$$

就不知道何時停止。

例如：

$$
\beta_i=
\text{evidence\ sufficient}
$$

或：

$$
\beta_i=
\text{deadline reached}.
$$

所以：

$$
\boxed{
\text{知道何時停止思考}
}
$$

也是 procedural memory。

---

# 六十一、Compiled Option 的完整格式

$$
\boxed{
\mathcal O_i^C
=
(
I_i,
A_i,
L_i,
M_i,
G_i,
B_i,
\Gamma_i,
V_i,
\beta_i
)
}
$$

其中：

- $I_i$ ：activation；
- $A_i$ ：agents；
- $L_i$ ：models；
- $M_i$ ：memory views；
- $G_i$ ：topology；
- $B_i$ ：budget；
- $\Gamma_i$ ：authority；
- $V_i$ ：verification；
- $\beta_i$ ：termination。

---

# 六十二、這已經像一個「認知程序」

所以：

$$
\boxed{
\mathcal O_i^C
}
$$

不是一段 advice。

它更像：

$$
\boxed{
\text{可執行、可驗證、可終止的認知程序}.
}
$$

這是「記憶編譯」一詞真正工程化的地方。

---

# 六十三、Compiled Memory Index

需要：

$$
\mathfrak I_M.
$$

可以包括：

$$
I_{\mathrm{state}},
I_{\mathrm{semantic}},
I_{\mathrm{procedural}},
I_{\mathrm{topology}},
I_{\mathrm{exception}},
I_{\mathrm{temporal}}.
$$

Mother AI 不是只做 vector similarity。

---

# 六十四、先分類再檢索

$$
x
\xrightarrow{C}
c_i
\xrightarrow{I}
B_i.
$$

比：

$$
x
\rightarrow
\operatorname{search\ all\ memory}
$$

更符合大規模系統。

---

# 六十五、多階段 Retrieval

$$
R_0:
\text{coarse class}
$$

$$
R_1:
\text{candidate memories}
$$

$$
R_2:
\text{scope／exception filter}
$$

$$
R_3:
\text{final compiled option}.
$$

這延續極致分類與快速索引理論。

---

# 六十六、Memory Hit

若：

$$
B_i
$$

安全命中，

則：

$$
K_{\mathrm{repeat}}
=
K_{\mathrm{classify}}
+
K_{\mathrm{retrieve}}
+
K_{\mathrm{light\ verify}}.
$$

而不再：

$$
K_{\mathrm{meta-search}}
+
K_{\mathrm{agent-design}}
+
K_{\mathrm{workflow-design}}.
$$

---

# 六十七、這就是 Mother AI 的「計算直覺」

外部看起來：

> 它好像立刻知道該找誰、該怎麼處理。

實際：

$$
\boxed{
\text{大量歷史 meta-control 已被壓縮}.
}
$$

所以：

$$
\text{intuition}
\approx
\text{compiled historical cognition}.
$$

---

# 六十八、Memory Miss

如果：

$$
C(x)=\bot
$$

或：

$$
F_i(x)=0,
$$

則不能強行 fast path。

進入：

$$
\boxed{
\text{Exploratory Meta-Control}.
}
$$

---

# 六十九、Exploratory Meta-Control

Mother AI 重新搜索：

$$
\mathcal C.
$$

可以：

- spawn new agents；
- increase diversity；
- use stronger models；
- increase verification；
- sandbox；
- involve humans。

新的成功 trajectory 再回到：

$$
\mathcal M_E.
$$

---

# 七十、所以完整循環

$$
\boxed{
\text{Unknown State}
\rightarrow
\text{Explore Cognitive Configuration}
\rightarrow
\text{Act}
\rightarrow
\text{Validate}
\rightarrow
\text{Episode}
\rightarrow
\text{Compile}
\rightarrow
\text{Known State}.
}
$$

---

# 七十一、Memory Compiling 不是單向

世界會 drift。

因此：

$$
B_i
$$

可能失效。

若：

$$
V_i(x)=0
$$

或：

$$
Drift_i>\tau_D,
$$

則：

$$
B_i
\rightarrow
\text{review}.
$$

---

# 七十二、Decompile

定義：

$$
\operatorname{Decompile}(B_i).
$$

不是把它刪掉。

而是：

- 停止 fast path；
- 回到 candidate；
-重新讀原始 episodes；
- 搜集新 evidence。

---

# 七十三、Recompile

新 evidence：

$$
P_i'
$$

產生：

$$
B_i'.
$$

所以：

$$
\boxed{
B_i
\rightarrow
B_i'
}
$$

可以保留版本 lineage。

---

# 七十四、Version Lineage

$$
B_i^{v1}
\rightarrow
B_i^{v2}
\rightarrow
B_i^{v3}.
$$

每版保存：

- why changed；
- evidence；
- failure；
- compatibility。

這使 Memory Compiler 可審計。

---

# 七十五、Forgetting 不是缺陷

MemCon 明確把：

$$
forget
$$

納入 memory control action。

因為：

$$
|\mathcal M|\uparrow
$$

不代表效能上升。

所以：

$$
\boxed{
\text{成熟記憶系統必須會忘記}.
}
$$

---

# 七十六、但 Forget 應區分

## Hard Delete

真正刪除。

## Archive

移出 fast retrieval。

## Deprecate

保留但不能自動調用。

## Decay

降低權重。

所以：

$$
\boxed{
\text{Forget}
\neq
\text{Erase}.
}
$$

---

# 七十七、Memory Decay

可以：

$$
w_i(t)
=
w_i(t_0)
e^{-\lambda_i(t-t_0)}.
$$

若被重新驗證：

$$
w_i\uparrow.
$$

不同 memory：

$$
\lambda_i
$$

不同。

---

# 七十八、法律規則與個人偏好不應同速衰減

例如：

$$
\lambda_{\mathrm{preference}}
>
\lambda_{\mathrm{contract}}.
$$

所以 forgetting policy 應 domain-specific。

---

# 七十九、Memory Budget

Mother AI 也有：

$$
B_M.
$$

要決定：

$$
\max
V(\mathcal M)
$$

subject to：

$$
K_{\mathrm{storage}}
+
K_{\mathrm{retrieval}}
+
K_{\mathrm{maintenance}}
\leq
B_M.
$$

所以記憶本身也是資源配置問題。

---

# 八十、不是所有 episode 都值得永久保存

可以定義：

$$
V_E(\tau)
=
\alpha novelty
+
\beta failure\ value
+
\gamma reuse
+
\delta evidence
-
\mu storage.
$$

低價值事件：

$$
\rightarrow
aggregate/archive.
$$

---

# 八十一、失敗 episode 可能比成功更有價值

成功：

> 這樣做有效。

失敗：

> 這樣做在某條件下會出錯。

因此：

$$
\boxed{
\mathcal M_E^{failure}
}
$$

不應被清掉。

它是 exception memory 的主要來源。

---

# 八十二、Failure-to-Constraint Compilation

若多次：

$$
\tau_i^{fail}
$$

在：

$$
condition=C
$$

失敗，

可以編譯：

$$
C\Rightarrow \neg\mathcal O_i.
$$

即：

$$
\boxed{
\text{失敗也可以編譯成禁止條件}.
}
$$

---

# 八十三、Memory Poisoning

如果惡意或錯誤 episode：

$$
\tau_m
$$

進入編譯，

可能產生：

$$
B_m.
$$

之後：

$$
B_m
$$

以 fast path 反覆影響系統。

所以：

$$
\boxed{
\text{memory poisoning}
}
$$

比一次錯誤回答更危險。

---

# 八十四、因此寫入權限比讀取權限更敏感

普通 Agent 可以：

$$
read(\mathcal M).
$$

但：

$$
write(\mathcal M_P)
$$

或：

$$
write(\mathcal M_T)
$$

應有更高門檻。

---

# 八十五、Memory Write Pipeline

Agent result：

$$
r_i
$$

不能：

$$
r_i\rightarrow\mathcal M_P
$$

直接寫入。

應：

$$
r_i
\rightarrow
\mathcal M_E
\rightarrow
validate
\rightarrow
candidate
\rightarrow
compiled.
$$

---

# 八十六、Mother AI 的「記憶」本質上是資產負債表

好的 compiled memory：

$$
\rightarrow
\text{future compute asset}.
$$

錯誤 compiled memory：

$$
\rightarrow
\text{future error liability}.
$$

所以：

$$
\boxed{
\text{Memory Value}
=
\text{reuse benefit}
-
\text{error propagation risk}.
}
$$

---

# 八十七、Memory ROI

定義：

$$
ROI(B_i)
=
\frac{
K_{\mathrm{saved}}
+
Q_{\mathrm{improved}}
}{
K_{\mathrm{compile}}
+
K_{\mathrm{maintain}}
+
K_{\mathrm{error}}
}.
$$

若：

$$
ROI<1,
$$

就不值得編譯。

---

# 八十八、記憶編譯也是投資決策

因此 Mother AI 不應：

> 每次做完事都寫一篇反思。

而是：

$$
\boxed{
\text{只對有重用價值的歷史支付編譯成本}.
}
$$

---

# 八十九、Frequency × Cost × Reuse

可定義：

$$
Priority_{\mathrm{compile}}
=
F(
frequency,
first\ cost,
expected\ reuse,
risk
).
$$

高頻、高成本、高重用：

$$
\rightarrow
\text{優先編譯}.
$$

---

# 九十、低頻未知不一定值得編譯

一次性的：

$$
x_i
$$

即使很複雜，

如果：

$$
P(\text{repeat})\approx0,
$$

保留 episode 即可。

所以：

$$
\boxed{
\text{不是所有智慧都需要程序化}.
}
$$

---

# 九十一、Memory Compilation 與創新

極強記憶不應讓 Mother AI 永遠使用：

$$
B_i.
$$

相反：

$$
B_i
$$

最大的作用之一是：

> 讓已知部分快速退出昂貴推理，把資源留給真正未知。

所以：

$$
\boxed{
\text{記憶越成熟，探索資源越應集中在殘差空間}.
}
$$

---

# 九十二、Residual Cognitive Search

已知認知空間：

$$
\mathcal S_t
=
\operatorname{span}
\{
B_1,\ldots,B_n
\}.
$$

新問題：

$$
x^\perp
=
x-\Pi_{\mathcal S_t}x.
$$

探索集中：

$$
\|x^\perp\|.
$$

這延續前一系列的 residual novelty search。

---

# 九十三、所以 Mother AI 的學習不是越來越少思考

而是：

$$
\boxed{
\text{越來越少在已知區域重新思考}
}
$$

並：

$$
\boxed{
\text{把更多思考轉移到真正未知區域}.
}
$$

---

# 九十四、跨 Agent 記憶編譯

Sub-AI：

$$
A_1,\ldots,A_n
$$

的經驗最後可：

$$
\bigcup_i\mathcal M_E^{(i)}
\rightarrow
\mathfrak C_M.
$$

所以一個 Agent 做出的經驗：

$$
\boxed{
\text{可以成為整個 Mother AI 系統的未來能力}.
}
$$

---

# 九十五、但先局部再全局

Agent local memory：

$$
\mathcal M_i
$$

先驗證。

再：

$$
\mathcal M_i
\rightarrow
\mathcal M_M.
$$

不能讓每個子 AI 自動改寫全局程序記憶。

---

# 九十六、跨模型 Procedural Memory

AFTER 顯示由多模型 execution traces 演化出的 skills 具有跨模型轉移潛力。

這提供：

$$
\boxed{
\text{Procedural Memory 可以比單一 Model Identity 更持久}.
}
$$

Mother AI 因此可以在模型世代更替中保持組織經驗。

---

# 九十七、跨 Agent Template Memory

若：

$$
\Theta_r
$$

被更新，

未來所有：

$$
A_i\sim\Theta_r
$$

都受益。

所以：

$$
\boxed{
\text{經驗可以從 Instance 上升為 Role Memory}.
}
$$

---

# 九十八、跨 Topology Memory

若某 Agent constellation：

$$
G_i
$$

長期成功，

可以：

$$
G_i
\rightarrow
\mathcal M_T.
$$

下一次：

$$
c_i\rightarrow G_i.
$$

所以：

$$
\boxed{
\text{組織結構本身也可以被記憶}.
}
$$

---

# 九十九、Memory Compiler 的總輸入

$$
\mathcal D_t
=
(
W_{0:t},
S_{0:t},
M_{0:t},
A_{0:t},
R_{0:t}
).
$$

輸出：

$$
\mathfrak C_M(\mathcal D_t)
=
(
\mathcal Q,
\mathcal O,
\Theta,
\mathcal V,
\mathfrak I
).
$$

其中：

- $\mathcal Q$ ：state classes；
- $\mathcal O$ ：cognitive options；
- $\Theta$ ：scope／activation；
- $\mathcal V$ ：validators；
- $\mathfrak I$ ：indices。

---

# 一百、完整 Mother AI Memory Runtime

$$
\boxed{
W_t
\xrightarrow{\Phi}
z_t
\xrightarrow{C}
c_t
\xrightarrow{I}
B_t
\xrightarrow{F_G}
\mathcal O_t^C
\xrightarrow{\Pi}
A_t
\xrightarrow{V}
R_t
\xrightarrow{U}
\mathcal M_{t+1}.
}
$$

若：

$$
C(z_t)=\bot,
$$

則：

$$
z_t
\rightarrow
\text{explore}
\rightarrow
\tau_{new}
\rightarrow
\mathcal M_E.
$$

---

# 一百零一、Compiler 不在每次事件後啟動

更合理：

$$
\operatorname{CompileTrigger}
=
F(
repeat,
value,
stability,
evidence,
cost
).
$$

只有：

$$
CompileTrigger=1
$$

才進行 consolidation。

---

# 一百零二、Memory Compiler 自己也是低頻高價值流程

它可能：

- nightly；
- weekly；
- milestone-based；
- threshold-based。

而不是：

$$
\text{每一輪對話都 compile}.
$$

這能降低：

- cost；
- overfitting；
- memory corruption。

---

# 一百零三、第一代 MVP 可以怎麼做？

MVP 只需要三層：

$$
\mathcal M_E
\oplus
\mathcal M_P
\oplus
\mathcal M_M.
$$

先不做完整 semantic／topological graph。

---

# 一百零四、MVP Episode Schema

```text
episode_id
state_class
task
agents
models
memory_refs
tools
workflow_graph
authority
cost
outcome
evidence
timestamp
```

這已足以後續編譯。

---

# 一百零五、MVP Compiled Skill Schema

```text
skill_id
activation_conditions
agent_constellation
model_policy
memory_policy
workflow_graph
budget
authority_requirements
verification
termination
provenance
confidence
version
status
```

這就是第一代 Cognitive Option。

---

# 一百零六、MVP Compile Policy

只有：

```text
if repeated_success >= N
and independent_evidence >= K
and outcome_variance <= epsilon:
    create_candidate_skill()
```

不要一開始用自由 LLM consolidation。

---

# 一百零七、MVP Shadow Test

candidate skill：

```text
status = shadow
```

實際 task 到來時：

- 主系統正常處理；
- candidate 預測；
- 比較兩者。

達標後才：

```text
status = production
```

---

# 一百零八、MVP Decompile

如果：

```text
failure_rate > threshold
or drift > threshold
or exception_match:
    status = suspended
```

然後重新讀 episodes。

---

# 一百零九、MVP 評估指標

## Compilation Rate

$$
R_C
=
\frac{N_{\mathrm{compiled}}}{N_{\mathrm{episodes}}}.
$$

## Reuse Rate

$$
R_R
=
\frac{N_{\mathrm{compiled\ hits}}}{N_{\mathrm{tasks}}}.
$$

## Compute Saving

$$
S_K
=
K_{\mathrm{baseline}}
-
K_{\mathrm{compiled}}.
$$

## False-Known Rate

$$
R_{FK}.
$$

## Decompile Rate

$$
R_D.
$$

## Memory Drift

$$
D_M.
$$

---

# 一百一十、真正最重要的指標仍然是 False Known

如果：

$$
B_i
$$

錯誤命中，

Mother AI 會：

- 快速叫錯 Agent；
- 快速用錯模型；
- 快速走錯流程；
- 快速給錯權限。

所以：

$$
\boxed{
Cost(FalseKnown)
\gg
Cost(MemoryMiss).
}
$$

高風險系統尤其如此。

---

# 一百十一、寧可 Miss，也不要錯誤 Fast Path

因此：

$$
\tau_{\mathrm{compile}}
$$

可以偏保守。

如果 unsure：

$$
\rightarrow
\text{explore}.
$$

這仍延續：

$$
\boxed{
\text{未知是合法狀態}.
}
$$

---

# 一百十二、Memory Compilation 的終極作用

一開始：

$$
W_t
\rightarrow
\text{expensive meta-control search}.
$$

成熟後：

$$
W_t
\rightarrow
c_i
\rightarrow
B_i
\rightarrow
\mathcal O_i^C.
$$

所以：

$$
\boxed{
\text{世界狀態}
\rightarrow
\text{索引問題}
}
$$

逐步取代：

$$
\boxed{
\text{世界狀態}
\rightarrow
\text{重新搜尋問題}.
}
$$

---

# 一百十三、這就是 Mother AI 的歷史計算資本化

定義：

$$
\mathcal A_t^M
=
\{
B_1,\ldots,B_n
\}
$$

為 Mother AI 的 compiled cognitive assets。

隨時間：

$$
|\mathcal A_t^M|\uparrow.
$$

理想：

$$
K_{\mathrm{known}}(t)\downarrow.
$$

這可以稱：

$$
\boxed{
\text{Historical Cognitive Capitalization}.
}
$$

---

# 一百十四、Mother AI 越成熟，不代表硬編譯率越接近 100%

理想：

$$
R_{\mathrm{compile}}<1.
$$

因為：

- 世界會變；
- unknown 永遠存在；
- rare events 不值得編譯；
- novel combinations 持續產生。

所以：

$$
\boxed{
\bot
}
$$

必須永久保留。

---

# 一百十五、正式定義

> **記憶編譯型母 AI，是一種將世界狀態、子 AI 組合、模型選擇、記憶切片、認知拓撲、預算、權限、驗證與實際結果所形成的歷史軌跡，經由保留原始 episode、來源追蹤、去重、狀態分類、抽象、候選編譯、影子驗證與版本化管理，轉換成可在相似未來狀態中快速、安全、可撤銷地重新調用之 Cognitive Options 的持續智能架構。**

---

# 一百十六、核心公式

$$
\boxed{
\mathfrak C_M:
\{\tau_i\}_{i=1}^{n}
\rightarrow
\{
(c_j,\mathcal O_j^C,\Theta_j,V_j,P_j)
\}_{j=1}^{m}
}
$$

且通常：

$$
m\ll n.
$$

表示大量歷史 episode 被壓縮成較少的可重用結構。

---

# 一百十七、系列第二部到目前的位置

第 05 篇：

$$
\boxed{
\text{Mother AI 一直存在，但不必一直高成本思考}.
}
$$

第 06 篇：

$$
\boxed{
\text{能力可以按需長成 Sub-AI 器官}.
}
$$

第 07 篇：

$$
\boxed{
\text{歷史可以把這些器官的最佳組合編譯成未來快速通道}.
}
$$

現在只剩第二部最後一篇：

# 08．《母 AI Runtime：從模型到持續認知核心》

將把：

- World State；
- Persistent State；
- Sub-AI Fabric；
- Memory Compiler；
- Meta-Control；
- Unknown；
- Authority；

收斂成真正可實作的 Runtime 規格：

$$
\boxed{
\text{Mother Runtime}
=
W+M+S+G+R+U+\Gamma.
}
$$

---

# 參考資料與公開技術資料

1. Jiang, E. H. et al. (2026). **Memory as a Controlled Process: Learned Adaptive Memory Management for LLM Agents.**  
   https://arxiv.org/abs/2607.13591

2. Mi, Q. et al. (2026). **ProcMEM: Learning Reusable Procedural Memory from Experience via Non-Parametric PPO for LLM Agents.**  
   https://arxiv.org/abs/2602.01869

3. Belikova, J. et al. (2026). **Managing Procedural Memory in LLM Agents: Control, Adaptation, and Evaluation.**  
   https://arxiv.org/abs/2606.23127

4. Zhang, D. et al. (2026). **Useful Memories Become Faulty When Continuously Updated by LLMs.**  
   https://arxiv.org/abs/2605.12978

5. Xiong, Z. et al. (2025). **How Memory Management Impacts LLM Agents: An Empirical Study of Experience-Following Behavior.**  
   https://arxiv.org/abs/2505.16067

6. Wang, G. et al. (2023). **Voyager: An Open-Ended Embodied Agent with Large Language Models.**  
   https://arxiv.org/abs/2305.16291

7. Packer, C. et al. (2023). **MemGPT: Towards LLMs as Operating Systems.**  
   https://arxiv.org/abs/2310.08560

8. Hsiao, V., Roberts, M., & Smith, L. (2025). **Procedural Knowledge Improves Agentic LLM Workflows.**  
   https://arxiv.org/abs/2511.07568

---

# 內部理論依賴

1. 01《AI 不是流程中的一個節點》
2. 02《母 AI、世界狀態機與子智能網路》
3. 03《會改變拓撲的智能：動態圖論認知系統》
4. 04《母 AI 是二階控制器》
5. 05《持續世界狀態：母 AI 如何一直醒著》
6. 06《子 AI 是認知器官，不是獨立 Workflow》
7. 《從路徑覆蓋到行星智能：記憶編譯型計算存在論》

本篇將前一系列的 Memory-Compiled State Agent、極致分類、Unknown Gate、Residual Novelty Search 與文明記憶編譯概念，正式移植到 Mother AI 的 Agent／Model／Memory／Topology／Authority Meta-Control 層。

---

## 一句話摘要

$$
\boxed{
\text{Mother AI 真正應該記住的，不只是「上次怎麼回答」，而是「這種世界狀態下，哪一種認知組織最值得再次被喚起」。}
}
$$
