@abelxiaoxing/cadence 1.3.0 → 1.4.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 (76) hide show
  1. package/README.md +172 -13
  2. package/agents/design-explorer.md +17 -11
  3. package/agents/diagnosis-worker.md +9 -1
  4. package/agents/implementation-worker.md +3 -1
  5. package/config/plan-draft.example.json +122 -0
  6. package/config/plan-draft.multiple-tasks.example.json +345 -0
  7. package/package.json +9 -5
  8. package/prompts/abel-design.md +141 -38
  9. package/prompts/abel-diagnose.md +10 -1
  10. package/prompts/abel-implement.md +118 -20
  11. package/prompts/abel-init.md +9 -2
  12. package/src/activity-contracts.ts +82 -0
  13. package/src/apply-transaction.ts +16 -14
  14. package/src/artifact-store.ts +17 -0
  15. package/src/candidate-artifact.ts +143 -0
  16. package/src/candidate-patch.ts +33 -12
  17. package/src/candidate-workspace.ts +74 -0
  18. package/src/canonical.ts +16 -0
  19. package/src/change-contract-schema.ts +191 -0
  20. package/src/change-contract.ts +273 -0
  21. package/src/change-verification.ts +896 -0
  22. package/src/child-model.ts +129 -0
  23. package/src/child-session.ts +296 -328
  24. package/src/contracts.ts +325 -109
  25. package/src/control-contracts.ts +51 -1
  26. package/src/delivery-compiler.ts +241 -141
  27. package/src/delivery-revision.ts +42 -0
  28. package/src/design-control.ts +182 -15
  29. package/src/design-diagnostics.ts +150 -0
  30. package/src/design-journal.ts +216 -72
  31. package/src/durable-contracts.ts +210 -0
  32. package/src/durable-workflow.ts +963 -0
  33. package/src/evidence-draft.ts +122 -0
  34. package/src/implement-graph.ts +14 -16
  35. package/src/implement-plan.ts +70 -0
  36. package/src/index.ts +341 -1405
  37. package/src/isolation-backend.ts +84 -23
  38. package/src/model-source.ts +22 -0
  39. package/src/package-candidate.ts +224 -0
  40. package/src/package-delivery.ts +486 -0
  41. package/src/package-verification.ts +509 -0
  42. package/src/package-workflow.ts +253 -0
  43. package/src/packet-runtime.ts +27 -48
  44. package/src/parent-provider.ts +86 -198
  45. package/src/phase-execution.ts +2248 -0
  46. package/src/pi-adapter.ts +19 -0
  47. package/src/plan-draft-summary.ts +146 -0
  48. package/src/plan-draft.ts +493 -0
  49. package/src/route-policy.ts +1 -11
  50. package/src/run-state.ts +4 -16
  51. package/src/run-store.ts +5 -144
  52. package/src/scoped-grep-worker.mjs +23 -0
  53. package/src/scoped-tools.ts +312 -116
  54. package/src/sqlite-schema.ts +171 -0
  55. package/src/storage-schema.ts +352 -0
  56. package/src/subagent-activity.ts +46 -67
  57. package/src/submit-tool.ts +40 -61
  58. package/src/task-ledger.ts +14 -55
  59. package/src/transport-budget.ts +32 -0
  60. package/src/verification-capability.ts +298 -102
  61. package/src/verification-environment.ts +213 -0
  62. package/src/verification-identity.ts +77 -0
  63. package/src/worker-broker.ts +134 -91
  64. package/src/workflow-engine.ts +28 -8285
  65. package/src/workflow-policy.ts +1388 -0
  66. package/src/workflow-recovery-policy.ts +95 -0
  67. package/src/workflow-scheduling.ts +105 -0
  68. package/src/workflow-state-machine.ts +4086 -0
  69. package/src/workflow-status.ts +384 -0
  70. package/src/workspace-io-entry.mjs +58 -0
  71. package/src/workspace-io-worker.mjs +991 -0
  72. package/src/workspace-io.ts +84 -0
  73. package/src/workspace-store.ts +125 -19
  74. package/skills/abel-workflow/SKILL.md +0 -205
  75. package/src/empty-resource-loader.ts +0 -38
  76. package/src/parent-payload-bridge.ts +0 -523
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  **Cadence** 是一个面向 Pi 的规范驱动四阶段工作流扩展包,内置可恢复的私有代理编排:
7
7
 
8
8
  - `/abel-init [project-path]` — 本地、固定顺序且幂等地初始化或安全修复 OpenSpec 与 AGENTS 托管索引,不派发子代理。
9
- - `/abel-design <requirement> | --change <change_name>` — 使用有界只读证据包解决行为与技术决策,生成经 Gate A(WHAT)和 Gate B(HOW)批准的 canonical delivery;不启动实现 Worker,不运行产品测试,也不修改产品代码。
9
+ - `/abel-design <requirement> | --change <change_name>` — 使用有界只读证据包解决行为与技术决策,生成绑定 Gate A 用户授权与 Gate B 系统计划证明的 canonical delivery;不启动实现 Worker,不运行产品测试,也不修改产品代码。
10
10
  - `/abel-implement <change_name>` — 在私有不可变 revision 中执行已批准的 Red-Green-Refactor DAG,累计验证全部任务后才通过一次可恢复事务写入主工作区。
