@jeiemgi/cckit 0.10.0 → 0.12.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 (193) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +136 -127
  3. package/README.md +66 -43
  4. package/bin/cckit +151 -181
  5. package/cckit.config.json +1 -4
  6. package/package.json +1 -1
  7. package/scripts/advisor-test.sh +55 -0
  8. package/scripts/autopilot-run-test.sh +20 -12
  9. package/scripts/autopilot-run.sh +9 -1
  10. package/scripts/autopilot-test.sh +29 -13
  11. package/scripts/autopilot.sh +4 -4
  12. package/scripts/benchmark/verb-timings-test.sh +4 -0
  13. package/scripts/benchmark/verb-timings.sh +16 -5
  14. package/scripts/capture-project-ids.sh +23 -1
  15. package/scripts/check.sh +25 -0
  16. package/scripts/content-skills-test.sh +1 -1
  17. package/scripts/contribute.sh +8 -3
  18. package/scripts/copilot-loop-test.sh +66 -81
  19. package/scripts/exec-targets-test.sh +20 -0
  20. package/scripts/force-push-fence-test.sh +44 -0
  21. package/scripts/force-push-fence.baseline +1 -0
  22. package/scripts/force-push-fence.sh +51 -0
  23. package/scripts/forge-fence-test.sh +69 -0
  24. package/scripts/forge-fence.baseline +2 -0
  25. package/scripts/forge-fence.sh +76 -0
  26. package/scripts/forge-report-test.sh +100 -0
  27. package/scripts/forge-report.sh +176 -0
  28. package/scripts/init-guided-test.sh +94 -82
  29. package/scripts/init.sh +12 -7
  30. package/scripts/install-test.sh +26 -0
  31. package/scripts/install.sh +7 -0
  32. package/scripts/instruction-budget-baseline.txt +1 -1
  33. package/scripts/kit-doctor-test.sh +60 -12
  34. package/scripts/kit-doctor.sh +170 -77
  35. package/scripts/lib/agent-resolve-test.sh +2 -0
  36. package/scripts/lib/agent-resolve.sh +15 -8
  37. package/scripts/lib/board-view.sh +3 -3
  38. package/scripts/lib/captain.sh +37 -8
  39. package/scripts/lib/content-kinds-gc-test.sh +22 -21
  40. package/scripts/lib/copilot-test.sh +20 -11
  41. package/scripts/lib/copilot.sh +19 -13
  42. package/scripts/lib/effort-close-subs-test.sh +96 -0
  43. package/scripts/lib/effort-dispatch-test.sh +5 -3
  44. package/scripts/lib/effort-metrics-test.sh +7 -12
  45. package/scripts/lib/effort-metrics.sh +17 -46
  46. package/scripts/lib/effort-ops-test.sh +261 -167
  47. package/scripts/lib/effort-ops.sh +449 -171
  48. package/scripts/lib/effort-parity-test.sh +57 -62
  49. package/scripts/lib/effort-plan-test.sh +56 -54
  50. package/scripts/lib/effort-plan.sh +14 -7
  51. package/scripts/lib/effort-review-test.sh +107 -0
  52. package/scripts/lib/effort-review.sh +93 -0
  53. package/scripts/lib/effort-slug-test.sh +34 -14
  54. package/scripts/lib/effort-slug.sh +13 -13
  55. package/scripts/lib/effort.sh +58 -80
  56. package/scripts/lib/forge-github.sh +260 -0
  57. package/scripts/lib/forge-none.sh +24 -0
  58. package/scripts/lib/forge-test.sh +186 -0
  59. package/scripts/lib/forge.sh +133 -0
  60. package/scripts/lib/gh-board-add-test.sh +118 -0
  61. package/scripts/lib/gh-project-test.sh +151 -31
  62. package/scripts/lib/gh-project.sh +139 -11
  63. package/scripts/lib/gh-rest-test.sh +63 -118
  64. package/scripts/lib/gh-rest.sh +275 -52
  65. package/scripts/lib/git-core-test.sh +128 -0
  66. package/scripts/lib/grill-record-test.sh +49 -0
  67. package/scripts/lib/grill-record.sh +88 -0
  68. package/scripts/lib/handoff.sh +1 -1
  69. package/scripts/lib/init-github.sh +38 -13
  70. package/scripts/lib/kinds-test.sh +13 -16
  71. package/scripts/lib/kit-brief-test.sh +51 -10
  72. package/scripts/lib/kit-brief.sh +103 -18
  73. package/scripts/lib/kit-gc-test.sh +90 -109
  74. package/scripts/lib/kit-gc.sh +19 -22
  75. package/scripts/lib/kit-hotfix.sh +18 -16
  76. package/scripts/lib/kit-interview.sh +6 -0
  77. package/scripts/lib/kit-lib-test.sh +1 -1
  78. package/scripts/lib/kit-lib.sh +7 -7
  79. package/scripts/lib/kit-msg.sh +3 -3
  80. package/scripts/lib/kit-status.sh +19 -14
  81. package/scripts/lib/kit-task-ops-test.sh +20 -1
  82. package/scripts/lib/kit-task-ops.sh +177 -94
  83. package/scripts/lib/kto-hotfix-test.sh +53 -58
  84. package/scripts/lib/kto-task-close-test.sh +28 -27
  85. package/scripts/lib/kto-task-new-test.sh +55 -48
  86. package/scripts/lib/kto-task-pr-merge-test.sh +77 -41
  87. package/scripts/lib/kto-task-pr-test.sh +30 -34
  88. package/scripts/lib/light-task-run-test.sh +19 -15
  89. package/scripts/lib/light-task-test.sh +34 -29
  90. package/scripts/lib/light-task.sh +24 -13
  91. package/scripts/lib/loose-issues.sh +65 -0
  92. package/scripts/lib/naming-test.sh +112 -0
  93. package/scripts/lib/naming-verbs-test.sh +126 -0
  94. package/scripts/lib/naming.sh +172 -0
  95. package/scripts/lib/next-test.sh +27 -22
  96. package/scripts/lib/next.sh +13 -7
  97. package/scripts/lib/orchestration-runtime-test.sh +11 -8
  98. package/scripts/lib/plan-machine.sh +22 -16
  99. package/scripts/lib/plan-next.sh +4 -4
  100. package/scripts/lib/pr-evidence-test.sh +63 -74
  101. package/scripts/lib/pr-evidence.sh +15 -12
  102. package/scripts/lib/qa-lane-test.sh +59 -27
  103. package/scripts/lib/qa-lane.sh +14 -6
  104. package/scripts/lib/review-page-test.sh +34 -25
  105. package/scripts/lib/review-page.sh +10 -4
  106. package/scripts/lib/spec-lint-test.sh +63 -0
  107. package/scripts/lib/spec-lint.sh +95 -0
  108. package/scripts/lib/sprint-test.sh +96 -0
  109. package/scripts/lib/sprint.sh +216 -0
  110. package/scripts/lib/stage-receipt-test.sh +169 -19
  111. package/scripts/lib/stage-receipt.sh +195 -10
  112. package/scripts/lib/test-forge-shim.sh +115 -0
  113. package/scripts/lib/verbs.sh +105 -0
  114. package/scripts/lib/verbs.tsv +92 -0
  115. package/scripts/lib/version-bump-test.sh +20 -0
  116. package/scripts/lib/version-bump.sh +4 -2
  117. package/scripts/lib/worker-brief-test.sh +1 -1
  118. package/scripts/lib/worker-brief.sh +1 -1
  119. package/scripts/lib/worktree-issue-test.sh +24 -19
  120. package/scripts/lib/worktree-issue.sh +10 -10
  121. package/scripts/lib/worktree-start-test.sh +13 -16
  122. package/scripts/lib/worktree-start.sh +57 -7
  123. package/scripts/loose-issues-test.sh +102 -0
  124. package/scripts/loose-issues.baseline +5 -0
  125. package/scripts/marketing-walkthrough-test.sh +25 -30
  126. package/scripts/night-grant.sh +14 -8
  127. package/scripts/night-run.mjs +1 -1
  128. package/scripts/orchestrate-test.sh +27 -31
  129. package/scripts/orchestrate.sh +9 -3
  130. package/scripts/portable-test.sh +37 -36
  131. package/scripts/publish.sh +9 -3
  132. package/scripts/setup-labels.sh +23 -12
  133. package/scripts/setup-milestones.sh +8 -2
  134. package/scripts/status-test.sh +39 -33
  135. package/scripts/status.sh +12 -6
  136. package/scripts/task-sync-test.sh +75 -32
  137. package/scripts/task-sync.sh +97 -6
  138. package/scripts/terms-check-test.sh +191 -0
  139. package/scripts/terms-check.sh +242 -0
  140. package/scripts/verbs-gen.sh +43 -0
  141. package/scripts/verbs-help-test.sh +61 -0
  142. package/scripts/verbs-ratchet-test.sh +69 -0
  143. package/scripts/verbs-ratchet.sh +34 -0
  144. package/scripts/verbs-test.sh +120 -0
  145. package/scripts/verbs.baseline +5 -0
  146. package/skills/kit-add/SKILL.md +2 -1
  147. package/skills/kit-advisor/SKILL.md +75 -0
  148. package/skills/kit-advisor/references/close.md +53 -0
  149. package/skills/kit-advisor/references/grill.md +69 -0
  150. package/skills/kit-advisor/references/orchestrate.md +56 -0
  151. package/skills/kit-advisor/references/plan.md +64 -0
  152. package/skills/kit-advisor/references/review.md +47 -0
  153. package/skills/kit-advisor/references/step-report.md +61 -0
  154. package/skills/kit-annotate/SKILL.md +1 -0
  155. package/skills/kit-autopilot/SKILL.md +2 -1
  156. package/skills/kit-cleanup/SKILL.md +3 -2
  157. package/skills/kit-contribute/SKILL.md +1 -0
  158. package/skills/kit-customize/SKILL.md +1 -0
  159. package/skills/kit-dev/SKILL.md +1 -0
  160. package/skills/kit-digest/SKILL.md +1 -0
  161. package/skills/kit-docs-writer/SKILL.md +4 -3
  162. package/skills/kit-effort-close/SKILL.md +18 -9
  163. package/skills/kit-effort-new/SKILL.md +12 -8
  164. package/skills/kit-effort-pr/SKILL.md +8 -7
  165. package/skills/kit-effort-start/SKILL.md +1 -0
  166. package/skills/kit-gc/SKILL.md +1 -0
  167. package/skills/kit-next/SKILL.md +8 -7
  168. package/skills/kit-onboard/SKILL.md +1 -0
  169. package/skills/kit-page/SKILL.md +1 -0
  170. package/skills/kit-plan-next/SKILL.md +11 -11
  171. package/skills/kit-security-sweep/SKILL.md +1 -0
  172. package/skills/kit-ship/SKILL.md +1 -0
  173. package/skills/kit-status/SKILL.md +6 -5
  174. package/skills/kit-task-close/SKILL.md +1 -0
  175. package/skills/kit-task-new/SKILL.md +1 -0
  176. package/skills/kit-task-pr/SKILL.md +1 -0
  177. package/skills/kit-task-pr-auto/SKILL.md +2 -1
  178. package/skills/kit-task-pr-merge/SKILL.md +4 -3
  179. package/skills/kit-task-start/SKILL.md +1 -0
  180. package/skills/kit-task-sync/SKILL.md +3 -0
  181. package/skills/kit-ux-audit/SKILL.md +1 -0
  182. package/skills/routing.yaml +124 -0
  183. package/templates/hooks/kit-mail-check.sh.tmpl +1 -1
  184. package/templates/instructions.md.tmpl +3 -3
  185. package/templates/rules/authoring.md +7 -3
  186. package/templates/rules/delegation-brief.md +4 -0
  187. package/templates/rules/effort-model.md +34 -31
  188. package/templates/rules/gate-and-review.md +1 -1
  189. package/templates/rules/merge-safety.md +9 -7
  190. package/templates/rules/naming-and-ids.md +20 -24
  191. package/templates/rules/plan-next.md +5 -5
  192. package/templates/skills/campaign/SKILL.md +2 -2
  193. package/scripts/lib/engine-adapter.sh +0 -93
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env bash
2
2
  # shellcheck shell=bash
