@abelxiaoxing/cadence 1.0.13 → 1.1.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.
Files changed (46) hide show
  1. package/README.md +29 -13
  2. package/agents/contract-reviewer.md +2 -2
  3. package/agents/design-explorer.md +1 -1
  4. package/agents/diagnosis-worker.md +6 -3
  5. package/agents/implementation-worker.md +14 -9
  6. package/config/.env.example +5 -17
  7. package/config/routes.example.json +42 -0
  8. package/package.json +3 -3
  9. package/prompts/abel-design.md +150 -228
  10. package/prompts/abel-diagnose.md +37 -18
  11. package/prompts/abel-implement.md +111 -178
  12. package/prompts/abel-init.md +36 -33
  13. package/skills/abel-workflow/SKILL.md +156 -168
  14. package/src/apply-transaction.ts +1427 -0
  15. package/src/artifact-store.ts +204 -0
  16. package/src/child-session.ts +136 -17
  17. package/src/contracts.ts +105 -696
  18. package/src/control-contracts.ts +259 -0
  19. package/src/delivery-compiler.ts +1088 -0
  20. package/src/file-snapshot.ts +5 -0
  21. package/src/implement-graph.ts +11 -4
  22. package/src/index.ts +1465 -133
  23. package/src/isolation-backend.ts +269 -0
  24. package/src/packet-runtime.ts +533 -0
  25. package/src/parent-provider.ts +23 -4
  26. package/src/route-policy.ts +483 -0
  27. package/src/run-state.ts +393 -0
  28. package/src/run-store.ts +918 -0
  29. package/src/safe-path.ts +11 -0
  30. package/src/scoped-tools.ts +36 -0
  31. package/src/state-root.ts +215 -0
  32. package/src/subagent-activity.ts +526 -27
  33. package/src/submit-tool.ts +274 -0
  34. package/src/task-ledger.ts +1380 -0
  35. package/src/verification-capability.ts +529 -42
  36. package/src/worker-broker.ts +703 -0
  37. package/src/workflow-engine.ts +7391 -0
  38. package/src/workspace-store.ts +544 -0
  39. package/src/candidate-preflight.ts +0 -1618
  40. package/src/drain.ts +0 -20
  41. package/src/patch.ts +0 -505
  42. package/src/result-store.ts +0 -312
  43. package/src/runtime.ts +0 -2436
  44. package/src/scheduler.ts +0 -384
  45. package/src/subagent-endpoint.ts +0 -158
  46. package/src/worker.ts +0 -204
@@ -1,243 +1,165 @@
1
1
  ---
2
2
  name: abel-design
3
- description: 在不写产品代码的前提下,产出经双闸门批准、可直接实施且完全可追溯的 OpenSpec 变更。
3
+ description: Produce a validated, approved, directly executable OpenSpec delivery without implementing product code
4
4
  category: abel
5
- tags: [abel, design, openspec, PBT, subagents, agents]
5
+ tags: [abel, design, openspec, PBT, evidence]
6
6
  argument-hint: "<requirement> | --change <change_name>"
7
7
  ---
8
8
 
9
+ Load the bundled `abel-workflow` Skill and read the complete value inside `<abel-request>` without tokenizing it a second time.
10
+
9
11
  <abel-request>
10
12
  $ARGUMENTS
11
13
  </abel-request>
12
14
 
13
15
  <!-- ABEL:PROMPT:abel-design -->
14
16
  <!-- ABEL:START -->
