harnessed 4.32.22 → 4.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +6 -6
  2. package/bin/harnessed-inject-state.mjs +16 -0
  3. package/dist/cli.mjs +1471 -302
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/index.mjs +1 -1
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/schemas/index.mjs.map +1 -1
  8. package/manifests/optional/doc-discipline-gate.yaml +54 -0
  9. package/messages/en.json +8 -0
  10. package/messages/zh-Hans.json +8 -0
  11. package/package.json +1 -1
  12. package/routing/decision_rules.yaml +1 -1
  13. package/workflows/README.md +1 -1
  14. package/workflows/auto/SKILL.md +13 -9
  15. package/workflows/auto/SKILL.zh-Hans.md +13 -9
  16. package/workflows/capabilities.yaml +100 -40
  17. package/workflows/defaults.yaml +8 -2
  18. package/workflows/disciplines/karpathy.yaml +29 -0
  19. package/workflows/disciplines/karpathy.zh-Hans.yaml +27 -0
  20. package/workflows/disciplines/language.yaml +15 -10
  21. package/workflows/disciplines/operational.yaml +1 -1
  22. package/workflows/disciplines/operational.zh-Hans.yaml +1 -1
  23. package/workflows/disciplines/output-style.yaml +10 -2
  24. package/workflows/disciplines/output-style.zh-Hans.yaml +10 -2
  25. package/workflows/disciplines/priority.yaml +15 -2
  26. package/workflows/disciplines/priority.zh-Hans.yaml +15 -2
  27. package/workflows/discuss/auto/SKILL.md +4 -4
  28. package/workflows/discuss/auto/SKILL.zh-Hans.md +4 -4
  29. package/workflows/discuss/auto/workflow.yaml +16 -3
  30. package/workflows/discuss/phase/SKILL.md +1 -1
  31. package/workflows/discuss/phase/SKILL.zh-Hans.md +1 -1
  32. package/workflows/discuss/strategic/SKILL.md +1 -1
  33. package/workflows/discuss/strategic/SKILL.zh-Hans.md +1 -1
  34. package/workflows/discuss/subtask/SKILL.md +1 -1
  35. package/workflows/discuss/subtask/SKILL.zh-Hans.md +1 -1
  36. package/workflows/judgments/parallelism-gate.yaml +11 -6
  37. package/workflows/judgments/phase-gate.yaml +5 -1
  38. package/workflows/judgments/stage-routing.yaml +21 -26
  39. package/workflows/judgments/strategic-gate.yaml +30 -0
  40. package/workflows/judgments/user-overrides.yaml +7 -3
  41. package/workflows/judgments/web-testing-routing.yaml +33 -12
  42. package/workflows/plan/architecture/SKILL.md +7 -3
  43. package/workflows/plan/architecture/SKILL.zh-Hans.md +7 -3
  44. package/workflows/plan/auto/SKILL.md +11 -7
  45. package/workflows/plan/auto/SKILL.zh-Hans.md +11 -7
  46. package/workflows/plan/phase/SKILL.md +7 -3
  47. package/workflows/plan/phase/SKILL.zh-Hans.md +7 -3
  48. package/workflows/research/SKILL.md +24 -9
  49. package/workflows/research/SKILL.zh-Hans.md +23 -9
  50. package/workflows/research/workflow.yaml +43 -3
  51. package/workflows/retro/SKILL.md +7 -3
  52. package/workflows/retro/SKILL.zh-Hans.md +7 -3
  53. package/workflows/role-prompts.yaml +28 -21
  54. package/workflows/role-prompts.zh-Hans.yaml +22 -17
  55. package/workflows/ship/auto/SKILL.md +11 -7
  56. package/workflows/ship/auto/SKILL.zh-Hans.md +11 -7
  57. package/workflows/ship/preflight/SKILL.md +7 -3
  58. package/workflows/ship/preflight/SKILL.zh-Hans.md +7 -3
  59. package/workflows/task/auto/SKILL.md +26 -16
  60. package/workflows/task/auto/SKILL.zh-Hans.md +26 -16
  61. package/workflows/task/auto/workflow.yaml +11 -4
  62. package/workflows/task/clarify/SKILL.md +1 -1
  63. package/workflows/task/clarify/SKILL.zh-Hans.md +1 -1
  64. package/workflows/task/code/SKILL.md +7 -3
  65. package/workflows/task/code/SKILL.zh-Hans.md +7 -3
  66. package/workflows/task/deliver/SKILL.md +53 -35
  67. package/workflows/task/deliver/SKILL.zh-Hans.md +54 -36
  68. package/workflows/task/deliver/workflow.yaml +32 -24
  69. package/workflows/task/test/SKILL.md +37 -3
  70. package/workflows/task/test/SKILL.zh-Hans.md +33 -3
  71. package/workflows/task/test/workflow.yaml +13 -0
  72. package/workflows/verify/auto/SKILL.md +12 -8
  73. package/workflows/verify/auto/SKILL.zh-Hans.md +12 -8
  74. package/workflows/verify/auto/workflow.yaml +3 -1
  75. package/workflows/verify/code-review/SKILL.md +7 -3
  76. package/workflows/verify/code-review/SKILL.zh-Hans.md +7 -3
  77. package/workflows/verify/design/SKILL.md +24 -10
  78. package/workflows/verify/design/SKILL.zh-Hans.md +24 -10
  79. package/workflows/verify/design/workflow.yaml +36 -7
  80. package/workflows/verify/eval-review/SKILL.md +7 -3
  81. package/workflows/verify/eval-review/SKILL.zh-Hans.md +7 -3
  82. package/workflows/verify/multispec/SKILL.md +17 -10
  83. package/workflows/verify/multispec/SKILL.zh-Hans.md +16 -10
  84. package/workflows/verify/multispec/workflow.yaml +7 -5
  85. package/workflows/verify/paranoid/SKILL.md +7 -3
  86. package/workflows/verify/paranoid/SKILL.zh-Hans.md +7 -3
  87. package/workflows/verify/progress/SKILL.md +7 -3
  88. package/workflows/verify/progress/SKILL.zh-Hans.md +7 -3
  89. package/workflows/verify/qa/SKILL.md +44 -14
  90. package/workflows/verify/qa/SKILL.zh-Hans.md +44 -14
  91. package/workflows/verify/qa/workflow.yaml +61 -2
  92. package/workflows/verify/security/SKILL.md +7 -3
  93. package/workflows/verify/security/SKILL.zh-Hans.md +7 -3
  94. package/workflows/verify/simplify/SKILL.md +7 -3
  95. package/workflows/verify/simplify/SKILL.zh-Hans.md +7 -3
  96. package/workflows/verify/validate-phase/SKILL.md +7 -3
  97. package/workflows/verify/validate-phase/SKILL.zh-Hans.md +7 -3
  98. package/manifests/skill-packs/karpathy-skills.yaml +0 -65
  99. package/manifests/tools/ralph-loop.yaml +0 -46
@@ -72,7 +72,7 @@ execution stages.
72
72
 
73
73
  Output: a locked spec the execution stages (`/plan` → `/task` → `/verify`) consume without further user input.
74
74
 
75
- <!-- harnessed-generated:v4.9.3 -->
75
+ <!-- harnessed-generated:v4.12.0 -->
76
76
 
77
77
  ## References
78
78
 
@@ -71,7 +71,7 @@ Sister `workflows/judgments/subtask-gate.yaml`:
71
71
 
72
72
  产出:一份 locked spec,执行阶段(`/plan` → `/task` → `/verify`)无需再问用户即可消费。
73
73
 
74
- <!-- harnessed-generated:v4.9.3 -->
74
+ <!-- harnessed-generated:v4.12.0 -->
75
75
 
76
76
  ## 参考资料
77
77
 
@@ -1,8 +1,10 @@
1
1
  # workflows/judgments/parallelism-gate.yaml
2
2
  # Parallelism 判据 — bundled subagent vs Agent Teams routing rules
3
- # (4 triggers: subagent-default / main-session-fallback / agent-teams-upgrade / ralph-loop-wrapper)
3
+ # (4 triggers: subagent-default / main-session-fallback / agent-teams-upgrade / completion-gate-wrapper)
4
4
  # Bundled Agent Teams lifecycle: 5 upgrade triggers + cleanup discipline
5
- # Phase v2.0-2.3 Wave 0 T2.3.W0.2 ship per D-11 (parallelism-gate) + R20.10 (ralph-loop 正交 wrapper)
5
+ # Phase v2.0-2.3 Wave 0 T2.3.W0.2 ship per D-11 (parallelism-gate) + R20.10 (完成保证正交 wrapper)
6
+ # 4.36.0 — trigger renamed ralph-loop-wrapper → completion-gate-wrapper (上游 plugin 依赖摘除;
7
+ # 保证由 harnessed `checkpoint complete` / `checkpoint fail` 自己提供)
6
8
 
