← Archive
lm-002716 · 2026-08

上下文治理算子與動態工作集理論:三域上下文動力學的控制層

下載 MD 檔 ⬇
📎 附件 · Companion files — 隨文交付的程式 / 證明 / 資料,可獨立下載重驗

上下文治理算子與動態工作集理論:三域上下文動力學的控制層

Context Governance Operator and Dynamic Working-Set Theory: The Control Layer of Three-Domain Context Dynamics

Series I / Paper 02 — v0.1

摘要

本文承接「三域上下文動力學」(Three-Domain Context Dynamics, TDCD),進一步研究其核心控制問題:在外部典範記憶可長期保存、投影記憶可低成本尋址的條件下,如何決定什麼資訊應在當下工作上下文中存在、退出、重新召回、被新版本覆寫、與其他分支隔離或重新連接。

本文將上下文治理從一般性的記憶檢索或壓縮問題中分離,定義治理算子

Gt:(Wt,Pt,Dt,st)At,\mathcal G_t:(\mathcal W_t,\mathcal P_t,\mathcal D_t,s_t)\rightarrow A_t,

其中 Wt\mathcal W_t 為工作域, Pt\mathcal P_t 為投影域, Dt\mathcal D_t 為典範域, sts_t 為當前任務狀態, AtA_t 為一組治理行為。本文定義上下文污染量、動態工作集、版本偏序、分支隔離、召回與驅逐遲滯、治理震盪與穩定條件,並提出安全驅逐、版本頭唯一性、非單調上下文效用與遲滯抑制震盪等命題。

本文的核心觀點是:長程智能體的問題不只是「記憶是否存在」,而是「當下工作集是否處於適合推理的狀態」。因此:

More accessible memory does not imply a better active context.\boxed{ \text{More accessible memory does not imply a better active context.} }

上下文治理的目的,是在保留典範可恢復性的同時,使工作域持續逼近當前任務的最小充分工作集。

關鍵詞

上下文治理、工作集、智能體記憶、記憶覆寫、分支隔離、上下文污染、召回、驅逐、遲滯、典範記憶、長程智能體、TDCD


1. 從記憶容量問題進入控制問題

在 TDCD Paper 01 中,系統記憶被區分為三個域:

Mt=(Wt,Pt,Dt),\mathfrak M_t=(\mathcal W_t,\mathcal P_t,\mathcal D_t),

其中:

Wt=Working Context Domain,\mathcal W_t=\text{Working Context Domain}, Pt=Projection / Compiled Domain,\mathcal P_t=\text{Projection / Compiled Domain}, Dt=Canonical External Domain.\mathcal D_t=\text{Canonical External Domain}.

這個區分解決了一個基本混淆:完整保存、低成本表示與當下推理並不是同一個問題。

若系統已經具有近乎無界的外部資料庫,仍不能推出:

the agent always has the right context.\text{the agent always has the right context}.

同樣地,即使存在高品質壓縮:

C(Dt)=Pt,C(\mathcal D_t)=\mathcal P_t,

也不能推出:

Pt=Wt.\mathcal P_t=\mathcal W_t^*.

因此本文研究的是一個控制問題:

How should the active context state evolve?\boxed{ \text{How should the active context state evolve?} }

這一問題與經典 working-set 思想存在結構類比:Denning 的 working-set model 研究執行中的程式在某段時間真正需要哪些 pages,而非要求所有 pages 同時駐留主記憶體。[1] 然而,AI 上下文中的「工作集」不能只由 recency 決定,因為語義依賴、版本有效性、任務分支、持續性與來源可信度皆可能使很久以前的資訊重新成為當下核心。

因此本文把 working set 從「近期被引用的資訊集合」推廣為「在當前任務狀態下具有主動參與資格的資訊集合」。


2. 記憶物件與治理狀態

令一個可治理記憶物件為:

m=(x,a,b,v,p,r,d,c),m=(x,a,b,v,p,r,d,c),

其中:

  • xx:內容或 canonical object;
  • aa:canonical restoration address;
  • bb:branch identifier;
  • vv:version state;
  • pp:persistence class;
  • rr:relations;
  • dd:dependency metadata;
  • cc:confidence / validation state。

