@on-par/factory-core 0.9.14-next.3 → 0.9.14-next.31

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 (344) hide show
  1. package/dist/checkers/app-smoke.d.ts +26 -0
  2. package/dist/checkers/app-smoke.d.ts.map +1 -0
  3. package/dist/checkers/app-smoke.js +174 -0
  4. package/dist/checkers/app-smoke.js.map +1 -0
  5. package/dist/checkers/baseline.d.ts +3 -2
  6. package/dist/checkers/baseline.d.ts.map +1 -1
  7. package/dist/checkers/baseline.js +5 -5
  8. package/dist/checkers/baseline.js.map +1 -1
  9. package/dist/checkers/command-log.d.ts +9 -0
  10. package/dist/checkers/command-log.d.ts.map +1 -0
  11. package/dist/checkers/command-log.js +36 -0
  12. package/dist/checkers/command-log.js.map +1 -0
  13. package/dist/checkers/index.d.ts +5 -4
  14. package/dist/checkers/index.d.ts.map +1 -1
  15. package/dist/checkers/index.js +12 -33
  16. package/dist/checkers/index.js.map +1 -1
  17. package/dist/checkers/run-command.d.ts +4 -1
  18. package/dist/checkers/run-command.d.ts.map +1 -1
  19. package/dist/checkers/run-command.js +14 -2
  20. package/dist/checkers/run-command.js.map +1 -1
  21. package/dist/config/build-route.d.ts +35 -0
  22. package/dist/config/build-route.d.ts.map +1 -0
  23. package/dist/config/build-route.js +47 -0
  24. package/dist/config/build-route.js.map +1 -0
  25. package/dist/config/config-schema-lint.d.ts.map +1 -1
  26. package/dist/config/config-schema-lint.js +31 -27
  27. package/dist/config/config-schema-lint.js.map +1 -1
  28. package/dist/config/effort.d.ts.map +1 -1
  29. package/dist/config/effort.js +0 -1
  30. package/dist/config/effort.js.map +1 -1
  31. package/dist/config/example.d.ts.map +1 -1
  32. package/dist/config/example.js +10 -1
  33. package/dist/config/example.js.map +1 -1
  34. package/dist/config/harness-declaration.d.ts.map +1 -1
  35. package/dist/config/harness-declaration.js +2 -0
  36. package/dist/config/harness-declaration.js.map +1 -1
  37. package/dist/config/index.d.ts +8 -1
  38. package/dist/config/index.d.ts.map +1 -1
  39. package/dist/config/index.js +52 -49
  40. package/dist/config/index.js.map +1 -1
  41. package/dist/config/optional-sections.d.ts +23 -0
  42. package/dist/config/optional-sections.d.ts.map +1 -0
  43. package/dist/config/optional-sections.js +5 -0
  44. package/dist/config/optional-sections.js.map +1 -0
  45. package/dist/config/policy.d.ts +4 -6
  46. package/dist/config/policy.d.ts.map +1 -1
  47. package/dist/config/policy.js +29 -38
  48. package/dist/config/policy.js.map +1 -1
  49. package/dist/config/precedence.d.ts +17 -0
  50. package/dist/config/precedence.d.ts.map +1 -0
  51. package/dist/config/precedence.js +13 -0
  52. package/dist/config/precedence.js.map +1 -0
  53. package/dist/config/provider-order-exports.d.ts +3 -0
  54. package/dist/config/provider-order-exports.d.ts.map +1 -0
  55. package/dist/config/provider-order-exports.js +3 -0
  56. package/dist/config/provider-order-exports.js.map +1 -0
  57. package/dist/config/provider-order.d.ts +38 -0
  58. package/dist/config/provider-order.d.ts.map +1 -0
  59. package/dist/config/provider-order.js +99 -0
  60. package/dist/config/provider-order.js.map +1 -0
  61. package/dist/config/qa-section.d.ts +17 -0
  62. package/dist/config/qa-section.d.ts.map +1 -0
  63. package/dist/config/qa-section.js +18 -0
  64. package/dist/config/qa-section.js.map +1 -0
  65. package/dist/config/repo-config-file.d.ts +4 -0
  66. package/dist/config/repo-config-file.d.ts.map +1 -1
  67. package/dist/config/repo-config-file.js +35 -0
  68. package/dist/config/repo-config-file.js.map +1 -1
  69. package/dist/config/repo-harnesses.js +3 -3
  70. package/dist/config/repo-harnesses.js.map +1 -1
  71. package/dist/config/repo.d.ts +16 -18
  72. package/dist/config/repo.d.ts.map +1 -1
  73. package/dist/config/repo.js +129 -166
  74. package/dist/config/repo.js.map +1 -1
  75. package/dist/config/v2-models.d.ts +76 -0
  76. package/dist/config/v2-models.d.ts.map +1 -0
  77. package/dist/config/v2-models.js +125 -0
  78. package/dist/config/v2-models.js.map +1 -0
  79. package/dist/config/v2.d.ts +6 -0
  80. package/dist/config/v2.d.ts.map +1 -1
  81. package/dist/config/v2.js +1 -101
  82. package/dist/config/v2.js.map +1 -1
  83. package/dist/daemon/execution-config.d.ts +12 -0
  84. package/dist/daemon/execution-config.d.ts.map +1 -1
  85. package/dist/daemon/run-runtime.d.ts +12 -0
  86. package/dist/daemon/run-runtime.d.ts.map +1 -1
  87. package/dist/eval/index.d.ts +2 -1
  88. package/dist/eval/index.d.ts.map +1 -1
  89. package/dist/eval/index.js +2 -1
  90. package/dist/eval/index.js.map +1 -1
  91. package/dist/eval/judge.d.ts +0 -1
  92. package/dist/eval/judge.d.ts.map +1 -1
  93. package/dist/eval/judge.js +2 -6
  94. package/dist/eval/judge.js.map +1 -1
  95. package/dist/events/kinds.d.ts +2 -2
  96. package/dist/events/kinds.d.ts.map +1 -1
  97. package/dist/events/kinds.js +4 -0
  98. package/dist/events/kinds.js.map +1 -1
  99. package/dist/events/payloads.d.ts +23 -0
  100. package/dist/events/payloads.d.ts.map +1 -1
  101. package/dist/harness/catalog.d.ts +17 -0
  102. package/dist/harness/catalog.d.ts.map +1 -1
  103. package/dist/harness/catalog.js +35 -8
  104. package/dist/harness/catalog.js.map +1 -1
  105. package/dist/harness/claude-cli.d.ts +5 -1
  106. package/dist/harness/claude-cli.d.ts.map +1 -1
  107. package/dist/harness/claude-cli.js +27 -5
  108. package/dist/harness/claude-cli.js.map +1 -1
  109. package/dist/harness/claude-error.d.ts +10 -0
  110. package/dist/harness/claude-error.d.ts.map +1 -0
  111. package/dist/harness/claude-error.js +108 -0
  112. package/dist/harness/claude-error.js.map +1 -0
  113. package/dist/harness/command.d.ts +7 -1
  114. package/dist/harness/command.d.ts.map +1 -1
  115. package/dist/harness/command.js +32 -8
  116. package/dist/harness/command.js.map +1 -1
  117. package/dist/harness/contract.d.ts.map +1 -1
  118. package/dist/harness/contract.js +17 -0
  119. package/dist/harness/contract.js.map +1 -1
  120. package/dist/harness/index.d.ts +13 -0
  121. package/dist/harness/index.d.ts.map +1 -1
  122. package/dist/harness/index.js.map +1 -1
  123. package/dist/harness/opencode-error.d.ts +9 -0
  124. package/dist/harness/opencode-error.d.ts.map +1 -0
  125. package/dist/harness/opencode-error.js +20 -0
  126. package/dist/harness/opencode-error.js.map +1 -0
  127. package/dist/harness/opencode.d.ts +14 -1
  128. package/dist/harness/opencode.d.ts.map +1 -1
  129. package/dist/harness/opencode.js +52 -7
  130. package/dist/harness/opencode.js.map +1 -1
  131. package/dist/harness/provider-failure.d.ts +21 -0
  132. package/dist/harness/provider-failure.d.ts.map +1 -0
  133. package/dist/harness/provider-failure.js +71 -0
  134. package/dist/harness/provider-failure.js.map +1 -0
  135. package/dist/index.d.ts +4 -3
  136. package/dist/index.d.ts.map +1 -1
  137. package/dist/index.js +2 -1
  138. package/dist/index.js.map +1 -1
  139. package/dist/internal.d.ts +10 -7
  140. package/dist/internal.d.ts.map +1 -1
  141. package/dist/internal.js +8 -4
  142. package/dist/internal.js.map +1 -1
  143. package/dist/kpis/index.d.ts +2 -1
  144. package/dist/kpis/index.d.ts.map +1 -1
  145. package/dist/kpis/index.js +13 -10
  146. package/dist/kpis/index.js.map +1 -1
  147. package/dist/kpis/park.d.ts +11 -0
  148. package/dist/kpis/park.d.ts.map +1 -0
  149. package/dist/kpis/park.js +41 -0
  150. package/dist/kpis/park.js.map +1 -0
  151. package/dist/kpis/steerability.d.ts.map +1 -1
  152. package/dist/kpis/steerability.js +4 -3
  153. package/dist/kpis/steerability.js.map +1 -1
  154. package/dist/logger/index.d.ts +3 -1
  155. package/dist/logger/index.d.ts.map +1 -1
  156. package/dist/logger/index.js +2 -0
  157. package/dist/logger/index.js.map +1 -1
  158. package/dist/models/index.d.ts +3 -2
  159. package/dist/models/index.d.ts.map +1 -1
  160. package/dist/models/index.js +7 -15
  161. package/dist/models/index.js.map +1 -1
  162. package/dist/phases/build.d.ts +2 -5
  163. package/dist/phases/build.d.ts.map +1 -1
  164. package/dist/phases/build.js +2 -0
  165. package/dist/phases/build.js.map +1 -1
  166. package/dist/phases/plan.d.ts +2 -6
  167. package/dist/phases/plan.d.ts.map +1 -1
  168. package/dist/phases/ship.d.ts.map +1 -1
  169. package/dist/phases/ship.js +24 -16
  170. package/dist/phases/ship.js.map +1 -1
  171. package/dist/public-api-keys.d.ts +3 -0
  172. package/dist/public-api-keys.d.ts.map +1 -0
  173. package/dist/public-api-keys.js +76 -0
  174. package/dist/public-api-keys.js.map +1 -0
  175. package/dist/queue/activity.d.ts +21 -0
  176. package/dist/queue/activity.d.ts.map +1 -1
  177. package/dist/queue/activity.js +44 -0
  178. package/dist/queue/activity.js.map +1 -1
  179. package/dist/queue/claim-liveness.d.ts +17 -0
  180. package/dist/queue/claim-liveness.d.ts.map +1 -0
  181. package/dist/queue/claim-liveness.js +25 -0
  182. package/dist/queue/claim-liveness.js.map +1 -0
  183. package/dist/queue/claim-settle.d.ts +19 -0
  184. package/dist/queue/claim-settle.d.ts.map +1 -0
  185. package/dist/queue/claim-settle.js +19 -0
  186. package/dist/queue/claim-settle.js.map +1 -0
  187. package/dist/queue/fake-issue-comments.d.ts +4 -0
  188. package/dist/queue/fake-issue-comments.d.ts.map +1 -0
  189. package/dist/queue/fake-issue-comments.js +22 -0
  190. package/dist/queue/fake-issue-comments.js.map +1 -0
  191. package/dist/queue/github-errors.d.ts +3 -0
  192. package/dist/queue/github-errors.d.ts.map +1 -0
  193. package/dist/queue/github-errors.js +10 -0
  194. package/dist/queue/github-errors.js.map +1 -0
  195. package/dist/queue/github-queue.d.ts +5 -3
  196. package/dist/queue/github-queue.d.ts.map +1 -1
  197. package/dist/queue/github-queue.js +6 -5
  198. package/dist/queue/github-queue.js.map +1 -1
  199. package/dist/queue/issue-comments.d.ts +32 -0
  200. package/dist/queue/issue-comments.d.ts.map +1 -0
  201. package/dist/queue/issue-comments.js +29 -0
  202. package/dist/queue/issue-comments.js.map +1 -0
  203. package/dist/queue/prerequisite-order.d.ts +30 -0
  204. package/dist/queue/prerequisite-order.d.ts.map +1 -0
  205. package/dist/queue/prerequisite-order.js +92 -0
  206. package/dist/queue/prerequisite-order.js.map +1 -0
  207. package/dist/queue/stale-claims.d.ts.map +1 -1
  208. package/dist/queue/stale-claims.js +6 -18
  209. package/dist/queue/stale-claims.js.map +1 -1
  210. package/dist/queue/unpark.d.ts +5 -0
  211. package/dist/queue/unpark.d.ts.map +1 -1
  212. package/dist/queue/unpark.js +10 -0
  213. package/dist/queue/unpark.js.map +1 -1
  214. package/dist/readiness/decompose.d.ts +2 -7
  215. package/dist/readiness/decompose.d.ts.map +1 -1
  216. package/dist/readiness/decompose.js.map +1 -1
  217. package/dist/router/breaker.d.ts +19 -2
  218. package/dist/router/breaker.d.ts.map +1 -1
  219. package/dist/router/breaker.js +26 -4
  220. package/dist/router/breaker.js.map +1 -1
  221. package/dist/router/context-ceiling.d.ts +18 -0
  222. package/dist/router/context-ceiling.d.ts.map +1 -0
  223. package/dist/router/context-ceiling.js +29 -0
  224. package/dist/router/context-ceiling.js.map +1 -0
  225. package/dist/router/index.d.ts +24 -25
  226. package/dist/router/index.d.ts.map +1 -1
  227. package/dist/router/index.js +73 -324
  228. package/dist/router/index.js.map +1 -1
  229. package/dist/run/adopt-pr.d.ts +1 -0
  230. package/dist/run/adopt-pr.d.ts.map +1 -1
  231. package/dist/run/adopt-pr.js +21 -30
  232. package/dist/run/adopt-pr.js.map +1 -1
  233. package/dist/run/attribution.d.ts +3 -1
  234. package/dist/run/attribution.d.ts.map +1 -1
  235. package/dist/run/attribution.js.map +1 -1
  236. package/dist/run/lane-file-guard.d.ts +2 -2
  237. package/dist/run/lane-file-guard.d.ts.map +1 -1
  238. package/dist/run/lane-file-guard.js +4 -9
  239. package/dist/run/lane-file-guard.js.map +1 -1
  240. package/dist/run/lane-install.d.ts +31 -0
  241. package/dist/run/lane-install.d.ts.map +1 -0
  242. package/dist/run/lane-install.js +49 -0
  243. package/dist/run/lane-install.js.map +1 -0
  244. package/dist/run/park-comment.d.ts +23 -1
  245. package/dist/run/park-comment.d.ts.map +1 -1
  246. package/dist/run/park-comment.js +29 -5
  247. package/dist/run/park-comment.js.map +1 -1
  248. package/dist/run/ports.d.ts +2 -0
  249. package/dist/run/ports.d.ts.map +1 -1
  250. package/dist/run/ports.js +1 -0
  251. package/dist/run/ports.js.map +1 -1
  252. package/dist/run/pr-lookup.d.ts +56 -0
  253. package/dist/run/pr-lookup.d.ts.map +1 -0
  254. package/dist/run/pr-lookup.js +67 -0
  255. package/dist/run/pr-lookup.js.map +1 -0
  256. package/dist/run/provider-failure-recorder.d.ts +16 -0
  257. package/dist/run/provider-failure-recorder.d.ts.map +1 -0
  258. package/dist/run/provider-failure-recorder.js +26 -0
  259. package/dist/run/provider-failure-recorder.js.map +1 -0
  260. package/dist/run/run-issue.d.ts +5 -0
  261. package/dist/run/run-issue.d.ts.map +1 -1
  262. package/dist/run/run-issue.js +46 -38
  263. package/dist/run/run-issue.js.map +1 -1
  264. package/dist/run/state.d.ts +19 -0
  265. package/dist/run/state.d.ts.map +1 -1
  266. package/dist/run/state.js +52 -2
  267. package/dist/run/state.js.map +1 -1
  268. package/dist/sim/pipeline.js +1 -1
  269. package/dist/sim/pipeline.js.map +1 -1
  270. package/dist/types/ci-evidence.d.ts +54 -0
  271. package/dist/types/ci-evidence.d.ts.map +1 -0
  272. package/dist/types/ci-evidence.js +3 -0
  273. package/dist/types/ci-evidence.js.map +1 -0
  274. package/dist/types/index.d.ts +5 -54
  275. package/dist/types/index.d.ts.map +1 -1
  276. package/dist/usage/index.d.ts +1 -0
  277. package/dist/usage/index.d.ts.map +1 -1
  278. package/dist/usage/index.js +8 -1
  279. package/dist/usage/index.js.map +1 -1
  280. package/dist/usage/subscription.d.ts +3 -0
  281. package/dist/usage/subscription.d.ts.map +1 -1
  282. package/dist/usage/subscription.js +9 -1
  283. package/dist/usage/subscription.js.map +1 -1
  284. package/dist/utils/index.d.ts +12 -2
  285. package/dist/utils/index.d.ts.map +1 -1
  286. package/dist/utils/index.js +11 -6
  287. package/dist/utils/index.js.map +1 -1
  288. package/dist/utils/lane-removal.d.ts +16 -0
  289. package/dist/utils/lane-removal.d.ts.map +1 -0
  290. package/dist/utils/lane-removal.js +62 -0
  291. package/dist/utils/lane-removal.js.map +1 -0
  292. package/dist/utils/median.d.ts +4 -0
  293. package/dist/utils/median.d.ts.map +1 -0
  294. package/dist/utils/median.js +11 -0
  295. package/dist/utils/median.js.map +1 -0
  296. package/dist/utils/worktree-gc.d.ts +1 -171
  297. package/dist/utils/worktree-gc.d.ts.map +1 -1
  298. package/dist/utils/worktree-gc.js +2 -739
  299. package/dist/utils/worktree-gc.js.map +1 -1
  300. package/dist/utils/worktree-keeps.d.ts +1 -19
  301. package/dist/utils/worktree-keeps.d.ts.map +1 -1
  302. package/dist/utils/worktree-keeps.js +2 -64
  303. package/dist/utils/worktree-keeps.js.map +1 -1
  304. package/dist/utils/worktree-name.d.ts +1 -9
  305. package/dist/utils/worktree-name.d.ts.map +1 -1
  306. package/dist/utils/worktree-name.js +2 -30
  307. package/dist/utils/worktree-name.js.map +1 -1
  308. package/dist/worktree/worktree-gc-decide.d.ts +40 -0
  309. package/dist/worktree/worktree-gc-decide.d.ts.map +1 -0
  310. package/dist/worktree/worktree-gc-decide.js +120 -0
  311. package/dist/worktree/worktree-gc-decide.js.map +1 -0
  312. package/dist/worktree/worktree-gc-evidence.d.ts +94 -0
  313. package/dist/worktree/worktree-gc-evidence.d.ts.map +1 -0
  314. package/dist/worktree/worktree-gc-evidence.js +218 -0
  315. package/dist/worktree/worktree-gc-evidence.js.map +1 -0
  316. package/dist/worktree/worktree-gc-issues.d.ts +26 -0
  317. package/dist/worktree/worktree-gc-issues.d.ts.map +1 -0
  318. package/dist/worktree/worktree-gc-issues.js +51 -0
  319. package/dist/worktree/worktree-gc-issues.js.map +1 -0
  320. package/dist/worktree/worktree-gc-scrub.d.ts +10 -0
  321. package/dist/worktree/worktree-gc-scrub.d.ts.map +1 -0
  322. package/dist/worktree/worktree-gc-scrub.js +89 -0
  323. package/dist/worktree/worktree-gc-scrub.js.map +1 -0
  324. package/dist/worktree/worktree-gc-types.d.ts +144 -0
  325. package/dist/worktree/worktree-gc-types.d.ts.map +1 -0
  326. package/dist/worktree/worktree-gc-types.js +33 -0
  327. package/dist/worktree/worktree-gc-types.js.map +1 -0
  328. package/dist/worktree/worktree-gc.d.ts +32 -0
  329. package/dist/worktree/worktree-gc.d.ts.map +1 -0
  330. package/dist/worktree/worktree-gc.js +321 -0
  331. package/dist/worktree/worktree-gc.js.map +1 -0
  332. package/dist/worktree/worktree-keeps.d.ts +20 -0
  333. package/dist/worktree/worktree-keeps.d.ts.map +1 -0
  334. package/dist/worktree/worktree-keeps.js +65 -0
  335. package/dist/worktree/worktree-keeps.js.map +1 -0
  336. package/dist/worktree/worktree-name.d.ts +10 -0
  337. package/dist/worktree/worktree-name.d.ts.map +1 -0
  338. package/dist/worktree/worktree-name.js +31 -0
  339. package/dist/worktree/worktree-name.js.map +1 -0
  340. package/package.json +5 -5
  341. package/dist/utils/worktree-gc-issues.d.ts +0 -22
  342. package/dist/utils/worktree-gc-issues.d.ts.map +0 -1
  343. package/dist/utils/worktree-gc-issues.js +0 -80
  344. package/dist/utils/worktree-gc-issues.js.map +0 -1