11
11
  - `/abel-diagnose <problem-description>` — 独立执行“复现 → 证伪 → 失败回归 → 最小修复”,不充当 Implement 的失败路由。
12
12
 
@@ -14,17 +14,38 @@
14
14
  加载本包会注册一个私有扩展与三个包内专业 Agent;`abel_dispatch` 工具注册但保持未激活,只有用户显式调用且包来源验证通过的 Design、Implement 或 Diagnose prompt 才会激活它。
15
15
  仓库中存在 Abel 文件、OpenSpec change、AGENTS 索引或普通文本都不会启动工作流;Init 也不会激活派发工具。
16
16
 
17
- 共享工作流规则统一收录于包内 `abel-workflow` Skill;其发现信息同样明确要求先有显式 `/abel-*` 调用。
17
+ 四个命令各自包含本阶段需要的操作指引,不再依赖共享工作流 Skill;普通任务不会从技能列表中自动选用 Abel 工作流。
18
+ Gate、交付校验和执行状态转换由控制面代码保证。
19
+ 只有用户通过交互输入或 RPC 显式提交对应斜杠命令才允许激活;扩展生成的命令不会展开工作流。
20
+ 当前任务的 Gate 回答与续轮保持阶段有效;用户结束工作流或转向无关任务时,父模型先调用 `{"action":"finish"}`,扩展等待活动操作停止并恢复原工具,保留可恢复进度。
21
+ 此退出同样适用于 Implement,不表示完成或丢弃。
22
+ 显式调用 Init 也会先退出已有阶段。
18
23
 
19
24
  Implement 只暴露 `start`、`status`、`resume`、`rebind`、`cancel` 和 `discard` 控制命令。
20
25
  `status` 完全本地可用;相同 operation id 幂等重放,进程、会话或 Worker 更换后仍从 durable checkpoint 继续。
21
26
  Design 从第一步起统一使用 `action: "design"`:新需求通过 `start(requirement)` 进入,已有 change 通过 `start(change)` 进入,后续只携带返回的 `runId`。
22
27
  需求、决策合同与 Gate A 合同由控制面规范化并计算哈希,调用方无需 SHA-256 工具;Gate B 自动绑定当前已编译 canonical plan,原始瞬时文本不会写入 durable journal。
23
28
  `validate-plan-draft` 可在 `compile-plan` 前只读运行同一套编译检查,并以结构化 `taskId` / phase / field / verification 诊断定位问题;Design finalization 的安全诊断码也会进入错误详情与可展开 TUI,而不再只显示统一失败标题。
29
+ 随包提供的 [单任务计划示例](config/plan-draft.example.json) 展示精简 PlanDraft 和结构化 Gate A 合同;按实际仓库替换示例中的路径、证据与验证命令。
30
+ 草稿可省略 `tracking`、阶段 `verificationInputs` 和现有测试的 `disposition`,编译器按任务、验证契约和已声明产物生成这些机械字段;已批准的 `changeContract` 由控制面继承,无需重复填写。
31
+ 原子验证命令可放在 `verificationDefinitions` 中,用 `{ "use": "name" }` 在各验证义务引用;Red 的 `expectedFailure` 仍需明确填写。
32
+ 内联原子验证也可省略 `id` / `classification`;任务公共 `read` 与阶段读取合并,固定 baseline/repair 保护字段由编译器补齐,恢复次数和 AGENTS 影响仍需作者明确选择。
33
+ [多任务示例](config/plan-draft.multiple-tasks.example.json) 保留显式依赖和产物 producer;ordered steps 仍使用完整内联合同。
34
+ `validate-plan-draft` 返回有界的最终权限、验证用途、恢复次数和实际派生来源摘要;摘要不充当批准或封存证明。
35
+ 推导有歧义时拒绝编译,显式错误仍会报错;代码不会据此扩大路径、依赖或产物权限,封存计划保持完整、严格的结构。
36
+ 预检集中返回不同任务的独立结构错误,并提供字段位置、期望/实际路径和修正提示;工具反馈与 TUI 共用有界脱敏投影。
24
37
  Design status 将可调用的 `legalOperations` 与顶层 `packetActions` 分开;显式退出只能发送 `{"action":"finish"}`,不能伪装成 `operation: "finish"`。
25
38
 
26
39
  普通 artifact、错误 Red、transport、environment、stale、conflict、baseline 与验证失败都留在同一 Implement run 中恢复。