3
- # effort-ops-test.sh — covers the effort lifecycle ops (#48). Hermetic: stubs gh (no network/auth)
4
- # and uses a throwaway git repo with a bare remote. Run: bash scripts/lib/effort-ops-test.sh
3
+ # effort-ops-test.sh — covers the effort lifecycle ops (#48). Hermetic: the forge shim
4
+ # (test-forge-shim.sh) answers like the REST API over a curl stand-in and logs `METHOD path {json}`;
5
+ # a throwaway git repo with a bare remote. Run: bash scripts/lib/effort-ops-test.sh
5
6
  # errors: strict — a test runner: rc 1 on any failed assertion
6
7
  set -u
7
8
  ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
@@ -17,43 +18,41 @@ command -v jq >/dev/null 2>&1 || { echo "effort-ops-test: jq required" >&2; ex
17
18
  command -v git >/dev/null 2>&1 || { echo "effort-ops-test: git required" >&2; exit 1; }
18
19
 
19
20
  tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
20
- export GH_LOG="$tmp/gh.log"; export GH_N="$tmp/n"; : > "$GH_LOG"
21
+ export GH_LOG="$tmp/gh.log"; export GH_N="$tmp/n"; : > "$GH_LOG"; printf '0' > "$GH_N"
21
22
 
22
- # Stub gh: log every call, return canned output keyed on the subcommand.
23
- stub="$tmp/bin"; mkdir -p "$stub"
24
- cat > "$stub/gh" <<'SH'
25
- #!/usr/bin/env bash
26
- echo "$*" >> "$GH_LOG"
27
- case "$1 $2" in
28
- "issue create") n=$(( $(cat "$GH_N" 2>/dev/null || echo 0) + 1 )); echo "$n" > "$GH_N"
29
- echo "https://github.com/o/r/issues/$n" ;;
30
- "issue edit"|"issue close"|"pr merge") exit 0 ;;
31
- "issue view") case "$*" in # effort_pr reads title+labels+milestone
32
- *labels,milestone*) echo '{"title":"[Effort] 99 · demo effort","labels":[{"name":"role:tech-lead"},{"name":"kind:task"}],"milestone":{"title":"M1"}}' ;;
33
- *) echo "[Effort] 99 · demo effort" ;; # --json title -q .title
34
- esac ;;
35
- "pr create") echo "https://github.com/o/r/pull/7" ;;
36
- "pr view") echo "${GH_MERGEABLE:-MERGEABLE}" ;; # --json mergeable (#394)
37
- "pr list") echo "${GH_DEP_PRS:-[]}" ;; # open PRs based on the effort branch (#358)
38
- "pr edit") exit "${GH_PR_EDIT_RC:-0}" ;; # re-target a dependent PR (#358)
39
- "pr diff") # a merged sub PR's diff (wave-style close, #164): one kit-managed + one app file
40
- # + one project-owned rule, which the drift check must NOT name (#218)
41
- printf 'diff --git a/.claude/skills/demo.md b/.claude/skills/demo.md\n+kit\ndiff --git a/src/app.ts b/src/app.ts\n+app\ndiff --git a/.claude/rules/project-owned.md b/.claude/rules/project-owned.md\n+own\n' ;;
42
- "api "*|"api")
43
- case "$*" in
44
- *"--method POST"*"/sub_issues"*) exit 0 ;; # link a sub
45
- *"/sub_issues"*".[].number"*) printf '101\n102\n' ;; # list subs (for close)
46
- # wave-style close (#164): per-sub "sub|state|pr|merge-oid|title" rows by parent number
47
- *closedByPullRequestsReferences*n=77*) printf '301|CLOSED|501|abc1234def|first sub\n302|CLOSED|502|bcd2345eab|second sub\n' ;;
48
- *closedByPullRequestsReferences*n=78*) printf '201|CLOSED|401|abc1234def|done sub\n202|OPEN|||still open sub\n' ;;
49
- *".id"*) echo "55501" ;; # issue db id
50
- *) exit 0 ;;
51
- esac ;;
52
- *) exit 0 ;;
23
+ # The forge shim: a `curl` that answers like the REST API from the GH_* knobs and logs one line per
24
+ # request, plus a `gh` that fails on any subcommand (a leftover gh call is a red test). The issue
25
+ # effort_pr reads is #99 (GH_TITLE/GH_LABELS); its PR is #9 from effort/99-demo onto main.
26
+ stub="$tmp/bin"
27
+ # shellcheck source=/dev/null
28
+ . "$LIB/test-forge-shim.sh"; forge_shim_install "$stub"
29
+ export PATH="$stub:$PATH" GH_TOKEN=test-token CCKIT_FORGE=github
30
+ export GH_TITLE="[Effort] 99 · demo effort" GH_LABELS='[{"name":"role:tech-lead"},{"name":"kind:task"}]'
31
+ export GH_HEAD="effort/99-demo" GH_BASE="main" GH_MERGEABLE=true
32
+ # The parent body every GET issues/<n> answers (JSON-escaped): it carries a Spec, so effort_close
33
+ # goes past its Spec check (E546.5). The Spec cases below override it.
34
+ SPEC_BODY='## Goal\nship it\n\n## Spec\n- it ships'
35
+ export GH_BODY="$SPEC_BODY"
36
+ # What the shim does not know, answered by request (GH_FIXTURE is sourced after the shim's own case):
37
+ # GH_DEP_PRS the open PRs based on the effort branch (REST shape), to GET pulls?base=… (#358)
38
+ # GH_DEP_PRS_RC an HTTP status that makes that read fail · GH_PR_EDIT_RC=1 fails the re-target PATCH
39
+ # the sub-issues of #77 are 301 + 302 (both closed), of #78 201 (closed) + 202 (still open) (#164)
40
+ export GH_FIXTURE="$tmp/fixture.sh"
41
+ cat > "$GH_FIXTURE" <<'SH'
42
+ case "$method $ep" in
43
+ "GET repos/o/r/pulls")
44
+ case "$path" in *base=*) out="${GH_DEP_PRS:-[]}"; [ "${GH_DEP_PRS_RC:-200}" = 200 ] || code="$GH_DEP_PRS_RC" ;; esac ;;
45
+ "PATCH repos/o/r/pulls/"*) [ "${GH_PR_EDIT_RC:-0}" = 0 ] || code=422 ;;
46
+ "GET repos/o/r/issues/77/sub_issues") out='[{"number":301,"state":"closed"},{"number":302,"state":"closed"}]' ;;
47
+ "GET repos/o/r/issues/78/sub_issues") out='[{"number":201,"state":"closed"},{"number":202,"state":"open"}]' ;;
53
48
  esac
54
49
  SH
