@buildr-ai/buildr 0.1.0-rc.24 → 0.1.0-rc.27

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.
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "schemaVersion": "buildr.application-payload/v1",
3
3
  "packageName": "@buildr-ai/buildr",
4
- "buildrVersion": "0.1.0-rc.24",
4
+ "buildrVersion": "0.1.0-rc.27",
5
5
  "protocolIdentity": "buildr.web-protocol/v1",
6
- "sourceCommit": "7d1b4dd8e61c64da8d55591405d8f67be9a9c44c",
6
+ "sourceCommit": "0c69ec993c958ca3a8dc98089897cc031c346d48",
7
7
  "enginesNode": ">=24.15.0 <25",
8
8
  "productionDependencies": [
9
9
  {
10
10
  "name": "ajv",
11
- "version": "8.17.1",
11
+ "version": "8.18.0",
12
12
  "license": "MIT",
13
13
  "licensePath": "resources/licenses/dependencies/ajv-LICENSE"
14
14
  },
@@ -54,7 +54,7 @@
54
54
  "path": "resources/product/package.json",
55
55
  "mode": 420,
56
56
  "size": 769,
57
- "sha256": "89456b82e813fda881d93eaf02b981b8708d3e416eb742fe3bc9edac1bb06ff5"
57
+ "sha256": "983326699d33365a177c89b3965d29c42a3fbaf4ba304b7deef3dfff20707829"
58
58
  },