27
- 累计验证发现 introduced failure 时会自动重开责任任务做有界修复;自动预算耗尽后 `resume` 复用已有 baseline 和 phase facts。
40
+ 累计验证发现 introduced failure 时会自动重开责任任务做有界修复。
41
+ artifact、stale candidate 与 verification 纠错会将具体失败码、修复策略和可用失败身份传给下一次 Worker。
42
+ 自动恢复预算以验证义务和阶段为依据,使用独立 SQLite 事实保存;普通 `resume`、重启、回滚、换路由、任务重命名和合同改写都不能重置额度。
43
+ 执行前持久化预留工作额度;内部修复也计入同一 run 的有限资源预算。
44
+ 系统保留 baseline 和 phase facts,并明确区分缺少能力、缺少决定与恢复额度耗尽。
45
+ Worker 可读取同一任务各阶段已批准路径的并集,并按需申请 sealed roots 内的普通文件读取;新增读取会绑定合并与最终应用的 currentness,写入和删除仍限于当前阶段;超大补丁先自动尝试紧凑的完整提交,不能完整提交时保留进度,绝不接受部分补丁。
46
+ Design 对明确需求尽量只进行一轮集中决策:先调查仓库约定,再一起呈现目标、关键技术取舍、推荐默认值及编译授权;编译器在记录有效计划时原子生成 Gate B 证明,无需第二次用户确认。
47
+ 相同计划重编译和仅修改决策引用不会重开 Gate。
48
+ 已完成 change 的新修订从同一 root/change 的最新私有 finalized delivery 继承未变化的决策与授权;仅技术变化保留 Gate A,行为契约变化仍重新生成相应证明。
28
49
  Design 证据包必须绑定 durable `runId`;接受后的有界证据、决策版本、Gate 证明与 canonical plan 身份写入 owner-private journal。
29
50
  Design 激活期间,父模型只保留进入前已启用的 `read`、`grep`、`find`、`ls` 与 `abel_dispatch`;原工具集合会在 finalize、finish、切换阶段或 session 结束时精确恢复。
30
51
  Implementation Worker 不再手写 unified-diff header、hunk range、分段或哈希;它一次提交有序的 `replace`、`rewrite`、`create`、`delete` 操作。
@@ -33,20 +54,62 @@ OpenSpec change 制品只能通过私有 `write-artifact` / `delete-artifact`
33
54
  Gate A/B 收据只有一套 canonical 结构,并在 Implement admission 时同时对照同一 root/change 的私有批准事实与 finalization revision/hash 事实验证。
34
55
 
35
56
  只有继续工作确实需要新增行为、架构/策略、依赖、路径、资源、验证或 AGENTS 权限时才进入 `approval-needed`。
36
- 结果保留原 Implement run,明确给出 authority category、所需 Gate、引用和 `/abel-design --change <change>` 用户指引;不会自动调用另一阶段。
37
- `resume` 只作为带有更高 `deliveryRevision` 与匹配 `receiptHash` 的条件命令出现。
38
- 用户显式完成 Design 后,新的 Implement 上下文会通过本地 `status` 自动发现 proof-bound 的精确 revision/hash,再对同一 run 做完整 admission 与 resume;不依赖复制上一次会话内容。
39
-
40
- 交互式 TUI、print、JSON 和 RPC 都以 durable semantic state 为准。
41
- queued、connecting、waiting-first-response、running、validating、retrying、verifying、paused、approval-needed、applying 和 recovering 都不是完成;operation-cancelled 表示本次操作取消但 run 仍可恢复,discarded 与 rejected 是非成功终态。
57
+ Design 完成主要决策后,Implement 中的新实施选择默认由父模型采用推荐方案,记录后继续执行;不再默认向用户追问。
58
+ 状态一次返回完整 `blockers`、稳定的 `decisionBatch`,并明确由父模型负责执行自动 `continuation`。
59
+ 父模型通过当前 Implement 内的 `action: "amend"` 修订同一 change、自动生成计划证明,再由普通 resume 发现并验证新交付;无需切换命令、重新确认或手动传递收据。
60
+ 交付校验失败和任务过大也能进入该修订通道,不必伪装成用户决策。
61
+ 修订有独立的持久化预算:每个 run 最多 64 次变更尝试,失败也计数,成功操作重放和只读检查不计数。
62
+ 自动修订保留 Design 目标、明确限制与验收标准;Worker 仍必须等待新计划通过完整校验才能使用新权限。
63
+ 新证明尚未就绪时,`resume` 只列为条件命令;证明就绪后可直接恢复,由控制层读取版本和哈希。
64
+ 增量修订或用户主动选择的 Design 完成后,新的 Implement 上下文都能本地发现并校验交付,继续同一 run。
65
+
66
+ 交互式 TUI、print、JSON 和 RPC 都保留 durable semantic state;父模型有自动继续动作时,TUI 显示 recovering,不把内部待编译状态显示成用户待确认,也不提示用户手动 resume。
67
+ queued、preparing、waiting-first-response、running、validating、retrying、verifying、paused、approval-needed、applying 和 recovering 都不是完成;operation-cancelled 表示本次操作取消但 run 仍可恢复,discarded 与 rejected 是非成功终态。
42
68
  只有最终 apply 与 post-apply verification 提交后的 `completed` 才显示成功。
43
- Design finalization、Implement 终态、Diagnose/显式 `finish` 或 session shutdown 会清除 active stage 与 parent bridge;Design 还会恢复进入前的精确父工具集合,其他阶段只撤下 `abel_dispatch`。
69
+ Design finalization、Implement 终态、Diagnose/显式 `finish` 或 session shutdown 会清除 active stage 与私有子执行状态;Design 还会恢复进入前的精确父工具集合,其他阶段只撤下 `abel_dispatch`。
44
70
  Gate 等待和可恢复暂停保持激活以接收直接后续操作。
45
71
 
46
72
  私有 journal、artifact 与 change workspace 位于 consumer repository 之外的 owner-private state root。
47
73
  暂停会保留最小结构化恢复事实;完成或显式 discard 后安全清理。