7
9
  schema_version: harnessed.judgment.v1
8
10
 
@@ -35,14 +37,17 @@ triggers:
35
37
  capabilities:
36
38
  - agent-teams-create
37
39
 
38
- ralph-loop-wrapper:
40
+ completion-gate-wrapper:
39
41
  description: |
40
- Orthogonal — ralph-loop 正交 wrapper, 套在 subagent / team / main session
42
+ Orthogonal — 完成保证正交 wrapper, 套在 subagent / team / main session
41
43
  外层保 completion-promise verbatim "COMPLETE"。任何执行单元均可套用,
42
- 并非互斥触发器 (per R20.10 + D-10)。
44
+ 并非互斥触发器 (per R20.10 + D-10)。4.36.0 起由 harnessed 自己的
45
+ `harnessed checkpoint complete` / `checkpoint fail` 兑现 (fail-closed
46
+ evidence + TDD boundary + verbatim promise; BUDGET-EXHAUSTED /
47
+ NO-PROGRESS / BREAK-LOOP), 不再依赖上游 ralph-loop plugin。
43
48
  wraps:
44
49
  - subagent-default
45
50
  - agent-teams-upgrade
46
51
  - main-session-fallback
47
52
  invokes:
48
- - capability: ralph-loop
53
+ - capability: completion-gate
@@ -11,7 +11,11 @@ triggers:
11
11
  GSD /gsd-discuss-phase — 新 phase 且 ≥2 个 open implementation decisions,
12
12
  或跨 phase 数据流 / API contract / 依赖不清, 或 phase scope > 1 天 / > 5 文件,
13
13
  或存在灰色地带 (多种合理实现都讲得通) 时激活。
14
- fires_when: "phase.open_decisions >= 2 or phase.has_cross_phase_data_flow == true or phase.scope_days > 1"
14
+ # T2.1 D-2 follow-up — the `> 5 文件` half of the scope criterion. `files_touched`
15
+ # is derived by `harnessed facts` from `git diff --name-only` (worktree ∪ index)
16
+ # and is OPTIONAL: buildDefaultGateContext never seeds it, so an unknown count
17
+ # (no repo / clean tree) is an absent member = quiet false, not a fired gate.
18
+ fires_when: "phase.open_decisions >= 2 or phase.has_cross_phase_data_flow == true or phase.scope_days > 1 or phase.files_touched > 5"
15
19
  skips_when: "phase.single_task == true or phase.scope_days < 1"
16
20
  invokes:
17
21
  - capability: gsd-discuss-phase
@@ -10,27 +10,22 @@
10
10
  schema_version: harnessed.judgment.v1
11
11
 
12
12
  triggers:
13
- # /discuss master → 3 sub conditional fire
14
- discuss-strategic-delegate:
15
- description: |
16
- /discuss master → /discuss-strategic 委派 fire 当 strategic-gate.fires
17
- (任一 office-hours OR plan-ceo-review)。
18
- fires_when: "phase.type in ['new_project', 'new_milestone', 'new_feature'] or phase.is_major_release == true"
19
- invokes:
20
- - capability: gstack-office-hours
21
- - capability: gstack-plan-ceo-review
22
-
23
- discuss-phase-delegate:
24
- description: /discuss master → /discuss-phase 委派 fire per phase-gate.fires。
25
- fires_when: "phase.open_decisions >= 2 or phase.has_cross_phase_data_flow == true or phase.scope_days > 1"
26
- invokes:
27
- - capability: gsd-discuss-phase
28
-
29
- discuss-subtask-delegate:
30
- description: /discuss master → /discuss-subtask 委派 fire per subtask-gate.fires。
31
- fires_when: "subtask.approaches >= 2 or subtask.core_algorithm == true or subtask.has_api_contract == true or subtask.error_cost == 'high'"
32
- invokes:
33
- - capability: superpowers-brainstorming
13
+ # discuss-strategic-delegate MOVED to judgments/strategic-gate.yaml as
14
+ # `strategic-tier-delegate` — verbatim expression, zero behaviour change. It was
15
+ # not a copy but the UNION of that file's two triggers, so it could not simply be
16
+ # deleted in favour of one of them (either choice drops arms). Relocating it
17
+ # beside its two members is what makes a future drift visible: adding an arm to
18
+ # `office-hours` now sits one screenful from the union that must learn it too.
19
+ #
20
+ # discuss-phase-delegate / discuss-subtask-delegate REMOVED — they were verbatim
21
+ # copies of judgments/phase-gate.yaml `gsd-discuss-phase` and
22
+ # judgments/subtask-gate.yaml `brainstorming`, and the copies were what
23
+ # workflows/discuss/auto/workflow.yaml actually evaluated. The phase copy had
24
+ # already drifted: the `phase.files_touched > 5` scope arm was added to
25
+ # phase-gate.yaml but never to the copy, so the criterion could not change any
26
+ # master-tier decision. The master now gates directly on the canonical triggers
27
+ # (gate refs are cross-file — judgments.<file>.<trigger>.fires resolves any
28
+ # judgments/*.yaml). Guard: tests/workflow/judgment-expression-dedup.test.ts.
34
29
 
35
30
  # /plan master → 2 sub serial
36
31
  plan-architecture-delegate:
@@ -72,11 +67,11 @@ triggers:
72
67
  invokes:
73
68
  - capability: gstack-cso
74
69
 
75
- verify-design-changes:
76
- description: /verify master → /verify-design fire 当 has_design_changes。
77
- fires_when: "phase.stage == 'verify' and phase.has_design_changes == true"
78
- invokes:
79
- - capability: gstack-design-review
70
+ # verify-design-changes REMOVED — verbatim copy of
71
+ # judgments/web-design-routing.yaml `design-review-post`, which T2.3 already
72
+ # made the canonical home (workflows/verify/design/workflow.yaml gates on it).
73
+ # workflows/verify/auto/workflow.yaml now delegates on the same canonical
74
+ # trigger; predicate is unchanged, so behaviour is identical.
80
75
 
81
76
  verify-eval-review-aiphase:
82
77
  description: /verify master → /verify-eval-review fire 当 has_ai_phase (AI phase eval 覆盖审计)。
@@ -23,3 +23,33 @@ triggers:
23
23
  skips_when: "phase.scope_locked_in_history == true or phase.type in ['bug_fix', 'tech_debt']"
24
24
  invokes:
25
25
  - capability: gstack-plan-ceo-review
26
+
27
+ # Routing-shaped entry in a tier-judgment file — deliberate. The /discuss master
28
+ # asks a coarser question than either trigger above: "is the strategic tier in
29
+ # play at all?", i.e. the UNION of the two. It cannot gate on `office-hours`
30
+ # (that drops the `is_major_release` arm) nor on `plan-ceo-review` (that drops
31
+ # the new_milestone / new_feature arms), so the union needs a home — and its home
32
+ # must be HERE, beside its two members, where a new arm added to either one makes
33
+ # the omission from the union visible in the same screenful. Living in
34
+ # stage-routing.yaml is what let it rot unobserved (sister: the phase-tier copy
35
+ # that silently lost `files_touched > 5`).
36
+ #
37
+ # The delegation is coarse ON PURPOSE: /discuss-strategic re-gates each member
38
+ # independently inside the sub-workflow, so a context that fires only one arm
39
+ # runs only that one capability. This trigger decides whether the tier is
40
+ # entered, never which of the two runs.
41
+ #
42
+ # Endgame is not this entry: it is a schema that lets `gate:` take multiple refs
43
+ # OR'd together, which would delete the union expression instead of relocating
44
+ # it. That costs WorkflowSchemaV3 + gates.ts + masterOrchestrator.ts +
45
+ # scripts/check-workflow-schema.mjs (mirror) — a separate slice. Until then this
46
+ # is the cheapest form that keeps one expression with one home.
47
+ strategic-tier-delegate:
48
+ description: |
49
+ /discuss master → /discuss-strategic 委派 gate — 上面两条 trigger 的并集
50
+ (任一 office-hours OR plan-ceo-review 可能 fire → 战略层适用)。
51
+ sub-workflow 内部再对两条各自独立 gate。
52
+ fires_when: "phase.type in ['new_project', 'new_milestone', 'new_feature'] or phase.is_major_release == true"
53
+ invokes:
54
+ - capability: gstack-office-hours
55
+ - capability: gstack-plan-ceo-review
@@ -28,8 +28,9 @@ overrides:
28
28
  - "brainstorm first"
29
29
  - "let's brainstorm"
30
30
  triggers:
31
+ # stage-routing.discuss-subtask-delegate removed — it was a copy of this
32
+ # trigger; workflows/discuss/auto/workflow.yaml now gates on the canonical one.
31
33
  - judgments.subtask-gate.brainstorming.fires
32
- - judgments.stage-routing.discuss-subtask-delegate.fires
33
34
 
34
35
  - id: strategic-review
