harnessed 4.38.0 → 4.40.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 (45) hide show
  1. package/dist/cli.mjs +249 -15
  2. package/dist/cli.mjs.map +1 -1
  3. package/dist/index.mjs +1 -1
  4. package/dist/index.mjs.map +1 -1
  5. package/manifests/SCHEMA.md +2 -2
  6. package/manifests/optional/chrome-devtools-mcp.yaml +2 -2
  7. package/manifests/optional/codegraph.yaml +2 -2
  8. package/manifests/optional/ecc.yaml +60 -17
  9. package/manifests/skill-packs/design-taste-frontend.yaml +2 -2
  10. package/manifests/skill-packs/gsd.yaml +2 -2
  11. package/manifests/skill-packs/gstack.yaml +2 -2
  12. package/manifests/skill-packs/mattpocock-skills.yaml +2 -2
  13. package/manifests/skill-packs/planning-with-files.yaml +2 -2
  14. package/manifests/skill-packs/ui-ux-pro-max.yaml +21 -7
  15. package/manifests/tools/ctx7.yaml +7 -3
  16. package/manifests/tools/exa-mcp.yaml +2 -2
  17. package/manifests/tools/playwright-test.yaml +10 -4
  18. package/manifests/tools/superpowers.yaml +2 -2
  19. package/manifests/tools/tavily-mcp.yaml +2 -2
  20. package/package.json +1 -1
  21. package/workflows/capabilities.yaml +110 -110
  22. package/workflows/defaults.yaml +17 -7
  23. package/workflows/discuss/phase/workflow.yaml +0 -1
  24. package/workflows/discuss/strategic/workflow.yaml +0 -2
  25. package/workflows/discuss/subtask/workflow.yaml +0 -1
  26. package/workflows/judgments/stage-routing.yaml +10 -0
  27. package/workflows/judgments/subtask-gate.yaml +24 -1
  28. package/workflows/plan/architecture/workflow.yaml +0 -1
  29. package/workflows/plan/phase/workflow.yaml +0 -1
  30. package/workflows/research/workflow.yaml +0 -6
  31. package/workflows/retro/workflow.yaml +0 -1
  32. package/workflows/task/clarify/SKILL.md +4 -2
  33. package/workflows/task/clarify/SKILL.zh-Hans.md +4 -3
  34. package/workflows/task/clarify/workflow.yaml +0 -1
  35. package/workflows/task/code/workflow.yaml +0 -1
  36. package/workflows/task/deliver/workflow.yaml +0 -1
  37. package/workflows/task/test/workflow.yaml +0 -1
  38. package/workflows/verify/auto/workflow.yaml +10 -1
  39. package/workflows/verify/code-review/workflow.yaml +0 -1
  40. package/workflows/verify/paranoid/workflow.yaml +0 -1
  41. package/workflows/verify/progress/workflow.yaml +0 -1
  42. package/workflows/verify/second-opinion/SKILL.md +89 -0
  43. package/workflows/verify/second-opinion/SKILL.zh-Hans.md +88 -0
  44. package/workflows/verify/second-opinion/workflow.yaml +50 -0
  45. package/workflows/verify/simplify/workflow.yaml +0 -1
@@ -17,7 +17,13 @@ schema_version: harnessed.defaults.v1
17
17
  ralph_max_iterations:
18
18
  # v3 standalone (research v3 schema bump + retro NEW per Phase 3.4 W1.1+W1.2)
19
19
  research:
20
- 01-fan-out: 3
20
+ # 5 个 fan-out phase 共用同一预算。曾写作单个 `01-fan-out` 前缀键,但查表按
21
+ # phase id 精确匹配 (Phase 54 T0),前缀键匹配不到任何 phase → 全落默认 20。
22
+ 01-fan-out-tavily-keyword: 3
23
+ 01-fan-out-exa-descriptive: 3
24
+ 01-fan-out-tavily-crawl: 3
25
+ 01-fan-out-ctx7-lib-docs: 3
26
+ 01-fan-out-webfetch-url: 3
21
27
  02-synth: 3
22
28
 
23
29
  retro:
@@ -30,7 +36,7 @@ ralph_max_iterations:
30
36
  02-plan-ceo-review: 3
31
37
 
32
38
  discuss-phase:
33
- 01-gsd-discuss-phase: 5
39
+ 01-gsd-discuss: 5
34
40
 
35
41
  discuss-subtask:
36
42
  01-brainstorm: 5
@@ -40,12 +46,12 @@ ralph_max_iterations:
40
46
  01-plan-eng-review: 3
41
47
 
42
48
  plan-phase:
43
- 01-gsd-plan-phase: 5
49
+ 01-gsd-plan: 5
44
50
  02-persist: 5
45
51
 
46
52
  # v3 sub-workflow — task stage (4 sub per Phase 3.4 W0.6-W0.9)
47
53
  task-clarify:
