@intentius/chant 0.124.40 → 0.124.42

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 (346) hide show
  1. package/dist/__fixtures__/oidc-emulator.d.ts +49 -0
  2. package/dist/__fixtures__/oidc-emulator.d.ts.map +1 -0
  3. package/dist/__fixtures__/oidc-emulator.js +89 -0
  4. package/dist/ci-handover.d.ts +117 -0
  5. package/dist/ci-handover.d.ts.map +1 -0
  6. package/dist/ci-handover.js +217 -0
  7. package/dist/ci-identity.d.ts +190 -0
  8. package/dist/ci-identity.d.ts.map +1 -0
  9. package/dist/ci-identity.js +219 -0
  10. package/dist/cli/handlers/approve.d.ts +2 -1
  11. package/dist/cli/handlers/approve.d.ts.map +1 -1
  12. package/dist/cli/handlers/approve.js +20 -6
  13. package/dist/cli/handlers/build.d.ts.map +1 -1
  14. package/dist/cli/handlers/build.js +18 -1
  15. package/dist/cli/handlers/fan-out.d.ts.map +1 -1
  16. package/dist/cli/handlers/fan-out.js +42 -5
  17. package/dist/cli/handlers/gate-resume.d.ts +3 -0
  18. package/dist/cli/handlers/gate-resume.d.ts.map +1 -1
  19. package/dist/cli/handlers/gate-resume.js +15 -2
  20. package/dist/cli/handlers/lock.d.ts +8 -0
  21. package/dist/cli/handlers/lock.d.ts.map +1 -0
  22. package/dist/cli/handlers/lock.js +197 -0
  23. package/dist/cli/handlers/pr-env.d.ts +34 -0
  24. package/dist/cli/handlers/pr-env.d.ts.map +1 -0
  25. package/dist/cli/handlers/pr-env.js +436 -0
  26. package/dist/cli/handlers/pr.d.ts +76 -0
  27. package/dist/cli/handlers/pr.d.ts.map +1 -1
  28. package/dist/cli/handlers/pr.js +615 -55
  29. package/dist/cli/handlers/promote.d.ts.map +1 -1
  30. package/dist/cli/handlers/promote.js +9 -0
  31. package/dist/cli/handlers/query.d.ts +6 -0
  32. package/dist/cli/handlers/query.d.ts.map +1 -0
  33. package/dist/cli/handlers/query.js +80 -0
  34. package/dist/cli/handlers/run.d.ts.map +1 -1
  35. package/dist/cli/handlers/run.js +11 -0
  36. package/dist/cli/main.d.ts.map +1 -1
  37. package/dist/cli/main.js +49 -4
  38. package/dist/cli/parse-args.d.ts.map +1 -1
  39. package/dist/cli/parse-args.js +46 -2
  40. package/dist/cli/registry.d.ts +31 -2
  41. package/dist/cli/registry.d.ts.map +1 -1
  42. package/dist/components/capability.d.ts +47 -0
  43. package/dist/components/capability.d.ts.map +1 -1
  44. package/dist/components/capability.js +44 -0
  45. package/dist/components/cli-support.d.ts +6 -0
  46. package/dist/components/cli-support.d.ts.map +1 -1
  47. package/dist/components/cli-support.js +8 -1
  48. package/dist/components/driver.d.ts +10 -0
  49. package/dist/components/driver.d.ts.map +1 -1
  50. package/dist/components/driver.js +52 -2
  51. package/dist/components/fan-out-run.d.ts +37 -0
  52. package/dist/components/fan-out-run.d.ts.map +1 -1
  53. package/dist/components/fan-out-run.js +44 -4
  54. package/dist/components/gate-plan.d.ts +2 -0
  55. package/dist/components/gate-plan.d.ts.map +1 -1
  56. package/dist/components/gate-plan.js +1 -0
  57. package/dist/components/pr-environment.d.ts +298 -0
  58. package/dist/components/pr-environment.d.ts.map +1 -0
  59. package/dist/components/pr-environment.js +406 -0
  60. package/dist/components/pr-hooks.d.ts +66 -0
  61. package/dist/components/pr-hooks.d.ts.map +1 -0
  62. package/dist/components/pr-hooks.js +119 -0
  63. package/dist/components/pr-pipeline.d.ts +92 -2
  64. package/dist/components/pr-pipeline.d.ts.map +1 -1
  65. package/dist/components/pr-pipeline.js +150 -21
  66. package/dist/components/pr-policy.d.ts +109 -0
  67. package/dist/components/pr-policy.d.ts.map +1 -0
  68. package/dist/components/pr-policy.js +150 -0
  69. package/dist/components/pr-run.d.ts +6 -0
  70. package/dist/components/pr-run.d.ts.map +1 -1
  71. package/dist/components/pr-run.js +8 -3
  72. package/dist/components/wave-plan.d.ts +14 -1
  73. package/dist/components/wave-plan.d.ts.map +1 -1
  74. package/dist/components/wave-plan.js +34 -2
  75. package/dist/gate-decision.d.ts +15 -2
  76. package/dist/gate-decision.d.ts.map +1 -1
  77. package/dist/gate-decision.js +17 -2
  78. package/dist/gate-policy.d.ts +140 -0
  79. package/dist/gate-policy.d.ts.map +1 -0
  80. package/dist/gate-policy.js +242 -0
  81. package/dist/lifecycle/gate-checkpoint.d.ts +1 -1
  82. package/dist/lifecycle/gate-checkpoint.js +1 -1
  83. package/dist/{workspace/trust → lifecycle}/gate-seal.d.ts +1 -1
  84. package/dist/lifecycle/gate-seal.d.ts.map +1 -0
  85. package/dist/lifecycle/query.d.ts +68 -0
  86. package/dist/lifecycle/query.d.ts.map +1 -0
  87. package/dist/lifecycle/query.js +246 -0
  88. package/dist/lifecycle/run-ledger.d.ts +13 -0
  89. package/dist/lifecycle/run-ledger.d.ts.map +1 -1
  90. package/dist/lifecycle/run-ledger.js +16 -0
  91. package/dist/lifecycle/target-lock.d.ts +97 -0
  92. package/dist/lifecycle/target-lock.d.ts.map +1 -0
  93. package/dist/lifecycle/target-lock.js +286 -0
  94. package/dist/op/activities/activity-contracts.d.ts +30 -0
  95. package/dist/op/activities/activity-contracts.d.ts.map +1 -1
  96. package/dist/op/activities/activity-contracts.js +26 -0
  97. package/dist/op/activities/index.d.ts +2 -0
  98. package/dist/op/activities/index.d.ts.map +1 -1
  99. package/dist/op/activities/index.js +4 -0
  100. package/dist/op/activities/pr-refs.d.ts +10 -0
  101. package/dist/op/activities/pr-refs.d.ts.map +1 -0
  102. package/dist/op/activities/pr-refs.js +26 -0
  103. package/dist/op/activities/predict-behaviour.d.ts +2 -4
  104. package/dist/op/activities/predict-behaviour.d.ts.map +1 -1
  105. package/dist/op/activities/predict-behaviour.js +2 -21
  106. package/dist/op/activities/review-agent.d.ts +137 -0
  107. package/dist/op/activities/review-agent.d.ts.map +1 -0
  108. package/dist/op/activities/review-agent.js +266 -0
  109. package/dist/op/builders.d.ts +9 -0
  110. package/dist/op/builders.d.ts.map +1 -1
  111. package/dist/op/builders.js +11 -0
  112. package/dist/op/cron.d.ts +8 -0
  113. package/dist/op/cron.d.ts.map +1 -1
  114. package/dist/op/cron.js +51 -0
  115. package/dist/op/gate-approval.d.ts +20 -13
  116. package/dist/op/gate-approval.d.ts.map +1 -1
  117. package/dist/op/gate-approval.js +13 -18
  118. package/dist/op/gate-quorum.d.ts +131 -0
  119. package/dist/op/gate-quorum.d.ts.map +1 -0
  120. package/dist/op/gate-quorum.js +183 -0
  121. package/dist/op/gate-resume.d.ts +4 -2
  122. package/dist/op/gate-resume.d.ts.map +1 -1
  123. package/dist/op/gate-resume.js +5 -4
  124. package/dist/op/gate-review.js +1 -1
  125. package/dist/op/gate.d.ts +32 -4
  126. package/dist/op/gate.d.ts.map +1 -1
  127. package/dist/op/gate.js +40 -24
  128. package/dist/op/index.d.ts +6 -4
  129. package/dist/op/index.d.ts.map +1 -1
  130. package/dist/op/index.js +4 -3
  131. package/dist/op/local-executor.d.ts.map +1 -1
  132. package/dist/op/local-executor.js +9 -3
  133. package/dist/op/op-waves-run.d.ts +28 -43
  134. package/dist/op/op-waves-run.d.ts.map +1 -1
  135. package/dist/op/op-waves-run.js +170 -120
  136. package/dist/op/op-waves.d.ts +55 -3
  137. package/dist/op/op-waves.d.ts.map +1 -1
  138. package/dist/op/op-waves.js +63 -8
  139. package/dist/op/schedule-overdue.d.ts +57 -0
  140. package/dist/op/schedule-overdue.d.ts.map +1 -0
  141. package/dist/op/schedule-overdue.js +138 -0
  142. package/dist/op/stage-hooks.d.ts +132 -0
  143. package/dist/op/stage-hooks.d.ts.map +1 -0
  144. package/dist/op/stage-hooks.js +142 -0
  145. package/dist/override-gate.d.ts +2 -2
  146. package/dist/override-gate.d.ts.map +1 -1
  147. package/dist/override-gate.js +1 -1
  148. package/dist/pr-forge.d.ts +64 -0
  149. package/dist/pr-forge.d.ts.map +1 -1
  150. package/dist/pr-forge.js +331 -44
  151. package/dist/pr-loop.d.ts +107 -1
  152. package/dist/pr-loop.d.ts.map +1 -1
  153. package/dist/pr-loop.js +84 -3
  154. package/dist/pr-post.d.ts +72 -0
  155. package/dist/pr-post.d.ts.map +1 -0
  156. package/dist/pr-post.js +134 -0
  157. package/dist/pr-requires.d.ts +38 -0
  158. package/dist/pr-requires.d.ts.map +1 -0
  159. package/dist/pr-requires.js +48 -0
  160. package/dist/wave-blocked.d.ts +79 -0
  161. package/dist/wave-blocked.d.ts.map +1 -0
  162. package/dist/wave-blocked.js +245 -0
  163. package/dist/wave-engine.d.ts +6 -0
  164. package/dist/wave-engine.d.ts.map +1 -1
  165. package/dist/wave-engine.js +2 -0
  166. package/dist/wave-runtime.mjs +243 -243
  167. package/dist/workspace/__fixtures__/two-member-workspace.d.ts +1 -0
  168. package/dist/workspace/__fixtures__/two-member-workspace.d.ts.map +1 -1
  169. package/dist/workspace/__fixtures__/two-member-workspace.js +1 -1
  170. package/dist/workspace/checks/ci-workflow.d.ts.map +1 -1
  171. package/dist/workspace/checks/ci-workflow.js +19 -4
  172. package/dist/workspace/ci-branches.d.ts +51 -0
  173. package/dist/workspace/ci-branches.d.ts.map +1 -0
  174. package/dist/workspace/ci-branches.js +69 -0
  175. package/dist/workspace/ci-cloud-identity.d.ts +11 -0
  176. package/dist/workspace/ci-cloud-identity.d.ts.map +1 -0
  177. package/dist/workspace/ci-cloud-identity.js +24 -0
  178. package/dist/workspace/ci-init.d.ts.map +1 -1
  179. package/dist/workspace/ci-init.js +5 -4
  180. package/dist/workspace/ci-locks.d.ts +12 -0
  181. package/dist/workspace/ci-locks.d.ts.map +1 -0
  182. package/dist/workspace/ci-locks.js +6 -0
  183. package/dist/workspace/ci-run.d.ts +17 -1
  184. package/dist/workspace/ci-run.d.ts.map +1 -1
  185. package/dist/workspace/ci-run.js +66 -4
  186. package/dist/workspace/ci-workflow-at.d.ts +14 -0
  187. package/dist/workspace/ci-workflow-at.d.ts.map +1 -0
  188. package/dist/workspace/ci-workflow-at.js +17 -0
  189. package/dist/workspace/ci-workflow.d.ts +11 -3
  190. package/dist/workspace/ci-workflow.d.ts.map +1 -1
  191. package/dist/workspace/ci-workflow.js +10 -2
  192. package/dist/workspace/declaration.d.ts +69 -3
  193. package/dist/workspace/declaration.d.ts.map +1 -1
  194. package/dist/workspace/declaration.js +72 -1
  195. package/dist/workspace/declaration.schema.json +149 -2
  196. package/dist/workspace/identity-gate-rule.d.ts +1 -1
  197. package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
  198. package/dist/workspace/identity-gate-rule.js +1 -1
  199. package/dist/workspace/identity.d.ts +1 -1
  200. package/dist/workspace/identity.d.ts.map +1 -1
  201. package/dist/workspace/lineage-upgrade.d.ts.map +1 -1
  202. package/dist/workspace/lineage-upgrade.js +8 -5
  203. package/dist/workspace/member-pipeline.d.ts +6 -0
  204. package/dist/workspace/member-pipeline.d.ts.map +1 -1
  205. package/dist/workspace/member-pipeline.js +23 -0
  206. package/dist/workspace/pr-report.schema.json +94 -3
  207. package/dist/workspace/reason-codes.d.ts +1 -1
  208. package/dist/workspace/reason-codes.d.ts.map +1 -1
  209. package/dist/workspace/reason-codes.js +1 -1
  210. package/dist/workspace/security.d.ts.map +1 -1
  211. package/dist/workspace/security.js +4 -0
  212. package/dist/workspace/status-gates.d.ts +3 -2
  213. package/dist/workspace/status-gates.d.ts.map +1 -1
  214. package/dist/workspace/status-gates.js +8 -7
  215. package/dist/workspace/status.d.ts.map +1 -1
  216. package/dist/workspace/status.js +4 -1
  217. package/dist/workspace/trust/seal.d.ts +2 -2
  218. package/dist/workspace/trust/seal.d.ts.map +1 -1
  219. package/dist/workspace/trust/seal.js +2 -2
  220. package/package.json +1 -1
  221. package/src/__fixtures__/oidc-emulator.ts +118 -0
  222. package/src/ci-handover.test.ts +209 -0
  223. package/src/ci-handover.ts +237 -0
  224. package/src/ci-identity.test.ts +201 -0
  225. package/src/ci-identity.ts +310 -0
  226. package/src/cli/handlers/approve.ts +18 -5
  227. package/src/cli/handlers/build.ts +18 -1
  228. package/src/cli/handlers/fan-out.ts +43 -6
  229. package/src/cli/handlers/gate-resume.ts +16 -2
  230. package/src/cli/handlers/lock.test.ts +98 -0
  231. package/src/cli/handlers/lock.ts +202 -0
  232. package/src/cli/handlers/operator.test.ts +3 -1
  233. package/src/cli/handlers/pr-before-merge.test.ts +276 -0
  234. package/src/cli/handlers/pr-env.ts +462 -0
  235. package/src/cli/handlers/pr-waves-blocked.test.ts +247 -0
  236. package/src/cli/handlers/pr.test.ts +184 -0
  237. package/src/cli/handlers/pr.ts +605 -61
  238. package/src/cli/handlers/promote.ts +9 -0
  239. package/src/cli/handlers/query.ts +78 -0
  240. package/src/cli/handlers/run.ts +10 -0
  241. package/src/cli/main.ts +49 -4
  242. package/src/cli/parse-args.ts +34 -2
  243. package/src/cli/registry.ts +31 -2
  244. package/src/components/capability-targets.test.ts +162 -0
  245. package/src/components/capability.ts +71 -0
  246. package/src/components/cli-support.ts +14 -1
  247. package/src/components/driver.ts +54 -3
  248. package/src/components/fan-out-run.ts +58 -3
  249. package/src/components/fan-out-waves.test.ts +45 -1
  250. package/src/components/gate-plan.ts +3 -0
  251. package/src/components/pr-environment.test.ts +249 -0
  252. package/src/components/pr-environment.ts +538 -0
  253. package/src/components/pr-hooks.test.ts +118 -0
  254. package/src/components/pr-hooks.ts +157 -0
  255. package/src/components/pr-pipeline.ts +194 -21
  256. package/src/components/pr-policy.test.ts +145 -0
  257. package/src/components/pr-policy.ts +211 -0
  258. package/src/components/pr-run.ts +14 -2
  259. package/src/components/wave-plan.ts +38 -3
  260. package/src/gate-decision-bundle.test.ts +4 -3
  261. package/src/gate-decision.ts +39 -2
  262. package/src/gate-policy-bundle.test.ts +28 -0
  263. package/src/gate-policy.test.ts +162 -0
  264. package/src/gate-policy.ts +298 -0
  265. package/src/lifecycle/gate-checkpoint.ts +1 -1
  266. package/src/{workspace/trust → lifecycle}/gate-seal.ts +1 -1
  267. package/src/lifecycle/query.test.ts +91 -0
  268. package/src/lifecycle/query.ts +315 -0
  269. package/src/lifecycle/run-ledger.ts +18 -0
  270. package/src/lifecycle/target-lock.test.ts +195 -0
  271. package/src/lifecycle/target-lock.ts +347 -0
  272. package/src/op/activities/activity-contracts.ts +31 -0
  273. package/src/op/activities/index.ts +6 -0
  274. package/src/op/activities/pr-refs.ts +28 -0
  275. package/src/op/activities/predict-behaviour.ts +3 -23
  276. package/src/op/activities/review-agent.test.ts +240 -0
  277. package/src/op/activities/review-agent.ts +355 -0
  278. package/src/op/builders.ts +13 -0
  279. package/src/op/cron.ts +44 -0
  280. package/src/op/gate-alias.test.ts +2 -2
  281. package/src/op/gate-approval.test.ts +30 -9
  282. package/src/op/gate-approval.ts +23 -26
  283. package/src/op/gate-quorum.test.ts +139 -0
  284. package/src/op/gate-quorum.ts +248 -0
  285. package/src/op/gate-resume.ts +6 -3
  286. package/src/op/gate-review.ts +1 -1
  287. package/src/op/gate.ts +64 -23
  288. package/src/op/index.ts +13 -1
  289. package/src/op/local-executor.ts +9 -2
  290. package/src/op/op-waves-hook-targets.test.ts +126 -0
  291. package/src/op/op-waves-policy-hold.test.ts +66 -0
  292. package/src/op/op-waves-quorum.test.ts +101 -0
  293. package/src/op/op-waves-run.ts +197 -183
  294. package/src/op/op-waves.ts +83 -10
  295. package/src/op/schedule-overdue.test.ts +220 -0
  296. package/src/op/schedule-overdue.ts +161 -0
  297. package/src/op/stage-hooks.ts +251 -0
  298. package/src/override-gate-bundle.test.ts +1 -1
  299. package/src/override-gate.ts +2 -2
  300. package/src/pr-forge-bundle.test.ts +2 -2
  301. package/src/pr-forge.test.ts +33 -0
  302. package/src/pr-forge.ts +347 -35
  303. package/src/pr-loop-bundle.test.ts +2 -2
  304. package/src/pr-loop.test.ts +58 -0
  305. package/src/pr-loop.ts +170 -4
  306. package/src/pr-post.test.ts +141 -0
  307. package/src/pr-post.ts +159 -0
  308. package/src/pr-requires.test.ts +184 -0
  309. package/src/pr-requires.ts +79 -0
  310. package/src/review-agent-bundle.test.ts +35 -0
  311. package/src/stage-hooks-bundle.test.ts +38 -0
  312. package/src/wave-blocked-bundle.test.ts +25 -0
  313. package/src/wave-blocked.test.ts +146 -0
  314. package/src/wave-blocked.ts +271 -0
  315. package/src/wave-engine.ts +8 -0
  316. package/src/workspace/__fixtures__/two-member-workspace.ts +2 -2
  317. package/src/workspace/checks/ci-workflow.test.ts +9 -0
  318. package/src/workspace/checks/ci-workflow.ts +18 -4
  319. package/src/workspace/ci-branches.test.ts +62 -0
  320. package/src/workspace/ci-branches.ts +79 -0
  321. package/src/workspace/ci-cloud-identity.test.ts +53 -0
  322. package/src/workspace/ci-cloud-identity.ts +23 -0
  323. package/src/workspace/ci-init.ts +5 -4
  324. package/src/workspace/ci-locks.ts +16 -0
  325. package/src/workspace/ci-run-index.test.ts +2 -1
  326. package/src/workspace/ci-run.test.ts +107 -8
  327. package/src/workspace/ci-run.ts +74 -5
  328. package/src/workspace/ci-workflow-at.ts +23 -0
  329. package/src/workspace/ci-workflow.ts +13 -2
  330. package/src/workspace/declaration.schema.json +149 -2
  331. package/src/workspace/declaration.test.ts +76 -0
  332. package/src/workspace/declaration.ts +140 -5
  333. package/src/workspace/identity-gate-rule.ts +1 -1
  334. package/src/workspace/identity.ts +1 -1
  335. package/src/workspace/lineage-upgrade.ts +11 -8
  336. package/src/workspace/member-pipeline.test.ts +29 -0
  337. package/src/workspace/member-pipeline.ts +30 -0
  338. package/src/workspace/pr-report.schema.json +94 -3
  339. package/src/workspace/reason-codes.ts +1 -1
  340. package/src/workspace/security.ts +4 -0
  341. package/src/workspace/status-gates.ts +9 -6
  342. package/src/workspace/status.ts +4 -1
  343. package/src/workspace/trust/gate-seal.test.ts +1 -1
  344. package/src/workspace/trust/seal.ts +2 -2
  345. package/dist/workspace/trust/gate-seal.d.ts.map +0 -1
  346. /package/dist/{workspace/trust → lifecycle}/gate-seal.js +0 -0
