flower-trellis 0.6.12-beta.4 → 0.6.12-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/README.md +3 -1
  2. package/enhancements/0.6/.agents/skills/trellis-push/SKILL.md +6 -6
  3. package/enhancements/0.6/.agents/skills/trellis-push/references/output-templates.md +7 -5
  4. package/enhancements/0.6/.claude/skills/trellis-push/SKILL.md +6 -6
  5. package/enhancements/0.6/.claude/skills/trellis-push/references/output-templates.md +7 -5
  6. package/enhancements/0.6/overrides/conflicts.json +3 -1
  7. package/enhancements/0.6/overrides/patches/scripts/task-closeout-lifecycle/patch.json +9 -0
  8. package/enhancements/0.6/overrides/patches/scripts/task-closeout-lifecycle/task-retirement-parser-content.py +4 -0
  9. package/enhancements/0.6/overrides/patches/scripts/task-closeout-lifecycle/task-retirement-parser-selector.py +1 -0
  10. package/enhancements/0.6/overrides/patches/skills/trellis-meta/managed-workflow-owners/active-task-lifecycle-content.md +2 -0
  11. package/enhancements/0.6/overrides/patches/skills/trellis-update-spec/autonomous-evaluation/content.md +4 -3
  12. package/enhancements/0.6/overrides/patches/workflow/hub/content.md +1 -1
  13. package/enhancements/0.6/overrides/patches/workflow/intent-routing/request-triage/content.md +1 -1
  14. package/enhancements/0.6/overrides/patches/workflow/runtime-contract-reference/task-system-content.md +3 -0
  15. package/enhancements/0.6/overrides/patches/workflow/state-no-task/content.md +2 -1
  16. package/enhancements/0.6/scripts/decision_log.py +94 -22
  17. package/enhancements/0.6/scripts/task_lifecycle.py +59 -12
  18. package/enhancements/MANIFEST.json +4 -2
  19. package/package.json +3 -3
  20. package/src/lib/codex-tweaks.js +5 -50
  21. package/src/patches/bundles/flower-platform-integration.json +0 -1
  22. package/src/patches/platforms/codex/sync-user-interaction/config-content.json.txt +6 -0
  23. package/src/patches/platforms/codex/remove-multi-agent-v2/patch.json +0 -17