48
74
  不会持久化凭据、环境值、原始 prompt、隐藏推理、完整子会话或原始模型输出。
49
75
 
76
+ ## 内部边界与运行验证
77
+
78
+ 扩展入口负责宿主生命周期与服务装配,交付加载和验证适配器分别由独立模块负责。
79
+ 工作流入口保留原有导出,状态机仍是唯一状态转换权威;执行服务通过类型化接口返回事实。
80
+ 状态机读取运行与预算事实,独立的 `workflow-status.ts` 纯函数生成状态、阻塞批次及继续动作,不访问存储或启动执行。
81
+ 普通阶段和修复阶段共用 `candidate-artifact.ts` 校验、封存候选;恢复旧候选仍按当前批准路径检查,调用方分别处理普通越界和修复权限扩展。
82
+ 测试检查模块依赖无环,以及子会话无法导入主工作区应用和 run 状态权限。
83
+
84
+ Implement 父模型属于受信任的宿主编排层,保留原有工具以调查和修复已授权的环境问题;产品修改应通过控制面完成。
85
+ 子 Worker 和控制面执行路径有代码边界;父模型直接使用宿主工具不经过这些路径,阶段指令约束其行为。
86
+ 只有 Design 会收紧父工具。
87
+ 结构化验收固定验证义务,目标是否被充分覆盖仍取决于验收测试的质量。
88
+
89
+ 新身份统一采用 UTF-16 码元排序,不依赖宿主语言环境。
90
+ 旧 workspace manifest 按已保存的条目顺序验证原身份;已绑定批准证明的历史交付可保留原有集合顺序,仍需验证原始字节哈希和私有批准事实。
91
+ 普通交付解析保持严格规范化。
92
+
93
+ 私有 SQLite 表结构集中声明,打开时检查必需列、类型、空值约束、主键、唯一键、外键和 STRICT 属性;已支持的补列在同一事务中执行。
94
+ 结构不符会在业务操作前拒绝,不自动重建或清空已有状态。
95
+
96
+ 原生 I/O 线程以预构建的纯 JavaScript 随包发布,安装到 node_modules 后无需运行时 TypeScript 加载器。
97
+ `bun run check` 会检查线程构建产物是否与源码一致;修改相关源码后运行 `bun run build:workspace-io` 更新。
98
+ Git 快照与工作区物化由可信本地 I/O 线程执行,不占用宿主事件循环;Git 枚举默认限制为 30 秒,支持取消,线程退出后才返回。
99
+ 物化优先使用写时复制,始终使用独立 inode 并验证复制内容。
100
+ 元数据查询只校验 manifest,实际使用产物时再校验字节;未变更文件继续由保留的祖先 revision 持有,整个 run 的私有数据仍在终态统一清理。
101
+
102
+ Linux CI 单独安装并要求 Bubblewrap,验证实际隔离边界、后代进程取消,以及 Red → 状态重开 → Green → 累计验证 → Apply → Post-apply。
103
+ 可在已配置 Bubblewrap 的 Linux 主机本地运行:
104
+
105
+ ```sh
106
+ CADENCE_REAL_ISOLATION=1 bun run test:target test/isolation-real.integration.test.ts
107
+ node --experimental-strip-types scripts/benchmark-workspace.mjs 1000
108
+ ```
109
+
110
+ 基准输出快照、物化耗时、文件数、字节数及父事件循环延迟;耗时取决于文件系统和仓库大小。
111
+ 真实隔离测试显式启用后,缺少可用后端会失败,不会跳过。
112
+
50
113
  ## 安装(Install)
51
114
 
52
115
  ### 在 pi 中快速安装(推荐)
@@ -69,7 +132,8 @@ npm install -g @abelxiaoxing/cadence
69
132
  - **本地包目录(local package directory)** — 将 Pi 指向本仓库的绝对路径或相对路径(absolute or relative path,例如 `./cadence`),Pi 发现同样的资源。
70
133
  - **已安装 tarball 目录(installed tarball directory)** — 运行 `bun pm pack --destination <tmp>` 生成真实 tarball(.tgz),安装或解压到隔离目录后指向该目录;tarball 文件本身永远不会被当作本地包传给 Pi。
71
134
 
72
- 本包要求 Node.js `>=22.13.0`,以使用稳定可用的内置 `node:sqlite`;不从参考仓库源安装,也不维护 Pi 主机版本兼容矩阵。
135
+ 本包要求 Node.js `>=22.13.0`,以使用稳定可用的内置 `node:sqlite`;不从参考仓库源安装。
136
+ Pi 相关 peer 依赖使用 `*`,不限制宿主 Pi 的版本;开发依赖的固定版本仅用于仓库构建与测试。
73
137
 
74
138
  ## OpenSpec 启动与平台范围
75
139
 
@@ -119,10 +183,28 @@ bun run test:target test/openspec-cli.test.ts test/design-delivery.integration.t
119
183
  一旦显式文件存在,它就是完整策略;损坏、缺字段或角色引用不一致会 fail closed,不会悄悄退回默认父模型。
120
184
  旧配置的顶层数字标记 `2` 会被安全迁移为当前 canonical 结构;其他编号会以专用诊断码明确拒绝。
121
185
  inherited route 声明的能力会与当前父模型真实能力取交集,不能通过夸大的配置绕过 admission。
