Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6897467
docs(decisions): a unit's session comes from the board
wefio Sep 19, 2026
f9ebd71
docs(decisions): the session identity is already there, so nothing re…
wefio Sep 19, 2026
a6132db
docs(decisions): the continuation is an in-band JSON block read by a …
wefio Sep 19, 2026
0ecfd2b
docs(decisions): the declaration is a parameter and the result is a r…
wefio Sep 19, 2026
df0e1c9
feat(execution): a session move has a name and a home in the run log
wefio Sep 19, 2026
075b2a6
test(execution): the session move is recorded once and read back as i…
wefio Sep 19, 2026
df0954a
feat(execution): a boundary decides and records its move in one call
wefio Sep 19, 2026
0296466
feat(execution): the session key is a function of the board, not of t…
wefio Sep 19, 2026
41ca6c4
refactor(execution): the session mechanism moves to the shared layer,…
wefio Sep 19, 2026
53fbb10
feat(execution): one call opens a unit's session - the key it runs un…
wefio Sep 19, 2026
070a42a
test(execution): a move belongs to the boundary, not to the session t…
wefio Sep 19, 2026
10b2d15
test(execution): no file may ask the adapter for a name the shared me…
wefio Sep 19, 2026
230d259
docs(experiments): the fusion trial's control arm, and the arm that c…
wefio Sep 19, 2026
d5af9ef
fix(execution): a fused session tells its units which conclusions are…
wefio Sep 19, 2026
7004f97
fix(execution): a fused session says which conclusions and which tool…
wefio Sep 19, 2026
86d67f2
docs(experiments): the fused arm measured - same quality, 15% more to…
wefio Sep 19, 2026
ce9b105
fix(execution): a task-level cancellation closes that task, not the w…
wefio Sep 19, 2026
149816b
docs(execution): the fusion claims say what their two reps actually c…
wefio Sep 19, 2026
7fabe4c
docs(execution): an A-D plan built on the samples that exist, and two…
wefio Sep 19, 2026
4b0ba09
docs(execution): the ledger says which evidence base each proof lives on
wefio Sep 19, 2026
6264aaf
measure(execution): a third rep on the cap cells - the wall saving su…
wefio Sep 19, 2026
f158308
docs(execution): fusion's measured benefit is stated, its old reading…
wefio Sep 19, 2026
9803ce7
feat(execution): a run records its own instrument and the provider's …
wefio Sep 19, 2026
6d1dbe2
measure(execution): the A-D cells on the plain path, and what the cha…
wefio Sep 19, 2026
19dbc72
docs(execution): the arm programme gets one measurement plan, with an…
wefio Sep 19, 2026
40c542b
measure(execution): the pair-grade reps land, and the plan's grades hold
wefio Sep 19, 2026
5e7b04c
docs(decisions): when the chain path may be entered, and the session-…
wefio Sep 19, 2026
bcef902
docs(decisions): the deferred item is an executor, not a call site
wefio Sep 19, 2026
5403faf
refactor(execution): the dispatch loop is shared, and the board is a …
wefio Sep 20, 2026
b140ff7
fix(execution): one pass takes each unit at most once
wefio Sep 20, 2026
e3508a3
test(execution): the shared loop gets a fast suite of its own, and it…
wefio Sep 20, 2026
af07f5a
test(execution): the arms' checks read data, and the host prepares no…
wefio Sep 20, 2026
c01d3fe
feat(rtm): the traceability report is evidence, not a count
wefio Sep 20, 2026
f99b09b
docs(execution): the product call path is audited against the extract…
wefio Sep 20, 2026
0982fe9
docs(experiments): the trial's stored specs keep their day's check sh…
wefio Sep 20, 2026
5cc822e
fix(lint): the trial's spec generator lives where the lint surface ca…
wefio Sep 20, 2026
43e9cc1
fix(lint): the generator's usage line and the trial README follow the…
wefio Sep 20, 2026
0ef177f
docs(decisions): the session AG runtime is implemented, not proposed
wefio Sep 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
420 changes: 65 additions & 355 deletions .pi/extensions/nmg/ooo-execution.ts

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions agent-context.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,16 @@ routes:
- src/integration/tool-contract.ts
owners:
- docs/design/design.md
tests: [tests/integration/agent-surface.test.ts, tests/integration/chain-projection.test.ts, tests/integration/config.test.ts, tests/integration/controller-channel.test.ts, tests/integration/evidence.test.ts, tests/integration/lab-capabilities.test.ts, tests/integration/tool-contract.test.ts]
tests:
[
tests/integration/agent-surface.test.ts,
tests/integration/chain-projection.test.ts,
tests/integration/config.test.ts,
tests/integration/controller-channel.test.ts,
tests/integration/evidence.test.ts,
tests/integration/lab-capabilities.test.ts,
tests/integration/tool-contract.test.ts,
]
verify:
blocking: [check, test:product, build]
advisory: []
Expand All @@ -203,12 +212,15 @@ routes:
paths:
- src/integration/ooo-board.ts
- src/integration/ooo-candidate.ts
- src/integration/ooo-dispatch.ts
- src/integration/ooo-execution.ts
- src/integration/ooo-fusion-plan.ts
- src/integration/ooo-mutation.ts
- src/integration/ooo-patch.ts
- src/integration/check-ticket.ts
- src/integration/check-runner.ts
- src/integration/ooo-session-facts.ts
- src/integration/ooo-session-mechanism.ts
- src/integration/task-advisers.ts
- src/integration/task-coordinator.ts
- src/integration/task-semantics-interleavings.ts
Expand All @@ -235,7 +247,12 @@ routes:
owners:
- docs/design/design.md
- docs/design/tiered-disclosure-design.md
tests: [tests/integration/leaf-summarizer.test.ts, tests/integration/summary-drain.test.ts, tests/core/store/node-summaries.test.ts]
tests:
[
tests/integration/leaf-summarizer.test.ts,
tests/integration/summary-drain.test.ts,
tests/core/store/node-summaries.test.ts,
]
verify:
blocking: [check, test:product, build]
advisory: []
122 changes: 122 additions & 0 deletions docs/decisions/implemented/2026-08-29-session-active-graph-runtime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Session-owned Active Graph runtime