package/README.md CHANGED
@@ -417,12 +417,14 @@ flower banner → 平台多选菜单 → Trellis 原生交互(模板 / monorepo
417
417
  ```
418
418
 
419
419
  - **统一品牌头部**:Trellis 子进程在伪终端(`node-pty`)中运行,其原生的模板 / monorepo / 冲突等交互完整保留,但重复打印的启动 banner 被过滤,全程只呈现一个 flower banner。
420
- - **按平台铺设技能**:Claude 铺到 `.claude/skills`,Codex / Gemini 等铺到 `.agents/skills`;并做平台后处理:Codex 兼容清理旧 `config.toml` 的 `[features.multi_agent_v2]`,在保留上游 hooks 的基础上补全 `SessionStart`;Claude Code 只在 `startup` SessionStart 挂载启动更新检查。
420
+ - **按平台铺设技能**:Claude 铺到 `.claude/skills`,Codex / Gemini 等铺到 `.agents/skills`;并做平台后处理:Codex 保留用户的 `multi_agent` / `multi_agent_v2` 配置,在保留上游 hooks 的基础上补全 `SessionStart`;Claude Code 只在 `startup` SessionStart 挂载启动更新检查。
421
421
  - **幂等执行**:0.6 Patch 使用受管 marker 原位升级,完整预检通过后只写 changed 文件;技能资产和现代 `.flower/state.json` 记录进入同一插件事务,通过路径 ownership 与摘要精确清理淘汰内容。0.5/old 继续使用兼容注入路径,旧 manifest 只用于迁移识别。
422
422
  - **结构化 Patch**:Trellis 0.6 的 workflow、skill、hook 与平台配置统一通过 `insert / replace / remove` 预检后应用;selector/baseline 或已知最终协议冲突时在写入前停止。
423
423
  - **上线事项账本**:强化包通过 Finish-Work Patch 在归档前智能识别 SQL、配置、批处理 / 部署脚本 / 数据修复、外部系统 / 依赖平台等上线事项,必要时写入任务 `release.md`;`trellis-release` 可在正式上线前核对任务文档、`release.md` 和 git 证据,生成 `YYYY-MM-DD-<release-slug>.md` 格式的版本 / 批次操作单。
424
424
  - **安全中止**:`Ctrl+C` 取消后不会继续叠加。
425
425
 
426
+ Codex 的实际多 agent 版本由客户端配置、模型元数据与会话状态共同决定;`multi_agent_v2=false` 不能保证使用 v1。Flower 保留用户的版本设置,0.5/old 兼容入口也保留配置原文。`agents.max_depth` 仅限制 v1 的递归深度,v2 忽略该值;`codex.dispatch_mode:auto` 负责 Trellis 上下文准备,版本选择仍由 Codex 处理。
427
+
426
428
  ## 强化包与更新
427
429
 
428
430
  强化包以**快照**形式打包在 `enhancements/`(由 `npm run sync` 从 skill-garden 同步),随 npm 发布。因此两者更新节奏不同:
@@ -5,7 +5,7 @@ description: "按确认的精确文件范围提交普通变更或完成已就绪
5
5
 
6
6
  # Trellis Push
7
7
 
8
- `trellis-push` 是 Phase 3.4 唯一的代码提交入口。它只负责生成最小计划、精确提交、普通推送,以及在 task 上触发进度同步或在 untracked 上完成状态清理。
8
+ `trellis-push` 是 Phase 3.4 唯一的代码提交入口。负责最小计划、精确提交与普通推送;task 同步进度,untracked 清理状态。
9
9
 
10
10
  ## 职责与条件入口
11
11
 
@@ -26,15 +26,15 @@ description: "按确认的精确文件范围提交普通变更或完成已就绪
26
26
 
27
27
  ## Step 0:记录完成链证据
28
28
 
29
- 除 auto-loop 内部 `commit-only` 外,普通 push 或用户 `commit-only` 已经构成明确 Git 意图。本 skill 在读取 Git 提交计划前只记录当前可用的完成链证据,不补跑、不切换阶段,也不新增确认:
29
+ 普通 push 或用户 `commit-only` 已经构成明确 Git 意图;也接受完成链 owner 的合法交接。除 auto-loop 内部 `commit-only` 外,按当前结果与实际 diff 记录:
30
30
 
31
- - Check-All:用当前报告与实际 diff 记录通过、有效已接受风险、未运行/失效、未处置问题、blocked 或部分验证;保留问题 ID/严重度,`[上线后验证]` 作为非阻断风险保留动作、责任与预期。
31
+ - Check-All:通过、有效已接受风险、未运行/失效、未处置 findings、blocked 或部分验证;保留 ID/严重度;`[上线后验证]` 作为非阻断风险保留动作、责任、预期。
32
+ - 快速直改:仅无 task/untracked、仍符合 Request Triage 且必要定向验证成功覆盖当前 diff,才记 `不适用(快速直改)` 并列真实命令、结果、范围。验证缺失/失败/失效或范围扩大不得使用;task/tracked 缺检查仍按实际状态列风险,不得伪造通过。
32
33
  - Update-Spec:根据当前 `spec_update_result` 与实际 diff 标记 `no-op`、`written`、`needs-review` 或未运行/失效。
33
- - 不从历史消息、摘要或 dirty 状态推断通过、风险接受或授权;完整展示字段由输出模板所有。
34
34
 
35
- 上述状态只进入 Step 3 的完成链证据与风险展示,不会阻止读取 Git 状态或生成提交计划。本步骤不得返回 Phase 2.2,不得加载 `trellis-check-all` 或 `trellis-update-spec`,不要求改写请求;正常 workflow 顺序由各自 owner 推进。
35
+ 禁止从历史、摘要或 dirty 推断通过、风险接受或授权。Step 3 展示证据,不会阻止读取 Git 状态或生成提交计划。本步骤不得返回 Phase 2.2,不得加载 `trellis-check-all` 或 `trellis-update-spec`,不补跑;阶段由各 owner 推进。
36
36
 
37
- 没有活动 task 时运行 `python3 ./.trellis/scripts/untracked_flow.py status --verbose`。命中 untracked 后,记录 work id、summary 和 stage,并要求 `stage=push`;完成链证据仍从当前 Check-All / Update-Spec 结果与实际 diff 获取。`miss` 才按既有“无活动任务”普通 Git 路径处理;损坏状态停止,不从摘要猜测。游标命中不表示 Push 已计划、已确认或已执行。
37
+ 无 task 时运行 `python3 ./.trellis/scripts/untracked_flow.py status --verbose`。命中须记录 work id/summary/stage 且要求 `stage=push`;miss 走无任务路径,损坏则停。游标命中不表示 Push 已计划、已确认或已执行。
38
38
 
39
39
  ## Step 1:发现仓库与任务
40
40
 
@@ -1,6 +1,6 @@
1
1
  # Trellis Push 输出模板
2
2
 
3
- 本 reference 只定义用户可见的计划、结果和展示规则。何时读取、是否确认、能否执行以及失败恢复均由同目录 `SKILL.md` 所有。
3
+ 读取、执行、确认和恢复规则由 `SKILL.md` 所有。
4
4
 
5
5
  ## 计划模板
6
6
 
@@ -13,7 +13,8 @@
13
13
  - **顺序**:<repo-a> [-> `<local generation command>`] -> <repo-b> [-> task progress]
14
14
 
15
15
  ### 完成链证据
16
- - **Check-All**:<通过 / 通过(N 项风险已接受) / 未运行 / 已失效 / 存在未处置 findings / blocked / 部分验证>
16
+ - **Check-All**:<通过 / 通过(N 项风险已接受) / 不适用(快速直改) / 未运行 / 已失效 / 存在未处置 findings / blocked / 部分验证>
17
+ - **定向验证**:<真实命令、结果与覆盖范围>(仅合法快速直改时显示)
17
18
  - **Update-Spec**:<no-op / written / needs-review / 未运行 / 已失效>
18
19
 
19
20
  ### 1. <repository-name>
@@ -50,8 +51,8 @@
50
51
 
51
52
  ## 共用展示规则
52
53
 
53
- - 计划与结果模板中的字段行必须使用 `- **字段**:值` 列表项。这些行在 Markdown 段落内会被折叠成一段,不得改回裸段落行,也不得依赖行尾空格换行。
54
- - 计划中的「任务记录」是与各仓库区平级的独立 `###` 小节,仅普通模式且存在活动任务时整节展示;不再用方括号条件行代替小节标题。
54
+ - 计划与结果须保留模板标题层级、字段顺序及 `- **字段**:值` 列表格式,仅替换占位内容、按条件省略;不得改成摘要表格、裸段落或依赖行尾空格换行,简洁要求不适用于模板结构。
55
+ - 「任务记录」仅普通模式有活动任务时展示,须用与仓库区平级的 `###` 小节,不用方括号条件行代替标题。
55
56
  - 计划中单仓 `planned` 不超过 8 个文件时完整列出。
56
57
  - 超过 8 个时按目录归组,最多 12 行;用户要求展开时展示同一 exact set。
57
58
  - 顶部仓库/commit/file 总数包含独立任务记录提交所在 Git root、该提交及其 exact files;任务记录文件使用相同的 8 文件展示阈值和展开规则。
@@ -59,7 +60,8 @@
59
60
  - 计划中的保留变更按仓库计数:不超过 8 项时逐项标注 `[untracked]`、`[unstaged]`、`[staged]`;超过 8 项时将非 staged 项按目录与 Git 状态汇总数量,每仓最多 12 行,必要时合并到上级目录。同一路径计数一次,兼有 staged/unstaged 时同时标注。
60
61
  - 计划中的计划外 staged 项始终逐项单列,不计入分组摘要;计划和结果中的真正风险均在独立“风险”区逐项展示,不受行数限制。分组、展开均只改变展示,不改变 exact set 或确认范围。
61
62
  - 用户要求“展开保留变更”时在对话中列出同一 exact set 与 Git 状态,不生成清单附件;“展开文件”仍指 planned files。
62
- - 计划的完成链证据始终显示当前状态,但不重复 Check-All 报告或 Spec review 正文;`未运行`、`已失效`、任一未处置 `CHK-*` / `FBK-*`、blocked、部分验证或 `needs-review` 同时计入风险区。未变化且接受仍有效的问题只在完成链证据中汇总数量,不再进入风险区;内部保留 ID、严重度、影响与接受依据,用户要求详情时再展开。接受失效或无法验证时按实际状态进入风险区并说明变化或证据缺口,不擅自延续接受。`[上线后验证]` 作为非阻断风险逐项保留动作、环境/责任边界和预期结果,不改变 Check-All 状态,并注明由既有 `trellis-release` / `release.md` 流程承接。
63
+ - 计划的完成链证据始终显示当前状态;`未运行`、`已失效`、任一未处置 `CHK-*` / `FBK-*`、blocked、部分验证或 `needs-review` 同时计入风险区。未变化且接受仍有效的问题只在完成链证据中汇总数量,不再进入风险区;内部保留 ID、严重度、影响与接受依据,用户要求详情时再展开。接受失效或无法验证时按实际状态进入风险区并说明变化或证据缺口,不擅自延续。`[上线后验证]` 作为非阻断风险逐项保留动作、环境/责任边界、预期,不改变 Check-All 状态,并注明由既有 `trellis-release` / `release.md` 流程承接。
64
+ - `不适用(快速直改)` 遵守 Step 0 资格,不算未检查风险;必须展示“定向验证”行,其它风险照常。
63
65
  - 顶部“风险 <N>”只统计本次风险区需展开的事项,不包含已经单独汇总的有效已接受问题;不重复计数。同一问题的有效性按 Check-All reporting reference 核对,不因无关 diff 自动失效,也不把展示去重当作已修复或零风险。
64
66
  - 无活动 task、untracked 或 `commit-only` 时省略进度动作。
65
67
  - 不重复展示检查结果、规范复核、物理 GC 或其他阶段的详细信息。
@@ -5,7 +5,7 @@ description: "按确认的精确文件范围提交普通变更或完成已就绪
5
5
 
6
6
  # Trellis Push
7
7
 
8
- `trellis-push` 是 Phase 3.4 唯一的代码提交入口。它只负责生成最小计划、精确提交、普通推送,以及在 task 上触发进度同步或在 untracked 上完成状态清理。
8
+ `trellis-push` 是 Phase 3.4 唯一的代码提交入口。负责最小计划、精确提交与普通推送;task 同步进度,untracked 清理状态。
9
9
 
10
10
  ## 职责与条件入口
11
11
 
@@ -26,15 +26,15 @@ description: "按确认的精确文件范围提交普通变更或完成已就绪
26
26
 
27
27
  ## Step 0:记录完成链证据
28
28
 
29
- 除 auto-loop 内部 `commit-only` 外,普通 push 或用户 `commit-only` 已经构成明确 Git 意图。本 skill 在读取 Git 提交计划前只记录当前可用的完成链证据,不补跑、不切换阶段,也不新增确认:
29
+ 普通 push 或用户 `commit-only` 已经构成明确 Git 意图;也接受完成链 owner 的合法交接。除 auto-loop 内部 `commit-only` 外,按当前结果与实际 diff 记录:
30
30
 
31
- - Check-All:用当前报告与实际 diff 记录通过、有效已接受风险、未运行/失效、未处置问题、blocked 或部分验证;保留问题 ID/严重度,`[上线后验证]` 作为非阻断风险保留动作、责任与预期。
31
+ - Check-All:通过、有效已接受风险、未运行/失效、未处置 findings、blocked 或部分验证;保留 ID/严重度;`[上线后验证]` 作为非阻断风险保留动作、责任、预期。
32
+ - 快速直改:仅无 task/untracked、仍符合 Request Triage 且必要定向验证成功覆盖当前 diff,才记 `不适用(快速直改)` 并列真实命令、结果、范围。验证缺失/失败/失效或范围扩大不得使用;task/tracked 缺检查仍按实际状态列风险,不得伪造通过。
32
33
  - Update-Spec:根据当前 `spec_update_result` 与实际 diff 标记 `no-op`、`written`、`needs-review` 或未运行/失效。
33
- - 不从历史消息、摘要或 dirty 状态推断通过、风险接受或授权;完整展示字段由输出模板所有。
34
34
 
35
- 上述状态只进入 Step 3 的完成链证据与风险展示,不会阻止读取 Git 状态或生成提交计划。本步骤不得返回 Phase 2.2,不得加载 `trellis-check-all` 或 `trellis-update-spec`,不要求改写请求;正常 workflow 顺序由各自 owner 推进。
35
+ 禁止从历史、摘要或 dirty 推断通过、风险接受或授权。Step 3 展示证据,不会阻止读取 Git 状态或生成提交计划。本步骤不得返回 Phase 2.2,不得加载 `trellis-check-all` 或 `trellis-update-spec`,不补跑;阶段由各 owner 推进。
36
36
 
37
- 没有活动 task 时运行 `python3 ./.trellis/scripts/untracked_flow.py status --verbose`。命中 untracked 后,记录 work id、summary 和 stage,并要求 `stage=push`;完成链证据仍从当前 Check-All / Update-Spec 结果与实际 diff 获取。`miss` 才按既有“无活动任务”普通 Git 路径处理;损坏状态停止,不从摘要猜测。游标命中不表示 Push 已计划、已确认或已执行。
37
+ 无 task 时运行 `python3 ./.trellis/scripts/untracked_flow.py status --verbose`。命中须记录 work id/summary/stage 且要求 `stage=push`;miss 走无任务路径,损坏则停。游标命中不表示 Push 已计划、已确认或已执行。
38
38
 
39
39
  ## Step 1:发现仓库与任务
40
40
 
@@ -1,6 +1,6 @@
1
1
  # Trellis Push 输出模板
2
2
 
3
- 本 reference 只定义用户可见的计划、结果和展示规则。何时读取、是否确认、能否执行以及失败恢复均由同目录 `SKILL.md` 所有。
3
+ 读取、执行、确认和恢复规则由 `SKILL.md` 所有。
4
4
 
5
5
  ## 计划模板
6
6
 
@@ -13,7 +13,8 @@
13
13
  - **顺序**:<repo-a> [-> `<local generation command>`] -> <repo-b> [-> task progress]
14
14
 
15
15
  ### 完成链证据
16
- - **Check-All**:<通过 / 通过(N 项风险已接受) / 未运行 / 已失效 / 存在未处置 findings / blocked / 部分验证>
16
+ - **Check-All**:<通过 / 通过(N 项风险已接受) / 不适用(快速直改) / 未运行 / 已失效 / 存在未处置 findings / blocked / 部分验证>
17
+ - **定向验证**:<真实命令、结果与覆盖范围>(仅合法快速直改时显示)
17
18
  - **Update-Spec**:<no-op / written / needs-review / 未运行 / 已失效>
18
19
 
19
20
  ### 1. <repository-name>
@@ -50,8 +51,8 @@
50
51
 
51
52
  ## 共用展示规则
52
53
 
53
- - 计划与结果模板中的字段行必须使用 `- **字段**:值` 列表项。这些行在 Markdown 段落内会被折叠成一段,不得改回裸段落行,也不得依赖行尾空格换行。
54
- - 计划中的「任务记录」是与各仓库区平级的独立 `###` 小节,仅普通模式且存在活动任务时整节展示;不再用方括号条件行代替小节标题。
54
+ - 计划与结果须保留模板标题层级、字段顺序及 `- **字段**:值` 列表格式,仅替换占位内容、按条件省略;不得改成摘要表格、裸段落或依赖行尾空格换行,简洁要求不适用于模板结构。
55
+ - 「任务记录」仅普通模式有活动任务时展示,须用与仓库区平级的 `###` 小节,不用方括号条件行代替标题。
55
56
  - 计划中单仓 `planned` 不超过 8 个文件时完整列出。
56
57
  - 超过 8 个时按目录归组,最多 12 行;用户要求展开时展示同一 exact set。
57
58
  - 顶部仓库/commit/file 总数包含独立任务记录提交所在 Git root、该提交及其 exact files;任务记录文件使用相同的 8 文件展示阈值和展开规则。
@@ -59,7 +60,8 @@
59
60
  - 计划中的保留变更按仓库计数:不超过 8 项时逐项标注 `[untracked]`、`[unstaged]`、`[staged]`;超过 8 项时将非 staged 项按目录与 Git 状态汇总数量,每仓最多 12 行,必要时合并到上级目录。同一路径计数一次,兼有 staged/unstaged 时同时标注。
60
61
  - 计划中的计划外 staged 项始终逐项单列,不计入分组摘要;计划和结果中的真正风险均在独立“风险”区逐项展示,不受行数限制。分组、展开均只改变展示,不改变 exact set 或确认范围。
61
62
  - 用户要求“展开保留变更”时在对话中列出同一 exact set 与 Git 状态,不生成清单附件;“展开文件”仍指 planned files。
62
- - 计划的完成链证据始终显示当前状态,但不重复 Check-All 报告或 Spec review 正文;`未运行`、`已失效`、任一未处置 `CHK-*` / `FBK-*`、blocked、部分验证或 `needs-review` 同时计入风险区。未变化且接受仍有效的问题只在完成链证据中汇总数量,不再进入风险区;内部保留 ID、严重度、影响与接受依据,用户要求详情时再展开。接受失效或无法验证时按实际状态进入风险区并说明变化或证据缺口,不擅自延续接受。`[上线后验证]` 作为非阻断风险逐项保留动作、环境/责任边界和预期结果,不改变 Check-All 状态,并注明由既有 `trellis-release` / `release.md` 流程承接。
63
+ - 计划的完成链证据始终显示当前状态;`未运行`、`已失效`、任一未处置 `CHK-*` / `FBK-*`、blocked、部分验证或 `needs-review` 同时计入风险区。未变化且接受仍有效的问题只在完成链证据中汇总数量,不再进入风险区;内部保留 ID、严重度、影响与接受依据,用户要求详情时再展开。接受失效或无法验证时按实际状态进入风险区并说明变化或证据缺口,不擅自延续。`[上线后验证]` 作为非阻断风险逐项保留动作、环境/责任边界、预期,不改变 Check-All 状态,并注明由既有 `trellis-release` / `release.md` 流程承接。
64
+ - `不适用(快速直改)` 遵守 Step 0 资格,不算未检查风险;必须展示“定向验证”行,其它风险照常。
63
65
  - 顶部“风险 <N>”只统计本次风险区需展开的事项,不包含已经单独汇总的有效已接受问题;不重复计数。同一问题的有效性按 Check-All reporting reference 核对,不因无关 diff 自动失效,也不把展示去重当作已修复或零风险。
64
66
  - 无活动 task、untracked 或 `commit-only` 时省略进度动作。
65
67
  - 不重复展示检查结果、规范复核、物理 GC 或其他阶段的详细信息。
@@ -412,7 +412,9 @@
412
412
  "| Deferred Physical GC | SessionStart |",
413
413
  "| Task Progress Recovery | `trellis-continue` |",
414
414
  "A validated auto-loop result returns through matching `record` + `next` before the interactive post-check stop applies.",
415
- "Interactive completion proceeds Check-All -> `trellis-update-spec` -> `trellis-push`; successful delivery writes completion and deterministic Close"
415
+ "Interactive completion proceeds Check-All -> `trellis-update-spec` -> `trellis-push` for task/tracked work.",
416
+ "Eligible quick direct edits use successful focused validation -> `trellis-update-spec` -> `trellis-push` in the same turn through `workflow-state:no_task`",
417
+ "Successful task delivery writes completion and deterministic Close"
416
418
  ]