48
- 01-clarify: 5
54
+ 01-brainstorm: 5
49
55
 
50
56
  task-code:
51
57
  01-code: 20
@@ -60,13 +66,13 @@ ralph_max_iterations:
60
66
  verify-progress:
61
67
  01-gsd-verify-work: 3
62
68
  02-gsd-progress: 3
63
- 03-persist: 3
69
+ 03-progress-update: 3
64
70
 
65
71
  verify-code-review:
66
72
  01-code-review: 5
67
73
 
68
74
  verify-paranoid:
69
- 01-gstack-review: 3
75
+ 01-review: 3
70
76
 
71
77
  verify-qa:
72
78
  01-qa: 3
@@ -77,8 +83,12 @@ ralph_max_iterations:
77
83
  verify-design:
78
84
  01-design-review: 3
79
85
 
86
+ verify-second-opinion:
87
+ # 第二意见跑一次就该有结论;循环重跑只会稀释它的独立性。
88
+ 01-second-opinion: 2
89
+
80
90
  verify-simplify:
81
- 01-code-simplifier: 5
91
+ 01-simplify: 5
82
92
 
83
93
  verify-multispec:
84
94
  01-team-create: 1
@@ -24,7 +24,6 @@ phases:
24
24
  capability: '{{ capabilities.gsd-discuss-phase.cmd }}'
25
25
  model: sonnet
26
26
  gate: judgments.phase-gate.gsd-discuss-phase.fires
27
- max_iterations: '{{ defaults.ralph_max_iterations.discuss-phase.01-gsd-discuss }}'
28
27
 
29
28
  - id: 02-persist
30
29
  name: planning-with-files findings.md + knowledge.md (phase decision 持久化)
@@ -27,7 +27,6 @@ phases:
27
27
  capability: '{{ capabilities.gstack-office-hours.cmd }}'
28
28
  model: opus
29
29
  gate: judgments.strategic-gate.office-hours.fires
30
- max_iterations: '{{ defaults.ralph_max_iterations.discuss-strategic.01-office-hours }}'
31
30
 
32
31
  - id: 02-plan-ceo-review
33
32
  name: gstack-plan-ceo-review (CEO 视角 商业价值 + 10-star 潜力 + scope)
@@ -35,7 +34,6 @@ phases:
35
34
  capability: '{{ capabilities.gstack-plan-ceo-review.cmd }}'
36
35
  model: opus
37
36
  gate: judgments.strategic-gate.plan-ceo-review.fires
38
- max_iterations: '{{ defaults.ralph_max_iterations.discuss-strategic.02-plan-ceo-review }}'
39
37
 
40
38
  - id: 03-persist
41
39
  name: planning-with-files findings.md (战略层决策 + 理由持久化)
@@ -30,4 +30,3 @@ phases:
30
30
  tool: grill-with-docs
31
31
  - if: 'phase.spec_ambiguous == true and phase.no_docs == true'
32
32
  tool: grill-me
33
- max_iterations: '{{ defaults.ralph_max_iterations.discuss-subtask.01-brainstorm }}'
@@ -55,6 +55,16 @@ triggers:
55
55
  invokes:
56
56
  - capability: gstack-review
57
57
 
58
+ verify-second-opinion-orchestration:
59
+ description: |
60
+ /verify master → /verify-second-opinion fire 当本次改动触及编排契约本身。
61
+ 判据由 `harnessed facts` 从 `git diff --name-only <last release tag>` 机械派生
62
+ (root-flat bare identifier `requires_second_opinion`),不是交给模型的判断题。
63
+ 算不出来时取 false 并显式报出原因 —— 不乱 fire,且不静默。
64
+ fires_when: "phase.stage == 'verify' and requires_second_opinion == true"
65
+ invokes:
66
+ - capability: codex
67
+
58
68
  verify-qa-ui:
59
69
  description: /verify master → /verify-qa fire 当 has_ui_changes。
60
70
  fires_when: "phase.stage == 'verify' and phase.has_ui_changes == true"
@@ -12,6 +12,29 @@ triggers:
12
12
  或涉及核心算法 / 数据结构 / API contract 设计,
13
13
  或无现成 pattern 可抄, 或错误成本高 (数据迁移 / 并发 / 性能关键路径) 时激活。
14
14
  fires_when: "subtask.approaches >= 2 or subtask.core_algorithm == true or subtask.has_api_contract == true or subtask.error_cost == 'high'"