59
59
  {
60
60
  "path": "resources/product/package/targets/runtime/skills/buildr/SKILL.md",
@@ -179,8 +179,8 @@
179
179
  {
180
180
  "path": "resources/product/resources/workspace/skills/buildr/current-knowledge-maintenance/SKILL.md",
181
181
  "mode": 420,
182
- "size": 7069,
183
- "sha256": "342e42d7119e5797079e7fa707708aeab9b38f76a137b12d51c44652c329e6f3"
182
+ "size": 7217,
183
+ "sha256": "9941bf1fdc4709467a45675949778ed43d891c15edd7dc04d70b1432d2c7bd72"
184
184
  },
185
185
  {
186
186
  "path": "resources/product/resources/workspace/skills/buildr/declaration-intake/SKILL.md",
@@ -221,8 +221,8 @@
221
221
  {
222
222
  "path": "resources/product/resources/workspace/skills/buildr/task-development/SKILL.md",
223
223
  "mode": 420,
224
- "size": 25853,
225
- "sha256": "bf8711033a3aebdf4b004a8242c46138839a1c895ba46c2a66504cccb60b9e25"
224
+ "size": 26112,
225
+ "sha256": "97e821504a413df10e47c75a39a9105d8e570a2b36e3b01505733c17ba1087b5"
226
226
  },
227
227
  {
228
228
  "path": "resources/product/resources/workspace/skills/buildr/task-environment/SKILL.md",
@@ -257,8 +257,8 @@
257
257
  {
258
258
  "path": "resources/product/resources/workspace/skills/buildr/task-finish/SKILL.md",
259
259
  "mode": 420,
260
- "size": 7569,
261
- "sha256": "2e741b6283a8dd35c49dfb127b6cfd63a54079fd9a10e47d5c7bc0e1f41e79c4"
260
+ "size": 7754,
261
+ "sha256": "bcee67d7abe425e46f22fad7ccaba3aea0594c262bb5e10f80de50db1ee07116"
262
262
  },
263
263
  {
264
264
  "path": "resources/product/resources/workspace/skills/buildr/task-manager/SKILL.md",
@@ -299,20 +299,20 @@
299
299
  {
300
300
  "path": "resources/product/resources/workspace/skills/buildr/task-triage/SKILL.md",
301
301
  "mode": 420,
302
- "size": 18883,
303
- "sha256": "1f18e9eec1f1a73ece16bfdbf2f00c7a334ac64caf311e7ec97ba8eb93d85bd6"
302
+ "size": 19195,
303
+ "sha256": "a8f88ebcc38f0c33a1b002a2c5146136d7646d90a4cba04f813e662ffffae3bf"
304
304
  },
305
305
  {
306
306
  "path": "resources/product/resources/workspace/skills/buildr/task-verification/SKILL.md",
307
307
  "mode": 420,
308
- "size": 18992,
309
- "sha256": "9fecd05bf07b912a7329f88aad8888e52014b038d37d04b48b020080b1f88f59"
308
+ "size": 19631,
309
+ "sha256": "2b89d65fc382276c61d4960ace72bc821065bf1821867903e0a0c97d8d34eae0"
310
310
  },
311
311
  {
312
312
  "path": "resources/product/resources/workspace/skills/buildr/task-verification/references/project-verification-v3.md",
313
313
  "mode": 420,
314
- "size": 2187,
315
- "sha256": "23019fa180875e60d07a10b283a05993ecd6580771f7c7e64669981329ae5c8d"
314
+ "size": 2258,
315
+ "sha256": "23ad3a75dda85af4786985e46373764c4dcc1a2d1655ea07fe2cebcb0508ed77"
316
316
  },
317
317
  {
318
318
  "path": "resources/product/resources/workspace/skills/buildr/task-verification/templates/project-verification.yml",
@@ -347,8 +347,8 @@
347
347
  {
348
348
  "path": "resources/product/resources/workspace/skills/contracts/buildr/current-knowledge-maintenance/v2.md",
349
349
  "mode": 420,
350
- "size": 4388,
351
- "sha256": "bd5b9f7d2527a0f2fd2c044e93087891d99239548e4c6639208277260484261b"
350
+ "size": 4592,
351
+ "sha256": "4f436c1a3012c12e2f75345d3a27f7b64b8c4dea6785596c352d53f1ab3139a3"
352
352
  },
353
353
  {
354
354
  "path": "resources/product/resources/workspace/skills/contracts/buildr/git-operations/v1.md",
@@ -365,8 +365,8 @@
365
365
  {
366
366
  "path": "resources/product/resources/workspace/skills/contracts/buildr/task-development/v2.md",
367
367
  "mode": 420,
368
- "size": 13970,
369
- "sha256": "b6a57aebf5c10f05e596256711706927ecf95a60d4fbb4086dff1614e245875b"
368
+ "size": 14201,
369
+ "sha256": "5fb4475d844c3bde36dfe87fdbb480345b458471f50fe57a713afe99fcd5940d"
370
370
  },
371
371
  {
372
372
  "path": "resources/product/resources/workspace/skills/contracts/buildr/task-environment/v1.md",
@@ -377,8 +377,8 @@
377
377
  {
378
378
  "path": "resources/product/resources/workspace/skills/contracts/buildr/task-finish/v1.md",
379
379
  "mode": 420,
380
- "size": 5086,
381
- "sha256": "3028249712c7b25a4b730cf9a29724a43eed4a555d1fb8a8f27d3ea52fdec00d"
380
+ "size": 5261,
381
+ "sha256": "fd1ff7dbe655105445adb6de2ddaed598490171fd05f0cd2243823f236ab441c"
382
382
  },
383
383
  {
384
384
  "path": "resources/product/resources/workspace/skills/contracts/buildr/task-record/v2.md",
@@ -401,8 +401,8 @@
401
401
  {
402
402
  "path": "resources/product/resources/workspace/skills/contracts/buildr/task-verification/v3.md",
403
403
  "mode": 420,
404
- "size": 12319,
405
- "sha256": "5ec011a5dd7089f2130176c934da215206f8fbc8e9ef052eeae782b629d3b118"
404
+ "size": 12603,
405
+ "sha256": "c16d118fb874347c128c478206abeecaf2ba2ea9597af58bda071e43a1e926d8"
406
406
  },
407
407
  {
408
408
  "path": "resources/product/resources/workspace/skills/contracts/buildr/terminology-governance/v1.md",
@@ -599,15 +599,15 @@
599
599
  {
600
600
  "path": "resources/runtime/read-worker.cjs",
601
601
  "mode": 420,
602
- "size": 3655025,
603
- "sha256": "43ae33d68f9379aa1e9983707a1ef9abcd0a53565a8d1348bea7316aa1388f9b"
602
+ "size": 3666202,
603
+ "sha256": "edbfb01f75a0199bc2f0ff1d0514ef85b44fc21771ae94c0e2e5b3e1a77e4103"
604
604
  },
605
605
  {
606
606
  "path": "runtime/buildr.cjs",
607
607
  "mode": 420,
608
- "size": 3718180,
609
- "sha256": "5ca2744c706f84fc27d6c8f8e4b8266f299fbd96c82e31560690fe43855bbeef"
608
+ "size": 3729336,
609
+ "sha256": "46575d0a7890eeb707b8638e94033b8e3fa4130cc76a8b744293cafb62511dde"
610
610
  }
611
611
  ],
612
- "applicationPayloadDigest": "sha256-8721d9613b14c6c733fb50d130860f012cdb18586ff714e73689d598eff7b953"
612
+ "applicationPayloadDigest": "sha256-296436ee7feeb1d94106866b691ca60e6e468f244951f84e2aa8cd0edc1c9051"
613
613
  }
@@ -3,11 +3,11 @@
3
3
  "channel": "npm",
4
4
  "runtimeRole": "host",
5
5
  "package": "@buildr-ai/buildr",
6
- "version": "0.1.0-rc.24",
6
+ "version": "0.1.0-rc.27",
7
7
  "protocolIdentity": "buildr.web-protocol/v1",
8
- "applicationPayloadDigest": "sha256-8721d9613b14c6c733fb50d130860f012cdb18586ff714e73689d598eff7b953",
9
- "sourceCommit": "7d1b4dd8e61c64da8d55591405d8f67be9a9c44c",
8
+ "applicationPayloadDigest": "sha256-296436ee7feeb1d94106866b691ca60e6e468f244951f84e2aa8cd0edc1c9051",
9
+ "sourceCommit": "0c69ec993c958ca3a8dc98089897cc031c346d48",
10
10
  "sourceTag": null,
11
- "installUnit": "@buildr-ai/buildr@0.1.0-rc.24",
12
- "ownershipIdentity": "sha256-865ac92dc2f62ab673d9fe8340cb6318ebcee2b7ffc7e24075bdb64fb3869102"
11
+ "installUnit": "@buildr-ai/buildr@0.1.0-rc.27",
12
+ "ownershipIdentity": "sha256-ddb932c4991f25475e15f1f8d73915f87c498af378fa2d3b46227c3e46f9f421"
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildr-ai/buildr",
3
- "version": "0.1.0-rc.24",
3
+ "version": "0.1.0-rc.27",
4
4
  "description": "Buildr CLI for managing Agent workspace assets.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildr-ai/buildr",
3
- "version": "0.1.0-rc.24",
3
+ "version": "0.1.0-rc.27",
4
4
  "description": "Buildr CLI for managing Agent workspace assets.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "node": ">=24.15.0 <25"
29
29
  },
30
30
  "dependencies": {
31
- "ajv": "8.17.1",
31
+ "ajv": "8.18.0",
32
32
  "yaml": "^2.9.0"
33
33
  }
34
34
  }
@@ -91,7 +91,7 @@ sourceIdentities: <paths/specs/tree>
91
91
  treeIdentity: <current candidate identity>
92
92
  ```
93
93
 
94
- Development聚合时只保存`aligned|not-applicable|attention|blocked`、tree identity、summary、source identities与bounded unresolved items;`updated`后必须重新观察新tree,`unresolved|change-required`按是否会造成错误完成结论转为blocked或先回到Change flow,不能伪装aligned。Archive只移动已对齐的Change、Brief和sidecar;archive后不得再写glossary或current knowledge。
94
+ Development聚合时只保存`aligned|not-applicable|attention|blocked`、tree identity、summary、source identities与bounded unresolved items。多Project Task必须逐Project取得Result并提交精确覆盖全部有效Project的dispositions;不得让一个Project结果代表整个Task。`updated`后必须重新观察新tree,`unresolved|change-required`按是否会造成错误完成结论转为blocked或先回到Change flow,不能伪装aligned。Archive只移动已对齐的Change、Brief和sidecar;archive后不得再写glossary或current knowledge。
95
95
 
96
96
  ## Guardrails
97
97
 
@@ -112,7 +112,7 @@ stable Content Target形成后按默认顺序执行:
112
112
 
113
113
  1. 针对每个有效Project形成并复核closed Formal Verification Plan;只运行较窄focused feedback,不在阶段切换前另启相同broad affected execution。
114
114
  2. Plan preview为`action-required`时,把原样`preparation.planRequest`交给Task Environment一次幂等prepare;不手写安装或扩大Task scope。
115
- 3. 使用同一批Plan documents调用`discover policy --plan <project>::<json-file>`,检查selected、not-selected、coverage gaps与必要risk override,再把返回的closed `inputJson`交给policy writer。
115
+ 3. 使用同一批Plan documents调用`discover policy --plan <project>::<json-file>`;若返回聚合`preparation.planRequest`,先原样交给Task Environment一次prepare并重跑同一批Plan preview/discover。检查selected、not-selected、coverage gaps与必要risk override,再把返回的closed `inputJson`交给policy writer。
116
116
  4. Task Context、Planning、Content Target、Environment准备与policy均current后调用freeze形成或复用Candidate;随后把同一Plan文件交给formal run/reconcile。
117
117
 
118
118
  该顺序是Formal Development的推荐工作流,不自动prepare、policy、freeze或run,也不是普通开发的许可层;Agent仍决定额外风险能力、override、外部授权及是否采用其他满足owner contract的合法路径。Plan、target、declaration或capability identity变化时重新plan,不复用旧preview或execution。
@@ -127,7 +127,7 @@ Candidate形成后读取response-only`formalVerificationReadiness`:`ready`时
127
127
 
128
128
  所有Change disposition非pending、每个`converged`由current working copy archived事实证明、planning disposition明确且Content Target与policy current后,即可调用Development Application freeze。freeze不修改内容、不运行命令,只创建或复用current Candidate;Verification、Completion与Current Knowledge都不进入Candidate identity,也不作为首次freeze前置。Change lifecycle、planning、Content、Task context或policy变化会使旧Candidate失效并在下一次freeze递增generation。
129
129
 
130
- Candidate形成后,按实际工作需要形成matching Verification、用`task-review`执行Completion Review,并由Current Knowledge provider形成绑定current Content Target的最小disposition。`blocked`只用于会造成错误完成结论的冲突;`attention`保留portable follow-up但不阻止proceed/handoff。根据current gates记录:
130
+ Candidate形成后,按实际工作需要形成matching Verification、用`task-review`执行Completion Review,并由Current Knowledge provider形成绑定current Content Target的最小disposition。多Project Task逐Project取得Result后一次提交精确Project集合,单Project与仅工作区Task可沿用原聚合输入。`blocked`只用于会造成错误完成结论的冲突;`attention`保留portable follow-up但不阻止proceed/handoff。根据current gates记录:
131
131
 
132
132
  - `blocked`:说明未获接受的风险或仍需处理的问题,不修改Task顶层status;
133
133
  - `proceed`:必须绑定current Candidate。Verification not-passed、coverage gap或Completion changes-required时,每项风险都要绑定`verification|completion`、精确Result digest、scope、summary和用户授权source;跳过整个适用gate使用`gate`记录waiver,不伪造Result或混入风险列表。
@@ -48,7 +48,7 @@ Agent 可通过 Git Operations、PR 或其他已授权方式推进代码;每
48
48
 
49
49
  `buildr task finish reconcile --task <task-id> --target <canonical-workspace> --detail compact --json`
50
50
 
51
- 交付对账(Delivery Reconciliation)不接受调用方提交“已成功”、commit 列表或证明文件。它优先复用current Environment;Environment不存在、已清理或局部不可用时,从current immutable handoff、Task scope、Project/Service registries、实际Git topology以及明确或唯一的remote/target构造只读上下文,不恢复或补造Receipt。它逐repository确认carrier已到达、已被后继包含,或目标tree精确包含任务贡献结果;无法证明时只报告对应repository的事实缺口,并保留其他repository已经登记的Delivery checkpoint。
51
+ 交付对账(Delivery Reconciliation)不接受调用方提交“已成功”、commit 列表或证明文件。它优先复用current Environment;Environment不存在、已清理、局部不可用,或ready shared placement没有provider repository set时,从current immutable handoff、Task scope、Project/Service registries、实际Git topology以及明确或唯一的remote/target构造只读delivery context,不恢复或补造Receipt。ready shared Environment仍保留自己的cleanup availability;该fallback不供自动Finish创建carrier。reconciliation逐repository确认carrier已到达、已被后继包含,或目标tree精确包含任务贡献结果;无法证明时只报告对应repository的事实缺口,并保留其他repository已经登记的Delivery checkpoint。
52
52
 
53
53
  ## 四个独立结果
54
54
 
@@ -59,7 +59,7 @@ authority 冲突、授权或 repository set 不明、不可逆行为缺少决定
59
59
 
60
60
  | 分支 | Capability / 动作 | 必要输入与成功证据 | 失败处理 |
61
61
  |---|---|---|---|
62
- | 新正式 Task 的 Git 基线 | `buildr.git-operations/v1` 的独立 `fetch` 与 `rebase` | 完整 repository set 均证明当前为 clean `dev`、upstream 为 `origin/dev`;每个 operation 返回 before/after、effects 与 current facts,适用 Workspace transition check ready | 任一前置事实、provider、fetch、rebase、冲突恢复或 Doctor blocked 时不调用 Task Record `create`;报告全部部分 effects,不换策略 |
62
+ | 新正式 Task 的 Git 基线 | `buildr.git-operations/v1` 的独立 `fetch` 与 `rebase` | 完整 repository set 分别证明current integration branch、matching upstream与clean状态;每个 operation 返回before/after、effects与current facts,适用Workspace transition check ready | 任一目标解析、前置事实、provider、fetch、rebase、冲突恢复或Doctor blocked时不调用Task Record `create`;报告全部部分effects,不换策略 |
63
63
  | 待办意向 | `buildr.task-record/v2` 的 `create --status todo` | 用户已接受但尚未启动的意向、stable ID、title、intent、scope与可选复盘来源;只返回SQLite record/effects | 不运行Git基线,不创建Environment、Change或专业placeholder |
64
64
  | 正式持久交付 | `buildr.task-record/v2` 的 active `create`、todo `activate` 或 `inspect` | stable Task ID、title、intent、canonical Workspace 与真实 scope/Change;首次执行写入前返回 current active record | provider或Git门禁blocked时停止正式交付写入;已有active inspect不重复门禁 |
65
65
  | 正式执行位置 | `buildr.task-environment/v1` 的 Plan `record/inspect` 与 Environment `prepare/inspect` | Task ID、canonical Workspace、完整 Task Project/Service scope、Project `preparation.yml`及Agent选择的Recipe;首次受管效果前取得`ready`、实际execution roots、validation root和执行CLI | Declaration/Plan缺失或scope不完整时只阻塞消费Environment authority的动作;不猜技术栈,不回退到cwd或旧Receipt |
@@ -84,16 +84,17 @@ Child Task必须先以`--parent <parent-task-id>`和自身scope创建,且初
84
84
 
85
85
  如果Child真实依赖Parent尚未交付的代码、文档或其他authority,先在Parent Plan中表达依赖并完成前置Contribution;可以先保留Child意向,但必须延后Child Environment prepare。前置贡献完成正式Finish且进入最新`dev`等canonical baseline后,再从收敛后的baseline准备Child Environment。不得通过从Parent worktree派生Child checkout、复制Parent Environment Receipt或提前共享未归档Change绕过该顺序。
86
86
 
87
- ### 新正式 Task 创建前收敛统一 dev 基线
87
+ ### 新正式 Task 创建前收敛逐 repository 权威基线
88
88
 
89
89
  只有即将创建 active Task 或把 todo 激活为 active 时执行本门禁;todo create、inspect、已有active继续、纯讨论和只读探索不执行。
90
90
 
91
- 1. 以已经解析的完整 repository set 为输入,按 selector 固定顺序逐个核验真实 Git root、当前符号分支恰为 `dev`、upstream 恰为 `origin/dev`、remote/ref 可读、index 与 working tree clean,并且没有 rebase、merge、cherry-pick 等进行中的 Git operation。任一事实不成立时在 tree/history 零写入状态返回 `blocked`;不 checkout、不 stash/autostash、不猜其他 branch/remote。
92
- 2. 读取 optional `buildr.git-operations/v1` binding;在本 create 分支把 ready selected provider 作为 required。先为全部 repositories 逐一选择独立 `fetch` operation,明确 `origin` 与 `dev`,消费每个 Result。任一 fetch blocked 时不执行尚未开始的 rebase,不创建 Task,并报告全部已发生的 remote-ref effects。
93
- 3. 全部 fetch 成功后重新核验 `dev`、`origin/dev` 与 clean 状态,再按同一顺序为每个 repository 明确选择 `rebase` operation,将本地 `dev` rebase 到本次观察的 `origin/dev`。本地已对齐、仅落后或含未 push 且未共享 commit 都使用同一 operation;provider 不自行选择 merge 或 push。
94
- 4. rebase 冲突时,consumer 明确授权 provider 只在 pre-state 已证明 clean 时执行有界 `rebase --abort`。只有 branch、HEAD、index 与 working tree 精确恢复到 pre-rebase facts 才记为 recovered;无论恢复是否成功,本次 Task create 都是 `blocked`。abort 失败或恢复不可证明时保留现场。已经在其他 repository 成功的 fetch/rebase 不反向回滚,必须作为部分 effects 报告。
95
- 5. 任一 rebase 返回 `treeChanged: true` 时,按产品入口 Buildr Skill 的 workspace transition 约束,对相应 Buildr Workspace 执行当前 Agent 的 check;Doctor 或必要收敛未 ready 时不创建 Task。若tree前进来自`origin/dev`上的协作者提交且当前会话不存在绑定同一Workspace、Task、run与delivered ref的matching Formal Finish Result,只能把它归类为普通Workspace update:本地没有协作者Task是正常事实,不得因此查找、恢复或启动`buildr-self-bootstrap-sync`。Doctor仅指向当前Agent managed workspace/runtime projection stale时,将现有用户授权或一次明确sync确认交给产品入口Buildr Skill执行`buildr sync <agent> --target <workspace-root>`并消费最终Doctor;存在非sync blocker时按对应authority停止或处理,不用一次sync掩盖。
96
- 6. 只有完整 repository set 的 fetch、rebase、恢复检查与适用 transition check 全部成功,才调用 selected `buildr.task-record/v2` provider 的 active `create` 或 `activate`。任一门禁blocked时todo保持不变。Task Record Application、Buildr Web 与 Task Environment 不获得任何Git mutation或本门禁状态authority。
91
+ 1. 以已经解析的完整repository set为输入,按selector固定顺序为每个repository解析integration branch、remote与matching upstream。优先使用Project/Service registry的Git声明;声明缺失时只接受当前符号branch/upstream或用户明确选择形成的唯一事实。无法唯一解析时在tree/history零写入状态返回`blocked`,不得猜测`dev`或复制Workspace目标。
92
+ 2. 逐个核验真实Git root、当前符号branch恰为已解析integration branch、upstream恰为matching remote ref、remote/ref可读、index与working tree clean,并且没有rebase、merge、cherry-pick等进行中的Git operation。任一事实不成立时在tree/history零写入状态返回`blocked`;不checkout、不stash/autostash、不猜其他branch/remote。
93
+ 3. 读取optional `buildr.git-operations/v1` binding;在本create分支把ready selected provider作为required。先为全部repositories逐一选择独立`fetch` operation,明确各自remote与integration branch,消费每个Result。任一fetch blocked时不执行尚未开始的rebase,不创建Task,并报告全部已发生的remote-ref effects。
94
+ 4. 全部fetch成功后重新核验每个local integration branch、matching remote ref与clean状态,再按同一顺序为每个repository明确选择`rebase` operation。本地已对齐、仅落后或含未push且未共享commit都使用同一operation;provider不自行选择merge或push。
95
+ 5. rebase冲突时,consumer明确授权provider只在pre-state已证明clean时执行有界`rebase --abort`。只有branch、HEAD、index与working tree精确恢复到pre-rebase facts才记为recovered;无论恢复是否成功,本次Task create都是`blocked`。abort失败或恢复不可证明时保留现场。已经在其他repository成功的fetch/rebase不反向回滚,必须作为部分effects报告。
96
+ 6. 任一rebase返回`treeChanged: true`时,按产品入口Buildr Skill的workspace transition约束,对相应Buildr Workspace执行当前Agent的check;Doctor或必要收敛未ready时不创建Task。若tree前进来自matching upstream上的协作者提交且当前会话不存在绑定同一Workspace、Task、run与delivered ref的matching Formal Finish Result,只能把它归类为普通Workspace update:本地没有协作者Task是正常事实,不得因此查找、恢复或启动`buildr-self-bootstrap-sync`。Doctor仅指向当前Agent managed workspace/runtime projection stale时,将现有用户授权或一次明确sync确认交给产品入口Buildr Skill执行`buildr sync <agent> --target <workspace-root>`并消费最终Doctor;存在非sync blocker时按对应authority停止或处理,不用一次sync掩盖。
97
+ 7. 只有完整repository set的fetch、rebase、恢复检查与适用transition check全部成功,才调用selected `buildr.task-record/v2` provider的active `create`或`activate`。任一门禁blocked时todo保持不变。Task Record Application、Buildr Web与Task Environment不获得任何Git mutation或本门禁状态authority。
97
98
 
98
99
  上述Workspace update分类只组合本次Git Result、post-transition Doctor与当前会话已有的matching Formal Finish Result,不按commit author推断ownership,也不建立持久状态。只有真实matching Finish Result才能把同一run交给self-bootstrap;普通workspace sync不创建Task、Environment、Verification、Candidate、Finish Result或self-bootstrap evidence。
99
100
 
@@ -108,7 +109,7 @@ Child Task必须先以`--parent <parent-task-id>`和自身scope创建,且初
108
109
  - 语义治理:code-only / spec-maintenance / change-flow / blocked
109
110
  - 执行形态:implementation / metadata-only / unknown
110
111
  - Repository set:<selectors 或 unresolved>
111
- - Git 基线:converged / none / blocked(仅新正式 Task create;包含 dev/origin/dev 与部分 effects)
112
+ - Git 基线:converged / none / blocked(仅新正式Task create;包含每个repository的integration branch/upstream与部分effects)
112
113
  - Task Record:create / inspect / none / blocked
113
114
  - Task Environment:prepare / inspect / none / blocked
114
115
  - 事实依据:<最小 authority/evidence>
@@ -90,7 +90,7 @@ stable Content Target的Formal Plans按有效Project全部形成后,使用matc
90
90
  --plan <project>::<plan-file> [--plan <project>::<plan-file> ...]
91
91
  ```
92
92
 
93
- Task Verification Application会重新校验Plan closed identity、task-delivery target、current Content Target、Project/declaration与selected capability,并返回policy writer所需的closed `inputJson`、Plan identities和response-only not-selected摘要;它零写入,不把Plan正文、preparation、not-selected或文件路径保存到Result/Receipt。Project集合缺失/重复或任一identity陈旧时重新plan,不手抄或猜选能力。Plan文件位于操作系统临时目录,只保留到同一Plan完成policy派生和formal run;随后立即删除。无Plan时仍可使用declaration默认policy discovery作为合法降级,但不得把它声称为Plan-derived选择。
93
+ Task Verification Application会重新校验Plan closed identity、task-delivery target、current Content Target、Project/declaration与selected capability,并返回policy writer所需的closed `inputJson`、Plan identities和response-only not-selected摘要。全部Project都提供正式Plan result envelope时,投影还会把每份`preparation.requirements`合成精确并集;任一Project为`action-required`时,只把聚合后的`preparation.planRequest`原样交给Task Environment一次prepare,不得依次提交局部Project request相互覆盖。该投影零写入,不把Plan正文、preparation、not-selected或文件路径保存到Result/Receipt。Project集合缺失/重复或任一identity陈旧时重新plan,不手抄或猜选能力。Plan文件位于操作系统临时目录,只保留到同一Plan完成policy派生和formal run;随后立即删除。无Plan时仍可使用declaration默认policy discovery作为合法降级,但不得把它声称为Plan-derived选择。
94
94
 
95
95
  `verification run`只执行已选择的command capability;`--json`默认返回有界`buildr.long-running-operation-summary/v1`,只有诊断需要时才显式使用`--detail full`返回既有`buildr.verification-execution/v1`。compact中的recovery pointer必须先用于回读同一Execution Record;stdout丢失、等待超时、展示截断或既有failed都不授权重跑。它不接受`--declaration-root`。带matching Task Environment的正式execution必须由Development consumer提交current Candidate lease,并在启动capability前把Candidate加入invocation identity和Task Execution Record;runner不反向读取或写Development。完成后先seal受控、脱敏、有限期正文,再精确清理transient evidence。Task外execution不接受Candidate lease且仍只产生transient evidence。`--declaration-root`只用于Result reconciliation;`inspect`不重新观察声明。
96
96
 
@@ -137,6 +137,8 @@ buildr task verification reconcile <task-id> \
137
137
 
138
138
  Application独立读取record metadata与受控`summary.json`,核验body integrity、Task、owner/kind、Candidate、generation、target stability、Project、declaration与selected checks,再派生capability outcome、portable facts、evidence identities和整体结论。调用方不得提交或补充capability outcome/fact、evidence digest、declaration identity或claimed external success;任一authority不匹配、正文不可用或执行未terminal时零写入失败。
139
139
 
140
+ 多Project Task按Project聚合:同一Project的records必须绑定相同Request/Plan/provider,不同Project允许使用各自独立Plan。records与`project:<code>` coverage gaps必须精确覆盖全部有效Project;不得寻找或构造跨Project合并Plan,也不得用其他Project的passed记录替代缺失Project。
141
+
140
142
  仅工作区Result不执行不存在的能力,可用兼容`task verification record`入口提交Candidate、target、唯一workspace gap与`not-passed`;该入口拒绝capability claims及任何Project/Service/Change Task。Project coverage gap随至少一个matching execution authority一起reconcile;没有可执行authority时如实报告尚不能形成formal Result。
141
143
 
142
144
  Result只回答Candidate、target、采用的declarations、从authority派生的实际能力及facts/evidence identities、coverage gaps和总体验证结论。不要复制stdout/stderr、耗时、临时evidence path、Environment Receipt、本机绝对路径、applicability、digest、history/revision,或写入proceed/blocked与Task状态。
@@ -21,7 +21,7 @@ Verification Request 冻结 target、selection scope、changed paths/risks 与 d
21
21
 
22
22
  普通 capability 使用 discovery 选择 affected;缺少可信 affected 入口时显式扩大到 full。未知 owner 失败关闭。复杂 Product 可使用 provider,但 provider 只能投射统一 Plan/Execution facts,不得公开内部 registry DAG、Context cache 或写 Task Result。
23
23
 
24
- 正式执行必须使用 matching current Plan;preview 不是 evidence。Execution Record 绑定 Request、Plan、declaration、Candidate、target 与 execution unit,reconciliation 只消费同一 Plan 的 terminal records。
24
+ 正式执行必须使用matching current Plan;preview不是evidence。Execution Record绑定Request、Plan、declaration、Candidate、target与execution unit。reconciliation在同一Project内只消费同一Plan的terminal records,不同Project使用各自Plan并按有效Project完整聚合。
25
25
 
26
26
  ## Maintenance boundary
27
27
 
@@ -12,7 +12,7 @@ version: 2
12
12
 
13
13
  ## Consumer Obligations
14
14
 
15
- consumer 必须提供 operation(`assess`、`reconcile`、`inspect` 或 `maintain`)、Workspace/Project identity、当前候选 tree 范围、允许的写入阶段和已有 evidence。Change lifecycle operations 还必须提供 change identity 与 artifact paths;`maintain` 必须提供 target assets、fact sources 和明确的 knowledge 写入授权,且不得伪造 Change identity 或 sidecar。
15
+ consumer 必须提供 operation(`assess`、`reconcile`、`inspect` 或 `maintain`)、Workspace/Project identity、当前候选 tree 范围、允许的写入阶段和已有 evidence。Change lifecycle operations 还必须提供 change identity 与 artifact paths;`maintain` 必须提供 target assets、fact sources 和明确的 knowledge 写入授权,且不得伪造 Change identity 或 sidecar。多Project Task的Development consumer必须分别取得每个有效Project的Result,再以精确Project集合提交最小dispositions;provider不得把单Project Result声明为整个Task已对齐。
16
16
 
17
17
  consumer 必须在可能修改 delivery content 的 `reconcile` 或 `maintain` 后重新建立验证 evidence,并不得在 archive 后请求当前知识写入。
18
18
 
@@ -35,7 +35,7 @@ consumer不得直接读写Workspace SQLite Development current slot或旧`.build
35
35
  - policy identity只绑定current declarations、selected capabilities、coverage gaps与明确overrides;Task Verification不拥有policy。仅工作区policy的空集合与workspace gap仍必须形成稳定identity;其Content Target改变时旧policy stale,Task新增Project/Service/Project-bound Change时必须改用完整Project declarations。
36
36
  - current专业Result、`not-applicable`和明确`waived`是不同gate事实。stale/incomplete Result不得被waiver或风险接受变成current。
37
37
  - Candidate closed shape继续只绑定generation、Content Target、Task Context与policy identity;Task Context、Content Target、policy或Candidate前planning disposition变化必须清除current Candidate,下一次freeze递增generation。Verification、Completion、Current Knowledge与专业Result identity不得进入Candidate,也不得仅因其更新递增generation。
38
- - Current Knowledge `knowledge` action只保存current Content Target identity、`aligned|not-applicable|attention|blocked`、portable summary、source identities与bounded unresolved items;`blocked`阻止proceed/handoff,`attention`保留在handoff但不得阻止完成。Application不解释knowledge正文或固定调用顺序。
38
+ - Current Knowledge `knowledge` action只保存current Content Target identity、`aligned|not-applicable|attention|blocked`、portable summary、source identities与bounded unresolved items。多Project Task必须提交按Project排序且精确覆盖有效Project集合的最小dispositions,Application从该集合确定性聚合顶层status/source/unresolved facts;单Project与仅工作区Task兼容旧聚合输入。`blocked`阻止proceed/handoff,`attention`保留在handoff但不得阻止完成。Application不解释knowledge正文或固定调用顺序。
39
39
  - handoff snapshot绑定Candidate、Change dispositions、Current Knowledge disposition、全部current gate/disposition、proceed decision与精确风险/waiver授权;已写snapshot append-only immutable。
40
40
  - Contribution Handoff只作为同一immutable handoff的可选专业事实;必须绑定current Parent Plan与已保存planned binding。Parent coordination read model只组合Task Record与已保存Development/Finish facts,不新增progress/lifecycle/event/history store,不回写Child状态。
41
41
  - 已completed、非no-change的直接Child若具有matching terminal Finish association与不含Contribution Handoff的immutable handoff,且全部Task-scoped Change仍由current working copy证明archived,可通过`task parent reconcile-child-delivery`显式追加一次terminal contribution reconciliation。该专业evidence由Task Development Application唯一写入,必须绑定current Parent Plan、Parent/Child关系、Candidate/generation、三个gate、完整Contribution Handoff、reason与source;若历史binding存在则planned必须精确匹配,缺失binding时由调用方显式提交planned映射。它不修改Receipt、handoff、Finish、Task Record或Parent Plan;相同identity重放unchanged,不同覆盖或其他Child owner冲突零写入失败。
@@ -18,7 +18,7 @@ provider只消费Development handoff,不得运行或记录Task Verification/Ta
18
18
 
19
19
  ## Minimum Guarantees
20
20
 
21
- provider必须冻结Task、handoff、Candidate/generation、Content Target、repository set和Task Contribution。自动路径继续要求matching ready Environment,只能普通fast-forward/push并回读远端;reconciliation优先复用current Environment,缺失、已清理或局部不可用时必须从current handoff、Task scope、Project/Service registries、Git topology及明确或唯一remote/target构造只读context,不得恢复或补造Receipt。它逐repository从真实remote target重建containment;已证明交付的repository必须立即checkpoint并幂等复用。
21
+ provider必须冻结Task、handoff、Candidate/generation、Content Target、repository set和Task Contribution。自动路径继续要求matching ready Environment与非空受管repository set,只能普通fast-forward/push并回读远端;reconciliation优先复用current Environment。Environment缺失、已清理、局部不可用,或ready shared placement没有provider repository set时,必须从current handoff、Task scope、Project/Service registries、Git topology及明确或唯一remote/target构造只读delivery context,不得恢复或补造Receipt;ready shared Environment的cleanup availability仍保持current。它逐repository从真实remote target重建containment;已证明交付的repository必须立即checkpoint并幂等复用。
22
22
 
23
23
  Agent-reviewed Delivery Adaptation必须从冻结Task Contribution派生完整路径集合,并为每个路径保存唯一处置:target精确包含、carrier实际改变或Agent通过matching run/resume提交逐路径非空理由。未知、重复、未处置路径或run/target/carrier identity漂移必须在adoption、deliver与cleanup前fail closed。逐路径Agent判断必须标记为Buildr未证明语义等价;provider不得把task-wide review隐式应用到未列出的路径。覆盖事实必须进入既有carrier proof identity并由remote readback与cleanup重验,不得创建第二Result或事件store。
24
24
 
@@ -21,8 +21,8 @@ consumer与Application必须以Task显式Project、Service所属Project和Change
21
21
  ## Minimum Guarantees
22
22
 
23
23
  - Project `verification.yml` 只接受 `buildr.project-verification/v3`,声明既有 capability family 的 scope、proves、evidence、usable targets、discovery、affected/full/provider invocation及必要执行边界;旧声明不兼容读取。
24
- - Application必须从closed Verification Request与current declarations/provider生成内容寻址Plan。正式execution和Execution Record必须绑定matching request/plan/provider/declaration/execution unit identities;preview不得充当evidence,不同Plan的records不得混合reconcile。
25
- - Application必须提供零写入的Formal Plan到Task Development policy投影:按有效Project完整对账closed Plan document、current Content Target、declaration和selected capability,输出required capabilities、portable coverage gaps、空默认overrides与response-only not-selected摘要。Plan、preparation、not-selected摘要和文件路径不得进入Development Receipt、Verification Result或新store;Project缺失/重复或identity陈旧时零写入失败。
24
+ - Application必须从closed Verification Request与current declarations/provider生成内容寻址Plan。正式execution和Execution Record必须绑定matching request/plan/provider/declaration/execution unit identities;preview不得充当evidence。同一Project的records必须绑定相同Plan,不同Project允许使用各自独立Plan;reconcile必须以records或project coverage gap精确覆盖Task有效Project集合。
25
+ - Application必须提供零写入的Formal Plan到Task Development policy投影:按有效Project完整对账closed Plan document、current Content Target、declaration和selected capability,输出required capabilities、portable coverage gaps、空默认overrides与response-only not-selected摘要;全部Plan result均含preparation preview时,还必须输出全部Project requirements精确并集形成的唯一closed Environment Plan Request。Plan、preparation、not-selected摘要和文件路径不得进入Development Receipt、Verification Result或新store;Project缺失/重复或identity陈旧时零写入失败。
26
26
  - capability可选通过`environment.preparation`引用同Project已登记Preparation Recipe。Formal command execution必须先纯读合并selected capability requirements,绑定capability/declaration、closure、Environment Plan/Receipt与runtime invocation identities;只有admission current且ready后才能open Execution Record或启动target/process/Browser/resource副作用。首次副作用前必须按相同expected identities重验,漂移时fail closed且record不得open。
27
27
  - 只有可由声明Recipe恢复的preparation gap可以返回closed supplemental Plan Request,并且只能交给Task Environment唯一writer幂等prepare后重跑admission。辅助Service不得进入Task scope、Change、Content Target、allowed execution roots或源码写入authority。Verification不得自行安装依赖、设置`BUILDR_NODE`/PATH、猜cwd或复制Environment facts进Result。
28
28
  - Formal admission只门禁正式execution、current Result与完成声明。provider/Receipt/preflight暂不可用时,无关开发、只读调查和明确非正式的有界检查不受阻塞,但不得产生Formal Result或完成声明。coverage、declaration invalid、authorization与external-system/resource gap必须保持各自owner,不得伪装成preparation recovery。
@@ -16032,6 +16032,7 @@ var require_pattern = __commonJS({
16032
16032
  "use strict";
16033
16033
  Object.defineProperty(exports2, "__esModule", { value: true });
16034
16034
  var code_1 = require_code2();
16035
+ var util_1 = require_util();
16035
16036
  var codegen_1 = require_codegen();
16036
16037
  var error3 = {
16037
16038
  message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
@@ -16044,10 +16045,18 @@ var require_pattern = __commonJS({
16044
16045
  $data: true,
16045
16046
  error: error3,
16046
16047
  code(cxt) {
16047
- const { data, $data, schema: schema7, schemaCode, it } = cxt;
16048
+ const { gen, data, $data, schema: schema7, schemaCode, it } = cxt;
16048
16049
  const u = it.opts.unicodeRegExp ? "u" : "";
16049
- const regExp = $data ? (0, codegen_1._)`(new RegExp(${schemaCode}, ${u}))` : (0, code_1.usePattern)(cxt, schema7);
16050
- cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
16050
+ if ($data) {
16051
+ const { regExp } = it.opts.code;
16052
+ const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
16053
+ const valid = gen.let("valid");
16054
+ gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
16055
+ cxt.fail$data((0, codegen_1._)`!${valid}`);
16056
+ } else {
16057
+ const regExp = (0, code_1.usePattern)(cxt, schema7);
16058
+ cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
16059
+ }
16051
16060
  }
16052
16061
  };
16053
16062
  exports2.default = def;
@@ -27906,7 +27915,7 @@ ${excerpt}`);
27906
27915
  if (!(skill.requires || []).some((item) => item.capability === "buildr.task-record" && item.version === 2 && item.mode === "required")) problems.push("task-retrospective must require buildr.task-record@2.");
27907
27916
  }
27908
27917
  if (skill.id === "task-triage") {
27909
- for (const requiredText5 of ["## 2. 两轴决策", "`code-only`", "`spec-maintenance`", "`change-flow`", "`blocked`", "Repository set", "`implementation`", "`metadata-only`", "`unknown`", "`buildr.task-record/v2`", "待办意向", "todo create", "Formal Task Record本身不是编辑、构建或有界测试的通用工作许可", "首次受管效果前取得`ready`", "`buildr.git-operations/v1`", "从 Parent 规划项启动独立 Child Task", "初始不引用Parent Change", "Child execution root中创建该独立目标自己的窄Change", "新正式 Task 创建前收敛统一 dev 基线", "`fetch` operation", "`rebase` operation", "`rebase --abort`", "Git 基线:converged / none / blocked", "`buildr.current-knowledge-maintenance/v2`", "`buildr.task-environment/v1`", "`maintain`", "`change-required`", "provider 不 ready", "selected `buildr.task-development/v2` provider", "selected `buildr.task-verification/v3` provider", "不预设 minimal/affected/candidate 层级", "## 4. 输出契约"]) {
27918
+ for (const requiredText5 of ["## 2. 两轴决策", "`code-only`", "`spec-maintenance`", "`change-flow`", "`blocked`", "Repository set", "`implementation`", "`metadata-only`", "`unknown`", "`buildr.task-record/v2`", "待办意向", "todo create", "Formal Task Record本身不是编辑、构建或有界测试的通用工作许可", "首次受管效果前取得`ready`", "`buildr.git-operations/v1`", "从 Parent 规划项启动独立 Child Task", "初始不引用Parent Change", "Child execution root中创建该独立目标自己的窄Change", "新正式 Task 创建前收敛逐 repository 权威基线", "`fetch` operation", "`rebase` operation", "`rebase --abort`", "Git 基线:converged / none / blocked", "`buildr.current-knowledge-maintenance/v2`", "`buildr.task-environment/v1`", "`maintain`", "`change-required`", "provider 不 ready", "selected `buildr.task-development/v2` provider", "selected `buildr.task-verification/v3` provider", "不预设 minimal/affected/candidate 层级", "## 4. 输出契约"]) {
27910
27919
  if (!skillContent.includes(requiredText5)) problems.push(`task-triage Skill must include ${JSON.stringify(requiredText5)}.`);
27911
27920
  }
27912
27921
  if (!(skill.requires || []).some((item) => item.capability === "buildr.task-record" && item.version === 2 && item.mode === "optional")) problems.push("task-triage must optionally require buildr.task-record@2.");
@@ -37619,6 +37628,42 @@ function registerTaskVerificationApplication(runtime2) {
37619
37628
  function declarationValues(observations) {
37620
37629
  return observations.map(({ project, path: declarationPath, identity: identity7 }) => ({ project, path: declarationPath, identity: identity7 }));
37621
37630
  }
37631
+ function aggregateFormalPlanPreparation(effectiveProjects, byProject) {
37632
+ const documents = effectiveProjects.map((project) => ({ project, result: byProject.get(project)?.result || null }));
37633
+ if (documents.some((entry) => !entry.result?.preparation)) return null;
37634
+ const requirements = [];
37635
+ const baseRequests = [];
37636
+ for (const { project, result: result5 } of documents) {
37637
+ const preparation = result5.preparation;
37638
+ if (preparation.status === "action-required" && !preparation.planRequest) throw taskVerificationError("task_verification_policy_preparation_request_missing", `Formal Plan preparation缺少Plan Request:${project}。`, 409, { project });
37639
+ if (preparation.planRequest) {
37640
+ assertFields4(preparation.planRequest, /* @__PURE__ */ new Set(["schemaVersion", "notApplicableReason", "projects", "auxiliaryPreparation"]), `formalPlans.${project}.preparation.planRequest`);
37641
+ if (preparation.planRequest.schemaVersion !== "buildr.task-environment-plan-request/v1" || !Array.isArray(preparation.planRequest.projects)) throw taskVerificationError("task_verification_policy_preparation_request_invalid", `Formal Plan preparation Plan Request不合法:${project}。`, 409, { project });
37642
+ baseRequests.push({ project, request: preparation.planRequest });
37643
+ }
37644
+ for (const [index, requirement] of preparation.requirements.entries()) {
37645
+ assertFields4(requirement, /* @__PURE__ */ new Set(["capability", "capabilityIdentity", "project", "selector", "recipe"]), `formalPlans.${project}.preparation.requirements[${index}]`);
37646
+ if ([requirement.capability, requirement.capabilityIdentity, requirement.project, requirement.selector, requirement.recipe].some((value) => typeof value !== "string" || !value)) throw taskVerificationError("task_verification_policy_preparation_requirement_invalid", `Formal Plan preparation requirement不合法:${project}/${index}。`, 409, { project, index });
37647
+ if (requirement.project !== project) throw taskVerificationError("task_verification_policy_preparation_requirement_project_mismatch", `Formal Plan preparation requirement Project不匹配:${project}/${requirement.project}。`, 409, { project, actualProject: requirement.project });
37648
+ requirements.push(requirement);
37649
+ }
37650
+ }
37651
+ const uniqueRequirements = [...new Map(requirements.sort((left, right) => JSON.stringify(left).localeCompare(JSON.stringify(right))).map((item) => [`${item.capabilityIdentity}/${item.project}/${item.selector}/${item.recipe}`, item])).values()];
37652
+ if (!baseRequests.length) return { status: "ready", identity: digest3({ projects: effectiveProjects, requirements: uniqueRequirements }), requirements: uniqueRequirements, planRequest: null };
37653
+ const base = baseRequests[0].request;
37654
+ const baseIdentity = JSON.stringify({ projects: base.projects, ...base.notApplicableReason ? { notApplicableReason: base.notApplicableReason } : {} });
37655
+ for (const entry of baseRequests.slice(1)) {
37656
+ const actual = JSON.stringify({ projects: entry.request.projects, ...entry.request.notApplicableReason ? { notApplicableReason: entry.request.notApplicableReason } : {} });
37657
+ if (actual !== baseIdentity) throw taskVerificationError("task_verification_policy_preparation_base_mismatch", `Formal Plan preparation base scopes不一致:${entry.project}。`, 409, { project: entry.project });
37658
+ }
37659
+ const planRequest = {
37660
+ schemaVersion: "buildr.task-environment-plan-request/v1",
37661
+ ...base.notApplicableReason ? { notApplicableReason: base.notApplicableReason } : {},
37662
+ projects: structuredClone(base.projects),
37663
+ auxiliaryPreparation: uniqueRequirements.map((item) => ({ ...item }))
37664
+ };
37665
+ return { status: "action-required", identity: digest3({ projects: effectiveProjects, requirements: uniqueRequirements, planRequest }), requirements: uniqueRequirements, planRequest };
37666
+ }
37622
37667
  function deriveTaskVerificationPolicyInput(targetRoot, taskId2, input2) {
37623
37668
  assertFields4(input2, /* @__PURE__ */ new Set(["targetIdentity", "formalPlans", "declarationRoot"]), "Task Verification policy projection");
37624
37669
  const targetIdentity = currentTarget2(input2.targetIdentity);
@@ -37649,13 +37694,13 @@ function registerTaskVerificationApplication(runtime2) {
37649
37694
  if (typeof entry.project !== "string" || !entry.project.trim()) throw taskVerificationError("task_verification_policy_plan_project_invalid", `formalPlans[${index}].project必须是非空字符串。`, 400);
37650
37695
  const project = entry.project.trim();
37651
37696
  if (byProject.has(project)) throw taskVerificationError("task_verification_policy_plan_project_duplicate", `Formal Plan Project重复:${project}。`, 400, { project });
37652
- let plan2;
37697
+ let document;
37653
37698
  try {
37654
- plan2 = assertVerificationPlanDocument(entry.document).plan;
37699
+ document = assertVerificationPlanDocument(entry.document);
37655
37700
  } catch (error3) {
37656
37701
  throw taskVerificationError("task_verification_policy_plan_invalid", `Formal Plan不可用:${project}:${error3.message}`, 400, { project });
37657
37702
  }
37658
- byProject.set(project, plan2);
37703
+ byProject.set(project, document);
37659
37704
  }
37660
37705
  const actualProjects = [...byProject.keys()].sort((left, right) => left.localeCompare(right));
37661
37706
  if (JSON.stringify(actualProjects) !== JSON.stringify(effectiveProjects)) {
@@ -37669,7 +37714,7 @@ function registerTaskVerificationApplication(runtime2) {
37669
37714
  for (const project of effectiveProjects) {
37670
37715
  const observation2 = observationByProject.get(project);
37671
37716
  if (!observation2?.valid || !observation2.declaration) throw taskVerificationError("task_verification_declaration_invalid", `Project ${project} verification declaration不可用:${observation2?.diagnostic || "missing"}。`, 409, { project, identity: observation2?.identity || null });
37672
- const plan2 = byProject.get(project);
37717
+ const plan2 = byProject.get(project).plan;
37673
37718
  if (plan2.target.kind !== "task-delivery" || plan2.target.identity !== targetIdentity) {
37674
37719
  throw taskVerificationError("task_verification_policy_plan_target_mismatch", `Formal Plan target不匹配:${project}。`, 409, { project, expectedTarget: targetIdentity, actualTarget: plan2.target });
37675
37720
  }
@@ -37696,6 +37741,7 @@ function registerTaskVerificationApplication(runtime2) {
37696
37741
  if (selectedIds.size === 0 && plan2.coverageGaps.length === 0) throw taskVerificationError("task_verification_policy_plan_empty", `Formal Plan既未选择capability也没有coverage gap:${project}。`, 409, { project });
37697
37742
  plans.push({ project, identity: plan2.identity, requestIdentity: plan2.requestIdentity, status: plan2.status, declarationIdentity: plan2.declarationIdentity });
37698
37743
  }
37744
+ const preparation = aggregateFormalPlanPreparation(effectiveProjects, byProject);
37699
37745
  return {
37700
37746
  schemaVersion: "buildr.task-verification-policy-input-projection/v1",
37701
37747
  operation: "derive-policy",
@@ -37704,6 +37750,7 @@ function registerTaskVerificationApplication(runtime2) {
37704
37750
  targetIdentity,
37705
37751
  inputJson: { capabilities, coverageGaps, overrides: [] },
37706
37752
  selection: { plans, notSelectedCapabilities },
37753
+ preparation,
37707
37754
  diagnostic: null,
37708
37755
  effects: [],
37709
37756
  nextActions: coverageGaps.length ? ["保留Plan coverage gap并由Agent决定修复、补充风险能力或在后续Result中如实对账。"] : []
@@ -37877,7 +37924,8 @@ function registerTaskVerificationApplication(runtime2) {
37877
37924
  const observations = observeDeclarations(task, input2.declarationRoot);
37878
37925
  const observationByProject = new Map(observations.map((item) => [item.project, item]));
37879
37926
  const capabilities = [];
37880
- let planBinding = null;
37927
+ const planBindings = /* @__PURE__ */ new Map();
37928
+ const recordProjects = /* @__PURE__ */ new Set();
37881
37929
  for (const recordId of input2.recordIds) {
37882
37930
  let detail;
37883
37931
  let summary;
@@ -37892,13 +37940,18 @@ function registerTaskVerificationApplication(runtime2) {
37892
37940
  if (summary.schemaVersion !== "buildr.verification-execution-record-summary/v1" || summary.task?.id !== taskId2) throw taskVerificationError("task_verification_evidence_mismatch", `Execution Record Task或schema不匹配:${recordId}。`, 409, { recordId });
37893
37941
  if (!summary.plan?.identity || !summary.plan?.requestIdentity) throw taskVerificationError("task_verification_evidence_plan_missing", `Execution Record未绑定Verification Request/Plan:${recordId}。`, 409, { recordId });
37894
37942
  if (!Array.isArray(summary.plan.executionUnits) || summary.plan.executionUnits.length === 0) throw taskVerificationError("task_verification_evidence_plan_missing", `Execution Record未绑定selected execution unit:${recordId}。`, 409, { recordId });
37895
- if (!planBinding) planBinding = { identity: summary.plan.identity, requestIdentity: summary.plan.requestIdentity, providerIdentity: summary.plan.providerIdentity || null };
37896
- else if (planBinding.identity !== summary.plan.identity || planBinding.requestIdentity !== summary.plan.requestIdentity || planBinding.providerIdentity !== (summary.plan.providerIdentity || null)) throw taskVerificationError("task_verification_evidence_plan_mismatch", `Execution Records不属于同一Verification Request/Plan/provider:${recordId}。`, 409, { recordId, expected: planBinding, actual: summary.plan });
37897
37943
  if (summary.candidate?.identity !== input2.candidateIdentity || summary.candidate?.generation !== input2.candidateGeneration || summary.candidate?.contentTargetIdentity !== input2.targetIdentity || summary.target?.identity !== input2.targetIdentity) throw taskVerificationError("task_verification_evidence_candidate_mismatch", `Execution Record Candidate或Content Target不匹配:${recordId}。`, 409, { recordId });
37898
37944
  if (summary.target?.stable !== true || summary.target?.drift) throw taskVerificationError("task_verification_evidence_target_drift", `Execution Record target发生漂移:${recordId}。`, 409, { recordId });
37899
37945
  const project = summary.project?.code;
37900
37946
  const observation2 = observationByProject.get(project);
37901
37947
  if (!observation2 || observation2.path !== summary.declaration?.path || observation2.identity !== summary.declaration?.identity) throw taskVerificationError("task_verification_evidence_declaration_mismatch", `Execution Record declaration不匹配:${recordId}。`, 409, { recordId, project });
37948
+ const planBinding = { identity: summary.plan.identity, requestIdentity: summary.plan.requestIdentity, providerIdentity: summary.plan.providerIdentity || null };
37949
+ const expectedPlanBinding = planBindings.get(project);
37950
+ if (expectedPlanBinding && (expectedPlanBinding.identity !== planBinding.identity || expectedPlanBinding.requestIdentity !== planBinding.requestIdentity || expectedPlanBinding.providerIdentity !== planBinding.providerIdentity)) {
37951
+ throw taskVerificationError("task_verification_evidence_plan_mismatch", `同一Project的Execution Records不属于同一Verification Request/Plan/provider:${recordId}。`, 409, { recordId, project, expected: expectedPlanBinding, actual: planBinding });
37952
+ }
37953
+ planBindings.set(project, planBinding);
37954
+ recordProjects.add(project);
37902
37955
  const selected = new Map((summary.selectedCapabilities || []).map((item) => [item.id, item]));
37903
37956
  if (!Array.isArray(summary.checks) || summary.checks.length !== selected.size) throw taskVerificationError("task_verification_evidence_incomplete", `Execution Record capability checks不完整:${recordId}。`, 409, { recordId });
37904
37957
  for (const check of summary.checks) {
@@ -37913,6 +37966,14 @@ function registerTaskVerificationApplication(runtime2) {
37913
37966
  }
37914
37967
  }
37915
37968
  const coverageGaps = input2.coverageGaps || [];
37969
+ const coveredProjects = new Set(recordProjects);
37970
+ for (const gap2 of coverageGaps) {
37971
+ const project = gap2.scope?.match(/^project:([^/]+)$/)?.[1];
37972
+ if (project) coveredProjects.add(project);
37973
+ }
37974
+ const effectiveProjects = taskRecordEffectiveProjectCodes(task.record);
37975
+ const missingProjects = effectiveProjects.filter((project) => !coveredProjects.has(project));
37976
+ if (missingProjects.length) throw taskVerificationError("task_verification_evidence_projects_incomplete", "Execution Records与project coverage gaps必须精确覆盖Task有效Project集合。", 409, { expectedProjects: effectiveProjects, actualProjects: [...coveredProjects].sort((left, right) => left.localeCompare(right)), missingProjects });
37916
37977
  const failed = capabilities.some((item) => item.outcome === "failed") || coverageGaps.length > 0;
37917
37978
  const draft = normalizeTaskVerificationResult({
37918
37979
  schemaVersion: "buildr.task-verification-result/v2",
@@ -38841,14 +38902,40 @@ function normalizeDecision(value) {
38841
38902
  }
38842
38903
  function createTaskDevelopmentKnowledge(value) {
38843
38904
  const knowledge2 = object11(value, "currentKnowledge");
38844
- closed12(knowledge2, /* @__PURE__ */ new Set(["identity", "treeIdentity", "status", "summary", "sourceIdentities", "unresolvedItems"]), "currentKnowledge");
38845
- if (!TASK_DEVELOPMENT_KNOWLEDGE_STATUSES.includes(knowledge2.status)) throw taskDevelopmentError("task_development_knowledge_status_invalid", "currentKnowledge.status不受支持。", 400, { status: knowledge2.status });
38905
+ closed12(knowledge2, /* @__PURE__ */ new Set(["identity", "treeIdentity", "status", "summary", "sourceIdentities", "unresolvedItems", "projects"]), "currentKnowledge");
38906
+ if (knowledge2.projects !== void 0 && !Array.isArray(knowledge2.projects)) throw taskDevelopmentError("task_development_field_invalid", "currentKnowledge.projects必须是数组。", 400, { field: "currentKnowledge.projects" });
38907
+ const projects = knowledge2.projects === void 0 ? null : knowledge2.projects.map((value2, index) => {
38908
+ const field = `currentKnowledge.projects[${index}]`;
38909
+ const item = object11(value2, field);
38910
+ closed12(item, /* @__PURE__ */ new Set(["project", "status", "summary", "sourceIdentities", "unresolvedItems"]), field);
38911
+ if (!TASK_DEVELOPMENT_KNOWLEDGE_STATUSES.includes(item.status)) throw taskDevelopmentError("task_development_knowledge_status_invalid", `${field}.status不受支持。`, 400, { status: item.status });
38912
+ const unresolvedItems2 = uniqueStrings(item.unresolvedItems, `${field}.unresolvedItems`);
38913
+ if (item.status === "blocked" && unresolvedItems2.length === 0) throw taskDevelopmentError("task_development_knowledge_blocker_required", `${field} blocked必须包含unresolvedItems。`, 409);
38914
+ return {
38915
+ project: portableText3(item.project, `${field}.project`),
38916
+ status: item.status,
38917
+ summary: portableText3(item.summary, `${field}.summary`),
38918
+ sourceIdentities: uniqueStrings(item.sourceIdentities, `${field}.sourceIdentities`),
38919
+ unresolvedItems: unresolvedItems2
38920
+ };
38921
+ }).sort((left, right) => left.project.localeCompare(right.project));
38922
+ if (projects && new Set(projects.map((item) => item.project)).size !== projects.length) throw taskDevelopmentError("task_development_knowledge_project_duplicate", "currentKnowledge.projects Project不能重复。", 400);
38923
+ const status = projects ? projects.some((item) => item.status === "blocked") ? "blocked" : projects.some((item) => item.status === "attention") ? "attention" : projects.some((item) => item.status === "aligned") ? "aligned" : "not-applicable" : knowledge2.status;
38924
+ if (!TASK_DEVELOPMENT_KNOWLEDGE_STATUSES.includes(status)) throw taskDevelopmentError("task_development_knowledge_status_invalid", "currentKnowledge.status不受支持。", 400, { status });
38925
+ const summary = projects ? `${projects.length}个Project Current Knowledge已聚合:${projects.map((item) => `${item.project}=${item.status}`).join(",")}。` : portableText3(knowledge2.summary, "currentKnowledge.summary");
38926
+ const sourceIdentities = projects ? [...new Set(projects.flatMap((item) => item.sourceIdentities))].sort() : uniqueStrings(knowledge2.sourceIdentities, "currentKnowledge.sourceIdentities");
38927
+ const unresolvedItems = projects ? [...new Set(projects.flatMap((item) => item.unresolvedItems))].sort() : uniqueStrings(knowledge2.unresolvedItems, "currentKnowledge.unresolvedItems");
38928
+ if (projects && knowledge2.status !== void 0 && knowledge2.status !== status) throw taskDevelopmentError("task_development_knowledge_aggregate_mismatch", "currentKnowledge.status与Project dispositions聚合不一致。", 409, { expected: status, actual: knowledge2.status });
38929
+ if (projects && knowledge2.summary !== void 0 && knowledge2.summary !== summary) throw taskDevelopmentError("task_development_knowledge_aggregate_mismatch", "currentKnowledge.summary与Project dispositions聚合不一致。", 409);
38930
+ if (projects && knowledge2.sourceIdentities !== void 0 && JSON.stringify([...knowledge2.sourceIdentities].sort()) !== JSON.stringify(sourceIdentities)) throw taskDevelopmentError("task_development_knowledge_aggregate_mismatch", "currentKnowledge.sourceIdentities与Project dispositions聚合不一致。", 409);
38931
+ if (projects && knowledge2.unresolvedItems !== void 0 && JSON.stringify([...knowledge2.unresolvedItems].sort()) !== JSON.stringify(unresolvedItems)) throw taskDevelopmentError("task_development_knowledge_aggregate_mismatch", "currentKnowledge.unresolvedItems与Project dispositions聚合不一致。", 409);
38846
38932
  const payload2 = {
38847
38933
  treeIdentity: digestIdentity(knowledge2.treeIdentity, "currentKnowledge.treeIdentity"),
38848
- status: knowledge2.status,
38849
- summary: portableText3(knowledge2.summary, "currentKnowledge.summary"),
38850
- sourceIdentities: uniqueStrings(knowledge2.sourceIdentities, "currentKnowledge.sourceIdentities"),
38851
- unresolvedItems: uniqueStrings(knowledge2.unresolvedItems, "currentKnowledge.unresolvedItems")
38934
+ status,
38935
+ summary,
38936
+ sourceIdentities,
38937
+ unresolvedItems,
38938
+ ...projects ? { projects } : {}
38852
38939
  };
38853
38940
  const identity7 = taskDevelopmentDigest(payload2);
38854
38941
  if (knowledge2.identity !== void 0) assertDerivedIdentity(knowledge2.identity, identity7, "currentKnowledge.identity");
@@ -39226,7 +39313,14 @@ var init_task_development_operation_contracts = __esm({
39226
39313
  status: { type: "string", enum: ["aligned", "not-applicable", "attention", "blocked"] },
39227
39314
  summary: text15(),
39228
39315
  sourceIdentities: array2(text15()),
39229
- unresolvedItems: array2(text15())
39316
+ unresolvedItems: array2(text15()),
39317
+ projects: array2(closed14({
39318
+ project: text15("Task有效Project code。"),
39319
+ status: { type: "string", enum: ["aligned", "not-applicable", "attention", "blocked"] },
39320
+ summary: text15(),
39321
+ sourceIdentities: array2(text15()),
39322
+ unresolvedItems: array2(text15())
39323
+ }, ["project", "status", "summary", "sourceIdentities", "unresolvedItems"]))
39230
39324
  };
39231
39325
  risk = closed14({
39232
39326
  gate: { type: "string", enum: ["verification", "completion"] },
@@ -39300,8 +39394,8 @@ var init_task_development_operation_contracts = __esm({
39300
39394
  },
39301
39395
  knowledge: {
39302
39396
  summary: "保存selected Current Knowledge provider针对current Content Target的最小disposition。",
39303
- inputSchema: inputSchema(knowledge, ["treeIdentity", "status", "summary", "sourceIdentities", "unresolvedItems"]),
39304
- example: { treeIdentity: "sha256-<content-target>", status: "aligned", summary: "<knowledge-summary>", sourceIdentities: [], unresolvedItems: [] }
39397
+ inputSchema: inputSchema(knowledge, ["treeIdentity"]),
39398
+ example: { treeIdentity: "sha256-<content-target>", projects: [{ project: "<project>", status: "aligned", summary: "<knowledge-summary>", sourceIdentities: [], unresolvedItems: [] }] }
39305
39399
  },
39306
39400
  gate: {
39307
39401
  summary: "记录 planning、verification 或 completion gate 的明确 waiver/not-applicable disposition。",
@@ -39963,6 +40057,12 @@ function registerTaskDevelopmentApplication(runtime2) {
39963
40057
  const persistence7 = runtime2.readTaskDevelopmentPersistence(targetRoot, taskId2, { optional: false });
39964
40058
  const observed = observeCurrent(targetRoot, taskId2, persistence7.receipt);
39965
40059
  if (!observed.target || observed.target.identity !== persistence7.receipt.contentTarget?.identity || input2.treeIdentity !== observed.target.identity) throw taskDevelopmentError("task_development_knowledge_target_mismatch", "knowledge disposition必须绑定current Content Target。", 409, { expected: observed.target?.identity || null, actual: input2.treeIdentity });
40060
+ const effectiveProjects = taskRecordEffectiveProjectCodes(observed.inspected.record);
40061
+ if (effectiveProjects.length > 1 && !Array.isArray(input2.projects)) throw taskDevelopmentError("task_development_knowledge_projects_required", "多Project Task的knowledge disposition必须按Project完整提交。", 409, { expectedProjects: effectiveProjects });
40062
+ if (Array.isArray(input2.projects)) {
40063
+ const actualProjects = input2.projects.map((item) => item?.project).sort((left, right) => String(left).localeCompare(String(right)));
40064
+ if (!same2(actualProjects, effectiveProjects)) throw taskDevelopmentError("task_development_knowledge_projects_incomplete", "Current Knowledge Project dispositions必须精确覆盖Task有效Project集合。", 409, { expectedProjects: effectiveProjects, actualProjects });
40065
+ }
39966
40066
  const currentKnowledge = createTaskDevelopmentKnowledge(input2);
39967
40067
  const receipt = normalizeTaskDevelopmentReceipt({ ...persistence7.receipt, currentKnowledge, gates: observed.gates, decision: null, updatedAt: now2() }, { expectedTaskId: taskId2 });
39968
40068
  const written = writeDevelopment(targetRoot, taskId2, persistence7.receipt, receipt);
@@ -42967,6 +43067,13 @@ function observeTaskFinishEntryReadiness({
42967
43067
  pushGap(gaps, gap("delivery", error3.code || "task_finish.reconciliation_context_unavailable", error3.message, error3.details ? { details: error3.details } : {}));
42968
43068
  context2 = null;
42969
43069
  }
43070
+ } else if (environmentReady && allowEnvironmentless && resolved.current && (context2.repositories || []).length === 0) {
43071
+ try {
43072
+ const fallback = resolveTaskFinishReconciliationContext({ runtime: runtime2, root, task, receipt: resolved.receipt, requestedTargetBranch, requestedRemote });
43073
+ repositories = fallback.repositories;
43074
+ } catch (error3) {
43075
+ pushGap(gaps, gap("delivery", error3.code || "task_finish.reconciliation_context_unavailable", error3.message, error3.details ? { details: error3.details } : {}));
43076
+ }
42970
43077
  } else if (environmentReady) {
42971
43078
  repositories = resolveRepositoryPlans({ context: context2, requestedTargetBranch, requestedRemote, gaps });
42972
43079
  }
@@ -46363,6 +46470,22 @@ function registerTaskFinishApplication(runtime2) {
46363
46470
  const requestedTargetBranch = optionValue(command2.args, "--target-branch", null);
46364
46471
  const requestedRemote = optionValue(command2.args, "--remote", null);
46365
46472
  const currentIdentityMatchesRequest = current?.run?.identity?.task === task && (!requestedAgent || current.run.identity.agent === requestedAgent) && (!requestedTargetBranch || current.run.identity.targetBranch === requestedTargetBranch) && (!requestedRemote || current.run.identity.remote === requestedRemote);
46473
+ const preparedCompletionMatchesRun = current?.preparedCompletion?.task === current?.run?.identity?.task && current.preparedCompletion.runId === current.run.runId && current.preparedCompletion.handoffIdentity === current.run.identity.handoffIdentity && current.preparedCompletion.candidateIdentity === current.run.identity.candidateIdentity && current.preparedCompletion.candidateGeneration === current.run.identity.candidateGeneration && current.preparedCompletion.contentTargetIdentity === current.run.identity.contentTargetIdentity;
46474
+ const terminalPersistenceMismatch = currentIdentityMatchesRequest && current.run.status === "complete" && current.run.completion?.status === "complete" && current.preparedCompletion?.status === "complete" && preparedCompletionMatchesRun && current.lease == null && current.run.phases.every((phase2) => ["passed", "not-applicable"].includes(phase2.status)) && current.run.completion?.persistence?.code === "task_finish_current_query_fields_mismatch";
46475
+ if (terminalPersistenceMismatch) {
46476
+ const recoveredRun = structuredClone(current.run);
46477
+ recoveredRun.completion = structuredClone(current.preparedCompletion);
46478
+ const result6 = finishResult(recoveredRun);
46479
+ runtime2.finalizeTaskFinishPersistence(root, {
46480
+ run: recoveredRun,
46481
+ result: result6,
46482
+ completion: recoveredRun.completion
46483
+ });
46484
+ return print9({
46485
+ ...inspectFinishRun({ root, runId: recoveredRun.runId, runtime: runtime2 }),
46486
+ persistenceRecovered: true
46487
+ }, command2.args);
46488
+ }
46366
46489
  if (currentIdentityMatchesRequest && current.run.status === "complete" && current.run.completion?.status === "complete" && current.run.developmentHandoff) {
46367
46490
  const result6 = reconcileTaskFinishDelivery({
46368
46491
  runtime: runtime2,
@@ -49578,6 +49701,7 @@ function currentRecord(run2, { preparedCompletion = null, lease = null } = {}) {
49578
49701
  function terminalRecord(run2, result5, completion2) {
49579
49702
  const normalized = assertRun(run2);
49580
49703
  const storedResult = compactResult(result5);
49704
+ const identityDigest = normalized.identityDigest || digest22(normalized.identity);
49581
49705
  const fullCompletion = {
49582
49706
  ...clone6(completion2) || {},
49583
49707
  task: normalized.identity.task,
@@ -49593,40 +49717,18 @@ function terminalRecord(run2, result5, completion2) {
49593
49717
  completedAt: result5?.completedAt || timestamp8()
49594
49718
  };
49595
49719
  const phases2 = assertPhases(storedResult.phases);
49720
+ const queryFields = terminalQueryFields(fullCompletion, identityDigest);
49596
49721
  return {
49597
49722
  record: {
49598
49723
  task_id: normalized.identity.task,
49599
49724
  run_id: normalized.runId,
49600
49725
  schema_version: CURRENT_SCHEMA,
49601
- status: "complete",
49602
- identity_digest: normalized.identityDigest || digest22(normalized.identity),
49603
- current_phase: "cleanup",
49604
- handoff_identity: normalized.identity.handoffIdentity,
49605
- candidate_identity: normalized.identity.candidateIdentity,
49606
- candidate_generation: normalized.identity.candidateGeneration,
49607
- content_target_identity: normalized.identity.contentTargetIdentity,
49608
- target_branch: normalized.identity.targetBranch,
49609
- target_remote: normalized.identity.remote || null,
49610
- carrier_identity: normalized.deliveryCarrier?.identity || fullCompletion.carrierIdentity || null,
49611
- repository_set_identity: repositorySetIdentity(normalized, storedResult),
49612
- carrier_set_identity: carrierSetIdentity(normalized, storedResult, fullCompletion),
49613
- delivery_set_identity: deliverySetIdentity(normalized, storedResult, fullCompletion),
49614
- ...associationValues(fullCompletion),
49615
- primary_failure_phase: null,
49616
- primary_failure_operation: null,
49617
- primary_failure_class: null,
49618
- primary_failure_code: null,
49619
- primary_failure_status: null,
49620
- primary_failure_exit_code: null,
49621
- primary_failure_diagnostic_digest: null,
49622
- resume_phase: null,
49623
- resume_token: null,
49624
- cleanup_status: fullCompletion.cleanup?.status || normalized.completion?.cleanup?.status || null,
49726
+ ...queryFields,
49625
49727
  lease_target_identity: null,
49626
49728
  lease_token: null,
49627
49729
  lease_expires_at: null,
49628
49730
  phases_json: JSON.stringify(phases2),
49629
- payload_json: JSON.stringify({ kind: "terminal", identityDigest: normalized.identityDigest || digest22(normalized.identity), completion: completionDetail(fullCompletion) }),
49731
+ payload_json: JSON.stringify({ kind: "terminal", identityDigest, completion: completionDetail(fullCompletion) }),
49630
49732
  created_at: normalized.createdAt || fullCompletion.completedAt,
49631
49733
  updated_at: timestamp8(),
49632
49734
  completed_at: fullCompletion.completedAt
@@ -49654,8 +49756,7 @@ function decodeRow(row) {
49654
49756
  const completion2 = clone6(payload2.completion);
49655
49757
  completion2.result = { ...completion2.result || {}, phases: phases2 };
49656
49758
  if (row.status !== "complete" || completion2.task !== row.task_id || completion2.runId !== row.run_id || completion2.status !== "complete") throw error("task_finish_terminal_payload_mismatch", "Task Finish terminal普通列与payload不一致。", 500, { taskId: row.task_id, runId: row.run_id });
49657
- const expected = terminalQueryFields(completion2);
49658
- expected.identity_digest = payload2.identityDigest || expected.identity_digest || row.identity_digest;
49759
+ const expected = terminalQueryFields(completion2, payload2.identityDigest || row.identity_digest);
49659
49760
  assertQueryFields(row, expected);
49660
49761
  return { kind: "terminal", completion: completion2, phases: phases2 };
49661
49762
  }
@@ -49725,18 +49826,18 @@ function assertQueryFields(row, expected) {
49725
49826
  const mismatches = QUERY_FIELDS.filter((field) => (row[field] ?? null) !== (expected[field] ?? null));
49726
49827
  if (mismatches.length) throw error("task_finish_current_query_fields_mismatch", `Task Finish current普通列与payload不一致:${mismatches.join(", ")}。`, 500, { taskId: row.task_id, runId: row.run_id, mismatches });
49727
49828
  }
49728
- function terminalQueryFields(completion2) {
49829
+ function terminalQueryFields(completion2, identityDigest = null) {
49729
49830
  const result5 = completion2.result || {};
49730
49831
  return {
49731
- identity_digest: result5.identity ? digest22(result5.identity) : null,
49832
+ identity_digest: identityDigest,
49732
49833
  status: "complete",
49733
49834
  current_phase: "cleanup",
49734
49835
  handoff_identity: completion2.handoffIdentity,
49735
49836
  candidate_identity: completion2.candidateIdentity,
49736
49837
  candidate_generation: completion2.candidateGeneration,
49737
49838
  content_target_identity: completion2.contentTargetIdentity,
49738
- target_branch: completion2.targetBranch,
49739
- target_remote: result5.identity?.remote || null,
49839
+ target_branch: result5.identity?.targetBranch ?? completion2.targetBranch ?? null,
49840
+ target_remote: result5.identity?.remote ?? null,
49740
49841
  carrier_identity: completion2.carrierIdentity || result5.carrier?.identity || null,
49741
49842
  repository_set_identity: result5.repositorySetIdentity || result5.identity?.repositorySetIdentity || null,
49742
49843
  carrier_set_identity: result5.carrierSetIdentity || completion2.carrierSetIdentity || null,
@@ -53402,6 +53503,7 @@ function createTaskFinishCliContributions(application = null) {
53402
53503
  "Usage: buildr task finish reconcile --task <task-id> [--agent <agent>] [--target-branch <branch>] [--remote <name>] [--target <canonical-workspace>] [--detail <compact|full|self-bootstrap>] [--json]",
53403
53504
  "",
53404
53505
  "从current Development handoff解析交付身份;优先复用Task Environment repository set,缺失或已清理时从Task scope、registries与实际Git topology构造只读上下文,再读取真实远端ref逐仓库验证Task Contribution包含关系。",
53506
+ "若matching completed run仅因terminal query fields持久化校验失败而保留current,reconcile只复用受验证prepared completion原子补写terminal state,不重复观察远端、交付或cleanup。",
53405
53507
  "不接受success、evidence、commit message、run token或手写proof;不会push、force push、改写共享历史或创建Delivery Carrier。",
53406
53508
  "逐repository立即保存已证明Delivery;全部适用repository成立后提交Task交付终态。activation、Environment cleanup与diagnostics独立处理;无current Environment时cleanup不声称cleaned。"
53407
53509
  ],
@@ -18020,6 +18020,7 @@ var require_pattern = __commonJS({
18020
18020
  "use strict";
18021
18021
  Object.defineProperty(exports2, "__esModule", { value: true });
18022
18022
  var code_1 = require_code2();
18023
+ var util_1 = require_util();
18023
18024
  var codegen_1 = require_codegen();
18024
18025
  var error3 = {
18025
18026
  message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
@@ -18032,10 +18033,18 @@ var require_pattern = __commonJS({
18032
18033
  $data: true,
18033
18034
  error: error3,
18034
18035
  code(cxt) {
18035
- const { data, $data, schema: schema7, schemaCode, it } = cxt;
18036
+ const { gen, data, $data, schema: schema7, schemaCode, it } = cxt;
18036
18037
  const u = it.opts.unicodeRegExp ? "u" : "";
18037
- const regExp = $data ? (0, codegen_1._)`(new RegExp(${schemaCode}, ${u}))` : (0, code_1.usePattern)(cxt, schema7);
18038
- cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
18038
+ if ($data) {
18039
+ const { regExp } = it.opts.code;
18040
+ const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
18041
+ const valid = gen.let("valid");
18042
+ gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
18043
+ cxt.fail$data((0, codegen_1._)`!${valid}`);
18044
+ } else {
18045
+ const regExp = (0, code_1.usePattern)(cxt, schema7);
18046
+ cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
18047
+ }
18039
18048
  }
18040
18049
  };
18041
18050
  exports2.default = def;
@@ -28525,6 +28534,42 @@ function registerTaskVerificationApplication(runtime) {
28525
28534
  function declarationValues(observations) {
28526
28535
  return observations.map(({ project, path: declarationPath, identity: identity7 }) => ({ project, path: declarationPath, identity: identity7 }));
28527
28536
  }
28537
+ function aggregateFormalPlanPreparation(effectiveProjects, byProject) {
28538
+ const documents = effectiveProjects.map((project) => ({ project, result: byProject.get(project)?.result || null }));
28539
+ if (documents.some((entry) => !entry.result?.preparation)) return null;
28540
+ const requirements = [];
28541
+ const baseRequests = [];
28542
+ for (const { project, result: result5 } of documents) {
28543
+ const preparation = result5.preparation;
28544
+ if (preparation.status === "action-required" && !preparation.planRequest) throw taskVerificationError("task_verification_policy_preparation_request_missing", `Formal Plan preparation缺少Plan Request:${project}。`, 409, { project });
28545
+ if (preparation.planRequest) {
28546
+ assertFields4(preparation.planRequest, /* @__PURE__ */ new Set(["schemaVersion", "notApplicableReason", "projects", "auxiliaryPreparation"]), `formalPlans.${project}.preparation.planRequest`);
28547
+ if (preparation.planRequest.schemaVersion !== "buildr.task-environment-plan-request/v1" || !Array.isArray(preparation.planRequest.projects)) throw taskVerificationError("task_verification_policy_preparation_request_invalid", `Formal Plan preparation Plan Request不合法:${project}。`, 409, { project });
28548
+ baseRequests.push({ project, request: preparation.planRequest });
28549
+ }
28550
+ for (const [index, requirement] of preparation.requirements.entries()) {
28551
+ assertFields4(requirement, /* @__PURE__ */ new Set(["capability", "capabilityIdentity", "project", "selector", "recipe"]), `formalPlans.${project}.preparation.requirements[${index}]`);
28552
+ if ([requirement.capability, requirement.capabilityIdentity, requirement.project, requirement.selector, requirement.recipe].some((value) => typeof value !== "string" || !value)) throw taskVerificationError("task_verification_policy_preparation_requirement_invalid", `Formal Plan preparation requirement不合法:${project}/${index}。`, 409, { project, index });
28553
+ if (requirement.project !== project) throw taskVerificationError("task_verification_policy_preparation_requirement_project_mismatch", `Formal Plan preparation requirement Project不匹配:${project}/${requirement.project}。`, 409, { project, actualProject: requirement.project });
28554
+ requirements.push(requirement);
28555
+ }
28556
+ }
28557
+ const uniqueRequirements = [...new Map(requirements.sort((left, right) => JSON.stringify(left).localeCompare(JSON.stringify(right))).map((item) => [`${item.capabilityIdentity}/${item.project}/${item.selector}/${item.recipe}`, item])).values()];
28558
+ if (!baseRequests.length) return { status: "ready", identity: digest4({ projects: effectiveProjects, requirements: uniqueRequirements }), requirements: uniqueRequirements, planRequest: null };
28559
+ const base = baseRequests[0].request;
28560
+ const baseIdentity = JSON.stringify({ projects: base.projects, ...base.notApplicableReason ? { notApplicableReason: base.notApplicableReason } : {} });
28561
+ for (const entry of baseRequests.slice(1)) {
28562
+ const actual = JSON.stringify({ projects: entry.request.projects, ...entry.request.notApplicableReason ? { notApplicableReason: entry.request.notApplicableReason } : {} });
28563
+ if (actual !== baseIdentity) throw taskVerificationError("task_verification_policy_preparation_base_mismatch", `Formal Plan preparation base scopes不一致:${entry.project}。`, 409, { project: entry.project });
28564
+ }
28565
+ const planRequest = {
28566
+ schemaVersion: "buildr.task-environment-plan-request/v1",
28567
+ ...base.notApplicableReason ? { notApplicableReason: base.notApplicableReason } : {},
28568
+ projects: structuredClone(base.projects),
28569
+ auxiliaryPreparation: uniqueRequirements.map((item) => ({ ...item }))
28570
+ };
28571
+ return { status: "action-required", identity: digest4({ projects: effectiveProjects, requirements: uniqueRequirements, planRequest }), requirements: uniqueRequirements, planRequest };
28572
+ }
28528
28573
  function deriveTaskVerificationPolicyInput(targetRoot, taskId2, input2) {
28529
28574
  assertFields4(input2, /* @__PURE__ */ new Set(["targetIdentity", "formalPlans", "declarationRoot"]), "Task Verification policy projection");
28530
28575
  const targetIdentity = currentTarget2(input2.targetIdentity);
@@ -28555,13 +28600,13 @@ function registerTaskVerificationApplication(runtime) {
28555
28600
  if (typeof entry.project !== "string" || !entry.project.trim()) throw taskVerificationError("task_verification_policy_plan_project_invalid", `formalPlans[${index}].project必须是非空字符串。`, 400);
28556
28601
  const project = entry.project.trim();
28557
28602
  if (byProject.has(project)) throw taskVerificationError("task_verification_policy_plan_project_duplicate", `Formal Plan Project重复:${project}。`, 400, { project });
28558
- let plan2;
28603
+ let document;
28559
28604
  try {
28560
- plan2 = assertVerificationPlanDocument(entry.document).plan;
28605
+ document = assertVerificationPlanDocument(entry.document);
28561
28606
  } catch (error3) {
28562
28607
  throw taskVerificationError("task_verification_policy_plan_invalid", `Formal Plan不可用:${project}:${error3.message}`, 400, { project });
28563
28608
  }
28564
- byProject.set(project, plan2);
28609
+ byProject.set(project, document);
28565
28610
  }
28566
28611
  const actualProjects = [...byProject.keys()].sort((left, right) => left.localeCompare(right));
28567
28612
  if (JSON.stringify(actualProjects) !== JSON.stringify(effectiveProjects)) {
@@ -28575,7 +28620,7 @@ function registerTaskVerificationApplication(runtime) {
28575
28620
  for (const project of effectiveProjects) {
28576
28621
  const observation2 = observationByProject.get(project);
28577
28622
  if (!observation2?.valid || !observation2.declaration) throw taskVerificationError("task_verification_declaration_invalid", `Project ${project} verification declaration不可用:${observation2?.diagnostic || "missing"}。`, 409, { project, identity: observation2?.identity || null });
28578
- const plan2 = byProject.get(project);
28623
+ const plan2 = byProject.get(project).plan;
28579
28624
  if (plan2.target.kind !== "task-delivery" || plan2.target.identity !== targetIdentity) {
28580
28625
  throw taskVerificationError("task_verification_policy_plan_target_mismatch", `Formal Plan target不匹配:${project}。`, 409, { project, expectedTarget: targetIdentity, actualTarget: plan2.target });
28581
28626
  }
@@ -28602,6 +28647,7 @@ function registerTaskVerificationApplication(runtime) {
28602
28647
  if (selectedIds.size === 0 && plan2.coverageGaps.length === 0) throw taskVerificationError("task_verification_policy_plan_empty", `Formal Plan既未选择capability也没有coverage gap:${project}。`, 409, { project });
28603
28648
  plans.push({ project, identity: plan2.identity, requestIdentity: plan2.requestIdentity, status: plan2.status, declarationIdentity: plan2.declarationIdentity });
28604
28649
  }
28650
+ const preparation = aggregateFormalPlanPreparation(effectiveProjects, byProject);
28605
28651
  return {
28606
28652
  schemaVersion: "buildr.task-verification-policy-input-projection/v1",
28607
28653
  operation: "derive-policy",
@@ -28610,6 +28656,7 @@ function registerTaskVerificationApplication(runtime) {
28610
28656
  targetIdentity,
28611
28657
  inputJson: { capabilities, coverageGaps, overrides: [] },
28612
28658
  selection: { plans, notSelectedCapabilities },
28659
+ preparation,
28613
28660
  diagnostic: null,
28614
28661
  effects: [],
28615
28662
  nextActions: coverageGaps.length ? ["保留Plan coverage gap并由Agent决定修复、补充风险能力或在后续Result中如实对账。"] : []
@@ -28783,7 +28830,8 @@ function registerTaskVerificationApplication(runtime) {
28783
28830
  const observations = observeDeclarations(task, input2.declarationRoot);
28784
28831
  const observationByProject = new Map(observations.map((item) => [item.project, item]));
28785
28832
  const capabilities = [];
28786
- let planBinding = null;
28833
+ const planBindings = /* @__PURE__ */ new Map();
28834
+ const recordProjects = /* @__PURE__ */ new Set();
28787
28835
  for (const recordId of input2.recordIds) {
28788
28836
  let detail;
28789
28837
  let summary;
@@ -28798,13 +28846,18 @@ function registerTaskVerificationApplication(runtime) {
28798
28846
  if (summary.schemaVersion !== "buildr.verification-execution-record-summary/v1" || summary.task?.id !== taskId2) throw taskVerificationError("task_verification_evidence_mismatch", `Execution Record Task或schema不匹配:${recordId}。`, 409, { recordId });
28799
28847
  if (!summary.plan?.identity || !summary.plan?.requestIdentity) throw taskVerificationError("task_verification_evidence_plan_missing", `Execution Record未绑定Verification Request/Plan:${recordId}。`, 409, { recordId });
28800
28848
  if (!Array.isArray(summary.plan.executionUnits) || summary.plan.executionUnits.length === 0) throw taskVerificationError("task_verification_evidence_plan_missing", `Execution Record未绑定selected execution unit:${recordId}。`, 409, { recordId });
28801
- if (!planBinding) planBinding = { identity: summary.plan.identity, requestIdentity: summary.plan.requestIdentity, providerIdentity: summary.plan.providerIdentity || null };
28802
- else if (planBinding.identity !== summary.plan.identity || planBinding.requestIdentity !== summary.plan.requestIdentity || planBinding.providerIdentity !== (summary.plan.providerIdentity || null)) throw taskVerificationError("task_verification_evidence_plan_mismatch", `Execution Records不属于同一Verification Request/Plan/provider:${recordId}。`, 409, { recordId, expected: planBinding, actual: summary.plan });
28803
28849
  if (summary.candidate?.identity !== input2.candidateIdentity || summary.candidate?.generation !== input2.candidateGeneration || summary.candidate?.contentTargetIdentity !== input2.targetIdentity || summary.target?.identity !== input2.targetIdentity) throw taskVerificationError("task_verification_evidence_candidate_mismatch", `Execution Record Candidate或Content Target不匹配:${recordId}。`, 409, { recordId });
28804
28850
  if (summary.target?.stable !== true || summary.target?.drift) throw taskVerificationError("task_verification_evidence_target_drift", `Execution Record target发生漂移:${recordId}。`, 409, { recordId });
28805
28851
  const project = summary.project?.code;
28806
28852
  const observation2 = observationByProject.get(project);
28807
28853
  if (!observation2 || observation2.path !== summary.declaration?.path || observation2.identity !== summary.declaration?.identity) throw taskVerificationError("task_verification_evidence_declaration_mismatch", `Execution Record declaration不匹配:${recordId}。`, 409, { recordId, project });
28854
+ const planBinding = { identity: summary.plan.identity, requestIdentity: summary.plan.requestIdentity, providerIdentity: summary.plan.providerIdentity || null };
28855
+ const expectedPlanBinding = planBindings.get(project);
28856
+ if (expectedPlanBinding && (expectedPlanBinding.identity !== planBinding.identity || expectedPlanBinding.requestIdentity !== planBinding.requestIdentity || expectedPlanBinding.providerIdentity !== planBinding.providerIdentity)) {
28857
+ throw taskVerificationError("task_verification_evidence_plan_mismatch", `同一Project的Execution Records不属于同一Verification Request/Plan/provider:${recordId}。`, 409, { recordId, project, expected: expectedPlanBinding, actual: planBinding });
28858
+ }
28859
+ planBindings.set(project, planBinding);
28860
+ recordProjects.add(project);
28808
28861
  const selected = new Map((summary.selectedCapabilities || []).map((item) => [item.id, item]));
28809
28862
  if (!Array.isArray(summary.checks) || summary.checks.length !== selected.size) throw taskVerificationError("task_verification_evidence_incomplete", `Execution Record capability checks不完整:${recordId}。`, 409, { recordId });
28810
28863
  for (const check of summary.checks) {
@@ -28819,6 +28872,14 @@ function registerTaskVerificationApplication(runtime) {
28819
28872
  }
28820
28873
  }
28821
28874
  const coverageGaps = input2.coverageGaps || [];
28875
+ const coveredProjects = new Set(recordProjects);
28876
+ for (const gap2 of coverageGaps) {
28877
+ const project = gap2.scope?.match(/^project:([^/]+)$/)?.[1];
28878
+ if (project) coveredProjects.add(project);
28879
+ }
28880
+ const effectiveProjects = taskRecordEffectiveProjectCodes(task.record);
28881
+ const missingProjects = effectiveProjects.filter((project) => !coveredProjects.has(project));
28882
+ if (missingProjects.length) throw taskVerificationError("task_verification_evidence_projects_incomplete", "Execution Records与project coverage gaps必须精确覆盖Task有效Project集合。", 409, { expectedProjects: effectiveProjects, actualProjects: [...coveredProjects].sort((left, right) => left.localeCompare(right)), missingProjects });
28822
28883
  const failed = capabilities.some((item) => item.outcome === "failed") || coverageGaps.length > 0;
28823
28884
  const draft = normalizeTaskVerificationResult({
28824
28885
  schemaVersion: "buildr.task-verification-result/v2",
@@ -29747,14 +29808,40 @@ function normalizeDecision(value) {
29747
29808
  }
29748
29809
  function createTaskDevelopmentKnowledge(value) {
29749
29810
  const knowledge2 = object11(value, "currentKnowledge");
29750
- closed13(knowledge2, /* @__PURE__ */ new Set(["identity", "treeIdentity", "status", "summary", "sourceIdentities", "unresolvedItems"]), "currentKnowledge");
29751
- if (!TASK_DEVELOPMENT_KNOWLEDGE_STATUSES.includes(knowledge2.status)) throw taskDevelopmentError("task_development_knowledge_status_invalid", "currentKnowledge.status不受支持。", 400, { status: knowledge2.status });
29811
+ closed13(knowledge2, /* @__PURE__ */ new Set(["identity", "treeIdentity", "status", "summary", "sourceIdentities", "unresolvedItems", "projects"]), "currentKnowledge");
29812
+ if (knowledge2.projects !== void 0 && !Array.isArray(knowledge2.projects)) throw taskDevelopmentError("task_development_field_invalid", "currentKnowledge.projects必须是数组。", 400, { field: "currentKnowledge.projects" });
29813
+ const projects = knowledge2.projects === void 0 ? null : knowledge2.projects.map((value2, index) => {
29814
+ const field = `currentKnowledge.projects[${index}]`;
29815
+ const item = object11(value2, field);
29816
+ closed13(item, /* @__PURE__ */ new Set(["project", "status", "summary", "sourceIdentities", "unresolvedItems"]), field);
29817
+ if (!TASK_DEVELOPMENT_KNOWLEDGE_STATUSES.includes(item.status)) throw taskDevelopmentError("task_development_knowledge_status_invalid", `${field}.status不受支持。`, 400, { status: item.status });
29818
+ const unresolvedItems2 = uniqueStrings(item.unresolvedItems, `${field}.unresolvedItems`);
29819
+ if (item.status === "blocked" && unresolvedItems2.length === 0) throw taskDevelopmentError("task_development_knowledge_blocker_required", `${field} blocked必须包含unresolvedItems。`, 409);
29820
+ return {
29821
+ project: portableText3(item.project, `${field}.project`),
29822
+ status: item.status,
29823
+ summary: portableText3(item.summary, `${field}.summary`),
29824
+ sourceIdentities: uniqueStrings(item.sourceIdentities, `${field}.sourceIdentities`),
29825
+ unresolvedItems: unresolvedItems2
29826
+ };
29827
+ }).sort((left, right) => left.project.localeCompare(right.project));
29828
+ if (projects && new Set(projects.map((item) => item.project)).size !== projects.length) throw taskDevelopmentError("task_development_knowledge_project_duplicate", "currentKnowledge.projects Project不能重复。", 400);
29829
+ const status = projects ? projects.some((item) => item.status === "blocked") ? "blocked" : projects.some((item) => item.status === "attention") ? "attention" : projects.some((item) => item.status === "aligned") ? "aligned" : "not-applicable" : knowledge2.status;
29830
+ if (!TASK_DEVELOPMENT_KNOWLEDGE_STATUSES.includes(status)) throw taskDevelopmentError("task_development_knowledge_status_invalid", "currentKnowledge.status不受支持。", 400, { status });
29831
+ const summary = projects ? `${projects.length}个Project Current Knowledge已聚合:${projects.map((item) => `${item.project}=${item.status}`).join(",")}。` : portableText3(knowledge2.summary, "currentKnowledge.summary");
29832
+ const sourceIdentities = projects ? [...new Set(projects.flatMap((item) => item.sourceIdentities))].sort() : uniqueStrings(knowledge2.sourceIdentities, "currentKnowledge.sourceIdentities");
29833
+ const unresolvedItems = projects ? [...new Set(projects.flatMap((item) => item.unresolvedItems))].sort() : uniqueStrings(knowledge2.unresolvedItems, "currentKnowledge.unresolvedItems");
29834
+ if (projects && knowledge2.status !== void 0 && knowledge2.status !== status) throw taskDevelopmentError("task_development_knowledge_aggregate_mismatch", "currentKnowledge.status与Project dispositions聚合不一致。", 409, { expected: status, actual: knowledge2.status });
29835
+ if (projects && knowledge2.summary !== void 0 && knowledge2.summary !== summary) throw taskDevelopmentError("task_development_knowledge_aggregate_mismatch", "currentKnowledge.summary与Project dispositions聚合不一致。", 409);
29836
+ if (projects && knowledge2.sourceIdentities !== void 0 && JSON.stringify([...knowledge2.sourceIdentities].sort()) !== JSON.stringify(sourceIdentities)) throw taskDevelopmentError("task_development_knowledge_aggregate_mismatch", "currentKnowledge.sourceIdentities与Project dispositions聚合不一致。", 409);
29837
+ if (projects && knowledge2.unresolvedItems !== void 0 && JSON.stringify([...knowledge2.unresolvedItems].sort()) !== JSON.stringify(unresolvedItems)) throw taskDevelopmentError("task_development_knowledge_aggregate_mismatch", "currentKnowledge.unresolvedItems与Project dispositions聚合不一致。", 409);
29752
29838
  const payload2 = {
29753
29839
  treeIdentity: digestIdentity(knowledge2.treeIdentity, "currentKnowledge.treeIdentity"),
29754
- status: knowledge2.status,
29755
- summary: portableText3(knowledge2.summary, "currentKnowledge.summary"),
29756
- sourceIdentities: uniqueStrings(knowledge2.sourceIdentities, "currentKnowledge.sourceIdentities"),
29757
- unresolvedItems: uniqueStrings(knowledge2.unresolvedItems, "currentKnowledge.unresolvedItems")
29840
+ status,
29841
+ summary,
29842
+ sourceIdentities,
29843
+ unresolvedItems,
29844
+ ...projects ? { projects } : {}
29758
29845
  };
29759
29846
  const identity7 = taskDevelopmentDigest(payload2);
29760
29847
  if (knowledge2.identity !== void 0) assertDerivedIdentity(knowledge2.identity, identity7, "currentKnowledge.identity");
@@ -30132,7 +30219,14 @@ var init_task_development_operation_contracts = __esm({
30132
30219
  status: { type: "string", enum: ["aligned", "not-applicable", "attention", "blocked"] },
30133
30220
  summary: text16(),
30134
30221
  sourceIdentities: array2(text16()),
30135
- unresolvedItems: array2(text16())
30222
+ unresolvedItems: array2(text16()),
30223
+ projects: array2(closed15({
30224
+ project: text16("Task有效Project code。"),
30225
+ status: { type: "string", enum: ["aligned", "not-applicable", "attention", "blocked"] },
30226
+ summary: text16(),
30227
+ sourceIdentities: array2(text16()),
30228
+ unresolvedItems: array2(text16())
30229
+ }, ["project", "status", "summary", "sourceIdentities", "unresolvedItems"]))
30136
30230
  };
30137
30231
  risk = closed15({
30138
30232
  gate: { type: "string", enum: ["verification", "completion"] },
@@ -30206,8 +30300,8 @@ var init_task_development_operation_contracts = __esm({
30206
30300
  },
30207
30301
  knowledge: {
30208
30302
  summary: "保存selected Current Knowledge provider针对current Content Target的最小disposition。",
30209
- inputSchema: inputSchema(knowledge, ["treeIdentity", "status", "summary", "sourceIdentities", "unresolvedItems"]),
30210
- example: { treeIdentity: "sha256-<content-target>", status: "aligned", summary: "<knowledge-summary>", sourceIdentities: [], unresolvedItems: [] }
30303
+ inputSchema: inputSchema(knowledge, ["treeIdentity"]),
30304
+ example: { treeIdentity: "sha256-<content-target>", projects: [{ project: "<project>", status: "aligned", summary: "<knowledge-summary>", sourceIdentities: [], unresolvedItems: [] }] }
30211
30305
  },
30212
30306
  gate: {
30213
30307
  summary: "记录 planning、verification 或 completion gate 的明确 waiver/not-applicable disposition。",
@@ -30869,6 +30963,12 @@ function registerTaskDevelopmentApplication(runtime) {
30869
30963
  const persistence7 = runtime.readTaskDevelopmentPersistence(targetRoot, taskId2, { optional: false });
30870
30964
  const observed = observeCurrent(targetRoot, taskId2, persistence7.receipt);
30871
30965
  if (!observed.target || observed.target.identity !== persistence7.receipt.contentTarget?.identity || input2.treeIdentity !== observed.target.identity) throw taskDevelopmentError("task_development_knowledge_target_mismatch", "knowledge disposition必须绑定current Content Target。", 409, { expected: observed.target?.identity || null, actual: input2.treeIdentity });
30966
+ const effectiveProjects = taskRecordEffectiveProjectCodes(observed.inspected.record);
30967
+ if (effectiveProjects.length > 1 && !Array.isArray(input2.projects)) throw taskDevelopmentError("task_development_knowledge_projects_required", "多Project Task的knowledge disposition必须按Project完整提交。", 409, { expectedProjects: effectiveProjects });
30968
+ if (Array.isArray(input2.projects)) {
30969
+ const actualProjects = input2.projects.map((item) => item?.project).sort((left, right) => String(left).localeCompare(String(right)));
30970
+ if (!same2(actualProjects, effectiveProjects)) throw taskDevelopmentError("task_development_knowledge_projects_incomplete", "Current Knowledge Project dispositions必须精确覆盖Task有效Project集合。", 409, { expectedProjects: effectiveProjects, actualProjects });
30971
+ }
30872
30972
  const currentKnowledge = createTaskDevelopmentKnowledge(input2);
30873
30973
  const receipt = normalizeTaskDevelopmentReceipt({ ...persistence7.receipt, currentKnowledge, gates: observed.gates, decision: null, updatedAt: now2() }, { expectedTaskId: taskId2 });
30874
30974
  const written = writeDevelopment(targetRoot, taskId2, persistence7.receipt, receipt);
@@ -33873,6 +33973,13 @@ function observeTaskFinishEntryReadiness({
33873
33973
  pushGap(gaps, gap("delivery", error3.code || "task_finish.reconciliation_context_unavailable", error3.message, error3.details ? { details: error3.details } : {}));
33874
33974
  context2 = null;
33875
33975
  }
33976
+ } else if (environmentReady && allowEnvironmentless && resolved.current && (context2.repositories || []).length === 0) {
33977
+ try {
33978
+ const fallback = resolveTaskFinishReconciliationContext({ runtime, root, task, receipt: resolved.receipt, requestedTargetBranch, requestedRemote });
33979
+ repositories = fallback.repositories;
33980
+ } catch (error3) {
33981
+ pushGap(gaps, gap("delivery", error3.code || "task_finish.reconciliation_context_unavailable", error3.message, error3.details ? { details: error3.details } : {}));
33982
+ }
33876
33983
  } else if (environmentReady) {
33877
33984
  repositories = resolveRepositoryPlans({ context: context2, requestedTargetBranch, requestedRemote, gaps });
33878
33985
  }
@@ -37329,6 +37436,22 @@ function registerTaskFinishApplication(runtime) {
37329
37436
  const requestedTargetBranch = optionValue2(command2.args, "--target-branch", null);
37330
37437
  const requestedRemote = optionValue2(command2.args, "--remote", null);
37331
37438
  const currentIdentityMatchesRequest = current?.run?.identity?.task === task && (!requestedAgent || current.run.identity.agent === requestedAgent) && (!requestedTargetBranch || current.run.identity.targetBranch === requestedTargetBranch) && (!requestedRemote || current.run.identity.remote === requestedRemote);
37439
+ const preparedCompletionMatchesRun = current?.preparedCompletion?.task === current?.run?.identity?.task && current.preparedCompletion.runId === current.run.runId && current.preparedCompletion.handoffIdentity === current.run.identity.handoffIdentity && current.preparedCompletion.candidateIdentity === current.run.identity.candidateIdentity && current.preparedCompletion.candidateGeneration === current.run.identity.candidateGeneration && current.preparedCompletion.contentTargetIdentity === current.run.identity.contentTargetIdentity;
37440
+ const terminalPersistenceMismatch = currentIdentityMatchesRequest && current.run.status === "complete" && current.run.completion?.status === "complete" && current.preparedCompletion?.status === "complete" && preparedCompletionMatchesRun && current.lease == null && current.run.phases.every((phase2) => ["passed", "not-applicable"].includes(phase2.status)) && current.run.completion?.persistence?.code === "task_finish_current_query_fields_mismatch";
37441
+ if (terminalPersistenceMismatch) {
37442
+ const recoveredRun = structuredClone(current.run);
37443
+ recoveredRun.completion = structuredClone(current.preparedCompletion);
37444
+ const result6 = finishResult(recoveredRun);
37445
+ runtime.finalizeTaskFinishPersistence(root, {
37446
+ run: recoveredRun,
37447
+ result: result6,
37448
+ completion: recoveredRun.completion
37449
+ });
37450
+ return print9({
37451
+ ...inspectFinishRun({ root, runId: recoveredRun.runId, runtime }),
37452
+ persistenceRecovered: true
37453
+ }, command2.args);
37454
+ }
37332
37455
  if (currentIdentityMatchesRequest && current.run.status === "complete" && current.run.completion?.status === "complete" && current.run.developmentHandoff) {
37333
37456
  const result6 = reconcileTaskFinishDelivery({
37334
37457
  runtime,
@@ -40544,6 +40667,7 @@ function currentRecord(run2, { preparedCompletion = null, lease = null } = {}) {
40544
40667
  function terminalRecord(run2, result5, completion2) {
40545
40668
  const normalized = assertRun(run2);
40546
40669
  const storedResult = compactResult(result5);
40670
+ const identityDigest = normalized.identityDigest || digest23(normalized.identity);
40547
40671
  const fullCompletion = {
40548
40672
  ...clone6(completion2) || {},
40549
40673
  task: normalized.identity.task,
@@ -40559,40 +40683,18 @@ function terminalRecord(run2, result5, completion2) {
40559
40683
  completedAt: result5?.completedAt || timestamp8()
40560
40684
  };
40561
40685
  const phases2 = assertPhases(storedResult.phases);
40686
+ const queryFields = terminalQueryFields(fullCompletion, identityDigest);
40562
40687
  return {
40563
40688
  record: {
40564
40689
  task_id: normalized.identity.task,
40565
40690
  run_id: normalized.runId,
40566
40691
  schema_version: CURRENT_SCHEMA,
40567
- status: "complete",
40568
- identity_digest: normalized.identityDigest || digest23(normalized.identity),
40569
- current_phase: "cleanup",
40570
- handoff_identity: normalized.identity.handoffIdentity,
40571
- candidate_identity: normalized.identity.candidateIdentity,
40572
- candidate_generation: normalized.identity.candidateGeneration,
40573
- content_target_identity: normalized.identity.contentTargetIdentity,
40574
- target_branch: normalized.identity.targetBranch,
40575
- target_remote: normalized.identity.remote || null,
40576
- carrier_identity: normalized.deliveryCarrier?.identity || fullCompletion.carrierIdentity || null,
40577
- repository_set_identity: repositorySetIdentity(normalized, storedResult),
40578
- carrier_set_identity: carrierSetIdentity(normalized, storedResult, fullCompletion),
40579
- delivery_set_identity: deliverySetIdentity(normalized, storedResult, fullCompletion),
40580
- ...associationValues(fullCompletion),
40581
- primary_failure_phase: null,
40582
- primary_failure_operation: null,
40583
- primary_failure_class: null,
40584
- primary_failure_code: null,
40585
- primary_failure_status: null,
40586
- primary_failure_exit_code: null,
40587
- primary_failure_diagnostic_digest: null,
40588
- resume_phase: null,
40589
- resume_token: null,
40590
- cleanup_status: fullCompletion.cleanup?.status || normalized.completion?.cleanup?.status || null,
40692
+ ...queryFields,
40591
40693
  lease_target_identity: null,
40592
40694
  lease_token: null,
40593
40695
  lease_expires_at: null,
40594
40696
  phases_json: JSON.stringify(phases2),
40595
- payload_json: JSON.stringify({ kind: "terminal", identityDigest: normalized.identityDigest || digest23(normalized.identity), completion: completionDetail(fullCompletion) }),
40697
+ payload_json: JSON.stringify({ kind: "terminal", identityDigest, completion: completionDetail(fullCompletion) }),
40596
40698
  created_at: normalized.createdAt || fullCompletion.completedAt,
40597
40699
  updated_at: timestamp8(),
40598
40700
  completed_at: fullCompletion.completedAt
@@ -40620,8 +40722,7 @@ function decodeRow(row) {
40620
40722
  const completion2 = clone6(payload2.completion);
40621
40723
  completion2.result = { ...completion2.result || {}, phases: phases2 };
40622
40724
  if (row.status !== "complete" || completion2.task !== row.task_id || completion2.runId !== row.run_id || completion2.status !== "complete") throw error("task_finish_terminal_payload_mismatch", "Task Finish terminal普通列与payload不一致。", 500, { taskId: row.task_id, runId: row.run_id });
40623
- const expected = terminalQueryFields(completion2);
40624
- expected.identity_digest = payload2.identityDigest || expected.identity_digest || row.identity_digest;
40725
+ const expected = terminalQueryFields(completion2, payload2.identityDigest || row.identity_digest);
40625
40726
  assertQueryFields(row, expected);
40626
40727
  return { kind: "terminal", completion: completion2, phases: phases2 };
40627
40728
  }
@@ -40691,18 +40792,18 @@ function assertQueryFields(row, expected) {
40691
40792
  const mismatches = QUERY_FIELDS.filter((field) => (row[field] ?? null) !== (expected[field] ?? null));
40692
40793
  if (mismatches.length) throw error("task_finish_current_query_fields_mismatch", `Task Finish current普通列与payload不一致:${mismatches.join(", ")}。`, 500, { taskId: row.task_id, runId: row.run_id, mismatches });
40693
40794
  }
40694
- function terminalQueryFields(completion2) {
40795
+ function terminalQueryFields(completion2, identityDigest = null) {
40695
40796
  const result5 = completion2.result || {};
40696
40797
  return {
40697
- identity_digest: result5.identity ? digest23(result5.identity) : null,
40798
+ identity_digest: identityDigest,
40698
40799
  status: "complete",
40699
40800
  current_phase: "cleanup",
40700
40801
  handoff_identity: completion2.handoffIdentity,
40701
40802
  candidate_identity: completion2.candidateIdentity,
40702
40803
  candidate_generation: completion2.candidateGeneration,
40703
40804
  content_target_identity: completion2.contentTargetIdentity,
40704
- target_branch: completion2.targetBranch,
40705
- target_remote: result5.identity?.remote || null,
40805
+ target_branch: result5.identity?.targetBranch ?? completion2.targetBranch ?? null,
40806
+ target_remote: result5.identity?.remote ?? null,
40706
40807
  carrier_identity: completion2.carrierIdentity || result5.carrier?.identity || null,
40707
40808
  repository_set_identity: result5.repositorySetIdentity || result5.identity?.repositorySetIdentity || null,
40708
40809
  carrier_set_identity: result5.carrierSetIdentity || completion2.carrierSetIdentity || null,
@@ -51709,7 +51810,7 @@ ${excerpt}`);
51709
51810
  if (!(skill.requires || []).some((item) => item.capability === "buildr.task-record" && item.version === 2 && item.mode === "required")) problems.push("task-retrospective must require buildr.task-record@2.");
51710
51811
  }
51711
51812
  if (skill.id === "task-triage") {
51712
- for (const requiredText5 of ["## 2. 两轴决策", "`code-only`", "`spec-maintenance`", "`change-flow`", "`blocked`", "Repository set", "`implementation`", "`metadata-only`", "`unknown`", "`buildr.task-record/v2`", "待办意向", "todo create", "Formal Task Record本身不是编辑、构建或有界测试的通用工作许可", "首次受管效果前取得`ready`", "`buildr.git-operations/v1`", "从 Parent 规划项启动独立 Child Task", "初始不引用Parent Change", "Child execution root中创建该独立目标自己的窄Change", "新正式 Task 创建前收敛统一 dev 基线", "`fetch` operation", "`rebase` operation", "`rebase --abort`", "Git 基线:converged / none / blocked", "`buildr.current-knowledge-maintenance/v2`", "`buildr.task-environment/v1`", "`maintain`", "`change-required`", "provider 不 ready", "selected `buildr.task-development/v2` provider", "selected `buildr.task-verification/v3` provider", "不预设 minimal/affected/candidate 层级", "## 4. 输出契约"]) {
51813
+ for (const requiredText5 of ["## 2. 两轴决策", "`code-only`", "`spec-maintenance`", "`change-flow`", "`blocked`", "Repository set", "`implementation`", "`metadata-only`", "`unknown`", "`buildr.task-record/v2`", "待办意向", "todo create", "Formal Task Record本身不是编辑、构建或有界测试的通用工作许可", "首次受管效果前取得`ready`", "`buildr.git-operations/v1`", "从 Parent 规划项启动独立 Child Task", "初始不引用Parent Change", "Child execution root中创建该独立目标自己的窄Change", "新正式 Task 创建前收敛逐 repository 权威基线", "`fetch` operation", "`rebase` operation", "`rebase --abort`", "Git 基线:converged / none / blocked", "`buildr.current-knowledge-maintenance/v2`", "`buildr.task-environment/v1`", "`maintain`", "`change-required`", "provider 不 ready", "selected `buildr.task-development/v2` provider", "selected `buildr.task-verification/v3` provider", "不预设 minimal/affected/candidate 层级", "## 4. 输出契约"]) {
51713
51814
  if (!skillContent.includes(requiredText5)) problems.push(`task-triage Skill must include ${JSON.stringify(requiredText5)}.`);
51714
51815
  }
51715
51816
  if (!(skill.requires || []).some((item) => item.capability === "buildr.task-record" && item.version === 2 && item.mode === "optional")) problems.push("task-triage must optionally require buildr.task-record@2.");
@@ -65988,6 +66089,7 @@ function createTaskFinishCliContributions(application = null) {
65988
66089
  "Usage: buildr task finish reconcile --task <task-id> [--agent <agent>] [--target-branch <branch>] [--remote <name>] [--target <canonical-workspace>] [--detail <compact|full|self-bootstrap>] [--json]",
65989
66090
  "",
65990
66091
  "从current Development handoff解析交付身份;优先复用Task Environment repository set,缺失或已清理时从Task scope、registries与实际Git topology构造只读上下文,再读取真实远端ref逐仓库验证Task Contribution包含关系。",
66092
+ "若matching completed run仅因terminal query fields持久化校验失败而保留current,reconcile只复用受验证prepared completion原子补写terminal state,不重复观察远端、交付或cleanup。",
65991
66093
  "不接受success、evidence、commit message、run token或手写proof;不会push、force push、改写共享历史或创建Delivery Carrier。",
65992
66094
  "逐repository立即保存已证明Delivery;全部适用repository成立后提交Task交付终态。activation、Environment cleanup与diagnostics独立处理;无current Environment时cleanup不声称cleaned。"
65993
66095
  ],