@abelxiaoxing/cadence 1.0.14 → 1.1.1

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 (48) hide show
  1. package/README.md +39 -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 +206 -228
  10. package/prompts/abel-diagnose.md +39 -18
  11. package/prompts/abel-implement.md +122 -178
  12. package/prompts/abel-init.md +36 -33
  13. package/skills/abel-workflow/SKILL.md +190 -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 +121 -696
  18. package/src/control-contracts.ts +246 -0
  19. package/src/delivery-compiler.ts +1118 -0
  20. package/src/design-control.ts +846 -0
  21. package/src/design-journal.ts +1569 -0
  22. package/src/file-snapshot.ts +5 -0
  23. package/src/implement-graph.ts +11 -4
  24. package/src/index.ts +1833 -118
  25. package/src/isolation-backend.ts +269 -0
  26. package/src/packet-runtime.ts +533 -0
  27. package/src/parent-provider.ts +23 -4
  28. package/src/route-policy.ts +483 -0
  29. package/src/run-state.ts +430 -0
  30. package/src/run-store.ts +990 -0
  31. package/src/safe-path.ts +11 -0
  32. package/src/scoped-tools.ts +36 -0
  33. package/src/state-root.ts +215 -0
  34. package/src/subagent-activity.ts +526 -27
  35. package/src/submit-tool.ts +274 -0
  36. package/src/task-ledger.ts +1380 -0
  37. package/src/verification-capability.ts +560 -45
  38. package/src/worker-broker.ts +703 -0
  39. package/src/workflow-engine.ts +7706 -0
  40. package/src/workspace-store.ts +544 -0
  41. package/src/candidate-preflight.ts +0 -1618
  42. package/src/drain.ts +0 -20
  43. package/src/patch.ts +0 -505
  44. package/src/result-store.ts +0 -312
  45. package/src/runtime.ts +0 -2436
  46. package/src/scheduler.ts +0 -384
  47. package/src/subagent-endpoint.ts +0 -158
  48. package/src/worker.ts +0 -204
@@ -1,194 +1,138 @@
1
1
  ---
2
2
  name: abel-implement
3
- description: 校验已批准的 OpenSpec 变更,并调度子代理并行执行强制 Red-Green-Refactor,在任务检查点维护 AGENTS 索引。
3
+ description: Execute one approved change through the durable control plane
4
4
  category: abel
5
- tags: [abel, implementation, TDD, agents]
5
+ tags: [abel, implement, openspec, TDD, recovery]
6
6
  argument-hint: "<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-implement -->
14
16
  <!-- ABEL:START -->