122
- transport 与 malformed structural result 都只在声明的 route 顺序内做有界 failover;只有一个 route 时会原地重试一次,多个 route 时按顺序切换。
186
+ Implement 保留 16,000 context / 8,000 output 的最低容量要求;任务复杂度估算只影响自动选择的优先级,满足最低要求的 route 仍可作为 fallback 或显式 rebind。
187
+ transport 与 malformed structural result 都只在声明的 route 集合内做有界 failover;优先选择达到容量估算的 route,同一优先级保持声明顺序,只有一个 route 时会原地重试一次。
188
+
189
+ 子任务由 Cadence 自己维护模型/工具循环,通过 `pi-ai` 公开接口请求完整响应,不创建 Pi `AgentSession`、覆盖 Agent 钩子或扫描宿主事件历史决定终止。
190
+ 模型流事件只用于进度与完整响应适配;只有正常完整响应的工具调用可以执行,错误、截断或取消不得提交产物。
191
+ 继承路由快照当前有效 Provider、模型及每次 attempt 新鲜解析的认证,不修改父 Provider 注册表,也不要求父请求预热。
192
+ Provider 自身的流式实现和模型配置仍然生效;宿主 session 的 `before_provider_request`/`onPayload` 不会自动移植到子任务。
193
+ 需要通用请求定制时,应使用明确配置的 Provider 实现或 custom route;子请求使用自己的 `low` reasoning 请求,最终由模型映射解释。
194
+ 输出上限沿用声明的模型/Provider 合同,不再隐式删除 Responses 的 `max_output_tokens`。
195
+
196
+ 子 Agent 的 evidence 提交使用精简草稿:工具绑定省略的身份,补齐未提供的提示性字段,然后按严格内部结果合同校验。
197
+ 引用、约束、风险和未决问题仍须显式提供;省略提示不等于已验证的“没有影响”,也不增加授权。
198
+ 一次被拒绝的提交可在原会话纠正一次;只有正常以文字结束且从未提交时,才额外提示补交一次。
199
+ 补交沿用原工具权限、总时限、取消和用量统计,不重新调查,不把文字直接当作交付;传输错误、截断和取消不触发补交。
200
+ 合法提交可附带简短文字,但接受后不得重复提交或覆盖结果。
201
+
123
202
  相同 pause 的安全指纹与重复计数通过 `status` 暴露,凭据、URL 和原始输出仍保持私有。
124
203
  `rebind` 只能选择已获 policy 授权且能力匹配的 route,不会扩大任务边界。
125
204
 
205
+ 验证归因使用完整失败集合;大基线以哈希校验的私有 artifact 持久化,Worker 和状态只接收最多 256 条失败摘要。
206
+ 非 Vitest 失败身份由执行入口、参数和失败证据决定,不受合同显示 ID 影响。
207
+
126
208
  ## 跨项目验证合同(Cross-project verification)
127
209
 
128
210
  Cadence 不要求 consumer repository 提供 `check` 或 `test:target` 脚本。
@@ -186,10 +268,87 @@ bun run check:agents # AGENTS 索引校验
186
268
 
187
269
  ```sh
188
270
  bun run verify # check && lint && test && pack:check(发布前全套校验)
189
- bun run pack:check # 真实 tarball 53 成员清单校验
271
+ bun run pack:check # 真实 tarball 56 成员清单校验
190
272
  bun run traceability:check # 162 条 active Requirement/Scenario 引用精确解析且唯一归属
191
273
  ```
192
274
 
193
275
  ## 许可(License)
194
276
 
195
277
  MIT — 详见 [LICENSE](LICENSE) 与 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
