cc-devflow 4.5.9 → 4.5.10

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 (121) hide show
  1. package/.claude/skills/cc-act/CHANGELOG.md +6 -0
  2. package/.claude/skills/cc-act/SKILL.md +12 -10
  3. package/.claude/skills/cc-act/assets/PR_BRIEF_TEMPLATE.md +1 -1
  4. package/.claude/skills/cc-act/references/closure-contract.md +1 -1
  5. package/.claude/skills/cc-act/references/git-commit-guidelines.md +1 -1
  6. package/.claude/skills/cc-check/CHANGELOG.md +17 -0
  7. package/.claude/skills/cc-check/PLAYBOOK.md +1 -0
  8. package/.claude/skills/cc-check/SKILL.md +9 -5
  9. package/.claude/skills/cc-check/references/review-contract.md +7 -0
  10. package/.claude/skills/cc-check/scripts/render-report-card.js +6 -1
  11. package/.claude/skills/cc-dev/CHANGELOG.md +5 -0
  12. package/.claude/skills/cc-dev/SKILL.md +26 -1
  13. package/.claude/skills/cc-do/CHANGELOG.md +12 -0
  14. package/.claude/skills/cc-do/PLAYBOOK.md +7 -7
  15. package/.claude/skills/cc-do/SKILL.md +35 -37
  16. package/.claude/skills/cc-do/references/execution-recovery.md +18 -13
  17. package/.claude/skills/cc-do/scripts/build-task-context.sh +4 -17
  18. package/.claude/skills/cc-do/scripts/record-review-decision.sh +4 -5
  19. package/.claude/skills/cc-do/scripts/recover-workflow.sh +9 -11
  20. package/.claude/skills/cc-do/scripts/verify-task-gates.sh +12 -10
  21. package/.claude/skills/cc-do/scripts/write-task-checkpoint.sh +7 -29
  22. package/.claude/skills/cc-investigate/CHANGELOG.md +17 -0
  23. package/.claude/skills/cc-investigate/PLAYBOOK.md +6 -5
  24. package/.claude/skills/cc-investigate/SKILL.md +56 -44
  25. package/.claude/skills/cc-investigate/assets/TASKS_TEMPLATE.md +48 -5
  26. package/.claude/skills/cc-investigate/assets/TASK_MANIFEST_TEMPLATE.json +4 -3
  27. package/.claude/skills/cc-investigate/assets/{ANALYSIS_TEMPLATE.md → legacy/ANALYSIS_TEMPLATE.md} +1 -0
  28. package/.claude/skills/cc-investigate/references/investigation-contract.md +2 -2
  29. package/.claude/skills/cc-investigate/scripts/bootstrap-analysis.sh +1 -1
  30. package/.claude/skills/cc-plan/CHANGELOG.md +19 -0
  31. package/.claude/skills/cc-plan/PLAYBOOK.md +55 -53
  32. package/.claude/skills/cc-plan/SKILL.md +101 -85
  33. package/.claude/skills/cc-plan/assets/TASKS_TEMPLATE.md +47 -14
  34. package/.claude/skills/cc-plan/assets/TASK_MANIFEST_TEMPLATE.json +4 -2
  35. package/.claude/skills/cc-plan/assets/{DESIGN_TEMPLATE.md → legacy/DESIGN_TEMPLATE.md} +1 -0
  36. package/.claude/skills/cc-plan/assets/{TINY_DESIGN_TEMPLATE.md → legacy/TINY_DESIGN_TEMPLATE.md} +1 -1
  37. package/.claude/skills/cc-plan/references/planning-contract.md +11 -10
  38. package/.claude/skills/cc-review/CHANGELOG.md +6 -0
  39. package/.claude/skills/cc-review/PLAYBOOK.md +9 -11
  40. package/.claude/skills/cc-review/SKILL.md +37 -61
  41. package/.claude/skills/cc-review/references/e2e-and-plugin-verification.md +1 -1
  42. package/.claude/skills/cc-review/references/implementation-review-branch.md +5 -5
  43. package/.claude/skills/cc-review/references/plan-review-branch.md +1 -1
  44. package/.claude/skills/cc-review/references/review-methods.md +4 -4
  45. package/.claude/skills/cc-review/scripts/collect-review-context.sh +14 -7
  46. package/CHANGELOG.md +16 -0
  47. package/CONTRIBUTING.md +40 -4
  48. package/CONTRIBUTING.zh-CN.md +40 -4
  49. package/README.md +20 -8
  50. package/README.zh-CN.md +20 -8
  51. package/bin/cc-devflow-cli.js +293 -36
  52. package/docs/examples/START-HERE.md +5 -4
  53. package/docs/examples/example-bindings.json +8 -8
  54. package/docs/examples/full-design-blocked/README.md +2 -2
  55. package/docs/examples/full-design-blocked/changes/REQ-002-bulk-invite-import/planning/design.md +2 -1
  56. package/docs/examples/full-design-blocked/changes/REQ-002-bulk-invite-import/planning/task-manifest.json +3 -2
  57. package/docs/examples/full-design-blocked/changes/REQ-002-bulk-invite-import/planning/tasks.md +11 -8
  58. package/docs/examples/full-design-blocked/changes/REQ-002-bulk-invite-import/review/report-card.json +4 -4
  59. package/docs/examples/local-handoff/README.md +2 -2
  60. package/docs/examples/local-handoff/changes/REQ-003-audit-log-export/planning/design.md +2 -1
  61. package/docs/examples/local-handoff/changes/REQ-003-audit-log-export/planning/task-manifest.json +3 -2
  62. package/docs/examples/local-handoff/changes/REQ-003-audit-log-export/planning/tasks.md +9 -6
  63. package/docs/examples/local-handoff/changes/REQ-003-audit-log-export/review/report-card.json +1 -1
  64. package/docs/examples/pdca-loop/README.md +2 -2
  65. package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/handoff/pr-brief.md +2 -2
  66. package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/planning/design.md +2 -1
  67. package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/planning/task-manifest.json +2 -1
  68. package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/planning/tasks.md +9 -6
  69. package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/review/report-card.json +1 -1
  70. package/docs/examples/scripts/check-example-bindings.sh +2 -0
  71. package/docs/get-shit-done-strategy-audit.md +22 -22
  72. package/docs/guides/artifact-contract.md +1 -1
  73. package/docs/guides/getting-started.md +10 -8
  74. package/docs/guides/getting-started.zh-CN.md +10 -8
  75. package/docs/guides/minimize-artifacts.md +123 -0
  76. package/lib/compiler/__tests__/skills-registry.test.js +2 -2
  77. package/lib/skill-runtime/CLAUDE.md +1 -1
  78. package/lib/skill-runtime/__tests__/autopilot.test.js +42 -6
  79. package/lib/skill-runtime/__tests__/benchmark-artifacts.test.js +165 -0
  80. package/lib/skill-runtime/__tests__/cli-bootstrap.integration.test.js +2 -2
  81. package/lib/skill-runtime/__tests__/dispatch.test.js +8 -38
  82. package/lib/skill-runtime/__tests__/intent.test.js +4 -20
  83. package/lib/skill-runtime/__tests__/lifecycle.test.js +1 -1
  84. package/lib/skill-runtime/__tests__/paths.test.js +7 -1
  85. package/lib/skill-runtime/__tests__/planner.tdd.test.js +61 -0
  86. package/lib/skill-runtime/__tests__/prepare-pr.test.js +3 -16
  87. package/lib/skill-runtime/__tests__/query.test.js +388 -7
  88. package/lib/skill-runtime/__tests__/review-check-integration.test.js +148 -0
  89. package/lib/skill-runtime/__tests__/review-records.test.js +619 -0
  90. package/lib/skill-runtime/__tests__/runtime.integration.test.js +64 -23
  91. package/lib/skill-runtime/__tests__/schemas.test.js +43 -0
  92. package/lib/skill-runtime/__tests__/task-contract-migrate.test.js +137 -0
  93. package/lib/skill-runtime/__tests__/task-contract.test.js +783 -0
  94. package/lib/skill-runtime/__tests__/verify-artifacts.test.js +203 -0
  95. package/lib/skill-runtime/__tests__/worker-run.test.js +4 -11
  96. package/lib/skill-runtime/__tests__/workflow-context-legacy-fallback.test.js +31 -0
  97. package/lib/skill-runtime/__tests__/workflow-context.test.js +98 -0
  98. package/lib/skill-runtime/artifacts.js +0 -5
  99. package/lib/skill-runtime/context-index.js +545 -0
  100. package/lib/skill-runtime/intent.js +9 -33
  101. package/lib/skill-runtime/lifecycle.js +1 -1
  102. package/lib/skill-runtime/operations/CLAUDE.md +2 -2
  103. package/lib/skill-runtime/operations/dispatch.js +4 -42
  104. package/lib/skill-runtime/operations/init.js +2 -6
  105. package/lib/skill-runtime/operations/janitor.js +2 -18
  106. package/lib/skill-runtime/operations/resume.js +21 -38
  107. package/lib/skill-runtime/operations/review-records.js +265 -0
  108. package/lib/skill-runtime/operations/snapshot.js +1 -1
  109. package/lib/skill-runtime/operations/task-contract.js +524 -0
  110. package/lib/skill-runtime/operations/worker-run.js +2 -30
  111. package/lib/skill-runtime/paths.js +4 -4
  112. package/lib/skill-runtime/planner.js +24 -11
  113. package/lib/skill-runtime/query-registry.js +2 -2
  114. package/lib/skill-runtime/query.js +15 -2
  115. package/lib/skill-runtime/review-records.js +123 -0
  116. package/lib/skill-runtime/review.js +246 -11
  117. package/lib/skill-runtime/schemas.js +174 -12
  118. package/lib/skill-runtime/store.js +0 -10
  119. package/lib/skill-runtime/task-contract.js +187 -0
  120. package/lib/skill-runtime/workflow-context.js +748 -0
  121. package/package.json +7 -4