15
- skips_when: "subtask.type in ['crud', 'standard_lib_call'] or subtask.lines < 20"
15
+ # Phase 58 — the skip is now CONJOINED with "and there is no design decision
16
+ # here". It used to be an unconditional veto, and that veto overrode every
17
+ # risk signal: measured on the real engine, a subtask with approaches=3,
18
+ # core_algorithm=true, has_api_contract=true, error_cost='high' was still
19
+ # vetoed at lines=15 ("sub vetoed despite its gate firing"), and fired at
20
+ # lines=25. Ten lines flipped a governance gate.
21
+ #
22
+ # The defect was encoding the SYMPTOM instead of the condition. ~/.claude
23
+ # CLAUDE.md reads "常规 CRUD" and "单一明显实现(< 20 行 / 一个文件)" — small
24
+ # size is a MODIFIER on "single obvious implementation", not the criterion.
25
+ # When approaches >= 2 the implementation is by definition not obvious, so the
26
+ # skip must not apply. Upstream superpowers 6.3.0 draws the same distinction
27
+ # on its own axis (spike / bounded / architectural measures whether the flow
28
+ # already exists in this repo, never the diff size).
29
+ #
30
+ # The seeded defaults are deliberately NOT withdrawn to match: under them
31
+ # `subtask.approaches < 2` and `subtask.has_api_contract == false` are false,
32
+ # so an unmeasured subtask cannot skip — unknown keeps firing the gate, which
33
+ # is the safe side. Withdrawing both pins as well would have turned every
34
+ # fires_when arm false and deleted the gate by default (ADR-0038).
35
+ # `error_cost in ['low','medium']` rather than `!= 'high'`: the enum is
36
+ # exactly low|medium|high and `in` is the operator already proven in these
37
+ # files.
38
+ skips_when: "(subtask.type in ['crud', 'standard_lib_call'] or subtask.lines < 20) and subtask.approaches < 2 and subtask.core_algorithm == false and subtask.has_api_contract == false and subtask.error_cost in ['low', 'medium']"
16
39
  invokes:
17
40
  - capability: superpowers-brainstorming
@@ -31,4 +31,3 @@ phases:
31
31
  capability: '{{ capabilities.plan-eng-review.cmd }}'
32
32
  model: opus
33
33
  gate: judgments.stage-routing.plan-architecture-delegate.fires
34
- max_iterations: '{{ defaults.ralph_max_iterations.plan-architecture.01-plan-eng-review }}'
@@ -26,7 +26,6 @@ phases:
26
26
  upstream: gsd
27
27
  capability: '{{ capabilities.gsd-plan-phase.cmd }}'
28
28
  model: sonnet
29
- max_iterations: '{{ defaults.ralph_max_iterations.plan-phase.01-gsd-plan }}'
30
29
 
31
30
  - id: 02-persist
32
31
  name: planning-with-files /plan (task_plan.md + progress.md 持久化)
@@ -49,7 +49,6 @@ phases:
49
49
  upstream: web-search
50
50
  model: sonnet
51
51
  gate: judgments.web-search-routing.tavily-mcp-default.fires
52
- max_iterations: '{{ defaults.ralph_max_iterations.research.01-fan-out }}'
53
52
  parallelism: judgments.parallelism-gate.subagent-default.fires
54
53
 
55
54
  # lane 2 — Exa MCP 覆盖默认: 描述式查询 / 学术论文 (需 EXA_API_KEY, 缺则落 lane 1)
@@ -57,28 +56,24 @@ phases:
57
56
  upstream: web-search
58
57
  model: sonnet
59
58
  gate: judgments.web-search-routing.exa-mcp-descriptive-academic.fires
60
- max_iterations: '{{ defaults.ralph_max_iterations.research.01-fan-out }}'
61
59
 
62
60
  # lane 3 — Tavily 必用: 抓整站 / 站点结构 (crawl / map), Exa 无对等工具
63
61
  - id: 01-fan-out-tavily-crawl
64
62
  upstream: web-search
65
63
  model: sonnet
66
64
  gate: judgments.web-search-routing.tavily-crawl-map-site.fires
67
- max_iterations: '{{ defaults.ralph_max_iterations.research.01-fan-out }}'
68
65
 
69
66
  # lane 4 — ctx7 CLI: 库 / API / 框架 / SDK / CLI 工具文档 (prefer over web search)
70
67
  - id: 01-fan-out-ctx7-lib-docs
71
68
  upstream: ctx7
72
69
  model: sonnet
73
70
  gate: judgments.web-search-routing.ctx7-lib-docs.fires
74
- max_iterations: '{{ defaults.ralph_max_iterations.research.01-fan-out }}'
75
71
 
76
72
  # lane 5 (永远规则) — 单次轻量查询 (一个明确 URL) 直接 WebFetch, 不走 MCP / CLI
77
73
  - id: 01-fan-out-webfetch-url
78
74
  upstream: web-search
79
75
  model: haiku
80
76
  gate: judgments.web-search-routing.webfetch-single-url.fires
81
- max_iterations: '{{ defaults.ralph_max_iterations.research.01-fan-out }}'
82
77
 
83
78
  # 02-synth: GSD discuss synth aggregate — 多源结果 dedup + reconcile + GSD discuss-phase format
84
79
  # (无 gate — 无论命中哪条 lane 都要 aggregate)
@@ -86,4 +81,3 @@ phases:
86
81
  upstream: gsd