[中文](2026-08-29-session-active-graph-runtime.zh-CN.md)

**Status:** implemented
**Approved:** unrecorded
**Relates to:** [Session AG runtime blueprint](../../design/session-active-graph-runtime-design.md)

## Problem

NMG used "Active Graph" for a query-scoped retrieval result while the Pi adapter separately kept a
flat `SessionRuntimeAg` for recent tool state. The two structures served different parts of working
memory, duplicated lifecycle logic, and left the task-state term in `AG_t = Project(STG, LTG, q_t,
task_t)` without a stable runtime owner. `activeGraphId` also named the retrieval trace, so a mutable
working graph and an immutable exposure record could not be distinguished.

Hierarchical Activation (HA) and the Memory-Graph Reasoner (MGR) already provided candidate
activation and graph traversal primitives, but they remained beside the runtime rather than operating
on one bounded working graph.

## Decision

AG is a **session-owned, mutable, memory-resident runtime graph**. It is the only working-memory
container, but it remains non-authoritative: durable truth and provenance stay in STG/LTG, and AG
disappears when its owning session is released.

AG holds task frames, STG/LTG references, bounded tool observations, temporary relations, unresolved
working state, reasoning artifacts, activation metadata, and a disclosure ledger. It may keep one
active task frame and a small bounded set of cooling frames, so a task switch does not destroy state
and a return does not require reconstructing everything from the transcript.

Each model-visible retrieval freezes an immutable `ProjectionRevision` from the mutable AG. Four
identities are kept distinct:

- `agId`: the session working graph;
- `taskFrameId`: one semantic task partition inside AG;
- `projectionId`: one immutable selection/disclosure/feedback boundary;
- `boardChannelId`: a Task Board coordination channel.

The update is:

```text
candidates_t = Project(STG, LTG, q_t, TaskBelief_t)
AG_(t+1) = Update_B(AG_t, candidates_t, observations_t, TaskBelief_t)
Projection_t = Freeze(VisibleSubset(AG_(t+1)))
```

`B` is a hard total budget over nodes, edges, evidence, tokens, graph depth, temporary observations,
reasoning steps, task frames, and latency. HA scores activation, cooling, reactivation, and budget
allocation. MGR may traverse the selected AG subgraph and emit bounded hypothetical nodes or
reasoning edges. HA can then rescore those artifacts before a projection is frozen.

AG has three typed edge layers which must not silently reinforce each other:

1. semantic edges referenced from STG/LTG;
2. activation/attention edges produced by HA;
3. hypothetical reasoning/operator edges produced by MGR.

Activation is not truth, and an MGR result is not a memory write. MGR artifacts start as attributed,
TTL-bound hypotheses and can reach STG/LTG only through a separate verified or explicit `remember`
path. Persistent HA/MGR model weights, if later justified, live in versioned controller/Lab state
rather than AG.

The query-scoped `ActiveGraph` became a projection revision, the Pi adapter's flat `SessionRuntimeAg`
was removed, and the injection window moved into the AG disclosure ledger. The APIs of the day were
implementation evidence, not compatibility requirements for the target design.