@@ -3,7 +3,7 @@
3
3
  set -euo pipefail
4
4
 
5
5
  # ------------------------------------------------------------
6
- # 组装当前任务的执行上下文,并记录 context_ready 事件
6
+ # 组装当前任务的执行上下文,只输出到 stdout
7
7
  # ------------------------------------------------------------
8
8
 
9
9
  usage() {
@@ -51,12 +51,8 @@ if [[ -z "$task_json" ]]; then
51
51
  fi
52
52
 
53
53
  change_id="$(jq -r '.changeId // .requirementId // "REQ-UNKNOWN"' "$manifest")"
54
- runtime_task_dir="$(req_do_task_runtime_dir "$CHANGE_DIR" "$TASK_ID")"
55
- output_path="$runtime_task_dir/context.md"
56
54
  ready_json="$("$SCRIPT_DIR/select-ready-tasks.sh" --manifest "$manifest")"
57
55
 
58
- mkdir -p "$runtime_task_dir"
59
-
60
56
  list_or_none() {
61
57
  local value="$1"
62
58
  if [[ -z "${value//$'\n'/}" ]]; then
@@ -168,21 +164,12 @@ sync_status="$(jq -r '.spec.syncStatus // "unknown"' "$spec_source" 2>/dev/null
168
164
  echo
169
165
  echo "## Context Reset"
170
166
  echo
171
- echo "- If chat context drifts, discard conversational memory and reload only the canonical files above plus the latest checkpoint."
172
- echo "- Do not continue from memory if the current task, active phase, or latest checkpoint summary cannot be restated exactly."
167
+ echo "- If chat context drifts, discard conversational memory and reload only the canonical files above, current Git state, and CLI logs."
168
+ echo "- Do not continue from memory if the current task, active phase, or latest verification status cannot be restated exactly."
173
169
  echo
174
170
  if [[ -f "$resume_index" ]]; then
175
171
  echo "## Optional Resume Index"
176
172
  echo
177
173
  cat "$resume_index"
178
174
  fi
179
- } > "$output_path"
180
-
181
- "$SCRIPT_DIR/write-task-checkpoint.sh" \
182
- --dir "$CHANGE_DIR" \
183
- --task "$TASK_ID" \
184
- --status pending \
185
- --summary "Task context assembled" \
186
- --next-action "Write the failing test for $TASK_ID" >/dev/null
187
-
188
- cat "$output_path"
175
+ }
@@ -3,7 +3,7 @@
3
3
  set -euo pipefail
4
4
 
5
5
  # ------------------------------------------------------------
6
- # 记录 spec / code review 结论,并同步 runtime / manifest
6
+ # 记录 spec / code review 结论,并同步 manifest;失败时保留 CLI 事件
7
7
  # ------------------------------------------------------------
8
8
 