35
36
  keywords:
@@ -42,7 +43,9 @@ overrides:
42
43
  triggers:
43
44
  - judgments.strategic-gate.office-hours.fires
44
45
  - judgments.strategic-gate.plan-ceo-review.fires
45
- - judgments.stage-routing.discuss-strategic-delegate.fires
46
+ # was stage-routing.discuss-strategic-delegate — same expression, relocated
47
+ # beside the two triggers it aggregates.
48
+ - judgments.strategic-gate.strategic-tier-delegate.fires
46
49
 
47
50
  - id: arch-review
48
51
  keywords:
@@ -60,8 +63,9 @@ overrides:
60
63
  - "discuss-phase"
61
64
  - "gsd-discuss-phase"
62
65
  triggers:
66
+ # stage-routing.discuss-phase-delegate removed — it was a (drifted) copy of
67
+ # this trigger; workflows/discuss/auto/workflow.yaml now gates on the canonical one.
63
68
  - judgments.phase-gate.gsd-discuss-phase.fires
64
- - judgments.stage-routing.discuss-phase-delegate.fires
65
69
 
66
70
  - id: paranoid-review
67
71
  keywords:
@@ -4,9 +4,17 @@
4
4
  #
5
5
  # 三层职责矩阵 verbatim:
6
6
  # 脑 (写测试 / 跑 CI) — @playwright/test (frontend/e2e/*.spec.ts)
7
- # 手 (AI 实时操作) — playwright-cli (一行 Bash, token 最省)
7
+ # 手 (AI 实时操作) — /browse 主导 (gstack headless Playwright);
8
+ # 未装 gstack 降级 playwright-cli (一行 Bash, token 最省)
8
9
  # 筋骨 (Python 后端联动) — webapp-testing skill (tests/e2e/*.py)
9
- # 非功能性诊断 (性能/a11y/内存) — chrome-devtools-mcp (必用)
10
+ # 非功能性诊断 (性能/a11y/内存) — chrome-devtools-mcp (有 provider 时必用;
11
+ # ecc / 自装 manifest 二选一, 两者都缺则该 lane 不 fire)
12
+ #
13
+ # T2.3 — 本 file 的 4 trigger 之前是运行时孤儿 (零 gate ref → resolveJudgmentGate
14
+ # 纯 ref 驱动, 永不加载求值)。现由 workflows/verify/qa/workflow.yaml 的 4 条 lane
15
+ # phase 各接一个 gate。手层 trigger 由 playwright-cli-probe 改名 browse-probe:
16
+ # 浏览器探查偏好 /browse (token 高效, 可复用 cookies 与会话状态)。
17
+ # 这是路由偏好, NOT deny-list — 不禁用任何浏览器工具。
10
18
  #
11
19
  # expr-eval 2.0.2 case-sensitive: keyword `and` / `or` 全小写 (sister Phase 2.3 W0.2 bug)
12
20
 
@@ -23,14 +31,19 @@ triggers:
23
31
  invokes:
24
32
  - capability: playwright-test
25
33
 
26
- playwright-cli-probe:
34
+ browse-probe:
27
35
  description: |
28
- playwright-cli — AI 实时操作浏览器 一行 Bash, token 最省;
29
- 用于探查 / 调试 / 一次性确认 (非提交 repo)。
30
- 探查产出的 selectors 再沉淀到正式 test。
31
- fires_when: "subtask.test_type == 'probe'"
36
+ 浏览器探查 / 调试 / 一次性确认 (非提交 repo) — 主导 /browse。
37
+ 探查产出的 selectors 再沉淀到正式 test (playwright-test-default lane)。
38
+ Provider 说明 (降级链, 同下方 chrome-devtools 二选一注记体例):
39
+ 首选 browse (gstack user-skill, capabilities.yaml browse — headless Playwright,
40
+ token 高效, 可复用 cookies 与会话状态) → 未装 gstack 时本 capability 不可用,
41
+ 降级 playwright-cli (npm-cli, 无 gstack 依赖, 仍在 tools_available 内) →
42
+ 两者都缺时用 harness 平台内置浏览器工具。
43
+ 路由偏好而非 deny-list: 只表达优先级, 不禁用任何浏览器工具。
44
+ fires_when: "subtask.test_type == 'probe' or subtask.needs_browser_automation == true"
32
45
  invokes:
33
- - capability: playwright-cli
46
+ - capability: browse
34
47
 
35
48
  webapp-testing-python-backend:
36
49
  description: |
@@ -43,13 +56,21 @@ triggers:
43
56
 
44
57
  chrome-devtools-mcp-diagnostic:
45
58
  description: |
46
- chrome-devtools-mcp — 非功能性诊断必须用 (NOT playwright/test/cli/webapp-testing)。
47
- LCP / Core Web Vitals / ARIA / 堆快照。
59
+ chrome-devtools-mcp — 非功能性诊断在 provider 在场时必须用它
60
+ (NOT playwright/test/cli/webapp-testing)。LCP / Core Web Vitals / ARIA / 堆快照。
48
61
  Provider 说明 (4.32.22 终局): 二选一 — ecc (manifests/optional/ecc.yaml,
49
62
  bonus tier; ECC 唯一默认 MCP connector) 或 optional 自装 manifest
50
63
  (manifests/optional/chrome-devtools-mcp.yaml, mcp-stdio-add 兜底, 供不装
51
64
  ecc 的用户; setup optional offer 可勾选)。双装同名双前缀歧义, doctor
52
- `ecc` check 会 warn。两者都缺 → 本 capability 不可用。
53
- fires_when: "subtask.test_type == 'perf-diagnostic'"
65
+ `ecc` check 会 warn。
66
+ 两者都缺 → 本 capability 不可用, 本 trigger 不 fire。这一句从散文变成判据:
67
+ fires_when 第二个 arm `chrome_devtools_available == true` 由
68
+ src/cli/lib/probe-chrome-devtools.ts 实测 (ecc plugin / 官方 plugin /
69
+ stdio mcpServers 三种注册形态), 经 `harnessed facts` 自动填入 (确定性事实,
70
+ 不问模型)。probe 抛错 = unknown → 仍算 available (fail-soft; 绝不静默删掉
71
+ 已声明的诊断能力, sister src/workflow/skipGate.ts)。
72
+ 未 fire 时的开启路径 (二选一): `harnessed install ecc`
73
+ 或 `claude mcp add chrome-devtools-mcp` —— 只装其中一个。
74
+ fires_when: "subtask.test_type == 'perf-diagnostic' and chrome_devtools_available == true"
54
75
  invokes:
55
76
  - capability: chrome-devtools-mcp
@@ -67,11 +67,15 @@ Do NOT pipe to `harnessed run plan-architecture` — that is the CI/headless pat
67
67
  that blocks the session inside Claude Code).
68
68
 
69
69
  1. Bash: `harnessed prompt plan-architecture --task "$ARGUMENTS" --json` → parse `{prompt, max_iterations, model}`.
70
- 2. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` + `model`, wrapped in the ralph-loop plugin: `/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`. If the plugin is absent, use the native goal gate instead (Claude Code 2.1.139+ / Codex): `/goal "this subtask is delivered: the subagent's final output contains verbatim <promise>COMPLETE</promise>; or stop after <max_iterations> turns"` then spawn the subagent and let the goal evaluator drive re-spawns until it clears. If `/goal` is unavailable too, self-loop: spawn → check output for `<promise>COMPLETE</promise>` → re-spawn with prior output appended (up to max_iterations). Set the goal only at the leaf subtask level — `/goal` is single-slot per session and a nested goal overwrites the outer one.
70
+ 2. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` and `model`, then drive delivery with harnessed's own completion gate:
71
+ - on return, write the subagent's final output to a file and run `harnessed checkpoint complete plan-architecture --result-file <path>` — it is fail-closed on the declared artifacts, the TDD boundary, and the verbatim `<promise>COMPLETE</promise>`.
72
+ - if it blocks, run `harnessed checkpoint fail plan-architecture --failing-tests <n>` to record the attempt; it prints BUDGET-EXHAUSTED / NO-PROGRESS / BREAK-LOOP when a stop condition is reached.
73
+ - respawn ONLY while none of those three has fired. Any one of them means stop: re-scope the subtask, fix the blocker, or escalate to the user. Never respawn past a stop directive.
71
74
  3. If the output contains `STATUS: NEEDS_CLARIFICATION` + a question list: STOP, relay them verbatim via AskUserQuestion, append the answers to the spec, then re-spawn the same sub.