@@ -163,6 +163,22 @@ export async function readRunLedger(environment, op, opts) {
163
163
  const content = await readBlobFromPath(environment, fileFor(op), opts);
164
164
  if (!content)
165
165
  return { records: [], malformed: 0 };
166
+ return parseRunLedger(content);
167
+ }
168
+ /** The run ledger file name for `op` under `<env>/`, `runs__<op>.jsonl`. */
169
+ export function runLedgerFile(op) {
170
+ return fileFor(op);
171
+ }
172
+ /** The op a run ledger file name holds, or null when `file` is not one. */
173
+ export function opOfRunLedgerFile(file) {
174
+ return file.startsWith(PREFIX) && file.endsWith(".jsonl") && file.length > PREFIX.length + ".jsonl".length ? file.slice(PREFIX.length, -".jsonl".length) : null;
175
+ }
176
+ /**
177
+ * Parse the text of one run ledger file the way {@link readRunLedger} reads
178
+ * it (#4297): a reader that fetches the file itself, such as `chant query`,
179
+ * gets the same records and the same malformed count.
180
+ */
181
+ export function parseRunLedger(content) {
166
182
  const lines = content.split("\n").map((l) => l.trim()).filter(Boolean);
167
183
  const records = [];
168
184
  let malformed = 0;
@@ -0,0 +1,97 @@
1
+ /** The directory on `chant/lifecycle` that holds the lock files. */
2
+ export declare const LOCKS_DIR = "_locks";
3
+ /**
4
+ * How a lock was taken. `plan`: the pull request's plan took it (`ci.locks:
5
+ * plan`). `apply`: its apply took it. `lock`: someone ran `chant lock`.
6
+ */
7
+ export type TargetLockStage = "plan" | "apply" | "lock";
8
+ export declare const TARGET_LOCK_STAGES: readonly ["plan", "apply", "lock"];
9
+ /** One target's lock: the pull request that holds it, who took it, when, how, and the head it took it at. */
10
+ export interface TargetLock {
11
+ pr: number;
12
+ by: string;
13
+ at: string;
14
+ stage: TargetLockStage;
15
+ /** The pull request's head commit when the lock was taken. Absent when the caller did not say. */
16
+ head?: string;
17
+ }
18
+ /** `_locks/<gate>.json`. */
19
+ export interface TargetLockFile {
20
+ version: 1;
21
+ locks: Record<string, TargetLock>;
22
+ }
23
+ /** A lock another open pull request holds on a target the caller needs. */
24
+ export interface HeldTargetLock extends TargetLock {
25
+ target: string;
26
+ }
27
+ /** Says whether pull request `pr` is still open. */
28
+ export type PullRequestOpen = (pr: number) => Promise<boolean>;
29
+ export interface TargetLockOptions {
30
+ cwd?: string;
31
+ /** Whether a holder is still open. Absent: every holder counts as open. */
32
+ isOpen?: PullRequestOpen;
33
+ }
34
+ export type TakeTargetLocksResult = {
35
+ ok: true;
36
+ /** The targets now locked, sorted. */
37
+ taken: string[];
38
+ /** Plan locks of the same pull request on targets it no longer reaches, released (`releaseStalePlan`). */
39
+ released: string[];
40
+ /** Locks of merged or closed pull requests that this write dropped. */
41
+ expired: string[];
42
+ /** Whether the remote has the write. False with no remote, or when recording is off. */
43
+ pushed: boolean;
44
+ } | {
45
+ ok: false;
46
+ held: HeldTargetLock[];
47
+ };
48
+ /** The path of `gate`'s lock file on `chant/lifecycle`, under a member's prefix when it has one. */
49
+ export declare function targetLockPath(gate: string, memberPrefix?: string): string;
50
+ /** A gate name that is safe as a file name. */
51
+ export declare function targetLockGateProblem(gate: string): string | null;
52
+ /** Parse a lock file. Anything that is not a version 1 file with a map of locks reads as no locks; a malformed entry is dropped. */
53
+ export declare function parseTargetLocks(text: string | null): TargetLockFile;
54
+ /** The file's text: targets sorted, so two writes of the same locks are the same blob. */
55
+ export declare function renderTargetLocks(file: TargetLockFile): string;
56
+ /** The locks of `gate` as the remote holds them now, fetched first. */
57
+ export declare function readTargetLocks(gate: string, opts?: {
58
+ cwd?: string;
59
+ }): Promise<TargetLockFile>;
60
+ /**
61
+ * The locks on `targets` that an open pull request other than `pr` holds.
62
+ * Reads only: an apply calls this to refuse a target another pull request
63
+ * holds. `pr` null (an apply of a green commit) counts every open holder.
64
+ */
65
+ export declare function heldTargetLocks(gate: string, targets: readonly string[], pr: number | null, opts?: TargetLockOptions): Promise<HeldTargetLock[]>;
66
+ /**
67
+ * Lock `targets` for pull request `holder.pr`. A target locked by another
68
+ * pull request that is still open is held, and nothing is locked. A target
69
+ * locked by one that merged or closed is taken over, and its lock dropped.
70
+ * Targets this pull request already holds stay its own, with the new head.
71
+ * An apply or a `chant lock` takes over the pull request's own plan locks;
72
+ * a plan keeps its own apply and `chant lock` locks as they are. With
73
+ * `releaseStalePlan`, the pull request's plan locks on targets it no longer
74
+ * reaches are released.
75
+ */
76
+ export declare function takeTargetLocks(gate: string, targets: readonly string[], holder: TargetLock, opts?: TargetLockOptions & {
77
+ releaseStalePlan?: boolean;
78
+ }): Promise<TakeTargetLocksResult>;
79
+ /**
80
+ * Release the locks pull request `pr` holds on `gate`: every one, or only
81
+ * those on `targets`. Returns the targets released, sorted.
82
+ */
83
+ export declare function releaseTargetLocks(gate: string, pr: number, opts?: {
84
+ cwd?: string;
85
+ targets?: readonly string[];
86
+ }): Promise<{
87
+ released: string[];
88
+ pushed: boolean;
89
+ }>;
90
+ /** The lock file's path for the project at `cwd`, for messages. */
91
+ export declare function targetLockPathAt(gate: string, cwd?: string): Promise<string>;
92
+ /**
93
+ * One line naming the targets others hold, for a refusal or a note.
94
+ * `name` says how the forge names a holder (GitLab: `merge request !7`).
95
+ */
96
+ export declare function describeHeldTargetLocks(held: readonly HeldTargetLock[], name?: (pr: number) => string): string;
97
+ //# sourceMappingURL=target-lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"target-lock.d.ts","sourceRoot":"","sources":["../../src/lifecycle/target-lock.ts"],"names":[],"mappings":"AAuCA,oEAAoE;AACpE,eAAO,MAAM,SAAS,WAAW,CAAC;AAOlC;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAExD,eAAO,MAAM,kBAAkB,oCAA0E,CAAC;AAE1G,6GAA6G;AAC7G,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,eAAe,CAAC;IACvB,kGAAkG;IAClG,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,4BAA4B;AAC5B,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,CAAC,CAAC;IACX,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACnC;AAED,2EAA2E;AAC3E,MAAM,WAAW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,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,GAAE,iBAAsB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAI1J;AA+DD;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,GAAE,iBAAiB,GAAG;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5D,OAAO,CAAC,qBAAqB,CAAC,CAsChC;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAO,GACvD,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,CAelD;AAED,mEAAmE;AACnE,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGlF;AAID;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,SAAS,cAAc,EAAE,EAAE,IAAI,GAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAqC,GAAG,MAAM,CAM5I"}
@@ -0,0 +1,286 @@
1
+ /**
2
+ * Target locks (#4293): a pull request holds a lock on each target its
3
+ * change reaches, so no other pull request applies or locks those targets
4
+ * until it merges or closes, or someone runs `chant unlock` on it.
5
+ *
6
+ * A target is a name the caller picks: a component, a workspace member, or
7
+ * a lexicon's own unit such as a Terraform root. The locks of one gate live
8
+ * in one file, `_locks/<gate>.json` on `chant/lifecycle`, under the member's
9
+ * ledger prefix in a workspace member (./git.ts `ledgerDir`). The gate is
10
+ * the pull-request loop's, `pr-apply` unless the pipeline names another, so
11
+ * two pipelines with their own gates keep their own locks.
12
+ *
13
+ * Every change is a new commit on the branch, written with the read-then-CAS
14
+ * the other ledgers use and then pushed. A lock counts only once the remote
15
+ * has it: when the push is refused because another writer moved the branch,
16
+ * the local commit is dropped, the branch is read again and the decision is
17
+ * made again. So two jobs that lock the same target at once cannot both win.
18
+ * A repository with no remote is one machine, and the local write decides.
19
+ *
20
+ * A lock held by a pull request that is no longer open is released: the
21
+ * holder merged or closed. The caller says which pull requests are open
22
+ * (`isOpen`, from the forge). Without it every lock counts as held, and only
23
+ * `chant unlock` releases one.
24
+ *
25
+ * The file is coordination, not a record of work. ws-074 holds: the
26
+ * repository is the database, and the file is one more ledger on the
27
+ * branch, so any clone can read who holds what.
28
+ */
29
+ import { getRuntime } from "../runtime-adapter.js";
30
+ import { fetchLifecycleStatus, pushLifecycleStatus, readBlobBySha, readPathSha, RefCASConflictError, writeBlobToPath, } from "./git.js";
31
+ import { resolveMemberLedger } from "./member-ledger.js";
32
+ /** The directory on `chant/lifecycle` that holds the lock files. */
33
+ export const LOCKS_DIR = "_locks";
34
+ const STATE_BRANCH = "chant/lifecycle";
35
+ /** A scratch ref this module owns, for reading the remote tip after a refused push. */
36
+ const PROBE_REF = "refs/chant/target-lock-probe";
37
+ const ATTEMPTS = 5;
38
+ export const TARGET_LOCK_STAGES = ["plan", "apply", "lock"];
39
+ /** The path of `gate`'s lock file on `chant/lifecycle`, under a member's prefix when it has one. */
40
+ export function targetLockPath(gate, memberPrefix = "") {
41
+ return `${memberPrefix}${LOCKS_DIR}/${gate}.json`;
42
+ }
43
+ /** A gate name that is safe as a file name. */
44
+ export function targetLockGateProblem(gate) {
45
+ return /^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(gate) ? null : `the gate name ${JSON.stringify(gate)} is not a lock file name: letters, digits, '.', '_' and '-', starting with a letter or digit`;
46
+ }
47
+ const isStage = (v) => typeof v === "string" && TARGET_LOCK_STAGES.includes(v);
48
+ /** Parse a lock file. Anything that is not a version 1 file with a map of locks reads as no locks; a malformed entry is dropped. */
49
+ export function parseTargetLocks(text) {
50
+ if (!text)
51
+ return { version: 1, locks: {} };
52
+ try {
53
+ const doc = JSON.parse(text);
54
+ if (doc?.version === 1 && doc.locks && typeof doc.locks === "object" && !Array.isArray(doc.locks)) {
55
+ const locks = {};
56
+ for (const [target, raw] of Object.entries(doc.locks)) {
57
+ if (!raw || !Number.isInteger(raw.pr) || typeof raw.by !== "string" || typeof raw.at !== "string" || !isStage(raw.stage))
58
+ continue;
59
+ locks[target] = { pr: raw.pr, by: raw.by, at: raw.at, stage: raw.stage, ...(typeof raw.head === "string" ? { head: raw.head } : {}) };
60
+ }
61
+ return { version: 1, locks };
62
+ }
63
+ }
64
+ catch {
65
+ // An unreadable file holds no locks.
66
+ }
67
+ return { version: 1, locks: {} };
68
+ }
69
+ /** The file's text: targets sorted, so two writes of the same locks are the same blob. */
70
+ export function renderTargetLocks(file) {
71
+ const locks = Object.fromEntries(Object.keys(file.locks).sort().map((t) => [t, file.locks[t]]));
72
+ return `${JSON.stringify({ version: 1, locks }, null, 2)}\n`;
73
+ }
74
+ /** Fetch `chant/lifecycle`, refusing a ledger this checkout cannot read: a lock decided on a stale branch is no lock. */
75
+ async function fetchForLocks(cwd) {
76
+ const fetched = await fetchLifecycleStatus({ cwd });
77
+ if (fetched.status === "diverged")
78
+ throw new Error(`the local ${STATE_BRANCH} has forked from ${fetched.remote}'s, so the locks cannot be read: ${fetched.stderr}`);
79
+ if (fetched.status === "unreachable")
80
+ throw new Error(`cannot fetch ${STATE_BRANCH} from ${fetched.remote}, so the locks cannot be read${fetched.stderr ? `: ${fetched.stderr}` : ""}`);
81
+ }
82
+ async function readCurrent(gate, cwd) {
83
+ const sha = await readPathSha(LOCKS_DIR, `${gate}.json`, { cwd });
84
+ return { sha, file: parseTargetLocks(sha ? await readBlobBySha(sha, { cwd }) : null) };
85
+ }
86
+ /** The locks of `gate` as the remote holds them now, fetched first. */
87
+ export async function readTargetLocks(gate, opts = {}) {
88
+ const problem = targetLockGateProblem(gate);
89
+ if (problem)
90
+ throw new Error(problem);
91
+ await fetchForLocks(opts.cwd);
92
+ return (await readCurrent(gate, opts.cwd)).file;
93
+ }
94
+ /** A memo of `isOpen`, so one decision asks the forge about each pull request once. */
95
+ function openMemo(isOpen) {
96
+ const seen = new Map();
97
+ return (pr) => {
98
+ if (!isOpen)
99
+ return Promise.resolve(true);
100
+ if (!seen.has(pr))
101
+ seen.set(pr, isOpen(pr));
102
+ return seen.get(pr);
103
+ };
104
+ }
105
+ /** The locks on `targets` that an open pull request other than `pr` holds, by target. */
106
+ async function heldIn(file, targets, pr, open) {
107
+ const held = [];
108
+ for (const target of [...new Set(targets)].sort()) {
109
+ const l = file.locks[target];
110
+ if (l && l.pr !== pr && (await open(l.pr)))
111
+ held.push({ target, ...l });
112
+ }
113
+ return held;
114
+ }
115
+ /**
116
+ * The locks on `targets` that an open pull request other than `pr` holds.
117
+ * Reads only: an apply calls this to refuse a target another pull request
118
+ * holds. `pr` null (an apply of a green commit) counts every open holder.
119
+ */
120
+ export async function heldTargetLocks(gate, targets, pr, opts = {}) {
121
+ if (targets.length === 0)
122
+ return [];
123
+ const file = await readTargetLocks(gate, opts);
124
+ return heldIn(file, targets, pr, openMemo(opts.isOpen));
125
+ }
126
+ /** The local tip of `chant/lifecycle`, or "" when there is none. */
127
+ async function localTip(cwd) {
128
+ const out = await getRuntime().spawn(["git", "rev-parse", "--verify", "--quiet", `refs/heads/${STATE_BRANCH}`], { cwd });
129
+ return out.exitCode === 0 ? out.stdout.trim() : "";
130
+ }
131
+ /**
132
+ * After a refused push: drop the lock commit `ours` from the local branch by
133
+ * moving it to the remote's tip, so the next attempt reads what the other
134
+ * writer pushed. Done only when `parent`, the tip before the write, is in
135
+ * the remote's history, so no other local commit is lost. Throws otherwise.
136
+ */
137
+ async function dropRefusedWrite(remote, ours, parent, cwd) {
138
+ const rt = getRuntime();
139
+ const env = { LC_ALL: "C", LANGUAGE: "" };
140
+ const probe = await rt.spawn(["git", "fetch", "--force", remote, `${STATE_BRANCH}:${PROBE_REF}`], { cwd, env });
141
+ if (probe.exitCode !== 0)
142
+ throw new Error(`the push of the locks was refused and ${STATE_BRANCH} could not be read again from ${remote}: ${probe.stderr.trim()}`);
143
+ try {
144
+ if (parent) {
145
+ const contains = await rt.spawn(["git", "merge-base", "--is-ancestor", parent, PROBE_REF], { cwd, env });
146
+ if (contains.exitCode !== 0)
147
+ throw new Error(`the push of the locks was refused, and the local ${STATE_BRANCH} holds commits ${remote} does not; push or fetch ${STATE_BRANCH} and lock again`);
148
+ }
149
+ const tip = (await rt.spawn(["git", "rev-parse", "--verify", PROBE_REF], { cwd, env })).stdout.trim();
150
+ const moved = await rt.spawn(["git", "update-ref", `refs/heads/${STATE_BRANCH}`, tip, ours], { cwd, env });
151
+ if (moved.exitCode !== 0)
152
+ throw new Error(`could not drop the refused lock commit from ${STATE_BRANCH}: ${moved.stderr.trim()}`);
153
+ await rt.spawn(["git", "update-ref", `refs/remotes/${remote}/${STATE_BRANCH}`, tip], { cwd, env });
154
+ }
155
+ finally {
156
+ await rt.spawn(["git", "update-ref", "-d", PROBE_REF], { cwd, env });
157
+ }
158
+ }
159
+ /**
160
+ * Write `next` over the file read at `sha`, then push. Returns null when the
161
+ * branch moved under the write (locally or on the remote), so the caller
162
+ * reads and decides again.
163
+ */
164
+ async function writeAndPush(gate, sha, next, message, cwd) {
165
+ const parent = await localTip(cwd);
166
+ let commit;
167
+ try {
168
+ commit = await writeBlobToPath(LOCKS_DIR, `${gate}.json`, renderTargetLocks(next), message, { cwd, expectPriorPathSha: sha });
169
+ }
170
+ catch (err) {
171
+ if (err instanceof RefCASConflictError)
172
+ return null;
173
+ throw err;
174
+ }
175
+ const push = await pushLifecycleStatus({ cwd });
176
+ switch (push.status) {
177
+ case "pushed":
178
+ return { pushed: true };
179
+ case "no-remote":
180
+ case "not-recorded":
181
+ return { pushed: false };
182
+ case "stale":
183
+ await dropRefusedWrite(push.remote, commit, parent, cwd);
184
+ await fetchForLocks(cwd);
185
+ return null;
186
+ case "failed":
187
+ throw new Error(`the locks were written but the push of ${STATE_BRANCH} to ${push.remote} failed, so they do not count yet: ${push.stderr}`);
188
+ }
189
+ }
190
+ /**
191
+ * Lock `targets` for pull request `holder.pr`. A target locked by another
192
+ * pull request that is still open is held, and nothing is locked. A target
193
+ * locked by one that merged or closed is taken over, and its lock dropped.
194
+ * Targets this pull request already holds stay its own, with the new head.
195
+ * An apply or a `chant lock` takes over the pull request's own plan locks;
196
+ * a plan keeps its own apply and `chant lock` locks as they are. With
197
+ * `releaseStalePlan`, the pull request's plan locks on targets it no longer
198
+ * reaches are released.
199
+ */
200
+ export async function takeTargetLocks(gate, targets, holder, opts = {}) {
201
+ const problem = targetLockGateProblem(gate);
202
+ if (problem)
203
+ throw new Error(problem);
204
+ for (const t of targets)
205
+ if (t.trim() === "")
206
+ throw new Error("a lock target is a non-empty name");
207
+ const wanted = [...new Set(targets)].sort();
208
+ const open = openMemo(opts.isOpen);
209
+ await fetchForLocks(opts.cwd);
210
+ for (let attempt = 1; attempt <= ATTEMPTS; attempt++) {
211
+ const { sha, file } = await readCurrent(gate, opts.cwd);
212
+ const held = await heldIn(file, wanted, holder.pr, open);
213
+ if (held.length > 0)
214
+ return { ok: false, held };
215
+ const next = { version: 1, locks: {} };
216
+ const released = [];
217
+ const expired = [];
218
+ for (const [target, l] of Object.entries(file.locks)) {
219
+ if (l.pr === holder.pr) {
220
+ if (opts.releaseStalePlan && l.stage === "plan" && !wanted.includes(target)) {
221
+ released.push(target);
222
+ continue;
223
+ }
224
+ }
225
+ else if (opts.isOpen && !(await open(l.pr))) {
226
+ expired.push(target);
227
+ continue;
228
+ }
229
+ next.locks[target] = l;
230
+ }
231
+ for (const target of wanted) {
232
+ const own = file.locks[target];
233
+ next.locks[target] = holder.stage === "plan" && own?.pr === holder.pr && own.stage !== "plan" ? own : holder;
234
+ }
235
+ const done = { ok: true, taken: wanted, released: released.sort(), expired: expired.sort() };
236
+ if (renderTargetLocks(next) === renderTargetLocks(file) && sha !== null)
237
+ return { ...done, pushed: false };
238
+ if (wanted.length === 0 && released.length === 0 && expired.length === 0)
239
+ return { ...done, pushed: false };
240
+ const wrote = await writeAndPush(gate, sha, next, `Lock ${wanted.length} target${wanted.length === 1 ? "" : "s"} of ${gate} for pull request ${holder.pr} (${holder.stage})`, opts.cwd);
241
+ if (wrote)
242
+ return { ...done, pushed: wrote.pushed };
243
+ }
244
+ throw new Error(`could not write the locks of ${gate}: ${STATE_BRANCH} kept moving; lock again`);
245
+ }
246
+ /**
247
+ * Release the locks pull request `pr` holds on `gate`: every one, or only
248
+ * those on `targets`. Returns the targets released, sorted.
249
+ */
250
+ export async function releaseTargetLocks(gate, pr, opts = {}) {
251
+ const problem = targetLockGateProblem(gate);
252
+ if (problem)
253
+ throw new Error(problem);
254
+ await fetchForLocks(opts.cwd);
255
+ for (let attempt = 1; attempt <= ATTEMPTS; attempt++) {
256
+ const { sha, file } = await readCurrent(gate, opts.cwd);
257
+ const mine = Object.keys(file.locks)
258
+ .filter((t) => file.locks[t].pr === pr && (!opts.targets || opts.targets.includes(t)))
259
+ .sort();
260
+ if (mine.length === 0)
261
+ return { released: [], pushed: false };
262
+ const next = { version: 1, locks: Object.fromEntries(Object.entries(file.locks).filter(([t]) => !mine.includes(t))) };
263
+ const wrote = await writeAndPush(gate, sha, next, `Unlock ${mine.length} target${mine.length === 1 ? "" : "s"} of ${gate} held by pull request ${pr}`, opts.cwd);
264
+ if (wrote)
265
+ return { released: mine, pushed: wrote.pushed };
266
+ }
267
+ throw new Error(`could not write the locks of ${gate}: ${STATE_BRANCH} kept moving; unlock again`);
268
+ }
269
+ /** The lock file's path for the project at `cwd`, for messages. */
270
+ export async function targetLockPathAt(gate, cwd) {
271
+ const { prefix } = await resolveMemberLedger(cwd ?? process.cwd());
272
+ return targetLockPath(gate, prefix);
273
+ }
274
+ const STAGE_WORDS = { plan: "planned", apply: "applied", lock: "locked with chant lock" };
275
+ /**
276
+ * One line naming the targets others hold, for a refusal or a note.
277
+ * `name` says how the forge names a holder (GitLab: `merge request !7`).
278
+ */
279
+ export function describeHeldTargetLocks(held, name = (pr) => `pull request ${pr}`) {
280
+ const byPr = new Map();
281
+ for (const h of held)
282
+ byPr.set(h.pr, [...(byPr.get(h.pr) ?? []), h]);
283
+ return [...byPr]
284
+ .map(([pr, hs]) => `${hs.map((h) => h.target).join(", ")} ${hs.length === 1 ? "is" : "are"} locked by ${name(pr)} (${STAGE_WORDS[hs[0].stage]} by ${hs[0].by})`)
285
+ .join("; ");
286
+ }
@@ -121,6 +121,36 @@ export declare const behaviourFindingContract: import("../index.js").ActivityCon
121
121
  pullRequest?: string | undefined;
122
122
  mergeRequest?: string | undefined;
123
123
  }>;