278
+
279
+ ## 验证执行环境与明确恢复
280
+
281
+ 验证使用独立 HOME、Vite 缓存和报告目录;consumer 依赖保持只读。
282
+ Vitest 的 JSON 报告与普通 stdout/stderr 分离,日志超过捕获预算只截取头尾,不终止正常测试。
283
+ 报告缺失、损坏或超限属于验证不可用,不作为产品失败基线或自动改代码的理由。
284
+ 已封存候选在环境故障后可重新验证,并在存储重开后复用;即使自动生成次数已耗尽,普通 resume 仍可只复验该候选,不启动新的补丁生成。
285
+ 非 Vitest 的 Red 证据通过有界流式匹配保留,不受日志头尾截取影响。
286
+ 完整的已批准 package-script 可包含组合命令、引号和嵌套脚本;包管理器在隔离环境中解释,manifest、lockfile 和项目配置绑定 currentness。
287
+ 配置注释和普通值不触发禁用词检查;有效的凭据或宿主执行配置仍被拒绝。
288
+ 计划已授权的 manifest/配置写入可在隔离候选中验证;未授权路径仍需匹配设计时哈希,实际入口脚本仍必须与批准命令相同,执行期间的输入漂移仍会使验证失效。
289
+ 专门的 Vitest 合同仍拥有 JSON reporter、测试数量及 Red 身份检查,复合脚本不会自动获得断言级语义。
290
+
291
+ 自动纠错耗尽后,普通 resume、rebind 和重启不充值。
292
+ 父代理可使用 status 返回的 `recovery.additionalAttempt`,作为 resume 的 `recovery` 字段明确追加一次尝试;失败后再次暂停,历史消耗保持。
293
+ 累计工作额度按成功接纳过的最大阶段数增长,任务重命名、重复编译及缩小后恢复原规模不增加额度。
294
+ 宿主可在启动前设置 `ABEL_WORK_MAX_UNITS`(默认 512)和 `ABEL_VERIFICATION_MAX_REPORT_BYTES`(默认 67108864);Worker 不能调整这些资源设置。
295
+ 前者在 run 中固定,后者用于每次独立报告的有界读取。
296
+
297
+ ## 结构化授权与验证模式
298
+
299
+ 新 Design 的 Gate A 使用 `ChangeContract`:目标、稳定验收 ID 与验证义务、明确限制,以及允许的写入范围、依赖和验证模式。
300
+ 控制面保存规范化的非敏感权威值并注入计划;重排任务不能删除验收或扩大政策。
301
+ 自动 amendment 保留 Gate A,不能改写已接受的 proposal/spec 或行为决定。
302
+ 旧文本授权继续可读,其修订保留原有验证义务与保守范围。
303
+
304
+ 任务默认 `verificationMode: "behavior"`,继续执行 Red/Green。
305
+ 明确授权的 `mechanical` 和 `refactor` 模式采用基线与后置验证,从 Green 开始,不生成 Red 候选。
306
+ 机械修改限于文档、数据与配置文件;重构不能改写已接受的验证入口;声明公共行为变化时仍需 Red。
307
+ 全部模式保留累计验证与事务应用。
308
+
309
+ 验证证据现在绑定安装后的依赖内容、runner 和适配器政策。
310
+ 依赖身份采集在可取消 I/O 线程中执行;工具缓存不参与身份。
311
+ 环境漂移会暂停验证,恢复后重建基线并重验保留阶段。
312
+
313
+ ## 真实模型工作流评估
314
+
315
+ 开发仓库提供独立评估入口,消费项目和 Git 历史均在临时目录创建,结束后清理。
316
+ 默认只验证真实 Pi 的包来源与命令激活,不调用模型:
317
+
318
+ ```sh
319
+ bun run eval:workflow
320
+ bun run eval:workflow --live --scenario small-fix --output /tmp/cadence-evaluation.json --progress-output /tmp/cadence-progress.json
321
+ bun run eval:workflow --live --scenario multiple-tasks
322
+ bun run eval:workflow --live --scenario restart-recovery
323
+ bun run eval:workflow --live --scenario missing-capability
324
+ ```
325
+
326
+ `--live` 使用 Pi 当前配置的模型,也可传 `--model provider/model`;需要可用的 Provider、OpenSpec 和 Linux Bubblewrap。
327
+ 报告记录完成状态、用户介入、重复修订、耗时及宿主报告的 token/成本;最终行为另由隔离 oracle 检查。
328
+ `trace` 提供有界的工具/操作计数、安全错误分类、阶段里程碑、重复提交、工具活动区间并集和消息 usage;截止时冻结快照,未到达的里程碑为 null。
329
+ 非工具时间不是纯模型计算时间。
330
+ `configurations` 记录实际模型、reasoning 和非秘密路由指纹,`sourceSha256` / `sourceUnchanged` 标识工作树版本和运行期间是否变化。
331
+ 可选 `--progress-output` 每 15 秒写一份有界进度快照;无原始参数、提示或响应正文。
332
+ 源码读取统计只覆盖明确的成功 read,未分类访问不能当作零。
333
+ `modelFailureDiagnostics` 最多保留 16 条脱敏错误分类及可从 SDK 错误文字识别的 HTTP 状态;无法识别时明确记录 `unclassified` / `null`。
334
+ `autoRetries` 与 `retryDelayMs` 单独记录宿主自动重试次数和计划退避时间,避免把同一请求的多次失败误读为独立故障。
335
+ 模型服务不可用、阶段停滞、取消与 Design 完成都不会被计为 Implement 成功。
336
+ 缺少能力的场景用于观察保留状态,不能把任意停滞当作正确恢复。
337
+ 无原始对话落盘。
338
+
339
+ ## 内部架构与请求预算
340
+
341
+ `PlanDraft` 只表示作者输入,`ImplementPlan` 独立定义完整执行合同;命名引用和默认值仅在编译入口展开,旧封存计划不被重写。
342
+ PlanDraft 的命名或内联 package-script 可以省略 `command`,编译器从 manifest 绑定脚本原文后生成身份;显式不匹配仍拒绝,Gate A 的完整验证合同不被替换。
343
+ 作者在 `tasks.md` 保留任务 checkbox、目标和精确 Scenario 归属;`compile-plan` 生成独立的验证 ID 绑定区域,保留作者正文,并在两份文件安装成功后记录编译。
344
+ 旧封存交付仍可读取;缺失作者证据或篡改绑定不能通过追溯检查。
345
+ `workflow-state-machine` 继续独占 run/task 状态转换与预算事务;调度、恢复策略和交付差异比较使用只接受事实的内部函数。
346
+ `durable-workflow` 管理资源生命周期和交付重放,`phase-execution` 执行候选阶段,`change-verification` 管理基线及变更验证;阶段服务没有主工作区 apply 能力。
347
+ Pi 入口负责激活、工具交互、模型能力投影和展示;`package-workflow` 组合控制服务,`package-candidate` 执行受限候选请求,核心不接收 Pi 会话事件或完整宿主上下文。
348
+
349
+ 每次模型请求独立计时:90 秒内没有非空文本、思考或工具参数增量时返回 `first-progress-timeout`;已有进展后空闲 180 秒返回 `stream-idle-timeout`。
350
+ HTTP 响应头用于观察,不刷新进展预算;完整终态可直接结束请求,本地工具执行间隙不计入流空闲,下一轮重新计时。
351
+ Broker 保留每 attempt 20 分钟总上限和原有有限重试;该上限不代表跨重试的 workflow 总时限。
352
+ 新请求不再发出 `connect-timeout`,也不声称观测到了 TCP/TLS 建连;旧超时事实和 `connecting` 展示仍可读取。
353
+ 子执行器限制为 64 轮、4 MiB 序列化上下文,不自动压缩或静默截断证据;达到限制返回执行限制失败,候选任务暂停并要求拆分,不作为端点故障重试。
354
+ 取消后的用量结算最多等待 250 ms,迟到结果不能进入候选提交或主工作区应用。
@@ -5,18 +5,24 @@ You are a package-owned read-only professional Agent for the `abel-design` stage
5
5
  You explore the repository ONLY through the scoped `read`, `grep`, `find`, and `ls` tools.