72
- 4. On `<promise>COMPLETE</promise>`: Bash `harnessed checkpoint complete plan-architecture --summary "<one-line>"`. The evidence guard runs here (fail-CLOSED): if a declared `artifacts_expected` file is missing it exits non-zero — re-spawn to produce it before treating the sub as done.
75
+ 4. On `<promise>COMPLETE</promise>`: write the subagent’s final output to a file, then Bash `harnessed checkpoint complete plan-architecture --result-file <path> --summary "<one-line>"`. Fail-CLOSED — it blocks unless every declared `artifacts_expected` file exists, the TDD boundary passes (non-empty evidence / both the red and green sides present / the test file was not deleted), and the result carries a verbatim `<promise>COMPLETE</promise>` (or a structured COMPLETE status). `--result <text>` is the inline variant; `--result-file` wins and is quoting-safe on Windows. `--force` records an audited override (`evidence_status=overridden`) — it does not silently pass.
76
+ 5. If the complete gate blocked: Bash `harnessed checkpoint fail plan-architecture --failing-tests <n>` to record the attempt. It prints `BUDGET-EXHAUSTED` / `NO-PROGRESS` / `BREAK-LOOP` once a stop condition is reached. Respawn ONLY while none of those three has fired; any one of them means STOP — re-scope the subtask, fix the blocker, or escalate to the user.
73
77
 
74
- <!-- harnessed-generated:v4.9.3 -->
78
+ <!-- harnessed-generated:v4.12.0 -->
75
79
 
76
80
  ## References
77
81
 
@@ -66,11 +66,15 @@ CC-native Task / Agent 工具 spawn subagent(保持 session 响应 + 让澄清 r
66
66
  Code 内部会阻塞 session)。
67
67
 
68
68
  1. Bash: `harnessed prompt plan-architecture --task "$ARGUMENTS" --json` → 解析 `{prompt, max_iterations, model}`。
69
- 2. 用 CC-native subagent(Task / Agent 工具)以该 `prompt` + `model` spawn,用 ralph-loop plugin 包裹:`/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`。若 plugin 未装,改用原生 goal gate(Claude Code 2.1.139+ / Codex):`/goal "this subtask is delivered: the subagent's final output contains verbatim <promise>COMPLETE</promise>; or stop after <max_iterations> turns"`,随后 spawn subagent,由 goal 评估器驱动重 spawn 直到目标清除。若 `/goal` 也不可用,自循环:spawn → 检查输出 `<promise>COMPLETE</promise>` → 把上轮输出 append 后重 spawn(至多 max_iterations)。goal 只在叶子 subtask 层设置 — `/goal` 每 session 单槽,嵌套 goal 会覆盖外层。
69
+ 2. 用 CC-native subagent(Task / Agent 工具)以该 `prompt` + `model` spawn,然后用 harnessed 自己的完成闸门驱动交付:
70
+ - subagent 返回后,把它的最终输出写入文件,跑 `harnessed checkpoint complete plan-architecture --result-file <path>` —— 该命令对声明的产物、TDD boundary、逐字 `<promise>COMPLETE</promise>` 三者 fail-closed。
71
+ - 若被拦下,跑 `harnessed checkpoint fail plan-architecture --failing-tests <n>` 记录本次尝试;命中停机条件时它会打印 BUDGET-EXHAUSTED / NO-PROGRESS / BREAK-LOOP。
72
+ - **仅当**这三者都未触发时才允许重 spawn。任一触发即停:重新收敛子任务范围、修掉阻塞点,或上报用户。绝不越过停机指令继续重 spawn。
70
73
  3. 若输出含 `STATUS: NEEDS_CLARIFICATION` + 问题列表:STOP,用 AskUserQuestion 原样转达,把答案 append 进 spec,再重 spawn。
71
- 4. 命中 `<promise>COMPLETE</promise>`:Bash `harnessed checkpoint complete plan-architecture --summary "<one-line>"`。evidence guard 在此运行(fail-CLOSED):若声明的 `artifacts_expected` 文件缺失会 exit 非零 —— 重 spawn 产出它再算 done。
74
+ 4. 命中 `<promise>COMPLETE</promise>`:把 subagent 最终输出写入文件,再 Bash `harnessed checkpoint complete plan-architecture --result-file <path> --summary "<one-line>"`。fail-CLOSED —— 除非声明的 `artifacts_expected` 文件全部存在、TDD boundary 通过(证据非空 / 红绿两侧齐全 / 测试文件未被删除)、且结果含逐字 `<promise>COMPLETE</promise>`(或结构化 COMPLETE 状态),否则拦下。`--result <text>` 是内联变体;`--result-file` 优先且在 Windows 上引号安全。`--force` 记录可审计的覆盖(`evidence_status=overridden`),不是静默放行。
75
+ 5. 若 complete 闸门拦下:Bash `harnessed checkpoint fail plan-architecture --failing-tests <n>` 记录本次尝试。命中停机条件时会打印 `BUDGET-EXHAUSTED` / `NO-PROGRESS` / `BREAK-LOOP`。**仅当**三者都未触发时才允许重 spawn;任一触发即 STOP —— 重新收敛子任务范围、修掉阻塞点,或上报用户。
72
76
 
73
- <!-- harnessed-generated:v4.9.3 -->
77
+ <!-- harnessed-generated:v4.12.0 -->
74
78
 
75
79
  ## 参考文档
76
80
 
@@ -68,22 +68,26 @@ Do NOT pipe to `harnessed run plan` — that is the CI/headless path (in-process
68
68
  that blocks the session, bypasses Agent Teams, and hangs inside Claude Code).
69
69
 
70
70
  1. If the clarification criteria fire for "$ARGUMENTS" (≥2 approaches / core algorithm / API contract / high error cost), clarify interactively in THIS session first (AskUserQuestion) and lock decisions; otherwise transparent-skip. Produce a locked spec.
71
- 2. Bash: `harnessed gates plan --task "<locked spec>" --skip-sub discuss` → parse the JSON `{fire, skip, parallelism}`. This is the plan SoT (no spawn). Keep the verbatim JSON.
71
+ 1b. Bash: `harnessed facts plan --out .harnessed-facts.json` → it lists ONLY the facts this stage’s gates actually read: deterministic ones already filled (change size / files touched / stage, from git), judgement calls left `null` with a one-line hint of what to judge. Edit the file and replace each `null` in `facts` with your honest answer from the locked spec — leave one null only if you genuinely cannot judge it (it then falls back to the built-in default). Do NOT skip this step and do NOT invent facts the command did not ask for.
72
+ 2. Bash: `harnessed gates plan --task "<locked spec>" --context-file .harnessed-facts.json --skip-sub discuss` → parse the JSON `{fire, skip, parallelism}`. This is the plan SoT (no spawn). Keep the verbatim JSON.
72
73
  3. Bash: `harnessed checkpoint start plan --plan '<the verbatim gates JSON from step 2>'` → seeds the per-sub ledger so `harnessed status --recover` can re-orient you after compaction.
73
- 4. If `parallelism.escalate_to_teams === true`: read `~/.claude/rules/agent-teams.md`, then drive the fired subs as an Agent Team (`TeamCreate` → `Agent(name, team_name, …)` per sub with its `harnessed prompt <sub>` prompt → coordinate via `SendMessage` → `SendMessage shutdown_request` + `TeamDelete`). Still checkpoint each sub (`complete` / `fail`) as below.
74
+ 4. If `parallelism.escalate_to_teams === true`: read `~/.claude/rules/agent-teams.md`, then drive the fired subs as an Agent Team. There is NO create step and no create tool — spawn one background teammate per fired sub with `Agent(name: <sub>, run_in_background: true, prompt: <that sub's `harnessed prompt <sub>` prompt>)` and the team forms implicitly on the FIRST spawn, with this session as lead (the `team_name` input is accepted but ignored — the name is session-derived). Coordinate via `SendMessage`; when a sub is finished, ask that teammate to shut down BY NAME (e.g. "ask the verify-qa teammate to shut down"). Still checkpoint each sub (`complete` / `fail`) as below.
74
75
  5. Otherwise, for each fired sub in `order` (serial subs sequentially, parallel subs concurrently):
75
- - **If the entry has `is_master: true`** (a stage master — e.g. `/auto` firing `plan`/`task`/`verify`): do NOT prompt+spawn it. RECURSE: run that master’s own `harnessed gates <sub> --task "<spec>" --skip-sub discuss` → `harnessed checkpoint start <sub> --plan '<json>'` → repeat this loop for ITS fired subs.
76
+ - **If the entry has `is_master: true`** (a stage master — e.g. `/auto` firing `plan`/`task`/`verify`): do NOT prompt+spawn it. RECURSE: run that master’s own `harnessed facts <sub> --out .harnessed-facts.json` (fill the nulls) → `harnessed gates <sub> --task "<spec>" --context-file .harnessed-facts.json --skip-sub discuss` → `harnessed checkpoint start <sub> --plan '<json>'` → repeat this loop for ITS fired subs.
76
77
  - **Else (leaf sub):**
77
78
  a. Bash: `harnessed prompt <sub> --task "<spec>" --json` → parse `{prompt, max_iterations, model}`.