系統在時間 tt 的治理狀態定義為:

St=(Wt,Pt,Dt,Rt,qt,Bt),S_t=(\mathcal W_t,\mathcal P_t,\mathcal D_t,\mathcal R_t,q_t,B_t),

其中 Rt\mathcal R_t 是目前已知的關係結構, qtq_t 是當前任務或問題狀態, BtB_t 是工作上下文預算。

治理算子作用為:

Gt(St)At,\mathcal G_t(S_t)\rightarrow A_t,

其中:

At{retain,admit,evict,recall,compress,merge,supersede,fork,bridge,flag,archive}.A_t\subseteq \{ \operatorname{retain}, \operatorname{admit}, \operatorname{evict}, \operatorname{recall}, \operatorname{compress}, \operatorname{merge}, \operatorname{supersede}, \operatorname{fork}, \operatorname{bridge}, \operatorname{flag}, \operatorname{archive} \}.

治理因而不是單一函數,而是根據狀態輸出操作集合的 policy。


3. 上下文效用不是單調函數

對任意工作上下文集合 WW,定義其任務效用為:

Ut(W)=U(Wqt,St).U_t(W)=U(W\mid q_t,S_t).

直覺上,人們容易假定加入更多可用資訊不會使結果變差:

WWUt(W)Ut(W).W\subseteq W' \Rightarrow U_t(W')\geq U_t(W).

本文拒絕這個假設。

在長上下文模型中,無關內容、位置效應與累積歷史可能造成 reasoning degradation;近期研究亦持續測量 context rot 與長程任務中因歷史累積造成的效能下降。[2][3]

因此一般情況下:

WW⇏Ut(W)Ut(W).\boxed{ W\subseteq W' \not\Rightarrow U_t(W')\geq U_t(W). }

命題 1:上下文效用非單調命題

存在 WWmm,使得:

Ut(W{m})<Ut(W).U_t(W\cup\{m\})<U_t(W).

證明構想

mm 為與當前任務高度詞彙相似、但已被更新版本取代的舊資訊。加入 mm 後,模型可能在舊值與新值之間產生錯誤競爭,因此工作域增大而任務效用降低。

故上下文治理不能以:

maxW\max |W|

作為目標,而必須尋找:

maxUt(W)\max U_t(W)

subject to

C(W)Bt.C(W)\leq B_t.

4. 上下文污染量

令記憶物件 mm 在時間 tt 的污染向量為:

Kt(m)=(Ktdup,Ktstale,Ktconf,Ktbranch,Ktirr,Ktprov).\mathbf K_t(m) = (K_t^{dup},K_t^{stale},K_t^{conf},K_t^{branch},K_t^{irr},K_t^{prov}).

分別表示:

  • 重複污染;
  • 過期污染;
  • 衝突污染;
  • 分支洩漏;
  • 當下無關;
  • provenance 不足。

定義標量污染量:

Kt(m)=iλiKt(i)(m),K_t(m) = \sum_i \lambda_iK_t^{(i)}(m),

其中:

λi0.\lambda_i\geq0.

對整個工作域:

Kt(Wt)=mWtKt(m)+ijκt(mi,mj),K_t(\mathcal W_t) = \sum_{m\in\mathcal W_t}K_t(m) + \sum_{i\neq j}\kappa_t(m_i,m_j),

其中 κt\kappa_t 表示 pairwise interference,例如兩個互斥版本同時出現在工作域。

因此 context noise 不是只有單一物件自身的問題,也可能由物件之間的關係產生。


5. 動態工作集

定義記憶物件 mm 的當下適格度為:

Ψt(m)=αRt(m)+βDt(m)+γPt(m)+δVt(m)+ϵQt(m)ζKt(m),\Psi_t(m) = \alpha R_t(m) +\beta D_t(m) +\gamma P_t(m) +\delta V_t(m) +\epsilon Q_t(m) -\zeta K_t(m),

其中:

  • RtR_t:與當前任務的 relevance;
  • DtD_t:dependency necessity;
  • PtP_t:persistence value;
  • VtV_t:version validity;
  • QtQ_t:source / validation quality;
  • KtK_t:污染量。