55
- chmod +x "$stub/gh"
56
- export PATH="$stub:$PATH"
50
+ # The REST lines the lifecycle leaves in the log.
51
+ MERGE_RE='^PUT repos/o/r/pulls/[0-9]+/merge '
52
+ CLOSE_RE='^PATCH repos/o/r/issues/[0-9]+ \{"state":"closed"'
53
+ CREATE_RE='^POST repos/o/r/issues '
54
+ PR_RE='^POST repos/o/r/pulls '
55
+ no_gh() { t "$1: no gh subcommand ran" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0"; }
57
56
  export KIT_REPO="o/r" EFFORT_REPO="o/r" KIT_BASE_BRANCH="main"
58
57
  export KIT_WT_INSTALL=0 # #119: skip the dependency install during the hermetic worktree bootstrap
59
58
  # shellcheck source=/dev/null
@@ -63,21 +62,81 @@ source "$LIB/effort-ops.sh"
63
62
 
64
63
  # ── effort_new ────────────────────────────────────────────────────────────────────────────────
65
64
  : > "$GH_LOG"
66
- parent="$(effort_new --flow Core "demo effort" "first sub" "second sub" 2>/dev/null)"
65
+ parent="$(effort_new --flow Core --spec "it ships" "demo effort" "first sub" "second sub" 2>/dev/null)"
67
66
  t "effort_new returns the parent number" "$parent" "1"
68
- t "effort_new creates parent + 2 subs (3 issues)" "$(grep -c 'issue create' "$GH_LOG")" "3"
69
- t "effort_new links 2 native sub-issues" "$(grep -c 'method POST .*sub_issues' "$GH_LOG")" "2"
70
- tc "$GH_LOG" 'issue create .*--title \[Effort\] · \[Core\] demo effort' "effort_new titles the parent"
67
+ t "effort_new creates parent + 2 subs (3 issues)" "$(grep -cE "$CREATE_RE" "$GH_LOG")" "3"
68
+ t "effort_new links 2 native sub-issues" "$(grep -c '^POST repos/o/r/issues/1/sub_issues ' "$GH_LOG")" "2"
69
+ tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"demo effort"' "effort_new files the parent under its name"
70
+ tc "$GH_LOG" '^PATCH repos/o/r/issues/1 \{"title":"\[E1\] demo effort"\}$' "effort_new renames the parent [E<n>] <name>, no [Flow] tag"
71
+ tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"\[E1\.2\] second sub"' "effort_new titles a sub [E<n>.<step>] <name>"
71
72
  # every kit-defined label is ensured (created idempotently) BEFORE the issue create uses it (#153)
72
- tc "$GH_LOG" 'label create ctx:' "effort_new ensures the ctx:* label exists"
73
- tc "$GH_LOG" 'label create kind:task' "effort_new ensures the kind label exists"
74
- tc "$GH_LOG" 'label create priority:p1' "effort_new ensures the priority label exists"
75
- tc "$GH_LOG" 'label create flow:core' "effort_new ensures the flow label exists"
73
+ tc "$GH_LOG" '^POST repos/o/r/labels \{"name":"ctx:' "effort_new ensures the ctx:* label exists"
74
+ tc "$GH_LOG" '^POST repos/o/r/labels \{"name":"kind:task"' "effort_new ensures the kind label exists"
75
+ tc "$GH_LOG" '^POST repos/o/r/labels \{"name":"priority:p1"' "effort_new ensures the priority label exists"
76
+ tc "$GH_LOG" '^POST repos/o/r/labels \{"name":"flow:core"' "effort_new ensures the flow label exists"
77
+ no_gh "effort_new"
76
78
  # a jargon/long name is rejected before any issue is created
77
79
  : > "$GH_LOG"
78
80
  effort_new "refactor the whole scripts/kit wiring layer" >/dev/null 2>&1 && rc=0 || rc=1
79
81
  t "effort_new rejects a bad title" "$rc" "1"
80
- t "effort_new creates nothing on a bad title" "$(grep -c 'issue create' "$GH_LOG")" "0"
82
+ t "effort_new creates nothing on a bad title" "$(grep -cE "$CREATE_RE" "$GH_LOG")" "0"
83
+
84
+ # ── E546.5: the ## Spec section — checked before any forge write ──────────────────────────────
85
+ : > "$GH_LOG"
86
+ err="$(effort_new "demo effort" "first sub" 2>&1 >/dev/null)" && rc=0 || rc=1
87
+ t "effort_new refuses a body without a Spec" "$rc" "1"
88
+ t "effort_new writes nothing without a Spec" "$(grep -c . "$GH_LOG")" "0"
89
+ case "$err" in *"no list item"*"--spec"*) echo "ok: the refusal gives the reason and the flag" ;; *) echo "FAIL: no-Spec refusal: $err"; fail=1 ;; esac
90
+ : > "$GH_LOG"
91
+ effort_new --spec "TBD" "demo effort" >/dev/null 2>&1 && rc=0 || rc=1
92
+ t "effort_new refuses a placeholder-only Spec" "$rc" "1"
93
+ t "effort_new writes nothing on a placeholder" "$(grep -c . "$GH_LOG")" "0"
94
+ : > "$GH_LOG"
95
+ effort_new --spec-file "$tmp/no-such-spec" "demo effort" >/dev/null 2>&1 && rc=0 || rc=1
96
+ t "effort_new refuses an unreadable --spec-file" "$rc" "1"
97
+ t "effort_new writes nothing on that refusal" "$(grep -c . "$GH_LOG")" "0"
98
+ printf '1. new refuses without it\n2. close re-checks it\n' > "$tmp/spec.md"
99
+ : > "$GH_LOG"
100
+ effort_new --spec-file "$tmp/spec.md" "demo effort" >/dev/null 2>&1 && rc=0 || rc=1
101
+ t "effort_new takes the Spec from --spec-file" "$rc" "0"
102
+ tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"demo effort","body":"## Goal\\n[^"]*\\n\\n## Spec\\n1\. new refuses without it\\n2\. close re-checks it\\n\\n## Scope' \
103
+ "the Spec section sits after Goal, the list kept as written"
104
+ : > "$GH_LOG"
105
+ effort_sub 99 "third step" --spec "TODO" >/dev/null 2>&1 && rc=0 || rc=1
106
+ t "effort_sub refuses a placeholder --spec" "$rc" "1"
107
+ t "effort_sub writes nothing on that refusal" "$(grep -c . "$GH_LOG")" "0"
108
+ : > "$GH_LOG"
109
+ GH_LABELS='[{"name":"effort"},{"name":"kind:task"}]' effort_sub 99 "third step" --body "one line" --spec "the step lands" >/dev/null 2>&1
110
+ tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"\[E99\.3\] third step","body":"one line\\n\\n## Spec\\n- the step lands\\n\\nSub-issue of #99' \
111
+ "effort_sub --spec adds a one-line Spec to the sub body"
112
+
113
+ # ── E547.2: the ## Grilling record — linted before any forge write, appended last ───────────────
114
+ : > "$GH_LOG"
115
+ err="$(effort_new --spec "it ships" --grilling "1. only one decision" "demo effort" 2>&1 >/dev/null)" && rc=0 || rc=1
116
+ t "effort_new refuses a Grilling record that is not one" "$rc" "1"
117
+ t "effort_new writes nothing on a bad Grilling record" "$(grep -c . "$GH_LOG")" "0"
118
+ case "$err" in *"Grilled:"*"--grilling"*) echo "ok: the Grilling refusal names the missing line and the flag" ;; *) echo "FAIL: Grilling refusal: $err"; fail=1 ;; esac
119
+ printf 'Grilled: the owner, 2026-11-24, in session.\n1. a sprint is one week\n2. waves run inside it\n3. the advisor writes no code\n' > "$tmp/grill.md"
120
+ : > "$GH_LOG"
121
+ effort_new --spec "it ships" --grilling-file "$tmp/grill.md" "demo effort" >/dev/null 2>&1 && rc=0 || rc=1
122
+ t "effort_new accepts the grill stage's record" "$rc" "0"
123
+ tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"demo effort","body":"## Goal[^"]*## Verification\\n[^"]*\\n\\n## Grilling\\n\\nGrilled: the owner, 2026-11-24, in session\.\\n1\. a sprint is one week' \
124
+ "the Grilling section closes the body, the record kept as written"
125
+ : > "$GH_LOG"
126
+ effort_new --spec "it ships" --grilling-file "$tmp/no-such-grill" "demo effort" >/dev/null 2>&1 && rc=0 || rc=1
127
+ t "effort_new refuses an unreadable --grilling-file" "$rc" "1"
128
+
129
+ # ── #570: --sprint files the effort into a week's sprint ────────────────────────────────────────
130
+ : > "$GH_LOG"
131
+ effort_new --spec "it ships" --sprint=2026-11-25 "demo effort" >/dev/null 2>&1 && rc=0 || rc=1
132
+ t "effort_new --sprint=<day> files the effort" "$rc" "0"
133
+ tc "$GH_LOG" '^POST repos/o/r/milestones \{"title":"2026-W48"' "effort_new --sprint opens the sprint milestone"
134
+ tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"demo effort","body":"[^"]*\\n\\n## Sprint\\n2026-W48 · Monday 2026-11-23 to Monday 2026-11-30"' \
135
+ "the body names the sprint and its Monday-to-Monday bounds"
136
+ : > "$GH_LOG"
137
+ effort_new --spec "it ships" --sprint=2026-11-25 --milestone v1 "demo effort" >/dev/null 2>&1 && rc=0 || rc=1
138
+ t "effort_new refuses --sprint with another --milestone" "$rc" "1"
139
+ t "effort_new writes nothing on that refusal" "$(grep -c . "$GH_LOG")" "0"
81
140
 
82
141
  # ── effort_start / effort_pr / effort_close (real git + bare remote) ───────────────────────────
83
142
  ( cd "$tmp" && git init -q --bare remote.git )
@@ -110,14 +169,16 @@ t "re-running effort_start keeps the start stamp" "$(cat "$start_stamp" 2>/dev/
110
169
  cd "$tmp/work/.claude/worktrees/effort+99-demo"
111
170
  : > "$GH_LOG"
112
171
  effort_pr 99 --summary "SUMMARY-MARKER" --for-agents "AGENTS-MARKER" >/dev/null 2>&1
113
- tc "$GH_LOG" 'pr create .*--base main --head effort/99-demo' "effort_pr opens effort/99 → main"
172
+ tc "$GH_LOG" '^POST repos/o/r/pulls \{"title":"[^"]*","head":"effort/99-demo","base":"main"' "effort_pr opens effort/99 → main"
114
173
  # #363: parity with the kit-effort-pr skill — the verb is the one implementation.
115
- tc "$GH_LOG" 'pr create .*--title feat: demo effort \[#99\]' "effort_pr titles with a conventional subject + the [#N] id"
116
- tc "$GH_LOG" '[-]-label role:tech-lead,kind:task' "effort_pr inherits the parent's labels"
117
- tc "$GH_LOG" '[-]-milestone M1' "effort_pr inherits the parent's milestone"
118
- tc "$GH_LOG" 'SUMMARY-MARKER' "effort_pr puts --summary in the body"
119
- tc "$GH_LOG" 'AGENTS-MARKER' "effort_pr puts --for-agents in the body"
120
- tc "$GH_LOG" '^Closes #99$' "effort_pr body closes the parent"
174
+ tc "$GH_LOG" '^POST repos/o/r/pulls \{"title":"feat: demo effort \[E99\]"' "effort_pr titles with a conventional subject + the [#N] id"
175
+ # labels, milestone (M1 is milestone 3 in the shim) and the author land in ONE PATCH on the PR
176
+ tc "$GH_LOG" '^PATCH repos/o/r/issues/7 \{"labels":\["role:tech-lead","kind:task"\]' "effort_pr inherits the parent's labels"
177
+ tc "$GH_LOG" '^PATCH repos/o/r/issues/7 \{.*"milestone":3\}$' "effort_pr inherits the parent's milestone"
178
+ tc "$GH_LOG" '^POST repos/o/r/pulls \{.*SUMMARY-MARKER' "effort_pr puts --summary in the body"
179
+ tc "$GH_LOG" '^POST repos/o/r/pulls \{.*AGENTS-MARKER' "effort_pr puts --for-agents in the body"
180
+ tc "$GH_LOG" '^POST repos/o/r/pulls \{.*\\nCloses #99(\\n|")' "effort_pr body closes the parent"
181
+ no_gh "effort_pr"
121
182
  t "effort_pr never commits an untracked .env.local" "$(git ls-files .env.local)" ""