78
- b. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` + `model`, wrapped in the ralph-loop plugin: `/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`. If the plugin is absent, use the native goal gate instead (Claude Code 2.1.139+ / Codex): `/goal "this subtask is delivered: the subagent's final output contains verbatim <promise>COMPLETE</promise>; or stop after <max_iterations> turns"` then spawn the subagent and let the goal evaluator drive re-spawns until it clears. If `/goal` is unavailable too, self-loop: spawn → check output for `<promise>COMPLETE</promise>` → re-spawn with prior output appended (up to max_iterations). Set the goal only at the leaf subtask level — `/goal` is single-slot per session and a nested goal overwrites the outer one.
79
+ b. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` and `model`, then drive delivery with harnessed's own completion gate:
80
+ - on return, write the subagent's final output to a file and run `harnessed checkpoint complete <sub> --result-file <path>` — it is fail-closed on the declared artifacts, the TDD boundary, and the verbatim `<promise>COMPLETE</promise>`.
81
+ - if it blocks, run `harnessed checkpoint fail <sub> --failing-tests <n>` to record the attempt; it prints BUDGET-EXHAUSTED / NO-PROGRESS / BREAK-LOOP when a stop condition is reached.
82
+ - respawn ONLY while none of those three has fired. Any one of them means stop: re-scope the subtask, fix the blocker, or escalate to the user. Never respawn past a stop directive.
79
83
  c. If the output contains `STATUS: NEEDS_CLARIFICATION` + questions: STOP, relay them verbatim via AskUserQuestion, append the answers to the spec, then re-spawn the same sub.
80
- d. On `<promise>COMPLETE</promise>`: Bash `harnessed checkpoint complete <sub> --summary "<one-line>"`. The evidence guard runs here (fail-CLOSED): if a declared `artifacts_expected` file is missing it exits non-zero — re-spawn to produce it, or pass `--force` only to deliberately override.
81
- e. If the sub cannot reach COMPLETE (max_iterations exhausted / unrecoverable error): Bash `harnessed checkpoint fail <sub> --summary "<why>"`, then STOP and report to the user.
84
+ d. On `<promise>COMPLETE</promise>`: write the subagent’s final output to a file, then Bash `harnessed checkpoint complete <sub> --result-file <path> --summary "<one-line>"`. Fail-CLOSED — it blocks unless every declared `artifacts_expected` file exists, the TDD boundary passes (non-empty evidence / both the red and green sides present / the test file was not deleted), and the result carries a verbatim `<promise>COMPLETE</promise>` (or a structured COMPLETE status). `--result <text>` is the inline variant; `--result-file` wins and is quoting-safe on Windows. On a non-zero exit the sub is NOT done — re-spawn to close the gap, or pass `--force` only to deliberately override (records `evidence_status=overridden`, an audited override rather than a silent pass).
85
+ e. If the complete gate blocked: Bash `harnessed checkpoint fail <sub> --failing-tests <n>` to record the attempt (omit the flag when the sub has no tests — the evidence-artifact digest is the fallback progress metric). It prints `BUDGET-EXHAUSTED` (attempts spent vs `workflows/defaults.yaml ralph_max_iterations`), `NO-PROGRESS` (no improvement for N consecutive attempts) or `BREAK-LOOP` (this sub failed >= the threshold) once a stop condition is reached. Respawn ONLY while none of those three has fired; any one of them means STOP — re-scope, fix the blocker, or escalate to the user, and report it.
82
86
  6. After all fired subs are `done` (or recorded `failed`), Bash `harnessed status --recover` to confirm the ledger and report a per-sub fired/skipped/done/failed summary to the user.
83
87
 
84
88
  **If you lose context (compaction / resume):** run `harnessed status --recover` first — it reads the ledger and prints "you are here, this is next" so you resume at the first `pending` sub instead of restarting. If the ledger is empty, re-run steps 2-3.
85
89
 
86
- <!-- harnessed-generated:v4.9.3 -->
90
+ <!-- harnessed-generated:v4.12.0 -->
87
91
 
88
92
  ## References
89
93
 
@@ -67,22 +67,26 @@ Sister `workflows/capabilities.yaml`:
67
67
  session、绕过 Agent Teams,在 Claude Code 内部调用时会挂死)。
68
68
 
69
69
  1. 若 "$ARGUMENTS" 触发澄清判据(≥2 方案 / 核心算法 / API contract / 高错误成本),先在**本 session** 交互澄清(AskUserQuestion)并锁决策;否则透明 skip。产出 locked spec。
70
- 2. Bash: `harnessed gates plan --task "<locked spec>" --skip-sub discuss` → 解析 JSON `{fire, skip, parallelism}`。这是 plan SoT(不 spawn)。保留 verbatim JSON。
70
+ 1b. Bash: `harnessed facts plan --out .harnessed-facts.json` → 它只列出**本阶段 gate 真正读取**的 fact:能确定性推导的已填好(改动行数 / 触及文件数 / stage,来自 git),判断题留 `null` 并附一行说明。编辑该文件,把 `facts` 里每个 `null` 按 locked spec 换成你的真实判断 —— 只有确实无法判断时才留 null(此时回退内置默认值)。**不要**跳过本步,也**不要**自行编造命令没问的 fact。
71
+ 2. Bash: `harnessed gates plan --task "<locked spec>" --context-file .harnessed-facts.json --skip-sub discuss` → 解析 JSON `{fire, skip, parallelism}`。这是 plan SoT(不 spawn)。保留 verbatim JSON。
71
72
  3. Bash: `harnessed checkpoint start plan --plan '<step 2 的 verbatim gates JSON>'` → seed per-sub ledger,让 `harnessed status --recover` 能在 compaction 后给你重新定位。
72
- 4. 若 `parallelism.escalate_to_teams === true`:读 `~/.claude/rules/agent-teams.md`,然后把 fired subs 作为 Agent Team 驱动(`TeamCreate` → 每个 sub `Agent(name, team_name, …)` + 其 `harnessed prompt <sub>` prompt → 用 `SendMessage` 协调 → `SendMessage shutdown_request` + `TeamDelete`)。每个 sub 仍按下方 checkpoint(`complete` / `fail`)。
73
+ 4. 若 `parallelism.escalate_to_teams === true`:读 `~/.claude/rules/agent-teams.md`,然后把 fired subs 作为 Agent Team 驱动。**没有建团步骤、也没有建团工具** —— 对每个 fired sub 用 `Agent(name: <sub>, run_in_background: true, prompt: <该 sub 的 `harnessed prompt <sub>` prompt>)` spawn 一个后台 teammate,团在**第一个** spawn 时隐式形成,本 session 即 lead(`team_name` 入参被接受但忽略 —— 团名由 session 派生)。用 `SendMessage` 协调;某个 sub 完成后,**按名**请求该 teammate 关闭(例如「ask the verify-qa teammate to shut down」)。每个 sub 仍按下方 checkpoint(`complete` / `fail`)。
73
74
  5. 否则,对 `order` 里每个 fired sub(serial 串行、parallel 并发):
74
- - **若该项 `is_master: true`**(本身是 stage master —— 如 `/auto` fire `plan`/`task`/`verify`):**不要**直接 prompt+spawn。RECURSE:跑该 master 自己的 `harnessed gates <sub> --task "<spec>" --skip-sub discuss` → `harnessed checkpoint start <sub> --plan '<json>'` → 对它的 fired subs 重复本循环。
75
+ - **若该项 `is_master: true`**(本身是 stage master —— 如 `/auto` fire `plan`/`task`/`verify`):**不要**直接 prompt+spawn。RECURSE:跑该 master 自己的 `harnessed facts <sub> --out .harnessed-facts.json`(填完 null)→ `harnessed gates <sub> --task "<spec>" --context-file .harnessed-facts.json --skip-sub discuss` → `harnessed checkpoint start <sub> --plan '<json>'` → 对它的 fired subs 重复本循环。
75
76
  - **否则(leaf sub):**
76
77
  a. Bash: `harnessed prompt <sub> --task "<spec>" --json` → 解析 `{prompt, max_iterations, model}`。