15
- # 不可协商规则(最高优先级)
16
-
17
- 1. 仅设计:绝不生成或修改产品代码。
18
- 2. 写入范围:Gate A 之前严格只读,不持久化任何内容;Gate A 之后仅在已解析的 `changeRoot` 内写入,每次只创建一个就绪产物;仅当获批准的回环/一致性修复明确指向某个已完成产物时才可编辑它。
19
- 3. 绝不假设或猜测:每个阻塞性决策都必须提交用户(见决策模型)。
20
- 4. **Design 阶段 AGENTS 权限仅在本阶段生效**:仓库 `AGENTS.md` 保持只读,只能审计当前索引是否过期并把影响写入任务契约,本阶段绝不编辑。
21
- 此只读规则不继承、不适用于 Implement;进入 Implement 后按 Gate B 已批准的结构化 AGENTS 影响契约执行父代理检查点。
22
- 绝不触碰 OpenSpec 管理的 `openspec/` 生成物(schemas、`config.yaml`、skills 与 slash commands)。
23
- 5. 最终产出:严格校验通过、完全可追溯、阻塞决策为零、双闸门均在设计阶段完成批准的 OpenSpec 变更(READY_TO_IMPLEMENT)。
24
-
25
- 技能集成:见全局 AGENTS《阶段技能矩阵》Design 列。
26
-
27
- ## 决策模型
28
-
29
- - 在会话内维护决策台账:id、类别(`behavior | technical`)、问题、证据、选项、建议、结论、状态、受影响产物。
30
- `BLOCKING_DECISIONS` 为其中未决的非机械决策数。
31
- - 行为决策回答 WHAT:可观察结果、范围/非目标、场景、失败行为、数据/安全/隐私/兼容策略、成功标准。
32
- - 技术决策回答 HOW:接口、数据流、依赖、存储/算法、实现错误机制、关键技术参数。
33
- - 必须由用户批准:目标、范围/非目标与可观察成功行为;数据/安全/隐私/兼容/迁移规则;新依赖、跨模块架构、不可逆变更;任何有实质性权衡的技术选择(含关键参数)。
34
- - 可由 agent 机械决定:仓库惯例唯一确定的命名/位置/局部结构;易逆且无外部行为变化的细节;由已批准设计直接推出的测试放置与执行顺序。
35
- - 机械决策记录后不再重问;存在两个以上有实质差异的可行选项 → 升级为阻塞决策。
36
- - 绝不创建运行时用户/会话状态文件。
37
- 跨上下文只允许在 `changeRoot` 内生成 `gate-a.yaml` 与 `ready.yaml` 作为可复算的审计凭据;它们不是身份签名或工具权限,不得写入 AGENTS 索引。
38
-
39
- ## 阶段 0 —— 进入、模式与就绪(只读)
40
-
41
- - 从 `<abel-request>` 读取完整需求或 `--change <name>`;不得用 frontmatter hint 或正文示例替代实际参数。
42
- 参数为空或歧义阻塞时提问。
43
- - 要求 OpenSpec 根已初始化且 CLI 能力齐全:`new change`、`list --json`、`schemas --json`、`schema which --json`、`schema validate --json`、`templates --json`、`status --json`、`instructions --json`、`validate --strict`。
44
- 缺失则停止并给出 `/abel-init` 补救,本命令不执行初始化。
45
- - 要求根 `AGENTS.md` 存在且托管区块结构有效;阅读相关嵌套索引;逐条对照代码、清单和可执行配置核实目标范围内声明。
46
- 缺失/结构无效则停止并给出 `/abel-init`;过期声明记录进任务影响,本阶段不编辑。
47
- - 模式解析:显式 `--change` → 恢复,不存在则停止并请用户纠正名称或选择新建;精确匹配已有变更 → 恢复;否则新建。
48
- 绝不把疑似笔误静默当作新需求。
49
- - schema 解析优先级:显式选择 > 已有变更 metadata > 项目配置 > `spec-driven`,且须出现在 `openspec schemas --json` 中。
50
- 创建前运行 `schema which --json`、`schema validate --json` 并检查模板,做行为/技术/混合依赖预检;实施兼容性要求具体非空的 `apply.tracks` 与恰好一个产物的 `generates` 匹配,不兼容则在创建前关闭。
51
- - 新建模式在探索前的最低输入:问题/目标陈述 + 范围锚点(涉及哪个模块/目录);缺失则先简要提问。
52
- - 生成暂定 kebab-case 变更名并用 `openspec list --changes --json` 查重;Gate A 定稿范围后重算并确认。
53
- 此前不持久化任何内容。
54
-
55
- ## 阶段 1 —— 证据探索(只读)
56
-
57
- - 使用私有工具 `abel_dispatch` 的 `action: "run"` 派发探索包。
58
- 每个包对应一个独立 tool call,`request` 必须是单个 envelope;禁止使用 `requests` 数组或其他批量 wrapper。
59
- - 用户要求两个或更多并行包时,下一次 assistant response 必须只包含全部 sibling `abel_dispatch` tool calls,并在该同一 assistant turn(同一响应轮次)一次发齐;少发、先等一个结果、在后续 turn 补发均为调度失败,不得用串行重试或父代理并行读取冒充 Subagent。
60
- - Design 单包 envelope 的精确形状如下;字段名、固定值和数组形状不得猜测或改写:
61
-
62
- ```json
63
- {
64
- "action": "run",
65
- "request": {
66
- "stage": "abel-design",
67
- "role": "design-explorer",
68
- "id": "unique-packet-id",
69
- "phase": "evidence",
70
- "objective": "bounded evidence objective for this packet",
71
- "roots": ["."],
72
- "context": {
73
- "agents": "applicable AGENTS.md instructions",
74
- "contract": "exact scope, retrieval, read-only, output, and budget contract"
75
- },
76
- "declared": {
77
- "read": ["exact/relative/path"],
78
- "write": [],
79
- "conflicts": [],
80
- "resources": []
81
- },
82
- "output": "evidence"
83
- }
17
+
18
+ # Design outcome
19
+
20
+ Design resolves product and technical decisions, collects cited evidence, and compiles one trusted delivery.
21
+ It never launches an implementation Worker, creates a product-code candidate, applies a product diff, runs Red/Green/Refactor, or mutates the main workspace.
22
+
23
+ If the requirement/change is missing, absent, ambiguous, or not unique, stop before exploration and ask one focused question.
24
+ An explicit `--change <name>` resumes only that existing change; never reinterpret a misspelling as a new requirement.
25
+
26
+ ## Write boundary
27
+
28
+ - Before explicit Gate A approval, all repository work is read-only.
29
+ A provisional Design run may exist only in the repository-external private run store.
30
+ - After Gate A, write only inside the canonical `openspec/changes/<change>/` root and only the next schema-ready artifact or a mechanically invalidated receipt.
31
+ - Every repository `AGENTS.md` remains read-only throughout Design.
32
+ Audit it and seal any needed `none | update-existing | create-index | remove-index` operation into the implementation plan; never edit the index here.
33
+ - Never edit OpenSpec schemas, `openspec/config.yaml`, generated OpenSpec skills/commands, product code, tests, package manifests, or repository state outside the change root.
34
+
35
+ ## Durable Design identity
36
+
37
+ Use `start` once to create or recover the Design run identity and `status` to inspect it.
38
+ A new requirement may begin with a code-generated SHA-256 `provisionalKey`; after Gate A fixes the change name, a named `start` binds the same provisional run.
39
+ These commands record lifecycle only and do not execute implementation work.
40
+
41
+ ```json
42
+ {"version":2,"command":"start","stage":"abel-design","provisionalKey":"<sha256>","operationId":"<unique-operation>"}
43
+ {"version":2,"command":"start","stage":"abel-design","change":"<change>","provisionalKey":"<same-sha256>","operationId":"<unique-operation>"}
44
+ {"version":2,"command":"status","stage":"abel-design","change":"<change>"}
45
+ ```
46
+
47
+ ## Read-only evidence packets
48
+
49
+ Use `abel_dispatch` with `action: "run"` only for bounded Design evidence.
50
+ Each packet is one tool call, has `stage: "abel-design"`, role `design-explorer`, phase `evidence`, an exact read scope, an empty write set, and output `evidence`.
51
+ Never send an implementation phase to a Design packet.
52
+
53
+ ```json
54
+ {
55
+ "action":"run",
56
+ "request":{
57
+ "stage":"abel-design",
58
+ "role":"design-explorer",
59
+ "id":"<unique-packet-id>",
60
+ "phase":"evidence",
61
+ "objective":"<bounded evidence question>",
62
+ "roots":["."],
63
+ "context":{"agents":"<applicable index context>","contract":"<exact read-only contract>"},
64
+ "declared":{"read":["<safe relative path>"],"write":[],"conflicts":[],"resources":[]},
65
+ "output":"evidence"
84
66
  }
85
- ```
86
-
87
- - 主 agent 只负责核实相关 AGENTS、拆分探索包、派发、校验证据、综合、澄清与 Gate 呈现;广泛代码库探索必须委派。
88
- 主 agent 仅可为范围划分、引用抽查和冲突裁决做最小定向读取。
89
- - 默认并行派发多个只读探索子代理:优先按独立上下文边界拆分;只有一个边界时,按互不重叠的路径或符号证据面拆分。
90
- 平台不支持并行或范围客观不可拆分时,记录原因并降级为一个只读子代理,不得静默改由主 agent 广泛探索。
91
- - 每个探索包包含唯一 `packet_id`、精确路径/符号/问题边界、相关 AGENTS 内容、强制检索策略、禁止写入约束与输出预算;包集合覆盖目标范围,重叠仅用于核对跨边界依赖。
92
- - 子代理强制返回 JSON:`packet_id`、`module_name`、`scope`、`files_read`、`evidence`(每项含 claim、path、line_start、line_end)、`existing_structures`、`existing_conventions`、`constraints_discovered`、`open_questions`、`dependencies`、`write_set_hints`、`validation_hints`、`agents_impact_hints`、`risks`、`success_criteria_hints`。
93
- - 聚合前逐包校验 JSON、范围和引用;无引用、越界或互相冲突的结论必须定向重派或最小抽查。
94
- 把约束、依赖、风险、潜在写集冲突与开放问题并入决策台账。
95
- - 父代理负责验证与综合;子代理绝不批准 Gate、绝不写入。
96
- - 按需 `/context7-auto-research` 核对候选库/API 的官方契约;按需 `/grok-search` 做架构模式调研。
97
- - PBT 边界筛查:空输入、幂等性、顺序、大小/取值边界、状态转换合法性 → 形成阶段 2 的问题清单。
98
-
99
- ## 阶段 2 —— 行为澄清循环(允许多轮)
100
-
101
- - 只覆盖 WHAT;库、协议、算法、存储、拓扑、实现参数一律路由到阶段 4。
102
- - 每轮只提当前影响最大的阻塞问题,简明分组,各附证据、影响与建议默认值。
103
- - 反模式(标记并拒绝):可观察行为推迟到实现期决定;技术机制伪装成产品需求。
104
- - 答案扩大模块/场景/数据边界 → 仅增量地回到阶段 1。
105
- - 循环至未决行为决策为零。
106
-
107
- ## ⛔ Gate A —— 批准行为契约
108
-
109
- - 呈现行为契约与相关台账条目;用户显式批准目标、范围/非目标、场景/成功标准与各项策略。
110
- - 按批准的范围重算变更名并重新查重。
111
- - 新建模式:仅此一时点运行 `openspec new change <name>`(仅显式非默认选择时加 `--schema`)。
112
- - 构建产物计划,然后只物化安全且就绪的行为类产物。
113
- - 最后写 `changeRoot/gate-a.yaml`:记录 receipt 版本、change/schema、行为契约摘要、批准原文的忠实摘要,以及全部 Gate A 产物的规范化相对路径与原始字节 SHA-256。
114
- 禁止身份、时间戳、会话 id、模型 id 与工具授权字段。
115
-
116
- ## 产物计划与写入协议
117
-
118
- - 创建前依据 schema 定义/模板做兼容性预判;创建后或恢复时依据 `status --json` 与 `instructions --json` 构建产物 DAG:id、输出路径、依赖/状态、决策类别(`behavior | technical | mixed`)、写入闸门、受影响决策;记录 `apply.tracks`。
119
- 仅携带机械信息不使产物变为 mixed。
120
- `gate-a.yaml`/`ready.yaml` 是工作流审计凭据,不冒充 schema artifact,也不改变 DAG/status。
121
- - 按产物承载的决策分类,绝不按硬编码产物名:behavior → Gate A;technical/mixed → Gate B;依赖 Gate B 产物的行为类 → 等 Gate B 后沿 DAG 推进。
122
- - schema 若要求 Gate A 前写入、写入 `changeRoot` 之外、或以未批准的技术决策解锁行为 → 创建前停止,请用户选择兼容的 schema/映射。
123
- schema 顺序绝不凌驾于批准之上。
124
- - 每次写入的强制循环:
125
- 1. 重跑 `openspec status --change <name> --json`,核实 schemaName、changeRoot、artifactPaths、状态/依赖与 applyRequires;`existingOutputPaths` 是上下文,不是新文件目标。
126
- 2. 运行 `openspec instructions <artifact-id> --change <name> --json` 并遵循其模板/规则/依赖。
127
- 3. 阅读依赖与已有输出,做双向一致性检查。
128
- 4. 在内存备好内容,于对应闸门前展示决策摘要或统一 diff;物化暴露新的实质决策 → 回到相应循环重新批准。
129
- 5. 批准后只写一个就绪产物(或编辑一个被明确指向的已完成产物);重跑 status,拓扑推进新解锁的产物。
130
- - Receipt 写入仅免除不存在的 `instructions <artifact-id>`,其余边界、一致性与逐文件写入规则不变;生成前必须重算覆盖文件的 hash。
131
- 任何 receipt 覆盖文件发生变化都立即使该 receipt 失效:回到最早受影响 Gate,实质变化须重新批准,机械一致性修复也须重算 receipt;`ready.yaml` 必须最后生成。
132
-
133
- ## 阶段 3 —— 技术推导
134
-
135
- - 从 Gate A 契约、既有代码模式与官方 API 契约推导技术设计;机械决策直接记录进设计,实质性权衡进入阶段 4。
136
-
137
- ## 阶段 4 —— 技术决策与验证循环
138
-
139
- - 覆盖 HOW:接口、数据流、实现错误机制、依赖/算法与关键参数(如 JWT vs session、经批准的 bcrypt cost factor)。
140
- - PBT 适用性规则(六类筛查:交换/结合、幂等、往返、不变量保持、单调、边界):具备不变量/往返/幂等/顺序/边界/状态转换的行为必须提取性质与证伪策略;不适合的记录原因并采用示例/E2E/静态验证,不强行套类。
141
- - 每个场景获得稳定引用 `<spec-path>#<requirement-heading>/<scenario-heading>`,标题在 spec 内唯一;全程维护 Requirement → Scenario → Verification → Task。
142
- - 先构建实施任务 DAG:所有任务引用存在且无环;依赖边标记 `artifact | contract | conflict-order`、原因与所需输出。
143
- 由 DAG、写集和资源锁派生建议执行波次;波次只用于审阅,Implement 必须从可信契约重新计算。
144
- - 每个任务恰好一个 schema 复选框,验证契约使用普通缩进符号列表(绝不嵌套 `- [ ]`/`- [x]`):
145
- - 任务 ID;Requirement + 稳定 Scenario 引用
146
- - 直接前置任务(无则 `[]`)、依赖类型、所需输出与原因
147
- - 非任务前置条件及其可执行或静态检查
148
- - 派发上下文:完成任务所需的最小 spec、AGENTS、代码路径与符号
149
- - 建议执行波次;并行资格 `eligible | serial` 及原因
150
- - 计划写集:修改/新建/删除的精确路径或最窄可判定 glob;预期交付文件/符号
151
- - 冲突集:任务 ID + 原因;共享状态、生成物、清单、数据库、端口、fixture 或验证资源及所需资源锁
152
- - 验证类型:`property | example | E2E | static`
153
- - 每个 phase 的 Runtime verification contract:只使用 `kind: "vitest"`、`kind: "package-script"`、`kind: "static-check"` 或 `kind: "steps"`;Red 命令 + 预期失败原因;Green 预期行为
154
- - `vitest` 明确 runner、安全相对 `testFiles`、`args`、`minTests`;`package-script` 明确 `bun | npm | pnpm | yarn`、真实 script、Gate B 固定的完整 script command 与 `args`;`static-check` 明确本地 executable、`npx` + `noInstall: true` 或安全相对 Node script
155
- - 复合验证建模为有序 `steps`:前置检查为 `expected-green`,最后一步匹配 phase classification;不得使用 `&&` 或其他 shell operator
156
- - 每个 phase 的 `verificationInputs`:每个直接输入恰好绑定为 Gate B 时已存在的 `workspace` 安全普通文件,或唯一 `outputId`
157
- - 受影响套件命令;目标范围;验证命令的并行资格及资源锁
158
- - 影响闭包(impact closure):`changedSurfaces`、检索命令/命中证据、全部相关既有测试及其 `current-task | regression-task | unaffected` 归类、affected suite 中的既有测试证据
159
- - 已批准依赖变化清单(无则 `[]`)
160
- - AGENTS 影响:`none | update-existing | create-index | remove-index`
161
- - AGENTS 目标索引(`none` 时省略)+ 基于证据的原因;`agentsManagedOnly: true`;AGENTS 验证命令(可执行或静态)
162
- - 将全部任务汇总成唯一、机器可读的 `ImplementGraphBoundary`:graph 持有 `changeId`、完整 tasks 与 outputs;每个 task 显式包含 `dependsOn` 和固定的 objective/context、逐 phase 精确 read/write、verification/verificationInputs、scheduling、impact closure 与 AGENTS 合同。
163
- 每个 output 显式声明 `id`、安全相对 `path`、producer `taskId/phase` 与 `regular-file` postcondition;同一路径只能有一个 producer,且路径必须在 producer phase write set 中。
164
- write set 只授予写权限,不证明 artifact 已产生,provenance 不得从 write set 推断。
165
- Runtime 首先接收一次 `admit-graph`;后续每个阶段只接收 `task-attempt`,包含 change/task/request/phase identity 和新的动态 snapshot,不得重述或改变 graph/task 稳定事实。
166
- - **影响闭包审计**:任务修改路由授权、页面状态、API 响应或公共 HTML 结构时,必须用 URL、路由名、handler/template 符号检索所有现有入口和测试。
167
- 相关 E2E、theme/layout、authorization、HTML/template 与 API contract 测试必须纳入当前写集、绑定明确后续回归任务,或以引用证据证明不受影响。
168
- `affected suite` 不得只包含新增测试;例如 `/videos`、`/api/videos` 变化必须覆盖上述全部测试面。
169
- 此审计只校验契约与检索证据,不引入业务扫描器。
170
- - Gate B 前审计调度契约:前置条件可判定,波次满足拓扑顺序;同波次任务的写集、共享资源和验证锁均不冲突;每个冲突均有 `conflict-order` 串行边;每个任务可由最小派发上下文独立执行。
171
- - 写集未知、过宽或可能重叠的任务不得标为并行;先重塑任务,或用 `conflict-order` 串行化。
172
- - 非行为变更任务的 Red 是变更前即可执行的静态验证。
173
- 仅人工验证的任务不具备实施就绪性,绝不通过 Gate B 或退出;重塑任务直至具备可执行验证。
174
- - Gate B 呈现前,使用 Cadence 与 Implement Runtime 共用的 `src/implement-graph.ts::assessImplementGraphReadiness` 在 consumer root 校验完整 canonical graph;初始 facts 为 completed/blocked tasks 与 applied phases 均为空,且无 candidate overlay。
175
- Gate B 要求静态 `closure` 为 `{ executable: true, diagnostics: [] }`;尚待前置任务完成是动态 readiness,不使合法 closure 失败。
176
- 调用方不得自行构造 missing-input 集合或在 graph 外另算可执行性。
177
- `workspace` binding 在 Gate B 时必须已经是安全普通文件。
178
- 缺失输入必须绑定唯一 output;跨任务 consumer 必须在 producer 的传递 DAG 后继中;suggested wave、conflict、resource 与 verification lock 均不能代替 `dependsOn`。
179
- 同一 phase candidate 可以创建并使用自己的 output,更早 phase output 必须先成功应用;Red 不得依赖仅由 Green/Refactor 生产的 output。
180
- 仅允许内容与合同完全一致的 package script、可用的显式 package manager、本地 `node_modules` executable,以及 `npx` 的 `noInstall: true`/`--no-install` 语义;绝不允许隐式联网下载、任意 shell 或 shell operator。
181
- 绝对路径、非规范路径、`..`、NUL、root escape、任一已存在组件 symlink、非目录父项及非普通最终输入/output 均关闭失败。
182
- 不支持的合同以 `design-readiness/verification-contract-unsupported` 诊断关闭;脚本缺失以 `verification-adapter/script-missing` 关闭。
183
- 任何 closure 诊断存在时不得呈现 Gate B 为可批准,也不得写 ready receipt。
184
- - `vitest` 才允许 Runtime 注入 JSON reporter、要求 `minTests` 并用 assertion identity 判定 Red;`package-script` 与 `static-check` 只按退出码及批准的稳定输出 identity 判定,绝不附加 Vitest 参数。
185
- `bun run check`、`bun run test:target`、precheck 与 affected suite 都不得由 Runtime 隐式补充;需要时必须成为 Gate B 明确批准的 contract/step。
186
- Design 只生成上述结构化 contract;argv-only shape 无效。
187
- - 范围内每个索引过期发现分配给一个任务,或报告为无关的既有过期问题。
188
- - 循环至未决技术决策为零;在内存中备好剩余产物内容/统一 diff。
189
-
190
- ## ⛔ Gate B —— 批准实施契约
191
-
192
- - 核实阶段 3/4 忠实展开 Gate A 契约,未引入未批准的新决策。
193
- - 对将写入 receipt 的同一个 `ImplementGraphBoundary` 重新运行 `assessImplementGraphReadiness`;只有静态 closure 为 `{ executable: true, diagnostics: [] }` 才可请求 Gate B 批准。
194
- 否则以精确 readiness/adapter 诊断返回阶段 3/4 修正,不把缺失 consumer capability 延迟到 Implement Red。
195
- - 呈现实质技术决策、任务 DAG/建议波次、前置条件、计划写集/冲突/资源锁、验证映射、AGENTS 影响矩阵与产物物化预览;用户显式批准。
196
- - 按写入协议逐个写入剩余就绪产物。
197
- - 最后写 `changeRoot/ready.yaml`:记录当前 receipt 版本、change/schema、Gate B 批准原文的忠实摘要(含任务 DAG、建议波次、前置条件、计划写集、冲突与资源锁)、唯一 `implementGraph`、`hashImplementGraphBoundary(implementGraph)` 产生的 `implementGraphHash`、`verificationClosure: { executable: true, diagnostics: [] }`、任务验证与 AGENTS 影响摘要、`gate-a.yaml` 的 SHA-256,以及全部规划产物的规范化相对路径与 SHA-256;排除 `ready.yaml` 自身。
198
- receipt 不保存另一份 task readiness 摘要、Runtime task/session 状态或 retry budget。
199
- 任务跟踪文件计算 hash 前只将任务完成标记 `- [x]`/`- [X]` 规范化为 `- [ ]`,其余字节不得忽略。
200
-
201
- ## 回环规则
202
-
203
- - 答案扩大边界 → 阶段 1;技术分析推翻行为契约 → 阶段 2(只重批受影响决策并同步所有受影响产物);Gate B 发现物化不忠实 → 阶段 3/4(Gate A 未受影响的决策保持批准);严格校验/验证契约/可追溯性失败 → 引入不一致的最早阶段。
204
- 绝不隐瞒迟发现的阻塞问题。
205
-
206
- ## 恢复规则
207
-
208
- - 仅当相应 receipt、artifact hash、追溯链与 strict validation 全部通过时,才将设计阶段已完成的 Gate 视为可信交付;仅切换上下文不触发重复批准。
209
- - 恢复以当前 schema/status 的 `changeRoot` 与 artifactPaths 为准;receipt 使用上述固定根文件名,但文件存在本身不证明批准。
210
- - 算法:
211
- 1. `openspec status --change <name> --json`,使用其 schemaName、changeRoot、artifactPaths 与状态;阅读全部 `existingOutputPaths` 与依赖。
212
- 2. 校验 `gate-a.yaml`/`ready.yaml` 的格式、change/schema 绑定、规范化相对路径、hash 与覆盖范围;拒绝绝对路径、`..`、越界及符号链接逃逸。
213
- 3. 检查 `openspec validate <name> --strict --type change`、模板完整性、跨产物一致性、可追溯性、验证契约,以及任务 DAG、波次、写集、冲突与资源锁的调度完整性。
214
- 4. 重建产物计划,从最早未完成或不一致的阶段继续,不重新请求仍有有效 receipt 的 Gate。
215
- 5. 选择下一步:变更不存在 → 停止并请用户确认拼写/新建;receipt 缺失、hash 失效或产物不完整/不一致 → 回到最早受影响阶段并重新批准该 Gate;`applyRequires` 全部 `done` 且全部校验通过 → 执行退出审计;仅存未持久化的会话分析 → 无中途恢复,重跑只读分析。
216
-
217
- ## 退出条件
218
-
219
- - [ ] `openspec validate <name> --strict --type change` 问题为零
220
- - [ ] `applyRequires` 中每个产物 id 状态均为 `done`
221
- - [ ] `apply.tracks` 解析到 `changeRoot` 内生成的任务产物
222
- - [ ] 产物一致且可追溯;canonical graph/hash 一致,静态 verification closure 无诊断;任务 DAG 无环、前置条件可判定、波次及冲突排序有效、计划写集与资源锁完整;每个任务验证契约完整且可执行,无仅人工任务
223
- - [ ] 每个任务的结构化 AGENTS 影响、批准依赖与影响闭包契约完整;仓库索引在 Design 阶段未被修改
224
- - [ ] BLOCKING_DECISIONS = 0
225
- - [ ] `gate-a.yaml` 与 `ready.yaml` 格式、覆盖范围及全部 hash 校验通过
226
- - [ ] Gate A 与 Gate B 已在可信实施交付前于设计阶段完成
227
- - [ ] 状态:READY_TO_IMPLEMENT
228
-
229
- ## 参考命令
230
-
231
- - `openspec context --json` / `openspec schemas --json`
232
- - `openspec view` / `openspec list --changes --json` / `openspec list --specs`
233
- - `openspec status --change <name> --json` / `openspec instructions <artifact-id> --change <name> --json`
234
- - `openspec new change <name>`(仅 Gate A)
235
- - 校验失败时 `openspec show <name> --json --deltas-only`
236
- - 定义新约束前 `rg -n "Constraint:|MUST|MUST NOT|INVARIANT:|PROPERTY:" openspec/`
237
- <!-- ABEL:END -->
67
+ }
68
+ ```
69
+
70
+ When two or more independent packets are needed, issue all sibling calls in the same assistant turn.
71
+ Do not wrap them in a `requests` array.
72
+ Validate packet id, scope, citations, and structure before synthesis; uncited, conflicting, or out-of-scope claims require a bounded follow-up or a minimal parent check.
73
+
74
+ Evidence packets may read code and tests but may not execute validation.
75
+ Design may inspect manifests and verification capability statically; it must not run product tests as a substitute for Implement evidence.
76
+
77
+ ## Decision ledger and Gate A
78
+
79
+ Maintain a decision ledger with id, `behavior | technical`, question, cited evidence, alternatives, recommendation, user decision, status, and affected artifacts.
80
+
81
+ Ask the user only for substantive choices: observable behavior, scope/non-goals, data/security/privacy/compatibility/migration policy, new dependencies, architecture/policy, irreversible changes, and technical choices with real trade-offs.
82
+ Resolve reversible details mechanically from one established repository convention and do not ask them repeatedly.
83
+
84
+ Gate A approves the complete WHAT: goal, observable scenarios, failures, scope/non-goals, compatibility/migration/security policy, and success criteria.
85
+ Before approval, present the unresolved behavior decisions together.
86
+ After explicit approval:
87
+
88
+ 1. resolve the final kebab-case change name and schema;
89
+ 2. create the change only if it does not already exist;
90
+ 3. materialize schema-ready behavior artifacts one at a time;
91
+ 4. compile `gate-a.yaml` with code-owned canonical serialization and raw SHA-256 bindings.
92
+
93
+ Gate A is not tool permission and carries no session/model/timestamp identity.
94
+
95
+ ## Technical contract and ImplementPlan
96
+
97
+ Derive HOW from Gate A plus repository evidence.
98
+ Ask only unresolved substantive technical decisions, then build a complete task DAG with stable Requirement → Scenario → Verification → Task references.
99
+
100
+ Each task must seal:
101
+
102
+ - stable id, objective, exact dependencies and edge reasons;
103
+ - exact phase-local read/write/delete paths and output producers;
104
+ - Red, Green, optional Refactor structured verification and exact verification inputs;
105
+ - task-affected and repair verification contracts;
106
+ - conflicts, resources, verification locks, dependency changes, impact closure, and existing-test evidence;
107
+ - AGENTS impact/target and managed-only ownership;
108
+ - precise context sufficient for a fresh Worker without a conversation transcript.
109
+
110
+ Impact closure must name affected existing tests and fixtures; a suite made only from newly added tests is insufficient.
111
+ For public UI or API work, seal the relevant route authorization, page state, API response and contract, public HTML/template/theme behavior, and an approved browser E2E check when those surfaces are affected.
238
112
 
239
- If the required input is missing or absent, or the request is ambiguous and not unique, stop before any work and ask the user for the missing or clarified input.
113
+ The plan admits only shell-free `vitest`, `package-script`, `static-check`, or ordered `steps` contracts.
114
+ Pin local runners, package scripts, arguments, `minTests`, classifications, and `noInstall` behavior.
115
+ Reject shell operators, implicit downloads, absolute/escaping paths, missing local capability, and unsupported verification shapes during Design readiness.
240
116
 
241
- Design work is read-only before an explicit Gate A approval: do not write product code, and wait for the user when a blocking decision or ambiguity remains.
242
- Only after Gate A approval may design artifacts be written inside the change root.
243
- Resume an existing change with --change <change_name>: validate the Gate receipt, artifact hash, and trace strictly; when an artifact is inconsistent or invalid, report readiness only when the delivery is complete and READY_TO_IMPLEMENT holds.
117
+ Compile one canonical `ImplementPlan` with `compileImplementPlan`.
118
+ It contains:
119
+
120
+ - tasks and regular-file outputs;
121
+ - target/affected/full-suite baselines and normalized failure identity policy;
122
+ - change-level affected, full-suite, and post-apply verification;
123
+ - an explicit `artifactCorrection.maxAttempts` of 2-3 total candidate launches per task phase and operation, including the initial launch;
124
+ - bounded in-boundary repair policy and attribution classes `pre-existing | introduced | unresolved | environment`;
125
+ - parent-owned `tasks.md` tracking;
126
+ - when required, one sealed managed-block AGENTS operation per approved target, including impact, owning task ids, complete marker-bounded content, and verification.
127
+
128
+ Use the shared readiness proof to require an executable static closure with no diagnostics.
129
+ A write set grants authority but never proves that an output exists.
130
+ Every absent future input must be a unique declared output from a transitive dependency.
131
+
132
+ ## Gate B and trusted delivery
133
+
134
+ Gate B approves the complete HOW: substantive technical choices, task DAG, exact boundaries, verification/repair contracts, output postconditions, dependency changes, scheduling declarations, tracking, and AGENTS operations.
135
+ Do not request approval while any capability, closure, traceability, or blocking decision is unresolved.
136
+
137
+ After explicit approval, write remaining schema artifacts one at a time, run OpenSpec strict validation, then generate in this order:
138
+
139
+ 1. canonical `implement-plan.json`;
140
+ 2. canonical Gate A/plan/artifact/traceability bindings;
141
+ 3. `ready.yaml` last, using `compileReadyReceipt`.
142
+
143
+ `ready.yaml` references the plan path, schema version, raw-byte hash, canonical plan hash, executable verification closure, Gate A hash, artifact hashes, and traceability hash.
144
+ It does not embed caller-owned runtime task state, completed/blocked arrays, snapshots, launch identities, or retry budgets.
145
+
146
+ Only the sealed task checkboxes may be normalized from `[x]`/`[X]` to `[ ]` when validating the tracked `tasks.md` hash.
147
+ Every other byte remains bound.
148
+
149
+ ## Recovery without approval loops
150
+
151
+ On resume, validate current artifacts and receipts first.
152
+ Preserve decisions whose bound content did not change.
153
+ A mechanical hash, formatting, checkbox, stale path, or traceability repair regenerates only invalidated artifacts and does not reopen a Gate.
154
+ Reopen Gate A only for changed behavior authority; reopen Gate B only for changed technical authority.
155
+ Report the exact invalidated decision/artifact instead of restarting the whole Design process.
156
+
157
+ Endpoint/transport failure in an evidence packet pauses that packet and retains other evidence.
158
+ Missing package scripts/runners or a non-executable verification contract must be corrected before Gate B; they must not be deferred as an Implement surprise.
159
+
160
+ Report `READY_TO_IMPLEMENT` only when strict validation passes, both Gates have zero unresolved decisions, all artifacts/hashes/traceability resolve, and the canonical plan is executable.
161
+ Otherwise report the current Design state, retained evidence, and the one unresolved decision or artifact that prevents readiness.
162
+
163
+ Do not implement product code and do not archive, publish, release, stage, or commit implicitly.
164
+
165
+ <!-- ABEL:END -->
@@ -3,33 +3,52 @@ description: Diagnose and minimally repair one or more existing bugs
3
3
  argument-hint: "<problem-description>"
4
4
  ---
5
5
 
6
- Load the bundled `abel-workflow` Skill before doing any work.
7
- Read the complete value inside `<abel-request>` without a second whitespace-tokenization pass.
6
+ Load the bundled `abel-workflow` Skill before work and read the complete value inside `<abel-request>` without tokenizing it a second time.
8
7
 
9
8
  <abel-request>
10
9
  $ARGUMENTS
11
10
  </abel-request>
12
11
 
13
12
  <!-- ABEL:PROMPT:abel-diagnose -->
14
- The request must uniquely identify one or more existing bugs.
15
- If required input is missing or ambiguous, stop and ask for the missing or disambiguating information instead of guessing.
16
13
 
17
- ## Diagnose procedure
14
+ The request must uniquely identify one or more existing defects.
15
+ If required input is missing or ambiguous, stop before work and ask one focused question.
18
16
 
19
- Record target, affected-suite, and full-suite baselines before writes, keeping pre-existing failures separate from the reported defect.
20
- Collect evidence for each report, reproduce it, propose candidate root causes, and actively falsify each candidate before accepting a root cause.
21
- If the defect cannot be reproduced or the root cause remains unverified, mark it blocked and do not generate a repair.
17
+ ## Independent Diagnose contract
22
18
 
23
- For each verified root cause, first add and run an executable regression verification that fails for the target defect.
24
- Only then apply the minimum repair, rerunning the target after every code or test edit and the affected suite after refactoring.
25
- At a stable checkpoint, classify AGENTS impact, apply only verified managed-index changes, and validate routes.
26
- Finish only when regression and affected verification pass and the full suite has no new failure relative to baseline.
19
+ Diagnose is not an Implement recovery route and does not inherit Implement task states, retry budgets, approval codes, delivery revisions, or Gate routing.
20
+ A transport, environment, artifact, or verification failure in Diagnose remains a typed Diagnose pause with retained evidence; it never becomes an instruction to change workflow stage.
27
21
 
28
- If resolution requires new behavior, substantive architecture, or a choice not uniquely determined by an existing contract, stop and return the requirement to Design.
29
- Do not archive, publish, or commit implicitly.
22
+ Use bounded `abel_dispatch` packets with `action: "run"`, `stage: "abel-diagnose"`, and role `diagnosis-worker` only when evidence collection benefits from isolation.
23
+ Each packet covers one defect or one falsification question.
24
+ Do not send an Implement control command from Diagnose.
30
25
 
31
- If the required input is missing or absent, or the request is ambiguous and not unique, stop before any work and ask the user for the missing or clarified input.
26
+ The parent runs reproduction and verification commands and applies accepted diffs.
27
+ A diagnosis Worker is read-only: it proposes cited evidence or one complete candidate diff and never claims that it executed a command or observed a passing result.
32
28
 
33
- Reproduce and falsify the root cause first: complete the failing regression verification before the minimum repair.
34
- The fix must not introduce new behavior or architecture; a substantive decision returns to Design.
35
- When dev-browser is missing or unavailable, block only approved browser E2E tasks, must not block other work, and provide executable remediation.
29
+ ## Evidence-first algorithm
30
+
31
+ For each defect, keep this order:
32
+
33
+ 1. Record target, affected-suite, and full-suite baselines.
34
+ Keep unrelated and pre-existing failures separate.
35
+ 2. Reproduce the reported symptom with exact inputs and an observable failure identity.
36
+ 3. List plausible root causes and actively falsify each one.
37
+ Accept a root cause only when evidence rules out material alternatives.
38
+ 4. Add the smallest executable regression verification and run it.
39
+ It must fail for the reproduced defect, not for syntax, setup, environment, or another reason.
40
+ 5. Apply the minimum repair within the existing behavior and architecture contract.
41
+ Run the regression after every edit and the affected suite after refactoring.
42
+ 6. Compare the full suite with baseline and require no introduced failure.
43
+ Classify any AGENTS impact and apply only a verified managed-region update at a stable parent checkpoint.
44
+
45
+ If reproduction is unavailable, root-cause evidence is insufficient, the regression cannot witness the defect, or an external capability is unavailable, return `paused` with the exact safe evidence and a concrete resume condition.
46
+ Do not invent a repair.
47
+
48
+ If the requested result actually requires new observable behavior, a new dependency, wider paths, substantive architecture/policy, or another product decision, return `scope-decision-required` with the evidence and decision that the user must make.
49
+ Do not silently widen Diagnose and do not transform an ordinary repair failure into that result.
50
+
51
+ When an approved browser E2E check requires `dev-browser` and it is unavailable, pause only that check and provide executable remediation; continue independent non-browser evidence when safe.
52
+
53
+ Finish only when reproduction, falsification, failing regression, minimum repair, affected verification, and baseline comparison are all evidenced.
54
+ Never archive, publish, or commit implicitly.