122
183
  # #418: pr.bodyStyle = content swaps the Verification checklist for a Review one; the machine line,
123
184
  # the summary and the For agents block stay.
@@ -131,24 +192,47 @@ t "effort body (content) drops the code wording" "$(printf '%s\n' "$eb" | grep
131
192
  : > "$GH_LOG"
132
193
  effort_pr 99 --title "feat(x): a conventional title" >/dev/null 2>&1 && rc=0 || rc=1
133
194
  t "effort_pr refuses a --title without the [#N] id" "$rc" "1"
134
- t "effort_pr opened nothing on a bad --title" "$(grep -c 'pr create' "$GH_LOG")" "0"
195
+ t "effort_pr opened nothing on a bad --title" "$(grep -cE "$PR_RE" "$GH_LOG")" "0"
135
196
  effort_pr 99 --title "feat(x): a conventional title [#99]" >/dev/null 2>&1
136
- tc "$GH_LOG" 'pr create .*--title feat\(x\): a conventional title \[#99\]' "effort_pr honours --title"
197
+ tc "$GH_LOG" '^POST repos/o/r/pulls \{"title":"feat\(x\): a conventional title \[#99\]"' "effort_pr honours --title"
137
198
  # #237: a title the commitlint gate would reject never reaches gh — built or passed in.
138
199
  : > "$GH_LOG"
139
200
  effort_pr 99 --type bogus >/dev/null 2>&1 && rc=0 || rc=1
140
201
  t "effort_pr refuses a built title that fails commitlint" "$rc" "1"
141
- t "effort_pr opened nothing on a non-conventional built title" "$(grep -c 'pr create' "$GH_LOG")" "0"
202
+ t "effort_pr opened nothing on a non-conventional built title" "$(grep -cE "$PR_RE" "$GH_LOG")" "0"
142
203
  : > "$GH_LOG"
143
204
  effort_pr 99 --title "[Tech Lead] [#99] demo effort" >/dev/null 2>&1 && rc=0 || rc=1
144
205
  t "effort_pr refuses a non-conventional --title" "$rc" "1"
145
- t "effort_pr opened nothing on a non-conventional --title" "$(grep -c 'pr create' "$GH_LOG")" "0"
206
+ t "effort_pr opened nothing on a non-conventional --title" "$(grep -cE "$PR_RE" "$GH_LOG")" "0"
146
207
  : > "$GH_LOG"
147
208
  effort_pr 99 --type fix >/dev/null 2>&1
148
- tc "$GH_LOG" 'pr create .*--title fix: demo effort \[#99\]' "effort_pr --type sets the conventional type"
209
+ tc "$GH_LOG" '^POST repos/o/r/pulls \{"title":"fix: demo effort \[E99\]"' "effort_pr --type sets the conventional type"
149
210
  : > "$GH_LOG"
150
211
  KIT_PR_TITLE_STYLE=issue-title effort_pr 99 >/dev/null 2>&1
151
- tc "$GH_LOG" 'pr create .*--title \[#99\] demo effort' "effort_pr issue-title style keeps the [#N] name form, no commitlint refusal"
212
+ tc "$GH_LOG" '^POST repos/o/r/pulls \{"title":"(\[Tech Lead\] )?\[#99\] demo effort"' "effort_pr issue-title style keeps the [#N] name form, no commitlint refusal"
213
+
214
+ # ── effort_close E546.5: the parent's Spec is re-read and checked before anything else ─────────
215
+ : > "$GH_LOG"
216
+ close_out="$(GH_BODY='## Goal\nship it' effort_close 99 2>&1)"; rc=$?
217
+ t "effort_close refuses a parent without a Spec (rc 1)" "$rc" "1"
218
+ case "$close_out" in *"no '## Spec' section"*"--no-spec-check"*) echo "ok: the Spec refusal gives the reason and the escape" ;; *) echo "FAIL: Spec refusal message: $close_out"; fail=1 ;; esac
219
+ t "effort_close merged nothing on a missing Spec" "$(grep -cE "$MERGE_RE" "$GH_LOG")" "0"
220
+ t "effort_close only read the parent on a missing Spec" "$(grep -vc '^GET repos/o/r/issues/99 ' "$GH_LOG")" "0"
221
+ : > "$GH_LOG"
222
+ close_out="$(GH_BODY='## Spec\n- TODO' effort_close 99 2>&1)"; rc=$?
223
+ t "effort_close refuses a placeholder-only Spec (rc 1)" "$rc" "1"
224
+ : > "$GH_LOG"
225
+ close_out="$(GH_FAIL_EP="repos/o/r/issues/99" effort_close 99 2>&1)"; rc=$?
226
+ t "effort_close refuses when the body cannot be read (rc 1)" "$rc" "1"
227
+ case "$close_out" in *"could not read #99"*) echo "ok: an unread body is not a checked one" ;; *) echo "FAIL: unread-body message: $close_out"; fail=1 ;; esac
228
+ # --no-spec-check skips the check, says so in one line, and the close goes on to its next gate
229
+ # (here the trace backstop below, since the branch has no commits yet).
230
+ : > "$GH_LOG"
231
+ close_out="$(GH_BODY='## Goal\nship it' effort_close 99 --no-spec-check 2>&1)"; rc=$?
232
+ t "effort_close --no-spec-check prints one skip notice" "$(printf '%s\n' "$close_out" | grep -c 'Spec check skipped for #99 (--no-spec-check)')" "1"
233
+ case "$close_out" in *"refusing to squash"*) echo "ok: --no-spec-check passes the Spec check" ;; *) echo "FAIL: --no-spec-check did not pass: $close_out"; fail=1 ;; esac
234
+ t "effort_close --no-spec-check does not read the body" "$(grep -c '^GET repos/o/r/issues/99 ' "$GH_LOG")" "0"
235
+ effort_close 99 --bogus >/dev/null 2>&1; t "effort_close refuses an unknown flag (rc 2)" "$?" "2"
152
236
 
153
237
  # ── effort_close #120: refuse-squash-without-trace backstop ────────────────────────────────────
154
238
  # With NO commits on the effort branch, effort_snapshot_subs captures no trace → close must refuse
@@ -157,7 +241,7 @@ tc "$GH_LOG" 'pr create .*--title \[#99\] demo effort' "effort_pr issue-title st
157
241
  close_out="$(effort_close 99 2>&1)"; rc=$?
158
242
  t "effort_close refuses without a trace (rc 1)" "$rc" "1"
159
243
  case "$close_out" in *"refusing to squash"*) echo "ok: refuse message explains itself" ;; *) echo "FAIL: refuse message: $close_out"; fail=1 ;; esac
160
- t "effort_close did NOT merge without a trace" "$(grep -c 'pr merge' "$GH_LOG")" "0"
244
+ t "effort_close did NOT merge without a trace" "$(grep -cE "$MERGE_RE" "$GH_LOG")" "0"
161
245
 
162
246
  # ── effort_close #120: happy path — commit present → trace captured → full close ────────────────
163
247
  # A real commit on the effort branch gives snapshot something to trace; close then proceeds through
@@ -190,22 +274,22 @@ close_out="$(PREHOOK_RC=1 KIT_CONFIG="$tmp/prehook-config.json" effort_close 99
190
274
  t "pre-close hook: a failing hook refuses the close (rc 1)" "$rc" "1"
191
275
  case "$close_out" in *"PREHOOK-SAYS: gate output"*) echo "ok: pre-close hook: the hook's output is printed" ;; *) echo "FAIL: pre-close hook output missing: $close_out"; fail=1 ;; esac
192
276
  case "$close_out" in *"pre-close hook"*"refus"*) echo "ok: pre-close hook: the refusal names the hook" ;; *) echo "FAIL: pre-close refusal message: $close_out"; fail=1 ;; esac
193
- t "pre-close hook: a failing hook merges nothing" "$(grep -c 'pr merge' "$GH_LOG")" "0"
277
+ t "pre-close hook: a failing hook merges nothing" "$(grep -cE "$MERGE_RE" "$GH_LOG")" "0"
194
278
  t "pre-close hook: a failing hook writes no trace" \
195
279
  "$(ls "$(git rev-parse --git-common-dir)/traces/effort-99" 2>/dev/null | grep -cE '(\.diff|\.meta|index\.jsonl)$')" "0"
196
280
  # a configured hook that is missing is a gate that cannot run — refuse rather than skip it
197
281
  : > "$GH_LOG"
198
282
  close_out="$(KIT_EFFORT_PRE_CLOSE_HOOK="$stub/no-such-hook" effort_close 99 2>&1)"; rc=$?
199
283
  t "pre-close hook: a missing hook refuses the close (rc 1)" "$rc" "1"
200
- t "pre-close hook: a missing hook merges nothing" "$(grep -c 'pr merge' "$GH_LOG")" "0"
284
+ t "pre-close hook: a missing hook merges nothing" "$(grep -cE "$MERGE_RE" "$GH_LOG")" "0"
201
285
  rm -f "$PREHOOK_MARKER" "$PREHOOK_MARKER.cwd"
202
286
  PREHOOK_WT="$(pwd -P)"
203
287
 
204
288
  # ── effort_close #394: a CONFLICTING PR is refused before the metrics capture writes a row ──────
205
289
  : > "$GH_LOG"