77
- b. 用 CC-native subagent(Task / Agent 工具)以该 `prompt` + `model` spawn,用 ralph-loop plugin 包裹:`/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`。若 plugin 未装,改用原生 goal gate(Claude Code 2.1.139+ / Codex):`/goal "this subtask is delivered: the subagent's final output contains verbatim <promise>COMPLETE</promise>; or stop after <max_iterations> turns"`,随后 spawn subagent,由 goal 评估器驱动重 spawn 直到目标清除。若 `/goal` 也不可用,自循环:spawn → 检查输出 `<promise>COMPLETE</promise>` → 把上轮输出 append 后重 spawn(至多 max_iterations)。goal 只在叶子 subtask 层设置 — `/goal` 每 session 单槽,嵌套 goal 会覆盖外层。
78
+ b. 用 CC-native subagent(Task / Agent 工具)以该 `prompt` + `model` spawn,然后用 harnessed 自己的完成闸门驱动交付:
79
+ - subagent 返回后,把它的最终输出写入文件,跑 `harnessed checkpoint complete <sub> --result-file <path>` —— 该命令对声明的产物、TDD boundary、逐字 `<promise>COMPLETE</promise>` 三者 fail-closed。
80
+ - 若被拦下,跑 `harnessed checkpoint fail <sub> --failing-tests <n>` 记录本次尝试;命中停机条件时它会打印 BUDGET-EXHAUSTED / NO-PROGRESS / BREAK-LOOP。
81
+ - **仅当**这三者都未触发时才允许重 spawn。任一触发即停:重新收敛子任务范围、修掉阻塞点,或上报用户。绝不越过停机指令继续重 spawn。
78
82
  c. 若输出含 `STATUS: NEEDS_CLARIFICATION` + 问题列表:STOP,用 AskUserQuestion 原样转达,把答案 append 进 spec,再重 spawn 同一 sub。
79
- d. 命中 `<promise>COMPLETE</promise>`:Bash `harnessed checkpoint complete <sub> --summary "<one-line>"`。evidence guard 在此运行(fail-CLOSED):若声明的 `artifacts_expected` 文件缺失会 exit 非零 —— 重 spawn 产出它,或仅在刻意覆盖时传 `--force`。
80
- e. 若 sub 无法达到 COMPLETE(max_iterations 耗尽 / 不可恢复错误):Bash `harnessed checkpoint fail <sub> --summary "<why>"`,然后 STOP 并向用户报告。
83
+ d. 命中 `<promise>COMPLETE</promise>`:把 subagent 最终输出写入文件,再 Bash `harnessed checkpoint complete <sub> --result-file <path> --summary "<one-line>"`。fail-CLOSED —— 除非声明的 `artifacts_expected` 文件全部存在、TDD boundary 通过(证据非空 / 红绿两侧齐全 / 测试文件未被删除)、且结果含逐字 `<promise>COMPLETE</promise>`(或结构化 COMPLETE 状态),否则拦下。`--result <text>` 是内联变体;`--result-file` 优先且在 Windows 上引号安全。exit 非零即表示该 sub **未** done —— 重 spawn 补齐,或仅在刻意覆盖时传 `--force`(记录 `evidence_status=overridden`,是可审计的覆盖而非静默放行)。
84
+ e. 若 complete 闸门拦下:Bash `harnessed checkpoint fail <sub> --failing-tests <n>` 记录本次尝试(该 sub 无测试时省略该 flag —— 回退用证据产物摘要作进展度量)。命中停机条件时它会打印 `BUDGET-EXHAUSTED`(已用尝试次数 vs `workflows/defaults.yaml ralph_max_iterations`)、`NO-PROGRESS`(连续 N 次无进展)或 `BREAK-LOOP`(该 sub 失败次数达阈值)。**仅当**三者都未触发时才允许重 spawn;任一触发即 STOP —— 重新收敛范围、修掉阻塞点或上报用户,并说明情况。
81
85
  6. 所有 fired subs `done`(或记录 `failed`)后,Bash `harnessed status --recover` 确认 ledger,并向用户报告 per-sub fired/skipped/done/failed 摘要。
82
86
 
83
87
  **若丢失上下文(compaction / resume):** 先跑 `harnessed status --recover` —— 它读 ledger 并打印「你在这里,下一步是什么」,让你从第一个 `pending` sub 续跑而非重启。若 ledger 为空,重跑 step 2-3。
84
88
 
85
- <!-- harnessed-generated:v4.9.3 -->
89
+ <!-- harnessed-generated:v4.12.0 -->
86
90
 
87
91
  ## 参考文档
88
92
 
@@ -69,11 +69,15 @@ Do NOT pipe to `harnessed run plan-phase` — that is the CI/headless path (in-p
69
69
  that blocks the session inside Claude Code).
70
70
 
71
71
  1. Bash: `harnessed prompt plan-phase --task "$ARGUMENTS" --json` → parse `{prompt, max_iterations, model}`.
72
- 2. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` + `model`, wrapped in the ralph-loop plugin: `/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`. If the plugin is absent, use the native goal gate instead (Claude Code 2.1.139+ / Codex): `/goal "this subtask is delivered: the subagent's final output contains verbatim <promise>COMPLETE</promise>; or stop after <max_iterations> turns"` then spawn the subagent and let the goal evaluator drive re-spawns until it clears. If `/goal` is unavailable too, self-loop: spawn → check output for `<promise>COMPLETE</promise>` → re-spawn with prior output appended (up to max_iterations). Set the goal only at the leaf subtask level — `/goal` is single-slot per session and a nested goal overwrites the outer one.
72
+ 2. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` and `model`, then drive delivery with harnessed's own completion gate:
73
+ - on return, write the subagent's final output to a file and run `harnessed checkpoint complete plan-phase --result-file <path>` — it is fail-closed on the declared artifacts, the TDD boundary, and the verbatim `<promise>COMPLETE</promise>`.
74
+ - if it blocks, run `harnessed checkpoint fail plan-phase --failing-tests <n>` to record the attempt; it prints BUDGET-EXHAUSTED / NO-PROGRESS / BREAK-LOOP when a stop condition is reached.
75
+ - respawn ONLY while none of those three has fired. Any one of them means stop: re-scope the subtask, fix the blocker, or escalate to the user. Never respawn past a stop directive.
73
76
  3. If the output contains `STATUS: NEEDS_CLARIFICATION` + a question list: STOP, relay them verbatim via AskUserQuestion, append the answers to the spec, then re-spawn the same sub.
74
- 4. On `<promise>COMPLETE</promise>`: Bash `harnessed checkpoint complete plan-phase --summary "<one-line>"`. The evidence guard runs here (fail-CLOSED): if a declared `artifacts_expected` file is missing it exits non-zero — re-spawn to produce it before treating the sub as done.
77
+ 4. On `<promise>COMPLETE</promise>`: write the subagent’s final output to a file, then Bash `harnessed checkpoint complete plan-phase --result-file <path> --summary "<one-line>"`. Fail-CLOSED — it blocks unless every declared `artifacts_expected` file exists, the TDD boundary passes (non-empty evidence / both the red and green sides present / the test file was not deleted), and the result carries a verbatim `<promise>COMPLETE</promise>` (or a structured COMPLETE status). `--result <text>` is the inline variant; `--result-file` wins and is quoting-safe on Windows. `--force` records an audited override (`evidence_status=overridden`) — it does not silently pass.
78
+ 5. If the complete gate blocked: Bash `harnessed checkpoint fail plan-phase --failing-tests <n>` to record the attempt. It prints `BUDGET-EXHAUSTED` / `NO-PROGRESS` / `BREAK-LOOP` once a stop condition is reached. Respawn ONLY while none of those three has fired; any one of them means STOP — re-scope the subtask, fix the blocker, or escalate to the user.
75
79
 
76
- <!-- harnessed-generated:v4.9.3 -->
80
+ <!-- harnessed-generated:v4.12.0 -->
77
81
 
78
82
  ## References
79
83
 
@@ -68,11 +68,15 @@ CC-native Task / Agent 工具 spawn subagent(保持 session 响应 + 让澄清 r
68
68
  Code 内部会阻塞 session)。
69
69
 
70
70
  1. Bash: `harnessed prompt plan-phase --task "$ARGUMENTS" --json` → 解析 `{prompt, max_iterations, model}`。
71
- 2. 用 CC-native subagent(Task / Agent 工具)以该 `prompt` + `model` spawn,用 ralph-loop plugin 包裹:`/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`。若 plugin 未装,改用原生 goal gate(Claude Code 2.1.139+ / Codex):`/goal "this subtask is delivered: the subagent's final output contains verbatim <promise>COMPLETE</promise>; or stop after <max_iterations> turns"`,随后 spawn subagent,由 goal 评估器驱动重 spawn 直到目标清除。若 `/goal` 也不可用,自循环:spawn → 检查输出 `<promise>COMPLETE</promise>` → 把上轮输出 append 后重 spawn(至多 max_iterations)。goal 只在叶子 subtask 层设置 — `/goal` 每 session 单槽,嵌套 goal 会覆盖外层。
71
+ 2. 用 CC-native subagent(Task / Agent 工具)以该 `prompt` + `model` spawn,然后用 harnessed 自己的完成闸门驱动交付:
72
+ - subagent 返回后,把它的最终输出写入文件,跑 `harnessed checkpoint complete plan-phase --result-file <path>` —— 该命令对声明的产物、TDD boundary、逐字 `<promise>COMPLETE</promise>` 三者 fail-closed。
73
+ - 若被拦下,跑 `harnessed checkpoint fail plan-phase --failing-tests <n>` 记录本次尝试;命中停机条件时它会打印 BUDGET-EXHAUSTED / NO-PROGRESS / BREAK-LOOP。
74
+ - **仅当**这三者都未触发时才允许重 spawn。任一触发即停:重新收敛子任务范围、修掉阻塞点,或上报用户。绝不越过停机指令继续重 spawn。
72
75
  3. 若输出含 `STATUS: NEEDS_CLARIFICATION` + 问题列表:STOP,用 AskUserQuestion 原样转达,把答案 append 进 spec,再重 spawn。