124
+ /**
125
+ * The review agent (#4299). `changeSet` is `composeChangeSet`'s document,
126
+ * checked only for the fields the prompt reads. `returns` names what a later
127
+ * step may read; no gate reads it.
128
+ */
129
+ export declare const reviewAgentContract: import("../index.js").ActivityContract<{
130
+ op: string;
131
+ changeSet?: {
132
+ [x: string]: unknown;
133
+ digest: string;
134
+ entries: unknown[];
135
+ } | undefined;
136
+ changeSetFile?: string | undefined;
137
+ mode?: "comment" | "report" | undefined;
138
+ title?: string | undefined;
139
+ description?: string | undefined;
140
+ base?: string | undefined;
141
+ instructions?: string | undefined;
142
+ command?: string | undefined;
143
+ keyEnv?: string | undefined;
144
+ timeout?: number | undefined;
145
+ }, {
146
+ mode: "comment" | "report";
147
+ risk: "high" | "low" | "medium" | "unknown";
148
+ exitCode: number | null;
149
+ summary: string;
150
+ commentUrl?: string | undefined;
151
+ pullRequest?: string | undefined;
152
+ mergeRequest?: string | undefined;
153
+ }>;
124
154
  /**
125
155
  * The propose-only template upgrade (#2550, ws-032). `args` mirrors
126
156
  * `ProposeWorkspaceUpgradeArgs` without its test hooks. `returns` names what
@@ -1 +1 @@
1
- {"version":3,"file":"activity-contracts.d.ts","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eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;EAkBhC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;EAIjC,CAAC;AAOF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;EAIpC,CAAC;AAEF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;EAI1C,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;EAIrC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;;EAW/B,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;EAWjC,CAAC;AAUF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6B1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;EAoBvC,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;EAWzC,CAAC;AAWF,eAAO,MAAM,mBAAmB;;;;;;;;;;;EAQ/B,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;YAIhC,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;EAU9B,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;EAIhC,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;EAIhC,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;EASjC,CAAC"}
@@ -107,6 +107,32 @@ export const behaviourFindingContract = activityContract("behaviourFinding", z.s
107
107
  pullRequest: z.string().optional(),
108
108
  mergeRequest: z.string().optional(),
109
109
  }));
110
+ /**
111
+ * The review agent (#4299). `changeSet` is `composeChangeSet`'s document,
112
+ * checked only for the fields the prompt reads. `returns` names what a later
113
+ * step may read; no gate reads it.
114
+ */
115
+ export const reviewAgentContract = activityContract("reviewAgent", z.strictObject({
116
+ op: z.string(),
117
+ changeSet: z.object({ digest: z.string(), entries: z.array(z.unknown()) }).passthrough().optional(),
118
+ changeSetFile: z.string().optional(),
119
+ mode: z.enum(["comment", "report"]).optional(),
120
+ title: z.string().optional(),
121
+ description: z.string().optional(),
122
+ base: z.string().optional(),
123
+ instructions: z.string().optional(),
124
+ command: z.string().optional(),
125
+ keyEnv: z.string().optional(),
126
+ timeout: z.number().positive().optional(),
127
+ }), z.object({
128
+ mode: z.enum(["comment", "report"]),
129
+ risk: z.enum(["low", "medium", "high", "unknown"]),
130
+ exitCode: z.number().nullable(),
131
+ summary: z.string(),
132
+ commentUrl: z.string().optional(),
133
+ pullRequest: z.string().optional(),
134
+ mergeRequest: z.string().optional(),
135
+ }));
110
136
  /**
111
137
  * The propose-only template upgrade (#2550, ws-032). `args` mirrors
112
138
  * `ProposeWorkspaceUpgradeArgs` without its test hooks. `returns` names what
@@ -38,6 +38,8 @@ export { lexiconUpgrade, isPinned, isRolling, severityToLabel, upgradeBranchName
38
38
  export type { LexiconUpgradeArgs, LexiconUpgradeResult, LexiconUpgradeMode, SupportedLexicon, SemverLabel, CheckPinnedFn, CheckRollingFn, GhRunner, ApplyBumpFn, } from "./lexicon-upgrade.js";
39
39
  export { predictBehaviour, behaviourFinding, behaviourFindingMarker, declaredEdgeCoverage, baseRefFrom, headRefFrom, noBaseRefMessage, noContributedRowsMessage, } from "./predict-behaviour.js";
40
40
  export type { PredictBehaviourArgs, BehaviourFindingArgs, BehaviourFindingResult, BehaviourFindingMode, BehaviourFindingDeps, BaseCheckout, } from "./predict-behaviour.js";
41
+ export { reviewAgent, reviewMarker } from "./review-agent.js";
42
+ export type { ReviewAgentArgs, ReviewAgentResult, ReviewAgentMode, ReviewRisk } from "./review-agent.js";
41
43
  export { proposeWorkspaceUpgrade } from "./propose-upgrade.js";
42
44
  export type { ProposeWorkspaceUpgradeArgs, ProposeWorkspaceUpgradeResult, ProposeUpgradeMode, CommandRunner, } from "./propose-upgrade.js";
43
45
  export { changeCoverage } from "./change-coverage.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AAgB,EAChB,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,GACb,MAAM,qBAAqB,CAAC;AAK7B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3D,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAItG,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,YAAY,EACV,2BAA2B,EAC3B,6BAA6B,EAC7B,kBAAkB,EAClB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAOlF,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGzD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC7G,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
@@ -43,6 +43,10 @@ export { lexiconUpgrade, isPinned, isRolling, severityToLabel, upgradeBranchName
43
43
  // collects every exported function as an activity, so `createBehaviourFinding`
44
44
  // and `checkoutBase` stay on the module.
45
45
  export { predictBehaviour, behaviourFinding, behaviourFindingMarker, declaredEdgeCoverage, baseRefFrom, headRefFrom, noBaseRefMessage, noContributedRowsMessage, } from "./predict-behaviour.js";
46
+ // The review agent (#4299): a model reviews the change set against the pull
47
+ // request's own text and posts one sticky note. Only the activity and its
48
+ // marker are re-exported, since the registry collects every exported function.
49
+ export { reviewAgent, reviewMarker } from "./review-agent.js";
46
50
  // The propose-only template upgrade (#2550). Loads the workspace code on first
47
51
  // call only, so importing this module loads nothing under `workspace/`.
48
52
  export { proposeWorkspaceUpgrade } from "./propose-upgrade.js";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The pull request's base and head branch names, read off the run's own
3
+ * event (#4299). Its own module so the review agent bundles without
4
+ * predict-behaviour's estate code.
5
+ */
6
+ /** Where the base branch name comes from, most specific first. Pure — exported for testing. */
7
+ export declare function baseRefFrom(env: Record<string, string | undefined>, explicit?: string): string | undefined;
8
+ /** What the head side is called in the finding: the source branch when the run names one, else the short commit. */
9
+ export declare function headRefFrom(env: Record<string, string | undefined>, shortSha?: string): string;
10
+ //# sourceMappingURL=pr-refs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pr-refs.d.ts","sourceRoot":"","sources":["../../../src/op/activities/pr-refs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+FAA+F;AAC/F,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EACvC,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAQpB;AAED,oHAAoH;AACpH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAM9F"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The pull request's base and head branch names, read off the run's own
3
+ * event (#4299). Its own module so the review agent bundles without
4
+ * predict-behaviour's estate code.
5
+ */
6
+ /** Where the base branch name comes from, most specific first. Pure — exported for testing. */
7
+ export function baseRefFrom(env, explicit) {
8
+ const fromArgs = explicit?.trim();
9
+ if (fromArgs)
10
+ return fromArgs;
11
+ for (const source of ["GITHUB_BASE_REF", "CI_MERGE_REQUEST_TARGET_BRANCH_NAME"]) {
12
+ const value = env[source]?.trim();
13
+ if (value)
14
+ return value;
15
+ }
16
+ return undefined;
17
+ }
18
+ /** What the head side is called in the finding: the source branch when the run names one, else the short commit. */
19
+ export function headRefFrom(env, shortSha) {
20
+ for (const source of ["GITHUB_HEAD_REF", "CI_MERGE_REQUEST_SOURCE_BRANCH_NAME"]) {
21
+ const value = env[source]?.trim();
22
+ if (value)
23
+ return value;
24
+ }
25
+ return shortSha?.trim() || "head";
26
+ }
@@ -66,6 +66,8 @@
66
66
  import { type BehaviourEdgeCoverage, type BehaviourResult } from "../../behaviour.js";
67
67
  import { type BehaviourDelta } from "../../behaviour-delta.js";
68
68
  import { reconcilePr } from "./reconcile.js";
69
+ import { baseRefFrom, headRefFrom } from "./pr-refs.js";
70
+ export { baseRefFrom, headRefFrom };
69
71
  export interface PredictBehaviourArgs {
70
72
  /** The environment the prediction is for, mirroring the deep read's `environment`. */
71
73
  environment: string;
@@ -167,10 +169,6 @@ export interface BehaviourFindingResult {
167
169
  export declare function behaviourFindingMarker(op: string, env: string): string;
168
170
  /** What the finding says when the run names no base branch to predict against. */
169
171
  export declare function noBaseRefMessage(): string;
170
- /** Where the base branch name comes from, most specific first. Pure — exported for testing. */
171
- export declare function baseRefFrom(env: Record<string, string | undefined>, explicit?: string): string | undefined;
172
- /** What the head side is called in the finding: the source branch when the run names one, else the short commit. */
173
- export declare function headRefFrom(env: Record<string, string | undefined>, shortSha?: string): string;
174
172
  /** A checked-out base branch: where its project root is, and how to remove it. */
175
173
  export interface BaseCheckout {
176
174
  /** The base branch's counterpart of the working directory. */
@@ -1 +1 @@
1
- {"version":3,"file":"predict-behaviour.d.ts","sourceRoot":"","sources":["../../../src/op/activities/predict-behaviour.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAMH,OAAO,EAEL,KAAK,qBAAqB,EAC1B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