@aipper/aiws-spec 0.0.27 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/cli-interface.md +10 -12
- package/docs/opencode-autonomous-swarm.md +178 -0
- package/docs/opencode-omo-adapter.md +123 -4
- package/docs/opencode-omo-validation-checklist.md +47 -0
- package/docs/opencode-subagent-first.md +187 -0
- package/docs/workflow-delegation-context-injection.md +217 -0
- package/docs/workflow-delegation-contracts.json +68 -1
- package/docs/workflow-delegation-contracts.md +3 -0
- package/docs/workflow-delegation-contracts.schema.json +95 -0
- package/docs/workflow-governance-rules.json +47 -6
- package/docs/workflow-governance-rules.md +7 -6
- package/docs/workflow-governance-rules.schema.json +39 -1
- package/docs/workflow-router-rules.json +63 -8
- package/docs/workflow-router-rules.md +15 -6
- package/docs/workflow-stage-contracts.json +16 -8
- package/docs/workflow-stage-contracts.md +7 -7
- package/package.json +1 -1
- package/templates/workspace/.agents/skills/using-aiws/SKILL.md +22 -8
- package/templates/workspace/.agents/skills/ws-commit/SKILL.md +6 -118
- package/templates/workspace/.agents/skills/ws-deliver/SKILL.md +6 -218
- package/templates/workspace/.agents/skills/ws-dev/SKILL.md +52 -141
- package/templates/workspace/.agents/skills/ws-finish/SKILL.md +6 -205
- package/templates/workspace/.agents/skills/ws-handoff/SKILL.md +10 -44
- package/templates/workspace/.agents/skills/ws-intake/SKILL.md +87 -0
- package/templates/workspace/.agents/skills/ws-plan/SKILL.md +15 -9
- package/templates/workspace/.agents/skills/ws-plan-verify/SKILL.md +6 -49
- package/templates/workspace/.agents/skills/ws-review/SKILL.md +6 -1
- package/templates/workspace/.agents/skills/ws-verify-before-complete/SKILL.md +12 -53
- package/templates/workspace/.claude/commands/ws-intake.md +19 -0
- package/templates/workspace/.claude/commands/ws-review.md +5 -1
- package/templates/workspace/.claude/settings.json.example +26 -0
- package/templates/workspace/.claude/skills/ws-commit/SKILL.md +6 -118
- package/templates/workspace/.claude/skills/ws-deliver/SKILL.md +6 -218
- package/templates/workspace/.claude/skills/ws-dev/SKILL.md +52 -141
- package/templates/workspace/.claude/skills/ws-finish/SKILL.md +6 -205
- package/templates/workspace/.claude/skills/ws-handoff/SKILL.md +10 -44
- package/templates/workspace/.claude/skills/ws-intake/SKILL.md +31 -0
- package/templates/workspace/.claude/skills/ws-plan-verify/SKILL.md +6 -49
- package/templates/workspace/.claude/skills/ws-review/SKILL.md +6 -1
- package/templates/workspace/.claude/skills/ws-verify-before-complete/SKILL.md +12 -53
- package/templates/workspace/.opencode/command/ws-auto.md +33 -0
- package/templates/workspace/.opencode/command/ws-autonomy.md +25 -0
- package/templates/workspace/.opencode/command/ws-intake.md +22 -0
- package/templates/workspace/.opencode/command/ws-review.md +5 -1
- package/templates/workspace/.opencode/commands/ws-auto.md +33 -0
- package/templates/workspace/.opencode/commands/ws-autonomy.md +25 -0
- package/templates/workspace/.opencode/commands/ws-commit.md +4 -56
- package/templates/workspace/.opencode/commands/ws-deliver.md +10 -50
- package/templates/workspace/.opencode/commands/ws-finish.md +8 -65
- package/templates/workspace/.opencode/commands/ws-handoff.md +9 -17
- package/templates/workspace/.opencode/commands/ws-intake.md +22 -0
- package/templates/workspace/.opencode/commands/ws-migrate.md +10 -17
- package/templates/workspace/.opencode/commands/ws-plan-verify.md +5 -15
- package/templates/workspace/.opencode/commands/ws-pull.md +6 -75
- package/templates/workspace/.opencode/commands/ws-push.md +7 -82
- package/templates/workspace/.opencode/commands/ws-review.md +5 -1
- package/templates/workspace/.opencode/commands/ws-submodule-setup.md +8 -47
- package/templates/workspace/.opencode/commands/ws-verify-before-complete.md +10 -19
- package/templates/workspace/.opencode/helpers/approval-whitelist-check.sh +148 -0
- package/templates/workspace/.opencode/helpers/approval-whitelist-run.sh +82 -0
- package/templates/workspace/.opencode/helpers/approval-whitelist-watchdog.sh +144 -0
- package/templates/workspace/.opencode/helpers/tmux-swarm-rescue.sh +56 -0
- package/templates/workspace/.opencode/helpers/tmux-swarm-scan.sh +46 -0
- package/templates/workspace/.opencode/oh-my-opencode.json.example +64 -4
- package/templates/workspace/.opencode/skills/using-aiws/SKILL.md +93 -77
- package/templates/workspace/.opencode/skills/ws-analyze/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-auto/SKILL.md +46 -0
- package/templates/workspace/.opencode/skills/ws-autonomy/SKILL.md +62 -0
- package/templates/workspace/.opencode/skills/ws-bugfix/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-commit/SKILL.md +6 -118
- package/templates/workspace/.opencode/skills/ws-delegate/SKILL.md +93 -40
- package/templates/workspace/.opencode/skills/ws-deliver/SKILL.md +6 -218
- package/templates/workspace/.opencode/skills/ws-dev/SKILL.md +53 -142
- package/templates/workspace/.opencode/skills/ws-dev-lite/SKILL.md +19 -6
- package/templates/workspace/.opencode/skills/ws-finish/SKILL.md +6 -205
- package/templates/workspace/.opencode/skills/ws-frontend-design/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-handoff/SKILL.md +10 -44
- package/templates/workspace/.opencode/skills/ws-intake/SKILL.md +40 -0
- package/templates/workspace/.opencode/skills/ws-migrate/SKILL.md +6 -42
- package/templates/workspace/.opencode/skills/ws-plan/SKILL.md +4 -2
- package/templates/workspace/.opencode/skills/ws-plan-verify/SKILL.md +6 -49
- package/templates/workspace/.opencode/skills/ws-preflight/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-pull/SKILL.md +8 -109
- package/templates/workspace/.opencode/skills/ws-push/SKILL.md +8 -100
- package/templates/workspace/.opencode/skills/ws-quality-review/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-req-change/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-req-contract-sync/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-req-contract-validate/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-req-flow-sync/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-req-review/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-review/SKILL.md +14 -3
- package/templates/workspace/.opencode/skills/ws-rule/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-spec-review/SKILL.md +1 -1
- package/templates/workspace/.opencode/skills/ws-submodule-setup/SKILL.md +10 -57
- package/templates/workspace/.opencode/skills/ws-verify-before-complete/SKILL.md +12 -53
- package/templates/workspace/AGENTS.md +12 -5
- package/templates/workspace/AI_PROJECT.md +1 -1
- package/templates/workspace/changes/README.md +9 -12
- package/templates/workspace/manifest.json +277 -203
- package/templates/workspace/.agents/skills/ws-migrate/SKILL.md +0 -54
- package/templates/workspace/.agents/skills/ws-pull/SKILL.md +0 -119
- package/templates/workspace/.agents/skills/ws-push/SKILL.md +0 -110
- package/templates/workspace/.agents/skills/ws-submodule-setup/SKILL.md +0 -65
- package/templates/workspace/.claude/skills/ws-migrate/SKILL.md +0 -54
- package/templates/workspace/.claude/skills/ws-pull/SKILL.md +0 -119
- package/templates/workspace/.claude/skills/ws-push/SKILL.md +0 -110
- package/templates/workspace/.claude/skills/ws-submodule-setup/SKILL.md +0 -65
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Workflow Delegation Context Injection
|
|
2
|
+
|
|
3
|
+
<!-- Managed by aiws. Do not hand edit. -->
|
|
4
|
+
|
|
5
|
+
**规范 ID**: `workflow-delegation-context-injection`
|
|
6
|
+
**版本**: 1
|
|
7
|
+
|
|
8
|
+
## 目的
|
|
9
|
+
|
|
10
|
+
定义 delegation 场景下,主 agent(integrator)如何为子 agent(delegated subagent)**策划并交付上下文**,让子 agent 在第一次尝试时就能获取到正确的约束与信息,减少因遗漏关键文件导致的重试与审查循环。
|
|
11
|
+
|
|
12
|
+
本规范的适用范围:
|
|
13
|
+
- 主 agent 派遣 worker / reviewer / explorer 等子 agent 前
|
|
14
|
+
- 需要明确告知子 agent 项目约束、委托合同、分配模块、计划文件与相关分析成果时
|
|
15
|
+
- 上下文超出子 agent prompt 容量时(通过 sections + priority 管理预算)
|
|
16
|
+
|
|
17
|
+
**非目标**:
|
|
18
|
+
- 替代子 agent 自身的代码搜索能力(grep / glob / 文件遍历)
|
|
19
|
+
- 保证子 agent 一定读取并理解所有注入的上下文(最终依赖 LLM 遵从度)
|
|
20
|
+
|
|
21
|
+
## 上下文文件格式
|
|
22
|
+
|
|
23
|
+
### 定义
|
|
24
|
+
|
|
25
|
+
上下文信息通过一个 **JSONL(JSON Lines)** 文件传递。每行一个 JSON 对象,代表一个需要子 agent 读取的引用文件。
|
|
26
|
+
|
|
27
|
+
文件命名约定:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
changes/<id>/analysis/<role>-context.jsonl
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
其中:
|
|
34
|
+
- `<id>`:当前 change 的 identifier
|
|
35
|
+
- `<role>`:子 agent 的角色(worker / explorer / reviewer / planner / integrator)
|
|
36
|
+
|
|
37
|
+
### 字段定义
|
|
38
|
+
|
|
39
|
+
| 字段 | 必需 | 类型 | 描述 |
|
|
40
|
+
|------|------|------|------|
|
|
41
|
+
| `file` | ✅ | `string` | 相对于仓库根的文件路径 |
|
|
42
|
+
| `reason` | ✅ | `string` | **为什么此文件相关**。子 agent 通过此字段理解该文件的阅读目的与上下文锚点。应包含具体条款引用或原因说明 |
|
|
43
|
+
| `sections` | ❌ | `[[int,int], ...]` | 针对大文件的精确行范围(1-indexed)。缺省或 `null` 表示读取整个文件 |
|
|
44
|
+
| `priority` | ✅ | `"high" \| "medium" \| "low"` | 上下文预算管理。子 agent 按优先级顺序读取;窗口不足时可跳过低优先级 |
|
|
45
|
+
| `kind` | ❌ | `string` | 认知分类标签。帮助子 agent 理解阅读目的(约束型 vs 实现型 vs 历史型)。可选值见下方 |
|
|
46
|
+
|
|
47
|
+
### 可选 kind 值
|
|
48
|
+
|
|
49
|
+
| kind | 含义 | 示例文件 |
|
|
50
|
+
|------|------|----------|
|
|
51
|
+
| `truth` | 项目真值、约束、规则 | `AI_PROJECT.md`, `REQUIREMENTS.md` |
|
|
52
|
+
| `contract` | 委托合同、角色边界 | `workflow-delegation-contracts.md` |
|
|
53
|
+
| `adapter` | 工具适配规则 | `opencode-omo-adapter.md` |
|
|
54
|
+
| `assigned` | 本次分配的模块代码 | `src/auth/login.ts` |
|
|
55
|
+
| `plan` | 变更计划 | `changes/<id>/plan/session-*.md` |
|
|
56
|
+
| `analysis` | 影响分析、方案分析 | `changes/<id>/analysis/impact.md` |
|
|
57
|
+
| `evidence` | 验证证据基线 | `changes/<id>/evidence/*.md` |
|
|
58
|
+
| `handoff` | 交接说明 | `changes/<id>/handoff.md` |
|
|
59
|
+
|
|
60
|
+
### 完整示例
|
|
61
|
+
|
|
62
|
+
```jsonl
|
|
63
|
+
{"file":"AI_PROJECT.md","reason":"第25-50行:安全与边界强制条款;第95-106行:产物与证据强制条款","sections":[[25,50],[95,106]],"priority":"high","kind":"truth"}
|
|
64
|
+
{"file":"packages/spec/docs/workflow-delegation-contracts.md","reason":"Worker 角色的 readScope/writeScope/artifactTargets 边界定义(第84-107行);通用规则(第236-243行)","sections":[[84,107],[236,243]],"priority":"high","kind":"contract"}
|
|
65
|
+
{"file":"packages/spec/docs/opencode-omo-adapter.md","reason":"委托给 oMo agent 时的回退规则与执行约定","sections":[[1,30],[245,254]],"priority":"medium","kind":"adapter"}
|
|
66
|
+
{"file":"src/auth/login.ts","reason":"分配的模块——身份验证核心逻辑:LoginService.login() 方法","sections":null,"priority":"high","kind":"assigned"}
|
|
67
|
+
{"file":"changes/demo-change/plan/session-20260515-auth-refactor.md","reason":"变更计划——目标/非目标/范围/步骤/验证命令","sections":null,"priority":"high","kind":"plan"}
|
|
68
|
+
{"file":"changes/demo-change/analysis/impact.md","reason":"影响分析——调用 login() 的所有函数清单及调用链","sections":null,"priority":"medium","kind":"analysis"}
|
|
69
|
+
{"file":"changes/demo-change/evidence/pre-refactor-test-run.md","reason":"重构前测试基线——当前测试通过状态与覆盖率","sections":null,"priority":"low","kind":"evidence"}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## OpenCode 插件集成
|
|
73
|
+
|
|
74
|
+
aiws 提供了两个 OpenCode 插件,自动实现上下文注入:
|
|
75
|
+
|
|
76
|
+
### aiws-session-start(chat.message hook)
|
|
77
|
+
|
|
78
|
+
每个新会话启动时,自动读取当前 change 上下文、项目真值、规范索引,并注入到第一条用户消息中。
|
|
79
|
+
|
|
80
|
+
**注入内容**:
|
|
81
|
+
- `<aiws-context>` 声明块
|
|
82
|
+
- `getContextSummary()` 输出(change ID、绑定状态等)
|
|
83
|
+
- `getSpecIndex()` 输出(可用的规范索引清单)
|
|
84
|
+
- 可用 spec discovery 提示
|
|
85
|
+
|
|
86
|
+
当插件被激活时,主 agent 启动会话即获得项目状态概览,无需手动阅读真值文件。
|
|
87
|
+
|
|
88
|
+
### aiws-inject-context(tool.execute.before hook)
|
|
89
|
+
|
|
90
|
+
当 `task()` 调用且 prompt 中包含 `role: <role>` 标记时自动拦截,读取 `changes/<id>/analysis/<role>-context.jsonl` 并注入到子 agent prompt。
|
|
91
|
+
|
|
92
|
+
**自动注入内容**:
|
|
93
|
+
1. JSONL 中引用的每个文件内容(按 priority 排序)
|
|
94
|
+
2. `<aiws-context-injection>` 头部(含 role、context file 路径、entry 数量)
|
|
95
|
+
3. 粘性指令:要求子 agent 先读上下文文件再工作
|
|
96
|
+
|
|
97
|
+
当插件被激活时,主 agent 不需要手动粘性指令模板——插件会自动生成。
|
|
98
|
+
|
|
99
|
+
### 配置方法
|
|
100
|
+
|
|
101
|
+
本地插件放在 `.opencode/plugins/` 后由 OpenCode 启动时自动加载;`.opencode/opencode.json` 仅保留合法 schema 声明,若需要显式注册 npm/远程插件则使用 OpenCode 1.15 的 `plugin`(单数)字段。
|
|
102
|
+
|
|
103
|
+
## 策展流程
|
|
104
|
+
|
|
105
|
+
上下文文件由委托者在派遣子 agent 前通过**三层混合模式**策展:
|
|
106
|
+
|
|
107
|
+
### 第 0 层:静态基线(合同定义)
|
|
108
|
+
|
|
109
|
+
`workflow-delegation-contracts.json` 中每个角色类型(`roleTypes[]`)可选的 `contextFiles` 属性定义了该角色**总是需要**的上下文基线。使用 glob 模式表达。
|
|
110
|
+
|
|
111
|
+
示例(worker 角色):
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
"contextFiles": [
|
|
115
|
+
{"glob": "AI_PROJECT.md", "sections": [[25, 50], [95, 106]], "priority": "high", "kind": "truth"},
|
|
116
|
+
{"glob": "REQUIREMENTS.md", "sections": [[1, 100]], "priority": "high", "kind": "truth"},
|
|
117
|
+
{"glob": "AI_WORKSPACE.md", "priority": "medium", "kind": "truth"},
|
|
118
|
+
{"glob": "packages/spec/docs/workflow-delegation-contracts.md", "sections": [[84, 107], [236, 243]], "priority": "high", "kind": "contract"},
|
|
119
|
+
{"glob": "changes/<id>/plan/*.md", "priority": "high", "kind": "plan"},
|
|
120
|
+
{"glob": "changes/<id>/analysis/*.md", "priority": "medium", "kind": "analysis"},
|
|
121
|
+
{"glob": "changes/<id>/evidence/*.md", "priority": "low", "kind": "evidence"}
|
|
122
|
+
]
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 第 1 层:自动展开(预派遣)
|
|
126
|
+
|
|
127
|
+
在派遣子 agent 前,主 agent 或预派遣脚本执行:
|
|
128
|
+
1. 读取角色的 `contextFiles` 条目
|
|
129
|
+
2. 将 `<id>` 替换为实际 change-id
|
|
130
|
+
3. 将 glob 模式展开为具体文件路径(使用 `glob` 工具)
|
|
131
|
+
4. 从 `writeScope` / `readScope` 推导"分配的模块",添加 `kind: "assigned"` 条目
|
|
132
|
+
5. 输出 JSONL 基线
|
|
133
|
+
|
|
134
|
+
### 第 2 层:委托者覆盖(手工调整)
|
|
135
|
+
|
|
136
|
+
主 agent(integrator)在写入前:
|
|
137
|
+
1. 添加任务特定的文件(如当前 plan 文件、新影响分析)
|
|
138
|
+
2. 删除不相关的条目(如旧的分析/证据文件)
|
|
139
|
+
3. 重新排序或调整 priority/sections
|
|
140
|
+
4. 执行预算检查(见下文)
|
|
141
|
+
5. 写入 `changes/<id>/analysis/<role>-context.jsonl`
|
|
142
|
+
|
|
143
|
+
### 策展决策记录
|
|
144
|
+
|
|
145
|
+
当策展过程产生非平凡决策时(如删除了 3 个文件、将某个文件从 high 降为 medium),应在 JSONL 文件头部以 JSON 注释形式记录:
|
|
146
|
+
|
|
147
|
+
```jsonl
|
|
148
|
+
// curation: trimmed from 8 to 5 files; excluded changes/demo/evidence/stale-test.md (unrelated)
|
|
149
|
+
// curation: downgraded changes/demo/analysis/impact.md from high to medium (too broad; only lines 50-70 relevant)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## 上下文预算管理
|
|
153
|
+
|
|
154
|
+
子 agent 的上下文窗口有限。策展者必须执行预算检查:
|
|
155
|
+
|
|
156
|
+
### 预算规则
|
|
157
|
+
|
|
158
|
+
1. **5 文件软上限**:统计 `priority=high` + `medium` 的文件数。若超过 5 个,删除所有 `low` 条目并输出警告
|
|
159
|
+
2. **4000 行硬上限**:估算每个文件的真实行数(通过 `git show HEAD:<path> \| wc -l` 或类似命令)。若总行数超过 4000:
|
|
160
|
+
- 优先用 `sections` 缩小范围
|
|
161
|
+
- 若仍超出,删除所有 `medium`,仅保留 `high`
|
|
162
|
+
- 若无法切分,考虑将任务拆分为更小的子任务
|
|
163
|
+
3. **零文件阻断**:若最终文件数 = 0,返回 `BLOCKED`,不派遣
|
|
164
|
+
|
|
165
|
+
### 优先级回退顺序
|
|
166
|
+
|
|
167
|
+
子 agent 应按照 `priority` 顺序读取文件:
|
|
168
|
+
1. 先读取所有 `high` 文件
|
|
169
|
+
2. 若上下文窗口允许,再读取 `medium`
|
|
170
|
+
3. 若窗口仍有空间,最后读取 `low`
|
|
171
|
+
|
|
172
|
+
当文件内容超出子 agent 上下文时,子 agent 可选择:
|
|
173
|
+
- 仅读取指定 sections(若有提供)
|
|
174
|
+
- 仅读取文件的开头部分(若未指定 sections)
|
|
175
|
+
- 跳过 `low` 优先级并记录"上下文预算超限,已跳过下列文件:..."
|
|
176
|
+
|
|
177
|
+
## 粘性指令模板
|
|
178
|
+
|
|
179
|
+
当主 agent 通过 `task()` 调用派遣子 agent 时,子 agent prompt 的**第一条指令**必须包含以下内容:
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
## ⚠️ 上下文文件(必需——开始任何工作前执行)
|
|
183
|
+
|
|
184
|
+
你必须首先读取 `{contextJsonlPath}`。此文件列出你必须在开始工作前了解的文件,包括项目约束、委托合同、变更计划与分配模块。
|
|
185
|
+
|
|
186
|
+
**执行步骤**:
|
|
187
|
+
1. 使用 Read 工具打开 JSONL 文件
|
|
188
|
+
2. 按 priority 顺序读取每个文件(high → medium → low)
|
|
189
|
+
3. 若文件有 `sections` 字段且行数超过 200,仅读取指定行范围
|
|
190
|
+
4. 若无法访问任何文件,返回 `NEEDS_CONTEXT`——立即停止,不要猜测内容
|
|
191
|
+
|
|
192
|
+
**确认(你的第一条回复)**:
|
|
193
|
+
列出你已读取的文件及每个文件的关键要点(≤3 要点/文件)。
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## 与委托合同的关系
|
|
197
|
+
|
|
198
|
+
| | 委托合同(delegation-contracts.json) | 上下文文件(<role>-context.jsonl) |
|
|
199
|
+
|---|---|---|
|
|
200
|
+
| **目的** | 定义角色的**总是需要什么**(团队共识、静态知识) | 定义**本次派遣需要什么**(任务特定、运行时) |
|
|
201
|
+
| **内容** | glob 模式 + 默认 sections/priority/kind | 展开的具体文件路径 + 委托者调整后的信息 |
|
|
202
|
+
| **生命周期** | 跨项目、跨会话不变 | 每次派遣重新生成 |
|
|
203
|
+
| **提交到 git?** | 是(在 `packages/spec/`) | 是(在 `changes/<id>/analysis/`) |
|
|
204
|
+
| **谁维护** | 项目维护者 | 委托者(主 agent) |
|
|
205
|
+
|
|
206
|
+
委托合同定义"规则",上下文文件是规则的运行时实例化。合同中的 `contextFiles` 是**可选**字段——未填充时,系统行为与现有完全一致。
|
|
207
|
+
|
|
208
|
+
## 安全注意事项
|
|
209
|
+
|
|
210
|
+
1. **JSONL 不应包含 secrets 引用**——委托者策展时不能将 `secrets/`、`.env*`、token 等路径写入 JSONL
|
|
211
|
+
2. **子 agent 无法访问 JSONL 时的处理**——返回 `NEEDS_CONTEXT`,后续见 Subagent Status Protocol 的 BLOCKED/NEEDS_CONTEXT 处理
|
|
212
|
+
3. **JSONL 文件本身是 change 工件**——提交在 `changes/<id>/analysis/` 中,使审计者可以追溯"子 agent 被赋予了怎样的上下文"
|
|
213
|
+
|
|
214
|
+
## 更新历史
|
|
215
|
+
|
|
216
|
+
- v1 (2026-05-15): 初版。基于 trellis 的 JSONL 上下文注入模式 + aiws delegation contract 三层策展模型设计。
|
|
217
|
+
- v1.1 (2026-05-15): 新增 OpenCode 插件集成描述(aiws-session-start / aiws-inject-context)并移除"不提供平台级 hooks"的约束。
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
"action": "根据任务性质选择 `planner / explorer / worker / reviewer / integrator` 角色,而不是把所有子任务都视为同一种 agent。",
|
|
23
23
|
"why": "不同角色的读写权限、输出契约与收敛方式不同。"
|
|
24
24
|
},
|
|
25
|
+
{
|
|
26
|
+
"step": "curate_context",
|
|
27
|
+
"action": "为子 agent 策划上下文文件(changes/<id>/analysis/<role>-context.jsonl),参阅 workflow-delegation-context-injection.md。",
|
|
28
|
+
"why": "子 agent 在第一次尝试时拿到正确的上下文,减少重试与审查循环。"
|
|
29
|
+
},
|
|
25
30
|
{
|
|
26
31
|
"step": "limit_scope",
|
|
27
32
|
"action": "为每个委托声明 `readScope` / `writeScope` / `artifactTargets`,超出范围必须回退给主 agent。",
|
|
@@ -60,6 +65,13 @@
|
|
|
60
65
|
"handoffRequirements": [
|
|
61
66
|
"写明目标、非目标、范围、验证方式",
|
|
62
67
|
"写明每个后续委托角色的 scope 边界"
|
|
68
|
+
],
|
|
69
|
+
"contextFiles": [
|
|
70
|
+
{"glob": "AI_PROJECT.md", "priority": "high", "kind": "truth"},
|
|
71
|
+
{"glob": "REQUIREMENTS.md", "priority": "high", "kind": "truth"},
|
|
72
|
+
{"glob": "AI_WORKSPACE.md", "priority": "medium", "kind": "truth"},
|
|
73
|
+
{"glob": "changes/<id>/analysis/*.md", "priority": "medium", "kind": "analysis"},
|
|
74
|
+
{"glob": "changes/<id>/evidence/verify-before-complete.md", "priority": "low", "kind": "evidence"}
|
|
63
75
|
]
|
|
64
76
|
},
|
|
65
77
|
{
|
|
@@ -79,6 +91,11 @@
|
|
|
79
91
|
"handoffRequirements": [
|
|
80
92
|
"结论必须附来源文件或路径",
|
|
81
93
|
"对不确定项要显式标注风险或缺口"
|
|
94
|
+
],
|
|
95
|
+
"contextFiles": [
|
|
96
|
+
{"glob": "AI_PROJECT.md", "sections": [[25, 50], [95, 106]], "priority": "high", "kind": "truth"},
|
|
97
|
+
{"glob": "changes/<id>/plan/*.md", "priority": "high", "kind": "plan"},
|
|
98
|
+
{"glob": "changes/<id>/analysis/*.md", "priority": "medium", "kind": "analysis"}
|
|
82
99
|
]
|
|
83
100
|
},
|
|
84
101
|
{
|
|
@@ -104,6 +121,16 @@
|
|
|
104
121
|
"handoffRequirements": [
|
|
105
122
|
"写清改动文件、验证命令、未完成项",
|
|
106
123
|
"不得越过显式授权的写入范围"
|
|
124
|
+
],
|
|
125
|
+
"contextFiles": [
|
|
126
|
+
{"glob": "AI_PROJECT.md", "sections": [[25, 50], [95, 106]], "priority": "high", "kind": "truth"},
|
|
127
|
+
{"glob": "REQUIREMENTS.md", "sections": [[1, 100]], "priority": "high", "kind": "truth"},
|
|
128
|
+
{"glob": "AI_WORKSPACE.md", "priority": "medium", "kind": "truth"},
|
|
129
|
+
{"glob": "packages/spec/docs/workflow-delegation-contracts.md", "sections": [[84, 107], [236, 243]], "priority": "high", "kind": "contract"},
|
|
130
|
+
{"glob": "packages/spec/docs/workflow-delegation-context-injection.md", "priority": "high", "kind": "contract"},
|
|
131
|
+
{"glob": "changes/<id>/plan/*.md", "priority": "high", "kind": "plan"},
|
|
132
|
+
{"glob": "changes/<id>/analysis/*.md", "priority": "medium", "kind": "analysis"},
|
|
133
|
+
{"glob": "changes/<id>/evidence/*.md", "priority": "low", "kind": "evidence"}
|
|
107
134
|
]
|
|
108
135
|
},
|
|
109
136
|
{
|
|
@@ -126,6 +153,14 @@
|
|
|
126
153
|
"handoffRequirements": [
|
|
127
154
|
"先列 findings,再给假设或残余风险",
|
|
128
155
|
"明确这是 spec review、quality review 还是交付前验证"
|
|
156
|
+
],
|
|
157
|
+
"contextFiles": [
|
|
158
|
+
{"glob": "AI_PROJECT.md", "sections": [[25, 50], [95, 106]], "priority": "high", "kind": "truth"},
|
|
159
|
+
{"glob": "REQUIREMENTS.md", "priority": "high", "kind": "truth"},
|
|
160
|
+
{"glob": "changes/<id>/plan/*.md", "priority": "high", "kind": "plan"},
|
|
161
|
+
{"glob": "changes/<id>/analysis/*.md", "priority": "medium", "kind": "analysis"},
|
|
162
|
+
{"glob": "changes/<id>/patches/*.patch", "priority": "high", "kind": "assigned"},
|
|
163
|
+
{"glob": "changes/<id>/evidence/*.md", "priority": "medium", "kind": "evidence"}
|
|
129
164
|
]
|
|
130
165
|
},
|
|
131
166
|
{
|
|
@@ -207,6 +242,36 @@
|
|
|
207
242
|
"changes/<id>/evidence/verify-before-complete.md"
|
|
208
243
|
]
|
|
209
244
|
},
|
|
245
|
+
"subagentStatusProtocol": {
|
|
246
|
+
"title": "Subagent Status Protocol",
|
|
247
|
+
"description": "四状态返回协议:定义 subagent 完成后返回的状态值及主 agent 的处理动作。",
|
|
248
|
+
"states": [
|
|
249
|
+
{ "status": "DONE", "meaning": "任务完成 + 验证通过 + 证据路径有效", "allowedNextRoles": ["reviewer", "integrator"] },
|
|
250
|
+
{ "status": "DONE_WITH_CONCERNS", "meaning": "实现完成但边角情况未全覆盖 / 质量有残余风险", "allowedNextRoles": ["reviewer"] },
|
|
251
|
+
{ "status": "NEEDS_CONTEXT", "meaning": "subagent 从给定 scope 无法继续,缺关键上下文", "allowedNextRoles": ["planner", "explorer"] },
|
|
252
|
+
{ "status": "BLOCKED", "meaning": "治理规则阻断(缺工件、dirty 工作区、validate 失败等)", "allowedNextRoles": ["integrator"] }
|
|
253
|
+
],
|
|
254
|
+
"handlerResponses": [
|
|
255
|
+
{ "forStatus": "DONE", "response": "进入 ws-review; 若已过 review 则准备 ws-finish" },
|
|
256
|
+
{ "forStatus": "DONE_WITH_CONCERNS", "response": "先执行 ws-quality-review,根据残余风险决定是否阻断 ws-finish" },
|
|
257
|
+
{ "forStatus": "NEEDS_CONTEXT", "response": "主 agent 补充缺失上下文后重新委托同一 subagent(最多 2 次);若仍 NEEDS_CONTEXT → 回退单 agent" },
|
|
258
|
+
{ "forStatus": "BLOCKED", "response": "停止委托流程;输出 blocker 详情;主 agent 解 blocker 后重试" }
|
|
259
|
+
]
|
|
260
|
+
},
|
|
261
|
+
"workflowPatterns": [
|
|
262
|
+
{
|
|
263
|
+
"id": "worker_reviewer_loop",
|
|
264
|
+
"description": "默认实现审查闭环:worker dispatch → status check → reviewer dispatch → pass/fail → loop back to worker if fail",
|
|
265
|
+
"steps": [
|
|
266
|
+
{ "step": "dispatch_worker", "action": "主 session 策展上下文后派发 aiws-worker", "input": "curated JSONL context + plan", "output": "worker status + patches/ + evidence/" },
|
|
267
|
+
{ "step": "check_worker_status", "action": "检查 worker 返回状态", "condition": "DONE → 进入 dispatch_reviewer; DONE_WITH_CONCERNS → 先 ws-quality-review; NEEDS_CONTEXT → 补充上下文重试; BLOCKED → 升级给人类" },
|
|
268
|
+
{ "step": "dispatch_reviewer", "action": "派发 aiws-reviewer 审查实现", "input": "patches/ + analysis/ + evidence/", "output": "reviewer findings + pass/fail" },
|
|
269
|
+
{ "step": "check_reviewer_result", "action": "审查结果判定", "condition": "pass → 主 session 收敛准备 ws-finish; fail → 返回 worker 修复(最多 3 次循环)" },
|
|
270
|
+
{ "step": "loop_back_worker", "action": "reviewer fail 后返回 worker 修复", "maxRetries": 3, "fallback": "升级给人类决策" },
|
|
271
|
+
{ "step": "converge", "action": "主 session 收敛最终 patch + evidence + review 到 changes/<id>/", "output": "changes/<id>/evidence/*.md + changes/<id>/review/*.md" }
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
],
|
|
210
275
|
"fallbackMode": {
|
|
211
276
|
"default": "single_agent_with_artifacts",
|
|
212
277
|
"triggers": [
|
|
@@ -262,6 +327,7 @@
|
|
|
262
327
|
"universalRules": [
|
|
263
328
|
"delegation 必须先绑定 `Req_ID` / change / Verify 入口,不能绕过真值文件。",
|
|
264
329
|
"主 agent 必须显式说明每个 sub-task 的角色、scope、产物目标与收敛方式。",
|
|
330
|
+
"主 agent 必须在派遣前执行上下文策展并写入 JSONL 上下文文件。",
|
|
265
331
|
"除显式授权的 worker/integrator 外,delegated agent 默认不直接写业务文件。",
|
|
266
332
|
"任何 native multi-agent 结果都必须能回收到 `analysis/patches/review/evidence` 约定路径。",
|
|
267
333
|
"native delegation 是可选执行策略,不是 workflow 的必需前提。"
|
|
@@ -269,6 +335,7 @@
|
|
|
269
335
|
"notes": [
|
|
270
336
|
"`aiws` 的价值在于治理内核和合同层,不在于成为统一 runtime。",
|
|
271
337
|
"这一版先把 contract 写清,再决定哪些入口需要在模板里显式投影。",
|
|
272
|
-
"后续若工具原生能力变化,只需要更新 capability matrix 与适配策略,不需要重写 workflow 真值。"
|
|
338
|
+
"后续若工具原生能力变化,只需要更新 capability matrix 与适配策略,不需要重写 workflow 真值。",
|
|
339
|
+
"v1.1: 新增 curate_context 流程步骤 + roleTypes[].contextFiles 基线 + 上下文策展 universal 规则。"
|
|
273
340
|
]
|
|
274
341
|
}
|
|
@@ -22,6 +22,7 @@ delegation contract 在做任何角色拆分或原生多 agent 调用前,必
|
|
|
22
22
|
| --- | --- | --- |
|
|
23
23
|
| `bind_task` | 先把任务绑定到 `Req_ID` / change / Verify 入口,再决定是否允许委托。 | 没有绑定的委托只会扩大漂移;delegation 不能绕过真值入口。 |
|
|
24
24
|
| `select_role` | 根据任务性质选择 `planner / explorer / worker / reviewer / integrator` 角色,而不是把所有子任务都视为同一种 agent。 | 不同角色的读写权限、输出契约与收敛方式不同。 |
|
|
25
|
+
| `curate_context` | 为子 agent 策划上下文文件(changes/<id>/analysis/<role>-context.jsonl),参阅 workflow-delegation-context-injection.md。 | 子 agent 在第一次尝试时拿到正确的上下文,减少重试与审查循环。 |
|
|
25
26
|
| `limit_scope` | 为每个委托声明 `readScope` / `writeScope` / `artifactTargets`,超出范围必须回退给主 agent。 | native 多 agent 的最大风险是越界写盘;scope 必须先于执行。 |
|
|
26
27
|
| `converge_outputs` | 把委托结果统一收敛到 `analysis/`、`patches/`、`review/`、`evidence/` 或明确允许的代码写入范围。 | 即使执行方式不同,交付证据与审计路径必须一致。 |
|
|
27
28
|
| `fallback_or_integrate` | 原生能力不可用、权限不满足或结果不可靠时,回退到单 agent / 手工委托;由主 agent 负责最终整合。 | `aiws` 的职责是治理和降级,不是保证每个工具都支持同一套运行时。 |
|
|
@@ -237,6 +238,7 @@ delegation contract 在做任何角色拆分或原生多 agent 调用前,必
|
|
|
237
238
|
|
|
238
239
|
- delegation 必须先绑定 `Req_ID` / change / Verify 入口,不能绕过真值文件。
|
|
239
240
|
- 主 agent 必须显式说明每个 sub-task 的角色、scope、产物目标与收敛方式。
|
|
241
|
+
- 主 agent 必须在派遣前执行上下文策展并写入 JSONL 上下文文件。
|
|
240
242
|
- 除显式授权的 worker/integrator 外,delegated agent 默认不直接写业务文件。
|
|
241
243
|
- 任何 native multi-agent 结果都必须能回收到 `analysis/patches/review/evidence` 约定路径。
|
|
242
244
|
- native delegation 是可选执行策略,不是 workflow 的必需前提。
|
|
@@ -246,3 +248,4 @@ delegation contract 在做任何角色拆分或原生多 agent 调用前,必
|
|
|
246
248
|
- `aiws` 的价值在于治理内核和合同层,不在于成为统一 runtime。
|
|
247
249
|
- 这一版先把 contract 写清,再决定哪些入口需要在模板里显式投影。
|
|
248
250
|
- 后续若工具原生能力变化,只需要更新 capability matrix 与适配策略,不需要重写 workflow 真值。
|
|
251
|
+
- v1.1: 新增 curate_context 流程步骤 + roleTypes[].contextFiles 基线 + 上下文策展 universal 规则。
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"roleTypes",
|
|
11
11
|
"artifactTargets",
|
|
12
12
|
"reviewConvergence",
|
|
13
|
+
"subagentStatusProtocol",
|
|
13
14
|
"fallbackMode",
|
|
14
15
|
"toolCapabilityMatrix",
|
|
15
16
|
"universalRules",
|
|
@@ -71,6 +72,30 @@
|
|
|
71
72
|
"type": "array",
|
|
72
73
|
"minItems": 1,
|
|
73
74
|
"items": { "type": "string", "minLength": 1 }
|
|
75
|
+
},
|
|
76
|
+
"contextFiles": {
|
|
77
|
+
"type": "array",
|
|
78
|
+
"minItems": 1,
|
|
79
|
+
"items": {
|
|
80
|
+
"type": "object",
|
|
81
|
+
"required": ["glob", "priority", "kind"],
|
|
82
|
+
"properties": {
|
|
83
|
+
"glob": { "type": "string", "minLength": 1 },
|
|
84
|
+
"sections": {
|
|
85
|
+
"type": "array",
|
|
86
|
+
"minItems": 1,
|
|
87
|
+
"items": {
|
|
88
|
+
"type": "array",
|
|
89
|
+
"minItems": 2,
|
|
90
|
+
"maxItems": 2,
|
|
91
|
+
"items": { "type": "integer", "minimum": 1 }
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"priority": { "type": "string", "enum": ["high", "medium", "low"] },
|
|
95
|
+
"kind": { "type": "string", "minLength": 1 }
|
|
96
|
+
},
|
|
97
|
+
"additionalProperties": false
|
|
98
|
+
}
|
|
74
99
|
}
|
|
75
100
|
},
|
|
76
101
|
"additionalProperties": false
|
|
@@ -121,6 +146,46 @@
|
|
|
121
146
|
},
|
|
122
147
|
"additionalProperties": false
|
|
123
148
|
},
|
|
149
|
+
"subagentStatusProtocol": {
|
|
150
|
+
"type": "object",
|
|
151
|
+
"required": ["title", "description", "states", "handlerResponses"],
|
|
152
|
+
"properties": {
|
|
153
|
+
"title": { "type": "string", "minLength": 1 },
|
|
154
|
+
"description": { "type": "string", "minLength": 1 },
|
|
155
|
+
"states": {
|
|
156
|
+
"type": "array",
|
|
157
|
+
"minItems": 4,
|
|
158
|
+
"items": {
|
|
159
|
+
"type": "object",
|
|
160
|
+
"required": ["status", "meaning", "allowedNextRoles"],
|
|
161
|
+
"properties": {
|
|
162
|
+
"status": { "type": "string", "pattern": "^(DONE|DONE_WITH_CONCERNS|NEEDS_CONTEXT|BLOCKED)$" },
|
|
163
|
+
"meaning": { "type": "string", "minLength": 1 },
|
|
164
|
+
"allowedNextRoles": {
|
|
165
|
+
"type": "array",
|
|
166
|
+
"minItems": 1,
|
|
167
|
+
"items": { "type": "string", "minLength": 1 }
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"additionalProperties": false
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
"handlerResponses": {
|
|
174
|
+
"type": "array",
|
|
175
|
+
"minItems": 4,
|
|
176
|
+
"items": {
|
|
177
|
+
"type": "object",
|
|
178
|
+
"required": ["forStatus", "response"],
|
|
179
|
+
"properties": {
|
|
180
|
+
"forStatus": { "type": "string", "pattern": "^(DONE|DONE_WITH_CONCERNS|NEEDS_CONTEXT|BLOCKED)$" },
|
|
181
|
+
"response": { "type": "string", "minLength": 1 }
|
|
182
|
+
},
|
|
183
|
+
"additionalProperties": false
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
"additionalProperties": false
|
|
188
|
+
},
|
|
124
189
|
"fallbackMode": {
|
|
125
190
|
"type": "object",
|
|
126
191
|
"required": ["default", "triggers", "requiredBehavior"],
|
|
@@ -161,6 +226,36 @@
|
|
|
161
226
|
"additionalProperties": false
|
|
162
227
|
}
|
|
163
228
|
},
|
|
229
|
+
"workflowPatterns": {
|
|
230
|
+
"type": "array",
|
|
231
|
+
"items": {
|
|
232
|
+
"type": "object",
|
|
233
|
+
"required": ["id", "description", "steps"],
|
|
234
|
+
"properties": {
|
|
235
|
+
"id": { "type": "string", "pattern": "^[a-z0-9_]+$", "minLength": 1 },
|
|
236
|
+
"description": { "type": "string", "minLength": 1 },
|
|
237
|
+
"steps": {
|
|
238
|
+
"type": "array",
|
|
239
|
+
"minItems": 1,
|
|
240
|
+
"items": {
|
|
241
|
+
"type": "object",
|
|
242
|
+
"required": ["step", "action"],
|
|
243
|
+
"properties": {
|
|
244
|
+
"step": { "type": "string", "pattern": "^[a-z0-9_]+$", "minLength": 1 },
|
|
245
|
+
"action": { "type": "string", "minLength": 1 },
|
|
246
|
+
"condition": { "type": "string" },
|
|
247
|
+
"input": { "type": "string" },
|
|
248
|
+
"output": { "type": "string" },
|
|
249
|
+
"maxRetries": { "type": "integer", "minimum": 1 },
|
|
250
|
+
"fallback": { "type": "string" }
|
|
251
|
+
},
|
|
252
|
+
"additionalProperties": false
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
"additionalProperties": false
|
|
257
|
+
}
|
|
258
|
+
},
|
|
164
259
|
"universalRules": {
|
|
165
260
|
"type": "array",
|
|
166
261
|
"minItems": 1,
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version":
|
|
2
|
+
"version": 2,
|
|
3
3
|
"description": "Machine-readable governance inference rules for aiws change status/next/dashboard.",
|
|
4
|
+
"workflowStateSuffix": {
|
|
5
|
+
"description": "每轮注入的 workflow state 面包屑后缀约定。格式: [workflow-state:session:{state}]",
|
|
6
|
+
"values": ["intake", "planning", "dev", "review", "deliver", "completed"],
|
|
7
|
+
"stateSuffixMap": {
|
|
8
|
+
"intake": "[workflow-state:session:intake]",
|
|
9
|
+
"planning": "[workflow-state:session:planning]",
|
|
10
|
+
"dev": "[workflow-state:session:dev]",
|
|
11
|
+
"review": "[workflow-state:session:review]",
|
|
12
|
+
"deliver": "[workflow-state:session:deliver]",
|
|
13
|
+
"completed": "[workflow-state:session:completed]"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"stateEnum": {
|
|
17
|
+
"values": ["intake", "planning", "dev", "review", "deliver", "completed"],
|
|
18
|
+
"stageMapping": {
|
|
19
|
+
"intake": ["ws-intake"],
|
|
20
|
+
"planning": ["ws-plan", "ws-plan-verify"],
|
|
21
|
+
"dev": ["ws-dev", "ws-dev-lite"],
|
|
22
|
+
"review": ["ws-review", "ws-spec-review", "ws-quality-review", "ws-commit"],
|
|
23
|
+
"deliver": ["ws-deliver", "ws-finish", "ws-verify-before-complete"],
|
|
24
|
+
"completed": ["ws-handoff"]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
4
27
|
"governanceRules": [
|
|
5
28
|
{
|
|
6
29
|
"id": "finish_resume_required",
|
|
@@ -70,14 +93,14 @@
|
|
|
70
93
|
"when": { "signal": "git_conflicted", "gt": 0 },
|
|
71
94
|
"currentStage": "ws-commit",
|
|
72
95
|
"recommendedStage": "ws-commit",
|
|
73
|
-
"rationale": "review exists but the change
|
|
96
|
+
"rationale": "review exists but the change branch still has merge conflicts"
|
|
74
97
|
},
|
|
75
98
|
{
|
|
76
99
|
"id": "review_dirty",
|
|
77
100
|
"when": { "signal": "git_total", "gt": 0 },
|
|
78
101
|
"currentStage": "ws-commit",
|
|
79
102
|
"recommendedStage": "ws-commit",
|
|
80
|
-
"rationale": "review exists but the change
|
|
103
|
+
"rationale": "review exists but the change branch is still dirty"
|
|
81
104
|
},
|
|
82
105
|
{
|
|
83
106
|
"id": "deliver_finish_gate_pending_submodules",
|
|
@@ -181,11 +204,29 @@
|
|
|
181
204
|
},
|
|
182
205
|
{
|
|
183
206
|
"id": "guidance_review",
|
|
184
|
-
"when": {
|
|
207
|
+
"when": {
|
|
208
|
+
"all": [
|
|
209
|
+
{ "signal": "governance_current_stage", "eq": "ws-review" },
|
|
210
|
+
{ "signal": "review_effective_count", "eq": 0 }
|
|
211
|
+
]
|
|
212
|
+
},
|
|
185
213
|
"lines": [
|
|
186
214
|
"进入审计:在 AI 工具中运行 `$ws-review`(形成 review 结论后再进入提交/交付)"
|
|
187
215
|
]
|
|
188
216
|
},
|
|
217
|
+
{
|
|
218
|
+
"id": "guidance_review_dual_gate",
|
|
219
|
+
"when": {
|
|
220
|
+
"all": [
|
|
221
|
+
{ "signal": "governance_current_stage", "eq": "ws-review" },
|
|
222
|
+
{ "signal": "review_effective_count", "gt": 0 },
|
|
223
|
+
{ "signal": "dual_review_missing_count", "gt": 0 }
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
"lines": [
|
|
227
|
+
"已有通用 review,但 dual review gate 仍未完成:继续补齐 `$ws-spec-review` / `$ws-quality-review`,不要把 `codex-review.md` 误当成 finish gate"
|
|
228
|
+
]
|
|
229
|
+
},
|
|
189
230
|
{
|
|
190
231
|
"id": "guidance_review_spec_missing",
|
|
191
232
|
"when": { "signal": "spec_review_ready", "falsy": true },
|
|
@@ -266,7 +307,7 @@
|
|
|
266
307
|
"id": "guidance_finish_cleanup_pending",
|
|
267
308
|
"when": { "signal": "governance_rule_id", "eq": "finish_cleanup_pending" },
|
|
268
309
|
"lines": [
|
|
269
|
-
"push 已完成,但 cleanup 仍未完成({finish_state_reason});清理对应
|
|
310
|
+
"push 已完成,但 cleanup 仍未完成({finish_state_reason});清理对应 change 分支后重跑 `$ws-finish`"
|
|
270
311
|
]
|
|
271
312
|
},
|
|
272
313
|
{
|
|
@@ -280,7 +321,7 @@
|
|
|
280
321
|
"id": "guidance_finish_resume_required",
|
|
281
322
|
"when": { "signal": "governance_rule_id", "eq": "finish_resume_required" },
|
|
282
323
|
"lines": [
|
|
283
|
-
"finish closeout 未完成:直接重跑 `aiws change finish {change_id} --push
|
|
324
|
+
"finish closeout 未完成:直接重跑 `aiws change finish {change_id} --push`(不要先在目标分支上运行 `aiws validate . --stamp`)"
|
|
284
325
|
]
|
|
285
326
|
},
|
|
286
327
|
{
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
- version: `1`
|
|
13
13
|
- description: Machine-readable governance inference rules for aiws change status/next/dashboard.
|
|
14
14
|
- governance rules: 17
|
|
15
|
-
- guidance rules:
|
|
15
|
+
- guidance rules: 18
|
|
16
16
|
|
|
17
17
|
## 阶段推断规则
|
|
18
18
|
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
| `finish_local` | `finish_state` == `local` | `ws-finish` | `ws-finish` | finish started locally but is not fully completed yet |
|
|
28
28
|
| `review_missing` | `review_effective_count` == `0` | `ws-review` | `ws-review` | deliver-ready state has no review artifact yet |
|
|
29
29
|
| `dual_review_incomplete` | `dual_review_missing_count` > 0 | `ws-review` | `ws-review` | dual review gate incomplete (spec={spec_review_status}, quality={quality_review_status}) |
|
|
30
|
-
| `review_conflicted` | `git_conflicted` > 0 | `ws-commit` | `ws-commit` | review exists but the change
|
|
31
|
-
| `review_dirty` | `git_total` > 0 | `ws-commit` | `ws-commit` | review exists but the change
|
|
30
|
+
| `review_conflicted` | `git_conflicted` > 0 | `ws-commit` | `ws-commit` | review exists but the change branch still has merge conflicts |
|
|
31
|
+
| `review_dirty` | `git_total` > 0 | `ws-commit` | `ws-commit` | review exists but the change branch is still dirty |
|
|
32
32
|
| `deliver_finish_gate_pending_submodules` | (`repo_submodules` > 0) AND ((`evidence_persistent_count` > 0) OR (`lifecycle_evidence_runs` > 0)) AND (`finish_gate_missing_count` > 0) | `ws-deliver` | `ws-deliver` | delivery evidence exists but finish gate is incomplete (missing={finish_gate_missing_count}) |
|
|
33
33
|
| `deliver_finish_gate_pending` | ((`evidence_persistent_count` > 0) OR (`lifecycle_evidence_runs` > 0)) AND (`finish_gate_missing_count` > 0) | `ws-deliver` | `ws-deliver` | delivery evidence exists but finish gate is incomplete (missing={finish_gate_missing_count}) |
|
|
34
34
|
| `deliver_evidence_converged_submodules` | (`repo_submodules` > 0) AND ((`evidence_persistent_count` > 0) OR (`lifecycle_evidence_runs` > 0)) AND (`finish_gate_missing_count` == `0`) | `ws-deliver` | `ws-finish` | delivery evidence and finish gate are converged; next step is submodule-aware finish |
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
| --- | --- | --- |
|
|
43
43
|
| `guidance_plan_verify` | `governance_current_stage` == `ws-plan-verify` | 先修复 strict blockers,再复跑 `aiws change validate <id> --strict` |
|
|
44
44
|
| `guidance_dev` | `governance_current_stage` == `ws-dev` | 继续开发:在 AI 工具中运行 `$ws-dev`(小步实现 + 可复现验证) |
|
|
45
|
-
| `guidance_review` | `governance_current_stage` == `ws-review` | 进入审计:在 AI 工具中运行 `$ws-review`(形成 review 结论后再进入提交/交付) |
|
|
45
|
+
| `guidance_review` | (`governance_current_stage` == `ws-review`) AND (`review_effective_count` == `0`) | 进入审计:在 AI 工具中运行 `$ws-review`(形成 review 结论后再进入提交/交付) |
|
|
46
|
+
| `guidance_review_dual_gate` | (`governance_current_stage` == `ws-review`) AND (`review_effective_count` > 0) AND (`dual_review_missing_count` > 0) | 已有通用 review,但 dual review gate 仍未完成:继续补齐 `$ws-spec-review` / `$ws-quality-review`,不要把 `codex-review.md` 误当成 finish gate |
|
|
46
47
|
| `guidance_review_spec_missing` | `spec_review_ready` is falsy | 补齐流程审查:运行 `$ws-spec-review`,并落盘 `changes/<change-id>/review/spec-review.md` |
|
|
47
48
|
| `guidance_review_quality_missing` | `quality_review_ready` is falsy | 补齐质量审查:运行 `$ws-quality-review`,并落盘 `changes/<change-id>/review/quality-review.md` |
|
|
48
49
|
| `guidance_commit` | `governance_current_stage` == `ws-commit` | 进入提交门:在 AI 工具中运行 `$ws-commit`(review + validate stamp + commit message 确认) |
|
|
@@ -51,9 +52,9 @@
|
|
|
51
52
|
| `guidance_deliver_validate_missing` | (`governance_current_stage` == `ws-deliver`) AND (`validate_stamp_ready` is falsy) | 补齐 validate stamp:运行 `aiws validate . --stamp` |
|
|
52
53
|
| `guidance_deliver_verify_before_complete_missing` | (`governance_current_stage` == `ws-deliver`) AND (`verify_before_complete_ready` is falsy) | 补齐完成前 gate:运行 `$ws-verify-before-complete`,并落盘 `changes/<change-id>/evidence/verify-before-complete.md` |
|
|
53
54
|
| `guidance_deliver_finish` | (`governance_current_stage` == `ws-deliver`) AND (`governance_recommended_stage` == `ws-finish`) | 交付工件齐全后,进入 `$ws-finish`(安全合并 + push + cleanup) |
|
|
54
|
-
| `guidance_finish_cleanup_pending` | `governance_rule_id` == `finish_cleanup_pending` | push 已完成,但 cleanup 仍未完成({finish_state_reason});清理对应
|
|
55
|
+
| `guidance_finish_cleanup_pending` | `governance_rule_id` == `finish_cleanup_pending` | push 已完成,但 cleanup 仍未完成({finish_state_reason});清理对应 change 分支后重跑 `$ws-finish` |
|
|
55
56
|
| `guidance_finish_handoff` | `governance_rule_id` == `finish_completed` | 收尾已完成且 change 应已归档:下一步运行 `$ws-handoff` 检查/补充归档 handoff |
|
|
56
|
-
| `guidance_finish_resume_required` | `governance_rule_id` == `finish_resume_required` | finish closeout 未完成:直接重跑 `aiws change finish {change_id} --push
|
|
57
|
+
| `guidance_finish_resume_required` | `governance_rule_id` == `finish_resume_required` | finish closeout 未完成:直接重跑 `aiws change finish {change_id} --push`(不要先在目标分支上运行 `aiws validate . --stamp`) |
|
|
57
58
|
| `guidance_finish_retry` | `governance_rule_id` in [`finish_failed`, `finish_local`, `finish_resume_required`] | 收尾未完整完成:检查 push / cleanup / submodule 状态后重跑 `$ws-finish` |
|
|
58
59
|
| `guidance_handoff` | `governance_current_stage` == `ws-handoff` | 进入交接:在 AI 工具中运行 `$ws-handoff`,并检查归档 handoff 是否足够支撑下一次接力 |
|
|
59
60
|
| `guidance_default` | `governance_current_stage` == `` | 按阶段契约继续推进当前 change |
|