The criteria this decision set, each one a requirement on the runtime and its host wiring:

- the normative design distinguishes AG, task frame, projection revision, and Task Board channel
identities;
- AG is memory-resident and session-owned; no AG content is persisted as authoritative semantic
memory;
- a projection revision freezes exact model exposure and supports later exact get, attribution,
verified outcomes, and replay after AG mutation;
- tool observations and retrieved semantic references share one total AG budget without becoming
durable writes;
- HA fast state is isolated by session/branch; its activation cannot increase semantic confidence or
edge stability by itself;
- MGR uses only bounded selected AG subgraphs, records derivation provenance, and emits hypothetical
TTL-bound artifacts;
- task-switch tests cover continuation, A-to-B switch, A-to-B-to-A return, shared constraints, false
switches, compaction, and session cleanup;
- the query-scoped AG, the Pi runtime AG, and the continuation map are migrated or removed rather
than kept as permanent compatibility layers.

## Alternatives considered

1. **Keep query-scoped AG and add a separate task-state manager.** This is the smallest
implementation change but retains two working-memory containers and makes compaction/task-return
behavior adapter-specific.
2. **Persist AG as a third semantic graph.** Rejected because temporary activation, tool state, and
hypotheses would become confused with durable memory and shared truth.
3. **Make MGR or HA own working memory.** Rejected because scoring and reasoning engines should
remain replaceable capabilities; neither should own evidence, session lifecycle, or disclosure
provenance.
4. **Treat the entire session as one task.** Rejected because topic drift causes contamination and
repeated query hashes provide a poor estimate of independent tasks for stability learning.

## Consequences

- The runtime that carries this decision is `src/core/session-active-graph.ts`: one active frame plus
a bounded cooling set, frame-local parent chains, a unified item/character budget across all
frames, `ttlMs` on artifacts, and the disclosure ledger a host writes with `markDisclosed`.
- The three compatibility layers the decision named are gone. The Pi adapter's runtime AG was
removed, the continuation map no longer exists, and the query-scoped AG is now the projection
revision; the identity collision the problem statement named is resolved by the four identities.
- Which capability stands where, and how each criterion maps to code, is owned by the
[runtime blueprint](../../design/session-active-graph-runtime-design.md) §4; this record does not
restate that status table.
- The disclosure ledger is host-neutral: the Pi extension, the Claude plugin, WorkBuddy and DSH mark
a projection through the runtime instead of keeping an injection window of their own, so a host that
kept one would be a second home for the same rule.

## Deferred

- The full multidimensional shared account (blueprint 4.3): the runtime bounds items and characters
across all frames, and the semantic/tool/reasoning account as one ledger remains open.
- Automatic MGR admission (blueprint 4.4): the runtime primitive for TTL-bound, attributed artifacts
is implemented; admitting MGR output without an explicit act remains deferred.
- HA admission and rescoring on AG (blueprint 4.6): intentionally deferred until natural-utility
evidence exists; explicit Lab invocation and its isolation remain available.
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,49 @@

[English](2026-08-29-session-active-graph-runtime.md)

**Status:** proposed

截至 2026-08-29 已部分实现:protocol v9 与 `SessionActiveGraphRuntime` 已提供
daemon 所有的会话状态、不可变 projection 身份、projection-to-trace 来源映射、Pi
工具/Task Board 观察接入、确定性释放、按会话隔离的 HA 快状态,以及受 projection
预算约束的 MGR 调用。自动 task/branch 生命周期、统一总预算、共享披露账本和带 TTL
推理产物尚未满足验收条件,因此本决策继续保持 proposed。
**Status:** implemented
**Approved:** unrecorded
**Relates to:** [会话 AG 运行时蓝图](../../design/session-active-graph-runtime-design.md)

## 问题

NMG 当前用 Active Graph 表示一次查询的检索结果,同时 Pi 适配器另有扁平的
NMG 曾用 Active Graph 表示一次查询的检索结果,同时 Pi 适配器另有扁平的
`SessionRuntimeAg` 保存近期工具状态。这两套结构分别承担工作记忆的一部分,重复了
生命周期逻辑,也没有为 `AG_t = Project(STG, LTG, q_t, task_t)` 中的稳定任务状态
提供明确所有者。`activeGraphId` 同时等于检索轨迹 ID,因而无法区分可变工作图和
不可变暴露记录。

层次化激活(HA)和 Memory-Graph Reasoner(MGR)已经提供候选激活与图遍历原语,
但目前位于运行时旁路,没有共同作用于一张受预算约束的工作图。
但当时位于运行时旁路,没有共同作用于一张受预算约束的工作图。