87
82
  capability: '{{ capabilities.gsd-discuss-phase.cmd }}'
88
83
  model: opus
89
- max_iterations: '{{ defaults.ralph_max_iterations.research.02-synth }}'
@@ -28,7 +28,6 @@ phases:
28
28
  upstream: gstack
29
29
  capability: '{{ capabilities.retro-gstack.cmd }}'
30
30
  model: opus
31
- max_iterations: '{{ defaults.ralph_max_iterations.retro.01-retro }}'
32
31
 
33
32
  - id: 02-persist
34
33
  name: planning-with-files RETROSPECTIVE.md (经验教训持久化)
@@ -37,8 +37,10 @@ spawns each phase as a sub-agent via `@anthropic-ai/claude-agent-sdk` 0.3.142+.
37
37
 
38
38
  task-clarify is **NOT** a one-shot 阶段 — execute-task master orchestrator delegates
39
39
  to task-clarify **每个 subtask 入口走一次** evaluate gate (subtask-gate.brainstorming
40
- .fires) 是否激活。Skip path (subtask.type in ['crud','standard_lib_call'] OR
41
- subtask.lines < 20) bypasses brainstorming entirely per CLAUDE.md "拿不准 → 倾向跳过"。
40
+ .fires) 是否激活。Skip path — small OR routine **AND** no design decision
41
+ (approaches < 2, no core algorithm, no API contract, error_cost not 'high') —
42
+ bypasses brainstorming per CLAUDE.md "拿不准 → 倾向跳过"。Phase 58: size alone no
43
+ longer vetoes; "< 20 行" is a modifier on "单一明显实现", not the criterion.
42
44
 
43
45
  ## Discipline Substrate (L0 always-on)
44
46
 
@@ -35,9 +35,10 @@ Discipline Substrate + D-05 conditional `invokes_tools` + D-04 gate ref)。
35
35
  ## Per-subtask 重复 invoke 模式
36
36
 
37
37
  task-clarify **不是**一次性阶段——execute-task 主控编排器对**每个 subtask 入口**委托一次
38
- task-clarify,评估 gate(subtask-gate.brainstorming.fires)是否激活。跳过路径
39
- (subtask.type in ['crud','standard_lib_call'] OR subtask.lines < 20)完全绕过
40
- brainstorming,遵循 CLAUDE.md「拿不准 → 倾向跳过」原则。
38
+ task-clarify,评估 gate(subtask-gate.brainstorming.fires)是否激活。跳过路径 ——
39
+ 小或常规 **且** 无设计决策(approaches < 2、非核心算法、无 API contract、
40
+ error_cost 不为 'high')—— 绕过 brainstorming,遵循 CLAUDE.md「拿不准 → 倾向跳过」
41
+ 原则。Phase 58:体量本身不再单独否决,「< 20 行」是「单一明显实现」的修饰语而非判据。
41
42
 
42
43
  ## Discipline Substrate (L0 always-on)
43
44
 
@@ -36,4 +36,3 @@ phases:
36
36
  invokes_tools:
37
37
  - if: 'phase.spec_ambiguous == true'
38
38
  tool: grill-with-docs
39
- max_iterations: '{{ defaults.ralph_max_iterations.task-clarify.01-brainstorm }}'
@@ -35,7 +35,6 @@ phases:
35
35
  name: code (karpathy 心法 always-on + mattpocock conditional route)
36
36
  upstream: karpathy
37
37
  model: sonnet
38
- max_iterations: '{{ defaults.ralph_max_iterations.task-code.01-code }}'
39
38
  invokes_tools:
40
39
  - if: 'phase.architecture_health_audit == true'
41
40
  tool: improve-codebase-architecture
@@ -69,7 +69,6 @@ phases:
69
69
  model: haiku
70
70
  args:
71
71
  completion_promise: COMPLETE
72
- max_iterations: '{{ defaults.ralph_max_iterations.task-deliver.01-deliver }}'
73
72
  parallelism: judgments.parallelism-gate.completion-gate-wrapper.fires
74
73
  on:
75
74
  - if: 'subtask.lines >= 20 and subtask.type != "single_command_query"'
@@ -40,7 +40,6 @@ phases:
40
40
  invokes_tools:
41
41
  - if: 'test_fail == true'
42
42
  tool: diagnose
43
- max_iterations: '{{ defaults.ralph_max_iterations.task-test.01-test }}'
44
43
  # v3.8.0 P1 — TDD core-logic phase, opts into full 3-RULES inject (escalation
45
44
  # may fire when test failures trigger /diagnosing-bugs handoff or subagent context overflow).
46
45
  injects_rules: [escalation, transparent-skip, agent-teams-prevention]
@@ -22,7 +22,8 @@
22
22
  #
23
23
  # Master invariant (per WorkflowSchemaV3 runtime + check-workflow-schema.mjs K9):
24
24
  # - phases 缺省 (master only has delegates_to[])