9
9
  usage() {
@@ -46,12 +46,9 @@ fi
46
46
  CHANGE_DIR="$(req_do_resolve_change_dir "$REQ_DIR")"
47
47
  manifest="$(req_do_manifest_path "$CHANGE_DIR")"
48
48
  change_id="$(jq -r '.changeId // .requirementId // "REQ-UNKNOWN"' "$manifest" 2>/dev/null || basename "$CHANGE_DIR")"
49
- runtime_task_dir="$(req_do_task_runtime_dir "$CHANGE_DIR" "$TASK_ID")"
50
49
  timestamp="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
51
50
  event_name="${GATE}_review_${VERDICT}"
52
51
 
53
- mkdir -p "$runtime_task_dir"
54
-
55
52
  if [[ -f "$manifest" ]]; then
56
53
  tmp_manifest="$(mktemp)"
57
54
  jq --arg task "$TASK_ID" --arg gate "$GATE" --arg verdict "$VERDICT" '
@@ -66,7 +63,9 @@ if [[ -f "$manifest" ]]; then
66
63
  mv "$tmp_manifest" "$manifest"
67
64
  fi
68
65
 
69
- if [[ -f "$runtime_task_dir/events.jsonl" || "$VERDICT" != "pass" ]]; then
66
+ if [[ "$VERDICT" != "pass" ]]; then
67
+ runtime_task_dir="$(req_do_task_runtime_dir "$CHANGE_DIR" "$TASK_ID")"
68
+ mkdir -p "$runtime_task_dir"
70
69
  jq -nc \
71
70
  --arg type "$event_name" \
72
71
  --arg changeId "$change_id" \
@@ -68,17 +68,15 @@ if [[ -f "$report" ]]; then
68
68
  echo "- Latest check verdict: $verdict"
69
69
  fi
70
70
 
71
- if [[ -n "$change_id" ]]; then
72
- runtime_dir="$(req_do_execution_dir "$CHANGE_DIR")/tasks"
71
+ if [[ -f "$manifest" ]]; then
72
+ echo
73
+ echo "## Task Status"
74
+ jq -r '.tasks[]? | "- " + .id + ": " + (.status // "pending") + (if .lastError then " - " + .lastError else "" end)' "$manifest" 2>/dev/null || true
73
75
  fi
74
76
 
75
- if [[ -n "${runtime_dir:-}" && -d "$runtime_dir" ]]; then
76
- echo "- Runtime dir: $runtime_dir"
77
-
78
- while IFS= read -r checkpoint_path; do
79
- task_id="$(jq -r '.taskId // "unknown"' "$checkpoint_path" 2>/dev/null || echo unknown)"
80
- checkpoint_status="$(jq -r '.status // "unknown"' "$checkpoint_path" 2>/dev/null || echo unknown)"
81
- checkpoint_summary="$(jq -r '.summary // ""' "$checkpoint_path" 2>/dev/null || echo "")"
82
- echo "- Checkpoint $task_id: $checkpoint_status ${checkpoint_summary:+- $checkpoint_summary}"
83
- done < <(find "$runtime_dir" -name checkpoint.json | sort)
77
+ if git -C "$CHANGE_DIR" rev-parse --show-toplevel >/dev/null 2>&1; then
78
+ repo_root="$(git -C "$CHANGE_DIR" rev-parse --show-toplevel)"
79
+ echo
80
+ echo "## Git State"
81
+ git -C "$repo_root" status --short
84
82
  fi
@@ -3,7 +3,7 @@
3
3
  set -euo pipefail
4
4
 
5
5
  # ------------------------------------------------------------
6
- # 校验任务是否完成 Red / Green / Refactor / Review 闭环
6
+ # 校验任务状态、依赖和可选 CLI 事件顺序
7
7
  # ------------------------------------------------------------
8
8
 
9
9
  usage() {
@@ -36,19 +36,21 @@ CHANGE_DIR="$(req_do_resolve_change_dir "$REQ_DIR")"
36
36
  manifest="$(req_do_manifest_path "$CHANGE_DIR")"
37
37
  runtime_task_dir="$(req_do_task_runtime_dir "$CHANGE_DIR" "$TASK_ID")"
38
38
  events_file="$runtime_task_dir/events.jsonl"
39
- checkpoint_file="$runtime_task_dir/checkpoint.json"
40
39
 
41
- if [[ ! -f "$checkpoint_file" ]]; then
42
- echo "Missing $checkpoint_file" >&2
43
- exit 1
44
- fi
45
-
46
- checkpoint_status="$(jq -r '.status // "unknown"' "$checkpoint_file" 2>/dev/null || echo unknown)"
47
- [[ "$checkpoint_status" == "passed" ]] || {
48
- echo "Task $TASK_ID checkpoint status is not passed" >&2
40
+ task_json="$(jq -c --arg task "$TASK_ID" '.tasks[] | select(.id == $task)' "$manifest" 2>/dev/null || true)"
41
+ [[ -n "$task_json" ]] || {
42
+ echo "Task $TASK_ID not found in manifest" >&2
49
43
  exit 1
50
44
  }
51
45
 
46
+ while IFS= read -r dependency; do
47
+ dep_status="$(jq -r --arg dep "$dependency" '.tasks[] | select(.id == $dep) | .status // "pending"' "$manifest" 2>/dev/null || echo pending)"
48
+ [[ "$dep_status" == "passed" || "$dep_status" == "completed" || "$dep_status" == "done" || "$dep_status" == "verified" ]] || {
49
+ echo "Task $TASK_ID dependency $dependency is not complete" >&2
50
+ exit 1
51
+ }
52
+ done < <(jq -r '(.dependsOn // [])[]?' <<<"$task_json")
53
+
52
54
  spec_verdict="$(jq -r --arg task "$TASK_ID" '.tasks[] | select(.id == $task) | .reviews.spec // "pending"' "$manifest" 2>/dev/null || echo pending)"
53
55
  code_verdict="$(jq -r --arg task "$TASK_ID" '.tasks[] | select(.id == $task) | .reviews.code // "pending"' "$manifest" 2>/dev/null || echo pending)"
54
56
 
@@ -3,13 +3,13 @@
3
3
  set -euo pipefail
4
4
 
5
5
  # ------------------------------------------------------------
6
- # 写入 task checkpoint.json / events.jsonl
6
+ # 兼容旧入口:只写必要的 CLI 事件,不再生成 checkpoint.json
7
7
  # ------------------------------------------------------------
8
8
 
9
9
  usage() {
10
10
  cat <<'EOF'
11
11
  Usage:
12
- write-task-checkpoint.sh --dir path/to/change --task T001 --status pending|running|passed|failed|skipped --summary "..." [--event context_ready] [--attempt 0] [--session session-id] [--next-action "..."] [--tdd-json '{"red":...}']
12
+ write-task-checkpoint.sh --dir path/to/change --task T001 --status pending|running|passed|failed|skipped [--summary "..."] [--event context_ready] [--attempt 0] [--session session-id] [--next-action "..."] [--tdd-json '{"red":...}']
13
13
  EOF
14
14
  }
15
15
 
@@ -41,7 +41,7 @@ while [[ $# -gt 0 ]]; do
41
41
  esac
42
42
  done
43
43
 
44
- if [[ -z "$REQ_DIR" || -z "$TASK_ID" || -z "$STATUS" || -z "$SUMMARY" ]]; then
44
+ if [[ -z "$REQ_DIR" || -z "$TASK_ID" || -z "$STATUS" ]]; then
45
45
  usage
46
46
  exit 1
47
47
  fi
@@ -49,12 +49,9 @@ fi
49
49
  CHANGE_DIR="$(req_do_resolve_change_dir "$REQ_DIR")"
50
50
  manifest="$(req_do_manifest_path "$CHANGE_DIR")"
51
51
  change_id="$(jq -r '.changeId // .requirementId // "REQ-UNKNOWN"' "$manifest" 2>/dev/null || basename "$REQ_DIR")"
52
- plan_version="$(jq -r '.metadata.planVersion // 1' "$manifest" 2>/dev/null || echo 1)"
53
52
  timestamp="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
54
53
  runtime_task_dir="$(req_do_task_runtime_dir "$CHANGE_DIR" "$TASK_ID")"
55
54
 
56
- mkdir -p "$runtime_task_dir"
57
-
58
55
  if [[ -z "$SESSION_ID" ]]; then
59
56
  SESSION_ID="${TASK_ID}-$(date -u +%s)"
60
57
  fi
@@ -68,28 +65,8 @@ if [[ -n "$TDD_JSON" ]]; then
68
65
  fi
69
66
  fi
70
67
 
71
- jq -nc \
72
- --arg changeId "$change_id" \
73
- --arg taskId "$TASK_ID" \
74
- --arg sessionId "$SESSION_ID" \
75
- --arg planVersion "$plan_version" \
76
- --arg status "$STATUS" \
77
- --arg summary "$SUMMARY" \
78
- --arg timestamp "$timestamp" \
79
- --arg attempt "$ATTEMPT" \
80
- --argjson tdd "$tdd_payload" \
81
- '{
82
- changeId: $changeId,
83
- taskId: $taskId,
84
- sessionId: $sessionId,
85
- planVersion: ($planVersion | tonumber),
86
- status: $status,
87
- summary: $summary,
88
- timestamp: $timestamp,
89
- attempt: ($attempt | tonumber)
90
- } + (if $tdd == null then {} else {tdd: $tdd} end)' > "$runtime_task_dir/checkpoint.json"
91
-
92
68
  if [[ -n "$EVENT_TYPE" || "$STATUS" == "failed" ]]; then
69
+ mkdir -p "$runtime_task_dir"
93
70
  jq -nc \
94
71
  --arg type "${EVENT_TYPE:-status_$STATUS}" \
95
72
  --arg changeId "$change_id" \
@@ -99,6 +76,7 @@ if [[ -n "$EVENT_TYPE" || "$STATUS" == "failed" ]]; then
99
76
  --arg summary "$SUMMARY" \
100
77
  --arg nextAction "$NEXT_ACTION" \
101
78
  --arg timestamp "$timestamp" \
79
+ --argjson tdd "$tdd_payload" \
102
80
  '{
103
81
  type: $type,
104
82
  changeId: $changeId,
@@ -108,7 +86,7 @@ if [[ -n "$EVENT_TYPE" || "$STATUS" == "failed" ]]; then
108
86
  summary: $summary,
109
87
  nextAction: $nextAction,
110
88
  timestamp: $timestamp
111
- }' >> "$runtime_task_dir/events.jsonl"
89
+ } + (if $tdd == null then {} else {tdd: $tdd} end)' >> "$runtime_task_dir/events.jsonl"
112
90
  fi
113
91
 
114
- echo "Wrote $runtime_task_dir/checkpoint.json"
92
+ echo "No checkpoint written; task truth lives in planning/tasks.md and planning/task-manifest.json"
@@ -1,5 +1,22 @@
1
1
  # CC-Investigate Skill Changelog
2
2
 
3
+ ## v1.5.0 - 2026-05-13
4
+
5
+ - collapse default investigation output to `planning/tasks.md` plus CLI-generated `task-manifest.json` and `change-meta.json`
6
+ - move root-cause truth into `planning/tasks.md#Root Cause Contract` so `planning/analysis.md` is legacy fallback only
7
+ - archive the legacy analysis template under `assets/legacy/` and keep repair handoffs rooted in `assets/TASKS_TEMPLATE.md`
8
+
9
+ ## v1.4.3 - 2026-05-13
10
+
11
+ - add the Worktree Branch Contract so new `FIX` investigations anchor detached worktrees to `FIX/<task>` before artifacts are written
12
+ - treat investigations on `main` / the default branch as a setup blocker instead of allowing the main checkout to accumulate repair state
13
+ - require analysis, tasks, and change metadata to record the canonical work branch for downstream `cc-do`
14
+
15
+ ## v1.4.2 - 2026-05-12
16
+
17
+ - require IDCA repair handoffs to be consumable by `cc-devflow query workflow-context`
18
+ - add the compact runtime reset to investigation task templates so `cc-do`, `cc-check`, and `cc-act` continue from the frozen root-cause packet instead of chat history
19
+
3
20
  ## v1.4.1 - 2026-05-11
4
21
 
5
22
  - add the Project Postmortem Recall Gate so investigations search `devflow/postmortems` before final hypotheses are frozen
@@ -5,7 +5,7 @@
5
5
  `cc-investigate -> cc-do -> cc-check`
6
6
 
7
7
  - Enter from: a bug, regression, or broken requirement whose root cause is still unclear.
8
- - Stay in: `cc-investigate` until `planning/analysis.md` and the repair handoff are both frozen.
8
+ - Stay in: `cc-investigate` until `planning/tasks.md#Root Cause Contract` and the repair handoff are both frozen.
9
9
  - Exit to: `cc-do` only after root cause, repair boundary, and source roadmap progress are explicit in canonical artifacts.
10
10
  - Reroute to: `cc-plan` for scope/design truth changes, or `roadmap` for project-level priority decisions.
11
11
 
@@ -16,7 +16,7 @@
16
16
  3. 先确认 loop 复现的是用户报告的同一个失败。
17
17
  4. 先看最近变化,再决定是不是 regression。
18
18
  5. 先证伪假设,再冻结根因。
19
- 6. `planning/analysis.md` 和 `planning/tasks.md` 必须足够让 `cc-do` 脱离当前会话继续工作。
19
+ 6. `planning/tasks.md` 必须足够让 `cc-do` 脱离当前会话继续工作。
20
20
  7. 调查失败三次后先重建入口,不准继续乱补。
21
21
  8. 没有 frozen root-cause contract,不准进入 repair task。
22
22
  9. 多组件、深层调用、flaky 问题必须先补边界探针、反向追踪或条件等待证据。
@@ -24,6 +24,7 @@
24
24
  11. workflow forensics 先分类 artifact / git / state / tool / permission / process failure,再决定是否进入修复。
25
25
  12. 退出前必须跑 Roadmap Sync Gate:`implementation drift`、`missing spec truth`、`roadmap mismatch` 三种结论都要让 source RM 的状态和 next action 跟上。
26
26
  13. Root Cause Proof Ladder 必须证明 symptom site、first bad state、violated contract、original trigger、counterfactual proof 和 escape reason。
27
+ 14. 分配 `FIX-*` change key 后立刻执行 Worktree Branch Contract:detached worktree 先挂到 `FIX/<task>`;当前在 `main` / default branch 时停止,不写 investigation artifacts。
27
28
 
28
29
  ## Iron Law
29
30
 
@@ -48,7 +49,6 @@ root-cause contract 至少包含:稳定复现或缩小后的可验证症状、
48
49
 
49
50
  ## Required Outputs
50
51
 
51
- - `planning/analysis.md`
52
52
  - `planning/tasks.md`
53
53
  - `planning/task-manifest.json`
54
54
  - `change-meta.json`
@@ -173,14 +173,15 @@ root-cause contract 至少包含:稳定复现或缩小后的可验证症状、
173
173
 
174
174
  ## Local Kit
175
175
 
176
- - 模板在 `assets/`
176
+ - 默认模板在 `assets/TASKS_TEMPLATE.md` 和 `assets/TASK_MANIFEST_TEMPLATE.json`
177
+ - 旧分析模板在 `assets/legacy/`,只用于 legacy fallback / migration
177
178
  - 调查契约在 `references/investigation-contract.md`
178
179
  - 需要分析骨架时用 `scripts/bootstrap-analysis.sh`
179
180
  - Roadmap 回写使用 `../cc-roadmap/scripts/locate-roadmap-item.sh` 和 `../cc-roadmap/scripts/sync-roadmap-progress.sh`
180
181
 
181
182
  ## Exit Rule
182
183
 
183
- 只有当下一位执行者读完 `planning/analysis.md`、`planning/tasks.md`、`planning/task-manifest.json` 就知道:
184
+ 只有当下一位执行者读完 `planning/tasks.md`、`planning/task-manifest.json` 就知道:
184
185
 
185
186
  - 为什么坏
186
187
  - 该修什么
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: cc-investigate
3
- version: 1.4.1
3
+ version: 1.5.0
4
4
  description: "Use when a bug, regression, broken task, or unexpected behavior needs root-cause investigation, reproducible evidence, and a frozen repair handoff before cc-do resumes coding."
5
5
  triggers:
6
6
  - "帮我查这个 bug"
@@ -15,15 +15,11 @@ reads:
15
15
  - "CHANGELOG.md"
16
16
  - "references/investigation-contract.md"
17
17
  - "docs/guides/project-postmortem.md"
18
- - "assets/ANALYSIS_TEMPLATE.md"
19
18
  - "assets/TASKS_TEMPLATE.md"
20
19
  - "assets/TASK_MANIFEST_TEMPLATE.json"
21
20
  - "../cc-roadmap/scripts/locate-roadmap-item.sh"
22
21
  - "../cc-roadmap/scripts/sync-roadmap-progress.sh"
23
22
  writes:
24
- - path: "devflow/changes/<change-key>/planning/analysis.md"
25
- durability: "durable"
26
- required: true
27
23
  - path: "devflow/changes/<change-key>/planning/tasks.md"
28
24
  durability: "durable"
29
25
  required: true
@@ -38,6 +34,7 @@ effects:
38
34
  entry_gate:
39
35
  - "Read the current bug report, existing requirement artifacts, relevant code, tests, and recent history before forming any hypothesis."
40
36
  - "Assign the change key by running `cc-devflow next-change-key --prefix FIX --description \"<short bug name>\"`. Use both output lines: first is changeId for task-manifest, second is the full changeKey for the directory."
37
+ - "Immediately after assigning the change key and before writing durable artifacts, enforce the Worktree Branch Contract: if the current worktree is detached, create or switch to the canonical `FIX/<task>` branch derived from the change key; if the current branch is the default branch (`main` / `master` / origin HEAD), stop with a setup blocker instead of investigating on main."
41
38
  - "Build a runnable feedback loop, confirm it matches the reported symptom, then freeze the evidence chain before proposing repair tasks."
42
39
  - "Record persistent debug session state: active hypothesis, probes, cleanup status, and next evidence action."
43
40
  - "Search prior investigations, TODO/backlog signals, and recent fixes in the affected area before declaring the bug novel."
@@ -45,16 +42,18 @@ entry_gate:
45
42
  - "For multi-component, deep-stack, or flaky symptoms, record boundary probes, backward trace, or condition-wait evidence before declaring the root cause."
46
43
  - "Run the Root Cause Proof Ladder before generating repair tasks: symptom site, first bad state, violated contract, original trigger, counterfactual proof, and escape reason must all be explicit."
47
44
  - "For performance regressions, collect a baseline or profile signal before treating logs as evidence."
48
- - "Do not write production code here; this stage ends with planning/analysis.md plus executable repair tasks for cc-do."
45
+ - "Do not write production code here; this stage ends with planning/tasks.md#Root Cause Contract plus executable repair tasks for cc-do."
49
46
  - "Before exit, locate the source RM in `devflow/roadmap.json`, `devflow/ROADMAP.md`, optional `devflow/BACKLOG.md`, or legacy `devflow/roadmap-tracking.json`; the repair handoff must not leave roadmap progress stale."
50
47
  exit_criteria:
51
- - "planning/analysis.md records symptom, reproduction, evidence chain, boundary probes or backward trace when applicable, pattern analysis, tested hypotheses, confirmed root cause, and repair boundary."
52
- - "planning/analysis.md proves the first bad state and original trigger, not only the visible error site."
53
- - "planning/analysis.md records the Project Postmortem Recall result, including matching incidents/principles or an explicit no-history verdict."
48
+ - "planning/tasks.md contains `## Root Cause Contract` with symptom, reproduction, evidence chain, boundary probes or backward trace when applicable, pattern analysis, tested hypotheses, confirmed root cause, and repair boundary."
49
+ - "planning/tasks.md#Root Cause Contract proves the first bad state and original trigger, not only the visible error site."
50
+ - "planning/tasks.md#Root Cause Contract records the Project Postmortem Recall result, including matching incidents/principles or an explicit no-history verdict."
54
51
  - "diagnose-only outcomes clearly stop before implementation while preserving root cause, owner, and next action."
55
52
  - "workflow forensics classify artifact, git, state, or tool failures before repair tasks are generated."
56
53
  - "planning/tasks.md and planning/task-manifest.json are explicit enough that cc-do can repair the bug without chat memory."
57
- - "The source roadmap item has been synchronized with the investigation outcome, or `planning/analysis.md` and `change-meta.json` record why no roadmap update is valid."
54
+ - "planning/tasks.md and change-meta.json record the canonical work branch or the explicit reason no branch mutation was valid."
55
+ - "`cc-devflow query workflow-context` can derive the IDCA next action, packet digests, default section refs, repair task, trusted commands, and deep-open triggers from the frozen investigation artifacts."
56
+ - "The source roadmap item has been synchronized with the investigation outcome, or `planning/tasks.md` and `change-meta.json` record why no roadmap update is valid."
58
57
  - "The honest next step is cc-do, cc-plan, or roadmap."
59
58
  reroutes:
60
59
  - when: "The issue is actually a new feature, a scope redesign, or a product decision instead of a bug investigation."
@@ -69,7 +68,7 @@ recovery_modes:
69
68
  action: "Drop the narrative, rebuild the reproduction from canonical artifacts and fresh output, then restate the symptom before testing hypotheses."
70
69
  - name: "re-open-investigation"
71
70
  when: "New execution evidence disproves the current root-cause contract or widens the suspected blast radius."
72
- action: "Reopen planning/analysis.md, update the evidence chain, and regenerate repair tasks only after the new root cause is frozen."
71
+ action: "Reopen planning/tasks.md#Root Cause Contract, update the evidence chain, and regenerate machine records only after the new root cause is frozen."
73
72
  tool_budget:
74
73
  read_files: 11
75
74
  search_steps: 6
@@ -100,19 +99,35 @@ tool_budget:
100
99
 
101
100
  写入任何 durable Markdown 或 JSON metadata 前,先运行 `cc-devflow config resolve --format policy`。
102
101
 
103
- - `Output language` 是机器约束,`planning/analysis.md`、`planning/tasks.md` 和 `change-meta.json` 必须记录并遵守它。
102
+ - `Output language` 是机器约束,`planning/tasks.md` 和 `change-meta.json` 必须记录并遵守它。
104
103
  - `agent_preferences` 是用户偏好建议,只影响表达方式和结构选择,不覆盖本 Skill 的工作流边界。
105
104
  - 如果配置解析失败,先修配置或向用户说明阻塞,不要用默认语言继续生成正式文档。
106
105
 
106
+ ## Worktree Branch Contract
107
+
108
+ 每个新的 `FIX` 默认拥有一个同名工作分支。主项目 checkout 的 `main` 只服务同步、审查和 parity proof,不承载调查产物或修复实现。
109
+
110
+ 分支锚定顺序固定:
111
+
112
+ 1. 先运行 `cc-devflow next-change-key --prefix FIX --description "<short bug name>"`,得到 `changeId` 和完整 `changeKey`。
113
+ 2. 计算 canonical work branch:`FIX/<task>`,其中 `<task>` 是去掉 `FIX-` 前缀后的 change key 尾部。例如 `FIX-014-auth-race` -> `FIX/014-auth-race`。
114
+ 3. 立即检查 `git branch --show-current`:
115
+ - 为空:当前是 detached worktree,立刻 `git switch -c <canonical-work-branch>`;如果分支已存在且指向当前 HEAD,可以 `git switch <canonical-work-branch>`。
116
+ - 等于 default branch(`main` / `master` / `origin/HEAD` 指向的分支):停止并报告 setup blocker;不要在主分支写 investigation artifacts。
117
+ - 等于 canonical work branch:继续。
118
+ - 其它分支:只有它已经明确绑定同一个 `changeKey` 时才继续;否则停止并让用户确认是否切换或新开 worktree。
119
+ 4. 在 `planning/tasks.md` 和 `change-meta.json` 记录 work branch。没有记录 work branch 的 repair handoff 不能进入 `cc-do`。
120
+
121
+ 这不是发布前补救动作。`cc-act` 的 detached HEAD rescue 只处理历史遗留;新的 `cc-investigate` 必须在入口阶段就把 worktree 绑定到 `FIX/<task>`。
122
+
107
123
  ## Read First
108
124
 
109
125
  1. `PLAYBOOK.md`
110
126
  2. `CHANGELOG.md`
111
127
  3. `references/investigation-contract.md`
112
- 4. `assets/ANALYSIS_TEMPLATE.md`
113
- 5. `assets/TASKS_TEMPLATE.md`
114
- 6. `assets/TASK_MANIFEST_TEMPLATE.json`
115
- 7. `docs/guides/project-postmortem.md`
128
+ 4. `assets/TASKS_TEMPLATE.md`
129
+ 5. `assets/TASK_MANIFEST_TEMPLATE.json`
130
+ 6. `docs/guides/project-postmortem.md`
116
131
 
117
132
  ## Use This Skill When
118
133
 
@@ -184,7 +199,7 @@ NO REPAIR WITHOUT A FROZEN ROOT-CAUSE CONTRACT
184
199
 
185
200
  ## Harness Contract
186
201
 
187
- - Allowed actions: reproduce, collect evidence, trace code paths, test hypotheses, freeze root cause, write `planning/analysis.md`, `planning/tasks.md`, `planning/task-manifest.json`, and `change-meta.json`, then run the final roadmap progress sync for the source RM.
202
+ - Allowed actions: reproduce, collect evidence, trace code paths, test hypotheses, freeze root cause, write `planning/tasks.md`, generate `planning/task-manifest.json` / `change-meta.json`, then run the final roadmap progress sync for the source RM.
188
203
  - Forbidden actions: writing production code, disguising guesses as root cause, or skipping directly from symptoms to repair.
189
204
  - Required evidence: every root-cause claim must point to reproduction evidence, code facts, recent history, or explicit user confirmation.
190
205
  - Reroute rule: product/scope changes go to `cc-plan`; strategy questions go to `roadmap`; only confirmed repair handoff goes to `cc-do`.
@@ -199,44 +214,40 @@ rg -n "<symptom|module|boundary|failure-class|model-risk>" devflow/postmortems
199
214
 
200
215
  执行规则:
201
216
 
202
- 1. `devflow/postmortems/` 不存在时,在 `planning/analysis.md` 记录 `no-project-postmortems-yet`。
217
+ 1. `devflow/postmortems/` 不存在时,在 `planning/tasks.md#Root Cause Contract` 记录 `no-project-postmortems-yet`。
203
218
  2. 有命中时,先读 `INDEX.md` / `principles.md`,再打开最相关的 1-2 个 incident。
204
219
  3. 相关 incident 必须进入假设表或反证表:同根因、相似症状不同根因、已知模型陷阱、或明确不相关。
205
220
  4. 如果本次确认是重复根因,`Root Cause` 的 `Prior history relationship` 必须标成 `recurring` 或 `same-root-cause`。
206
221
 
207
222
  ## Output Model
208
223
 
209
- `cc-investigate` 只允许产出 4 个主文件:
210
-
211
- 1. `planning/analysis.md`
212
- - 现象
213
- - 复现
214
- - 证据链
215
- - 假设表
216
- - 已确认根因
217
- - 修复边界
218
- 2. `planning/tasks.md`
219
- - 只保留真正要执行的修复任务
220
- - 顶部明确 canonical contract 是 `planning/analysis.md`
221
- 3. `planning/task-manifest.json`
224
+ `cc-investigate` 默认只允许产出 3 个主文件:
225
+
226
+ 1. `planning/tasks.md`
227
+ - 唯一默认 human-authored Markdown
228
+ - `## Root Cause Contract` 记录现象、复现、证据链、假设表、已确认根因和修复边界
229
+ - 后续区块只保留真正要执行的修复任务
230
+ - 顶部明确 canonical contract 是 `planning/tasks.md#Root Cause Contract`
231
+ 2. `planning/task-manifest.json`
222
232
  - 机器真相源
223
233
  - 标记当前任务、依赖、验证命令、调查版本链
224
- 4. `change-meta.json`
234
+ 3. `change-meta.json`
225
235
  - 标记当前 bug 是实现偏离 spec、spec 本身缺失,还是 roadmap 假设错误
226
236
  - 记录这次修复会如何影响 capability truth
227
237
 
228
238
  `cc-investigate` 不写生产代码,不在这里偷跑 `cc-do`。
229
239
 
230
- diagnose-only 仍然写 `planning/analysis.md`,但 `planning/tasks.md` 只能包含证据交接、
240
+ diagnose-only 仍然写 `planning/tasks.md#Root Cause Contract`,但 task blocks 只能包含证据交接、
231
241
  监控、人工动作或明确的 `reroute`;不能把“已经诊断”伪装成“已经修复”。
232
242
 
233
243
  ## Entry Gate
234
244
 
235
245
  1. 先确认当前对象仍然属于一个 requirement,而不是整个项目级故障。
236
- 2. 先收症状事实:错误、触发条件、影响面、复现路径。
237
- 3. 先读现有 change 目录里的 `planning/design.md` / `planning/analysis.md` / `planning/tasks.md` / `planning/task-manifest.json`,不要假设自己是第一位调查者。
238
- 4. 先读代码、测试、日志、相关 capability spec 和最近提交,再下任何假设。
239
- 5. 如果复现都不稳定,先不要写根因。
246
+ 2. 先分配 canonical `FIX-*` change key,并执行 Worktree Branch Contract;detached worktree 必须先挂到 `FIX/<task>`,主分支必须停止。
247
+ 3. 先收症状事实:错误、触发条件、影响面、复现路径。
248
+ 4. 先读现有 change 目录里的 `planning/design.md` / `planning/analysis.md` / `planning/tasks.md` / `planning/task-manifest.json`,不要假设自己是第一位调查者。
249
+ 5. 先读代码、测试、日志、相关 capability spec 和最近提交,再下任何假设。
250
+ 6. 如果复现都不稳定,先不要写根因。
240
251
 
241
252
  ## Investigation Loop
242
253
 
@@ -278,13 +289,13 @@ diagnose-only 仍然写 `planning/analysis.md`,但 `planning/tasks.md` 只能
278
289
  7. **Freeze repair contract**
279
290
  - 先填写 `Root Cause Proof Ladder`:symptom site、first bad state、violated contract、original trigger、counterfactual proof、escape reason
280
291
  - 如果 first bad state、original trigger 或 counterfactual proof 缺失,只能写 `Evidence Request` 或 reroute,不能生成 repair task
281
- - 根因确认后,写进 `planning/analysis.md`
292
+ - 根因确认后,写进 `planning/tasks.md#Root Cause Contract`
282
293
  - 只保留最小修复边界
283
294
  - 写清正确测试缝隙:测试是否覆盖真实触发链;如果没有正确 seam,这本身就是需要记录的架构事实
284
295
  - 写明 affected module、allowed files、forbidden files、blast radius estimate;超过 5 个文件默认拆分或 reroute
285
296
  - 输出 `planning/tasks.md` + `planning/task-manifest.json` + `change-meta.json`
286
297
  8. **Roadmap sync**
287
- - 用 `locate-roadmap-item.sh` 定位 source RM;找不到时在 `analysis.md` 和 `change-meta.json.roadmapSync` 写 `no-source-rm`
298
+ - 用 `locate-roadmap-item.sh` 定位 source RM;找不到时在 `planning/tasks.md#Root Cause Contract` 和 `change-meta.json.roadmapSync` 写 `no-source-rm`
288
299
  - `implementation drift`:回写 source RM 为 `Repair planned` 或等价调查完成状态,绑定 `FIX-*`,进度保持在可执行修复前的真实百分比
289
300
  - `missing spec truth`:回写 source RM 的 expected spec delta 或 follow-up,必要时 reroute 到 `cc-plan`
290
301
  - `roadmap mismatch`:不要直接进入修复;先把 mismatch 写回 roadmap / backlog,下一步写 `roadmap` 或 `cc-plan`
@@ -328,7 +339,7 @@ diagnose-only 仍然写 `planning/analysis.md`,但 `planning/tasks.md` 只能
328
339
 
329
340
  ## Backward Trace Chain
330
341
 
331
- 报错点很深时,不准只在 symptom site 加 guard。`analysis.md` 必须追到:
342
+ 报错点很深时,不准只在 symptom site 加 guard。`planning/tasks.md#Root Cause Contract` 必须追到:
332
343
 
333
344
  - immediate failure site
334
345
  - direct caller
@@ -427,7 +438,7 @@ flaky bug 的目标不是立刻 100% 复现,而是提高复现率直到可调
427
438
  4. 既有 `report-card.json` finding 和 `planning/analysis.md`
428
439
  5. 可用时,查询项目记忆或历史调查摘要
429
440
 
430
- 如果命中过往调查,写入 `analysis.md` 的 `Prior Investigations`,包括是否复发、根因是否同类、这次是否说明结构问题。
441
+ 如果命中过往调查,写入 `planning/tasks.md#Root Cause Contract` 的 `Prior Investigations`,包括是否复发、根因是否同类、这次是否说明结构问题。
431
442
 
432
443
  ## External Research Hygiene
433
444
 
@@ -467,7 +478,7 @@ flaky bug 的目标不是立刻 100% 复现,而是提高复现率直到可调
467
478
 
468
479
  ## Escalation Decision
469
480
 
470
- 三次假设失败后,不准继续硬猜。`analysis.md` 必须写:
481
+ 三次假设失败后,不准继续硬猜。`planning/tasks.md#Root Cause Contract` 必须写:
471
482
 
472
483
  - failedHypothesisCount
473
484
  - what was attempted
@@ -493,7 +504,7 @@ flaky bug 的目标不是立刻 100% 复现,而是提高复现率直到可调
493
504
 
494
505
  - 变更记录:`CHANGELOG.md`
495
506
  - 调查契约:`references/investigation-contract.md`
496
- - 分析模板:`assets/ANALYSIS_TEMPLATE.md`
507
+ - legacy 分析模板:`assets/legacy/ANALYSIS_TEMPLATE.md`
497
508
  - 修复任务模板:`assets/TASKS_TEMPLATE.md`
498
509
  - manifest 模板:`assets/TASK_MANIFEST_TEMPLATE.json`
499
510
  - 分析骨架:`scripts/bootstrap-analysis.sh`
@@ -513,10 +524,11 @@ flaky bug 的目标不是立刻 100% 复现,而是提高复现率直到可调
513
524
  9. 修复触点超过 5 个文件时,默认先拆分或 reroute,不把大重构伪装成 bug fix。
514
525
  10. 好的调查不是“找了很多可能性”,而是把错误世界缩成一个可信的 repair contract。
515
526
  11. Roadmap 相关文件以 `devflow/roadmap.json` 为真相源,`devflow/ROADMAP.md` / `devflow/BACKLOG.md` 只是投影;不要再写旧式 `devflow/roadmap/*` 路径。
527
+ 12. 一个 `FIX` 对应一个 canonical work branch;新调查不在 `main` 上落盘,不把 detached worktree 留到 `cc-act` 才补救。
516
528
 
517
529
  ## Exit Criteria
518
530
 
519
- - `planning/analysis.md` 已冻结症状、复现、证据链、根因和修复边界
531
+ - `planning/tasks.md#Root Cause Contract` 已冻结症状、复现、证据链、根因和修复边界
520
532
  - `planning/tasks.md` / `planning/task-manifest.json` 可直接交给 `cc-do`
521
533
  - Roadmap Sync Gate 已闭合:source RM 已回写调查结果 / reroute,或 no-op reason 已落盘
522
534
  - 下一步唯一答案是 `cc-do`、`cc-plan` 或 `roadmap`
@@ -5,6 +5,7 @@
5
5
  - Requirement version:
6
6
  - Analysis version:
7
7
  - Investigate skill version:
8
+ - Work branch:
8
9
  - Output language:
9
10
  - Source bug / incident:
10
11
  - Roadmap sync status:
@@ -12,14 +13,56 @@
12
13
 
13
14
  ## Progressive Disclosure Index
14
15
 
15
- - Default read: Investigation Meta, Execution Handoff, current task block.
16
- - Open for root-cause doubt: `planning/analysis.md` Project Postmortem Recall, Feedback Loop, Evidence Chain, Boundary Probe Matrix.
16
+ - Default read: Investigation Meta, Root Cause Contract, Execution Handoff, current task block.
17
+ - Runtime reset: run `cc-devflow query workflow-context --change <changeId> --change-key <changeKey> --cwd <repo-root> --data-only --no-trace --compact` before `cc-do`, `cc-check`, or `cc-act`; use `packetOnly` plus `mustNotForget` first, verify `sourceHashes`, open `defaultOpen` refs only when needed, and reserve `deepOpen` for matching `openWhen.conditions`.
18
+ - Open for root-cause doubt: `planning/tasks.md#Root Cause Contract` Project Postmortem Recall, Feedback Loop, Evidence Chain, Boundary Probe Matrix.
17
19
  - Open for scheduling: `planning/task-manifest.json`, dependencies, touched files.
18
- - Open for audit/recovery: checkpoint files, report-card findings, Workflow Forensics.
20
+ - Open for audit/recovery: Git state, CLI logs, report-card findings, Workflow Forensics.
21
+
22
+ ## Root Cause Contract
23
+
24
+ Change:
25
+ Mode: investigation
26
+ Approval:
27
+
28
+ Symptom:
29
+ -
30
+
31
+ Reproduction:
32
+ -
33
+
34
+ Feedback Loop:
35
+ -
36
+
37
+ Root Cause Proof Ladder:
38
+ - Symptom site:
39
+ - First bad state:
40
+ - Violated contract:
41
+ - Original trigger:
42
+ - Counterfactual proof:
43
+ - Escape reason:
44
+
45
+ Confirmed Root Cause:
46
+ -
47
+
48
+ Frozen Repair Boundary:
49
+ - Allowed files:
50
+ - Forbidden files:
51
+ - Blast radius:
52
+
53
+ Verification:
54
+ -
55
+
56
+ Risk / Escalate If:
57
+ -
58
+
59
+ > This is the default human-authored investigation contract. Do not create
60
+ > `planning/analysis.md` for new investigations unless the user explicitly
61
+ > requests a legacy artifact or a migration requires preserving one.
19
62
 
20
63
  ## Execution Handoff
21
64
 
22
- - Canonical analysis: `planning/analysis.md`
65
+ - Canonical contract: `planning/tasks.md#Root Cause Contract`
23
66
  - Canonical change meta: `change-meta.json`
24
67
  - Execution mode: `single-path` | `parallel-ready`
25
68
  - Confirmed root cause:
@@ -68,7 +111,7 @@
68
111
  Read first: `analysis.md`, `path/to/test`
69
112
  Project postmortem search: `rg -n "<root cause|module|failure-class|model-risk>" devflow/postmortems` or record `no-project-postmortems-yet`
70
113
  Verification: `npm test -- path/to/test`
71
- Evidence: passing output + checkpoint
114
+ Evidence: passing output + Git diff
72
115
  Do not re-decide: root cause, first bad state, original trigger, allowed files, forbidden files
73
116
  Ready when: T001 已证明同一个用户症状存在,analysis 已证明根因源头和 counterfactual proof
74
117