@@ -0,0 +1,218 @@
1
+ // src/worktree/worktree-gc-evidence.ts — gathers one evidence record per worktree for decideWorktree
2
+ import { exec as execCb } from 'node:child_process';
3
+ import { statSync } from 'node:fs';
4
+ import { basename, join } from 'node:path';
5
+ import { promisify } from 'node:util';
6
+ import { shellEscape } from '../utils/index.js';
7
+ import { claimOf, dispositionOf, existenceOf, fetchIssueRecord, } from './worktree-gc-issues.js';
8
+ const exec = promisify(execCb);
9
+ export async function defaultRunCommand(cmd, opts) {
10
+ const { stdout } = await exec(cmd, opts);
11
+ return { stdout: stdout.toString() };
12
+ }
13
+ function safeExec(runCommand, cmd, opts) {
14
+ return runCommand(cmd, opts).catch(() => null);
15
+ }
16
+ export async function resolveMainTip(runCommand, repoRoot) {
17
+ const result = await safeExec(runCommand, 'git rev-parse --verify origin/main', { cwd: repoRoot });
18
+ const sha = result?.stdout.trim() ?? '';
19
+ return sha === '' ? null : sha;
20
+ }
21
+ async function hasPriorPushEvidence(runCommand, repoRoot, branch) {
22
+ const trackingRef = await safeExec(runCommand, `git rev-parse --verify --quiet ${shellEscape(`refs/remotes/origin/${branch}`)}`, { cwd: repoRoot });
23
+ if (trackingRef !== null && trackingRef.stdout.trim() !== '')
24
+ return true;
25
+ const reflog = await safeExec(runCommand, `git reflog show --no-abbrev ${shellEscape(`refs/remotes/origin/${branch}`)}`, { cwd: repoRoot });
26
+ if (reflog !== null && reflog.stdout.trim() !== '')
27
+ return true;
28
+ const upstream = await safeExec(runCommand, `git config --get ${shellEscape(`branch.${branch}.merge`)}`, {
29
+ cwd: repoRoot,
30
+ });
31
+ // git sets branch.<name>.merge automatically at worktree-creation time from the start point
32
+ // (e.g. `git worktree add -b <branch> <path> origin/main` sets it to refs/heads/main), so a
33
+ // non-empty value alone is not proof of a push. Only `git push -u origin <branch>` points it at
34
+ // the branch's own ref — require that exact match.
35
+ return upstream !== null && upstream.stdout.trim() === `refs/heads/${branch}`;
36
+ }
37
+ /** GitHub's verdict on the branch's PRs. `null` when no client/repo is available or the query
38
+ * fails — the caller must then fall back to local evidence (fail-safe: keep on doubt). */
39
+ async function resolvePrState(octokit, repo, branch, log) {
40
+ if (!octokit || !repo)
41
+ return null;
42
+ const [owner, repoName] = repo.split('/');
43
+ try {
44
+ const { data } = await octokit.rest.pulls.list({
45
+ owner,
46
+ repo: repoName,
47
+ state: 'all',
48
+ head: `${owner}:${branch}`,
49
+ });
50
+ if (data.some((pr) => pr.state === 'open'))
51
+ return 'open';
52
+ const merged = data.find((pr) => pr.merged_at != null);
53
+ if (merged)
54
+ return 'merged';
55
+ if (data.some((pr) => pr.state === 'closed'))
56
+ return 'closed';
57
+ return 'none';
58
+ }
59
+ catch (err) {
60
+ log('warn', `worktree-gc: GitHub PR query failed for ${branch} (${err?.message ?? String(err)}) — using local evidence only`);
61
+ return null;
62
+ }
63
+ }
64
+ /** The lane issue number a candidate belongs to: capture group 1 of the lane-branch shape
65
+ * `<prefix>/<n>-*`, falling back to a trailing `-<n>` in the directory basename (covers
66
+ * detached checkouts of factory-named paths). `null` when neither matches. */
67
+ export function laneIssueNumber(entry, lanePattern) {
68
+ const fromBranch = entry.branch?.match(lanePattern);
69
+ if (fromBranch)
70
+ return Number(fromBranch[1]);
71
+ const fromPath = basename(entry.path).match(/-(\d+)$/);
72
+ return fromPath ? Number(fromPath[1]) : null;
73
+ }
74
+ /** A worktree is clean when it has no modified tracked files. `--untracked-files=no` deliberately
75
+ * ignores untracked build residue (node_modules, artifacts) — the "live work" signal is tracked-file
76
+ * modifications. A probe failure (`safeExec` null) ⇒ false ⇒ keep. */
77
+ export async function isWorktreeClean(runCommand, worktreePath) {
78
+ const result = await safeExec(runCommand, 'git status --porcelain --untracked-files=no', { cwd: worktreePath });
79
+ return result !== null && result.stdout.trim() === '';
80
+ }
81
+ /** True when `git status --porcelain --untracked-files=normal` output lists an untracked path. */
82
+ export function hasUntrackedLine(stdout) {
83
+ return stdout.split('\n').some((l) => l.startsWith('?? '));
84
+ }
85
+ /** True when the worktree has untracked, non-ignored files; null when the probe failed (⇒ hold).
86
+ * Ignored files are excluded because there is no `--ignored` (#3318). */
87
+ export async function hasUntrackedFiles(runCommand, worktreePath) {
88
+ const result = await safeExec(runCommand, 'git status --porcelain --untracked-files=normal', { cwd: worktreePath });
89
+ return result === null ? null : hasUntrackedLine(result.stdout);
90
+ }
91
+ /** Commits reachable from `rev` that are on no `origin` ref; null when the probe fails or is unparseable (⇒ keep). */
92
+ export async function countUnpushedCommits(runCommand, repoRoot, rev) {
93
+ const result = await safeExec(runCommand, `git rev-list --count ${shellEscape(rev)} --not --remotes=origin`, {
94
+ cwd: repoRoot,
95
+ });
96
+ const n = result === null ? NaN : Number.parseInt(result.stdout.trim(), 10);
97
+ return Number.isInteger(n) ? n : null;
98
+ }
99
+ /** True only when `head` has exactly 0 commits ahead of origin/main — a lane that has not committed
100
+ * yet (every lane starts at origin/main), never proof of a merge (#2964). Probe failure ⇒ false. */
101
+ export async function isZeroCommitLane(runCommand, repoRoot, head) {
102
+ if (head === null)
103
+ return false;
104
+ const result = await safeExec(runCommand, `git rev-list --count origin/main..${shellEscape(head)}`, {
105
+ cwd: repoRoot,
106
+ });
107
+ return result !== null && result.stdout.trim() === '0';
108
+ }
109
+ export function computeAgeDays(worktreePath, now, log) {
110
+ const gitPath = join(worktreePath, '.git');
111
+ try {
112
+ const mtimeMs = statSync(gitPath).mtimeMs;
113
+ return (now() - mtimeMs) / (24 * 60 * 60 * 1000);
114
+ }
115
+ catch (err) {
116
+ // An inconclusive probe must never mean "delete" — this directory may hold the only copy of
117
+ // uncommitted work.
118
+ log('warn', `worktree-gc: cannot stat ${gitPath} (${err?.message ?? String(err)}) — treating as age 0 (keeping)`);
119
+ return 0;
120
+ }
121
+ }
122
+ export function createEvidenceContext(opts, deps) {
123
+ return {
124
+ repoRoot: opts.repoRoot,
125
+ repo: opts.repo,
126
+ dryRun: opts.dryRun,
127
+ lanePattern: opts.lanePattern,
128
+ protectedIssues: opts.protectedIssues,
129
+ keeps: opts.keeps,
130
+ mainTip: opts.mainTip,
131
+ runCommand: deps.runCommand,
132
+ now: deps.now,
133
+ log: deps.log,
134
+ octokit: deps.octokit,
135
+ issueWarnDedup: deps.issueWarnDedup,
136
+ issueRecords: new Map(),
137
+ prStates: new Map(),
138
+ };
139
+ }
140
+ function issueRecordFor(ctx, issue) {
141
+ let record = ctx.issueRecords.get(issue);
142
+ if (!record) {
143
+ record = fetchIssueRecord(ctx.octokit, ctx.repo, issue, ctx.log, ctx.issueWarnDedup);
144
+ ctx.issueRecords.set(issue, record);
145
+ }
146
+ return record;
147
+ }
148
+ function prStateFor(ctx, branch) {
149
+ let state = ctx.prStates.get(branch);
150
+ if (!state) {
151
+ state = resolvePrState(ctx.octokit, ctx.repo, branch, ctx.log);
152
+ ctx.prStates.set(branch, state);
153
+ }
154
+ return state;
155
+ }
156
+ const NO_GIT = {
157
+ clean: false,
158
+ zeroCommit: false,
159
+ priorPush: false,
160
+ remoteBranch: null,
161
+ headIsAncestorOfMain: false,
162
+ mainTip: null,
163
+ unpushedCount: null,
164
+ untracked: false,
165
+ };
166
+ async function gatherGitEvidence(ctx, entry, prState, probeUntracked) {
167
+ const { runCommand, repoRoot } = ctx;
168
+ const { branch, head } = entry;
169
+ const lsRemote = branch
170
+ ? await safeExec(runCommand, `git ls-remote --heads origin ${shellEscape(branch)}`, { cwd: repoRoot })
171
+ : null;
172
+ const ancestor = head === null
173
+ ? null
174
+ : await safeExec(runCommand, `git merge-base --is-ancestor ${shellEscape(head)} origin/main`, { cwd: repoRoot });
175
+ return {
176
+ clean: await isWorktreeClean(runCommand, entry.path),
177
+ zeroCommit: await isZeroCommitLane(runCommand, repoRoot, head),
178
+ // Only the no-PR-verdict local-evidence rules consult push history.
179
+ priorPush: branch && (prState === null || prState === 'none')
180
+ ? await hasPriorPushEvidence(runCommand, repoRoot, branch)
181
+ : false,
182
+ remoteBranch: lsRemote === null ? null : lsRemote.stdout.trim() === '' ? 'absent' : 'present',
183
+ headIsAncestorOfMain: ancestor !== null,
184
+ mainTip: ctx.mainTip,
185
+ unpushedCount: head ? await countUnpushedCommits(runCommand, repoRoot, head) : null,
186
+ untracked: probeUntracked ? await hasUntrackedFiles(runCommand, entry.path) : false,
187
+ };
188
+ }
189
+ /** Collects every fact decideWorktree may consult. Probes are read-only, so gathering them up
190
+ * front cannot change their answers. A protected entry skips git probes (and, outside dry-run,
191
+ * GitHub lookups: dry-run's diagnostics cover every candidate). */
192
+ export async function gatherWorktreeEvidence(ctx, entry) {
193
+ const issue = laneIssueNumber(entry, ctx.lanePattern);
194
+ const isProtected = issue !== null && ctx.protectedIssues?.has(issue) === true;
195
+ const base = { path: entry.path, branch: entry.branch, head: entry.head, issue, protected: isProtected };
196
+ const lookUp = !isProtected || ctx.dryRun;
197
+ const record = lookUp && issue !== null ? await issueRecordFor(ctx, issue) : { kind: 'not-configured' };
198
+ const prState = lookUp && entry.branch ? await prStateFor(ctx, entry.branch) : null;
199
+ const issueFields = {
200
+ disposition: issue === null ? null : dispositionOf(record, issue),
201
+ existence: existenceOf(record),
202
+ claim: issue === null ? 'unknown' : claimOf(record, issue),
203
+ ...(record.kind === 'error' || record.kind === 'not-found' ? { issueError: record.message } : {}),
204
+ };
205
+ if (isProtected) {
206
+ return { ...base, keep: null, ageDays: 0, ...issueFields, prState, git: NO_GIT };
207
+ }
208
+ const keep = issue === null ? undefined : ctx.keeps.get(issue);
209
+ return {
210
+ ...base,
211
+ keep: keep ? { issue: keep.issue, reason: keep.reason } : null,
212
+ ageDays: computeAgeDays(entry.path, ctx.now, ctx.log),
213
+ ...issueFields,
214
+ prState,
215
+ git: await gatherGitEvidence(ctx, entry, prState, !keep && issueFields.disposition === 'reap-parked'),
216
+ };
217
+ }
218
+ //# sourceMappingURL=worktree-gc-evidence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-gc-evidence.js","sourceRoot":"","sources":["../../src/worktree/worktree-gc-evidence.ts"],"names":[],"mappings":"AAAA,qGAAqG;AAErG,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,OAAO,EACP,aAAa,EACb,WAAW,EACX,gBAAgB,GAGjB,MAAM,yBAAyB,CAAC;AAIjC,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAE/B,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,GAAW,EAAE,IAAuB;IAC1E,MAAM,EAAE,MAAM,EA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AU,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClG,CAAC;IAEF,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IACnF,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC/D,OAAO;QACL,GAAG,IAAI;QACP,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI;QAC9D,OAAO,EAAE,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;QACrD,GAAG,WAAW;QACd,OAAO;QACP,GAAG,EAAE,MAAM,iBAAiB,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,IAAI,IAAI,WAAW,CAAC,WAAW,KAAK,aAAa,CAAC;KACtG,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { EventKind } from '../events/kinds.js';
2
+ import type { IssueWarnDedup, SweepDeps } from './worktree-gc-types.js';
3
+ /** The owning issue's verdict on a lane worktree. `null` means "no verdict" (no client/repo,
4
+ * or the query failed) and must always fall back to the PR-state/local-evidence rules. */
5
+ export type IssueDisposition = 'reap-closed' | 'reap-parked' | 'reap-decomposed' | 'keep-claimed' | 'keep';
6
+ /** One `issues.get` response (or why there is none), fetched once per issue per sweep; the
7
+ * disposition, existence and claim verdicts are all derived from it. */
8
+ export type IssueRecord = {
9
+ kind: 'ok';
10
+ state: string;
11
+ labels: string[];
12
+ } | {
13
+ kind: 'not-found';
14
+ message: string;
15
+ } | {
16
+ kind: 'error';
17
+ message: string;
18
+ } | {
19
+ kind: 'not-configured';
20
+ };
21
+ export declare function fetchIssueRecord(octokit: SweepDeps['octokit'], repo: string | undefined, issue: number, log: (type: EventKind, msg: string) => void, issueWarnDedup: IssueWarnDedup): Promise<IssueRecord>;
22
+ /** The disposition resolveIssueDisposition computes, from an already-fetched record. */
23
+ export declare function dispositionOf(record: IssueRecord, _issue: number): IssueDisposition | null;
24
+ export declare function existenceOf(record: IssueRecord): 'exists' | 'not-found' | 'error' | 'not-configured';
25
+ export declare function claimOf(record: IssueRecord, _issue: number): 'claimed' | 'unclaimed' | 'unknown';
26
+ //# sourceMappingURL=worktree-gc-issues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-gc-issues.d.ts","sourceRoot":"","sources":["../../src/worktree/worktree-gc-issues.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExE;2FAC2F;AAC3F,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,aAAa,GAAG,iBAAiB,GAAG,cAAc,GAAG,MAAM,CAAC;AAE3G;yEACyE;AACzE,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAE/B,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,EAC7B,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,EAC3C,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,WAAW,CAAC,CAmBtB;AAMD,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAQ1F;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,gBAAgB,CAGpG;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAGhG"}
@@ -0,0 +1,51 @@
1
+ import { claimIsLive, claimLiveness } from '../queue/claim-liveness.js';
2
+ import { DECOMPOSED_LABEL, PARKED_LABEL } from '../queue/github-queue.js';
3
+ export async function fetchIssueRecord(octokit, repo, issue, log, issueWarnDedup) {
4
+ if (!octokit || !repo)
5
+ return { kind: 'not-configured' };
6
+ const [owner, repoName] = repo.split('/');
7
+ try {
8
+ const { data } = await octokit.rest.issues.get({ owner, repo: repoName, issue_number: issue });
9
+ const labels = (data.labels ?? []).map((l) => (typeof l === 'string' ? l : (l?.name ?? '')));
10
+ return { kind: 'ok', state: data.state, labels };
11
+ }
12
+ catch (err) {
13
+ const message = err?.message ?? String(err);
14
+ if (issueWarnDedup.record(issue)) {
15
+ log('warn', `worktree-gc: GitHub issue query failed for #${issue} (${message}) — using PR/local evidence only`);
16
+ }
17
+ else {
18
+ log('warn', `worktree-gc: GitHub issue query failed for #${issue} — suppressed ${issueWarnDedup.suppressedCount(issue)} repeated warning(s) (using PR/local evidence only)`);
19
+ }
20
+ return { kind: err?.status === 404 ? 'not-found' : 'error', message };
21
+ }
22
+ }
23
+ function hasLiveClaim(labels) {
24
+ return claimIsLive(claimLiveness(labels, Date.now()));
25
+ }
26
+ /** The disposition resolveIssueDisposition computes, from an already-fetched record. */
27
+ export function dispositionOf(record, _issue) {
28
+ if (record.kind !== 'ok')
29
+ return null;
30
+ if (record.state === 'closed')
31
+ return 'reap-closed';
32
+ // A lapsed lease is expired in the shared claim verdict and does not protect (#2964, #3442).
33
+ if (hasLiveClaim(record.labels))
34
+ return 'keep-claimed';
35
+ if (record.labels.includes(PARKED_LABEL))
36
+ return 'reap-parked';
37
+ if (record.labels.includes(DECOMPOSED_LABEL))
38
+ return 'reap-decomposed';
39
+ return 'keep';
40
+ }
41
+ export function existenceOf(record) {
42
+ if (record.kind === 'ok')
43
+ return 'exists';
44
+ return record.kind;
45
+ }
46
+ export function claimOf(record, _issue) {
47
+ if (record.kind !== 'ok')
48
+ return 'unknown';
49
+ return hasLiveClaim(record.labels) ? 'claimed' : 'unclaimed';
50
+ }
51
+ //# sourceMappingURL=worktree-gc-issues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-gc-issues.js","sourceRoot":"","sources":["../../src/worktree/worktree-gc-issues.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAe1E,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAA6B,EAC7B,IAAwB,EACxB,KAAa,EACb,GAA2C,EAC3C,cAA8B;IAE9B,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1C,IAAI,CAAC;QACH,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,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KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACtC,IAAI,MAAM,CAAC,KAAK,KAAK,QAAQ;QAAE,OAAO,aAAa,CAAC;IACpD,6FAA6F;IAC7F,IAAI,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC;QAAE,OAAO,cAAc,CAAC;IACvD,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC;QAAE,OAAO,aAAa,CAAC;IAC/D,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QAAE,OAAO,iBAAiB,CAAC;IACvE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAmB;IAC7C,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,QAAQ,CAAC;IAC1C,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,MAAmB,EAAE,MAAc;IACzD,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAC3C,OAAO,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare function findCredentialFiles(worktreePath: string): string[];
2
+ /** Zero a file in place through one fd opened with O_NOFOLLOW. The worktree's agent can swap
3
+ * a credential file for a symlink after `findCredentialFiles` walks it; a path-based
4
+ * stat + write would then zero the link's target (e.g. `~/.ssh/id_*`). Throws ELOOP on a
5
+ * symlink and refuses anything that is not a regular file. */
6
+ export declare function zeroFill(filePath: string): void;
7
+ /** Zero-fill then delete. A symlink is unlinked without zeroing — rm removes the link, never
8
+ * its target. */
9
+ export declare function scrubFile(filePath: string): void;
10
+ //# sourceMappingURL=worktree-gc-scrub.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-gc-scrub.d.ts","sourceRoot":"","sources":["../../src/worktree/worktree-gc-scrub.ts"],"names":[],"mappings":"AAQA,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,CA0BlE;AA4BD;;;+DAG+D;AAC/D,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAa/C;AAED;kBACkB;AAClB,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAOhD"}
@@ -0,0 +1,89 @@
1
+ // src/worktree/worktree-gc-scrub.ts — credential discovery and in-place scrub for reaped worktrees
2
+ import { closeSync, constants, fstatSync, lstatSync, openSync, readdirSync, rmSync, writeSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ const CREDENTIAL_BASENAMES = new Set(['.git-credentials', '.npmrc']);
5
+ export function findCredentialFiles(worktreePath) {
6
+ const found = [];
7
+ let topLevel;
8
+ try {
9
+ topLevel = readdirSync(worktreePath);
10
+ }
11
+ catch {
12
+ return found;
13
+ }
14
+ for (const name of topLevel) {
15
+ if (name === '.env' || name.startsWith('.env.') || CREDENTIAL_BASENAMES.has(name)) {
16
+ const filePath = join(worktreePath, name);
17
+ try {
18
+ // lstat, not stat: a symlinked `.env` must never lead the scrub outside the worktree.
19
+ if (lstatSync(filePath).isFile())
20
+ found.push(filePath);
21
+ }
22
+ catch { }
23
+ }
24
+ }
25
+ const claudeDir = join(worktreePath, '.claude');
26
+ if (isRealDirectory(claudeDir)) {
27
+ walkFiles(claudeDir, found);
28
+ }
29
+ return found;
30
+ }
31
+ function walkFiles(dir, found) {
32
+ let entries;
33
+ try {
34
+ entries = readdirSync(dir, { withFileTypes: true });
35
+ }
36
+ catch {
37
+ return;
38
+ }
39
+ for (const entry of entries) {
40
+ const full = join(dir, entry.name);
41
+ if (entry.isDirectory()) {
42
+ walkFiles(full, found);
43
+ }
44
+ else if (entry.isFile()) {
45
+ found.push(full);
46
+ }
47
+ }
48
+ }
49
+ function isRealDirectory(path) {
50
+ try {
51
+ return lstatSync(path).isDirectory();
52
+ }
53
+ catch {
54
+ return false;
55
+ }
56
+ }
57
+ /** Zero a file in place through one fd opened with O_NOFOLLOW. The worktree's agent can swap
58
+ * a credential file for a symlink after `findCredentialFiles` walks it; a path-based
59
+ * stat + write would then zero the link's target (e.g. `~/.ssh/id_*`). Throws ELOOP on a
60
+ * symlink and refuses anything that is not a regular file. */
61
+ export function zeroFill(filePath) {
62
+ const fd = openSync(filePath, constants.O_WRONLY | constants.O_NOFOLLOW);
63
+ try {
64
+ const stat = fstatSync(fd);
65
+ if (!stat.isFile())
66
+ throw new Error(`refusing to zero-fill non-regular file ${filePath}`);
67
+ const zeros = Buffer.alloc(Math.min(stat.size, 64 * 1024));
68
+ let offset = 0;
69
+ while (offset < stat.size) {
70
+ offset += writeSync(fd, zeros, 0, Math.min(zeros.length, stat.size - offset), offset);
71
+ }
72
+ }
73
+ finally {
74
+ closeSync(fd);
75
+ }
76
+ }
77
+ /** Zero-fill then delete. A symlink is unlinked without zeroing — rm removes the link, never
78
+ * its target. */
79
+ export function scrubFile(filePath) {
80
+ try {
81
+ zeroFill(filePath);
82
+ }
83
+ catch (err) {
84
+ if (err?.code !== 'ELOOP')
85
+ throw err;
86
+ }
87
+ rmSync(filePath, { force: true });
88
+ }
89
+ //# sourceMappingURL=worktree-gc-scrub.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-gc-scrub.js","sourceRoot":"","sources":["../../src/worktree/worktree-gc-scrub.ts"],"names":[],"mappings":"AAAA,mGAAmG;AAGnG,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/G,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC,CAAC;AAErE,M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B,CAAC;AACH,CAAC;AAED;kBACkB;AAClB,MAAM,UAAU,SAAS,CAAC,QAAgB;IACxC,IAAI,CAAC;QACH,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAK,GAA6B,EAAE,IAAI,KAAK,OAAO;YAAE,MAAM,GAAG,CAAC;IAClE,CAAC;IACD,MAAM,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,144 @@
1
+ import type { Octokit } from '@octokit/rest';
2
+ import type { EventKind } from '../events/kinds.js';
3
+ import type { WorktreeSandbox } from '../utils/microvm.js';
4
+ export type GcReason = 'merged' | 'remote-gone' | 'ttl-expired' | 'issue-closed' | 'issue-parked' | 'issue-decomposed' | 'issue-not-found' | 'no-active-claim';
5
+ /** GitHub's verdict on a candidate branch's PR(s), read via pulls.list (state=all,
6
+ * head=owner:branch). `null` means "no verdict" (no client/repo, or the query failed) —
7
+ * which must always fall back to the #639 local-evidence rules. */
8
+ export type GcHeadPrState = 'open' | 'merged' | 'closed' | 'none';
9
+ export interface WorktreeListEntry {
10
+ path: string;
11
+ head: string | null;
12
+ branch: string | null;
13
+ }
14
+ export interface GcCandidate {
15
+ path: string;
16
+ branch: string | null;
17
+ ageDays: number;
18
+ reason: GcReason;
19
+ scrubbedFiles: string[];
20
+ /** True when the candidate's local branch was force-deleted after removal. False when the
21
+ * reason was not branch-reapable, when the candidate was detached, when this was a dry run,
22
+ * or when `git branch -D` failed (a warn is logged in that last case). */
23
+ branchDeleted: boolean;
24
+ /** Set at decision time for the issue-driven reasons (`issue-closed` / `issue-parked`): true
25
+ * only when the branch's content is provably on the remote (a PR ever existed, the remote
26
+ * branch is live, or the tip is an ancestor of origin/main). An unpushed parked attempt's
27
+ * branch stays as its only handle. */
28
+ branchReapable?: boolean;
29
+ /** `'remove'` for every hard-evidence reason (merge/remote/ttl/issue-disposition proof).
30
+ * `'quarantine'` for the two heuristic reasons (`issue-not-found` / `no-active-claim`, #1355)
31
+ * that carry no merge/ancestry proof: the worktree is relocated under the quarantine
32
+ * directory instead of deleted, and its branch is never force-deleted (see ADR, this PR). */
33
+ action: 'remove' | 'quarantine';
34
+ /** Set only in real mode, only for a `'quarantine'` action, only once the move succeeds — the
35
+ * path the worktree was relocated to. Absent for `'remove'`, for dry-run, and when the move
36
+ * itself failed (the worktree is then left in place; see the `warn` log for the failure). */
37
+ quarantinedTo?: string;
38
+ }
39
+ /** A factory-owned worktree whose lane-branch issue number could not be confirmed to exist on
40
+ * GitHub. Dry-run surfaces every such candidate here regardless of its other GcReason evidence
41
+ * (see ADR-0088); real mode instead quarantines it via `removed`/`GcReason.issue-not-found`
42
+ * (only when no hard-evidence reason already claimed it — see ADR, this PR). */
43
+ export interface Issue404Candidate {
44
+ path: string;
45
+ branch: string | null;
46
+ issue: number;
47
+ }
48
+ /** A factory-owned worktree whose branch's PR is merged or closed but whose owning issue has no
49
+ * active `factory:claimed-by:*` label. Dry-run surfaces every such candidate here regardless of
50
+ * its other GcReason evidence; real mode instead quarantines it via
51
+ * `removed`/`GcReason.no-active-claim` (only when no hard-evidence reason already claimed it —
52
+ * see ADR, this PR). */
53
+ export interface NoActiveClaimCandidate {
54
+ path: string;
55
+ branch: string | null;
56
+ issue: number;
57
+ prState: 'merged' | 'closed';
58
+ }
59
+ /** A candidate GC would otherwise reap on hard issue evidence but kept to protect local work —
60
+ * surfaced so the operator sees why it survived (#1756). */
61
+ export interface GcHeldCandidate {
62
+ path: string;
63
+ branch: string | null;
64
+ issue: number;
65
+ why: string;
66
+ }
67
+ /** A worktree kept by a worktree-keeps.json record (#3316). */
68
+ export interface GcKeptCandidate {
69
+ path: string;
70
+ branch: string | null;
71
+ issue: number;
72
+ reason: string;
73
+ }
74
+ export interface GcReport {
75
+ removed: GcCandidate[];
76
+ kept: number;
77
+ dryRun: boolean;
78
+ /** Dry-run only: factory-owned candidates whose lane issue number 404'd on GitHub — a strong
79
+ * signal the worktree was created for an issue that never existed. Never read by, or written
80
+ * from, GcReason/BRANCH_REAPABLE_REASONS. Always [] outside dry-run — real mode's equivalent
81
+ * signal shows up as a `removed` entry with `reason: 'issue-not-found'` instead. */
82
+ issueNotFound: Issue404Candidate[];
83
+ /** Dry-run only: factory-owned candidates whose lane issue lookup threw a non-404 error (rate
84
+ * limit, network failure) — "couldn't check," never conflated with issueNotFound's "confirmed
85
+ * gone." Always [] outside dry-run; real mode never acts on an unverifiable lookup (fail-safe:
86
+ * keeps the worktree). */
87
+ issueUnverifiable: Issue404Candidate[];
88
+ /** Dry-run only: factory-owned candidates whose branch's PR is merged or closed and whose
89
+ * owning issue carries no active `factory:claimed-by:*` label — the lane finished (or was
90
+ * abandoned) without releasing its worktree. Fail-safe: any doubt (no client/repo, lookup
91
+ * error, unresolved issue number) means "not flagged." Never read by, or written from,
92
+ * GcReason/BRANCH_REAPABLE_REASONS. Always [] outside dry-run — real mode's equivalent signal
93
+ * shows up as a `removed` entry with `reason: 'no-active-claim'` instead. */
94
+ noActiveClaim: NoActiveClaimCandidate[];
95
+ /** Decomposed-parent worktrees (`factory:decomposed`) kept because they are dirty, hold
96
+ * unpushed commits, or could not be verified (#1756). Populated in dry-run and real mode;
97
+ * every entry is also counted in `kept`. */
98
+ held: GcHeldCandidate[];
99
+ /** Worktrees kept by a worktree-keeps.json record (#3316); also counted in kept. */
100
+ keptByRecord?: GcKeptCandidate[];
101
+ /** Parked, unkept worktrees held because they have untracked files (#3318); also counted in kept. */
102
+ heldUntracked?: GcHeldCandidate[];
103
+ }
104
+ export interface SweepDeps {
105
+ runCommand?: (cmd: string, opts?: {
106
+ cwd?: string;
107
+ }) => Promise<{
108
+ stdout: string;
109
+ }>;
110
+ now?: () => number;
111
+ log?: (type: EventKind, msg: string) => void;
112
+ /** When present (with opts.repo), merged/close status is sourced from GitHub; absent or failing ⇒ local evidence only. */
113
+ octokit?: Pick<Octokit, 'rest'>;
114
+ /** The repo's current docker-sandbox descriptor (runtime + authPaths), or undefined for every
115
+ * other runtime. A reaped candidate may have been provisioned under a different runtime than
116
+ * today's config, but removeMicroVm is a no-op unless `runtime === 'docker-sandbox'` and the
117
+ * named VM exists, so passing today's descriptor for every candidate is safe and idempotent. */
118
+ sandbox?: WorktreeSandbox;
119
+ /** Dedup tracker for resolveIssueDisposition's lookup-failure warning (see IssueWarnDedup).
120
+ * Defaults to a module-level singleton shared across every sweep in the process; tests should
121
+ * inject a fresh instance to avoid bleeding suppression state across cases. */
122
+ issueWarnDedup?: IssueWarnDedup;
123
+ }
124
+ /** Dedupes resolveIssueDisposition's lookup-failure warning across repeated sweeps — the factory
125
+ * loop calls sweepWorktrees every iteration, and a worktree tied to a nonexistent issue number
126
+ * fails that lookup on every one of them. The first failure for a given issue since the last
127
+ * reconcile-clear warns in full; every following one folds into a one-line "suppressed N"
128
+ * summary instead of repeating the same text. `reconcile()` drops an issue's tracking once it's
129
+ * no longer among the sweep's candidates, so a later re-appearance (or a different worktree
130
+ * reusing the number) warns in full again. Keyed by issue number, not by worktree path, since
131
+ * the failing lookup is per-issue (see ADR, this PR). */
132
+ export declare class IssueWarnDedup {
133
+ private readonly counts;
134
+ /** Records one occurrence for `issue`. Returns true the first time since the last
135
+ * reconcile-clear (caller should log the full warning), false thereafter. */
136
+ record(issue: number): boolean;
137
+ /** Occurrences suppressed for `issue` since its last full warning (0 before the second one). */
138
+ suppressedCount(issue: number): number;
139
+ /** Drops tracking for every issue not in `activeIssues` — call once per sweep with the issue
140
+ * numbers still present among that sweep's candidates. */
141
+ reconcile(activeIssues: ReadonlySet<number>): void;
142
+ }
143
+ export declare const defaultIssueWarnDedup: IssueWarnDedup;
144
+ //# sourceMappingURL=worktree-gc-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-gc-types.d.ts","sourceRoot":"","sources":["../../src/worktree/worktree-gc-types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAA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AO,EAAE,MAAM,CAAC,CAAC;IAChC;;;qGAGiG;IACjG,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B;;oFAEgF;IAChF,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;;;;;0DAO0D;AAC1D,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IAEpD;kFAC8E;IAC9E,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAI7B;IAED,gGAAgG;IAChG,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErC;IAED;+DAC2D;IAC3D,SAAS,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAIjD;CACF;AAED,eAAO,MAAM,qBAAqB,gBAAuB,CAAC"}
@@ -0,0 +1,33 @@
1
+ // src/worktree/worktree-gc-types.ts — report, dep and candidate types shared by the worktree GC files.
2
+ /** Dedupes resolveIssueDisposition's lookup-failure warning across repeated sweeps — the factory
3
+ * loop calls sweepWorktrees every iteration, and a worktree tied to a nonexistent issue number
4
+ * fails that lookup on every one of them. The first failure for a given issue since the last
5
+ * reconcile-clear warns in full; every following one folds into a one-line "suppressed N"
6
+ * summary instead of repeating the same text. `reconcile()` drops an issue's tracking once it's
7
+ * no longer among the sweep's candidates, so a later re-appearance (or a different worktree
8
+ * reusing the number) warns in full again. Keyed by issue number, not by worktree path, since
9
+ * the failing lookup is per-issue (see ADR, this PR). */
10
+ export class IssueWarnDedup {
11
+ counts = new Map();
12
+ /** Records one occurrence for `issue`. Returns true the first time since the last
13
+ * reconcile-clear (caller should log the full warning), false thereafter. */
14
+ record(issue) {
15
+ const count = (this.counts.get(issue) ?? 0) + 1;
16
+ this.counts.set(issue, count);
17
+ return count === 1;
18
+ }
19
+ /** Occurrences suppressed for `issue` since its last full warning (0 before the second one). */
20
+ suppressedCount(issue) {
21
+ return Math.max(0, (this.counts.get(issue) ?? 0) - 1);
22
+ }
23
+ /** Drops tracking for every issue not in `activeIssues` — call once per sweep with the issue
24
+ * numbers still present among that sweep's candidates. */
25
+ reconcile(activeIssues) {
26
+ for (const issue of this.counts.keys()) {
27
+ if (!activeIssues.has(issue))
28
+ this.counts.delete(issue);
29
+ }
30
+ }
31
+ }
32
+ export const defaultIssueWarnDedup = new IssueWarnDedup();
33
+ //# sourceMappingURL=worktree-gc-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-gc-types.js","sourceRoot":"","sources":["../../src/worktree/worktree-gc-types.ts"],"names":[],"mappings":"AAAA,uGAAuG;AA6IvG;;;;;;;0DAO0D;AAC1D,MAAM,OAAO,cAAc;IACR,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEpD;kFAC8E;IAC9E,MAAM,CAAC,KAAa;QAClB,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC9B,OAAO,KAAK,KAAK,CAAC,CAAC;IACrB,CAAC;IAED,gGAAgG;IAChG,eAAe,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACxD,CAAC;IAED;+DAC2D;IAC3D,SAAS,CAAC,YAAiC;QACzC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YACvC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,cAAc,EAAE,CAAC"}