206
- close_out="$(GH_MERGEABLE=CONFLICTING effort_close 99 2>&1)"; rc=$?
290
+ close_out="$(GH_MERGEABLE=false effort_close 99 2>&1)"; rc=$?
207
291
  t "effort_close refuses a conflicting PR (rc 1)" "$rc" "1"
208
- t "effort_close did NOT merge a conflicting PR" "$(grep -c 'pr merge' "$GH_LOG")" "0"
292
+ t "effort_close did NOT merge a conflicting PR" "$(grep -cE "$MERGE_RE" "$GH_LOG")" "0"
209
293
  case "$close_out" in
210
294
  *"metrics:"*) echo "FAIL: metrics captured before the conflict refusal"; fail=1 ;;
211
295
  *"nothing was written"*) echo "ok: conflict refused before the metrics capture" ;;
@@ -213,8 +297,10 @@ case "$close_out" in
213
297
  esac
214
298
 
215
299
  # ── effort_close #358: open PRs based on the effort branch are re-targeted before it is deleted ──
216
- # The selector is pure: `gh pr list --json number,baseRefName` in, the PR numbers on <branch> out.
300
+ # The selector is pure: the `{number, baseRefName}` rows read from GET pulls?base=… in, the PR
301
+ # numbers on <branch> out. DEPS_REST is the same list as the API answers it (the fixture's shape).
217
302
  DEPS='[{"number":41,"baseRefName":"effort/99-demo"},{"number":42,"baseRefName":"main"},{"number":43,"baseRefName":"effort/99-demo"}]'
303
+ DEPS_REST='[{"number":41,"base":{"ref":"effort/99-demo"}},{"number":42,"base":{"ref":"main"}},{"number":43,"base":{"ref":"effort/99-demo"}}]'
218
304
  t "_eo_dependent_prs keeps only the PRs based on the branch" \
219
305
  "$(printf '%s' "$DEPS" | _eo_dependent_prs effort/99-demo | tr '\n' ' ')" "41 43 "
220
306
  t "_eo_dependent_prs: no dependents → no output" "$(printf '[]' | _eo_dependent_prs effort/99-demo)" ""
@@ -225,20 +311,20 @@ t "_eo_dependent_prs: a prefix-sharing branch is not a match" \
225
311
  records="$(git rev-parse --git-common-dir)/effort-metrics/records.jsonl"
226
312
  rows_before="$(cat "$records" 2>/dev/null | wc -l | tr -d ' ')"
227
313
  : > "$GH_LOG"
228
- close_out="$(GH_DEP_PRS="$DEPS" GH_PR_EDIT_RC=1 effort_close 99 2>&1)"; rc=$?
314
+ close_out="$(GH_DEP_PRS="$DEPS_REST" GH_PR_EDIT_RC=1 effort_close 99 2>&1)"; rc=$?
229
315
  t "effort_close refuses when a dependent PR cannot be re-targeted (rc 1)" "$rc" "1"
230
- t "effort_close did NOT merge after a failed re-target" "$(grep -c 'pr merge' "$GH_LOG")" "0"
316
+ t "effort_close did NOT merge after a failed re-target" "$(grep -cE "$MERGE_RE" "$GH_LOG")" "0"
231
317
  t "effort_close appended no metrics row on that refusal" "$(cat "$records" 2>/dev/null | wc -l | tr -d ' ')" "$rows_before"
232
318
  case "$close_out" in
233
319
  *"metrics:"*) echo "FAIL: metrics captured before the re-target refusal"; fail=1 ;;
234
320
  *"PR 41"*"nothing was merged"*) echo "ok: re-target refusal names the PR" ;;
235
321
  *) echo "FAIL: re-target refusal message: $close_out"; fail=1 ;;
236
322
  esac
237
- # `gh pr list` failing is not "no dependents": the close refuses instead of deleting blind.
323
+ # A failed GET pulls?base=… is not "no dependents": the close refuses instead of deleting blind.
238
324
  : > "$GH_LOG"
239
- close_out="$(GH_DEP_PRS='not json' effort_close 99 2>&1)"; rc=$?
325
+ close_out="$(GH_DEP_PRS_RC=500 effort_close 99 2>&1)"; rc=$?
240
326
  t "effort_close refuses when the dependent-PR list is unreadable (rc 1)" "$rc" "1"
241
- t "effort_close did NOT merge on an unreadable list" "$(grep -c 'pr merge' "$GH_LOG")" "0"
327
+ t "effort_close did NOT merge on an unreadable list" "$(grep -cE "$MERGE_RE" "$GH_LOG")" "0"
242
328
 
243
329
  # #148: the VERB sets board Status=Done (guarded). Stub the board helpers + captured ids in-shell —
244
330
  # _eo_source_board must see them and skip sourcing the real gh-project.sh.
@@ -249,23 +335,29 @@ export KIT_PROJECTS_V2="true" STATUS_FIELD_ID="SF1" STATUS_OPT_DONE="OPT_DONE"
249
335
 
250
336
  : > "$GH_LOG"
251
337
  # (#380 case 2) a passing pre-close hook rides this happy path: called with effort + subs, close proceeds.
252
- close_out="$(GH_DEP_PRS="$DEPS" KIT_EFFORT_PRE_CLOSE_HOOK="$stub/prehook" effort_close 99 2>&1)"; rc=$?
338
+ close_out="$(GH_DEP_PRS="$DEPS_REST" KIT_EFFORT_PRE_CLOSE_HOOK="$stub/prehook" effort_close 99 2>&1)"; rc=$?
253
339
  export KIT_PROJECTS_V2="false"
254
340
  cd "$tmp/work" # our cwd (the effort worktree) is GC'd by the close — step to the main checkout
255
341
  t "effort_close succeeds with a trace (rc 0)" "$rc" "0"
256
342
  t "pre-close hook: called as <hook> <effort#> <sub#…>" "$(cat "$PREHOOK_MARKER" 2>/dev/null)" "99 101 102"
257
343
  t "pre-close hook: runs from the effort worktree" "$(cat "$PREHOOK_MARKER.cwd" 2>/dev/null)" "$PREHOOK_WT"
258
- tc "$GH_LOG" 'pr merge effort/99-demo .*--squash' "effort_close squash-merges the PR"
344
+ tc "$GH_LOG" '^GET repos/o/r/pulls\?head=o%3Aeffort%2F99-demo&state=open' "effort_close finds the PR for the effort branch"
345
+ tc "$GH_LOG" '^PUT repos/o/r/pulls/9/merge \{"merge_method":"squash"\}$' "effort_close squash-merges the PR"
346
+ # the remote branch goes through git, not the API — and it is gone (a cloud session keeps it, #396)
347
+ t "effort_close deleted the remote branch" "$(git -C "$tmp/work" ls-remote --heads origin effort/99-demo | wc -l | tr -d ' ')" "0"
259
348
  # #358: both dependents re-targeted to the base, and before the merge that deletes the branch
260
- tc "$GH_LOG" 'pr list .*--base effort/99-demo .*--state open' "effort_close lists open PRs based on the effort branch"
261
- tc "$GH_LOG" 'pr edit 41 .*--base main' "effort_close re-targets dependent PR 41 to the base"
262
- tc "$GH_LOG" 'pr edit 43 .*--base main' "effort_close re-targets dependent PR 43 to the base"
263
- t "effort_close leaves a PR on another base alone" "$(grep -c 'pr edit 42' "$GH_LOG")" "0"
349
+ tc "$GH_LOG" '^GET repos/o/r/pulls\?base=effort%2F99-demo&state=open&per_page=100' "effort_close lists open PRs based on the effort branch"
350
+ tc "$GH_LOG" '^PATCH repos/o/r/pulls/41 \{"base":"main"\}$' "effort_close re-targets dependent PR 41 to the base"
351
+ tc "$GH_LOG" '^PATCH repos/o/r/pulls/43 \{"base":"main"\}$' "effort_close re-targets dependent PR 43 to the base"
352
+ t "effort_close leaves a PR on another base alone" "$(grep -c '^PATCH repos/o/r/pulls/42 ' "$GH_LOG")" "0"
264
353
  t "effort_close re-targets before the merge deletes the branch" \
265
- "$(grep -nE 'pr edit 43|pr merge' "$GH_LOG" | sed -E 's/^[0-9]+:(pr [a-z]+).*/\1/' | tr '\n' ' ')" "pr edit pr merge "
354
+ "$(grep -nE 'PATCH repos/o/r/pulls/43 |PUT repos/o/r/pulls/9/merge' "$GH_LOG" | sed -E 's/^[0-9]+:(PATCH|PUT).*/\1/' | tr '\n' ' ')" "PATCH PUT "
266
355
  case "$close_out" in *"PR 41 re-targeted to main"*) echo "ok: close output carries the re-targeted line" ;; *) echo "FAIL: no re-targeted line in close output"; fail=1 ;; esac
267
- tc "$GH_LOG" 'issue close 101' "effort_close closes sub #101"
268
- tc "$GH_LOG" 'issue close 99 ' "effort_close closes the parent"
356
+ # #565: the shim's subs are already closed — close keeps their close reason (no second PATCH);
357
+ # the open-sub cases are in effort-close-subs-test.sh
358
+ t "effort_close does not re-close an already-closed sub" "$(grep -c '^PATCH repos/o/r/issues/101 ' "$GH_LOG")" "0"
359
+ tc "$GH_LOG" '^PATCH repos/o/r/issues/99 \{"state":"closed","state_reason":"completed"\}$' "effort_close closes the parent"
360
+ no_gh "effort_close"
269
361
  case "$close_out" in *"metrics:"*) echo "ok: capture_effort_metrics composed into close" ;; *) echo "FAIL: no metrics capture in close"; fail=1 ;; esac
270
362
  # #453: the row that close wrote carries a build time measured from the start stamp.
271
363
  t "effort_close records build_seconds from the start stamp" \
@@ -304,7 +396,8 @@ forced_out="$(PREHOOK_RC=1 KIT_EFFORT_PRE_CLOSE_HOOK="$stub/prehook" KHOOK_MARKE
304
396
  cd "$tmp/work"
305
397
  case "$forced_out" in *"pre-close hook"*"skipped (KIT_FORCE=1)"*) echo "ok: pre-close hook: KIT_FORCE=1 says the hook was skipped" ;; *) echo "FAIL: no pre-close skip notice: $forced_out"; fail=1 ;; esac