則理論有效工作集定義為:

Wt=argmaxWMt[mWΨt(m)Ωt(W)]\mathcal W_t^* = \arg\max_{W\subseteq\mathcal M_t} \left[ \sum_{m\in W}\Psi_t(m) -\Omega_t(W) \right]

subject to

C(W)BtC(W)\leq B_t

以及 dependency closure:

mW, d(mj,m)=1mjWm\in W,\ d(m_j,m)=1 \Rightarrow m_j\in W

或存在足以替代 mjm_j 的有效投影。

Ωt(W)\Omega_t(W) 是集合級干擾成本。

這使工作集不再是單純 top- kk retrieval,而是一個帶有依賴、版本與衝突限制的 constrained selection problem。


6. Admission 與 Retention 必須分離

新資訊進入工作域與舊資訊繼續停留在工作域,是兩種不同決策。

定義 admission threshold:

θin,\theta_{in},

以及 retention / eviction threshold:

θout.\theta_{out}.

若單純使用同一閾值:

θin=θout,\theta_{in}=\theta_{out},

則當 Ψt(m)\Psi_t(m) 在臨界值附近震盪時,容易形成:

admitevictrecallevict\operatorname{admit}\rightarrow \operatorname{evict}\rightarrow \operatorname{recall}\rightarrow \operatorname{evict}\rightarrow\cdots

本文稱之為 Context Thrashing

因此設定遲滯帶:

θin>θout.\theta_{in}>\theta_{out}.

Admission rule:

mWt,Ψt(m)θinadmit(m).m\notin\mathcal W_t, \quad \Psi_t(m)\geq\theta_{in} \Rightarrow \operatorname{admit}(m).

Retention rule:

mWt,Ψt(m)>θoutretain(m).m\in\mathcal W_t, \quad \Psi_t(m)>\theta_{out} \Rightarrow \operatorname{retain}(m).

Eviction rule:

mWt,Ψt(m)θoutevict(m).m\in\mathcal W_t, \quad \Psi_t(m)\leq\theta_{out} \Rightarrow \operatorname{evict}(m).

這使單次小幅 relevance 波動不會立即觸發狀態切換。


7. 上下文震盪與遲滯穩定性

定義時間區間 [t0,t1][t_0,t_1] 內物件 mm 的上下文切換次數:

Nswitch(m;t0,t1).N_{switch}(m;t_0,t_1).

總震盪率:

Γt0:t1=mNswitch(m;t0,t1)t1t0.\Gamma_{t_0:t_1} = \frac{ \sum_mN_{switch}(m;t_0,t_1) }{t_1-t_0}.

命題 2:遲滯抑制局部震盪命題

若:

θinθout=h>0\theta_{in}-\theta_{out}=h>0

且單步適格度擾動滿足:

Ψt+1(m)Ψt(m)<h,|\Psi_{t+1}(m)-\Psi_t(m)|<h,

則單一小擾動不能同時完成一次完整的 admit-evict 往返。

證明

mm 由外部進入工作域,必有:

Ψt(m)θin.\Psi_t(m)\geq\theta_{in}.

要在下一步被驅逐,必須:

Ψt+1(m)θout.\Psi_{t+1}(m)\leq\theta_{out}.

因此需要:

Ψt(m)Ψt+1(m)θinθout=h,\Psi_t(m)-\Psi_{t+1}(m) \geq \theta_{in}-\theta_{out} =h,

與假設矛盾。

故小於遲滯帶的單步擾動不足以形成完整往返。證畢。

這並不保證全域穩定,但提供一個最基本的 anti-thrashing 條件。


8. 安全驅逐與可恢復性

對任意:

mWt,m\in\mathcal W_t,

若存在:

mDtm\in\mathcal D_t

以及 canonical address:

a(m),a(m),

且 restoration operator 滿足:

R(a(m),Dt)=m,R(a(m),\mathcal D_t)=m,

則可以定義:

evictsafe(m).\operatorname{evict}_{safe}(m).

