refactor(subagent): derive agent names from creation records

This commit is contained in:
Dudu-0223 committed 2026-10-16 15:33:23 +08:00
1 parent c3a4c95800
commit 3c0bbdfeb1
130 files changed
+1619 -1282

No files matched your search

@@ -9,8 +9,8 @@
en: a5bae46eec7e5c5b
zh: 190923c7b9b397d9
/2026-10-16-tree-wide-agent-names/summary:
en: 3f16c8de27431ce8
zh: d3db668518da7e37
en: 6e23ea12e89a6757
zh: ac9d622b031d0ef7
/2026-10-16-tree-wide-agent-names/table-of-contents:
en: 6cf314a069ceb451
zh: 9adff678e9ecab3b
@@ -18,11 +18,11 @@
en: 6907136f28e48c90
zh: 02f8298485f3d8e7
/2026-10-16-tree-wide-agent-names/compatibility:
en: fbdcc4f1b829bb9c
zh: 2454c11be18019c7
en: 545b22f47bd00215
zh: 95226d0985a2fb8e
/2026-10-16-tree-wide-agent-names/verification:
en: 1b417eb5cdfa4ce6
zh: ec3f2dfcddd16b25
en: 5e054e311823a97b
zh: 7162121924d879e7
/2026-10-16-tree-wide-agent-names/dev-note:
en: b75c8458928b72b9
zh: 003ba4e17b4b5269
@@ -9,7 +9,7 @@ English | [中文](2026-10-16-tree-wide-agent-names.zh.md)
## Summary
Records immutable tree-wide agent names in the root Session.
Stores immutable tree-wide agent names in existing subagent catalog and descriptor records.
## Table of Contents
@@ -26,21 +26,25 @@ schemaVersion: 1
id: 2026-10-16-tree-wide-agent-names
baseline: false
changes:
- root: "event:subagent/named"
previous: null
after: "273f07aea05d56ffbb8b43508bcfb4a20cce230819feadb3fe740bceb8b12ca6"
- root: "event:subagent/catalog"
previous: "2026-09-19-external-subagent-catalog"
after: "8521c4e8b3ddb8a7835fe8e707061bf4a9a52b9e4c2e98e5fc5fef2ac4998ff3"
decision: same-version
- root: "event:subagent/descriptor"
previous: "2026-09-11-initial"
after: "194530445ad15cc68b8a708321a4d8d118dfe54600864fcb965ffca9b1afb8cc"
decision: same-version
```
<a id="compatibility"></a>
## Compatibility
New readers accept older Sessions without assignments and expose stable legacy addresses. Older readers reject the new non-ignorable subagent/named discriminator instead of silently losing identity; existing catalog records and Session ids are unchanged. No writer format bump is needed.
New readers accept earlier field-free catalogs and descriptors and expose stable legacy addresses. Older catalog readers reject the added name field through their strict event schema; older descriptor readers reject the unknown field and cannot cold-resume that child. Neither reader silently assigns a different identity. Session ids, event discriminators, and writer format remain unchanged. Existing projection checkpoints are invalidated by their state-version increments. Names remain reserved after settlement; external caller-delivered executions now also publish catalog entries.
<a id="verification"></a>
## Verification
The names.spec.ts and tool-team.spec.ts tests passed (33 cases); names.ts reached 100% statement, branch, function, and line coverage. Headless and TypeScript SDK replay exercised named creation, messages, discovery, and completion.
Focused catalog, descriptor, continuation, and Team tests passed. The names and continuation tests exercised concurrent catalog reconstruction, cold name recovery, unreadable historical branches, failed-start release, fork isolation, and repeated child-id rejection; names.ts reached 100% statement, branch, function, and line coverage.
<a id="dev-note"></a>
## Dev Note
@@ -2,11 +2,11 @@
"formatVersion": 2,
"roots": [
{
"key": "event:subagent/named",
"key": "event:subagent/catalog",
"kind": "event",
"event": "subagent/named",
"event": "subagent/catalog",
"surface": false,
"digest": "273f07aea05d56ffbb8b43508bcfb4a20cce230819feadb3fe740bceb8b12ca6",
"digest": "8521c4e8b3ddb8a7835fe8e707061bf4a9a52b9e4c2e98e5fc5fef2ac4998ff3",
"schema": {
"root": 0,
"nodes": [
@@ -20,23 +20,246 @@
},
{
"name": "ignorable",
"type": 3,
"type": 17,
"optional": true
},
{
"name": "seq",
"type": 4,
"type": 3,
"optional": false
},
{
"name": "time",
"type": 4,
"type": 3,
"optional": false
},
{
"name": "type",
"type": 18,
"optional": false
}
],
"indices": []
},
{
"kind": "union",
"types": [
2,
7,
9,
12,
14,
15
]
},
{
"kind": "object",
"properties": [
{
"name": "childCreatedAt",
"type": 3,
"optional": false
},
{
"name": "childId",
"type": 4,
"optional": false
},
{
"name": "label",
"type": 4,
"optional": false
},
{
"name": "mode",
"type": 5,
"optional": false
},
{
"name": "name",
"type": 4,
"optional": true
},
{
"name": "version",
"type": 6,
"optional": false
}
],
"indices": []
},
{
"kind": "primitive",
"type": "number"
},
{
"kind": "primitive",
"type": "string"
},
{
"kind": "literal",
"value": "continuable"
},
{
"kind": "literal",
"value": 0
},
{
"kind": "object",
"properties": [
{
"name": "childCreatedAt",
"type": 3,
"optional": false
},
{
"name": "childId",
"type": 4,
"optional": false
},
{
"name": "label",
"type": 4,
"optional": false
},
{
"name": "mode",
"type": 5,
"optional": false
},
{
"name": "name",
"type": 4,
"optional": true
},
{
"name": "version",
"type": 8,
"optional": false
}
],
"indices": []
},
{
"kind": "literal",
"value": 1
},
{
"kind": "object",
"properties": [
{
"name": "childCreatedAt",
"type": 3,
"optional": false
},
{
"name": "childId",
"type": 4,
"optional": false
},
{
"name": "label",
"type": 4,
"optional": true
},
{
"name": "mode",
"type": 10,
"optional": false
},
{
"name": "name",
"type": 4,
"optional": true
},
{
"name": "version",
"type": 11,
"optional": false
}
],
"indices": []
},
{
"kind": "literal",
"value": "external"
},
{
"kind": "literal",
"value": 2
},
{
"kind": "object",
"properties": [
{
"name": "childCreatedAt",
"type": 3,
"optional": false
},
{
"name": "childId",
"type": 4,
"optional": false
},
{
"name": "label",
"type": 4,
"optional": true
},
{
"name": "mode",
"type": 13,
"optional": false
},
{
"name": "name",
"type": 4,
"optional": true
},
{
"name": "version",
"type": 6,
"optional": false
}
],
"indices": []
},
{
"kind": "literal",
"value": "one-shot"
},
{
"kind": "object",
"properties": [
{
"name": "childCreatedAt",
"type": 3,
"optional": false
},
{
"name": "childId",
"type": 4,
"optional": false
},
{
"name": "label",
"type": 4,
"optional": true
},
{
"name": "mode",
"type": 13,
"optional": false
},
{
"name": "name",
"type": 4,
"optional": true
},
{
"name": "version",
"type": 8,
"optional": false
}
],
"indices": []
@@ -45,13 +268,151 @@
"kind": "object",
"properties": [
{
"name": "id",
"type": 2,
"name": "childCreatedAt",
"type": 3,
"optional": false
},
{
"name": "childId",
"type": 4,
"optional": false
},
{
"name": "label",
"type": 4,
"optional": true
},
{
"name": "mode",
"type": 16,
"optional": false
},
{
"name": "name",
"type": 2,
"type": 4,
"optional": true
},
{
"name": "version",
"type": 8,
"optional": false
}
],
"indices": []
},
{
"kind": "literal",
"value": "unknown"
},
{
"kind": "literal",
"value": true
},
{
"kind": "literal",
"value": "subagent/catalog"
}
]
}
},
{
"key": "event:subagent/descriptor",
"kind": "event",
"event": "subagent/descriptor",
"surface": false,
"digest": "194530445ad15cc68b8a708321a4d8d118dfe54600864fcb965ffca9b1afb8cc",
"schema": {
"root": 0,
"nodes": [
{
"kind": "object",
"properties": [
{
"name": "data",
"type": 1,
"optional": false
},
{
"name": "ignorable",
"type": 10,
"optional": true
},
{
"name": "seq",
"type": 7,
"optional": false
},
{
"name": "time",
"type": 7,
"optional": false
},
{
"name": "type",
"type": 11,
"optional": false
}
],
"indices": []
},
{
"kind": "union",
"types": [
2,
8
]
},
{
"kind": "object",
"properties": [
{
"name": "agentModel",
"type": 3,
"optional": true
},
{
"name": "agentProvider",
"type": 3,
"optional": true
},
{
"name": "agentReasoningEffort",
"type": 3,
"optional": true
},
{
"name": "label",
"type": 3,
"optional": false
},
{
"name": "mode",
"type": 4,
"optional": false
},
{
"name": "name",
"type": 3,
"optional": true
},
{
"name": "persona",
"type": 3,
"optional": true
},
{
"name": "provider",
"type": 3,
"optional": false
},
{
"name": "toolFilter",
"type": 5,
"optional": true
},
{
"name": "version",
"type": 7,
"optional": false
}
],
@@ -63,15 +424,74 @@
},
{
"kind": "literal",
"value": true
"value": "continuable"
},
{
"kind": "object",
"properties": [
{
"name": "allow",
"type": 6,
"optional": true
},
{
"name": "deny",
"type": 6,
"optional": true
}
],
"indices": []
},
{
"kind": "array",
"element": 3
},
{
"kind": "primitive",
"type": "number"
},
{
"kind": "object",
"properties": [
{
"name": "label",
"type": 3,
"optional": true
},
{
"name": "mode",
"type": 9,
"optional": false
},
{
"name": "name",
"type": 3,
"optional": true
},
{
"name": "provider",
"type": 3,
"optional": false
},
{
"name": "version",
"type": 7,
"optional": false
}
],
"indices": []
},
{
"kind": "literal",
"value": "subagent/named"
"value": "one-shot"
},
{
"kind": "literal",
"value": true
},
{
"kind": "literal",
"value": "subagent/descriptor"
}
]
}
@@ -9,7 +9,7 @@ kind: persistence-change
## 概述
在根 Session 记录整棵树内唯一且不可变的 agent 名字。
在现有 subagent catalog 和 descriptor 记录中保存不可变的树内唯一名字。
## 目录
@@ -26,21 +26,25 @@ schemaVersion: 1
id: 2026-10-16-tree-wide-agent-names
baseline: false
changes:
- root: "event:subagent/named"
previous: null
after: "273f07aea05d56ffbb8b43508bcfb4a20cce230819feadb3fe740bceb8b12ca6"
- root: "event:subagent/catalog"
previous: "2026-09-19-external-subagent-catalog"
after: "8521c4e8b3ddb8a7835fe8e707061bf4a9a52b9e4c2e98e5fc5fef2ac4998ff3"
decision: same-version
- root: "event:subagent/descriptor"
previous: "2026-09-11-initial"
after: "194530445ad15cc68b8a708321a4d8d118dfe54600864fcb965ffca9b1afb8cc"
decision: same-version
```
<a id="compatibility"></a>
## 兼容性
新读取方接受没有名字分配的旧 Session,并公开稳定的旧地址。旧读取方拒绝新的非可忽略 subagent/named 判别值,避免静默丢失身份;现有目录记录与 Session id 不变。无需提升写入格式版本。
新读取方接受早期不含名字的 catalog 和 descriptor,并公开稳定的旧地址。旧 catalog 读取方通过严格事件 schema 拒绝新增的 name 字段;旧 descriptor 读取方拒绝未知字段,无法冷恢复该子级。两种读取方都不会静默分配其他身份。Session id、事件判别字段与写入格式不变。现有投影检查点通过状态版本递增失效。执行结束后名字仍被占用;采用 caller 交付的外部执行现在也发布 catalog 条目。
<a id="verification"></a>
## 验证
names.spec.ts 与 tool-team.spec.ts 的 33 个用例通过;names.ts 的语句、分支、函数与行覆盖率均为 100%。Headless 与 TypeScript SDK 回放覆盖按名字创建、消息、发现和完成通知。
聚焦的 catalog、descriptor、continuation 与 Team 测试通过。命名与继续执行测试覆盖并发 catalog 重建、冷恢复名字、不可读历史分支、启动失败释放、分叉隔离与重复 child-id 拒绝;names.ts 的语句、分支、函数和行覆盖率均为 100%。
<a id="dev-note"></a>
## 开发备注
@@ -15,8 +15,8 @@
en: 14c57f30e676f6e3
zh: b1a0ccf26fab3727
/session-persistence-formats/format-references:
en: 57e3fe7dd9e36b70
zh: 2dac8a29964d982f
en: 43a4a6600fa37a1a
zh: 72174fab8355c344
/session-persistence-formats/scope-and-evidence:
en: b220062139ddac1e
zh: 7c4c0efe05dafa9c
@@ -32,7 +32,7 @@ The index is generated from validated snapshots and the current writer constant.
| 1 | PR #3349 | [V1](v1.md) | [JSON](v1.schema.json) | 54 / 415 |
| 2 | `dsh-v0.1.3-alpha.2` | [V2](v2.md) | [JSON](v2.schema.json) | 56 / 435 |
| 3 | PR #4320 | [V3](v3.md) | [JSON](v3.schema.json) | 60 / 467 |
| 4 | Current checkout | [Current catalog](../../persistence-catalog.md) | [JSON](../../persistence-schema.json) | 66 / 615 |
| 4 | Current checkout | [Current catalog](../../persistence-catalog.md) | [JSON](../../persistence-schema.json) | 65 / 612 |
<!-- persistence-format-index:end -->
@@ -32,7 +32,7 @@ description: "查找从 V0 到工作区写入器版本的每个 Session 格式
| 1 | PR #3349 | [V1](v1.zh.md) | [JSON](v1.schema.json) | 54 / 415 |
| 2 | `dsh-v0.1.3-alpha.2` | [V2](v2.zh.md) | [JSON](v2.schema.json) | 56 / 435 |
| 3 | PR #4320 | [V3](v3.zh.md) | [JSON](v3.schema.json) | 60 / 467 |
| 4 | 当前工作树 | [当前目录](../../persistence-catalog.zh.md) | [JSON](../../persistence-schema.json) | 66 / 615 |
| 4 | 当前工作树 | [当前目录](../../persistence-catalog.zh.md) | [JSON](../../persistence-schema.json) | 65 / 612 |
<!-- persistence-format-index:end -->