306
398
  t "pre-close hook: KIT_FORCE=1 does not run the hook" "$([ -e "$PREHOOK_MARKER" ] && echo ran || echo skipped)" "skipped"
307
- tc "$GH_LOG" 'pr merge effort/88-forced .*--squash' "KIT_FORCE=1 close merges despite no trace"
399
+ tc "$GH_LOG" '^GET repos/o/r/pulls\?head=o%3Aeffort%2F88-forced&state=open' "KIT_FORCE=1 close reads the PR of effort/88-forced"
400
+ tc "$GH_LOG" '^PUT repos/o/r/pulls/[0-9]+/merge \{"merge_method":"squash"\}$' "KIT_FORCE=1 close merges despite no trace"
308
401
  t "knowledge-ingest hook ran with the effort number" "$(cat "$tmp/khook.out" 2>/dev/null)" "ingested 88"
309
402
  # #371: the close GCs the worktree it was run from; the hook must run in the main checkout, not in
310
403
  # that deleted directory (where every relative path and git call fails).
@@ -343,32 +436,40 @@ case "$gone_out" in *"post-close hook not read"*) echo "ok: a config that vanish
343
436
  close_out="$(effort_close 78 2>&1)"; rc=$?
344
437
  t "wave close refuses while a sub is open (rc 1)" "$rc" "1"
345
438
  case "$close_out" in *"not done"*"#202"*) echo "ok: wave refuse lists the straggler sub" ;; *) echo "FAIL: wave refuse output: $close_out"; fail=1 ;; esac
346
- t "wave refuse closes nothing" "$(grep -c 'issue close' "$GH_LOG")" "0"
439
+ t "wave refuse closes nothing" "$(grep -cE "$CLOSE_RE" "$GH_LOG")" "0"
347
440
 
348
441
  # #380: the wave path has no effort worktree; the hook runs from the checkout the close was run in.
349
442
  : > "$GH_LOG"; rm -f "$PREHOOK_MARKER"
350
443
  close_out="$(PREHOOK_RC=1 KIT_EFFORT_PRE_CLOSE_HOOK="$stub/prehook" effort_close 77 2>&1)"; rc=$?
351
444
  t "pre-close hook: a failing hook refuses a wave close (rc 1)" "$rc" "1"
352
445
  t "pre-close hook: wave hook gets the effort + its subs" "$(cat "$PREHOOK_MARKER" 2>/dev/null)" "77 301 302"
353
- t "pre-close hook: a refused wave close closes nothing" "$(grep -c 'issue close' "$GH_LOG")" "0"
446
+ t "pre-close hook: a refused wave close closes nothing" "$(grep -cE "$CLOSE_RE" "$GH_LOG")" "0"
354
447
 
355
448
  # happy: every sub CLOSED with a merged PR → trace from the PR diffs → parent closed, board Done
356
- # for parent + subs, drift check fires off the union of the merged PR diffs
449
+ # for parent + subs, drift check read off the union of the merged PR diffs. The shim's diff for any
450
+ # PR is one app file (src/app.ts) and that answer cannot be changed from a fixture, so the drift
451
+ # check is asserted silent here — the kit-managed warning itself is covered on the branch path above.
357
452
  : > "$BOARD_LOG"
358
453
  export KIT_PROJECTS_V2="true"
359
454
  : > "$GH_LOG"
360
455
  close_out="$(effort_close 77 2>&1)"; rc=$?
361
456
  export KIT_PROJECTS_V2="false"
362
457
  t "wave close succeeds when all subs merged (rc 0)" "$rc" "0"
363
- tc "$GH_LOG" 'pr diff 501' "wave close snapshots the merged sub PR diffs"
364
- tc "$GH_LOG" 'issue close 77 ' "wave close closes the parent"
365
- t "wave close closes ONLY the parent (subs already closed)" "$(grep -c 'issue close' "$GH_LOG")" "1"
366
- t "wave close never squash-merges anything" "$(grep -c 'pr merge' "$GH_LOG")" "0"
458
+ # the closing PR of sub #301 is #5301 in the shim's timeline (#6301 only mentions it); its diff is
459
+ # the `GET pulls/<n>` read with the diff Accept header
460
+ tc "$GH_LOG" '^GET repos/o/r/issues/301/timeline' "wave close reads each sub's timeline for its closing PR"
461
+ tc "$GH_LOG" '^GET repos/o/r/pulls/5301 $' "wave close snapshots the merged sub PR diffs"
462
+ tc "$GH_LOG" '^PATCH repos/o/r/issues/77 \{"state":"closed","state_reason":"completed"\}$' "wave close closes the parent"
463
+ t "wave close closes ONLY the parent (subs already closed)" "$(grep -cE "$CLOSE_RE" "$GH_LOG")" "1"
464
+ t "wave close never squash-merges anything" "$(grep -cE "$MERGE_RE" "$GH_LOG")" "0"
367
465
  tc "$BOARD_LOG" 'ITEM-77 SF1 OPT_DONE' "wave close sets board Done for the parent"
368
466
  tc "$BOARD_LOG" 'ITEM-301 SF1 OPT_DONE' "wave close sets board Done for sub #301"
369
467
  tc "$BOARD_LOG" 'ITEM-302 SF1 OPT_DONE' "wave close sets board Done for sub #302"
370
- case "$close_out" in *"kit-sync"*".claude/skills/demo.md"*) echo "ok: wave drift check reads the merged PR diffs" ;; *) echo "FAIL: no kit-sync warning in wave close output"; fail=1 ;; esac
468
+ wave_trace="$(git -C "$tmp/work" rev-parse --git-common-dir)/traces/effort-77"
469
+ t "wave close traces the merged sub PR diffs" "$(cat "$wave_trace"/*.diff 2>/dev/null | grep -c '^diff --git a/src/app.ts ')" "2"
470
+ case "$close_out" in *"kit-sync"*) echo "FAIL: wave kit-sync warning fired with no kit-managed file in the merged diffs: $close_out"; fail=1 ;; *) echo "ok: wave drift check stays silent when the merged diffs touch no kit-managed file" ;; esac
371
471
  case "$close_out" in *"project-owned.md"*) echo "FAIL: wave kit-sync warning names a project-owned rule"; fail=1 ;; *) echo "ok: wave drift check skips a project-owned rule" ;; esac
472
+ no_gh "wave close"
372
473
 
373
474
  # ── #218 · _EO_KIT_MANAGED_RE — only the rules the kit ships are kit-managed ──────────────────────
374
475
  # init.sh writes .claude/rules/<name>.md only for a templates/rules/<name>.md, so the regex lists
@@ -404,59 +505,49 @@ t "relations_add respects a mid-body section" \
404
505
  # It used to be built inline with `$( … )`, which eats trailing newlines — the section shipped as the
405
506
  # single mangled line `## Relations- Depends on #4- Depends on #9`. Both now go through the formatter.
406
507
  : > "$GH_LOG"; printf '0' > "$GH_N"
407
- effort_new --depends-on "#4,9" "depends on effort" >/dev/null 2>&1
408
- tc "$GH_LOG" '^## Relations$' "--depends-on writes ## Relations on its own line"
409
- tc "$GH_LOG" '^- Depends on #4$' "--depends-on writes the first dep on its own line"
410
- tc "$GH_LOG" '^- Depends on #9( |$)' "--depends-on writes the second dep on its own line"
508
+ effort_new --spec "it ships" --depends-on "#4,9" "depends on effort" >/dev/null 2>&1
509
+ # the body travels as a JSON string in the POST issues line, so a line break is a literal \n there
510
+ tc "$GH_LOG" '^POST repos/o/r/issues \{.*\\n## Relations\\n' "--depends-on writes ## Relations on its own line"
511
+ tc "$GH_LOG" '^POST repos/o/r/issues \{.*\\n- Depends on #4\\n' "--depends-on writes the first dep on its own line"
512
+ tc "$GH_LOG" '^POST repos/o/r/issues \{.*\\n- Depends on #9(\\n|")' "--depends-on writes the second dep on its own line"
411
513
  t "--depends-on does not mangle the heading" "$(grep -c '## Relations-' "$GH_LOG")" "0"
412
514
 
413
515
  # ── #243 · effort_chain — a linear blocked_by chain, idempotent, cycle-refusing ────────────────────
414
- # Its own gh stub (prepended to PATH) with real STATE: which issues exist, the blocked_by edge set,
415
- # and per-issue bodies — so the edges and the body lines can be asserted, not just the call log.
416
- cstub="$tmp/cbin"; mkdir -p "$cstub"
516
+ # A stateful fixture for the shim — which issues exist, the blocked_by edge set, and per-issue
517
+ # bodies — so the edges and the body lines can be asserted, not just the request log. The log of
518
+ # this section is $CH_LOG (the shim writes wherever GH_LOG points).
417
519
  export CH_DIR="$tmp/chain"; mkdir -p "$CH_DIR"
418
520
  export CH_LOG="$CH_DIR/gh.log" CH_EDGES="$CH_DIR/edges" CH_EXISTS="$CH_DIR/exists"
419
521
  printf '501\n502\n503\n504\n601\n' > "$CH_EXISTS" # #999 deliberately absent
420
522
  : > "$CH_EDGES"; : > "$CH_LOG"