定理 1:安全驅逐定理

若 canonical domain 在 [t,t][t,t'] 期間保持完整,且地址 a(m)a(m) 有效,則:

mWt+1m\notin\mathcal W_{t+1}

不導致:

mMt+1.m\notin\mathfrak M_{t+1}.

並且存在未來時間 t>tt'>t,使:

recall(a(m))=m.\operatorname{recall}(a(m))=m.

因此:

Active forgetting can coexist with lossless archival memory.\boxed{ \text{Active forgetting can coexist with lossless archival memory.} }

此定理就是 aggressive context cleaning 能安全成立的基礎。


9. 版本不是重複資料:Supersession Relation

長程記憶最危險的情況之一,是同一 predicate 在不同時間具有不同有效值。

例如:

m1=(k=v1,t1),m_1=(k=v_1,t_1), m2=(k=v2,t2),m_2=(k=v_2,t_2),

且:

t2>t1.t_2>t_1.

m2m_2 明確取代 m1m_1,定義:

m1vm2.m_1\prec_v m_2.

v\prec_v 稱為 supersession relation。

近期 Supersede 工作顯示,bounded self-maintained memory 在事實更新情境中仍存在明顯的 stale-memory failure,而單純增加記憶容量不必然解決問題。[4] 因此 version freshness 應被視為獨立治理維度。

令某語義鍵 kk 的所有版本為:

V(k)={m1,,mn}.V(k)=\{m_1,\ldots,m_n\}.

v\prec_vV(k)V(k) 上形成有向無環偏序,定義 active head:

headt(k)=maxvVt(k).\operatorname{head}_t(k) = \max_{\prec_v}V_t(k).

對一般事實型 context,治理器預設只允許 active head 直接參與工作域:

WtV(k)={headt(k)},\mathcal W_t\cap V(k) = \{\operatorname{head}_t(k)\},

除非當前任務明確需要版本比較或歷史追蹤。


10. 版本頭唯一性命題

命題 3:版本頭唯一性

V(k)V(k) 上的 supersession relation 是有限 DAG,且所有不可比較的極大元素均被標記為 unresolved conflict 或 branch-specific state,則在任一已解決 branch 中存在唯一有效 active head。

說明

若存在兩個不同極大元素:

mimj,m_i\neq m_j,

且二者不可比較,系統不能任意把「較新時間戳」當作唯一真值,而應進入:

conflict(mi,mj)\operatorname{conflict}(m_i,m_j)

或:

b(mi)b(mj).b(m_i)\neq b(m_j).

因此 uniqueness 不是資料天然具有,而是由「偏序 + branch/conflict resolution」共同產生。

這避免系統把真正存在的分歧錯誤壓縮成單一結論。


11. Supersede 不等於 Delete

若:

m1vm2,m_1\prec_v m_2,

治理行為應是:

supersede(m1,m2),\operatorname{supersede}(m_1,m_2),

而不是:

delete(m1).\operatorname{delete}(m_1).

因為舊版本仍可能具有:

  • provenance value;
  • historical value;
  • debugging value;
  • causal reconstruction value;
  • branch recovery value。

因此:

Superseded from active contexterased from canonical history.\boxed{ \text{Superseded from active context} \neq \text{erased from canonical history}. }

在三域模型中,典型狀態轉換為:

m1:WP/D,m_1:\mathcal W\rightarrow\mathcal P/\mathcal D, m2:DPW.m_2:\mathcal D\rightarrow\mathcal P\rightarrow\mathcal W.

12. 分支隔離

對每個 memory object 定義 branch label:

b(m)B.b(m)\in\mathcal B.

當前任務 branch 為:

bt.b_t^*.

最簡單的 branch admission penalty 可寫成:

Ktbranch(m)={0,b(m)=bt,λb,b(m)bt and no bridge exists,λb(1ρbridge),valid bridge exists.K_t^{branch}(m) = \begin{cases} 0,&b(m)=b_t^*,\\ \lambda_b,&b(m)\neq b_t^*\text{ and no bridge exists},\\ \lambda_b(1-\rho_{bridge}),&\text{valid bridge exists}. \end{cases}

其中:

0ρbridge1.0\leq\rho_{bridge}\leq1.

橋接物件 gg 必須記錄:

g=(bi,bj,r,scope,provenance).g=(b_i,b_j,r,scope,provenance).

亦即不能因為兩個分支詞彙相似,就自動融合。


13. 分支污染與橋接原則

命題 4:無橋接跨分支加入可以降低工作域效用

存在 branches b1,b2b_1,b_2 及:

m1b1,m2b2,m_1\in b_1, \quad m_2\in b_2,

使得在任務屬於 b1b_1 時:

Ut(W{m2})<Ut(W).U_t(W\cup\{m_2\})<U_t(W).

因此跨 branch retrieval 需要比同 branch retrieval 更高的 admission evidence。

但 branch isolation 不能退化為完全封閉:若存在 dependency、method reuse 或明確 bridge,則:

b(m)btb(m)\neq b_t^*

仍可能有:

Ψt(m)θin.\Psi_t(m)\geq\theta_{in}.

故理論上應實施的是:

Isolation by default, connection by evidence.\boxed{ \text{Isolation by default, connection by evidence.} }

而不是永久分割。


14. Conflict 與 Supersession 必須分開

兩個互斥資訊:

mimjm_i\perp m_j

可能有至少三種語義:

  1. mivmjm_i\prec_v m_j:舊版本被新版本取代;
  2. b(mi)b(mj)b(m_i)\neq b(m_j):不同 branch 各自有效;
  3. unresolved contradiction:尚不能判定哪一個成立。

因此 conflict classifier:

χ(mi,mj){supersession,branch,unresolved}.\chi(m_i,m_j) \in \{ \operatorname{supersession}, \operatorname{branch}, \operatorname{unresolved} \}.

如果系統把三者全部視為 duplication,壓縮器就可能刪除必要資訊;若全部視為平等共存,又會污染工作域。

所以治理發生在 compression 之前與之後,而不是 compression 的附帶功能。


15. Recall 不等於 Search

令外部記憶中候選集合為:

Ct(qt).\mathcal C_t(q_t).

搜尋只回答:

match(m,qt).\operatorname{match}(m,q_t).

召回治理則必須回答:

admissible(mSt).\operatorname{admissible}(m\mid S_t).

因此召回函數應寫成:

Recallt(qt)={mCt(qt):Ψt(m)θin}.\operatorname{Recall}_t(q_t) = \left\{ m\in\mathcal C_t(q_t): \Psi_t(m)\geq\theta_{in} \right\}.

這意味:

RetrievedAdmitted.\boxed{ \text{Retrieved} \neq \text{Admitted}. }

retriever 可以找到十個高度相關物件,governor 仍可能只允許其中兩個進入 Wt\mathcal W_t


16. 缺失成本:清理也可能過度

治理不能只有污染成本,還必須考慮「該存在卻不在工作域」的缺失成本。

定義:

Mt(Wt)=mNtWtωt(m),M_t(\mathcal W_t) = \sum_{m\in\mathcal N_t^*\setminus\mathcal W_t} \omega_t(m),

其中 Nt\mathcal N_t^* 為當前任務真正需要的記憶集合。

因此治理目標不能只最小化:

Kt(Wt).K_t(\mathcal W_t).

否則最乾淨的上下文將退化為空集合。

更完整的目標是:

Jt(Wt)=Kt(Wt)+αMt(Wt)+βCt(Wt)+γTt,J_t(\mathcal W_t) = K_t(\mathcal W_t) +\alpha M_t(\mathcal W_t) +\beta C_t(\mathcal W_t) +\gamma T_t,

其中:

  • KtK_t:污染成本;
  • MtM_t:必要資訊缺失成本;
  • CtC_t:token / latency / compute cost;
  • TtT_t:狀態切換與重取成本。

治理器目標:

minWtJt(Wt).\boxed{ \min_{\mathcal W_t}J_t(\mathcal W_t). }

17. Context Governor 的動態方程

令:

Ft=CtLtEtGt,F_t = \mathcal C_t\circ\mathcal L_t\circ\mathcal E_t\circ\mathcal G_t,

則:

Mt+1=Ft(Mt,qt).\mathfrak M_{t+1}=F_t(\mathfrak M_t,q_t).

如果任務在一段期間內近似穩定:

qt+1qt,q_{t+1}\approx q_t,

我們希望工作域收斂到近似固定點:

Wt+1Wt.\mathcal W_{t+1}\approx\mathcal W_t.

理想情況:

W=F(W).\mathcal W^*=F(\mathcal W^*).

這裡的固定點不是「永遠不變」,而是在任務狀態未顯著改變時,不應無原因持續清理與重新召回同一批資訊。


18. 治理穩定性

定義上下文距離:

dW(Wt,Wt+1),d_W(\mathcal W_t,\mathcal W_{t+1}),

可以由 weighted symmetric difference 表示:

dW(A,B)=mABω(m).d_W(A,B) = \sum_{m\in A\triangle B}\omega(m).

若任務變化量:

dq(qt,qt+1)0,d_q(q_t,q_{t+1})\rightarrow0,

而:

dW(Wt,Wt+1)d_W(\mathcal W_t,\mathcal W_{t+1})

長期仍維持高值,則系統可能處於治理震盪。

定義局部穩定條件:對任意 ε>0\varepsilon>0,存在 δ>0\delta>0,使:

dq(qt,qt+1)<δd_q(q_t,q_{t+1})<\delta

時有:

dW(Wt,Wt+1)<εd_W(\mathcal W_t,\mathcal W_{t+1})<\varepsilon

在排除外部 canonical update 的條件下。

這提供未來 benchmark 一個比單純 recall accuracy 更重要的量:工作上下文是否在穩定任務下不必要地持續抖動。


19. Context Thrashing 與經典 Working Set 的差異

Denning 的 working-set 理論用 locality 管理 page residency 並研究 thrashing。[1][5]

本文借用的只是結構:

有限高成本工作空間較大外部空間.\text{有限高成本工作空間} \leftrightarrow \text{較大外部空間}.

但 AI context thrashing 額外包含:

  • semantic recall thrashing;
  • branch switching;
  • version reactivation;
  • summary expansion / recompression;
  • tool-output reloading;
  • conflicting memory oscillation。

因此 AI 工作集不能只定義為最近使用窗口:

Wt{m:recent(m,t)τ}.\mathcal W_t\neq \{m:\operatorname{recent}(m,t)\geq\tau\}.

它是任務條件化、版本條件化、依賴條件化的動態集合。


20. Governance Policy

治理器可抽象為 policy:

πG(AtSt).\pi_G(A_t\mid S_t).

它可以由:

  • deterministic rules;
  • learned policy;
  • contextual bandit;
  • reinforcement learning;
  • LLM judgment;
  • hybrid controller

實作。

近期 MemCon 已將 retrieve、plan injection、consolidate 與 forget 等操作建模為 context-dependent control policy,顯示這個問題可以從固定 heuristic 推進為 learned control。[6]

本文與此類工作並不衝突。TDCD 的目的不是指定唯一的 policy learner,而是定義 policy 必須治理的狀態結構與安全條件。

換言之:

TDCD specifies what must be governed;\boxed{ \text{TDCD specifies what must be governed;} } a learned controller may decide how to govern it.\boxed{ \text{a learned controller may decide how to govern it.} }

21. 治理安全不變量

為避免 autonomous governor 在清理時破壞長期記憶,提出以下 invariants。

Invariant A:Canonical Preservation

若物件尚未被明確授權永久刪除:

mDtmDt+1m\in\mathcal D_t \Rightarrow m\in\mathcal D_{t+1}

或存在版本化 successor 能恢復其歷史狀態。

Invariant B:Address Preservation

若投影層提及 canonical object:

p(m)Pt,p(m)\in\mathcal P_t,

則必須存在:

a(m).a(m).

Invariant C:Supersession Traceability

若:

mivmj,m_i\prec_v m_j,

則 canonical history 必須可回答:

why(mimj).\operatorname{why}(m_i\rightarrow m_j).

Invariant D:Branch Provenance

跨 branch 進入工作域的物件應保留來源:

b(m),b(m),

不可在 merge 後失去其原始 scope。

Invariant E:Reversible Active Eviction

在正常清理模式中:

evict\operatorname{evict}

不得等價於:

destroy.\operatorname{destroy}.

22. MCP 在治理架構中的位置

MCP 2026-07-28 將 protocol core 改為 stateless request/response,並明確允許需要持久狀態的應用透過顯式 handle 自行管理跨呼叫狀態。[7]

因此 TDCD 的治理狀態不應寄生在 transport session 中。

更適合的結構是:

Agent / Context GovernorMCP BusMemory Services / Databases.\boxed{ \text{Agent / Context Governor} \leftrightarrow \text{MCP Bus} \leftrightarrow \text{Memory Services / Databases}. }

例如:

Governorrecall(memory_handle),\text{Governor} \rightarrow \operatorname{recall}(memory\_handle), Governorexpand(canonical_address),\text{Governor} \rightarrow \operatorname{expand}(canonical\_address), Governorstore(snapshot_handle).\text{Governor} \rightarrow \operatorname{store}(snapshot\_handle).

MCP 負責能力暴露與傳輸; G\mathcal G 負責狀態判斷。


23. 可觀測量與 Benchmark

若 TDCD 只能提出抽象概念而沒有量測方式,就無法成為可驗證理論。

因此提出第一組治理指標。

23.1 Active Context Precision

ACP=WtNtWt.ACP = \frac{|\mathcal W_t\cap\mathcal N_t^*|}{|\mathcal W_t|}.

衡量目前上下文有多少內容真正需要。

23.2 Active Context Recall

ACR=WtNtNt.ACR = \frac{|\mathcal W_t\cap\mathcal N_t^*|}{|\mathcal N_t^*|}.

衡量必要資訊有多少已在工作域。

23.3 Stale Activation Rate

SAR=NstaleactiveNversionedactive.SAR = \frac{N_{stale-active}}{N_{versioned-active}}.

衡量已被 supersede 的資訊錯誤進入 active context 的比例。

23.4 Branch Leakage Rate

BLR=NunjustifiedcrossbranchNactive.BLR = \frac{N_{unjustified-cross-branch}}{N_{active}}.

23.5 Restoration Fidelity

若原始 bytes 為 xx,恢復結果為 x^\hat x

RF=Pr[H(x)=H(x^)].RF = \Pr[H(x)=H(\hat x)].

理想 canonical restoration:

RF=1.RF=1.

23.6 Context Thrashing Rate

CTR=Nadmit+Nevict+NrecallT.CTR = \frac{N_{admit}+N_{evict}+N_{recall}}{T}.

需與任務狀態變化量共同解讀。

23.7 Governance Cost

GC=Cretrieval+Ccompression+CLLMjudgment+Ctransfer+Clatency.GC = C_{retrieval} +C_{compression} +C_{LLM-judgment} +C_{transfer} +C_{latency}.

最終系統不能以節省 prompt tokens 為名,產生更高的隱藏治理成本。


24. Governance Frontier

上下文治理存在至少四個互相競爭的目標:

Ot=(task utility,fidelity,cost,stability).\mathbf O_t =( \text{task utility}, \text{fidelity}, \text{cost}, \text{stability} ).

一般不存在單一設定同時最大化全部維度。

例如 aggressive eviction 可以降低 token cost,但可能提高 recall latency;保留大量版本可以提高 auditability,卻降低 active context precision。

因此合理系統追求的是 Pareto frontier:

FG=Pareto(U,RF,GC,CTR).\mathcal F_G = \operatorname{Pareto} (U,RF,-GC,-CTR).

這也意味不同任務應具有不同 governor profile,而不是一組通用固定閾值。


25. 最小治理循環

本文最小可執行治理循環如下:

ObserveScoreAdmit/EvictResolve VersionCheck BranchExecuteArchiveRe-evaluate.\boxed{ \text{Observe} \rightarrow \text{Score} \rightarrow \text{Admit/Evict} \rightarrow \text{Resolve Version} \rightarrow \text{Check Branch} \rightarrow \text{Execute} \rightarrow \text{Archive} \rightarrow \text{Re-evaluate}. }

以三域表示:

DtΠPtGWtinteractionΔtcanonicalizeDt+1.\mathcal D_t \xrightarrow{\Pi} \mathcal P_t \xrightarrow{\mathcal G} \mathcal W_t \xrightarrow{\text{interaction}} \Delta_t \xrightarrow{\text{canonicalize}} \mathcal D_{t+1}.

再由:

Dt+1Pt+1Wt+1\mathcal D_{t+1} \rightarrow \mathcal P_{t+1} \rightarrow \mathcal W_{t+1}

形成閉環。


26. 本文的主要理論結果

本文得到以下結論。

第一:

Context utility is generally non-monotonic in context size.\boxed{ \text{Context utility is generally non-monotonic in context size.} }

因此「能塞更多」不等價於「應塞更多」。

第二:

Eviction from Wdeletion from D.\boxed{ \text{Eviction from }\mathcal W \neq \text{deletion from }\mathcal D. }

只要 canonical restoration 成立,工作域可以積極清理。

第三:

Version management is a partial-order problem, not a deduplication problem.\boxed{ \text{Version management is a partial-order problem, not a deduplication problem.} }

第四:

Branch isolation should be default; cross-branch linking requires evidence.\boxed{ \text{Branch isolation should be default; cross-branch linking requires evidence.} }

第五:

θin>θout\boxed{ \theta_{in}>\theta_{out} }

提供一個簡單但重要的 anti-thrashing mechanism。

第六:

Retrieval produces candidates; governance produces active context.\boxed{ \text{Retrieval produces candidates; governance produces active context.} }

27. 結論

長期記憶系統真正困難的地方,不只是如何儲存更多資訊,也不是如何把更多歷史壓縮進有限 token window。

真正的問題是:

What belongs in the present?\boxed{ \text{What belongs in the present?} }

本文因此把 TDCD 的核心控制層形式化為 Context Governor,並把工作域視為一個持續變化的 semantic working set。

完整系統不是:

MemorySearchPrompt.\text{Memory} \rightarrow \text{Search} \rightarrow \text{Prompt}.

而是:

Canonical MemoryProjectionGovernanceWorking SetExecutionCanonical Update.\boxed{ \text{Canonical Memory} \rightarrow \text{Projection} \rightarrow \text{Governance} \rightarrow \text{Working Set} \rightarrow \text{Execution} \rightarrow \text{Canonical Update}. }

其最核心的治理原則可以濃縮為:

記憶的安全保存,使上下文可以勇敢地清理;\boxed{ \text{記憶的安全保存,使上下文可以勇敢地清理;} } 上下文的持續清理,使長期記憶真正變得可用。\boxed{ \text{上下文的持續清理,使長期記憶真正變得可用。} }

因此,對長程 AI 而言,理想狀態不是永遠記住所有事情,而是:

完整地保存過去,選擇性地形成現在,必要時精確地重新展開。\boxed{ \text{完整地保存過去,選擇性地形成現在,必要時精確地重新展開。} }

參考文獻

[1] Denning, P. J. (1968). The Working Set Model for Program Behavior. Communications of the ACM, 11(5), 323–333. DOI: 10.1145/363095.363141.

[2] Positional Failures in Long-Context LLMs: A Blind Spot in Reasoning Benchmarks. arXiv:2605.23170, 2026.

[3] Diagnosing and Mitigating Context Rot in Long-horizon Search. arXiv:2606.29718, 2026.

[4] Patel, V. (2026). Supersede: Diagnosing and Training the Memory-Update Gap in LLM Agents. arXiv:2606.27472.

[5] Denning, P. J. (1968). Thrashing: Its Causes and Prevention. AFIPS Fall Joint Computer Conference.

[6] Jiang, E. H., Zhang, Z., Wu, Y., et al. (2026). Memory as a Controlled Process: Learned Adaptive Memory Management for LLM Agents. arXiv:2607.13591.

[7] Model Context Protocol Core Maintainers. (2026). The 2026-07-28 Specification.