intentdna 1.7.4 → 1.8.0
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/LICENSE +201 -0
- package/README.md +143 -194
- package/dist/assets/candidates.d.ts +124 -0
- package/dist/assets/candidates.js +1249 -0
- package/dist/assets/catalog.d.ts +101 -0
- package/dist/assets/catalog.js +311 -0
- package/dist/assets/evidence.d.ts +93 -0
- package/dist/assets/evidence.js +391 -0
- package/dist/assets/index.d.ts +4 -0
- package/dist/assets/index.js +4 -0
- package/dist/assets/metadata.d.ts +19 -0
- package/dist/assets/metadata.js +227 -0
- package/dist/cli/commands/assets.d.ts +65 -0
- package/dist/cli/commands/assets.js +2871 -0
- package/dist/cli/commands/auth.d.ts +322 -0
- package/dist/cli/commands/auth.js +1592 -0
- package/dist/cli/commands/cloud-auth-guidance.d.ts +2 -0
- package/dist/cli/commands/cloud-auth-guidance.js +4 -0
- package/dist/cli/commands/cloud.d.ts +1359 -0
- package/dist/cli/commands/cloud.js +8364 -0
- package/dist/cli/commands/evolve.js +18 -2
- package/dist/cli/commands/generate.js +25 -2
- package/dist/cli/commands/guard.d.ts +1 -1
- package/dist/cli/commands/guard.js +1 -1
- package/dist/cli/commands/guide.d.ts +15 -0
- package/dist/cli/commands/guide.js +1747 -0
- package/dist/cli/commands/init.d.ts +12 -0
- package/dist/cli/commands/init.js +95 -60
- package/dist/cli/commands/org.d.ts +16 -0
- package/dist/cli/commands/org.js +2393 -0
- package/dist/cli/commands/release.d.ts +59 -0
- package/dist/cli/commands/release.js +716 -0
- package/dist/cli/commands/report.d.ts +82 -0
- package/dist/cli/commands/report.js +1516 -0
- package/dist/cli/commands/run.d.ts +6 -1
- package/dist/cli/commands/run.js +95 -26
- package/dist/cli/commands/sync.d.ts +8 -1
- package/dist/cli/commands/sync.js +436 -141
- package/dist/cli/commands/templates.d.ts +64 -0
- package/dist/cli/commands/templates.js +2151 -1
- package/dist/cli/commands/workflow.d.ts +26 -0
- package/dist/cli/commands/workflow.js +3053 -0
- package/dist/cli/index.js +719 -42
- package/dist/compiler/cascade.js +4 -9
- package/dist/compiler/compile.js +1 -0
- package/dist/governance/evidence-capture-attribution.d.ts +12 -0
- package/dist/governance/evidence-capture-attribution.js +46 -0
- package/dist/governance/index.d.ts +2 -0
- package/dist/governance/index.js +1 -0
- package/dist/hooks/cli.d.ts +6 -0
- package/dist/hooks/cli.js +168 -12
- package/dist/hooks/enforce.d.ts +1 -0
- package/dist/hooks/protocol.d.ts +1 -1
- package/dist/hooks/protocol.js +1 -1
- package/dist/hooks/state.d.ts +41 -0
- package/dist/hooks/state.js +126 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/mcp/tools-state.js +2 -0
- package/dist/organization/index.d.ts +121 -0
- package/dist/organization/index.js +413 -0
- package/dist/runtime/claude-sync-target.d.ts +49 -0
- package/dist/runtime/claude-sync-target.js +280 -0
- package/dist/runtime/codex-adapter.d.ts +254 -0
- package/dist/runtime/codex-adapter.js +1204 -0
- package/dist/runtime/codex-sync-target.d.ts +33 -0
- package/dist/runtime/codex-sync-target.js +241 -0
- package/dist/runtime/index.d.ts +8 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/output-artifact-registry.d.ts +1 -1
- package/dist/runtime/output-artifact-registry.js +2 -0
- package/dist/runtime/settings-adapter.d.ts +1 -1
- package/dist/runtime/settings-adapter.js +1 -1
- package/dist/runtime/skill-adapter.d.ts +5 -1
- package/dist/runtime/skill-adapter.js +120 -34
- package/dist/runtime/sync-artifact-registry.d.ts +99 -0
- package/dist/runtime/sync-artifact-registry.js +194 -0
- package/dist/runtime/sync-target-plan.d.ts +45 -0
- package/dist/runtime/sync-target-plan.js +19 -0
- package/dist/schema/controller-registry.d.ts +8 -1
- package/dist/schema/controller-registry.js +8 -0
- package/dist/schema/types.d.ts +35 -23
- package/dist/schema/types.js +10 -1
- package/dist/schema/validate.js +22 -22
- package/dist/schema/validators/controllers.js +38 -20
- package/dist/schema/workflow-authoring-contract.d.ts +29 -0
- package/dist/schema/workflow-authoring-contract.js +109 -0
- package/dist/schema/yaml-parser.js +18 -0
- package/dist/templates/api-backend.dna.yaml +19 -0
- package/dist/templates/brainstorming-first.dna.yaml +19 -0
- package/dist/templates/code-cleanup.dna.yaml +19 -0
- package/dist/templates/code-review-pipeline.dna.yaml +18 -0
- package/dist/templates/documentation-writer.dna.yaml +19 -0
- package/dist/templates/flutter-behavior-lock.dna.yaml +19 -0
- package/dist/templates/flutter-refactoring-rescue.dna.yaml +19 -0
- package/dist/templates/flutter-rewrite-diagnosis-review.dna.yaml +210 -0
- package/dist/templates/flutter-rewrite-fix-review-loop.dna.yaml +260 -0
- package/dist/templates/flutter-rewrite-new.dna.yaml +506 -0
- package/dist/templates/flutter-rewrite.dna.yaml +20 -0
- package/dist/templates/frontend-quality.dna.yaml +19 -0
- package/dist/templates/full-pipeline.dna.yaml +20 -0
- package/dist/templates/marketplace.d.ts +92 -0
- package/dist/templates/marketplace.js +502 -0
- package/dist/templates/metadata.d.ts +25 -0
- package/dist/templates/metadata.js +136 -3
- package/dist/templates/mobile-dev.dna.yaml +19 -0
- package/dist/templates/multi-agent-handoff-coordination.dna.yaml +156 -0
- package/dist/templates/multi-perspective-review.dna.yaml +19 -0
- package/dist/templates/persistent-executor.dna.yaml +19 -0
- package/dist/templates/qa-loop.dna.yaml +18 -0
- package/dist/templates/release-evidence-gate.dna.yaml +131 -0
- package/dist/templates/requirements-gate.dna.yaml +19 -0
- package/dist/templates/research-orchestration.dna.yaml +19 -0
- package/dist/templates/root-cause-analysis.dna.yaml +19 -0
- package/dist/templates/safe-refactoring.dna.yaml +321 -0
- package/dist/templates/secure-dev.dna.yaml +19 -0
- package/dist/templates/subagent-parallel.dna.yaml +19 -0
- package/dist/templates/systematic-debugging.dna.yaml +19 -0
- package/dist/templates/tdd-strict.dna.yaml +19 -0
- package/dist/templates/ui-visual-regression-qa.dna.yaml +133 -0
- package/dist/templates/workflow-author.dna.yaml +302 -0
- package/dist/templates/workflow-blocked-scope-triage.dna.yaml +242 -0
- package/dist/templates/workflow-completion-audit.dna.yaml +254 -0
- package/dist/templates/workflow-cross-boundary-resource-approval.dna.yaml +249 -0
- package/dist/templates/workflow-evidence-review.dna.yaml +198 -0
- package/dist/templates/workflow-module-inventory.dna.yaml +257 -0
- package/dist/templates/workflow-runtime-smoke-review.dna.yaml +252 -0
- package/dist/templates/workflow-verification-command-routing.dna.yaml +278 -0
- package/dist/workflow/authoring-packet.d.ts +67 -0
- package/dist/workflow/authoring-packet.js +218 -0
- package/dist/workflow/draft.d.ts +159 -0
- package/dist/workflow/draft.js +800 -0
- package/dist/workflow/index.d.ts +3 -0
- package/dist/workflow/index.js +3 -0
- package/dist/workflow/suggestion-review.d.ts +65 -0
- package/dist/workflow/suggestion-review.js +245 -0
- package/package.json +1 -1
- package/spec/README.md +15 -48
- package/spec/codex-adapter-contract.md +176 -0
- package/spec/sync-target-plan.md +158 -0
- package/spec/workflow-capability-ir.md +153 -0
- package/spec/agent-dispatch-fix.md +0 -116
- package/spec/control-plane-convergence-handoff-2026-04-24.md +0 -432
- package/spec/flutter-rewrite-template-optimization.md +0 -301
- package/spec/foundation-hardening.md +0 -178
- package/spec/hooks-infra-harness-hardening.md +0 -741
- package/spec/multi-config.md +0 -172
- package/spec/parallel-isolation.md +0 -268
- package/spec/template-version-namespace-fix.md +0 -653
- package/spec/workflow-pipeline.md +0 -101
package/spec/multi-config.md
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
# Spec: Multi-Config 模板管理
|
|
2
|
-
|
|
3
|
-
## Metadata
|
|
4
|
-
- Date: 2026-04-15
|
|
5
|
-
- Phase: 6 (持续改进 C2/C3)
|
|
6
|
-
- Status: 设计完成,待实现
|
|
7
|
-
|
|
8
|
-
## Goal
|
|
9
|
-
|
|
10
|
-
支持一个项目同时使用多个 DNA 模板,每个模板有独立的 namespace、roles、workflows。统一编译到一个 IR,运行时透明。
|
|
11
|
-
|
|
12
|
-
## 目录结构
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
.dna/
|
|
16
|
-
configs/ # 多模板配置目录
|
|
17
|
-
flutter-rewrite.yaml # namespace: frw
|
|
18
|
-
secure-dev.yaml # namespace: sec
|
|
19
|
-
code-review.yaml # namespace: cr
|
|
20
|
-
compiled/
|
|
21
|
-
ir.json # 合并后的单一 IR
|
|
22
|
-
state/
|
|
23
|
-
trace/
|
|
24
|
-
lock # 追踪所有 configs 的 hash
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## 核心设计决策
|
|
28
|
-
|
|
29
|
-
| 决策 | 结论 | 理由 |
|
|
30
|
-
|------|------|------|
|
|
31
|
-
| 目录结构 | `.dna/configs/*.yaml` | 独立目录,清晰分离 |
|
|
32
|
-
| IR 输出 | 合并为单一 ir.json | hooks 只读一个 IR,运行时透明 |
|
|
33
|
-
| Namespace 冲突 | 编译时报错 | 一个 namespace 只属于一个模板,静默覆盖 = 数据丢失 |
|
|
34
|
-
| Gene 冲突 | 合并 codons + 警告 | gene 是项目级共享概念,additive 合并最合理 |
|
|
35
|
-
| 向后兼容 | 暂不考虑 | 新项目直接用 configs/,老项目手动迁移 |
|
|
36
|
-
| 性能 | 无影响 | YAML parse 5 个文件 ~25ms,ir.json KB 级,hook 运行时无差异 |
|
|
37
|
-
|
|
38
|
-
## Namespace 冲突处理
|
|
39
|
-
|
|
40
|
-
编译时扫描 `configs/*.yaml`,检测 namespace 重复:
|
|
41
|
-
|
|
42
|
-
```typescript
|
|
43
|
-
// sync.ts
|
|
44
|
-
const namespaces = new Map<string, string>(); // namespace → filename
|
|
45
|
-
for (const config of configs) {
|
|
46
|
-
if (namespaces.has(config.namespace)) {
|
|
47
|
-
throw new Error(
|
|
48
|
-
`Namespace "${config.namespace}" conflict: ` +
|
|
49
|
-
`${namespaces.get(config.namespace)} and ${config.filename}. ` +
|
|
50
|
-
`Each template must have a unique namespace.`
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
namespaces.set(config.namespace, config.filename);
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Gene 冲突处理
|
|
58
|
-
|
|
59
|
-
同名 gene 来自不同模板时,合并 codons 并输出警告:
|
|
60
|
-
|
|
61
|
-
```typescript
|
|
62
|
-
// cascade.ts
|
|
63
|
-
if (mergedGenes[geneName] && sourceNamespace !== existingNamespace) {
|
|
64
|
-
// Different templates define same gene — merge codons
|
|
65
|
-
mergedGenes[geneName].codons.push(...gene.codons);
|
|
66
|
-
warnings.push(
|
|
67
|
-
`Gene "${geneName}" defined in both ${existingNamespace} and ${sourceNamespace}. ` +
|
|
68
|
-
`Codons merged. Verify this is intentional.`
|
|
69
|
-
);
|
|
70
|
-
} else {
|
|
71
|
-
// Same namespace or new gene — normal cascade (higher priority wins)
|
|
72
|
-
mergedGenes[geneName] = gene;
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## 模板版本追踪
|
|
77
|
-
|
|
78
|
-
每个 config 文件增加 `_template_version` 字段:
|
|
79
|
-
|
|
80
|
-
```yaml
|
|
81
|
-
_source_template: flutter-rewrite
|
|
82
|
-
_template_version: "1.4.9" # npm 包版本时写入
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
`dna sync` 时对比:
|
|
86
|
-
1. 读每个 config 的 `_source_template` + `_template_version`
|
|
87
|
-
2. 查 npm 包里对应模板的当前版本
|
|
88
|
-
3. 版本不一致 → 提示 "flutter-rewrite 有新版本 (1.4.9 → 1.5.0),是否升级?(Y/n)"
|
|
89
|
-
4. 确认 → `upgradeConfig()` 全量替换 + 回写 variables
|
|
90
|
-
|
|
91
|
-
## dna sync 流程变化
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
当前:
|
|
95
|
-
autoDetectDNA() → 找 .dna/config.yaml → 读一个文件 → 编译
|
|
96
|
-
|
|
97
|
-
新:
|
|
98
|
-
autoDetectConfigs() → 扫描 .dna/configs/*.yaml
|
|
99
|
-
→ 读所有文件
|
|
100
|
-
→ 检测 namespace 冲突(报错)
|
|
101
|
-
→ 检测 gene 冲突(合并 + 警告)
|
|
102
|
-
→ 检测模板版本(提示升级)
|
|
103
|
-
→ cascadeDNA(all) → 合并为一个 IR
|
|
104
|
-
→ 生成全部产物
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## dna init 流程变化
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
当前:
|
|
111
|
-
dna init --template flutter-rewrite
|
|
112
|
-
→ 写 .dna/config.yaml
|
|
113
|
-
|
|
114
|
-
新:
|
|
115
|
-
dna init --template flutter-rewrite
|
|
116
|
-
→ mkdir -p .dna/configs/
|
|
117
|
-
→ 写 .dna/configs/flutter-rewrite.yaml
|
|
118
|
-
|
|
119
|
-
dna init --template secure-dev (追加第二个模板)
|
|
120
|
-
→ 检测 namespace 冲突
|
|
121
|
-
→ 写 .dna/configs/secure-dev.yaml
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
## dna init --upgrade 流程变化
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
当前:
|
|
128
|
-
读 .dna/config.yaml → 升级一个
|
|
129
|
-
|
|
130
|
-
新:
|
|
131
|
-
dna init --upgrade (升级所有)
|
|
132
|
-
→ 扫描 configs/*.yaml
|
|
133
|
-
→ 逐个检测版本,逐个升级
|
|
134
|
-
|
|
135
|
-
dna init --upgrade flutter-rewrite (升级指定)
|
|
136
|
-
→ 只升级 configs/flutter-rewrite.yaml
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
## 对现有功能的影响
|
|
140
|
-
|
|
141
|
-
| 功能 | 改动 |
|
|
142
|
-
|------|------|
|
|
143
|
-
| **autoDetectDNA()** | 改为 `autoDetectConfigs()`,扫描 `configs/*.yaml` |
|
|
144
|
-
| **cascadeDNA()** | 无改动(已支持多 DNA 输入) |
|
|
145
|
-
| **ir.json** | 内容更大(更多 roles/workflows),格式不变 |
|
|
146
|
-
| **hooks (dna-hook)** | 无改动(只读 ir.json) |
|
|
147
|
-
| **agents/*.md** | 无改动(namespace 前缀天然隔离) |
|
|
148
|
-
| **skills/*.md** | 无改动(namespace 前缀天然隔离) |
|
|
149
|
-
| **settings.json** | 无改动(hook 注册逻辑不变) |
|
|
150
|
-
| **CLAUDE.md** | 所有模板的 directives 合并注入 |
|
|
151
|
-
| **lock 文件** | 追踪所有 configs/*.yaml 的 hash |
|
|
152
|
-
| **dna init** | 写到 `configs/` 目录 |
|
|
153
|
-
| **dna init --upgrade** | 支持全量升级和指定升级 |
|
|
154
|
-
|
|
155
|
-
## 不做
|
|
156
|
-
|
|
157
|
-
- 向后兼容自动迁移(老项目手动 `mv config.yaml configs/`)
|
|
158
|
-
- config 间的 gene 优先级控制(MVP 用合并 + 警告)
|
|
159
|
-
- 运行时动态加载 config(全部编译时处理)
|
|
160
|
-
|
|
161
|
-
## Acceptance Criteria
|
|
162
|
-
|
|
163
|
-
- [ ] `dna init --template X` 写到 `.dna/configs/X.yaml`
|
|
164
|
-
- [ ] `dna sync` 自动扫描 `configs/*.yaml`
|
|
165
|
-
- [ ] namespace 重复 → 编译报错
|
|
166
|
-
- [ ] 同名 gene 不同模板 → codons 合并 + 警告
|
|
167
|
-
- [ ] `_template_version` 写入 config,sync 时对比提示升级
|
|
168
|
-
- [ ] `dna init --upgrade` 支持全量和指定模板
|
|
169
|
-
- [ ] 多模板编译为单一 ir.json
|
|
170
|
-
- [ ] agents/skills 文件 namespace 隔离正确
|
|
171
|
-
- [ ] lock 文件追踪所有 configs
|
|
172
|
-
- [ ] 测试覆盖:namespace 冲突、gene 合并、多模板编译、升级流程
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
# Spec: DNA 并行执行 + Worktree 隔离
|
|
2
|
-
|
|
3
|
-
## Metadata
|
|
4
|
-
- Interview: 8 rounds, final ambiguity 20%
|
|
5
|
-
- Type: brownfield
|
|
6
|
-
- Date: 2026-04-14
|
|
7
|
-
- Phase: 6 (基础体验)
|
|
8
|
-
|
|
9
|
-
## Goal
|
|
10
|
-
|
|
11
|
-
DNA 模板可声明并行执行策略和文件隔离策略,编译到 workflow-runner 生成的 bash 脚本中实际执行。支持强制 worktree、编译时自动判断(scope overlap)、和无隔离三种模式。
|
|
12
|
-
|
|
13
|
-
## 核心设计决策
|
|
14
|
-
|
|
15
|
-
| 决策 | 结论 | 理由 |
|
|
16
|
-
|------|------|------|
|
|
17
|
-
| 执行方式 | 自管 worktree (bash) | 不依赖 CC 平台特性,完全自控 |
|
|
18
|
-
| isolation 语义 | 纯文件隔离 | context 隔离已由独立进程解决,context 保护已由 Handoff 解决 |
|
|
19
|
-
| Schema 声明 | step 属性 + parallel block 双支持 | 灵活性 + 简洁性兼顾 |
|
|
20
|
-
| auto 模式 | 编译时 scope overlap 检测 | DNA 独有能力——Role scope 编译时已知 |
|
|
21
|
-
| merge 策略 | escalate only (MVP) | 冲突报告给用户,不自动解决 |
|
|
22
|
-
| scope.write 语义 | merge-time accept filter | 不是运行时 block rule,是合并时的产出过滤器 |
|
|
23
|
-
| 模型差异 | 暂不考虑 | 后续扩展 |
|
|
24
|
-
|
|
25
|
-
## 设计哲学:默会知识与三层防御
|
|
26
|
-
|
|
27
|
-
参考波兰尼(Michael Polanyi)默会知识理论:意图不能被规则穷尽,但可以通过适当的"身体"来实现。
|
|
28
|
-
|
|
29
|
-
**核心洞察**:`scope.write: ["test/**"]` 表达的是模板作者的**意图**("这个角色只该写测试文件"),不应该被实现为运行时工具拦截(显性规则,不完备),而应该被实现为物理隔离 + 出口把关(身体 + 审查)。
|
|
30
|
-
|
|
31
|
-
### 为什么工具拦截不可靠
|
|
32
|
-
|
|
33
|
-
路径级 scope enforce 通过拦截工具检查文件路径(Write/Edit/Bash/MCP...)。但写文件的工具不可枚举——每出现一个新工具就是一个绕过点。这是认识论问题,不是实现问题:显性规则永远追不上默会知识的丰富度。
|
|
34
|
-
|
|
35
|
-
### 三层对应
|
|
36
|
-
|
|
37
|
-
| 层 | 时机 | 机制 | 波兰尼对应 | 可靠度 |
|
|
38
|
-
|---|---|---|---|---|
|
|
39
|
-
| **工具控制** | PreToolUse | `tool_permissions.deny` — 禁止工具本身 | 显性知识(可完全条文化) | 高——工具名有限可枚举 |
|
|
40
|
-
| **过程提示** | PreToolUse | 当前 scope enforce(保留为软防线) | 辅助线索(from) | 低——最佳努力,不可依赖 |
|
|
41
|
-
| **出口把关** | Merge time | **scope gate 过滤 git diff** — 只接受 scope 内改动 | 焦点判断(to) | **确定性——基于实际产出** |
|
|
42
|
-
|
|
43
|
-
scope.write 的真正语义:**merge 时的 accept filter**,不是运行时的 block rule。
|
|
44
|
-
|
|
45
|
-
agent 在 worktree 内有完整读权限(理解上下文)和写自由(不被微管理),但只有符合角色意图的产出才能合并回主分支。如同管理者不盯每次敲键盘,而在 review 时评估产出。
|
|
46
|
-
|
|
47
|
-
## Schema 设计
|
|
48
|
-
|
|
49
|
-
### isolation 取值
|
|
50
|
-
|
|
51
|
-
| 值 | 含义 |
|
|
52
|
-
|---|---|
|
|
53
|
-
| `none` | 共享目录(默认,当前行为) |
|
|
54
|
-
| `worktree` | 强制每个并行 step 开 worktree |
|
|
55
|
-
| `auto` | 编译时分析 scope overlap,自动决定 none 或 worktree |
|
|
56
|
-
|
|
57
|
-
### 两种声明方式
|
|
58
|
-
|
|
59
|
-
**方式 A: step 属性 + workflow 默认值(隐式并行)**
|
|
60
|
-
|
|
61
|
-
```yaml
|
|
62
|
-
workflows:
|
|
63
|
-
rescue:
|
|
64
|
-
default_isolation: auto # workflow 级默认
|
|
65
|
-
merge_strategy: escalate
|
|
66
|
-
steps:
|
|
67
|
-
- id: investigate
|
|
68
|
-
role: investigator
|
|
69
|
-
- id: fix-auth
|
|
70
|
-
role: surgeon
|
|
71
|
-
isolation: worktree # step 级覆盖
|
|
72
|
-
depends_on: [investigate]
|
|
73
|
-
- id: fix-api
|
|
74
|
-
role: surgeon
|
|
75
|
-
# 继承 workflow 默认 auto
|
|
76
|
-
depends_on: [investigate]
|
|
77
|
-
- id: report
|
|
78
|
-
depends_on: [fix-auth, fix-api]
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
编译器通过 `depends_on` + Kahn 拓扑排序自动检测并行组(已实现)。
|
|
82
|
-
|
|
83
|
-
**方式 B: 显式 parallel block(语法糖)**
|
|
84
|
-
|
|
85
|
-
```yaml
|
|
86
|
-
workflows:
|
|
87
|
-
rescue:
|
|
88
|
-
steps:
|
|
89
|
-
- id: investigate
|
|
90
|
-
role: investigator
|
|
91
|
-
|
|
92
|
-
- parallel:
|
|
93
|
-
isolation: worktree
|
|
94
|
-
merge_strategy: escalate
|
|
95
|
-
steps:
|
|
96
|
-
- id: fix-auth
|
|
97
|
-
role: surgeon
|
|
98
|
-
- id: fix-api
|
|
99
|
-
role: surgeon
|
|
100
|
-
|
|
101
|
-
- id: report
|
|
102
|
-
depends_on: [fix-auth, fix-api]
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
parallel block 编译时展开为带 `depends_on` 的独立 step + 统一 isolation 设置。
|
|
106
|
-
|
|
107
|
-
### isolation 粒度
|
|
108
|
-
|
|
109
|
-
| 粒度 | 声明位置 | 含义 |
|
|
110
|
-
|------|----------|------|
|
|
111
|
-
| step 级 | step.isolation | 该 step 的并行执行隔离 |
|
|
112
|
-
| workflow 级 | workflow.default_isolation | 所有并行组的默认隔离策略 |
|
|
113
|
-
|
|
114
|
-
step 级 > workflow 级(覆盖优先级)。
|
|
115
|
-
|
|
116
|
-
## auto 模式编译逻辑
|
|
117
|
-
|
|
118
|
-
```
|
|
119
|
-
对每个 ParallelGroup:
|
|
120
|
-
1. 收集组内所有 step 对应 role 的 write scope
|
|
121
|
-
2. 做 glob 交叉检测(minimatch 或等价)
|
|
122
|
-
3. 无重叠 → 编译为 none
|
|
123
|
-
4. 有重叠 → 编译为 worktree
|
|
124
|
-
5. 无法判断("**/*")→ 保守编译为 worktree
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## workflow-runner 生成
|
|
128
|
-
|
|
129
|
-
### isolation: none(当前行为不变)
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
# Group 1: fix-auth, fix-api (parallel, no isolation)
|
|
133
|
-
run_agent "dna-surgeon" 'prompt' "fix-auth" &
|
|
134
|
-
PID_fix_auth=$!
|
|
135
|
-
run_agent "dna-surgeon" 'prompt' "fix-api" &
|
|
136
|
-
PID_fix_api=$!
|
|
137
|
-
wait $PID_fix_auth || STEP_fix_auth_STATUS=1
|
|
138
|
-
wait $PID_fix_api || STEP_fix_api_STATUS=1
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### isolation: worktree
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
# Group 1: fix-auth, fix-api (parallel, worktree isolation)
|
|
145
|
-
MAIN_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
146
|
-
|
|
147
|
-
git worktree add .dna/worktrees/fix-auth -b dna-wt-fix-auth HEAD 2>/dev/null
|
|
148
|
-
git worktree add .dna/worktrees/fix-api -b dna-wt-fix-api HEAD 2>/dev/null
|
|
149
|
-
|
|
150
|
-
(cd .dna/worktrees/fix-auth && run_agent "dna-surgeon" 'prompt' "fix-auth") &
|
|
151
|
-
PID_fix_auth=$!
|
|
152
|
-
(cd .dna/worktrees/fix-api && run_agent "dna-surgeon" 'prompt' "fix-api") &
|
|
153
|
-
PID_fix_api=$!
|
|
154
|
-
|
|
155
|
-
wait $PID_fix_auth || STEP_fix_auth_STATUS=1
|
|
156
|
-
wait $PID_fix_api || STEP_fix_api_STATUS=1
|
|
157
|
-
|
|
158
|
-
# Merge (escalate on conflict)
|
|
159
|
-
merge_worktree() {
|
|
160
|
-
local branch=$1 name=$2
|
|
161
|
-
if ! git merge --no-commit --no-ff "$branch" 2>/dev/null; then
|
|
162
|
-
git merge --abort
|
|
163
|
-
echo "[Intent DNA] CONFLICT: $name conflicts with $MAIN_BRANCH. Manual resolution required."
|
|
164
|
-
echo "[Intent DNA] Branch preserved: $branch"
|
|
165
|
-
return 1
|
|
166
|
-
fi
|
|
167
|
-
git commit -m "merge: $name" --no-edit
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
merge_worktree "dna-wt-fix-auth" "fix-auth"
|
|
171
|
-
merge_worktree "dna-wt-fix-api" "fix-api"
|
|
172
|
-
|
|
173
|
-
# Cleanup (only if merge succeeded)
|
|
174
|
-
git worktree remove .dna/worktrees/fix-auth 2>/dev/null
|
|
175
|
-
git worktree remove .dna/worktrees/fix-api 2>/dev/null
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### Merge-time scope gate
|
|
179
|
-
|
|
180
|
-
合并前过滤越权改动(scope.write 的真正执行点):
|
|
181
|
-
|
|
182
|
-
```bash
|
|
183
|
-
# scope gate: 只接受 scope 内的改动
|
|
184
|
-
scope_gate() {
|
|
185
|
-
local branch=$1 role=$2
|
|
186
|
-
# 获取该 role 的 write scope globs (从 IR 读取)
|
|
187
|
-
local allowed_globs=$(read_scope_globs "$role")
|
|
188
|
-
|
|
189
|
-
# 检查所有改动文件
|
|
190
|
-
local changed=$(git diff --name-only HEAD...$branch)
|
|
191
|
-
local rejected=()
|
|
192
|
-
for file in $changed; do
|
|
193
|
-
if ! matches_any_glob "$file" $allowed_globs; then
|
|
194
|
-
rejected+=("$file")
|
|
195
|
-
# 在 worktree 中 revert 越权改动
|
|
196
|
-
(cd .dna/worktrees/$branch && git checkout HEAD -- "$file")
|
|
197
|
-
fi
|
|
198
|
-
done
|
|
199
|
-
|
|
200
|
-
if [ ${#rejected[@]} -gt 0 ]; then
|
|
201
|
-
echo "[Intent DNA] Scope gate: ${#rejected[@]} file(s) outside scope, reverted:"
|
|
202
|
-
printf " - %s\n" "${rejected[@]}"
|
|
203
|
-
# trace 记录越权尝试 → 表观遗传反馈
|
|
204
|
-
fi
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
scope_gate "fix-auth" "surgeon"
|
|
208
|
-
scope_gate "fix-api" "surgeon"
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
## Constraint IR 扩展
|
|
212
|
-
|
|
213
|
-
```typescript
|
|
214
|
-
// ParallelGroup 扩展
|
|
215
|
-
interface ParallelGroup {
|
|
216
|
-
group_index: number;
|
|
217
|
-
step_ids: string[];
|
|
218
|
-
isolation: 'none' | 'worktree'; // auto 已被编译期解析
|
|
219
|
-
merge_strategy: 'escalate'; // MVP: escalate only
|
|
220
|
-
scope_overlap: boolean; // 编译期分析结果
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// WorkflowIR 扩展
|
|
224
|
-
interface WorkflowIR {
|
|
225
|
-
// ... 现有字段
|
|
226
|
-
parallel_groups?: ParallelGroupIR[]; // 新增
|
|
227
|
-
}
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
## 与 DNA 现有概念的关系
|
|
231
|
-
|
|
232
|
-
| DNA 概念 | 在并行隔离中的角色 |
|
|
233
|
-
|---|---|
|
|
234
|
-
| **Role scope.write** | **merge-time scope gate 的输入**——决定哪些改动可以合并回主分支 |
|
|
235
|
-
| **Role scope** | auto 模式的编译时 overlap 分析输入 |
|
|
236
|
-
| **tool_permissions.deny** | 工具级控制(可靠层)——reviewer 不能用 Edit |
|
|
237
|
-
| **Handoff** | 并行 step 的 artifact 传递(已实现) |
|
|
238
|
-
| **Threshold codon** | 可声明 `parallel_without_isolation == false` 硬约束 |
|
|
239
|
-
| **Attract codon** | `attract: worktree_per_task` 软提示(保留兼容) |
|
|
240
|
-
| **Hooks enforce (PreToolUse)** | 保留为过程提示(辅助软防线),不作为安全保障依赖 |
|
|
241
|
-
| **表观遗传** | scope gate 越权记录 → trace → epigenetic marker 反馈 |
|
|
242
|
-
|
|
243
|
-
## 不做
|
|
244
|
-
|
|
245
|
-
- 自动冲突解决(MVP 只 escalate)
|
|
246
|
-
- LLM 模型差异适配(暂不考虑)
|
|
247
|
-
- context budget 管理(已由独立进程 + Handoff 解决)
|
|
248
|
-
- container 级隔离(过度设计)
|
|
249
|
-
- sparse-checkout(限制读权限会破坏 agent 理解上下文的能力)
|
|
250
|
-
|
|
251
|
-
## Acceptance Criteria
|
|
252
|
-
|
|
253
|
-
- [ ] Schema: WorkflowStepDef 支持 `isolation` 字段
|
|
254
|
-
- [ ] Schema: WorkflowDef 支持 `default_isolation` + `merge_strategy`
|
|
255
|
-
- [ ] Schema: `parallel:` block 语法糖可解析
|
|
256
|
-
- [ ] Compiler: auto 模式 scope overlap 检测正确
|
|
257
|
-
- [ ] Compiler: parallel block 展开为 step + depends_on
|
|
258
|
-
- [ ] workflow-runner: isolation=none 行为不变(向后兼容)
|
|
259
|
-
- [ ] workflow-runner: isolation=worktree 生成 git worktree 生命周期脚本
|
|
260
|
-
- [ ] workflow-runner: merge 前执行 scope gate(过滤越权改动)
|
|
261
|
-
- [ ] workflow-runner: merge 冲突时 escalate(报告 + 保留分支)
|
|
262
|
-
- [ ] scope gate: 越权改动被 revert + trace 记录
|
|
263
|
-
- [ ] E2E: 两个并行 step 写不同目录,auto → none,正确执行
|
|
264
|
-
- [ ] E2E: 两个并行 step 写相同目录,auto → worktree,隔离执行 + merge
|
|
265
|
-
- [ ] E2E: agent 写越权文件,scope gate 过滤 + trace 记录
|
|
266
|
-
- [ ] Dogfood: flutter-rewrite rescue workflow 可配置 isolation
|
|
267
|
-
- [ ] IR: ParallelGroup 包含 isolation + scope_overlap 信息
|
|
268
|
-
- [ ] 测试覆盖所有新增代码
|