421
- for n in 501 502 503 504; do printf '## Goal\ng%s\n\n## Verification\nv\n' "$n" > "$CH_DIR/body.$n"; done
422
- cat > "$cstub/gh" <<'SH'
423
- #!/usr/bin/env bash
424
- # stub gh with state. DB id of issue N is 900000+N (the dependencies API takes the blocker's db id).
425
- echo "$*" | tr '\n' ' ' >> "$CH_LOG"; echo >> "$CH_LOG"
426
- _n() { printf '%s' "$1" | sed -nE 's#.*issues/([0-9]+).*#\1#p'; }
427
- case "$1" in
428
- issue)
429
- case "$2" in
430
- view) cat "$CH_DIR/body.$3" 2>/dev/null; exit 0 ;;
431
- edit) n="$3"; shift 3
432
- # CH_FAIL_EDIT=<n> makes the edit fail for that issue — a POST-validation failure, the
433
- # only way to reach effort_chain's rc=1 path (pre-flight refusals never write at all).
434
- [ -n "${CH_FAIL_EDIT:-}" ] && [ "$n" = "$CH_FAIL_EDIT" ] && exit 1
435
- while [ $# -gt 0 ]; do
436
- [ "$1" = "--body" ] && { printf '%s' "$2" > "$CH_DIR/body.$n"; break; }
437
- shift
438
- done
439
- exit 0 ;;
440
- *) exit 0 ;;
441
- esac ;;
442
- api)
443
- case "$*" in
444
- *"--method POST"*"/dependencies/blocked_by"*)
445
- n="$(_n "$*")"; bid="$(printf '%s' "$*" | sed -nE 's#.*issue_id=([0-9]+).*#\1#p')"
446
- b=$((bid - 900000))
447
- grep -qx "$n $b" "$CH_EDGES" && exit 1 # GitHub rejects a duplicate edge
448
- echo "$n $b" >> "$CH_EDGES"; exit 0 ;;
449
- *"/dependencies/blocked_by"*)
450
- awk -v k="$(_n "$*")" '$1==k{print $2}' "$CH_EDGES"; exit 0 ;;
451
- *".id"*) n="$(_n "$*")"; echo $((900000 + n)); exit 0 ;;
452
- *".number"*) n="$(_n "$*")"; grep -qx "$n" "$CH_EXISTS" || exit 1; echo "$n"; exit 0 ;;
453
- *) exit 0 ;;
454
- esac ;;
455
- *) exit 0 ;;
523
+ for n in 501 502 503 504 601; do printf '## Goal\ng%s\n\n## Verification\nv\n' "$n" > "$CH_DIR/body.$n"; done
524
+ CHAIN_FIXTURE="$tmp/chain-fixture.sh"
525
+ cat > "$CHAIN_FIXTURE" <<'SH'
526
+ # DB id of issue N is 900000+N (the dependencies API takes the blocker's db id). Edges are "issue
527
+ # blocker" lines in $CH_EDGES; a body is $CH_DIR/body.N. CH_FAIL_EDIT=<n> makes that issue's PATCH
528
+ # fail — a POST-validation failure, the only way to reach effort_chain's rc=1 path (pre-flight
529
+ # refusals never write at all).
530
+ _n() { printf '%s' "$ep" | sed -nE 's#^repos/o/r/issues/([0-9]+).*#\1#p'; }
531
+ case "$method $ep" in
532
+ "GET repos/o/r/issues/"*"/dependencies/blocked_by")
533
+ out="$(awk -v k="$(_n)" 'BEGIN{printf "["} $1==k{printf "%s{\"number\":%s}", (c++?",":""), $2} END{printf "]"}' "$CH_EDGES")" ;;
534
+ "POST repos/o/r/issues/"*"/dependencies/blocked_by")
535
+ n="$(_n)"; bid="$(printf '%s' "$body" | jq -r .issue_id)"; b=$((bid - 900000))
536
+ if grep -qx "$n $b" "$CH_EDGES"; then code=422; else echo "$n $b" >> "$CH_EDGES"; fi ;; # GitHub rejects a duplicate edge
537
+ "GET repos/o/r/issues/"*)
538
+ n="$(_n)"
539
+ if grep -qx "$n" "$CH_EXISTS"; then
540
+ out="$(jq -n --argjson n "$n" --rawfile b "$CH_DIR/body.$n" '{number:$n, id:(900000+$n), title:"issue", state:"open", body:$b, labels:[]}')"
541
+ else code=404; out='{"message":"Not Found"}'; fi ;;
542
+ "PATCH repos/o/r/issues/"*)
543
+ n="$(_n)"
544
+ if [ "${CH_FAIL_EDIT:-}" = "$n" ]; then code=500
545
+ else printf '%s' "$body" | jq -r '.body // empty' > "$CH_DIR/body.$n"; fi ;;
456
546
  esac
457
547
  SH
458
- chmod +x "$cstub/gh"
459
- export PATH="$cstub:$PATH"
548
+ export GH_FIXTURE="$CHAIN_FIXTURE" GH_LOG="$CH_LOG"
549
+ POST_DEP_RE='^POST repos/o/r/issues/[0-9]+/dependencies/blocked_by '
550
+ EDIT_RE='^PATCH repos/o/r/issues/'
460
551
  edges() { sort "$CH_EDGES" | tr '\n' ';'; }
461
552
 
462
553
  # happy path: 502 blocked_by 501, 503 blocked_by 502, each body records its predecessor
@@ -474,13 +565,13 @@ t "chain leaves the head issue's body alone" "$(grep -c 'Depends on' "$CH_DIR/bo
474
565
  effort_chain 501 502 503 >/dev/null 2>&1; rc=$?
475
566
  t "chain re-run returns 0" "$rc" "0"
476
567
  t "chain re-run sets no new edge" "$(edges)" "502 501;503 502;"
477
- t "chain re-run POSTs no dependency" "$(grep -c 'method POST' "$CH_LOG")" "0"
478
- t "chain re-run edits no body" "$(grep -c 'issue edit' "$CH_LOG")" "0"
568
+ t "chain re-run POSTs no dependency" "$(grep -cE "$POST_DEP_RE" "$CH_LOG")" "0"
569
+ t "chain re-run edits no body" "$(grep -cE "$EDIT_RE" "$CH_LOG")" "0"
479
570
  t "chain re-run leaves ONE Depends on line" "$(grep -c 'Depends on #501' "$CH_DIR/body.502")" "1"
480
571
  # a `#`-prefixed number is the same issue
481
572
  : > "$CH_LOG"
482
573
  effort_chain '#501' '#502' >/dev/null 2>&1
483
- t "chain accepts #-prefixed numbers" "$(grep -c 'method POST' "$CH_LOG")" "0"
574
+ t "chain accepts #-prefixed numbers" "$(grep -cE "$POST_DEP_RE" "$CH_LOG")" "0"
484
575
 
485
576
  # arity: fewer than two numbers is a usage error and writes nothing
486
577
  : > "$CH_LOG"
@@ -488,32 +579,32 @@ effort_chain 501 >/dev/null 2>&1 && rc=0 || rc=1
488
579
  t "chain refuses a single issue (rc 1)" "$rc" "1"
489
580
  effort_chain >/dev/null 2>&1 && rc=0 || rc=1
490
581
  t "chain refuses zero issues (rc 1)" "$rc" "1"
491
- t "chain arity refusal writes nothing" "$(grep -cE 'method POST|issue edit' "$CH_LOG")" "0"
582
+ t "chain arity refusal writes nothing" "$(grep -cE "$POST_DEP_RE|$EDIT_RE" "$CH_LOG")" "0"
492
583
 
493
584
  # a non-numeric argument is rejected up front
494
585
  : > "$CH_LOG"
495
586
  effort_chain 501 not-a-number >/dev/null 2>&1 && rc=0 || rc=1
496
587
  t "chain refuses a non-numeric arg (rc 1)" "$rc" "1"
497
- t "chain non-numeric refusal writes nothing" "$(grep -cE 'method POST|issue edit' "$CH_LOG")" "0"
588
+ t "chain non-numeric refusal writes nothing" "$(grep -cE "$POST_DEP_RE|$EDIT_RE" "$CH_LOG")" "0"
498
589
 
499
590
  # a nonexistent issue aborts the WHOLE chain — the earlier, valid link is not written either
500
591
  : > "$CH_LOG"
501
592
  effort_chain 504 999 >/dev/null 2>&1 && rc=0 || rc=1
502
593
  t "chain refuses a nonexistent issue (rc 1)" "$rc" "1"
503
- t "chain missing-issue refusal writes nothing" "$(grep -cE 'method POST|issue edit' "$CH_LOG")" "0"
594
+ t "chain missing-issue refusal writes nothing" "$(grep -cE "$POST_DEP_RE|$EDIT_RE" "$CH_LOG")" "0"
504
595
  t "chain missing-issue refusal adds no edge" "$(edges)" "502 501;503 502;"
505
596
 
506
597
  # a repeated number is a cycle (`chain 1 2 1`) — refused whole
507
598
  : > "$CH_LOG"
508
599
  effort_chain 504 501 504 >/dev/null 2>&1 && rc=0 || rc=1
509
600
  t "chain refuses a repeated number (rc 1)" "$rc" "1"
510
- t "chain repeat refusal writes nothing" "$(grep -cE 'method POST|issue edit' "$CH_LOG")" "0"
601
+ t "chain repeat refusal writes nothing" "$(grep -cE "$POST_DEP_RE|$EDIT_RE" "$CH_LOG")" "0"
511
602
 
512
603
  # a cycle through edges GitHub ALREADY holds: 503 → 502 → 501 exists, so 501 blocked_by 503 loops
513
604
  : > "$CH_LOG"
514
605
  effort_chain 503 501 >/dev/null 2>&1 && rc=0 || rc=1
515
606
  t "chain refuses a transitive cycle (rc 1)" "$rc" "1"
516
- t "chain cycle refusal writes nothing" "$(grep -cE 'method POST|issue edit' "$CH_LOG")" "0"
607
+ t "chain cycle refusal writes nothing" "$(grep -cE "$POST_DEP_RE|$EDIT_RE" "$CH_LOG")" "0"
517
608
  t "chain cycle refusal adds no edge" "$(edges)" "502 501;503 502;"
518
609
 
519
610
  # an issue already blocked by something ELSE keeps that blocker — chain only ever ADDS its edge
@@ -554,8 +645,9 @@ wtmp="$tmp/wip"; mkdir -p "$wtmp"
554
645
  && git push -q origin HEAD:main )
555
646
  cd "$wtmp/work" || exit 1
556
647
  unset EFFORT_WIP_LIMIT KIT_EFFORT_WIP_LIMIT KIT_FORCE 2>/dev/null || true
557
- # `gh` on PATH here is the chain stub, which logs to $CH_LOG — that is the log a refusal must leave
558
- # empty, so the "writes nothing" assertions read it rather than $GH_LOG.
648
+ # The shim logs to $CH_LOG here (GH_LOG points at it since the chain section) — that is the log a
649
+ # refusal must leave empty. The chain fixture stays installed: the title read of an issue it does not
650
+ # know is a 404, which effort_start survives (#330), and every start below names its slug anyway.
559
651
 