6
6
  You have no shell, edit, Git, network, or validation capability, and you never create or modify files.
7
7
 
8
- Call `abel_submit_result` exactly once with one structured object.
9
- Do not emit a second submit, prose, or fields outside the declared Design evidence schema.
10
- The object contains the matching `id`, `role: "design-explorer"`, `kind: "evidence"`, and:
8
+ Submit one accepted final result through `abel_submit_result`; brief accompanying text is harmless.
9
+ If the tool rejects your submission, use its error to correct once in this same disposable session.
10
+ A second rejected structural submission ends the session.
11
+ Never submit again after acceptance.
11
12
 
12
- - `packet_id` (exactly equal to the request id), `module_name`, `scope`, and
13
- `files_read`;
14
- - `evidence`, where every item has `claim`, `path`, `line_start`, and
15
- `line_end`;
16
- - `existing_structures`, `existing_conventions`, `constraints_discovered`,
17
- `open_questions`, and `dependencies`;
18
- - `write_set_hints`, `validation_hints`, `agents_impact_hints`, `risks`, and
19
- `success_criteria_hints`.
13
+ Required draft fields:
14
+
15
+ - `module_name`: a canonical workspace-relative module path or slug;
16
+ - `scope` and `files_read`: unique workspace-relative paths, with nonempty scope;
17
+ - `evidence`: cited claims with `claim`, `path`, positive `line_start`, and inclusive `line_end >= line_start`;
18
+ - `constraints_discovered`, `open_questions`, and `risks`: explicit arrays (use `[]` only when there are none).
19
+
20
+ Omit `id`, `packet_id`, `role`, and `kind`: the trusted tool binds them to this packet.
21
+ If supplied, they must match the declared identity.
22
+ Optional advisory arrays are `existing_structures`, `existing_conventions`, `dependencies`, `write_set_hints`, `validation_hints`, `agents_impact_hints`, and `success_criteria_hints`.
23
+ Omission means no advisory information supplied, not a verified absence or authorization.
24
+ Do not invent evidence or drop unresolved questions to satisfy the format.
25
+ Do not add undeclared fields.
20
26
 
21
27
  You never return raw transcripts, hidden reasoning, or tool-call history.
22
28
  A packet is complete only when every claim is cited and every blocking question is explicit.
@@ -6,8 +6,16 @@ You collect evidence and falsify candidate root causes ONLY through the scoped `
6
6
  You never write, execute commands, or run validation.
7
7
  The fixed algorithm order is reproduce, falsify, failing-regression, then minimum-repair.
8
8
 
9
- An evidence packet submits exactly one compact structured evidence object through `abel_submit_result` with the reported symptoms, candidate causes, confirming or refuting citations, and a supported root-cause conclusion or an explicit evidence gap.
9
+ An evidence packet submits one accepted compact structured evidence object through `abel_submit_result` with the reported symptoms, candidate causes, confirming or refuting citations, and a supported root-cause conclusion or an explicit evidence gap.
10
10
  Only the parent may claim that command-based reproduction succeeded.
11
+ For evidence, omit `id`, `role`, and `kind`; the tool binds them.
12
+ Keep `conclusions`, `citations`, `constraints`, `risks`, and `blockingQuestions` explicit.
13
+ `dependencies` and `hints` may be omitted when no advisory information is supplied.
14
+ If supplying hints, use `writeSet`, `verification`, and `agentsImpact` (`none`, `update-existing`, `create-index`, or `remove-index`).
15
+ Omission never proves the absence of an impact.
16
+ After a rejected evidence or patch submission, use the error to correct once in this same disposable session.
17
+ A second rejected structural submission ends the session.
18
+ Never submit again after acceptance.
11
19
 
12
20
  A candidate packet submits one complete structured patch: either the failing regression or, after the parent has verified that regression, the minimum repair.
13
21
  Use ordered `replace`, `rewrite`, `create`, and `delete` operations inside the approved write set.
@@ -8,7 +8,7 @@ You never write the workspace, run validation, or execute commands.
8
8
  Your output is one complete structured patch delivered through `abel_submit_result`:
9
9
 
10
10
  - copy the attempt-bound `candidateId` from the phase contract;
11
- - submit exactly one `candidate-patch` call containing that `candidateId` and
11
+ - submit one accepted `candidate-patch` call containing that `candidateId` and
12
12
  an ordered `operations` array;
13
13
  - use `replace` with exact uniquely occurring `oldText` and the intended
14
14
  `newText` for compact edits, `rewrite` for a complete existing-file body,
@@ -32,6 +32,8 @@ Your output is one complete structured patch delivered through `abel_submit_resu
32
32
 