417
419
  },
418
420
  "owner": "workflow-hub",
@@ -98,6 +98,15 @@
98
98
  "selector": { "type": "literal", "source": "task-parser-archive-selector.py" },
99
99
  "content": { "source": "task-parser-lifecycle-content.py" }
100
100
  },
101
+ {
102
+ "id": "task-lifecycle-retirement-option",
103
+ "operation": "insert",
104
+ "position": "after",
105
+ "dependsOn": ["task-lifecycle-parser-commands"],
106
+ "targets": [{ "kind": "file", "path": ".trellis/scripts/task.py", "missing": "error", "markerStyle": "hash" }],
107
+ "selector": { "type": "literal", "source": "task-retirement-parser-selector.py" },
108
+ "content": { "source": "task-retirement-parser-content.py" }
109
+ },
101
110
  {
102
111
  "id": "task-lifecycle-parser-list-views",
103
112
  "operation": "replace",
@@ -0,0 +1,4 @@
1
+ p_close.add_argument(
2
+ "--retire-reason",
3
+ help="Explicit user termination reason; preserve rejected decisions without claiming acceptance",
4
+ )
@@ -0,0 +1 @@
1
+ p_restore.add_argument("--json", action="store_true", help="Output machine-readable JSON")
@@ -24,3 +24,5 @@ completed -> explicit reopen -> in_progress
24
24
  ```
25
25
 
26
26
  Partial pushes, user `commit-only`, and normal helper failures remain `in_progress`. Auto-loop closes an item immediately after its verified internal commit-only chain. Closed tasks are excluded from active pointers, task queues, counts, statusline, and recovery candidates; physical GC only changes storage location and never changes semantic state.
27
+
28
+ When the user explicitly ends old completed work, `task.py close <task> --retire-reason "<reason>"` records a non-success retirement in `meta.retirement` and preserves the decision digest, review verdict, and unresolved change IDs. This permits closing the old task without accepting rejected decisions. The normal Close gate still blocks explicit rework; retirement does not bypass invalid evidence, incomplete children, dirty delivery, or other semantic blockers.
@@ -28,11 +28,11 @@ Reuse already-read, unchanged evidence in this order; read missing or changed ma
28
28
  1. For task context, the current task's `implement.jsonl` / `check.jsonl` and every file they reference.
29
29
  2. For task context, the current task's `prd.md`, `design.md`, and `implement.md`.
30
30
  3. For untracked context, `untracked_flow.py status --verbose` for work id, summary, and stage; obtain validation evidence from the current Check-All result and current change set rather than the cursor helper.
31
- 4. The final Check-All conclusion and its actual validation evidence.
31
+ 4. The final Check-All conclusion and its actual validation evidence, or, for an eligible quick direct edit, the actual successful focused validation commands, results, and covered scope.
32
32
  5. The current subject's actual diff, source code, tests, and commit evidence.
33
33
  6. Existing specs and their indexes returned by `spec_router.py`.
34
34
 
35
- When there is no active task, use a valid current-session untracked state when present; otherwise require an explicit Update-Spec invocation or a passed Check-All continuation authorized by its owner, and use the current request, actual diff, source/tests, and existing specs. Do not invent task evidence.
35
+ When there is no active task, use a valid current-session untracked state when present; otherwise accept an explicit Update-Spec invocation, a passed Check-All continuation authorized by its owner, or the quick direct edit completion authorized by `workflow-state:no_task`. For quick entry, verify that the actual diff still meets `Request Triage` eligibility and that current successful focused validation covers it; missing, failed, or stale evidence cannot substitute for this handoff. Use the current request, actual diff, source/tests, and existing specs. Do not invent task evidence or a Check-All pass.
36
36
 
37
37
  ### Minimal Write Boundary
38
38
 
@@ -54,8 +54,9 @@ When applicable, also validate indexes/links, code signatures, or project-specif
54
54
  ### Workflow Disposition
55
55
 
56
56
  - Interactive: follow the continuation decision made by Check-All's `Interactive Post-Check Stop Gate`, including strict pass and accepted-risk pass. A passed check defaults to this skill in the same turn after the Check-All report or brief acceptance acknowledgment; an explicit check-only or stop-after-check request keeps the chain stopped. When the user later says “下一步”, “继续”, `next`, `continue`, or an equivalent continuation intent, resume the deliberately stopped chain. Reuse a currently valid `spec_update_result` instead of evaluating again.
57
+ - Quick direct edit: accept the eligible no-task handoff above without requiring a Check-All report, task, or untracked cursor. Evaluate the focused validation and actual diff, then use the same result and Push continuation contract; an explicit user instruction to stop or defer completion keeps the chain stopped.
57
58
  - Interactive completion, including direct Git: when the gate permits continuation, a `no-op` or `written` result must load `trellis-push` in the same turn and present its single confirmation plan; if there are no deliverable changes, report that no commit is needed instead of manufacturing an empty commit. Only `no-op` or `written` may proceed to `trellis-push`; `needs-review` stops and must not generate a Push plan. Reuse valid acceptance evidence internally without repeating unchanged risks. Default continuation does not authorize Git writes; do not infer risk acceptance or Git write authorization from unrelated history, summaries, dirty state, or an auto-loop internal `commit-only`. Do not treat an agent-authored "no commit/push" restriction in task artifacts or ordinary implementation-plan approval as an explicit user stop instruction; stopping this handoff requires an explicit user instruction, and pending Git write authorization does not block presenting the Push plan.
58
59
  - Validated auto-loop: for `no-op` or `written`, execute `record --action run_spec_update --result ok`; only after a successful record immediately run `next`. If record returns `status=retryable` with an artifact recovery diagnosis, follow `trellis-auto-loop` recovery instructions in the same turn, then resubmit the original truthful record; do not advance or request user continuation. For `needs-review`, execute `record --action run_spec_update --result blocked --failure-type spec-needs-review`; never disguise it as `no-op`.
59
60
  - Untracked: keep the cursor at `spec` for `needs-review`. For `no-op` or `written`, run `untracked_flow.py advance --stage push`. Any later product edit returns the cursor to `implement`; the helper does not validate or preserve owner evidence.
60
61
 
61
- Do not ask again or rerun when a currently valid `no-op` or `written` result already exists. Re-evaluate after the actual diff, Check-All conclusion, or the user's spec intent changes.
62
+ Do not ask again or rerun when a currently valid `no-op` or `written` result already exists. Re-evaluate after the actual diff, Check-All or focused validation conclusion, or the user's spec intent changes.
@@ -26,4 +26,4 @@ Cross-stage ordering:
26
26
 
27
27
  1. Request intent, active-task scope, and any current untracked work are resolved before task creation, task routing, or file edits.
28
28
  2. A validated auto-loop result returns through matching `record` + `next` before the interactive post-check stop applies.
29
- 3. Interactive completion proceeds Check-All -> `trellis-update-spec` -> `trellis-push`; successful delivery writes completion and deterministic Close in one lifecycle update.
29
+ 3. Interactive completion proceeds Check-All -> `trellis-update-spec` -> `trellis-push` for task/tracked work. Eligible quick direct edits use successful focused validation -> `trellis-update-spec` -> `trellis-push` in the same turn through `workflow-state:no_task`; explicit user stops remain effective. Successful task delivery writes completion and deterministic Close in one lifecycle update.
@@ -2,7 +2,7 @@
2
2
  - Infer `discuss`, `inspect`, `direct_edit`, `task_plan`, or `workflow_action` for new work from the whole current request, scope, risk, side effects, active-task state, and latest explicit switch. Do not classify from one keyword alone.
3
3
  - For new work, treat requests for an opinion, expressions of discomfort, rejected proposals, or questions about how something should change as `discuss`; treat requests to inspect, explain, verify, or locate a cause as `inspect`. Both are read-only unless the current request explicitly authorizes a concrete edit. Selecting a repair does not authorize editing while scope is unknown or permission to skip task planning; inspect first and reclassify from evidence.
4
4
  - `direct_edit` requires known, bounded, low-risk, reversible scope, no unresolved design choice, and simple validation. Permission/authentication/data-scope/security, database/migration/release/external effects, or unknown scope remain strong `task_plan` boundaries. Shared contracts, cross-package/layer or multi-entry behavior, configuration, historical regressions, and systematic validation raise the evidence and validation bar, but do not automatically require `task_plan`. An exact rollback or mechanically synchronized known change may remain `direct_edit` or `workflow_action` when its behavior, scope, side effects, and validation are already determined.
5
- - `direct_edit` has two execution shapes. Use quick direct edit for one-turn small fixes, wording/config tweaks, focused release-note corrections, or other changes that can be edited, validated, and reported without remembering a later phase; do not create `untracked_flow` for those. Use tracked direct edit only when the user explicitly wants no task but still wants later turns to remember the current phase, or when the work is likely to continue across turns with `下一步` / `继续` / check / push handoff.
5
+ - `direct_edit` has two execution shapes. Use quick direct edit for one-turn small fixes, wording/config tweaks, focused release-note corrections, or other bounded changes with simple focused validation; do not create a task or `untracked_flow` for those. Its successful completion continues through Spec evaluation and the Push plan in the same turn, as defined by `workflow-state:no_task`. Use tracked direct edit only when the user explicitly wants no task but still wants later turns to remember the current phase, or when the work is likely to continue across turns with `下一步` / `继续` / check / push handoff.
6
6
  - When project-local SOPs or conventions may change the correct action for non-trivial work, build a short query from the request, intended commands, affected files or systems, package/layer, and domain terms; run `python3 ./.trellis/scripts/spec_router.py "<short query describing the intended action>"` once per user intent, workflow phase, or decision boundary and follow its returned `load_strategy` and `action`. Skip discovery for pure Q&A, simple read-only inspection, opening local tools, or trivial edits unless project rules may alter the approach.
7
7
  - For new work when an active task exists, apply the Active Task Scope Guard before artifact ownership, task routing, or file edits. New implementation outside the active task title/brief requires a new task, an artifact update before continuing, or an explicit untracked path that does not reuse current progress. `task_intent.py` executes the already-decided safety boundary; it does not decide semantic ownership.
8
8
  - Within an initially approved task, follow `trellis-task-brief` for incremental plan changes and update affected artifacts before implementation. Artifact refresh is not a new whole-Brief approval gate; unresolved scope or product decisions still pause affected work.
@@ -8,6 +8,7 @@ python3 ./.trellis/scripts/task.py start <name>
8
8
  python3 ./.trellis/scripts/task.py current --source
9
9
  python3 ./.trellis/scripts/task.py finish # only clear this session pointer
10
10
  python3 ./.trellis/scripts/task.py close <name> --json
11
+ python3 ./.trellis/scripts/task.py close <name> --retire-reason "<explicit user termination reason>" --json
11
12
  python3 ./.trellis/scripts/task.py list [--closed|--all] [--mine] [--json]
12
13
  python3 ./.trellis/scripts/task.py gc --closed --before 3d [--dry-run] [--json]
13
14
  python3 ./.trellis/scripts/task.py restore <name> [--dry-run] [--json]
@@ -20,3 +21,5 @@ python3 ./.trellis/scripts/task.py create-pr [name] [--dry-run]
20
21
  ```
21
22
 
22
23
  `task.py start` binds the task to the current AI session and moves planning work to `in_progress`. Successful normal delivery and successful auto-loop commit-only both write completion plus Close through their owning deterministic helper; Close does not call a model. Physical GC runs best-effort from SessionStart on startup/resume for tasks closed at least three days, commits only the exact moved paths, never pushes, and can be reversed with `restore`.
24
+
25
+ For completed work that the user explicitly ends, `close --retire-reason` records the reason and a non-success outcome in `meta.retirement`. Rejected decisions and unresolved change IDs remain in the audit trail; the task may close without turning them into accepted reviews. Other Close requirements still apply.
@@ -1,7 +1,8 @@
1
1
  No active task. First resolve any Check-All repair continuation through `Request Triage`; otherwise infer the current request intent before acting.
2
2
  For new work, repair intent alone is not a no-task switch. Only an explicit current-request workflow instruction such as `直接做` / `不要任务` may override automatic `task_plan`.
3
3
  Load a Trellis capability directly only when the user explicitly names it or the request exactly matches that capability; route project-specific workflow actions through the matched SOP instead of keyword-mapping a general release/publish request to `trellis-release`.
4
- For quick direct edit, make the bounded edit, run focused validation, and report without creating `untracked_flow`; small wording/config tweaks, release dry-runs, version checks, local SOP steps, and other one-turn fixes stay in this path unless the current request explicitly asks future `下一步` / `继续` / check / push handoff to remember this no-task work. For tracked direct edit, state once that work will use the session-scoped untracked flow, then run `python3 ./.trellis/scripts/untracked_flow.py begin --summary "<bounded work summary>" --source <inferred|user-explicit> --mode tracked-direct-edit`.
4
+ For quick direct edit, make the bounded edit and run required focused validation without creating a task or `untracked_flow`. With deliverable repository changes, still-eligible scope, and current successful validation evidence, briefly report progress, then load `trellis-update-spec` in the same turn; its `no-op` / `written` result continues to the Push plan. Do not end the turn at the progress report or wait for another continuation request. Missing, failed, or stale validation must be resolved within the authorized scope before this handoff; if scope outgrows quick direct edit, return to `Request Triage` rather than claiming a pass. On an explicit user stop or deferral, report the outcome and end with one guide: say continue when ready for Spec evaluation -> Push plan. Do not start that handoff yet. Read-only inspection, release dry-runs, version checks, and SOP steps without deliverable changes finish without a Git plan.
5
+ For tracked direct edit, state once that work will use the session-scoped untracked flow, then run `python3 ./.trellis/scripts/untracked_flow.py begin --summary "<bounded work summary>" --source <inferred|user-explicit> --mode tracked-direct-edit`.
5
6
  Never create `untracked_flow` for `workflow_action` itself, including release/publish, commit, push, task operations, snapshot sync, auto-loop control, or read-only inspection. If a workflow action reveals a separate code/config fix, pause that workflow action, explain the separate fix, and only create tracked direct edit when the user wants later turns to remember that fix's check/spec/push handoff; otherwise keep it as quick direct edit.
6
7
  A same-item hit resumes the existing state; `active-work-conflict` blocks unrelated code writes until the current item is completed, explicitly abandoned, or adopted into a task. Unrelated read-only requests may continue without mutating the state. A successful `begin` starts at `stage=implement`; the helper is a workflow cursor and does not gate edits on file scope, Git state, or owner evidence.
7
8
  For high-confidence complex implementation, create an auto-routed planning task through `task_intent.py create`, show one non-blocking switch hint, and enter `trellis-brainstorm`. Do NOT call the harness built-in plan mode (`EnterPlanMode` / `ExitPlanMode`) as a substitute; Trellis planning owns this routing.
@@ -59,7 +59,7 @@ def _load_common_modules(repo_root: Path) -> None:
59
59
 
60
60
 
61
61
  def _resolve_task_dir(repo_root: Path, task: str) -> Path:
62
- """把任务引用解析为活动任务目录。
62
+ """把审查引用解析为活跃、逻辑关闭或已归档的任务目录。
63
63
 
64
64
  Args:
65
65
  repo_root: Trellis 项目根。
@@ -69,15 +69,61 @@ def _resolve_task_dir(repo_root: Path, task: str) -> Path:
69
69
  已存在的任务目录绝对路径。
70
70
 
71
71
  Raises:
72
- DecisionLogError: 任务不存在或位于项目外。
72
+ DecisionLogError: 任务不存在、存在歧义、经过软链或位于任务目录外。
73
73
  """
74
74
  _load_common_modules(repo_root)
75
- from common.task_utils import resolve_active_task_reference # type: ignore[import-not-found]
75
+ from common.paths import get_tasks_dir
76
+ from common.tasks import iter_task_records
76
77
 
78
+ raw = task.strip() if isinstance(task, str) else ""
79
+ if not raw:
80
+ raise DecisionLogError("任务引用不能为空")
81
+ tasks_dir = get_tasks_dir(repo_root)
77
82
  try:
78
- return resolve_active_task_reference(task, repo_root)
83
+ records = list(iter_task_records(tasks_dir))
79
84
  except ValueError as exc:
80
85
  raise DecisionLogError(str(exc)) from exc
86
+ normalized = raw.replace("\\", "/")
87
+ while normalized.startswith("./"):
88
+ normalized = normalized[2:]
89
+ candidate = Path(raw)
90
+ path_reference = candidate.is_absolute() or "/" in normalized or normalized.startswith(".trellis")
91
+ if path_reference:
92
+ candidate = candidate if candidate.is_absolute() else repo_root / Path(normalized)
93
+ try:
94
+ resolved = candidate.resolve()
95
+ resolved.relative_to(tasks_dir.resolve())
96
+ except (OSError, RuntimeError, ValueError) as exc:
97
+ raise DecisionLogError(f"任务引用必须指向本项目任务目录:{task}") from exc
98
+ # 检查任务根以下的软链,兼容 Windows 短路径等解析后等价的合法绝对路径。
99
+ ancestor = candidate
100
+ try:
101
+ while ancestor.resolve() != tasks_dir.resolve():
102
+ if ancestor.is_symlink() or ancestor == ancestor.parent:
103
+ raise DecisionLogError(f"任务引用必须指向本项目任务目录,不能经过软链:{task}")
104
+ ancestor = ancestor.parent
105
+ except (OSError, RuntimeError) as exc:
106
+ raise DecisionLogError(f"无法解析任务引用:{task}") from exc
107
+ matches = [
108
+ record.directory.resolve()
109
+ for record in records
110
+ if record.directory.resolve() == resolved
111
+ ]
112
+ else:
113
+ matches = [
114
+ record.directory.resolve()
115
+ for record in records
116
+ if record.dir_name == raw or record.dir_name.endswith(f"-{raw}")
117
+ ]
118
+ matches = sorted(set(matches))
119
+ if len(matches) == 1:
120
+ return matches[0]
121
+ if len(matches) > 1:
122
+ names = ", ".join(path.relative_to(tasks_dir.resolve()).as_posix() for path in matches)
123
+ raise DecisionLogError(f"任务引用存在歧义:{task};候选:{names};请使用完整任务路径")
124
+ if path_reference and candidate.exists():
125
+ raise DecisionLogError(f"任务引用必须指向本项目任务目录:{task}")
126
+ raise DecisionLogError(f"任务不存在:{task}")
81
127
 
82
128
 
83
129
  def _validate_event(event: Any, line_number: int) -> dict[str, Any]:
@@ -225,13 +271,13 @@ def _atomic_write_events(task_dir: Path, events: list[dict[str, Any]]) -> None:
225
271
 
226
272
 
227
273
  def decision_review_status(task_dir: Path) -> dict[str, Any]:
228
- """返回任务当前决策摘要与 Close 审查状态。
274
+ """分别返回当前待审查状态与尚未解决的人工返工要求。
229
275
 
230
276
  Args:
231
277
  task_dir: 任务目录。
232
278
 
233
279
  Returns:
234
- 包含 decision 数量、digest、最新有效 review 和 Close 门禁状态的对象。
280
+ 包含当前 digest、有效 review、待返工 ID 和 Close 是否允许的对象。
235
281
 
236
282
  Raises:
237
283
  DecisionLogError: 日志损坏。
@@ -241,15 +287,27 @@ def decision_review_status(task_dir: Path) -> dict[str, Any]:
241
287
  digest = decision_digest(events)
242
288
  decision_ids = [str(event["decision_id"]) for event in decisions]
243
289
  valid_review: dict[str, Any] | None = None
244
- for event in reversed(events):
245
- if event.get("event") != "review":
246
- continue
247
- if event.get("decision_digest") != digest:
248
- continue
249
- if event.get("decision_ids") != decision_ids:
290
+ pending_changes: set[str] = set()
291
+ preceding_decisions: list[dict[str, Any]] = []
292
+ for event in events:
293
+ if event["event"] == "decision":
294
+ preceding_decisions.append(event)
250
295
  continue
251
- valid_review = event
252
- break
296
+ preceding_ids = [str(decision["decision_id"]) for decision in preceding_decisions]
297
+ if (not preceding_ids or event["decision_digest"] != decision_digest(preceding_decisions)
298
+ or event["decision_ids"] != preceding_ids):
299
+ raise DecisionLogError("审查记录与其发生时的决策摘要不匹配")
300
+ if event["verdict"] == "changes-requested":
301
+ requested = event.get("requested_decision_ids")
302
+ if (not isinstance(requested, list) or not requested
303
+ or any(not isinstance(value, str) or value not in preceding_ids for value in requested)):
304
+ raise DecisionLogError("返工审查缺少有效的 requested_decision_ids")
305
+ # 返工要求跨后续新增决策保留,只有覆盖这些决策的 accepted 审查才能解除。
306
+ pending_changes.update(requested)
307
+ else:
308
+ pending_changes.difference_update(preceding_ids)
309
+ if event["decision_digest"] == digest and event["decision_ids"] == decision_ids:
310
+ valid_review = event
253
311
  verdict = valid_review.get("verdict") if valid_review else None
254
312
  return {
255
313
  "task": str(task_dir),
@@ -260,8 +318,9 @@ def decision_review_status(task_dir: Path) -> dict[str, Any]:
260
318
  "decision_digest": digest,
261
319
  "review_verdict": verdict,
262
320
  "reviewed_at": valid_review.get("reviewed_at") if valid_review else None,
263
- "close_allowed": not decisions or verdict == "accepted",
321
+ "close_allowed": not pending_changes,
264
322
  "needs_review": bool(decisions) and verdict != "accepted",
323
+ "pending_change_ids": [decision_id for decision_id in decision_ids if decision_id in pending_changes],
265
324
  "decisions": decisions,
266
325
  }
267
326
 
@@ -446,13 +505,26 @@ def cmd_review(args: argparse.Namespace) -> int:
446
505
  repo_root = _repo_root()
447
506
  if repo_root is None:
448
507
  raise DecisionLogError("当前目录不是 Trellis 项目")
449
- task_dir = _resolve_task_dir(repo_root, args.task)
450
- event = review_decisions(
451
- task_dir,
452
- verdict=args.verdict,
453
- decision_ids=args.decision_id,
454
- notes=args.notes or "",
508
+ _load_common_modules(repo_root)
509
+ from task_lifecycle import (
510
+ EXACT_COMMIT_JOURNAL_RELATIVE,
511
+ GC_JOURNAL_RELATIVE,
512
+ maintenance_lock,
455
513
  )
514
+
515
+ # 归档会移动整个任务目录,必须在同一维护锁内重新定位并写入,防止重建旧目录。
516
+ with maintenance_lock(repo_root) as acquired:
517
+ if not acquired:
518
+ raise DecisionLogError("任务维护正在执行,请稍后重试审查")
519
+ if any((repo_root / journal).exists() for journal in [GC_JOURNAL_RELATIVE, EXACT_COMMIT_JOURNAL_RELATIVE]):
520
+ raise DecisionLogError("任务维护事务尚未恢复,请先恢复维护操作再审查")
521
+ task_dir = _resolve_task_dir(repo_root, args.task)
522
+ event = review_decisions(
523
+ task_dir,
524
+ verdict=args.verdict,
525
+ decision_ids=args.decision_id,
526
+ notes=args.notes or "",
527
+ )
456
528
  return _print({"status": "reviewed", "task": str(task_dir), "review": event})
457
529
 
458
530
 
@@ -465,7 +537,7 @@ def build_parser() -> argparse.ArgumentParser:
465
537
  parser = argparse.ArgumentParser(description="读取和审查 Trellis AI 决策日志。")
466
538
  subparsers = parser.add_subparsers(dest="command", required=True)
467
539
 
468
- task_help = "任务完整目录名、项目内路径、允许的绝对路径或唯一短名(例如 cli-invocation-contracts)"
540
+ task_help = "活跃、已关闭或已归档任务的完整目录名、项目内路径、允许的绝对路径或唯一短名"
469
541
 
470
542
  status = subparsers.add_parser("status", help="读取任务决策审查状态")
471
543
  status.add_argument("--task", required=True, help=task_help)
@@ -37,6 +37,8 @@ FILESET_DIAGNOSTIC_RELATIVE = ".trellis/.runtime/task-maintenance-fileset.json"
37
37
  RECOMPUTABLE_BLOCKER_CODES = {
38
38
  "ambiguous-child",
39
39
  "decision-log-invalid",
40
+ "decision-changes-requested",
41
+ # 保留旧原因码用于重试时淘汰过时门槛,不能把它继承为持久化语义阻塞。
40
42
  "decision-review-required",
41
43
  "delivery-recovery-required",
42
44
  "missing-child",
@@ -198,6 +200,7 @@ def evaluate_close(
198
200
  explicit_blockers: Optional[list[dict[str, Any]]] = None,
199
201
  resolved_blocker_codes: Optional[set[str]] = None,
200
202
  closed_at: Optional[str] = None,
203
+ retire_reason: Optional[str] = None,
201
204
  ) -> dict[str, Any]:
202
205
  """确定性评估任务 Close,不写文件。
203
206
 
@@ -209,12 +212,20 @@ def evaluate_close(
209
212
  explicit_blockers: 上游 owner 明确传入的语义 blocker。
210
213
  resolved_blocker_codes: 上游 owner 明确声明已解决的持久化 blocker code。
211
214
  closed_at: 测试或迁移使用的固定关闭时间。
215
+ retire_reason: 用户明确终止旧任务的原因;保留返工结论,不表示业务验收通过。
212
216
 
213
217
  Returns:
214
218
  结构化 close 结果;``closeout`` 可直接写入 task.json。
215
219
  """
216
220
  data = task_data if isinstance(task_data, dict) else read_json(task_dir / FILE_TASK_JSON)
217
221
  task_ref = _task_relative(repo_root, task_dir)
222
+ if retire_reason is not None and (not isinstance(retire_reason, str) or not retire_reason.strip()):
223
+ return {
224
+ "status": "error",
225
+ "task": task_ref,
226
+ "reason": "invalid-retire-reason",
227
+ "message": "终止旧任务必须提供非空原因",
228
+ }
218
229
  if not isinstance(data, dict):
219
230
  return {
220
231
  "status": "error",
@@ -253,12 +264,16 @@ def evaluate_close(
253
264
  from decision_log import decision_review_status
254
265
 
255
266
  decision_status = decision_review_status(task_dir)
256
- if not decision_status.get("close_allowed"):
267
+ # 显式终止保留尚未解决的返工事实;正常交付仍必须解决返工要求。
268
+ if not decision_status.get("close_allowed") and retire_reason is None:
257
269
  blockers.append(_blocker(
258
- "decision-review-required",
270
+ "decision-changes-requested",
259
271
  "decision_log.py",
260
- "当前 AI 决策摘要尚未获得 accepted review",
261
- {"decisionDigest": decision_status.get("decision_digest")},
272
+ "AI 决策存在尚未解决的明确返工要求",
273
+ {
274
+ "decisionDigest": decision_status.get("decision_digest"),
275
+ "decisionIds": decision_status.get("pending_change_ids", []),
276
+ },
262
277
  ))
263
278
  except (ImportError, OSError, ValueError) as error:
264
279
  blockers.append(_blocker("decision-log-invalid", "decision_log.py", str(error)))
@@ -316,13 +331,24 @@ def evaluate_close(
316
331
  }
317
332
  timestamp = closed_at or utc_now()
318
333
  closeout = {"status": "closed", "closedAt": timestamp, "blockers": []}
319
- return {
334
+ result = {
320
335
  "status": "closed",
321
336
  "task": task_ref,
322
337
  "closedAt": timestamp,
323
338
  "blockers": [],
324
339
  "closeout": closeout,
325
340
  }
341
+ if retire_reason is not None:
342
+ result["retirement"] = {
343
+ "disposition": "ended-by-user",
344
+ "reason": retire_reason.strip(),
345
+ "retiredAt": timestamp,
346
+ "businessAcceptancePassed": False,
347
+ "decisionDigest": decision_status.get("decision_digest"),
348
+ "reviewVerdict": decision_status.get("review_verdict"),
349
+ "pendingChangeIds": decision_status.get("pending_change_ids", []),
350
+ }
351
+ return result
326
352
 
327
353
 
328
354
  def apply_close(
@@ -333,6 +359,7 @@ def apply_close(
333
359
  explicit_blockers: Optional[list[dict[str, Any]]] = None,
334
360
  resolved_blocker_codes: Optional[set[str]] = None,
335
361
  closed_at: Optional[str] = None,
362
+ retire_reason: Optional[str] = None,
336
363
  ) -> dict[str, Any]:
337
364
  """评估并原子写入 Close 结果。
338
365
 
@@ -343,6 +370,7 @@ def apply_close(
343
370
  explicit_blockers: 上游明确传入的 blocker。
344
371
  resolved_blocker_codes: 上游明确声明已经解决的 blocker code。
345
372
  closed_at: 测试或迁移固定时间。
373
+ retire_reason: 用户明确终止旧任务的原因,随关闭结果原子记录。
346
374
 
347
375
  Returns:
348
376
  结构化 Close 结果。
@@ -357,11 +385,23 @@ def apply_close(
357
385
  explicit_blockers=explicit_blockers,
358
386
  resolved_blocker_codes=resolved_blocker_codes,
359
387
  closed_at=closed_at,
388
+ retire_reason=retire_reason,
360
389
  )
361
390
  if result["status"] in {"error", "already-closed"}:
362
391
  return result
363
392
  if not isinstance(data, dict):
364
393
  return result
394
+ if "retirement" in result:
395
+ meta = data.get("meta")
396
+ if meta is not None and not isinstance(meta, dict):
397
+ return {
398
+ "status": "error",
399
+ "task": result["task"],
400
+ "reason": "invalid-task-meta",
401
+ "message": "任务 meta 不是对象,无法安全记录终止原因",
402
+ }
403
+ data["meta"] = dict(meta or {})
404
+ data["meta"]["retirement"] = result["retirement"]
365
405
  if data.get("closeout") == result["closeout"]:
366
406
  return result
367
407
  data["closeout"] = result["closeout"]
@@ -409,19 +449,26 @@ def cmd_close(args: argparse.Namespace) -> int:
409
449
  """执行 ``task.py close``。
410
450
 
411
451
  Args:
412
- args: 含 task、resolve_blocker 与 json 的 argparse 参数。
452
+ args: 含 task、resolve_blocker、retire_reason 与 json 的 argparse 参数。
413
453
 
414
454
  Returns:
415
455
  closed/already-closed 为 0,blocked/error 为 1。
416
456
  """
417
457
  repo_root = get_repo_root()
418
458
  try:
419
- task_dir = _resolve_top_level_task(repo_root, args.task)
420
- result = apply_close(
421
- task_dir,
422
- repo_root,
423
- resolved_blocker_codes=set(getattr(args, "resolve_blocker", []) or []),
424
- )
459
+ # 与审查写入及物理 GC 使用同一锁,终止快照必须绑定本次读取的决策。
460
+ with maintenance_lock(repo_root) as acquired:
461
+ if not acquired:
462
+ raise TaskLifecycleError("maintenance-busy", "任务维护正在执行,请稍后重试关闭")
463
+ if any((repo_root / journal).exists() for journal in [GC_JOURNAL_RELATIVE, EXACT_COMMIT_JOURNAL_RELATIVE]):
464
+ raise TaskLifecycleError("maintenance-recovery-required", "任务维护事务尚未恢复,请先恢复维护操作")
465
+ task_dir = _resolve_top_level_task(repo_root, args.task)
466
+ result = apply_close(
467
+ task_dir,
468
+ repo_root,
469
+ resolved_blocker_codes=set(getattr(args, "resolve_blocker", []) or []),
470
+ retire_reason=getattr(args, "retire_reason", None),
471
+ )
425
472
  except TaskLifecycleError as error:
426
473
  result = {"status": "error", "reason": error.reason, "message": str(error)}
427
474
  if getattr(args, "json", False):
@@ -1,7 +1,7 @@
1
1
  {
2
- "syncedAt": "2026-10-25T23:14:14.623Z",
2
+ "syncedAt": "2026-10-27T07:38:48.725Z",
3
3
  "syncedFrom": "vendor/skill-garden",
4
- "sourceCommit": "102a1c327736b755116ab9cd5638a4a9ad4dcbe3",
4
+ "sourceCommit": "53c65aa6286ffe6e3f9be296436f4218529dda84",
5
5
  "common": {
6
6
  "codexSkills": [
7
7
  "aliyun-ops",
@@ -280,6 +280,8 @@
280
280
  "scripts/task-closeout-lifecycle/task-parser-lifecycle-content.py",
281
281
  "scripts/task-closeout-lifecycle/task-parser-list-content.py",
282
282
  "scripts/task-closeout-lifecycle/task-parser-list-selector.py",
283
+ "scripts/task-closeout-lifecycle/task-retirement-parser-content.py",
284
+ "scripts/task-closeout-lifecycle/task-retirement-parser-selector.py",
283
285
  "scripts/task-closeout-lifecycle/task-start-active-reference-content.py",
284
286
  "scripts/task-closeout-lifecycle/task-start-active-reference-selector.py",
285
287
  "scripts/task-closeout-lifecycle/task-store-config-content.py",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flower-trellis",
3
- "version": "0.6.12-beta.4",
3
+ "version": "0.6.12-beta.6",
4
4
  "description": "一键安装/升级 Trellis 并自动融合 skill-garden 强化包(默认 Claude + agents)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -71,9 +71,9 @@
71
71
  "commit-and-tag-version": "^12.7.3"
72
72
  },
73
73
  "flowerReleaseNotes": {
74
- "version": "0.6.12-beta.4",
74
+ "version": "0.6.12-beta.6",
75
75
  "source": "CHANGELOG.md",
76
- "body": "### 🐛 修复 Bug Fixes\n\n* **hooks:** 修复任务归档失败与启动诊断刷屏 ([9dc372f](https://github.com/SilentFlower/flower-trellis/commit/9dc372f5a0cbe878504f836593121c505c3e289d))\n* **task:** 同步 Git 路径校验兼容修正 ([e9a7e0e](https://github.com/SilentFlower/flower-trellis/commit/e9a7e0eb04363a34bfba19fbaecf52e82367bb51))\n* **workflow:** 校验停止指令来源并同步规则快照 ([dcadf66](https://github.com/SilentFlower/flower-trellis/commit/dcadf66b16904e1e4c9c36abedc47685da07e6a3))",
76
+ "body": "### ✨ 新功能 Features\n\n* **task:** 支持显式终止旧任务并保留拒绝记录 ([e6f7e5a](https://github.com/SilentFlower/flower-trellis/commit/e6f7e5a9c7c40c1094c6f5d80995b2a067ce2937))\n\n\n### 🐛 修复 Bug Fixes\n\n* **codex:** 保留用户多 agent 配置并修正版本说明 ([839e7e2](https://github.com/SilentFlower/flower-trellis/commit/839e7e2397baf4d78db150702707d90ace48ecc9))\n* **task:** 同步决策审查与归档规则 ([8ab3f0a](https://github.com/SilentFlower/flower-trellis/commit/8ab3f0ad4619b3bfa2afeceae3f57874566c2acd))\n* **workflow:** 同步快速直改收尾规则与验证 ([ef145c9](https://github.com/SilentFlower/flower-trellis/commit/ef145c955d9d282c92bae4e272e43eaebdcaaced))",
77
77
  "truncated": false
78
78
  },
79
79
  "optionalDependencies": {
@@ -6,10 +6,9 @@ import { FLOWER_UPDATE_HOOK_REL } from "./flower-assets.js";
6
6
  * flower-trellis 对 Trellis 生成的 codex 配置的定制后处理。
7
7
  *
8
8
  * 仅当目标项目已配置 codex 平台(存在 .codex/)时生效;在 init / update 叠加阶段调用,幂等。
9
- * 做三件事:
10
- * 1. 兼容旧 Trellis:注释掉 .codex/config.toml 的 [features.multi_agent_v2] 段;
11
- * 2. 合并 .codex/hooks.json —— 保留 Trellis 上游 hook 设置,只补 flower 需要的 SessionStart。
12
- * 3. 强制 .trellis/config.yaml 的 codex.dispatch_mode 为 auto。
9
+ * 保留用户的 Codex 功能与版本配置,只处理两件事:
10
+ * 1. 合并 .codex/hooks.json —— 保留 Trellis 上游 hook 设置,只补 flower 需要的 SessionStart。
11
+ * 2. 强制 .trellis/config.yaml 的 codex.dispatch_mode 为 auto。
13
12
  */
14
13
 
15
14
  const WORKFLOW_HOOK_SCRIPT = ".codex/hooks/inject-workflow-state.py";
@@ -158,49 +157,6 @@ function forceCodexDispatchMode(configPath) {
158
157
  return true;
159
158
  }
160
159
 
161
- /**
162
- * 注释掉 config.toml 里的 [features.multi_agent_v2] 段(段头 + 段内键,直到下一个 section)。
163
- * 幂等:段头已被注释则不再处理。
164
- * @returns {boolean} 是否发生改动
165
- */
166
- function commentMultiAgentV2(tomlPath) {
167
- if (!fs.existsSync(tomlPath)) return false;
168
- const lines = fs.readFileSync(tomlPath, "utf8").split("\n");
169
- const out = [];
170
- let inSection = false;
171
- let changed = false;
172
-
173
- for (const line of lines) {
174
- const t = line.trim();
175
- if (inSection) {
176
- // 段结束:遇到下一个未注释的 section 头
177
- if (t.startsWith("[") && !t.startsWith("#")) {
178
- inSection = false;
179
- out.push(line);
180
- continue;
181
- }
182
- // 段内非空、未注释行 → 注释
183
- if (t && !t.startsWith("#")) {
184
- out.push("# " + line);
185
- changed = true;
186
- } else {
187
- out.push(line);
188
- }
189
- continue;
190
- }
191
- if (t === "[features.multi_agent_v2]") {
192
- out.push("# " + line);
193
- inSection = true;
194
- changed = true;
195
- continue;
196
- }
197
- out.push(line);
198
- }
199
-
200
- if (changed) fs.writeFileSync(tomlPath, out.join("\n"));
201
- return changed;
202
- }
203
-
204
160
  /**
205
161
  * 容错读取 JSON 文件;缺失或格式异常时返回空 hooks 壳。
206
162
  * @param {string} hooksPath .codex/hooks.json 路径
@@ -348,13 +304,12 @@ function mergeHooks(hooksPath) {
348
304
  /**
349
305
  * codex 平台后处理入口。仅当 .codex/ 存在时执行。
350
306
  * @param {string} target 目标项目根
351
- * @returns {{applied: boolean, tomlChanged?: boolean, hooksWritten?: boolean, dispatchModeChanged?: boolean}}
307
+ * @returns {{applied: boolean, hooksWritten?: boolean, dispatchModeChanged?: boolean}} 平台处理结果
352
308
  */
353
309
  export function applyCodexTweaks(target) {
354
310
  const codexDir = path.join(target, ".codex");
355
311
  if (!fs.existsSync(codexDir)) return { applied: false };
356
- const tomlChanged = commentMultiAgentV2(path.join(codexDir, "config.toml"));
357
312
  const hooksWritten = mergeHooks(path.join(codexDir, "hooks.json"));
358
313
  const dispatchModeChanged = forceCodexDispatchMode(path.join(target, ".trellis", "config.yaml"));
359
- return { applied: true, tomlChanged, hooksWritten, dispatchModeChanged };
314
+ return { applied: true, hooksWritten, dispatchModeChanged };
360
315
  }
@@ -8,7 +8,6 @@
8
8
  "codex/dispatch-mode",
9
9
  "workflow-state-config",
10
10
  "codex/sync-user-interaction",
11
- "codex/remove-multi-agent-v2",
12
11
  "claude/startup-update-hook",
13
12
  "claude/session-start-hooks",
14
13
  "claude/statusline-active-tasks",
@@ -3,5 +3,11 @@
3
3
  "commentReplacements": [{
4
4
  "from": "# Codex hooks (`hooks.json` in this directory) only fire when the user\n# has enabled them in their USER-level config: `[features].hooks = true`\n# in ~/.codex/config.toml (Codex 0.129+; legacy name: `codex_hooks = true`,\n# still works but emits a deprecation warning on 0.129+). Project-level\n# config.toml cannot set feature flags; they must be user-level.\n# Codex 0.129+ additionally gates each installed hook behind a one-time\n# `/hooks` TUI review; until the user approves it, the hook stays inactive.",
5
5
  "to": "# Codex hooks require features.hooks and any review required by the installed\n# Codex version. Current Codex also reads supported feature flags from trusted\n# project config; older clients may require user-level settings."
6
+ }, {
7
+ "from": "# NOTE: Trellis intentionally does NOT write a [features.multi_agent_v2]\n# block here. Codex CLI changed `features` deserialization between 0.130\n# and 0.131: the structured table form (with max_concurrent_threads_per_session\n# / *_wait_timeout_ms) is only accepted by 0.131+. On 0.130 and earlier —\n# including the codex CLI bundled inside the Codex desktop app — it fails\n# with `data did not match any variant of untagged enum FeatureToml`, which\n# aborts the entire config load and blocks Codex from starting. Codex's own\n# default for multi_agent_v2 is used instead; tune it in your user-level\n# config if needed.",
8
+ "to": "# Keep multi-agent version settings user-owned. Codex selects the effective\n# runtime from explicit settings, model metadata, and existing session state.\n# A false multi_agent_v2 flag does not guarantee V1; inspect the active session.\n# Use configuration syntax supported by the installed Codex version."
9
+ }, {
10
+ "from": "# Pin the subagent recursion depth explicitly instead of relying on Codex's\n# default. #445 removed the per-agent `[features] multi_agent = false` guard\n# (the #240/#241 wait_agent-deadlock structural fix) because native subagent\n# dispatch already caps recursion via `agents.max_depth` — but that key is\n# global/user-level, not settable inside an individual agent's .toml. Pinning\n# it here means an upstream default change, or a user's own global override,\n# can't silently reopen the recursion the #240/#241 fix closed. Project config\n# (this file) takes precedence over user-level `~/.codex/config.toml`.",
11
+ "to": "# Limit recursive subagent spawning for the V1 runtime.\n# Codex MultiAgentV2 ignores agents.max_depth; this setting does not impose\n# a nesting limit on V2 agents. Verify the active runtime before relying on it.\n# This project-level setting takes precedence over the user-level value."
6
12
  }]
7
13
  }
@@ -1,17 +0,0 @@
1
- {
2
- "schemaVersion": 2,
3
- "id": "flower-codex-remove-multi-agent-v2",
4
- "purpose": "platform_config",
5
- "operations": [{
6
- "id": "flower-codex-remove-multi-agent-v2",
7
- "operation": "remove",
8
- "after": ["flower-codex-sync-user-interaction"],
9
- "targets": [{
10
- "kind": "toml",
11
- "path": ".codex/config.toml",
12
- "missing": "skip",
13
- "requires": [".codex"]
14
- }],
15
- "selector": { "type": "toml-section", "name": "features.multi_agent_v2" }
16
- }]
17
- }