73
- 4. 命中 `<promise>COMPLETE</promise>`:Bash `harnessed checkpoint complete plan-phase --summary "<one-line>"`。evidence guard 在此运行(fail-CLOSED):若声明的 `artifacts_expected` 文件缺失会 exit 非零 —— 重 spawn 产出它再算 done。
76
+ 4. 命中 `<promise>COMPLETE</promise>`:把 subagent 最终输出写入文件,再 Bash `harnessed checkpoint complete plan-phase --result-file <path> --summary "<one-line>"`。fail-CLOSED —— 除非声明的 `artifacts_expected` 文件全部存在、TDD boundary 通过(证据非空 / 红绿两侧齐全 / 测试文件未被删除)、且结果含逐字 `<promise>COMPLETE</promise>`(或结构化 COMPLETE 状态),否则拦下。`--result <text>` 是内联变体;`--result-file` 优先且在 Windows 上引号安全。`--force` 记录可审计的覆盖(`evidence_status=overridden`),不是静默放行。
77
+ 5. 若 complete 闸门拦下:Bash `harnessed checkpoint fail plan-phase --failing-tests <n>` 记录本次尝试。命中停机条件时会打印 `BUDGET-EXHAUSTED` / `NO-PROGRESS` / `BREAK-LOOP`。**仅当**三者都未触发时才允许重 spawn;任一触发即 STOP —— 重新收敛子任务范围、修掉阻塞点,或上报用户。
74
78
 
75
- <!-- harnessed-generated:v4.9.3 -->
79
+ <!-- harnessed-generated:v4.12.0 -->
76
80
 
77
81
  ## 参考文档
78
82
 
@@ -10,14 +10,24 @@ schema_version: harnessed.workflow.v3
10
10
  Multi-source research workflow shipped with harnessed v2.0 (Stage ① Discuss);
11
11
  `workflow.yaml` schema bumped to `harnessed.workflow.v3` in Phase v3.0-3.4 W1.1
12
12
  (T3.4.W1.1 — D-09 L0 Discipline Substrate + D-05 tools_available cross-validate);
13
- phases content (01-fan-out + 02-synth) verbatim reused from v2 SHIPPED unchanged.
13
+ T2.3 split `01-fan-out` into 5 gated source lanes — each lane is now gated by one
14
+ `workflows/judgments/web-search-routing.yaml` trigger (those 5 triggers used to be runtime
15
+ orphans: zero gate ref, so the file was never loaded or evaluated). `02-synth` unchanged.
14
16
 
15
- ## Phases (2)
17
+ ## Phases (6)
16
18
 
17
- | # | Phase | Upstream | Capability | Model | Description |
18
- |---|-------|----------|-----------|-------|-------------|
19
- | 01 | `01-fan-out` | web-search | (route-by-subtask) | sonnet | 3 source fan-out (Tavily MCP / Exa MCP / ctx7 CLI per bundled web-search + context7 routing) |
20
- | 02 | `02-synth` | gsd | `gsd-discuss-phase` | opus | GSD discuss-phase aggregate + dedup + reconcile |
19
+ | # | Phase | Upstream | Capability | Model | Gate | Description |
20
+ |---|-------|----------|-----------|-------|------|-------------|
21
+ | 01 | `01-fan-out-tavily-keyword` | web-search | (route-by-subtask) | sonnet | `judgments.web-search-routing.tavily-mcp-default.fires` | 默认 lane — Tavily MCP 关键词 / 库 API / 新闻时效 / 生产 RAG |
22
+ | 02 | `01-fan-out-exa-descriptive` | web-search | (route-by-subtask) | sonnet | `judgments.web-search-routing.exa-mcp-descriptive-academic.fires` | Exa MCP 覆盖默认 — 描述式查询 / 学术论文 (需 `EXA_API_KEY`, 缺则落默认 lane) |
23
+ | 03 | `01-fan-out-tavily-crawl` | web-search | (route-by-subtask) | sonnet | `judgments.web-search-routing.tavily-crawl-map-site.fires` | Tavily 必用 — 抓整站 / 站点结构 (crawl / map), Exa 无对等工具 |
24
+ | 04 | `01-fan-out-ctx7-lib-docs` | ctx7 | (route-by-subtask) | sonnet | `judgments.web-search-routing.ctx7-lib-docs.fires` | ctx7 CLI — 库 / API / 框架 / SDK / CLI 工具文档 (prefer over web search) |
25
+ | 05 | `01-fan-out-webfetch-url` | web-search | (route-by-subtask) | haiku | `judgments.web-search-routing.webfetch-single-url.fires` | 永远规则 — 单次轻量查询 (一个明确 URL) 直接 WebFetch, 不走 MCP / CLI |
26
+ | 06 | `02-synth` | gsd | `gsd-discuss-phase` | opus | (无 gate — 无论命中哪条 lane 都要 aggregate) | GSD discuss-phase aggregate + dedup + reconcile |
27
+
28
+ Lanes are mutually exclusive (`subtask.search_type` is single-valued); the default
29
+ gateContext (`search_type == 'keyword'`) fires only the Tavily lane, which is behaviourally
30
+ identical to the pre-T2.3 unconditional single `01-fan-out`.
21
31
 
22
32
  ## Capability refs
23
33
 
@@ -52,8 +62,13 @@ Do NOT pipe to `harnessed run research` — that is the CI/headless path (in-pro
52
62
  that blocks the session inside Claude Code).
53
63
 
54
64
  1. Bash: `harnessed prompt research --task "$ARGUMENTS" --json` → parse `{prompt, max_iterations, model}`.
55
- 2. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` + `model`, wrapped in the ralph-loop plugin: `/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`. If the plugin is absent, use the native goal gate instead (Claude Code 2.1.139+ / Codex): `/goal "this subtask is delivered: the subagent's final output contains verbatim <promise>COMPLETE</promise>; or stop after <max_iterations> turns"` then spawn the subagent and let the goal evaluator drive re-spawns until it clears. If `/goal` is unavailable too, self-loop: spawn → check output for `<promise>COMPLETE</promise>` → re-spawn with prior output appended (up to max_iterations). Set the goal only at the leaf subtask level — `/goal` is single-slot per session and a nested goal overwrites the outer one. Delivery contract: use a BLOCKING Agent/Task call — only a blocking call returns the subagent's final text as your tool result. A named/background teammate's final message is DISCARDED by the platform; if you must run it that way, instruct the agent to write its findings to a file (and read it back) or SendMessage them to the main session — otherwise the COMPLETE promise and the findings never reach you.
65
+ 2. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` and `model`, then drive delivery with harnessed's own completion gate:
66
+ - on return, write the subagent's final output to a file and run `harnessed checkpoint complete research --result-file <path>` — it is fail-closed on the declared artifacts, the TDD boundary, and the verbatim `<promise>COMPLETE</promise>`.
67
+ - if it blocks, run `harnessed checkpoint fail research --failing-tests <n>` to record the attempt; it prints BUDGET-EXHAUSTED / NO-PROGRESS / BREAK-LOOP when a stop condition is reached.
68
+ - respawn ONLY while none of those three has fired. Any one of them means stop: re-scope the subtask, fix the blocker, or escalate to the user. Never respawn past a stop directive.
69
+ - delivery contract: use a BLOCKING Agent/Task call — only a blocking call returns the subagent's final text as your tool result. A named/background teammate's final message is DISCARDED by the platform; if you must run it that way, instruct the agent to write its findings to a file (and read it back) or SendMessage them to the main session — otherwise the COMPLETE promise and the findings never reach you.
56
70
  3. If the output contains `STATUS: NEEDS_CLARIFICATION` + a question list: STOP, relay them verbatim via AskUserQuestion, append the answers to the spec, then re-spawn the same sub.
57
- 4. On `<promise>COMPLETE</promise>`: Bash `harnessed checkpoint complete research --summary "<one-line>"`. The evidence guard runs here (fail-CLOSED): if a declared `artifacts_expected` file is missing it exits non-zero — re-spawn to produce it before treating the sub as done.
71
+ 4. On `<promise>COMPLETE</promise>`: write the subagent’s final output to a file, then Bash `harnessed checkpoint complete research --result-file <path> --summary "<one-line>"`. Fail-CLOSED — it blocks unless every declared `artifacts_expected` file exists, the TDD boundary passes (non-empty evidence / both the red and green sides present / the test file was not deleted), and the result carries a verbatim `<promise>COMPLETE</promise>` (or a structured COMPLETE status). `--result <text>` is the inline variant; `--result-file` wins and is quoting-safe on Windows. `--force` records an audited override (`evidence_status=overridden`) — it does not silently pass.
72
+ 5. If the complete gate blocked: Bash `harnessed checkpoint fail research --failing-tests <n>` to record the attempt. It prints `BUDGET-EXHAUSTED` / `NO-PROGRESS` / `BREAK-LOOP` once a stop condition is reached. Respawn ONLY while none of those three has fired; any one of them means STOP — re-scope the subtask, fix the blocker, or escalate to the user.
58
73
 