## 提案
## 决策

AG 重新定义为**会话所有、可变、纯内存的运行时图**。它是唯一的工作记忆容器,
但仍然不是权威记忆:持久事实和来源留在 STG/LTG,拥有它的会话释放时 AG 消失。
AG **会话所有、可变、纯内存的运行时图**。它是唯一的工作记忆容器,但仍然不是权威
记忆:持久事实和来源留在 STG/LTG,拥有它的会话释放时 AG 消失。

AG 可包含任务分区、STG/LTG 引用、受限工具观察、临时关系、未解决工作状态、推演
产物、激活元数据和披露账本。它可保留一个活跃任务分区以及少量有界的 cooling 分区,
从而在任务切换时不销毁状态,返回旧任务时也不必完全依赖 transcript 重建。

每次向模型披露内容时,从可变 AG 冻结一个不可变的 `ProjectionRevision`。明确区分:
每次向模型披露内容时,从可变 AG 冻结一个不可变的 `ProjectionRevision`。四个身份
必须明确区分:

- `agId`:会话工作图;
- `taskFrameId`:AG 内一个语义任务分区;
- `projectionId`:一次不可变的选择、披露与反馈边界;
- `boardChannelId`:Task Board 协作频道。

目标更新过程为
更新过程为

```text
candidates_t = Project(STG, LTG, q_t, TaskBelief_t)
AG_(t+1) = Update_B(AG_t, candidates_t, observations_t, TaskBelief_t)
Projection_t = Freeze(VisibleSubset(AG_(t+1)))
```

`B` 继续作为节点、边、证据、token、图深度、临时观察、推演步数、任务分区和延迟的
总硬预算。HA 负责激活、降温、重新激活和预算分配;MGR 可遍历选中的 AG 子图并产生
受限的假设节点或推理边;随后 HA 可在冻结 projection 前重新评分这些产物。
`B` 是节点、边、证据、token、图深度、临时观察、推演步数、任务分区和延迟的总硬预算。
HA 负责激活、降温、重新激活和预算分配;MGR 可遍历选中的 AG 子图并产生受限的假设
节点或推理边;随后 HA 可在冻结 projection 前重新评分这些产物。

AG 内部必须区分三层边,且它们不能静默互相强化:

Expand All @@ -59,9 +56,22 @@ AG 内部必须区分三层边,且它们不能静默互相强化:
假设,只能通过独立的验证或显式 `remember` 路径进入 STG/LTG。若以后需要持久化
HA/MGR 参数,它们属于版本化 controller/Lab 状态,而不属于 AG。

当前 query-scoped `ActiveGraph` 改为 projection revision。Pi 的扁平
`SessionRuntimeAg` 在工具观察进入共享 session AG 后退化为短暂事件接入缓存或被删除;
injection window 并入 AG 的披露账本。现有 API 只是实现现状,不构成目标设计的兼容要求。
query-scoped `ActiveGraph` 改为 projection revision,Pi 适配器的扁平
`SessionRuntimeAg` 已删除,injection window 并入 AG 的披露账本。当时的 API 是实现
现状,不构成目标设计的兼容要求。

本决策设定的条件,每条都是对运行时及其宿主接线的要求:

- 规范设计明确区分 AG、task frame、projection revision 和 Task Board channel;
- AG 只存在内存并归属会话;AG 内容不会作为权威语义记忆持久化;
- projection revision 冻结模型实际看到的证据,并在 AG 变化后仍支持精确 get、归因、
验证结果与回放;
- 工具观察和语义记忆引用共享一份 AG 总预算,但不会因此成为持久写入;
- HA 快状态按 session/branch 隔离;激活本身不能提高语义置信度或边稳定度;
- MGR 只消费受预算约束的 AG 子图,保留派生来源,并输出带 TTL 的假设产物;
- 任务切换测试覆盖连续任务、A→B、A→B→A、共享约束、误切换、压缩和会话清理;
- 当前 query AG、Pi runtime AG 和 continuation map 被迁移或删除,而不是成为永久
兼容层。

## 考虑过的替代方案

Expand All @@ -74,23 +84,25 @@ injection window 并入 AG 的披露账本。现有 API 只是实现现状,不
4. **整场 session 视作一个任务。** 拒绝;主题漂移会造成污染,而每次 query hash
也不能可靠表示边稳定度所需的独立任务。

## 验收标准