15
- **参数**:从 `<abel-request>` 读取必需的 `<change_name>`。
16
-
17
- # 护栏
18
-
19
- - 改动保持最小且已获批准;应用任何修改前做副作用评审;保留无关的脏文件。
20
- - 最少注释/文档,优先自解释代码。
21
- - OpenSpec 约定以 `openspec/config.yaml` 声明的 schema 及其模板为准;OpenSpec 管理的 `openspec/` 生成物(schemas、`config.yaml`、skills 与 slash commands)绝不编辑。
22
-
23
- ## AGENTS 阶段权限(Implement 专用)
24
-
25
- Design 阶段的 `AGENTS.md` 只读规则仅适用于 Design 阶段,不继承为全局规则。
26
- 进入 Implement 后,父代理必须按 Gate B 已批准的结构化契约在稳定任务检查点执行:
27
-
28
- - `agentsImpact: none`:不得修改任何 `AGENTS.md`,且不得声明 `agentsTarget`。
29
- - `agentsImpact: update-existing`:父代理应更新指定现有索引的托管区块。
30
- - `agentsImpact: create-index`:父代理可创建批准路径的新索引。
31
- - `agentsImpact: remove-index`:父代理可移除批准路径的索引托管区块;仅当无人工内容残留时才删除文件。
32
- - 非 `none` 必须有明确 `agentsTarget` 且 `agentsManagedOnly: true`。
33
- 父代理只能修改批准路径及 `<!-- ABEL:AGENTS-INDEX:START -->` 到 `<!-- ABEL:AGENTS-INDEX:END -->` 的托管区域,保留全部人工内容。
34
- - 子代理始终不能修改任何 `AGENTS.md`,其派发写集必须排除 Gate receipt、OpenSpec 跟踪文件和 AGENTS 路径。
35
- - 已批准的 AGENTS checkpoint 是正常 Implement Green/检查点工作,必须完成;不能成为阶段路由或用户恢复动作。
36
-
37
- ## TDD 护栏(强制)
38
-
39
- - **Red**:只创建/执行任务的失败可执行验证;实现代码禁止。
40
- - **Green**:写最小代码满足验证;过度工程禁止。
41
- - **Refactor**:在保持目标与受影响验证为绿、不引入完整套件新失败的前提下优化质量。
42
- - 每次代码/测试变更后必须运行任务验证,并在会话中重新分类累计的 AGENTS 影响;仅在稳定任务检查点写索引。
43
- 绝不跳过验证;测试先行强制。
44
-
45
- **技能集成**:见全局 AGENTS《阶段技能矩阵》Implement 列;E2E 任务 → `/dev-browser`。
46
-
47
- ## 就绪预检(任何代码/测试写入之前)
48
-
49
- Implement 不重新作出或请求 Gate A/B 决策;只有 Gate receipts、artifact hashes、追溯链与 OpenSpec strict validation 全部通过时,才将所选变更视为可信设计交付。
50
-
51
- 1. 从 `<abel-request>` 直接解析 change name;仅在缺失或无法唯一解析时提问。
52
- 绝不要求无条件的 `openspec view` 确认。
53
- 2. 解析仓库根目录,记录 `git status --short`,阅读根/相关嵌套索引。
54
- 根索引缺失/无效 → `/abel-init`。
55
- 3. `openspec status --change <name> --json`:读 `schemaName`、`changeRoot`、`artifactPaths`、`applyRequires`、`artifacts`。
56
- 4. `openspec schema which <schemaName> --json` 读取解析出的 schema.yaml,提取 `apply.tracks` 并相对 `changeRoot` 解析;必须是 `changeRoot` 内一个已存在的具体常规文件。
57
- 缺失/空/不具体/越界路径一律关闭失败;绝不从 apply 指令的 `contextFiles`/`tasks` 推断跟踪路径。
58
- 5. `applyRequires` 中每个产物 id 状态必须为 `done`;数组存在或总体完成标记不算数。
59
- 6. 校验 `changeRoot/gate-a.yaml` 与 `changeRoot/ready.yaml`:当前 receipt 版本、change/schema 绑定、批准摘要、artifact 覆盖范围、`gate-a.yaml` hash,以及每个规范化相对路径的 SHA-256。
60
- `ready.yaml` 必须只含一份 canonical `implementGraph`,且 `implementGraphHash` 必须等于 `hashImplementGraphBoundary(implementGraph)`;`verificationClosure` 必须精确为 `{ executable: true, diagnostics: [] }`。
61
- hash 使用文件原始字节;仅对 schema `apply.tracks` 指向的任务文件先把 `- [x]`/`- [X]` 规范化为 `- [ ]`。
62
- 拒绝绝对路径、`..`、越界与符号链接逃逸。
63
- receipt 缺失或任一 hash 失效即关闭失败。
64
- 7. `openspec validate <name> --strict --type change` 问题为零。
65
- 8. 阅读 `artifactPaths` 报告的全部规划产物;运行 `openspec instructions apply --change <name> --json` 并遵循其 apply 契约。
66
- 9. 从 receipt 的 `implementGraph` 校验稳定 Requirement/Scenario 引用、Requirement → Scenario → Verification → Task 追溯链,以及每个任务的前置条件、`dependsOn`、计划写集、冲突/资源锁、派发上下文、验证、批准依赖、结构化 AGENTS 影响和影响闭包契约;缺失、含糊或不可判定时按下方矩阵关闭失败。
67
- 每个 phase 必须是 Gate B 批准的结构化 `kind: "vitest" | "package-script" | "static-check" | "steps"`;Implement 不从命令固定下标猜测语义,也不隐式运行 `bun run check`、`bun run test:target` 或任何 consumer script。
68
- `steps` 按声明顺序执行;precheck 必须是显式 `expected-green` step,不得用 `&&` 或其他 shell operator 合成。
69
- 每个 phase 的直接 verification input 必须恰好绑定为 `workspace` path 或 graph `outputId`;每个 output 必须有唯一 id/path/producer phase 和 `regular-file` postcondition。
70
- write set 只授予权限,不能推断 provenance。
71
- 10. 影响闭包(impact closure):若任务修改路由授权、页面状态、API 响应或公共 HTML,检查 URL/路由/handler/template 检索证据及全部相关既有测试归类。
72
- E2E、theme/layout、authorization、HTML/template、API contract 测试必须进入当前写集、明确后续回归任务或有不受影响证据;affected suite 不能只包含新增测试。
73
- `/videos`、`/api/videos` 等变化须检查全部这些测试面。
74
- 11. 在 graph admission 前,使用 receipt 中同一个 `implementGraph` 重跑共享 `assessImplementGraphReadiness`。
75
- fresh context 的 facts 只来自父代理在跟踪文件中拥有的 completed tasks、当前进程已知的 blocked tasks 与当前工作区安全扫描;不得因文件碰巧存在而推断 task/phase 完成。
76
- 静态 closure 必须继续为 `{ executable: true, diagnostics: [] }`;completed producer 的全部 outputs 必须实际为安全普通文件。
77
- 任一不一致都是 `delivery-invalid` stage blocker,不得调用方另算 missing inputs。
78
- package script 的 package manager、名称与完整 command 必须和当前 consumer `package.json` 一致;本地 executable 必须受 `node_modules` 约束;`npx` 只能用 `noInstall: true` 并编译为 `--no-install`,不允许下载。
79
- `vitest` 才注入 JSON reporter、应用 `minTests` 并解析 assertion Red identity;`package-script`/`static-check` 不附加 Vitest 参数,只使用退出码和批准的稳定输出 identity。
80
- parent-only AGENTS checkpoint 可使用合法的 Node/static contract。
81
- 不支持的 shape 是 `design-readiness/verification-contract-unsupported` stage blocker;缺失 script 是 `verification-adapter/script-missing`,其他缺失/漂移能力使用精确 adapter code;只有 Bubblewrap、Bun 解析、依赖路径或 sandbox runtime 不可用才使用 environment code。
82
- 12. 在任何写入前运行并记录每个未完成任务的目标命令、全部 affected-suite 命令与完整套件基线:命令、退出码、归一化失败标识/原因。
83
- 尚未加入 Red 验证时,目标命令可记录为契约规定的预期状态;既有失败与目标 Red 严格分离,既有失败绝不算 Red。
84
- 13. 可信交付无效时,在注册任务前输出 stage-level blocker;不得伪装成 task outcome。
85
- boundary 外的新路径、依赖、行为、策略、架构、冲突、资源、verification 或 AGENTS 需求使当前任务以 typed `approval-boundary` failure 终止。
86
- 工具、依赖路径、命令或沙箱不可用使当前任务以 typed environment failure 终止;可机械修复的产物仅使用 phase 的有界 correction budget。
87
-
88
- **工具路由**:父代理只负责可信交付校验、执行图调度、子代理派发、统一 diff 审查与机械应用、验证决策、Gate/AGENTS/任务状态所有权,不直接编写测试、实现或局部重构。
89
- 任务的 Red、Green、Refactor 内容统一由任务 worker 子代理生成;E2E 任务使用 `/dev-browser`。
90
-
91
- ## 执行图与并行调度(父代理专有)
92
-
93
- 1. 以 receipt-bound `ImplementGraphBoundary` 为唯一执行图;校验 hash 后先调用一次 `admit-graph`,不得另建 stage graph 或逐任务重述完整 boundary。
94
- 从 graph tasks 的 `dependsOn` 计算 DAG,拒绝未知任务、自依赖和环。
95
- 非任务前置条件通过契约检查后,且所有前置任务均已由父代理验收并推进状态,任务才进入 ready 集合。
96
- 2. 规范化每个计划写集、冲突集和资源锁;写集覆盖测试、fixture、快照与生成输出。
97
- 拒绝绝对路径、`..`、符号链接逃逸和不可判定的宽泛 glob。
98
- Gate receipt、OpenSpec 跟踪文件和 `AGENTS.md` 不属于子代理写集,只能由父代理按契约写入。
99
- 3. 父代理从 ready 集合计算受可用并发槽约束的批次;仅计划写集两两不相交、无冲突边且共享/验证资源锁兼容的任务可同批。
100
- 相同路径、祖先/后代目录、共同生成输出或互斥资源均串行;Design 的建议波次只供核对,不替代重新计算。
101
- 4. 每个 ready task 的首次 Red `task-attempt` 由 Runtime 从已 admitted graph 打开一个 immutable TaskRecord;后续 Green、Refactor、artifact correction 或 stale refresh 仍只提交 `task-attempt` 的 change/task/request/phase identity 与 fresh snapshot。
102
- 每个 ready 任务绑定一个任务局部 worker,并在同一 worker 上通过后续派发连续完成 Red、Green、Refactor,避免把全局上下文复制给 worker。
103
- 首次派发只提供相关 AGENTS 内容、任务契约、允许读取/改动范围、可信基线标识与当前阶段;worker 不得广泛探索。
104
- 5. 同批 worker 并行生成当前阶段的统一 diff 和说明,不得写入任何工作树。
105
- 父代理按跟踪文件顺序校验基线、实际路径、契约与 diff,再机械应用合格 diff;父代理不得自行补写或修正实现。
106
- 每次应用后由父代理运行契约命令,并把命令、退出码和归一化结果回传原 worker,作为进入下一阶段或生成修正 diff 的唯一事实。
107
- 6. diff 冲突、越界、写集扩张或验证失败时只终止当前任务;已独立验收的同批任务可保留,外层 DAG 的其余调度仍由父代理决定。
108
- 机械重派只可在不改变行为、架构、依赖和固定 boundary 时基于最新 snapshot 进行。
109
- 普通实现或测试失败不得由自然语言推测为契约变化。
110
- 禁止无界重试。
111
- 7. 一批任务稳定后,父代理逐任务完成 AGENTS 检查点和状态推进,再重新计算 ready 集合;任何后继不得提前调度。
112
- 循环直至 DAG 全部完成。
113
- 8. 当前 phase candidate 在隔离 checkout apply 后、verification 前必须满足该 phase 的全部 output postconditions;main workspace apply 后、phase progression 前再次检查。
114
- 跨任务 output 仅在 producer 整个 task completed 后发布;producer blocked/failed 时 consumer 保持 `dependency-blocked` 且不启动 child,producer completed 但 output 缺失或 unsafe 时返回 `producer-output-unavailable`。
115
-
116
- ## 每个任务的委派式 TDD 循环
117
-
118
- worker 消费任务契约的普通缩进符号列表(绝非 Markdown 复选框):前置条件、直接依赖、派发上下文、计划写集、冲突/资源锁、验证类型、Red 命令/预期失败原因、Green 预期行为、受影响套件命令、目标范围和 AGENTS 影响。
119
-
120
- 1. **🔴 Red(worker → 父代理)**:worker 只用契约规定的验证类型与范围生成失败验证 diff;父代理审查并应用后运行 Red 命令,必须因契约描述的目标缺陷失败。
121
- 加载/导入失败、未运行目标测试或失败身份与批准身份不同时,将结果分类为生成的实现产物拒绝并进入有界修正路径。
122
- 若 Red 候选意外通过,记录 `{ kind: "artifact", code: "red-not-witnessed" }`;Runtime 返回有界 `{ kind: "retry", scope: "worker", cause: "artifact", remainingAttempts: 1 }`,因为候选通过本身不证明设计有缺陷。
123
- 已证明批准命令无法见证行为且必须改变行为、策略、依赖、架构、范围、写集或验证契约时,以 `verification-contract-insufficient` 终止当前任务,不消耗产物修正预算。
124
- 非行为变更任务以指定的失败静态验证起步;仅人工任务不具备可执行合同并阻塞。
125
- 2. **🟢 Green(worker → 父代理)**:同一 worker 基于已确认的 Red 证据生成最小实现 diff;父代理审查并应用后运行目标验证。
126
- 失败证据回传 worker,仅允许在声明写集和已批准行为内生成修正 diff。
127
- 3. **🔵 Refactor(worker → 父代理)**:同一 worker 仅在声明范围内生成消除重复、改进命名/结构/可读性的可选 diff;父代理每次应用后跑目标验证,重构后跑 affected suite;失败则仅撤销该次重构 diff。
128
- 4. **交付验收(父代理)**:拒绝基线不符、越界文件、Gate/索引/跟踪文件修改、验证证据缺失或未批准行为;父代理只做契约判断、机械应用与验证,不直接修码。
129
- 5. **AGENTS 检查点(父代理)**:审查完整任务 diff,机械比较 `agentsImpact`、`agentsTarget`、`agentsManagedOnly: true` 与实际影响。
130
- - `none` → 记录未写 AGENTS 的证据;`update-existing | create-index | remove-index` → 父代理在稳定任务检查点按批准目标完成托管区块操作。
131
- 子代理 diff 中出现 AGENTS 路径一律是写集越界。
132
- - 实际 diff 暴露未批准生产行为/架构,或必须改变 AGENTS/任务契约时,以匹配的 `approval-boundary` code 终止当前任务;正常已批准 checkpoint 继续执行。
133
- - 校验已索引的路径/命令/根到嵌套路由、marker 唯一性与人工内容不变;运行该任务的 AGENTS 验证命令。
134
- 6. 父代理重跑目标与受影响验证;全绿后,仅在 schema `apply.tracks` 解析出的具体跟踪文件中更新匹配的那个任务复选框;零个/多个匹配 → stage-level blocker。
135
-
136
- ## 当前任务的 typed blocker(闭合)
137
-
138
- Runtime 只报告当前任务事实,不选择用户恢复动作,也不控制外层 DAG。
139
- 闭合失败类如下:
140
-
141
- - malformed diff、syntax/import/load、no-test/错误命令、wrong Red identity、重复/无效提交或 Red 候选意外通过:`{ kind: "artifact", code: <closed-artifact-code> }`,其中意外通过使用 `red-not-witnessed`;首次可在共享两次 launch 内修正,耗尽为 `attempts-exhausted`。
142
- - stale snapshot 使用 `{ kind: "stale", code: <closed-stale-code> }`;可机械重派的 transport failure 使用 `{ kind: "transport", code: "transport-failure" }`;首次可在共享两次 launch 内刷新或同调用重派,耗尽为 `attempts-exhausted`。
143
- - artifact、stale 或 transport 耗尽必须返回 `{ kind: "attempts-exhausted", cause, attemptsUsed: 2, lastFailure: { code, stage, details? } }`。
144
- `lastFailure` 保留最终具体 closed code 与 `child-session-create | child-provider-stream | child-timeout | child-finalization | structural-submit | candidate-retention | candidate-diff | candidate-preflight | parent-review | candidate-apply | agents-checkpoint | phase-runtime` stage。
145
- 安全 details 只允许 final submit category、有界 submit attempts、schema state、request/role/task/phase 中不匹配的维度名和受约束 verification id;不得返回 prompt、diff、模型原始输出、excerpt、consumer 内容、command/argv、endpoint、credential、环境值或 identity 实际值。
146
- - Bubblewrap、依赖路径、测试沙箱或外部环境不可用:`{ kind: "environment", code: <closed-environment-code> }`,当前任务 terminal blocked。
147
- - 缺失/漂移的已批准 script、runner、本地 executable 或 verification input:`{ kind: "verification-adapter", code: <closed-adapter-code> }`;`script-missing` 不得误报为 `bubblewrap-or-dependency-unavailable`。
148
- - 新路径、依赖、行为、策略、架构、冲突、资源、verification 或 AGENTS 合同:对应 closed `approval-boundary` code,当前任务 terminal blocked,不扩大 boundary。
149
- - result size 超限:`{ kind: "result-limit", limitBytes }`,当前任务 terminal blocked,不接受 partial diff。
150
-
151
- 可信 delivery 的 receipt/hash/trace/strict/graph closure failure 发生在 `admit-graph` 前并成为 `delivery-invalid` stage blocker,不是 TaskFailure。
152
- 预期 Red 失败、artifact defect、stale snapshot、环境失败、已批准 AGENTS checkpoint、已批准文档/测试和 boundary 内兼容修复均不产生阶段选择。
153
- 重试预算始终有限。
154
-
155
- 父代理拥有主工作区补丁应用、闸门、索引写入与任务完成状态;子代理只接收任务局部索引上下文,只返回统一 diff 与分析,绝不应用补丁、批准决策、编辑索引或推进状态。
156
-
157
- ## 最终评审与收尾
158
-
159
- 1. 全部目标测试为绿后运行受影响套件。
160
- 2. 重跑同一完整套件命令,与基线的归一化失败标识对比,要求无新增失败。
161
- 3. 变更风险需要时以子代理做全局只读评审;接受其编辑后重跑目标验证与 AGENTS 分类。
162
- 4. 目标/索引/受影响/完整套件任何失败都阻塞完成;只修复或回退本次变更的编辑。
163
- 5. 最终副作用评审。
164
- 6. 要求每个任务/索引结论均已解决,然后报告:Red/Green/Refactor 证据、受影响/完整套件相对基线的结果、AGENTS 文件与原因、是否可进入用户授权的归档。
165
- 绝不隐式归档。
166
-
167
- ## 输出格式
168
-
169
- ```text
170
- ## /abel-implement (TDD)
171
-
172
- ### 任务 i/N: {任务描述}
173
- 🔴 Red ├─ 类型: {verification_type} ├─ 运行: {red_command} └─ 结果: 因 {预期失败原因} 失败 ✓
174
- 🟢 Green ├─ 实现: {文件} ├─ 运行: {red_command} └─ 结果: {green 预期行为} ✓
175
- 🔵 Refactor ├─ 优化: {描述} ├─ 运行: {affected_suite_command} └─ 结果: 绿 ✓
176
- AGENTS: {none 的证据 | 更新的索引文件与原因}
177
-
178
- ### 全部任务完成
179
- ├─ 目标测试: 绿 ✓
180
- ├─ 受影响套件: 绿 ✓
181
- ├─ 完整套件: 相对基线无新增失败 ✓
182
- └─ 可进入用户授权的归档
17
+
18
+ # Implement outcome
19
+
20
+ The request must resolve to exactly one existing change.
21
+ If it is missing, absent, or ambiguous, stop before execution and ask for the unique change name.
22
+
23
+ Implement is a durable, resumable execution stage.
24
+ The private control plane owns task scheduling, Red-Green-Refactor progression, candidate application, verification attribution, repair, task checkbox updates, AGENTS checkpoints, and the final transaction.
25
+ The parent interprets state and makes product decisions; it must not reproduce those mechanics manually.
26
+
27
+ ## Trusted admission
28
+
29
+ Before the first Worker launch, load the current `ready.yaml` and referenced canonical `implement-plan.json`; verify the Gate A binding, raw and canonical hashes, OpenSpec strict/planning status, Requirement → Scenario → Verification → Task traceability, capability closure, exact path/output contracts, repair policy, tracking contract, and sealed AGENTS operations.
30
+
31
+ An invalid or incomplete delivery is one aggregated `delivery-invalid` admission result.
32
+ Report every safe diagnostic together.
33
+ Do not launch a Worker, consume a retry, mutate the main workspace, or infer a missing contract.
34
+
35
+ Gate approval is not tool permission.
36
+ A fresh context validates existing approval facts and does not ask the user to approve unchanged decisions again.
37
+
38
+ ## Closed control surface
39
+
40
+ Use `abel_dispatch` only with the change commands below; never send `version`; never send `action: "run"`; and never send `admit-graph`, `task-attempt`, caller-owned snapshots, completed/blocked arrays, or apply identities.
41
+
42
+ ```json
43
+ {"command":"start","stage":"abel-implement","change":"<change>","operationId":"<unique-operation>"}
44
+ {"command":"status","stage":"abel-implement","change":"<change>"}
45
+ {"command":"resume","stage":"abel-implement","change":"<change>","operationId":"<unique-operation>"}
46
+ {"command":"rebind","stage":"abel-implement","change":"<change>","operationId":"<unique-operation>","routeId":"<approved-route>"}
47
+ {"command":"cancel","stage":"abel-implement","change":"<change>","operationId":"<unique-operation>"}
48
+ {"command":"discard","stage":"abel-implement","change":"<change>","operationId":"<unique-operation>"}
183
49
  ```
184
50
 
185
- <!-- ABEL:END -->
51
+ When the user approves a revised delivery boundary, resume the same run with both `deliveryRevision` and `receiptHash`.
52
+ The engine revalidates retained phase/repair facts, invalidates only incompatible tasks, rebuilds tracking, and preserves compatible work.
53
+
54
+ `status` is local and must remain useful when every Worker endpoint is unavailable.
55
+ Repeating the same operation id returns its committed outcome.
56
+ Use a new operation id for a new attempt.
57
+
58
+ For an approval-needed retained run, a later explicit Implement invocation must inspect local `status`.
59
+ When a newer owner-private-proof-bound receipt is present, status exposes its exact pair in `availableDelivery`, adds `resume` to `legalCommands`, and fills the matching `conditionalCommands` arguments.
60
+ Resume with that discovered pair; do not require the user to copy revision or hash data from a prior Design conversation.
61
+ Discovery never admits the delivery: `resume` still performs the full artifact, traceability, capability, and currentness validation before any Worker starts.
62
+
63
+ ## Execution and verification
64
+
65
+ Before any candidate, the engine records target-contract, task-affected, and full-suite baselines with normalized failure identities.
66
+ A pre-existing failure remains separate and never satisfies Red or becomes evidence that this change caused it.
67
+
68
+ For each ready task the engine runs:
69
+
70
+ 1. Red in a disposable child revision; the declared target must fail with the approved identity.
71
+ 2. Green with the minimum approved implementation; the declared target and task-affected contract must pass relative to baseline.
72
+ 3. Optional Refactor with behavior unchanged and verification still green.
73
+ 4. Parent-owned task completion and exactly one `tasks.md` checkbox update in the private cumulative revision.
186
74
 
187
- 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.
75
+ Independent tasks may merge only after currentness and declared conflict checks.
76
+ Conflicting tasks remain durably queued without spending a Worker attempt.
77
+ Workers only propose complete diffs inside their exact write/delete sets; they never write the workspace, AGENTS, task state, or the main repository.
188
78
 
189
- Record target, affected suite, and full-suite baselines before writing; keep pre-existing failures separate and never attribute them to the task Red.
190
- Red must fail with the expected identity; a wrong reason is a generated implementation-artifact rejection handled by bounded correction.
191
- If a Red candidate passes, classify it as an artifact failure with `code: red-not-witnessed`; a separately proven insufficient verification contract terminally blocks the current task without consuming the artifact correction budget.
192
- After Green the target and affected suite must be green, in Red-Green-Refactor order, with a stable AGENTS index at checkpoints and no new failure relative to the recorded baseline.
193
- A fresh-context handoff validates the Gate receipt, hash, and trace strictly without requesting Gate approval again.
194
- You must not archive, publish, or commit implicitly: only explicit parent actions may do so.
79
+ After all tasks, run every task-affected contract, the approved full suite, output postconditions, and the code-owned managed-only AGENTS checkpoint.
80
+ Only then prepare one journaled, currentness-checked cumulative apply and the declared post-apply verification.
81
+ The main workspace stays unchanged before that transaction.
82
+
83
+ ## Failure attribution and recovery
84
+
85
+ Ordinary failures stay inside this Implement run:
86
+
87
+ - `artifact`, wrong-Red identity, malformed/incomplete diff, stale candidate, or transport failure: use the bounded automatic attempt policy; after exhaustion pause with the last safe code and retain the last committed revision.
88
+ - Artifact correction alone consumes the sealed `artifactCorrection.maxAttempts` of 2-3 total candidate launches per task phase and operation, including the initial launch; a later `resume` starts a fresh operation budget.
89
+ - `environment` or `verification-adapter`: pause without speculative edits.
90
+ Resume after the capability is restored; baseline facts and completed phases are reused.
91
+ - `pre-existing`: keep as baseline evidence.
92
+ It does not authorize a code change and does not fail completion unless the change worsens it.
93
+ - `introduced` in a task-affected contract: reopen the owning task as `repairable`, perform the minimum bounded repair inside its approved paths, record `repair-verified`, and re-run attribution automatically.
94
+ - `unresolved` full-suite attribution: pause with failure identities and retained cumulative state; resume after evidence resolves ownership.
95
+ - `workspace-revision-stale`, conflict, cancellation, process interruption, or apply recovery: preserve user edits and resume from the last durable checkpoint.
96
+ Cancellation is budget-neutral.
97
+ During a partially visible final apply, recovery must settle before pause or discard.
98
+ - `result-limit`: pause as `needs-task-split`; never accept a partial diff.
99
+
100
+ No item above carries stage-routing metadata or asks the user to restart the approved workflow.
101
+
102
+ ## The only approval-needed boundary
103
+
104
+ Use `approval-needed` only when continuing requires authority not present in the sealed delivery: new observable behavior, architecture or policy; a new/changed dependency; an undeclared write/delete/read target; expanded conflict/resource authority; a changed verification contract; an AGENTS target/impact/managed block change; or another irreversible scope decision.
105
+
106
+ Classify only codes in the closed authority table.
107
+ An unknown Worker, verifier, or internal approval code is an `approval-code-invalid` integrity pause; never guess a category or Gate from keywords.
108
+
109
+ Report the exact missing authority and retained run state.
110
+ Do not discard compatible work.
111
+ Expose `approval.category`, `approval.requiredGates`, safe `approval.refs`, and `approval.designRequest` as `/abel-design --change <change>` user guidance only; never invoke Design automatically.
112
+ Bare `resume` is not immediately executable progress while approval is missing, so keep it out of `legalCommands` and expose it only in `conditionalCommands` with a `deliveryRevision` greater than the retained revision and the matching `receiptHash` precondition.
113
+ If the user supplies that newly approved receipt revision, resume the same run with the revision/hash pair.
114
+ A generated artifact defect, endpoint outage, stale snapshot, environment failure, pre-existing failure, introduced in-boundary repair, approved documentation/test edit, or approved AGENTS checkpoint is never `approval-needed`.
115
+
116
+ ## AGENTS and tracking
117
+
118
+ Design-time AGENTS read-only authority does not carry into Implement.
119
+ Gate B seals `none | update-existing | create-index | remove-index`, exact targets, owning task ids, verification, and the complete managed block.
120
+ The parent control plane applies those operations only in the private cumulative revision, preserves all human text outside `<!-- ABEL:AGENTS-INDEX:START -->` and `<!-- ABEL:AGENTS-INDEX:END -->`, and never gives an AGENTS write path to a Worker.
121
+
122
+ Task checkboxes are parent-owned progress facts.
123
+ The loader may normalize only `[x]`/`[X]` to `[ ]` for the sealed task ids when checking the delivery hash; every other byte remains integrity-bound.
124
+
125
+ ## Truthful completion
126
+
127
+ Treat `queued`, `connecting`, `waiting-first-response`, `running`, `validating`, `retrying`, `verifying`, `paused`, `approval-needed`, `applying`, and `recovering` as nonterminal activity states.
128
+ `operation-cancelled` ends only the current operation; `discarded` and `rejected` are non-success terminal run states.
129
+ Tool-call settlement is not success.
130
+ Report success only when the durable state is `completed`, final application and post-apply verification committed, and private run content was cleaned.
131
+ Terminal `completed`, `discarded`, or `rejected` settlement deactivates private dispatch; a nonterminal pause or approval wait keeps it active for direct follow-up.
132
+
133
+ On a nonterminal result, report the safe code, affected task/scope when present, retained progress, and the exact legal command that continues or inspects the same run.
134
+ Never hide an incomplete run behind a success checkmark.
135
+
136
+ Do not archive, publish, release, stage, or commit implicitly.
137
+
138
+ <!-- ABEL:END -->
@@ -1,42 +1,45 @@
1
1
  ---
2
- description: Initialize OpenSpec and AGENTS indexes for an Abel workflow project
2
+ description: Initialize or safely repair an Abel OpenSpec project
3
3
  argument-hint: "[project-path]"
4
4
  ---
5
5
 
6
- Load the bundled `abel-workflow` Skill before inspecting or modifying OpenSpec or AGENTS files.
7
- If that core Skill is unavailable, stop before any write and report an executable package-resource restore or reinstall command.
8
- Read the complete value inside `<abel-request>` without a second whitespace-tokenization pass.
6
+ Load the bundled `abel-workflow` Skill before inspecting or writing the target.
7
+ If it is unavailable, stop before writes and report one executable package restore or reinstall command.
8
+ Read the complete value inside `<abel-request>` without tokenizing it a second time.
9
9
 
10
10
  <abel-request>
11
11
  $ARGUMENTS
12
12
  </abel-request>
13
13
 
14
- The request is an optional project path; when absent, target the current working directory.
15
- Resolve that root before action and preserve unrelated files, all human-authored AGENTS content, baseline dirty state, and nested repository boundaries.
16
- Never overwrite or cross a nested repository boundary merely because it is below the selected root.
17
-
18
- ## Prerequisites
19
-
20
- Select Bun when it is usable; otherwise select npm.
21
- Use that single JavaScript toolchain for the whole run.
22
- If neither is usable, stop with the original probe errors and executable remediation.
23
-
24
- Discover the bundled `context7-auto-research` and `grok-search` Skills.
25
- Record each resolved discovery path when present.
26
- When either is missing, report an actionable package-resource restore or reinstall command, continue OpenSpec initialization and AGENTS repair, and mark the final environment as not fully ready.
27
- A missing research Skill does not prevent OpenSpec initialization or AGENTS repair.
28
- The absence of `git-commit`, external `dev-browser`, or a dedicated `time` Skill does not affect Init readiness; do not check them as Init prerequisites.
29
-
30
- Probe OpenSpec and all CLI capabilities required by the shared workflow.
31
- If OpenSpec is absent, install `@fission-ai/openspec@latest` globally with the selected toolchain (`bun add --global @fission-ai/openspec@latest` or `npm install --global @fission-ai/openspec@latest`), then recheck every required capability.
32
- If installation or the recheck fails, stop, preserve the original error, and report the exact executable remediation command for the selected toolchain.
33
-
34
- ## Initialization
35
-
36
- Initialize or safely update OpenSpec without `--force` or another destructive force option.
37
- Resolve and validate the selected schema and its templates before reporting success.
38
- Create or repair only the verified managed blocks of appropriate root and nested AGENTS indexes, preserving all human-authored text and unrelated content.
39
- You must not edit `openspec/AGENTS.md`.
40
-
41
- Report the resolved project root, selected toolchain, OpenSpec capability results, schema/template validation, AGENTS repairs, research-Skill discovery paths or remediation, and final readiness.
42
- A missing research Skill makes the environment not fully ready even when OpenSpec and AGENTS repair completed.
14
+ The request is an optional project path; when absent, use the current working directory.
15
+ Resolve and report the canonical target root before action.
16
+
17
+ ## Deterministic boundary
18
+
19
+ - Init performs no Subagent or `abel_dispatch` work.
20
+ Probe and repair locally in a fixed order.
21
+ - Preserve the baseline dirty state, unrelated files, all human-authored AGENTS text, and every nested repository boundary.
22
+ - Never use `--force`, replace an existing OpenSpec tree wholesale, follow a symlink escape, or edit `openspec/AGENTS.md`.
23
+ - Choose Bun when usable, otherwise npm, and use only that toolchain for this run.
24
+ If neither works, stop with the original probe errors and an executable remediation.
25
+
26
+ ## Fixed procedure
27
+
28
+ 1. Inspect the canonical root, repository boundaries, OpenSpec presence, project configuration, and root/nested AGENTS marker structure without writing.
29
+ 2. Probe the required OpenSpec CLI capabilities, schema selection, schema validation, templates, status, instructions, and strict validation.
30
+ 3. If OpenSpec is absent, install `@fission-ai/openspec@latest` globally with the selected toolchain (`bun add --global @fission-ai/openspec@latest` or `npm install --global @fission-ai/openspec@latest`), then repeat the complete capability probe.
31
+ If installation or recheck fails, preserve the original error and stop with the exact remediation command.
32
+ 4. Initialize only when no OpenSpec root exists.
33
+ Otherwise repair only missing or mechanically invalid configuration that can be changed without discarding project choices.
34
+ 5. Resolve and validate the selected schema and templates before claiming readiness.
35
+ 6. Create or repair only verified `<!-- ABEL:AGENTS-INDEX:START -->` … `<!-- ABEL:AGENTS-INDEX:END -->` managed regions.
36
+ Preserve every byte of human content outside those markers and do not cross nested repositories.
37
+ 7. Re-run all probes after writes.
38
+ A second identical Init must produce no additional changes.
39
+
40
+ Discover the bundled `context7-auto-research` and `grok-search` Skills and report their resolved paths.
41
+ Their absence does not prevent OpenSpec or AGENTS repair, but final readiness is `partial` and must include an actionable package-resource restore command.
42
+ Do not probe `git-commit`, external `dev-browser`, or a dedicated time Skill; none is an Init prerequisite.
43
+
44
+ Report one final result with the root, selected toolchain, actions actually taken, OpenSpec capability/schema/template evidence, AGENTS files changed or unchanged, research-Skill paths or remediation, and `ready | partial | paused`.
45
+ Never report success from the initial probe when the post-write recheck did not pass.