59
- <!-- harnessed-generated:v4.9.3 -->
74
+ <!-- harnessed-generated:v4.12.0 -->
@@ -10,14 +10,23 @@ schema_version: harnessed.workflow.v3
10
10
  harnessed v2.0 随附的多源调研工作流(Stage ① Discuss);
11
11
  `workflow.yaml` schema 在 Phase v3.0-3.4 W1.1 中 bump 至 `harnessed.workflow.v3`
12
12
  (T3.4.W1.1 — D-09 L0 Discipline Substrate + D-05 tools_available 交叉验证);
13
- phases 内容(01-fan-out + 02-synth)原样沿用 v2 SHIPPED,未做更改。
13
+ T2.3 把 `01-fan-out` 拆成 5 条 gated source lane —— 每条 lane 各由
14
+ `workflows/judgments/web-search-routing.yaml` 的一个 trigger gate(那 5 个 trigger 此前是
15
+ 运行时孤儿:零 gate ref,文件永不加载求值)。`02-synth` 未变。
14
16
 
15
- ## 阶段 (2)
17
+ ## 阶段 (6)
16
18
 
17
- | # | Phase | Upstream | Capability | Model | Description |
18
- |---|-------|----------|-----------|-------|-------------|
19
- | 01 | `01-fan-out` | web-search | (route-by-subtask) | sonnet | 3 路并发调研 (Tavily MCP / Exa MCP / ctx7 CLI,遵循内置 web-search + context7 路由规则) |
20
- | 02 | `02-synth` | gsd | `gsd-discuss-phase` | opus | GSD discuss-phase 聚合 + 去重 + 对账 |
19
+ | # | Phase | Upstream | Capability | Model | Gate | Description |
20
+ |---|-------|----------|-----------|-------|------|-------------|
21
+ | 01 | `01-fan-out-tavily-keyword` | web-search | (route-by-subtask) | sonnet | `judgments.web-search-routing.tavily-mcp-default.fires` | 默认 lane —— Tavily MCP 关键词 / 库 API / 新闻时效 / 生产 RAG |
22
+ | 02 | `01-fan-out-exa-descriptive` | web-search | (route-by-subtask) | sonnet | `judgments.web-search-routing.exa-mcp-descriptive-academic.fires` | Exa MCP 覆盖默认 —— 描述式查询 / 学术论文(需 `EXA_API_KEY`,缺则落默认 lane) |
23
+ | 03 | `01-fan-out-tavily-crawl` | web-search | (route-by-subtask) | sonnet | `judgments.web-search-routing.tavily-crawl-map-site.fires` | Tavily 必用 —— 抓整站 / 站点结构 (crawl / map),Exa 无对等工具 |
24
+ | 04 | `01-fan-out-ctx7-lib-docs` | ctx7 | (route-by-subtask) | sonnet | `judgments.web-search-routing.ctx7-lib-docs.fires` | ctx7 CLI —— 库 / API / 框架 / SDK / CLI 工具文档(优先于 web search) |
25
+ | 05 | `01-fan-out-webfetch-url` | web-search | (route-by-subtask) | haiku | `judgments.web-search-routing.webfetch-single-url.fires` | 永远规则 —— 单次轻量查询(一个明确 URL)直接 WebFetch,不走 MCP / CLI |
26
+ | 06 | `02-synth` | gsd | `gsd-discuss-phase` | opus | (无 gate —— 无论命中哪条 lane 都要 aggregate) | GSD discuss-phase 聚合 + 去重 + 对账 |
27
+
28
+ lane 之间互斥(`subtask.search_type` 单值);默认 gateContext(`search_type == 'keyword'`)
29
+ 只 fire Tavily lane,与 T2.3 之前"`01-fan-out` 无条件跑一次"行为等价。
21
30
 
22
31
  ## Capability refs
23
32
 
@@ -51,8 +60,13 @@ CC-native Task / Agent 工具 spawn subagent(保持 session 响应 + 让澄清 r
51
60
  Code 内部会阻塞 session)。
52
61
 
53
62
  1. Bash: `harnessed prompt research --task "$ARGUMENTS" --json` → 解析 `{prompt, max_iterations, model}`。
54
- 2. 用 CC-native subagent(Task / Agent 工具)以该 `prompt` + `model` spawn,用 ralph-loop plugin 包裹:`/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`。若 plugin 未装,改用原生 goal gate(Claude Code 2.1.139+ / Codex):`/goal "this subtask is delivered: the subagent's final output contains verbatim <promise>COMPLETE</promise>; or stop after <max_iterations> turns"`,随后 spawn subagent,由 goal 评估器驱动重 spawn 直到目标清除。若 `/goal` 也不可用,自循环:spawn → 检查输出 `<promise>COMPLETE</promise>` → 把上轮输出 append 后重 spawn(至多 max_iterations)。goal 只在叶子 subtask 层设置 — `/goal` 每 session 单槽,嵌套 goal 会覆盖外层。交付契约:必须用**阻塞式** Agent/Task 调用 —— 只有阻塞调用会把 subagent 的最终文本作为 tool result 返回给你。named/background teammate 的最终消息会被平台**丢弃**;若必须那样跑,要求 agent 把发现写入文件(你再读回)或 SendMessage 回主 session —— 否则 COMPLETE promise 和研究发现永远到不了你手里。
63
+ 2. 用 CC-native subagent(Task / Agent 工具)以该 `prompt` + `model` spawn,然后用 harnessed 自己的完成闸门驱动交付:
64
+ - subagent 返回后,把它的最终输出写入文件,跑 `harnessed checkpoint complete research --result-file <path>` —— 该命令对声明的产物、TDD boundary、逐字 `<promise>COMPLETE</promise>` 三者 fail-closed。
65
+ - 若被拦下,跑 `harnessed checkpoint fail research --failing-tests <n>` 记录本次尝试;命中停机条件时它会打印 BUDGET-EXHAUSTED / NO-PROGRESS / BREAK-LOOP。
66
+ - **仅当**这三者都未触发时才允许重 spawn。任一触发即停:重新收敛子任务范围、修掉阻塞点,或上报用户。绝不越过停机指令继续重 spawn。
67
+ - 交付契约:必须用**阻塞式** Agent/Task 调用 —— 只有阻塞调用会把 subagent 的最终文本作为 tool result 返回给你。named/background teammate 的最终消息会被平台**丢弃**;若必须那样跑,要求 agent 把发现写入文件(你再读回)或 SendMessage 回主 session —— 否则 COMPLETE promise 和研究发现永远到不了你手里。
55
68
  3. 若输出含 `STATUS: NEEDS_CLARIFICATION` + 问题列表:STOP,用 AskUserQuestion 原样转达,把答案 append 进 spec,再重 spawn。
56
- 4. 命中 `<promise>COMPLETE</promise>`:Bash `harnessed checkpoint complete research --summary "<one-line>"`。evidence guard 在此运行(fail-CLOSED):若声明的 `artifacts_expected` 文件缺失会 exit 非零 —— 重 spawn 产出它再算 done。
69
+ 4. 命中 `<promise>COMPLETE</promise>`:把 subagent 最终输出写入文件,再 Bash `harnessed checkpoint complete research --result-file <path> --summary "<one-line>"`。fail-CLOSED —— 除非声明的 `artifacts_expected` 文件全部存在、TDD boundary 通过(证据非空 / 红绿两侧齐全 / 测试文件未被删除)、且结果含逐字 `<promise>COMPLETE</promise>`(或结构化 COMPLETE 状态),否则拦下。`--result <text>` 是内联变体;`--result-file` 优先且在 Windows 上引号安全。`--force` 记录可审计的覆盖(`evidence_status=overridden`),不是静默放行。
70
+ 5. 若 complete 闸门拦下:Bash `harnessed checkpoint fail research --failing-tests <n>` 记录本次尝试。命中停机条件时会打印 `BUDGET-EXHAUSTED` / `NO-PROGRESS` / `BREAK-LOOP`。**仅当**三者都未触发时才允许重 spawn;任一触发即 STOP —— 重新收敛子任务范围、修掉阻塞点,或上报用户。
57
71
 
58
- <!-- harnessed-generated:v4.9.3 -->
72
+ <!-- harnessed-generated:v4.12.0 -->