25
- # - 7 delegates_to: serial 2 (progress order 1 + simplify order 99) + parallel 5
25
+ # - 11 delegates_to: serial 3 (progress order 1 + second-opinion order 90 +
26
+ # simplify order 99) + parallel 8
26
27
  # - serial mode 必带 explicit order (K9 invariant T3.3.W0.10)
27
28
  # - parallel mode 无 order field 需求
28
29
 
@@ -78,6 +79,14 @@ delegates_to:
78
79
  - sub: multispec
79
80
  gate: judgments.stage-routing.verify-multispec-critical-release.fires
80
81
  mode: parallel
82
+ # Phase 54 T2 — 条件性交付要求 = 条件性 fire 的 sub。判据由 harnessed facts 机械
83
+ # 派生 (git diff <last release tag> ∩ ORCHESTRATION SURFACE);fire 了就必须交
84
+ # second-opinion.md,evidence guard 已是 fail-closed。order 90:在 code-review /
85
+ # paranoid 之后 (它也审这些的产出),在 simplify (99) 之前。
86
+ - sub: second-opinion
87
+ gate: judgments.stage-routing.verify-second-opinion-orchestration.fires
88
+ mode: serial
89
+ order: 90
81
90
  - sub: simplify
82
91
  mode: serial
83
92
  order: 99
@@ -27,7 +27,6 @@ phases:
27
27
  capability: '{{ capabilities.code-review.cmd }}'
28
28
  model: sonnet
29
29
  parallelism: judgments.parallelism-gate.subagent-default.fires
30
- max_iterations: '{{ defaults.ralph_max_iterations.verify-code-review.01-code-review }}'
31
30
  # D2-followup (ADR-0033): declare report artifact so the evidence guard is real
32
31
  # (verified, not none_declared) — proves the multi-agent code-review actually ran.
33
32
  artifacts_expected: [code-review-report.md]
@@ -26,7 +26,6 @@ phases:
26
26
  capability: '{{ capabilities.gstack-review.cmd }}'
27
27
  model: opus
28
28
  gate: judgments.stage-routing.verify-paranoid-critical.fires
29
- max_iterations: '{{ defaults.ralph_max_iterations.verify-paranoid.01-review }}'
30
29
  # D2-followup (ADR-0033): declare report artifact so the evidence guard is real
31
30
  # (verified, not none_declared) — proves the Paranoid Staff Engineer review actually ran.
32
31
  artifacts_expected: [paranoid-review-report.md]
@@ -25,7 +25,6 @@ phases:
25
25
  upstream: gsd
26
26
  capability: '{{ capabilities.gsd-verify-work.cmd }}'
27
27
  model: sonnet
28
- max_iterations: '{{ defaults.ralph_max_iterations.verify-progress.01-gsd-verify-work }}'
29
28
 
30
29
  - id: 02-gsd-progress
31
30
  name: gsd-progress (状态同步 — ROADMAP/STATE/REQUIREMENTS 更新)