- 规范设计明确区分 AG、task frame、projection revision 和 Task Board channel。
- AG 只存在内存并归属会话;AG 内容不会作为权威语义记忆持久化。
- projection revision 冻结模型实际看到的证据,并在 AG 变化后仍支持精确 get、归因、
验证结果与回放。
- 工具观察和语义记忆引用共享一份 AG 总预算,但不会因此成为持久写入。
- HA 快状态按 session/branch 隔离;激活本身不能提高语义置信度或边稳定度。
- MGR 只消费受预算约束的 AG 子图,保留派生来源,并输出带 TTL 的假设产物。
- 任务切换测试覆盖连续任务、A→B、A→B→A、共享约束、误切换、压缩和会话清理。
- 当前 query AG、Pi runtime AG 和 continuation map 被迁移或删除,而不是成为永久兼容层。

## 风险

- 过度任务切分会破坏因果连续性;切分不足会保留无关状态。
- 若激活、推演、语义置信度和稳定度没有类型隔离,HA 与 MGR 会形成自强化回路。
- 可变会话状态增加并发、分支所有权、清理和确定性回放的复杂度。
- 多个 cooling task frame 可能消耗内存与 prompt 预算却没有实际收益。
- 在共享运行时落地前先改适配器,会制造更多重复实现;应先实现 Core session AG 和
projection 契约,再做宿主接线。
## 后果

- 承载本决策的运行时是 `src/core/session-active-graph.ts`:一个活跃分区加有界
cooling 集合、分区内的 parent chain、跨分区的统一条目/字符预算、产物上的
`ttlMs`,以及宿主用 `markDisclosed` 写入的披露账本。
- 问题里点名的三层兼容结构均已消失:Pi adapter 的 runtime AG 被删除,continuation
map 不再存在,query-scoped AG 已成为 projection revision;四个身份之分也消除了
当时 `activeGraphId` 兼作轨迹名的歧义。
- 每项能力的当前状态以及它与代码的对应关系由[运行时蓝图](../../design/session-active-graph-runtime-design.md)
§4 拥有,本记录不重述那张状态表。
- 披露账本是宿主中立的:Pi 扩展、Claude 插件、WorkBuddy 和 DSH 都通过运行时标记
projection,而不再各自保留 injection window;若某宿主仍保留一份,同一规则就有了
第二个家。

## 未完成项

- 多维共享总账(蓝图 4.3):运行时已有跨分区的条目与字符上限,语义/工具/推演合成
一本账仍未完成。
- MGR 自动准入(蓝图 4.4):带 TTL 与来源的产物原语已实现,未经显式动作即接纳
MGR 输出仍然延后。
- AG 上的 HA 准入与重新评分(蓝图 4.6):在有自然效用证据前有意延后;显式 Lab
调用及其隔离仍然可用。
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

**Status:** implemented
**Approved:** explicit
**Superseded by:** [The dispatch loop is shared](2026-09-19-dispatch-loop-is-shared.md)
Date: 2026-09-17
Branch: feat/ooo-run-namespace
**Relates to:** [task-unit semantics design](../../design/task-unit-semantics.md),
Expand Down Expand Up @@ -148,3 +149,10 @@ not "not started".
refusals.
- `evals/ooo-execution/cycle.test.ts` — 23 cases, unchanged and green: the driver's behaviour is
preserved.

## What the later supersession leaves standing

The supersession is partial and the later record states its scope: what it moves is where the loop that
executes a given plan lives. Everything else here stands - the arms keep their own driver, their spec
declarations and their measurement record, the product still does not own a planning platform, and
`src/integration/ooo-cycle.ts` stays the specific external-window experiment it is.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

**Status:** implemented
**Approved:** explicit
**Superseded by:** [派发循环是共享的](2026-09-19-dispatch-loop-is-shared.zh-CN.md)
Date: 2026-09-17
Branch: feat/ooo-run-namespace
**Relates to:** [task-unit 语义设计](../../design/task-unit-semantics.md)、
Expand Down Expand Up @@ -114,3 +115,7 @@ in the plan` 失败;把汇合点从 `C` 改名也同样失败。可读性那
`["A","B","C"]` 会令其失败)、上述两种拒绝、一个计划值同时到达 store 与轮次、spec 映射及其默认值、
以及解析器的拒绝。
- `evals/ooo-execution/cycle.test.ts` —— 23 条,未改动且全绿:驱动器行为被保留。

## 这次部分取代之后仍然成立的

取代是部分的,范围写在后一条记录里:被搬动的是**执行一份给定计划的循环住在哪**。本记录其余内容全部成立——臂保留自己的驱动、spec 声明与测量记录;产品仍不拥有规划平台;`src/integration/ooo-cycle.ts` 仍是它那个特定的外部等待窗口实验。
Loading
Loading