33
33
  If the submit tool rejects malformed operations, use its concrete error to correct the submission once in this same disposable session; a second rejected structural submission ends the session.
34
34
 
35
+ Never submit again after acceptance; brief accompanying text is harmless.
36
+
35
37
  If the configured candidate limit is exceeded, the submit tool returns terminal typed `result-limit` with `limitBytes`; never continue with a partial or truncated patch.
36
38
  The parent alone reviews, applies, and validates the generated diff.
37
39
  You report candidate facts only and never claim execution success, select parent recovery, choose a workflow stage, or control the task DAG.
@@ -0,0 +1,122 @@
1
+ {
2
+ "changeContract": {
3
+ "goal": "Fix integer addition while preserving the existing zero case",
4
+ "acceptance": [
5
+ {
6
+ "id": "integer-addition",
7
+ "statement": "add(2, 3) returns 5 and add(0, 0) remains 0",
8
+ "verification": {
9
+ "kind": "static-check",
10
+ "id": "add-acceptance",
11
+ "runner": {
12
+ "kind": "node",
13
+ "script": "test/add.test.mjs"
14
+ },
15
+ "args": [],
16
+ "classification": "expected-green"
17
+ }
18
+ }
19
+ ],
20
+ "constraints": [
21
+ {
22
+ "id": "no-dependencies",
23
+ "statement": "Keep the existing function signature and add no dependencies"
24
+ }
25
+ ],
26
+ "policy": {
27
+ "writeRoots": ["src/add.mjs", "test/add.test.mjs"],
28
+ "dependencies": [],
29
+ "verificationModes": ["behavior"]
30
+ }
31
+ },
32
+ "changeId": "fix-integer-addition",
33
+ "tasks": [
34
+ {
35
+ "taskId": "fix-add",
36
+ "dependsOn": [],
37
+ "objective": "Preserve the existing zero assertion; add a failing positive-integer assertion with [ADD:positive-integers], then fix addition",
38
+ "context": {
39
+ "agents": "No AGENTS.md in this example consumer; use the actual repository instructions when adapting",
40
+ "contract": "Gate A integer-addition acceptance; only src/add.mjs and test/add.test.mjs may change"
41
+ },
42
+ "roots": ["."],
43
+ "phases": {
44
+ "red": {
45
+ "write": ["test/add.test.mjs"],
46
+ "delete": [],
47
+ "verification": {
48
+ "use": "add-test",
49
+ "expectedFailure": "[ADD:positive-integers]"
50
+ }
51
+ },
52
+ "green": {
53
+ "write": ["src/add.mjs"],
54
+ "delete": [],
55
+ "verification": {
56
+ "use": "add-test"
57
+ }
58
+ }
59
+ },
60
+ "affectedVerification": {
61
+ "use": "add-test"
62
+ },
63
+ "repairVerification": {
64
+ "use": "add-test"
65
+ },
66
+ "scheduling": {
67
+ "conflicts": [],
68
+ "resources": []
69
+ },
70
+ "agents": {
71
+ "impact": "none"
72
+ },
73
+ "approvedDependencies": [],
74
+ "impactClosure": {
75
+ "changedSurfaces": ["none"],
76
+ "searchEvidence": [
77
+ "Example consumer: src/add.mjs exports add; test/add.test.mjs is its only caller and existing test"
78
+ ],
79
+ "relatedTests": [
80
+ {
81
+ "path": "test/add.test.mjs",
82
+ "evidence": "Existing add(0, 0) assertion passes; preserve it while adding the positive-integer regression"
83
+ }
84
+ ],
85
+ "affectedSuite": ["test/add.test.mjs"]
86
+ },
87
+ "read": ["package.json", "src/add.mjs", "test/add.test.mjs"]
88
+ }
89
+ ],
90
+ "outputs": [],
91
+ "verification": {
92
+ "baseline": {
93
+ "fullSuite": {
94
+ "use": "add-test"
95
+ }
96
+ },
97
+ "change": {
98
+ "fullSuite": {
99
+ "use": "add-test"
100
+ },
101
+ "postApply": {
102
+ "use": "add-test"
103
+ }
104
+ },
105
+ "artifactCorrection": {
106
+ "maxAttempts": 2
107
+ },
108
+ "repair": {
109
+ "maxAttempts": 1
110
+ }
111
+ },
112
+ "verificationDefinitions": {
113
+ "add-test": {
114
+ "kind": "static-check",
115
+ "runner": {
116
+ "kind": "node",
117
+ "script": "test/add.test.mjs"
118
+ },
119
+ "args": []
120
+ }
121
+ }
122
+ }