@@ -0,0 +1,89 @@
1
+ ---
2
+ name: verify-second-opinion
3
+ description: |
4
+ Stage ④ verify sub-workflow — 跨模型第二意见 (cross-AI peer review), fired only when this
5
+ release-in-progress touched the ORCHESTRATION SURFACE.
6
+ schema_version: harnessed.workflow.v3 with disciplines_applied (6 default) + tools_available
7
+ (codex) + 1 phase (gate ref requires_second_opinion, mechanically derived).
8
+ Triggered by slash command
9
+ `/verify-second-opinion` after `harnessed setup`.
10
+ trigger_phrases:
11
+ - "verify second opinion"
12
+ - "cross model review"
13
+ - "第二意见"
14
+ - "跨模型审查"
15
+ - "跑 verify-second-opinion"
16
+ ---
17
+
18
+ # verify-second-opinion workflow (v3)
19
+
20
+ ## Overview
21
+
22
+ 1-phase sub-workflow — 编排契约改动时的跨模型第二意见 (Phase 54 T2)。
23
+
24
+ | phase | id | upstream | model | capability | gate |
25
+ | ----- | -- | -------- | ----- | ---------- | ---- |
26
+ | 1 | `01-second-opinion` | gstack | sonnet | `{{ capabilities.codex.cmd }}` | `judgments.stage-routing.verify-second-opinion-orchestration.fires` |
27
+
28
+ 判据不是交给模型的判断题。`harnessed facts` 把 `git diff --name-only <last release tag>`
29
+ 与 ORCHESTRATION SURFACE (judgments / capabilities / 事实 schema / resolver / exprBuilder /
30
+ ledger / disciplines / 任一 workflows SKILL.md) 求交集,机械得出 `requires_second_opinion`。
31
+
32
+ 基准是**上一个 release tag**,不是 `merge-base origin/main` —— 后者在 commit-即-push-main
33
+ 的纪律下塌缩成 HEAD,只看得见未提交改动,会漏掉多-commit milestone 的早期 commit。
34
+
35
+ 算不出来 (无 tag / 无 git / diff 失败) 时取 `false`,并在每轮 `<workflow-state>` 断点打出
36
+ `SECOND-OPINION: 判据不可用(<原因>)`。不乱 fire,且不静默。
37
+
38
+ ## Capability refs
39
+
40
+ Sister `workflows/capabilities.yaml` entries:
41
+ - `codex` — 第二意见 / cross-AI peer review via codex (impl: gstack, cmd: /codex)
42
+
43
+ ## Gate ref
44
+
45
+ Sister `workflows/judgments/stage-routing.yaml`:
46
+ - `verify-second-opinion-orchestration.fires` — `phase.stage == 'verify' and requires_second_opinion == true`
47
+
48
+ ## Routing rules
49
+
50
+ - ✅ **触发**: 本次改动触及编排契约本身 (judgments / capabilities.yaml / phaseFactContext /
51
+ facts.ts / judgmentResolver / exprBuilder / ledger.ts / disciplines / 任一 SKILL.md)
52
+ - ❌ **跳过**: 纯 installer / 文档 / 测试 / 依赖 bump —— 改这些不会改变引擎的决策方式
53
+
54
+ **交付物即证据。** 本 sub fire 了就必须交 `second-opinion.md`;不交则 `checkpoint complete`
55
+ fail-closed 阻断,`--force` 在 ledger 记 `evidence_status: overridden`。跳过因此是台账上
56
+ 一行,不是隐形的。
57
+
58
+ ## How to invoke
59
+
60
+ !`harnessed checkpoint intent verify-second-opinion`
61
+
62
+ > The banner above (when present) means this invocation is REGISTERED with the engine (an intent marker) — not yet compliant: the steps below (prompt → spawn → checkpoint complete) resolve it, and a per-turn `<workflow-intent>` reminder persists until they run.
63
+
64
+ The numbered sequence below **is** the state machine — execute it with Bash. Do NOT improvise
65
+ an equivalent flow from the Overview above: freelancing bypasses the engine (no ledger, no
66
+ evidence guard). harnessed gives you the spawn-ready prompt; YOU spawn the subagent with a
67
+ CC-native Task / Agent tool (keeps the session responsive + lets clarification round-trips reach the user).
68
+
69
+ Do NOT pipe to `harnessed run verify-second-opinion` — that is the CI/headless path (in-process SDK spawn
70
+ that blocks the session inside Claude Code).
71
+
72
+ 1. Bash: `harnessed prompt verify-second-opinion --task "$ARGUMENTS" --json` → parse `{prompt, max_iterations, model}`.
73
+ 2. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` and `model`, then drive delivery with harnessed's own completion gate:
74
+ - on return, write the subagent's final output to a file and run `harnessed checkpoint complete verify-second-opinion --result-file <path>` — it is fail-closed on the declared artifacts, the TDD boundary, and the verbatim `<promise>COMPLETE</promise>`.
75
+ - if it blocks, run `harnessed checkpoint fail verify-second-opinion --failing-tests <n>` to record the attempt; it prints BUDGET-EXHAUSTED / NO-PROGRESS / BREAK-LOOP when a stop condition is reached.
76
+ - 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.
77
+ 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.
78
+ 4. On `<promise>COMPLETE</promise>`: write the subagent’s final output to a file, then Bash `harnessed checkpoint complete verify-second-opinion --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.
79
+ 5. If the complete gate blocked: Bash `harnessed checkpoint fail verify-second-opinion --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.
80
+
81
+ <!-- harnessed-generated:v4.12.0 -->
82
+
83
+ ## References
84
+
85
+ - Phase 54 SPEC — .planning/phases/54-declaration-evaluation-parity/SPEC.md
86
+ - workflows/capabilities.yaml — codex
87
+ - workflows/judgments/stage-routing.yaml — verify-second-opinion-orchestration trigger
88
+ - workflows/defaults.yaml — ralph_max_iterations.verify-second-opinion.*
89
+ - src/cli/facts.ts — deriveSecondOpinion / ORCHESTRATION_SURFACE
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: verify-second-opinion
3
+ description: |
4
+ Stage ④ verify 子工作流 — 跨模型第二意见 (cross-AI peer review),仅在本次发版触及
5
+ 编排契约面时触发。
6
+ schema_version: harnessed.workflow.v3,含 disciplines_applied (6 默认) + tools_available
7
+ (codex) + 1 phase (gate ref requires_second_opinion,机械派生)。
8
+ 斜杠命令
9
+ `/verify-second-opinion`(`harnessed setup` 之后可用)。
10
+ trigger_phrases:
11
+ - "verify second opinion"
12
+ - "cross model review"
13
+ - "第二意见"
14
+ - "跨模型审查"
15
+ - "跑 verify-second-opinion"
16
+ ---
17
+
18
+ # verify-second-opinion workflow (v3)
19
+
20
+ ## 概览
21
+
22
+ 单 phase 子工作流 — 编排契约改动时的跨模型第二意见 (Phase 54 T2)。
23
+
24
+ | phase | id | upstream | model | capability | gate |
25
+ | ----- | -- | -------- | ----- | ---------- | ---- |
26
+ | 1 | `01-second-opinion` | gstack | sonnet | `{{ capabilities.codex.cmd }}` | `judgments.stage-routing.verify-second-opinion-orchestration.fires` |
27
+
28
+ 判据不是交给模型的判断题。`harnessed facts` 把 `git diff --name-only <last release tag>`
29
+ 与 ORCHESTRATION SURFACE (judgments / capabilities / 事实 schema / resolver / exprBuilder /
30
+ ledger / disciplines / 任一 workflows SKILL.md) 求交集,机械得出 `requires_second_opinion`。
31
+
32
+ 基准是**上一个 release tag**,不是 `merge-base origin/main` —— 后者在 commit-即-push-main
33
+ 的纪律下塌缩成 HEAD,只看得见未提交改动,会漏掉多-commit milestone 的早期 commit。
34
+
35
+ 算不出来 (无 tag / 无 git / diff 失败) 时取 `false`,并在每轮 `<workflow-state>` 断点打出
36
+ `SECOND-OPINION: 判据不可用(<原因>)`。不乱 fire,且不静默。
37
+
38
+ ## Capability refs
39
+
40
+ Sister `workflows/capabilities.yaml` 条目:
41
+ - `codex` — 第二意见 / cross-AI peer review via codex (impl: gstack, cmd: /codex)
42
+
43
+ ## Gate ref
44
+
45
+ Sister `workflows/judgments/stage-routing.yaml`:
46
+ - `verify-second-opinion-orchestration.fires` — `phase.stage == 'verify' and requires_second_opinion == true`
47
+
48
+ ## 路由规则
49
+
50
+ - ✅ **触发**: 本次改动触及编排契约本身 (judgments / capabilities.yaml / phaseFactContext /
51
+ facts.ts / judgmentResolver / exprBuilder / ledger.ts / disciplines / 任一 SKILL.md)
52
+ - ❌ **跳过**: 纯 installer / 文档 / 测试 / 依赖 bump —— 改这些不会改变引擎的决策方式
53
+
54
+ **交付物即证据。** 本 sub fire 了就必须交 `second-opinion.md`;不交则 `checkpoint complete`
55
+ fail-closed 阻断,`--force` 在 ledger 记 `evidence_status: overridden`。跳过因此是台账上
56
+ 一行,不是隐形的。
57
+
58
+ ## 如何调用
59
+
60
+ !`harnessed checkpoint intent verify-second-opinion`
61
+
62
+ > 上方 banner(如出现)表示本次调用已在引擎**登记**(intent 标记)——尚未合规:按下方步骤(prompt → spawn → checkpoint complete)完成即解除;在此之前每 turn 会持续注入 `<workflow-intent>` 提醒。
63
+
64
+ 下面这套编号序列**就是** state machine —— 用 Bash 执行。**不要**从上方 Overview 自行演绎等价流程:
65
+ freestyle 会旁路引擎(无 ledger、无 evidence guard)。harnessed 给你 spawn-ready prompt;**你**用
66
+ CC-native Task / Agent 工具 spawn subagent(保持 session 响应 + 让澄清 round-trip 能回到用户)。
67
+
68
+ **不要** pipe 到 `harnessed run verify-second-opinion` —— 那是 CI/headless 路径(in-process SDK spawn,在 Claude
69
+ Code 内部会阻塞 session)。
70
+
71
+ 1. Bash: `harnessed prompt verify-second-opinion --task "$ARGUMENTS" --json` → 解析 `{prompt, max_iterations, model}`。
72
+ 2. 用 CC-native subagent(Task / Agent 工具)以该 `prompt` + `model` spawn,然后用 harnessed 自己的完成闸门驱动交付:
73
+ - subagent 返回后,把它的最终输出写入文件,跑 `harnessed checkpoint complete verify-second-opinion --result-file <path>` —— 该命令对声明的产物、TDD boundary、逐字 `<promise>COMPLETE</promise>` 三者 fail-closed。
74
+ - 若被拦下,跑 `harnessed checkpoint fail verify-second-opinion --failing-tests <n>` 记录本次尝试;命中停机条件时它会打印 BUDGET-EXHAUSTED / NO-PROGRESS / BREAK-LOOP。
75
+ - **仅当**这三者都未触发时才允许重 spawn。任一触发即停:重新收敛子任务范围、修掉阻塞点,或上报用户。绝不越过停机指令继续重 spawn。
76
+ 3. 若输出含 `STATUS: NEEDS_CLARIFICATION` + 问题列表:STOP,用 AskUserQuestion 原样转达,把答案 append 进 spec,再重 spawn。
77
+ 4. 命中 `<promise>COMPLETE</promise>`:把 subagent 最终输出写入文件,再 Bash `harnessed checkpoint complete verify-second-opinion --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`),不是静默放行。
78
+ 5. 若 complete 闸门拦下:Bash `harnessed checkpoint fail verify-second-opinion --failing-tests <n>` 记录本次尝试。命中停机条件时会打印 `BUDGET-EXHAUSTED` / `NO-PROGRESS` / `BREAK-LOOP`。**仅当**三者都未触发时才允许重 spawn;任一触发即 STOP —— 重新收敛子任务范围、修掉阻塞点,或上报用户。
79
+
80
+ <!-- harnessed-generated:v4.12.0 -->
81
+
82
+ ## 参考资料
83
+
84
+ - Phase 54 SPEC — .planning/phases/54-declaration-evaluation-parity/SPEC.md
85
+ - workflows/capabilities.yaml — codex
86
+ - workflows/judgments/stage-routing.yaml — verify-second-opinion-orchestration trigger
87
+ - workflows/defaults.yaml — ralph_max_iterations.verify-second-opinion.*
88
+ - src/cli/facts.ts — deriveSecondOpinion / ORCHESTRATION_SURFACE
@@ -0,0 +1,50 @@
1
+ # workflows/verify/second-opinion/workflow.yaml — Phase 54 T2
2
+ #
3
+ # Stage ④ verify sub-workflow — 跨模型第二意见 (cross-AI peer review)。
4
+ #
5
+ # 为什么是一个独立 sub 而不是一条建议:
6
+ # `artifacts_expected` 是 leaf phase 级的静态列表 (src/workflow/schema/workflow.ts),
7
+ # `src/checkpoint/evidence.ts` 收集一个 leaf 全部 phase 的声明 —— 没有条件位。把第二
8
+ # 意见记录直接声明到某个既有 verify sub 上,就等于**每次 verify 都必交**,判据没命中
9
+ # 也卡住;`--force` 随即变成肌肉记忆,门形同虚设。
10
+ #
11
+ # 本仓表达「条件性要求」的现成惯用法是**条件性 fire 的 sub**:gate 决定 sub 跑不跑,
12
+ # 跑了的 sub 必须交它声明的产物。于是零新机制:
13
+ #
14
+ # 判据命中 ──▶ delegates_to.gate fires ──▶ 本 sub fire ──▶ artifacts_expected 必交
15
+ # │
16
+ # 不交 ─┴─ --force
17
+ # │ │
18
+ # 阻断 ledger 记
19
+ # evidence_status: overridden
20
+ # 判据未命中 ─▶ gate false ─▶ sub skip ─▶ ledger 记 status: skipped + reason
21
+ #
22
+ # 跳过因此从隐形变成台账上一行。
23
+ #
24
+ # Sister refs:
25
+ # - workflows/judgments/stage-routing.yaml verify-second-opinion-orchestration trigger
26
+ # - workflows/capabilities.yaml — codex (第二意见 / cross-AI peer review)
27
+ # - src/cli/facts.ts deriveSecondOpinion — 判据的机械派生 (ORCHESTRATION_SURFACE)
28
+ # - .planning/phases/54-declaration-evaluation-parity/SPEC.md T2/T3
29
+
30
+ schema_version: harnessed.workflow.v3
31
+ workflow: verify-second-opinion
32
+ description: |
33
+ Stage ④ 跨模型第二意见。fires_when phase.stage == 'verify' AND requires_second_opinion
34
+ == true —— 后者由 `harnessed facts` 从 `git diff --name-only <last release tag>` 与
35
+ ORCHESTRATION SURFACE 的交集机械派生,不是交给模型的判断题。算不出来时取 false 并显式
36
+ 报出原因 (per-turn 断点的 SECOND-OPINION 行),不乱 fire 且不静默。
37
+
38
+ disciplines_applied: [karpathy, output-style, language, operational, priority, protocols]
39
+ tools_available: [codex]
40
+
41
+ phases:
42
+ - id: 01-second-opinion
43
+ name: 跨模型第二意见 (编排契约改动)
44
+ upstream: gstack
45
+ capability: '{{ capabilities.codex.cmd }}'
46
+ model: sonnet
47
+ gate: judgments.stage-routing.verify-second-opinion-orchestration.fires
48
+ # 交付物即证据。不交 → checkpoint complete fail-closed 阻断;--force → ledger 记
49
+ # evidence_status: overridden (可审计的显式跳过,不是静默放行)。
50
+ artifacts_expected: [second-opinion.md]
@@ -27,4 +27,3 @@ phases:
27
27
  capability: '{{ capabilities.code-simplifier.cmd }}'
28
28
  model: sonnet
29
29
  gate: judgments.stage-routing.verify-simplify-tail.fires
30
- max_iterations: '{{ defaults.ralph_max_iterations.verify-simplify.01-simplify }}'