560
652
  wip_started() { git show-ref --verify --quiet "refs/heads/effort/$1" && echo yes || echo no; }
561
653
  wip_reset() { git checkout -q main 2>/dev/null; \
@@ -584,17 +676,18 @@ case "$out" in *"effort.wipLimit"*) echo "ok: refusal names the config key" ;; *
584
676
  # …and the refusal WRITES nothing: no branch, no worktree dir, no board change.
585
677
  t "wip: refusal created no branch" "$(wip_started 703-three)" "no"
586
678
  t "wip: refusal created no worktree" "$(ls -d .claude/worktrees/effort+703-three 2>/dev/null | wc -l | tr -d ' ')" "0"
587
- # For a NUMERIC argument the refusal also makes no gh call — the number is passed through, so no
679
+ # For a NUMERIC argument the refusal also makes no forge call — the number is passed through, so no
588
680
  # resolution happens. This is NOT the guarantee for a <slug> argument (see the next assertion), and
589
681
  # the docs claim only "no branch, no worktree, no board change" (#244 review).
590
- t "wip: a numeric-arg refusal made no gh call" "$(grep -c . "$CH_LOG" | tr -d ' ')" "0"
591
- # A SLUG argument is resolved BEFORE the gate, and the resolver falls through to `gh issue list`
592
- # when no branch matches — so a refusal on that path can read from GitHub. Asserted on the resolver
682
+ t "wip: a numeric-arg refusal made no forge call" "$(grep -c . "$CH_LOG" | tr -d ' ')" "0"
683
+ # A SLUG argument is resolved BEFORE the gate, and the resolver falls through to the issue list
684
+ # (the slug: label, then the open effort titles) when no branch matches — so a refusal on that path
685
+ # can read from GitHub. Asserted on the resolver
593
686
  # itself, which is the mechanism the narrowed doc claim refers to.
594
687
  : > "$CH_LOG"
595
688
  effort_slug_resolve no-such-effort-anywhere >/dev/null 2>&1 || true
596
- t "wip: resolving a slug with no branch DOES call gh" \
597
- "$(grep -c 'issue list' "$CH_LOG" | tr -d ' ')" "2"
689
+ t "wip: resolving a slug with no branch DOES read the forge" \
690
+ "$(grep -cE '^GET repos/o/r/issues\?' "$CH_LOG" | tr -d ' ')" "2"
598
691
 
599
692
  # 4. --force starts anyway (and says so).
600
693
  out="$(effort_start --force 703 three 2>&1)"; rc=$?
@@ -751,7 +844,7 @@ cd "$tmp/work" || exit 1
751
844
  # it. `cckit effort plan` therefore answered "no open efforts found" for every effort ever
752
845
  # made, in every repo, with no error anywhere. A static check because the failure mode is
753
846
  # silence — there is nothing at runtime to notice.
754
- plan_label="$(sed -n 's/.*gh issue list [^|]*--label \([a-z][a-z-]*\).*/\1/p' "$LIB/effort-plan.sh" | sed -n 1p)"
847
+ plan_label="$(sed -n 's/.*forge_rest "repos\/\$repo\/issues" [^|]*-f labels=\([a-z][a-z-]*\).*/\1/p' "$LIB/effort-plan.sh" | sed -n 1p)"
755
848
  t "plan queries a label at all" "${plan_label:-MISSING}" "effort"
756
849
  t "effort_new applies the label plan queries" \
757
850
  "$(grep -c "labels=\"$plan_label," "$LIB/effort-ops.sh" | tr -d ' ')" "1"
@@ -760,41 +853,42 @@ t "effort_new ensures the label exists before using it" \
760
853
  t "setup-labels provisions the label plan queries" \
761
854
  "$(grep -c "ensure_label \"$plan_label\"" "$SCRIPTS/setup-labels.sh" | tr -d ' ')" "1"
762
855
 
763
- # 16. #330 — a failed gh read is said, never a silent rc 1. With GraphQL failing, the bare
764
- # `title="$(gh issue view …)"` assignment ended effort_start under `set -e` with no output at all.
765
- fstub="$tmp/failbin"; mkdir -p "$fstub"
766
- printf '#!/usr/bin/env bash\necho "GraphQL: API rate limit exceeded" >&2\nexit 1\n' > "$fstub/gh"
767
- chmod +x "$fstub/gh"
856
+ # 16. #330 — a failed forge read is said, never a silent rc 1. With the issue read failing, the bare
857
+ # `title="$(…)"` assignment ended effort_start under `set -e` with no output at all. GH_FAIL_EP
858
+ # makes the shim answer 404 on that one endpoint.
768
859
  wip_reset
769
- out="$( set -e; PATH="$fstub:$PATH"; CCKIT_GH_TRANSPORT=graphql EFFORT_WIP_REMOTE=0 effort_start --force 801 2>&1 )"; rc=$?
860
+ out="$( set -e; GH_FAIL_EP="repos/o/r/issues/801" EFFORT_WIP_REMOTE=0 effort_start --force 801 2>&1 )"; rc=$?
770
861
  t "#330: effort_start survives a failed title read (rc 0)" "$rc" "0"
771
862
  case "$out" in *"could not read the title of issue #801"*) echo "ok: #330: the failed title read is named on stderr" ;;
772
863
  *) echo "FAIL: #330: no message for the failed title read -> '$out'"; fail=1 ;; esac
773
864
  t "#330: the fallback slug made the branch" "$(git show-ref --verify --quiet refs/heads/effort/801-effort && echo yes)" "yes"
774
865
  # A re-start during the outage lands on the effort's existing branch, not on a second one.
775
866
  git branch -q effort/802-real-slug
776
- out="$( set -e; PATH="$fstub:$PATH"; CCKIT_GH_TRANSPORT=graphql EFFORT_WIP_REMOTE=0 effort_start --force 802 2>&1 )"; rc=$?
777
- t "#330: a re-start with gh failing keeps rc 0" "$rc" "0"
778
- t "#330: a re-start with gh failing cuts no fallback branch" \
867
+ out="$( set -e; GH_FAIL_EP="repos/o/r/issues/802" EFFORT_WIP_REMOTE=0 effort_start --force 802 2>&1 )"; rc=$?
868
+ t "#330: a re-start with the forge failing keeps rc 0" "$rc" "0"
869
+ t "#330: a re-start with the forge failing cuts no fallback branch" \
779
870
  "$(git show-ref --verify --quiet refs/heads/effort/802-effort && echo yes || echo no)" "no"
780
- # effort_close: a failed PR read refuses by name instead of dying on the bare assignment.
871
+ # effort_close: a failed PR read (GET pulls?head=…) refuses by name instead of dying on the bare
872
+ # assignment — and before the capture writes a records.jsonl row and consumes the start marker (the
873
+ # write-then-fail #394 exists to prevent). --no-spec-check: the chain fixture answers 404 for #801's
874
+ # body, and the read under test here is the PR's.
875
+ : > "$CH_LOG"
781
876
  out="$( set -e; cd "$(git worktree list --porcelain | awk -v b=refs/heads/effort/801-effort '/^worktree /{w=$2} $2==b{print w}')" \
782
- && PATH="$fstub:$PATH" && CCKIT_GH_TRANSPORT=graphql KIT_FORCE=1 effort_close 801 2>&1 )"; rc=$?
877
+ && GH_FAIL_EP="repos/o/r/pulls" KIT_FORCE=1 effort_close 801 --no-spec-check 2>&1 )"; rc=$?
783
878
  t "#330: effort_close refuses when the PR cannot be read (rc 1)" "$rc" "1"
784
879
  case "$out" in *"could not read the PR for effort/801-effort"*) echo "ok: #330: effort_close names the failed PR read" ;;
785
880
  *) echo "FAIL: #330: effort_close gave no reason -> '$out'"; fail=1 ;; esac
786
- # The REST twin. REST is the transport in use when GraphQL is unavailable, and there the failed read
787
- # was swallowed: the capture wrote a records.jsonl row and consumed the start marker, then the merge
788
- # failed — the write-then-fail #394 exists to prevent.
881
+ t "#330: nothing was merged on the failed read" "$(grep -cE "$MERGE_RE" "$CH_LOG")" "0"
789
882
  out="$( set -e; cd "$(git worktree list --porcelain | awk -v b=refs/heads/effort/801-effort '/^worktree /{w=$2} $2==b{print w}')" \
790
883
  && echo work > rest-twin.txt && git add rest-twin.txt \
791
884
  && git -c user.email=t@t -c user.name=t commit -q -m "feat: work (#801)" \
792
- && PATH="$fstub:$PATH" && CCKIT_GH_TRANSPORT=rest KIT_FORCE=1 effort_close 801 2>&1 )"; rc=$?
793
- t "#330: rest: effort_close refuses when the PR cannot be read (rc 1)" "$rc" "1"
885
+ && GH_FAIL_EP="repos/o/r/pulls" KIT_FORCE=1 effort_close 801 --no-spec-check 2>&1 )"; rc=$?
886
+ t "#330: with a trace, effort_close still refuses the failed PR read (rc 1)" "$rc" "1"
794
887
  case "$out" in
795
- *"metrics:"*) echo "FAIL: #330: rest: metrics captured before the failed PR read was refused -> '$out'"; fail=1 ;;
796
- *"could not read the PR for effort/801-effort"*"nothing was written"*) echo "ok: #330: rest: effort_close names the failed PR read" ;;
797
- *) echo "FAIL: #330: rest: effort_close gave no reason -> '$out'"; fail=1 ;; esac
888
+ *"metrics:"*) echo "FAIL: #330: metrics captured before the failed PR read was refused -> '$out'"; fail=1 ;;
889
+ *"could not read the PR for effort/801-effort"*"nothing was written"*) echo "ok: #330: the refusal says nothing was written" ;;
890
+ *) echo "FAIL: #330: effort_close gave no reason -> '$out'"; fail=1 ;; esac
891
+ no_gh "the whole wip + #330 section"
798
892
 
799
893
  [ "$fail" -eq 0 ] && echo "ALL OK (effort-ops)" || echo "effort-ops: FAILURES"
800
894
  exit "$fail"