pstack-claude-mirror 0.0.0-stage → 0.9.133

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 (664) hide show
  1. package/.claude-plugin/marketplace.json +16 -0
  2. package/CHANGES.md +1110 -0
  3. package/LICENSE +22 -0
  4. package/LICENSE-cursor-team-kit +21 -0
  5. package/LICENSE-mirror +27 -0
  6. package/LICENSE-thermos +21 -0
  7. package/NOTICE-skills.md +13 -0
  8. package/NOTICE.md +62 -0
  9. package/README.md +84 -2
  10. package/UPSTREAM-README.md +243 -0
  11. package/bin/pstack-claude.mjs +183 -0
  12. package/docs/reference.md +247 -0
  13. package/package.json +88 -4
  14. package/plugins/pstack/.antigravity-plugin/plugin.json +8 -0
  15. package/plugins/pstack/.claude-plugin/icon.png +0 -0
  16. package/plugins/pstack/.claude-plugin/plugin.json +31 -0
  17. package/plugins/pstack/.codex-plugin/plugin.json +52 -0
  18. package/plugins/pstack/.github/plugin/plugin.json +15 -0
  19. package/plugins/pstack/.grok-plugin/plugin.json +9 -0
  20. package/plugins/pstack/.muse-plugin/plugin.json +381 -0
  21. package/plugins/pstack/README.md +27 -0
  22. package/plugins/pstack/agents/comment-sicko.md +34 -0
  23. package/plugins/pstack/agents/poteto-agent.md +8 -0
  24. package/plugins/pstack/agents/thermo-nuclear-code-quality-review-subagent.md +23 -0
  25. package/plugins/pstack/agents/thermo-nuclear-review-subagent.md +28 -0
  26. package/plugins/pstack/assets/pstack-icon.png +0 -0
  27. package/plugins/pstack/assets/pstack-icon.prompt.txt +8 -0
  28. package/plugins/pstack/grok/skills/pstack-routing/SKILL.md +8 -0
  29. package/plugins/pstack/hooks/agy-context.awk +9 -0
  30. package/plugins/pstack/hooks/codex-hooks.json +17 -0
  31. package/plugins/pstack/hooks/copilot-context.awk +44 -0
  32. package/plugins/pstack/hooks/copilot-hooks.json +27 -0
  33. package/plugins/pstack/hooks/hooks.json +16 -0
  34. package/plugins/pstack/hooks/json.awk +164 -0
  35. package/plugins/pstack/hooks/kimi-instructions.md +17 -0
  36. package/plugins/pstack/hooks/muse-context.awk +31 -0
  37. package/plugins/pstack/hooks/pre-tool-use.awk +152 -0
  38. package/plugins/pstack/hooks/pre-tool-use.sh +16 -0
  39. package/plugins/pstack/hooks/script-contracts.awk +55 -0
  40. package/plugins/pstack/hooks/session-start-agy.md +17 -0
  41. package/plugins/pstack/hooks/session-start-context.md +15 -0
  42. package/plugins/pstack/hooks/session-start-copilot-setup.md +1 -0
  43. package/plugins/pstack/hooks/session-start-copilot-sheet.md +1 -0
  44. package/plugins/pstack/hooks/session-start-copilot.md +3 -0
  45. package/plugins/pstack/hooks/session-start-minimax.md +17 -0
  46. package/plugins/pstack/hooks/session-start-muse-sheet.md +1 -0
  47. package/plugins/pstack/hooks/session-start-muse.md +17 -0
  48. package/plugins/pstack/hooks/session-start-opencode.md +17 -0
  49. package/plugins/pstack/hooks/session-start.ps1 +105 -0
  50. package/plugins/pstack/hooks/session-start.sh +95 -0
  51. package/plugins/pstack/hooks.json +10 -0
  52. package/plugins/pstack/models.json +67 -0
  53. package/plugins/pstack/omp/index.mjs +34 -0
  54. package/plugins/pstack/opencode/index.js +49 -0
  55. package/plugins/pstack/package.json +8 -0
  56. package/plugins/pstack/pi/agent-files.ts +117 -0
  57. package/plugins/pstack/pi/agent-text.ts +99 -0
  58. package/plugins/pstack/pi/agent-tools.ts +148 -0
  59. package/plugins/pstack/pi/agents.ts +486 -0
  60. package/plugins/pstack/pi/ask.ts +87 -0
  61. package/plugins/pstack/pi/child.ts +310 -0
  62. package/plugins/pstack/pi/config.ts +178 -0
  63. package/plugins/pstack/pi/index.ts +44 -0
  64. package/plugins/pstack/pi/one-shot.ts +90 -0
  65. package/plugins/pstack/pi/path-skills.ts +54 -0
  66. package/plugins/pstack/pi/prompt.ts +39 -0
  67. package/plugins/pstack/pi/schedule.ts +254 -0
  68. package/plugins/pstack/pi/slash.ts +92 -0
  69. package/plugins/pstack/pi/sleep-wait.ts +76 -0
  70. package/plugins/pstack/pi/worktree.ts +74 -0
  71. package/plugins/pstack/skills/architect/SKILL.md +100 -0
  72. package/plugins/pstack/skills/architect/references/design-red-flags.md +57 -0
  73. package/plugins/pstack/skills/architect/references/rationale-template.md +39 -0
  74. package/plugins/pstack/skills/architect/references/runner-prompt.md +20 -0
  75. package/plugins/pstack/skills/arena/SKILL.md +66 -0
  76. package/plugins/pstack/skills/automate-me/SKILL.md +111 -0
  77. package/plugins/pstack/skills/babysit/SKILL.md +68 -0
  78. package/plugins/pstack/skills/benchmark-checklist/SKILL.md +38 -0
  79. package/plugins/pstack/skills/blast-radius/SKILL.md +49 -0
  80. package/plugins/pstack/skills/bro/SKILL.md +6 -0
  81. package/plugins/pstack/skills/correct/SKILL.md +31 -0
  82. package/plugins/pstack/skills/create-formal-verification-skill/SKILL.md +50 -0
  83. package/plugins/pstack/skills/create-verification-skill/SKILL.md +51 -0
  84. package/plugins/pstack/skills/create-verification-skill/references/feature-map-example/README.md +47 -0
  85. package/plugins/pstack/skills/create-verification-skill/references/feature-map-example/create-note.md +39 -0
  86. package/plugins/pstack/skills/create-verification-skill/references/feature-map-example/search.md +45 -0
  87. package/plugins/pstack/skills/deslop/SKILL.md +24 -0
  88. package/plugins/pstack/skills/figure-it-out/SKILL.md +51 -0
  89. package/plugins/pstack/skills/fix-ci/SKILL.md +29 -0
  90. package/plugins/pstack/skills/fix-merge-conflicts/SKILL.md +32 -0
  91. package/plugins/pstack/skills/get-pr-comments/SKILL.md +23 -0
  92. package/plugins/pstack/skills/how/SKILL.md +54 -0
  93. package/plugins/pstack/skills/how/references/explainer-prompt.md +55 -0
  94. package/plugins/pstack/skills/how/references/explorer-prompt.md +35 -0
  95. package/plugins/pstack/skills/in-your-own-words/SKILL.md +6 -0
  96. package/plugins/pstack/skills/interrogate/SKILL.md +48 -0
  97. package/plugins/pstack/skills/ketchup/SKILL.md +42 -0
  98. package/plugins/pstack/skills/ketchup-video/SKILL.md +28 -0
  99. package/plugins/pstack/skills/maintain-formal-verification-skill/SKILL.md +65 -0
  100. package/plugins/pstack/skills/maintain-verification-skill/SKILL.md +46 -0
  101. package/plugins/pstack/skills/make-pr-easy-to-review/SKILL.md +59 -0
  102. package/plugins/pstack/skills/no-comments/SKILL.md +45 -0
  103. package/plugins/pstack/skills/poteto-help/SKILL.md +149 -0
  104. package/plugins/pstack/skills/poteto-help/references/prompting.md +51 -0
  105. package/plugins/pstack/skills/poteto-help/references/recipes.md +51 -0
  106. package/plugins/pstack/skills/poteto-mode/SKILL.md +174 -0
  107. package/plugins/pstack/skills/poteto-mode/playbooks/authoring-a-skill.md +12 -0
  108. package/plugins/pstack/skills/poteto-mode/playbooks/autonomous-run.md +13 -0
  109. package/plugins/pstack/skills/poteto-mode/playbooks/autopilot-full.md +31 -0
  110. package/plugins/pstack/skills/poteto-mode/playbooks/autopilot-stack.md +8 -0
  111. package/plugins/pstack/skills/poteto-mode/playbooks/babysit.md +23 -0
  112. package/plugins/pstack/skills/poteto-mode/playbooks/bug-fix.md +15 -0
  113. package/plugins/pstack/skills/poteto-mode/playbooks/eval.md +25 -0
  114. package/plugins/pstack/skills/poteto-mode/playbooks/feature.md +21 -0
  115. package/plugins/pstack/skills/poteto-mode/playbooks/hillclimb.md +21 -0
  116. package/plugins/pstack/skills/poteto-mode/playbooks/investigation.md +14 -0
  117. package/plugins/pstack/skills/poteto-mode/playbooks/multi-phase-plan.md +158 -0
  118. package/plugins/pstack/skills/poteto-mode/playbooks/opening-a-pr.md +34 -0
  119. package/plugins/pstack/skills/poteto-mode/playbooks/orchestrate.md +27 -0
  120. package/plugins/pstack/skills/poteto-mode/playbooks/pause-safely.md +11 -0
  121. package/plugins/pstack/skills/poteto-mode/playbooks/perf-issue.md +25 -0
  122. package/plugins/pstack/skills/poteto-mode/playbooks/prototype.md +14 -0
  123. package/plugins/pstack/skills/poteto-mode/playbooks/refactoring.md +18 -0
  124. package/plugins/pstack/skills/poteto-mode/playbooks/runtime-forensics.md +11 -0
  125. package/plugins/pstack/skills/poteto-mode/playbooks/session-pickup.md +11 -0
  126. package/plugins/pstack/skills/poteto-mode/playbooks/shipping.md +16 -0
  127. package/plugins/pstack/skills/poteto-mode/playbooks/trace-forensics.md +14 -0
  128. package/plugins/pstack/skills/poteto-mode/playbooks/visual-parity.md +11 -0
  129. package/plugins/pstack/skills/poteto-mode/playbooks/worktree-cleanup.md +12 -0
  130. package/plugins/pstack/skills/poteto-mode/references/agents/comment-sicko.md +34 -0
  131. package/plugins/pstack/skills/poteto-mode/references/agy-tools.md +99 -0
  132. package/plugins/pstack/skills/poteto-mode/references/bugbot-triage.md +142 -0
  133. package/plugins/pstack/skills/poteto-mode/references/codex-tools.md +109 -0
  134. package/plugins/pstack/skills/poteto-mode/references/copilot-tools.md +143 -0
  135. package/plugins/pstack/skills/poteto-mode/references/grok.md +50 -0
  136. package/plugins/pstack/skills/poteto-mode/references/kimi-tools.md +40 -0
  137. package/plugins/pstack/skills/poteto-mode/references/licenses/LICENSE +22 -0
  138. package/plugins/pstack/skills/poteto-mode/references/licenses/LICENSE-cursor-team-kit +21 -0
  139. package/plugins/pstack/skills/poteto-mode/references/licenses/LICENSE-thermos +21 -0
  140. package/plugins/pstack/skills/poteto-mode/references/licenses/NOTICE.md +13 -0
  141. package/plugins/pstack/skills/poteto-mode/references/merge-safety.md +43 -0
  142. package/plugins/pstack/skills/poteto-mode/references/minimax-tools.md +93 -0
  143. package/plugins/pstack/skills/poteto-mode/references/muse-tools.md +105 -0
  144. package/plugins/pstack/skills/poteto-mode/references/omp-tools.md +39 -0
  145. package/plugins/pstack/skills/poteto-mode/references/opencode-tools.md +29 -0
  146. package/plugins/pstack/skills/poteto-mode/references/pi-tools.md +117 -0
  147. package/plugins/pstack/skills/poteto-mode/references/resume-storage.md +20 -0
  148. package/plugins/pstack/skills/poteto-mode/scripts/.prettierignore +23 -0
  149. package/plugins/pstack/skills/poteto-mode/scripts/.prettierrc.json +3 -0
  150. package/plugins/pstack/skills/poteto-mode/scripts/bootstrap.ts +71 -0
  151. package/plugins/pstack/skills/poteto-mode/scripts/bun.lock +67 -0
  152. package/plugins/pstack/skills/poteto-mode/scripts/check-plan.mjs +214 -0
  153. package/plugins/pstack/skills/poteto-mode/scripts/check-plan.test.ts +115 -0
  154. package/plugins/pstack/skills/poteto-mode/scripts/check-playbooks.mjs +71 -0
  155. package/plugins/pstack/skills/poteto-mode/scripts/codex-session-effort.mjs +66 -0
  156. package/plugins/pstack/skills/poteto-mode/scripts/package.json +16 -0
  157. package/plugins/pstack/skills/poteto-mode/scripts/resume.mjs +139 -0
  158. package/plugins/pstack/skills/poteto-mode/scripts/tsconfig.json +14 -0
  159. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/cli.test.ts +383 -0
  160. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/cli.ts +266 -0
  161. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/deadline.ts +20 -0
  162. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/fakes.test-helper.ts +157 -0
  163. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/fresh-install.test.ts +35 -0
  164. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/github.test.ts +902 -0
  165. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/github.ts +922 -0
  166. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/integrity.test.ts +887 -0
  167. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/landing.ts +92 -0
  168. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/live-merge-safety.mjs +142 -0
  169. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/policy.test.ts +1151 -0
  170. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/policy.ts +956 -0
  171. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/render.ts +200 -0
  172. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/ship-pr +6 -0
  173. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/shipping-cli.test.ts +159 -0
  174. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/shipping-cli.ts +65 -0
  175. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/shipping.test-helper.ts +48 -0
  176. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/shipping.test.ts +360 -0
  177. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/shipping.ts +235 -0
  178. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/transport.test.ts +211 -0
  179. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/tsconfig.json +13 -0
  180. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/types.compile.ts +108 -0
  181. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/types.ts +474 -0
  182. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/watch-pr +6 -0
  183. package/plugins/pstack/skills/poteto-mode/scripts/watch-pr/wrapper.test.ts +20 -0
  184. package/plugins/pstack/skills/poteto-mode/scripts/worktree-audit.mjs +434 -0
  185. package/plugins/pstack/skills/principle-attack-the-premise/SKILL.md +21 -0
  186. package/plugins/pstack/skills/principle-boundary-discipline/SKILL.md +34 -0
  187. package/plugins/pstack/skills/principle-build-the-lever/SKILL.md +24 -0
  188. package/plugins/pstack/skills/principle-encode-lessons-in-structure/SKILL.md +11 -0
  189. package/plugins/pstack/skills/principle-exhaust-the-design-space/SKILL.md +9 -0
  190. package/plugins/pstack/skills/principle-experience-first/SKILL.md +19 -0
  191. package/plugins/pstack/skills/principle-explain-the-number/SKILL.md +18 -0
  192. package/plugins/pstack/skills/principle-fix-root-causes/SKILL.md +21 -0
  193. package/plugins/pstack/skills/principle-foundational-thinking/SKILL.md +21 -0
  194. package/plugins/pstack/skills/principle-guard-the-context-window/SKILL.md +12 -0
  195. package/plugins/pstack/skills/principle-laziness-protocol/SKILL.md +10 -0
  196. package/plugins/pstack/skills/principle-make-operations-idempotent/SKILL.md +22 -0
  197. package/plugins/pstack/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +14 -0
  198. package/plugins/pstack/skills/principle-minimize-reader-load/SKILL.md +18 -0
  199. package/plugins/pstack/skills/principle-model-the-domain/SKILL.md +24 -0
  200. package/plugins/pstack/skills/principle-never-block-on-the-human/SKILL.md +15 -0
  201. package/plugins/pstack/skills/principle-outcome-oriented-execution/SKILL.md +21 -0
  202. package/plugins/pstack/skills/principle-prove-it-works/SKILL.md +27 -0
  203. package/plugins/pstack/skills/principle-redesign-from-first-principles/SKILL.md +16 -0
  204. package/plugins/pstack/skills/principle-separate-before-serializing-shared-state/SKILL.md +16 -0
  205. package/plugins/pstack/skills/principle-sequence-verifiable-units/SKILL.md +17 -0
  206. package/plugins/pstack/skills/principle-subtract-before-you-add/SKILL.md +18 -0
  207. package/plugins/pstack/skills/principle-test-behavior-not-implementation/SKILL.md +20 -0
  208. package/plugins/pstack/skills/principle-type-system-discipline/SKILL.md +13 -0
  209. package/plugins/pstack/skills/recall/SKILL.md +43 -0
  210. package/plugins/pstack/skills/reflect/SKILL.md +89 -0
  211. package/plugins/pstack/skills/reflect/references/divergent-reviewer.md +38 -0
  212. package/plugins/pstack/skills/reflect/references/judgment-reviewer.md +37 -0
  213. package/plugins/pstack/skills/reflect/references/synthesizer.md +56 -0
  214. package/plugins/pstack/skills/reflect/references/tooling-reviewer.md +48 -0
  215. package/plugins/pstack/skills/reflect/scripts/claude-project-dir.mjs +121 -0
  216. package/plugins/pstack/skills/reflect/scripts/find-transcript.mjs +218 -0
  217. package/plugins/pstack/skills/setup-pstack/SKILL.md +109 -0
  218. package/plugins/pstack/skills/setup-pstack/copilot.md +88 -0
  219. package/plugins/pstack/skills/setup-pstack/references/runtimes.md +75 -0
  220. package/plugins/pstack/skills/setup-pstack/scripts/check-sheet.awk +10 -0
  221. package/plugins/pstack/skills/setup-pstack/scripts/check-sheet.sh +20 -0
  222. package/plugins/pstack/skills/setup-pstack/scripts/read-sheet.sh +24 -0
  223. package/plugins/pstack/skills/setup-pstack/scripts/sheet.awk +160 -0
  224. package/plugins/pstack/skills/sharpen/SKILL.md +15 -0
  225. package/plugins/pstack/skills/show-me-your-work/SKILL.md +89 -0
  226. package/plugins/pstack/skills/show-me-your-work/references/decision-log-template.tsv +1 -0
  227. package/plugins/pstack/skills/show-me-your-work/scripts/log.sh +58 -0
  228. package/plugins/pstack/skills/statechart/SKILL.md +81 -0
  229. package/plugins/pstack/skills/statechart/references/render.md +93 -0
  230. package/plugins/pstack/skills/statechart/scripts/backends/cfg.ts +33 -0
  231. package/plugins/pstack/skills/statechart/scripts/backends/mermaid.ts +201 -0
  232. package/plugins/pstack/skills/statechart/scripts/backends/plain-text.ts +72 -0
  233. package/plugins/pstack/skills/statechart/scripts/backends/report.ts +177 -0
  234. package/plugins/pstack/skills/statechart/scripts/bun.lock +17 -0
  235. package/plugins/pstack/skills/statechart/scripts/frontends/config.ts +276 -0
  236. package/plugins/pstack/skills/statechart/scripts/frontends/dot.ts +74 -0
  237. package/plugins/pstack/skills/statechart/scripts/frontends/marks.ts +93 -0
  238. package/plugins/pstack/skills/statechart/scripts/frontends/messages.ts +52 -0
  239. package/plugins/pstack/skills/statechart/scripts/frontends/spec.ts +114 -0
  240. package/plugins/pstack/skills/statechart/scripts/frontends/trace.ts +24 -0
  241. package/plugins/pstack/skills/statechart/scripts/frontends/value.ts +166 -0
  242. package/plugins/pstack/skills/statechart/scripts/frontends/verdict.ts +40 -0
  243. package/plugins/pstack/skills/statechart/scripts/frontends/view.ts +119 -0
  244. package/plugins/pstack/skills/statechart/scripts/ir.ts +547 -0
  245. package/plugins/pstack/skills/statechart/scripts/janitor.ts +12 -0
  246. package/plugins/pstack/skills/statechart/scripts/package.json +11 -0
  247. package/plugins/pstack/skills/statechart/scripts/passes/annotate.ts +128 -0
  248. package/plugins/pstack/skills/statechart/scripts/passes/label.ts +269 -0
  249. package/plugins/pstack/skills/statechart/scripts/passes/lift.ts +85 -0
  250. package/plugins/pstack/skills/statechart/scripts/passes/loop-check.ts +68 -0
  251. package/plugins/pstack/skills/statechart/scripts/passes/paths.ts +60 -0
  252. package/plugins/pstack/skills/statechart/scripts/passes/reach.ts +135 -0
  253. package/plugins/pstack/skills/statechart/scripts/passes/region-check.ts +97 -0
  254. package/plugins/pstack/skills/statechart/scripts/passes/regions.ts +295 -0
  255. package/plugins/pstack/skills/statechart/scripts/pipeline.ts +76 -0
  256. package/plugins/pstack/skills/statechart/scripts/run.ts +526 -0
  257. package/plugins/pstack/skills/statechart/scripts/statechart +29 -0
  258. package/plugins/pstack/skills/statechart/scripts/statechart.ts +171 -0
  259. package/plugins/pstack/skills/statechart/scripts/test/ConfigOracle.java +63 -0
  260. package/plugins/pstack/skills/statechart/scripts/test/chart.test.ts +1210 -0
  261. package/plugins/pstack/skills/statechart/scripts/test/charts/Braces.mmd +7 -0
  262. package/plugins/pstack/skills/statechart/scripts/test/charts/Escapes.mmd +11 -0
  263. package/plugins/pstack/skills/statechart/scripts/test/charts/Phases.mmd +29 -0
  264. package/plugins/pstack/skills/statechart/scripts/test/child-env.test.ts +15 -0
  265. package/plugins/pstack/skills/statechart/scripts/test/cli.test.ts +1323 -0
  266. package/plugins/pstack/skills/statechart/scripts/test/config-fuzz.test.ts +263 -0
  267. package/plugins/pstack/skills/statechart/scripts/test/corpus/Counter/ChartRun.out +57 -0
  268. package/plugins/pstack/skills/statechart/scripts/test/corpus/Counter/Counter.cfg +3 -0
  269. package/plugins/pstack/skills/statechart/scripts/test/corpus/Counter/Counter.tla +10 -0
  270. package/plugins/pstack/skills/statechart/scripts/test/corpus/Counter/chart.mmd +9 -0
  271. package/plugins/pstack/skills/statechart/scripts/test/corpus/Counter/graph.dot +16 -0
  272. package/plugins/pstack/skills/statechart/scripts/test/corpus/Counter/report.md +7 -0
  273. package/plugins/pstack/skills/statechart/scripts/test/corpus/Counter/sany.out +2 -0
  274. package/plugins/pstack/skills/statechart/scripts/test/corpus/Counter/verdict-1.out +49 -0
  275. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterAction/ChartRun.out +60 -0
  276. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterAction/CounterAction.cfg +4 -0
  277. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterAction/CounterAction.tla +22 -0
  278. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterAction/chart.mmd +26 -0
  279. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterAction/graph.dot +19 -0
  280. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterAction/report.md +20 -0
  281. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterAction/sany.out +2 -0
  282. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterAction/verdict-1.exit +1 -0
  283. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterAction/verdict-1.out +56 -0
  284. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterAction/verdict-2.exit +1 -0
  285. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterAction/verdict-2.out +82 -0
  286. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterAction/verdict-3.out +57 -0
  287. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterDeadlock/ChartRun.out +59 -0
  288. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterDeadlock/CounterDeadlock.cfg +3 -0
  289. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterDeadlock/CounterDeadlock.tla +11 -0
  290. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterDeadlock/chart.mmd +22 -0
  291. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterDeadlock/graph.dot +16 -0
  292. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterDeadlock/report.md +17 -0
  293. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterDeadlock/sany.out +2 -0
  294. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-1.exit +1 -0
  295. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-1.out +56 -0
  296. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-2.exit +1 -0
  297. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-2.out +77 -0
  298. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterFan/ChartRun.out +69 -0
  299. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterFan/CounterFan.cfg +2 -0
  300. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterFan/CounterFan.tla +11 -0
  301. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterFan/chart.mmd +85 -0
  302. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterFan/graph.dot +70 -0
  303. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterFan/report.md +12 -0
  304. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterFan/sany.out +2 -0
  305. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterFan/verdict-1.exit +1 -0
  306. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterFan/verdict-1.out +67 -0
  307. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterFan/verdict-2.out +57 -0
  308. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterGuard/ChartRun.exit +1 -0
  309. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterGuard/ChartRun.out +85 -0
  310. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterGuard/CounterGuard.cfg +6 -0
  311. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterGuard/CounterGuard.tla +13 -0
  312. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterGuard/chart.mmd +5 -0
  313. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterGuard/graph.dot +10 -0
  314. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterGuard/report.md +31 -0
  315. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterGuard/sany.out +2 -0
  316. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterGuard/verdict-1.exit +1 -0
  317. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterGuard/verdict-1.out +64 -0
  318. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterGuard/verdict-2.exit +1 -0
  319. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterGuard/verdict-2.out +77 -0
  320. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPast/ChartRun.out +55 -0
  321. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPast/CounterInitPast.cfg +3 -0
  322. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPast/CounterInitPast.tla +10 -0
  323. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPast/chart.mmd +12 -0
  324. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPast/graph.dot +6 -0
  325. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPast/report.md +12 -0
  326. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPast/sany.out +2 -0
  327. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPast/verdict-1.exit +1 -0
  328. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPast/verdict-1.out +33 -0
  329. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPast/verdict-2.out +54 -0
  330. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPastHolds/ChartRun.out +54 -0
  331. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPastHolds/CounterInitPastHolds.cfg +3 -0
  332. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPastHolds/CounterInitPastHolds.tla +10 -0
  333. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPastHolds/chart.mmd +1 -0
  334. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPastHolds/graph.dot +6 -0
  335. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPastHolds/report.md +7 -0
  336. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPastHolds/sany.out +2 -0
  337. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInitPastHolds/verdict-1.out +46 -0
  338. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInstance/ChartRun.out +59 -0
  339. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInstance/CounterInstance.cfg +2 -0
  340. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInstance/CounterInstance.tla +10 -0
  341. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInstance/CounterSteps.tla +6 -0
  342. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInstance/chart.mmd +17 -0
  343. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInstance/graph.dot +15 -0
  344. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInstance/report.md +14 -0
  345. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInstance/sany.out +3 -0
  346. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInstance/verdict-1.exit +1 -0
  347. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterInstance/verdict-1.out +78 -0
  348. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterJump/ChartRun.out +59 -0
  349. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterJump/CounterJump.cfg +3 -0
  350. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterJump/CounterJump.tla +19 -0
  351. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterJump/chart.mmd +26 -0
  352. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterJump/graph.dot +22 -0
  353. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterJump/report.md +12 -0
  354. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterJump/sany.out +2 -0
  355. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterJump/verdict-1.exit +1 -0
  356. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterJump/verdict-1.out +58 -0
  357. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterJump/verdict-2.out +57 -0
  358. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterLoop/ChartRun.out +57 -0
  359. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterLoop/CounterLoop.cfg +2 -0
  360. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterLoop/CounterLoop.tla +11 -0
  361. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterLoop/chart.mmd +17 -0
  362. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterLoop/graph.dot +15 -0
  363. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterLoop/report.md +14 -0
  364. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterLoop/sany.out +2 -0
  365. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterLoop/verdict-1.exit +1 -0
  366. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterLoop/verdict-1.out +76 -0
  367. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterOrder/ChartRun.out +59 -0
  368. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterOrder/CounterOrder.cfg +3 -0
  369. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterOrder/CounterOrder.tla +11 -0
  370. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterOrder/chart.mmd +19 -0
  371. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterOrder/graph.dot +10 -0
  372. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterOrder/report.md +15 -0
  373. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterOrder/sany.out +2 -0
  374. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterOrder/verdict-1.exit +1 -0
  375. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterOrder/verdict-1.out +56 -0
  376. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterOrder/verdict-2.exit +1 -0
  377. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterOrder/verdict-2.out +67 -0
  378. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterRules/ChartRun.out +62 -0
  379. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterRules/CounterRules.cfg +6 -0
  380. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterRules/CounterRules.tla +24 -0
  381. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterRules/Moves.tla +5 -0
  382. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterRules/chart.mmd +22 -0
  383. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterRules/graph.dot +10 -0
  384. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterRules/report.md +23 -0
  385. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterRules/sany.out +3 -0
  386. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterRules/verdict-1.exit +1 -0
  387. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterRules/verdict-1.out +58 -0
  388. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterRules/verdict-2.exit +1 -0
  389. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterRules/verdict-2.out +66 -0
  390. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterRules/verdict-3.exit +1 -0
  391. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterRules/verdict-3.out +74 -0
  392. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterRules/verdict-4.out +59 -0
  393. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStart/ChartRun.out +58 -0
  394. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStart/CounterStart.cfg +3 -0
  395. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStart/CounterStart.tla +15 -0
  396. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStart/chart.mmd +18 -0
  397. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStart/graph.dot +13 -0
  398. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStart/report.md +11 -0
  399. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStart/sany.out +2 -0
  400. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStart/verdict-1.exit +1 -0
  401. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStart/verdict-1.out +33 -0
  402. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStart/verdict-2.out +57 -0
  403. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStop/ChartRun.out +57 -0
  404. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStop/CounterStop.cfg +3 -0
  405. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStop/CounterStop.tla +15 -0
  406. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStop/chart.mmd +7 -0
  407. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStop/graph.dot +13 -0
  408. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStop/report.md +6 -0
  409. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStop/sany.out +2 -0
  410. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterStop/verdict-1.out +49 -0
  411. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTie/ChartRun.out +61 -0
  412. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTie/CounterTie.cfg +4 -0
  413. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTie/CounterTie.tla +14 -0
  414. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTie/chart.mmd +30 -0
  415. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTie/graph.dot +19 -0
  416. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTie/report.md +27 -0
  417. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTie/sany.out +2 -0
  418. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTie/verdict-1.exit +1 -0
  419. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTie/verdict-1.out +56 -0
  420. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTie/verdict-2.exit +1 -0
  421. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTie/verdict-2.out +64 -0
  422. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTie/verdict-3.exit +1 -0
  423. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTie/verdict-3.out +87 -0
  424. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTie/verdict-4.out +57 -0
  425. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTieInGraph/ChartRun.out +60 -0
  426. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTieInGraph/CounterTieInGraph.cfg +3 -0
  427. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTieInGraph/CounterTieInGraph.tla +12 -0
  428. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTieInGraph/chart.mmd +23 -0
  429. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTieInGraph/graph.dot +19 -0
  430. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTieInGraph/report.md +11 -0
  431. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTieInGraph/sany.out +2 -0
  432. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTieInGraph/verdict-1.exit +1 -0
  433. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTieInGraph/verdict-1.out +56 -0
  434. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterTieInGraph/verdict-2.out +57 -0
  435. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterView/ChartRun.out +61 -0
  436. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterView/CounterView.cfg +4 -0
  437. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterView/CounterView.tla +14 -0
  438. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterView/chart.mmd +23 -0
  439. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterView/graph.dot +19 -0
  440. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterView/report.md +27 -0
  441. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterView/sany.out +2 -0
  442. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterView/verdict-1.exit +1 -0
  443. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterView/verdict-1.out +56 -0
  444. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterView/verdict-2.exit +1 -0
  445. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterView/verdict-2.out +64 -0
  446. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterView/verdict-3.exit +1 -0
  447. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterView/verdict-3.out +87 -0
  448. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterView/verdict-4.out +57 -0
  449. package/plugins/pstack/skills/statechart/scripts/test/corpus/CounterView/view.mjs +1 -0
  450. package/plugins/pstack/skills/statechart/scripts/test/corpus/DieHard/ChartRun.out +59 -0
  451. package/plugins/pstack/skills/statechart/scripts/test/corpus/DieHard/DieHard.cfg +4 -0
  452. package/plugins/pstack/skills/statechart/scripts/test/corpus/DieHard/DieHard.tla +38 -0
  453. package/plugins/pstack/skills/statechart/scripts/test/corpus/DieHard/chart.mmd +92 -0
  454. package/plugins/pstack/skills/statechart/scripts/test/corpus/DieHard/graph.dot +126 -0
  455. package/plugins/pstack/skills/statechart/scripts/test/corpus/DieHard/report.md +17 -0
  456. package/plugins/pstack/skills/statechart/scripts/test/corpus/DieHard/sany.out +2 -0
  457. package/plugins/pstack/skills/statechart/scripts/test/corpus/DieHard/verdict-1.exit +1 -0
  458. package/plugins/pstack/skills/statechart/scripts/test/corpus/DieHard/verdict-1.out +91 -0
  459. package/plugins/pstack/skills/statechart/scripts/test/corpus/DieHard/verdict-2.out +57 -0
  460. package/plugins/pstack/skills/statechart/scripts/test/corpus/FirstRule/ChartRun.out +61 -0
  461. package/plugins/pstack/skills/statechart/scripts/test/corpus/FirstRule/FirstRule.cfg +6 -0
  462. package/plugins/pstack/skills/statechart/scripts/test/corpus/FirstRule/FirstRule.tla +11 -0
  463. package/plugins/pstack/skills/statechart/scripts/test/corpus/FirstRule/chart.mmd +22 -0
  464. package/plugins/pstack/skills/statechart/scripts/test/corpus/FirstRule/graph.dot +16 -0
  465. package/plugins/pstack/skills/statechart/scripts/test/corpus/FirstRule/report.md +25 -0
  466. package/plugins/pstack/skills/statechart/scripts/test/corpus/FirstRule/sany.out +2 -0
  467. package/plugins/pstack/skills/statechart/scripts/test/corpus/FirstRule/verdict-1.exit +1 -0
  468. package/plugins/pstack/skills/statechart/scripts/test/corpus/FirstRule/verdict-1.out +56 -0
  469. package/plugins/pstack/skills/statechart/scripts/test/corpus/FirstRule/verdict-2.exit +1 -0
  470. package/plugins/pstack/skills/statechart/scripts/test/corpus/FirstRule/verdict-2.out +64 -0
  471. package/plugins/pstack/skills/statechart/scripts/test/corpus/FirstRule/verdict-3.exit +1 -0
  472. package/plugins/pstack/skills/statechart/scripts/test/corpus/FirstRule/verdict-3.out +64 -0
  473. package/plugins/pstack/skills/statechart/scripts/test/corpus/FirstRule/verdict-4.exit +1 -0
  474. package/plugins/pstack/skills/statechart/scripts/test/corpus/FirstRule/verdict-4.out +77 -0
  475. package/plugins/pstack/skills/statechart/scripts/test/corpus/HiddenClock/ChartRun.out +57 -0
  476. package/plugins/pstack/skills/statechart/scripts/test/corpus/HiddenClock/HiddenClock.cfg +4 -0
  477. package/plugins/pstack/skills/statechart/scripts/test/corpus/HiddenClock/HiddenClock.tla +11 -0
  478. package/plugins/pstack/skills/statechart/scripts/test/corpus/HiddenClock/chart.mmd +13 -0
  479. package/plugins/pstack/skills/statechart/scripts/test/corpus/HiddenClock/graph.dot +12 -0
  480. package/plugins/pstack/skills/statechart/scripts/test/corpus/HiddenClock/report.md +11 -0
  481. package/plugins/pstack/skills/statechart/scripts/test/corpus/HiddenClock/sany.out +2 -0
  482. package/plugins/pstack/skills/statechart/scripts/test/corpus/HiddenClock/verdict-1.exit +1 -0
  483. package/plugins/pstack/skills/statechart/scripts/test/corpus/HiddenClock/verdict-1.out +72 -0
  484. package/plugins/pstack/skills/statechart/scripts/test/corpus/Login/ChartRun.out +57 -0
  485. package/plugins/pstack/skills/statechart/scripts/test/corpus/Login/Login.cfg +3 -0
  486. package/plugins/pstack/skills/statechart/scripts/test/corpus/Login/Login.tla +62 -0
  487. package/plugins/pstack/skills/statechart/scripts/test/corpus/Login/chart.mmd +27 -0
  488. package/plugins/pstack/skills/statechart/scripts/test/corpus/Login/graph.dot +40 -0
  489. package/plugins/pstack/skills/statechart/scripts/test/corpus/Login/report.md +7 -0
  490. package/plugins/pstack/skills/statechart/scripts/test/corpus/Login/sany.out +1 -0
  491. package/plugins/pstack/skills/statechart/scripts/test/corpus/Login/verdict-1.out +47 -0
  492. package/plugins/pstack/skills/statechart/scripts/test/corpus/Login/view.mjs +1 -0
  493. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginGuarded/ChartRun.out +57 -0
  494. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginGuarded/LoginGuarded.cfg +2 -0
  495. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginGuarded/LoginGuarded.tla +64 -0
  496. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginGuarded/chart.mmd +28 -0
  497. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginGuarded/graph.dot +37 -0
  498. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginGuarded/report.md +8 -0
  499. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginGuarded/sany.out +1 -0
  500. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginGuarded/verdict-1.out +47 -0
  501. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginGuarded/view.mjs +1 -0
  502. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginParallel/ChartRun.out +60 -0
  503. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginParallel/LoginParallel.cfg +3 -0
  504. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginParallel/LoginParallel.tla +64 -0
  505. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginParallel/chart.mmd +44 -0
  506. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginParallel/graph.dot +58 -0
  507. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginParallel/report.md +17 -0
  508. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginParallel/sany.out +1 -0
  509. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginParallel/verdict-1.exit +1 -0
  510. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginParallel/verdict-1.out +83 -0
  511. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginParallel/verdict-2.out +57 -0
  512. package/plugins/pstack/skills/statechart/scripts/test/corpus/LoginParallel/view.mjs +1 -0
  513. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayer/ChartRun.out +60 -0
  514. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayer/MediaPlayer.cfg +3 -0
  515. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayer/MediaPlayer.tla +103 -0
  516. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayer/chart.mmd +43 -0
  517. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayer/graph.dot +93 -0
  518. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayer/report.md +14 -0
  519. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayer/sany.out +1 -0
  520. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayer/verdict-1.exit +1 -0
  521. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayer/verdict-1.out +59 -0
  522. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayer/verdict-2.out +72 -0
  523. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayer/view.mjs +3 -0
  524. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerFixed/ChartRun.out +57 -0
  525. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerFixed/MediaPlayerFixed.cfg +2 -0
  526. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerFixed/MediaPlayerFixed.tla +100 -0
  527. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerFixed/chart.mmd +31 -0
  528. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerFixed/graph.dot +85 -0
  529. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerFixed/report.md +9 -0
  530. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerFixed/sany.out +1 -0
  531. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerFixed/verdict-1.out +47 -0
  532. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerFixed/view.mjs +3 -0
  533. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/ChartRun.out +59 -0
  534. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/MediaPlayer.tla +103 -0
  535. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/MediaPlayerProps.cfg +3 -0
  536. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/MediaPlayerProps.tla +6 -0
  537. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/chart.mmd +42 -0
  538. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/graph.dot +93 -0
  539. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/report.md +19 -0
  540. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/sany.out +2 -0
  541. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-1.exit +1 -0
  542. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-1.out +61 -0
  543. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-2.out +59 -0
  544. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-3.out +61 -0
  545. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-4.exit +1 -0
  546. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-4.out +66 -0
  547. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-5.exit +1 -0
  548. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-5.out +58 -0
  549. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-6.out +49 -0
  550. package/plugins/pstack/skills/statechart/scripts/test/corpus/MediaPlayerProps/view.mjs +3 -0
  551. package/plugins/pstack/skills/statechart/scripts/test/corpus/PickWorker/ChartRun.out +57 -0
  552. package/plugins/pstack/skills/statechart/scripts/test/corpus/PickWorker/PickWorker.cfg +6 -0
  553. package/plugins/pstack/skills/statechart/scripts/test/corpus/PickWorker/PickWorker.tla +11 -0
  554. package/plugins/pstack/skills/statechart/scripts/test/corpus/PickWorker/chart.mmd +5 -0
  555. package/plugins/pstack/skills/statechart/scripts/test/corpus/PickWorker/graph.dot +11 -0
  556. package/plugins/pstack/skills/statechart/scripts/test/corpus/PickWorker/report.md +7 -0
  557. package/plugins/pstack/skills/statechart/scripts/test/corpus/PickWorker/sany.out +5 -0
  558. package/plugins/pstack/skills/statechart/scripts/test/corpus/PickWorker/verdict-1.out +70 -0
  559. package/plugins/pstack/skills/statechart/scripts/test/corpus/Shadow/ChartRun.out +61 -0
  560. package/plugins/pstack/skills/statechart/scripts/test/corpus/Shadow/Shadow.cfg +4 -0
  561. package/plugins/pstack/skills/statechart/scripts/test/corpus/Shadow/Shadow.tla +11 -0
  562. package/plugins/pstack/skills/statechart/scripts/test/corpus/Shadow/ShadowLib.tla +6 -0
  563. package/plugins/pstack/skills/statechart/scripts/test/corpus/Shadow/ShadowSub.tla +3 -0
  564. package/plugins/pstack/skills/statechart/scripts/test/corpus/Shadow/chart.mmd +9 -0
  565. package/plugins/pstack/skills/statechart/scripts/test/corpus/Shadow/graph.dot +16 -0
  566. package/plugins/pstack/skills/statechart/scripts/test/corpus/Shadow/report.md +8 -0
  567. package/plugins/pstack/skills/statechart/scripts/test/corpus/Shadow/sany.out +4 -0
  568. package/plugins/pstack/skills/statechart/scripts/test/corpus/Shadow/verdict-1.out +65 -0
  569. package/plugins/pstack/skills/statechart/scripts/test/corpus/SpacedNames/ChartRun.out +59 -0
  570. package/plugins/pstack/skills/statechart/scripts/test/corpus/SpacedNames/SpacedNames.cfg +2 -0
  571. package/plugins/pstack/skills/statechart/scripts/test/corpus/SpacedNames/SpacedNames.tla +9 -0
  572. package/plugins/pstack/skills/statechart/scripts/test/corpus/SpacedNames/chart.mmd +23 -0
  573. package/plugins/pstack/skills/statechart/scripts/test/corpus/SpacedNames/graph.dot +17 -0
  574. package/plugins/pstack/skills/statechart/scripts/test/corpus/SpacedNames/report.md +15 -0
  575. package/plugins/pstack/skills/statechart/scripts/test/corpus/SpacedNames/sany.out +1 -0
  576. package/plugins/pstack/skills/statechart/scripts/test/corpus/SpacedNames/verdict-1.exit +1 -0
  577. package/plugins/pstack/skills/statechart/scripts/test/corpus/SpacedNames/verdict-1.out +65 -0
  578. package/plugins/pstack/skills/statechart/scripts/test/corpus/SpacedNames/verdict-2.exit +1 -0
  579. package/plugins/pstack/skills/statechart/scripts/test/corpus/SpacedNames/verdict-2.out +75 -0
  580. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhase/ChartRun.out +69 -0
  581. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhase/TwoPhase.cfg +3 -0
  582. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhase/TwoPhase.tla +75 -0
  583. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhase/chart.mmd +60 -0
  584. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhase/graph.dot +297 -0
  585. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhase/report.md +20 -0
  586. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhase/sany.out +1 -0
  587. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhase/verdict-1.exit +1 -0
  588. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhase/verdict-1.out +95 -0
  589. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhase/verdict-2.out +57 -0
  590. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhase/view.mjs +1 -0
  591. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhaseFixed/ChartRun.out +57 -0
  592. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhaseFixed/TwoPhaseFixed.cfg +3 -0
  593. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhaseFixed/TwoPhaseFixed.tla +75 -0
  594. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhaseFixed/chart.mmd +37 -0
  595. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhaseFixed/graph.dot +223 -0
  596. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhaseFixed/report.md +11 -0
  597. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhaseFixed/sany.out +1 -0
  598. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhaseFixed/verdict-1.out +47 -0
  599. package/plugins/pstack/skills/statechart/scripts/test/corpus/TwoPhaseFixed/view.mjs +1 -0
  600. package/plugins/pstack/skills/statechart/scripts/test/corpus/TypeGuard/ChartRun.exit +1 -0
  601. package/plugins/pstack/skills/statechart/scripts/test/corpus/TypeGuard/ChartRun.out +75 -0
  602. package/plugins/pstack/skills/statechart/scripts/test/corpus/TypeGuard/TypeGuard.cfg +5 -0
  603. package/plugins/pstack/skills/statechart/scripts/test/corpus/TypeGuard/TypeGuard.tla +11 -0
  604. package/plugins/pstack/skills/statechart/scripts/test/corpus/TypeGuard/chart.mmd +18 -0
  605. package/plugins/pstack/skills/statechart/scripts/test/corpus/TypeGuard/graph.dot +14 -0
  606. package/plugins/pstack/skills/statechart/scripts/test/corpus/TypeGuard/report.md +29 -0
  607. package/plugins/pstack/skills/statechart/scripts/test/corpus/TypeGuard/sany.out +2 -0
  608. package/plugins/pstack/skills/statechart/scripts/test/corpus/TypeGuard/verdict-1.exit +1 -0
  609. package/plugins/pstack/skills/statechart/scripts/test/corpus/TypeGuard/verdict-1.out +64 -0
  610. package/plugins/pstack/skills/statechart/scripts/test/corpus/TypeGuard/verdict-2.exit +1 -0
  611. package/plugins/pstack/skills/statechart/scripts/test/corpus/TypeGuard/verdict-2.out +75 -0
  612. package/plugins/pstack/skills/statechart/scripts/test/corpus/UserNoDeadlock/ChartRun.out +58 -0
  613. package/plugins/pstack/skills/statechart/scripts/test/corpus/UserNoDeadlock/UserNoDeadlock.cfg +2 -0
  614. package/plugins/pstack/skills/statechart/scripts/test/corpus/UserNoDeadlock/UserNoDeadlock.tla +8 -0
  615. package/plugins/pstack/skills/statechart/scripts/test/corpus/UserNoDeadlock/chart.mmd +22 -0
  616. package/plugins/pstack/skills/statechart/scripts/test/corpus/UserNoDeadlock/graph.dot +16 -0
  617. package/plugins/pstack/skills/statechart/scripts/test/corpus/UserNoDeadlock/report.md +15 -0
  618. package/plugins/pstack/skills/statechart/scripts/test/corpus/UserNoDeadlock/sany.out +2 -0
  619. package/plugins/pstack/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-1.exit +1 -0
  620. package/plugins/pstack/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-1.out +56 -0
  621. package/plugins/pstack/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-2.exit +1 -0
  622. package/plugins/pstack/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-2.out +77 -0
  623. package/plugins/pstack/skills/statechart/scripts/test/corpus.test.ts +415 -0
  624. package/plugins/pstack/skills/statechart/scripts/test/differential.test.ts +565 -0
  625. package/plugins/pstack/skills/statechart/scripts/test/grid/Grid.cfg +2 -0
  626. package/plugins/pstack/skills/statechart/scripts/test/grid/Grid.tla +9 -0
  627. package/plugins/pstack/skills/statechart/scripts/test/grid/sany.out +2 -0
  628. package/plugins/pstack/skills/statechart/scripts/test/java.ts +63 -0
  629. package/plugins/pstack/skills/statechart/scripts/test/labels.ts +643 -0
  630. package/plugins/pstack/skills/statechart/scripts/test/messages.test.ts +227 -0
  631. package/plugins/pstack/skills/statechart/scripts/test/pipeline.test.ts +270 -0
  632. package/plugins/pstack/skills/statechart/scripts/test/plain-tlc.test.ts +255 -0
  633. package/plugins/pstack/skills/statechart/scripts/test/render.test.ts +81 -0
  634. package/plugins/pstack/skills/statechart/scripts/test/tlc-out.test.ts +90 -0
  635. package/plugins/pstack/skills/statechart/scripts/test/tlc.ts +158 -0
  636. package/plugins/pstack/skills/statechart/scripts/tsconfig.json +11 -0
  637. package/plugins/pstack/skills/statechart/scripts/worker.ts +35 -0
  638. package/plugins/pstack/skills/swarm/SKILL.md +58 -0
  639. package/plugins/pstack/skills/tdd/SKILL.md +41 -0
  640. package/plugins/pstack/skills/teach/SKILL.md +28 -0
  641. package/plugins/pstack/skills/technical-writing/SKILL.md +105 -0
  642. package/plugins/pstack/skills/thermo-nuclear-code-quality-review/SKILL.md +201 -0
  643. package/plugins/pstack/skills/thermo-nuclear-review/SKILL.md +50 -0
  644. package/plugins/pstack/skills/thermos/SKILL.md +40 -0
  645. package/plugins/pstack/skills/typescript-best-practices/SKILL.md +32 -0
  646. package/plugins/pstack/skills/typescript-best-practices/references/patterns.md +328 -0
  647. package/plugins/pstack/skills/unslop/SKILL.md +61 -0
  648. package/plugins/pstack/skills/what-did-i-get-done/SKILL.md +31 -0
  649. package/plugins/pstack/skills/why/SKILL.md +116 -0
  650. package/plugins/pstack/skills/why/references/epistemics.md +79 -0
  651. package/plugins/pstack/skills/why/references/investigator-prompt.md +86 -0
  652. package/plugins/pstack/skills/why/references/source-playbook.md +17 -0
  653. package/plugins/pstack/skills/why/references/sources/code-archaeology.md +51 -0
  654. package/plugins/pstack/skills/why/references/sources/databricks.md +70 -0
  655. package/plugins/pstack/skills/why/references/sources/datadog.md +97 -0
  656. package/plugins/pstack/skills/why/references/sources/incident-postmortem.md +5 -0
  657. package/plugins/pstack/skills/why/references/sources/linear.md +48 -0
  658. package/plugins/pstack/skills/why/references/sources/notion.md +55 -0
  659. package/plugins/pstack/skills/why/references/sources/sentry.md +66 -0
  660. package/plugins/pstack/skills/why/references/sources/slack.md +17 -0
  661. package/plugins/pstack/skills/why/references/synthesizer-prompt.md +130 -0
  662. package/tools/forks.json +398 -0
  663. package/tools/substitutions.json +646 -0
  664. package/tools/upstream.json +53 -0
@@ -0,0 +1,956 @@
1
+ import { landingRevision } from "./landing.ts";
2
+ import {
3
+ ChecksUnavailable,
4
+ WatcherQueryError,
5
+ resolveChecks,
6
+ resolveReviewThreads,
7
+ } from "./github.ts";
8
+ import { DeadlineExceeded, type WatchDeadline } from "./deadline.ts";
9
+ import type * as T from "./types.ts";
10
+ import { nonEmpty } from "./types.ts";
11
+ export function assessGitHubMerge(args: {
12
+ readonly mergeStateStatus: T.MergeStateStatus;
13
+ readonly headRollupState: T.RollupState;
14
+ }): T.GitHubMergeAssessment {
15
+ if (args.mergeStateStatus === "BLOCKED") {
16
+ if (args.headRollupState === "ERROR" || args.headRollupState === "FAILURE")
17
+ return {
18
+ kind: "refused",
19
+ mergeStateStatus: args.mergeStateStatus,
20
+ headRollupState: args.headRollupState,
21
+ };
22
+ return {
23
+ kind: "allowed",
24
+ basis: "rollup",
25
+ mergeStateStatus: args.mergeStateStatus,
26
+ headRollupState: args.headRollupState,
27
+ };
28
+ }
29
+ return {
30
+ kind: "allowed",
31
+ basis: "merge-state",
32
+ mergeStateStatus: args.mergeStateStatus,
33
+ headRollupState: args.headRollupState,
34
+ };
35
+ }
36
+ async function mergeAssessment(
37
+ reader: T.GitHubReader,
38
+ facts: T.PullRequestFacts
39
+ ) {
40
+ const commits = await reader.commitRollups(facts.context);
41
+ const head = commits.find((commit) => commit.oid === facts.headRefOid);
42
+ if (head === undefined)
43
+ throw new WatcherQueryError({
44
+ kind: "snapshot-changed",
45
+ retryable: true,
46
+ detail: `commit response does not contain expected head ${facts.headRefOid}`,
47
+ });
48
+ const headRollupState = head.state;
49
+ return {
50
+ anyCommitReported: commits.some((commit) => commit.state !== null),
51
+ hadPreviousPassingCi: commits.some(
52
+ (commit) => commit.oid !== facts.headRefOid && commit.state === "SUCCESS"
53
+ ),
54
+ github: assessGitHubMerge({
55
+ mergeStateStatus: facts.mergeStateStatus,
56
+ headRollupState,
57
+ }),
58
+ };
59
+ }
60
+ type OpenFacts = Extract<T.PullRequestFacts, { readonly state: "OPEN" }>;
61
+ export type NoChecksConfirmer = (
62
+ head: Pick<OpenFacts, "context" | "headRefOid">
63
+ ) => boolean;
64
+ // GitHub registers a fresh head's checks seconds after the push, during which
65
+ // every read matches a repository with no CI. Across 67 pushes measured in six
66
+ // repositories the first check appeared within 9 seconds.
67
+ export const NO_CHECKS_CONFIRM_SECONDS = 60;
68
+ export function noChecksConfirmer(
69
+ clock: Pick<WatchClock, "now">
70
+ ): NoChecksConfirmer {
71
+ const firstSeen = new Map<
72
+ T.PrNumber,
73
+ { readonly headRefOid: string; readonly at: number }
74
+ >();
75
+ return (head) => {
76
+ const now = clock.now();
77
+ const prior = firstSeen.get(head.context.number);
78
+ if (prior?.headRefOid === head.headRefOid)
79
+ return now - prior.at >= NO_CHECKS_CONFIRM_SECONDS;
80
+ firstSeen.set(head.context.number, {
81
+ headRefOid: head.headRefOid,
82
+ at: now,
83
+ });
84
+ return false;
85
+ };
86
+ }
87
+ const neverConfirms: NoChecksConfirmer = () => false;
88
+ async function noChecksCi(
89
+ reader: T.GitHubReader,
90
+ facts: OpenFacts,
91
+ confirmNoChecks = neverConfirms
92
+ ): Promise<T.CiNone | T.CiUnreported> {
93
+ const merge = await mergeAssessment(reader, facts);
94
+ if (merge.anyCommitReported || merge.github.kind === "refused")
95
+ throw new ChecksUnavailable(
96
+ `no checks reported on head ${facts.headRefOid}, but a commit on this PR has reported checks`
97
+ );
98
+ const none = {
99
+ failed: [],
100
+ pending: [],
101
+ hadPreviousPassingCi: false,
102
+ } as const;
103
+ return confirmNoChecks(facts)
104
+ ? { ...none, kind: "ci-none", github: merge.github }
105
+ : { ...none, kind: "ci-unreported" };
106
+ }
107
+ const AUTOMATION_TOKENS = [
108
+ "bugbot",
109
+ "security review",
110
+ "pr review automation",
111
+ "review automation",
112
+ ] as const;
113
+ const VERDICT_FACTS: Record<
114
+ Exclude<keyof T.PullRequestFacts, "context">,
115
+ true
116
+ > = {
117
+ state: true,
118
+ mergedAt: true,
119
+ isDraft: true,
120
+ mergeable: true,
121
+ mergeStateStatus: true,
122
+ reviewDecision: true,
123
+ headRefOid: true,
124
+ headRefName: true,
125
+ baseRefName: true,
126
+ baseRefOid: true,
127
+ };
128
+ const mergeabilityUnknown = (facts: T.PullRequestFacts): boolean =>
129
+ facts.mergeable === "UNKNOWN" || facts.mergeStateStatus === "UNKNOWN";
130
+ // GitHub computes these two on the first read that asks, so an unknown first
131
+ // read usually has its answer by the re-read. That is not the PR changing.
132
+ const COMPUTED_ON_DEMAND: ReadonlySet<string> = new Set([
133
+ "mergeable",
134
+ "mergeStateStatus",
135
+ ]);
136
+ const changedFacts = (
137
+ before: T.PullRequestFacts,
138
+ after: T.PullRequestFacts
139
+ ): string[] =>
140
+ (Object.keys(VERDICT_FACTS) as (keyof typeof VERDICT_FACTS)[])
141
+ .filter((fact) => before[fact] !== after[fact])
142
+ .filter(
143
+ (fact) => !(mergeabilityUnknown(before) && COMPUTED_ON_DEMAND.has(fact))
144
+ )
145
+ .map((fact) => `${fact} ${before[fact]} -> ${after[fact]}`);
146
+ export async function readSnapshot(args: {
147
+ readonly reader: T.GitHubReader;
148
+ readonly context: T.PrContext;
149
+ readonly pendingHistory: "include" | "omit";
150
+ readonly allowDraft: boolean;
151
+ readonly confirmNoChecks?: NoChecksConfirmer;
152
+ }): Promise<T.PrSnapshot> {
153
+ const facts = await args.reader.pullRequest(args.context);
154
+ if (facts.state === "MERGED" || facts.mergedAt !== null)
155
+ return { kind: "merged", context: args.context, facts };
156
+ if (facts.state === "CLOSED")
157
+ return { kind: "closed", context: args.context, facts };
158
+ const [threads, checks] = await Promise.all([
159
+ resolveReviewThreads(args.reader, args.context),
160
+ resolveChecks(args.reader, args.context),
161
+ ]);
162
+ const failed = nonEmpty(
163
+ checks.checks.filter(
164
+ (check): check is T.FailedCheck => check.kind === "failed"
165
+ )
166
+ );
167
+ const pending = nonEmpty(
168
+ checks.checks.filter(
169
+ (check): check is T.PendingCheck => check.kind === "pending"
170
+ )
171
+ );
172
+ let ci: T.CiState;
173
+ if (checks.kind === "no-checks")
174
+ ci = await noChecksCi(args.reader, facts, args.confirmNoChecks);
175
+ else if (
176
+ failed === null &&
177
+ pending !== null &&
178
+ args.pendingHistory === "omit"
179
+ )
180
+ ci = {
181
+ kind: "ci-pending",
182
+ source: checks.source,
183
+ all: checks.checks,
184
+ failed: [],
185
+ pending,
186
+ hadPreviousPassingCi: false,
187
+ };
188
+ else {
189
+ const merge = await mergeAssessment(args.reader, facts);
190
+ const base = {
191
+ source: checks.source,
192
+ all: checks.checks,
193
+ hadPreviousPassingCi: merge.hadPreviousPassingCi,
194
+ };
195
+ if (failed !== null)
196
+ ci = {
197
+ ...base,
198
+ kind: "ci-failing",
199
+ failed,
200
+ pending: pending ?? [],
201
+ github: merge.github,
202
+ };
203
+ else if (merge.github.kind === "refused")
204
+ ci = {
205
+ ...base,
206
+ kind: "ci-github-rejected",
207
+ failed: [],
208
+ pending: pending ?? [],
209
+ github: merge.github,
210
+ };
211
+ else if (pending !== null)
212
+ ci = { ...base, kind: "ci-pending", failed: [], pending };
213
+ else
214
+ ci = {
215
+ ...base,
216
+ kind: "ci-clean",
217
+ failed: [],
218
+ pending: [],
219
+ github: merge.github,
220
+ };
221
+ }
222
+ const factsAfterChecks = await args.reader.pullRequest(args.context);
223
+ const changed = changedFacts(facts, factsAfterChecks);
224
+ if (changed.length > 0)
225
+ throw new WatcherQueryError({
226
+ kind: "snapshot-changed",
227
+ retryable: true,
228
+ detail: `PR changed while collecting ${facts.headRefOid} against ${facts.baseRefName}: ${changed.join(", ")}`,
229
+ });
230
+ return {
231
+ kind: "open",
232
+ context: args.context,
233
+ facts,
234
+ threads,
235
+ ci,
236
+ reviewAutomationRunning: checks.checks.some(
237
+ (check) =>
238
+ check.kind === "pending" &&
239
+ AUTOMATION_TOKENS.some((token) =>
240
+ check.name.toLowerCase().includes(token)
241
+ )
242
+ ),
243
+ };
244
+ }
245
+ const conflictBlocker = (row: T.PrSnapshot): T.MergeBlocker | null =>
246
+ row.kind === "open" &&
247
+ (row.facts.mergeable === "CONFLICTING" ||
248
+ row.facts.mergeStateStatus === "DIRTY" ||
249
+ row.facts.mergeStateStatus === "CONFLICTING")
250
+ ? { kind: "merge-conflicts", pr: row.context, facts: row.facts }
251
+ : null;
252
+ function threadBlocker(row: T.PrSnapshot): T.MergeBlocker | null {
253
+ if (row.kind !== "open") return null;
254
+ const threads = nonEmpty(row.threads);
255
+ return threads === null
256
+ ? null
257
+ : { kind: "review-threads", pr: row.context, threads };
258
+ }
259
+ const ciBlocker = (row: T.PrSnapshot): T.MergeBlocker | null =>
260
+ row.kind === "open" &&
261
+ (row.ci.kind === "ci-failing" || row.ci.kind === "ci-github-rejected")
262
+ ? { kind: "failing-checks", pr: row.context, ci: row.ci }
263
+ : null;
264
+ function gateReason(
265
+ row: T.PrSnapshot,
266
+ allowDraft: boolean
267
+ ): T.MergeGateReason | null {
268
+ if (row.kind === "merged") return null;
269
+ if (row.kind === "closed") return "closed-without-merge";
270
+ if (row.facts.isDraft && !allowDraft) return "draft-pr";
271
+ if (row.facts.reviewDecision === "CHANGES_REQUESTED")
272
+ return "changes-requested";
273
+ // BEHIND means the base requires an up-to-date head. Updating the branch
274
+ // restarts its checks and can dismiss an approval, so this comes before a
275
+ // required review and does not wait for the current checks.
276
+ if (row.facts.mergeStateStatus === "BEHIND") return "behind-base";
277
+ if (row.facts.reviewDecision === "REVIEW_REQUIRED") return "review-required";
278
+ // BLOCKED with clean CI is some other branch protection rule, such as signed
279
+ // commits or a required check that never reported. GitHub will not merge it.
280
+ return row.facts.mergeStateStatus === "BLOCKED" ? "merge-blocked" : null;
281
+ }
282
+ function waitReason(row: T.PrSnapshot): T.WaitReason | null {
283
+ if (row.kind !== "open") return null;
284
+ if (row.ci.kind === "ci-pending")
285
+ return { kind: "pending-checks", pending: row.ci.pending };
286
+ if (row.ci.kind === "ci-unreported") return { kind: "checks-unreported" };
287
+ return mergeabilityUnknown(row.facts)
288
+ ? { kind: "mergeability-unknown" }
289
+ : null;
290
+ }
291
+ const DEFERRED_WHILE_WAITING: ReadonlySet<T.MergeGateReason> = new Set([
292
+ "draft-pr",
293
+ "review-required",
294
+ "merge-blocked",
295
+ ]);
296
+ function gateBlocker(
297
+ row: T.PrSnapshot,
298
+ allowDraft: boolean
299
+ ): T.MergeBlocker | null {
300
+ const reason = gateReason(row, allowDraft);
301
+ return reason === null ||
302
+ (DEFERRED_WHILE_WAITING.has(reason) && waitReason(row) !== null)
303
+ ? null
304
+ : { kind: "merge-gate", pr: row.context, reason };
305
+ }
306
+ // Indexed by the fact itself, so a proof compiles only where the guard below
307
+ // has narrowed mergeable to MERGEABLE.
308
+ const CLEAR_ONLY_WHEN = { MERGEABLE: "clear" } as const;
309
+ function readyContribution(
310
+ row: T.PrSnapshot,
311
+ allowDraft: boolean
312
+ ): T.ReadyPr | T.MergedPr | null {
313
+ if (row.kind === "merged")
314
+ return {
315
+ kind: "merged-pr",
316
+ context: row.context,
317
+ mergedAt: row.facts.mergedAt,
318
+ };
319
+ if (
320
+ row.kind !== "open" ||
321
+ (row.ci.kind !== "ci-clean" && row.ci.kind !== "ci-none") ||
322
+ row.threads.length !== 0 ||
323
+ row.facts.mergeable !== "MERGEABLE" ||
324
+ conflictBlocker(row) !== null ||
325
+ gateReason(row, allowDraft) !== null
326
+ )
327
+ return null;
328
+ const reviewDecision = row.facts.reviewDecision;
329
+ if (
330
+ reviewDecision === "CHANGES_REQUESTED" ||
331
+ reviewDecision === "REVIEW_REQUIRED"
332
+ )
333
+ return null;
334
+ return {
335
+ kind: "ready-pr",
336
+ context: row.context,
337
+ proof: {
338
+ revision: landingRevision(row.facts),
339
+ mergeability: CLEAR_ONLY_WHEN[row.facts.mergeable],
340
+ threads: [],
341
+ ci: row.ci,
342
+ gate: {
343
+ state: "OPEN",
344
+ reviewDecision,
345
+ draft: row.facts.isDraft ? "draft-allowed" : "not-draft",
346
+ },
347
+ },
348
+ };
349
+ }
350
+ export function classifyPr(
351
+ row: T.PrSnapshot,
352
+ allowDraft = false
353
+ ): T.PrDecision {
354
+ for (const blocker of [
355
+ conflictBlocker(row),
356
+ threadBlocker(row),
357
+ ciBlocker(row),
358
+ gateBlocker(row, allowDraft),
359
+ ])
360
+ if (blocker !== null) return { kind: "blocker", blocker };
361
+ const wait = waitReason(row);
362
+ if (wait !== null)
363
+ return { kind: "waiting", frontier: row.context, reason: wait };
364
+ const ready = readyContribution(row, allowDraft);
365
+ if (ready === null) throw new Error("snapshot has no classified decision");
366
+ return ready.kind === "merged-pr"
367
+ ? { kind: "merged", pr: ready }
368
+ : { kind: "ready", pr: ready };
369
+ }
370
+ export function selectTierMajorStackDecision(
371
+ rows: T.NonEmpty<T.PrSnapshot>,
372
+ allowDraft = false
373
+ ): T.StackDecision {
374
+ for (const tier of [conflictBlocker, threadBlocker, ciBlocker])
375
+ for (const row of rows) {
376
+ const blocker = tier(row);
377
+ if (blocker !== null) return { kind: "blocker", blocker };
378
+ }
379
+ for (const row of rows) {
380
+ const blocker = gateBlocker(row, allowDraft);
381
+ if (blocker !== null) return { kind: "blocker", blocker };
382
+ }
383
+ for (const row of rows) {
384
+ const wait = waitReason(row);
385
+ if (wait !== null)
386
+ return { kind: "waiting", frontier: row.context, reason: wait };
387
+ }
388
+ const prs = nonEmpty(
389
+ rows
390
+ .map((row) => readyContribution(row, allowDraft))
391
+ .filter((row): row is T.ReadyPr | T.MergedPr => row !== null)
392
+ );
393
+ if (prs === null || prs.length !== rows.length)
394
+ throw new Error("stack has no classified decision");
395
+ return { kind: "clear", prs };
396
+ }
397
+ export const queryBackoffSeconds = (
398
+ interval: number,
399
+ failures: number
400
+ ): number => Math.min(Math.max(interval, 60) * 2 ** (failures - 1), 300);
401
+ interface Envelope<M extends T.WatchMode> {
402
+ readonly schemaVersion: 1;
403
+ readonly sequence: number;
404
+ readonly observedAt: string;
405
+ readonly mode: M;
406
+ }
407
+ type Payload<V> = V extends unknown
408
+ ? Omit<V, keyof Envelope<T.WatchMode>>
409
+ : never;
410
+ type VerdictPayload = Payload<T.WatcherVerdict>;
411
+ export interface VerdictStamp<M extends T.WatchMode = T.WatchMode> {
412
+ <const P extends VerdictPayload>(payload: P): Envelope<M> & P;
413
+ <const P extends VerdictPayload, M2 extends T.WatchMode>(
414
+ payload: P,
415
+ mode: M2
416
+ ): Envelope<M2> & P;
417
+ }
418
+ export function verdictFactory<M extends T.WatchMode>(
419
+ clock: WatchClock,
420
+ mode: M
421
+ ): VerdictStamp<M> {
422
+ let sequence = 0;
423
+ function stamp<const P extends VerdictPayload>(payload: P): Envelope<M> & P;
424
+ function stamp<const P extends VerdictPayload, M2 extends T.WatchMode>(
425
+ payload: P,
426
+ mode: M2
427
+ ): Envelope<M2> & P;
428
+ function stamp<const P extends VerdictPayload>(
429
+ payload: P,
430
+ override?: T.WatchMode
431
+ ): Envelope<T.WatchMode> & P {
432
+ return {
433
+ schemaVersion: 1,
434
+ sequence: (sequence += 1),
435
+ observedAt: clock.observedAt(),
436
+ mode: override ?? mode,
437
+ ...payload,
438
+ };
439
+ }
440
+ return stamp;
441
+ }
442
+ function blockerVerdict(
443
+ stamp: VerdictStamp,
444
+ blocker: T.MergeBlocker
445
+ ): T.BlockerVerdict {
446
+ switch (blocker.kind) {
447
+ case "merge-conflicts":
448
+ return stamp({ kind: "BLOCKER", terminal: true, exitCode: 2, blocker });
449
+ case "review-threads":
450
+ return stamp({ kind: "BLOCKER", terminal: true, exitCode: 3, blocker });
451
+ case "failing-checks":
452
+ return stamp({ kind: "BLOCKER", terminal: true, exitCode: 4, blocker });
453
+ case "merge-gate":
454
+ return stamp({ kind: "BLOCKER", terminal: true, exitCode: 6, blocker });
455
+ default: {
456
+ const exhaustive: never = blocker;
457
+ return exhaustive;
458
+ }
459
+ }
460
+ }
461
+ export function statusQueryVerdict(
462
+ stamp: VerdictStamp,
463
+ failures: number,
464
+ failure: T.QueryFailure
465
+ ): T.BlockerVerdict {
466
+ return stamp({
467
+ kind: "BLOCKER",
468
+ terminal: true,
469
+ exitCode: 7,
470
+ blocker: { kind: "status-query", failures, failure },
471
+ });
472
+ }
473
+ export interface WatchClock {
474
+ now(): number;
475
+ observedAt(): string;
476
+ sleep(seconds: number): Promise<void>;
477
+ }
478
+ export interface RunDependencies {
479
+ readonly deadline: WatchDeadline;
480
+ readonly reader: T.GitHubReader;
481
+ readonly clock: WatchClock;
482
+ readonly emit: (verdict: T.ProgressVerdict) => void;
483
+ }
484
+ export function deadlineVerdict(stamp: VerdictStamp): T.TimeoutVerdict {
485
+ return stamp({
486
+ kind: "TIMEOUT",
487
+ terminal: true,
488
+ exitCode: 5,
489
+ reason: {
490
+ kind: "status-unavailable",
491
+ failure: {
492
+ kind: "deadline",
493
+ retryable: false,
494
+ detail: "deadline reached before a complete observation",
495
+ },
496
+ },
497
+ });
498
+ }
499
+ type StepResult<V> =
500
+ | { readonly kind: "terminal"; readonly verdict: V }
501
+ | {
502
+ readonly kind: "sleep";
503
+ readonly seconds: number;
504
+ readonly onDeadline: () => V;
505
+ }
506
+ | { readonly kind: "continue" };
507
+ async function pollUntilTerminal<V>(args: {
508
+ readonly dependencies: RunDependencies;
509
+ readonly options: T.PollingOptions;
510
+ readonly stamp: VerdictStamp;
511
+ readonly step: () => Promise<StepResult<V>>;
512
+ }): Promise<V | T.BlockerVerdict | T.TimeoutVerdict> {
513
+ let failures = 0;
514
+ const { deadline } = args.dependencies;
515
+ let onDeadline: () => V | T.TimeoutVerdict = () =>
516
+ deadlineVerdict(args.stamp);
517
+ while (deadline.remaining() > 0) {
518
+ let result: StepResult<V>;
519
+ try {
520
+ result = await args.step();
521
+ failures = 0;
522
+ } catch (error) {
523
+ if (error instanceof DeadlineExceeded) break;
524
+ if (!(error instanceof WatcherQueryError)) throw error;
525
+ onDeadline = () =>
526
+ args.stamp({
527
+ kind: "TIMEOUT",
528
+ terminal: true,
529
+ exitCode: 5,
530
+ reason: { kind: "status-unavailable", failure: error.failure },
531
+ });
532
+ failures += 1;
533
+ if (!error.failure.retryable || failures >= args.options.maxQueryErrors)
534
+ return statusQueryVerdict(args.stamp, failures, error.failure);
535
+ const retryInSeconds = Math.min(
536
+ deadline.remaining(),
537
+ queryBackoffSeconds(args.options.interval, failures)
538
+ );
539
+ args.dependencies.emit(
540
+ args.stamp({
541
+ kind: "RETRY",
542
+ terminal: false,
543
+ failure: error.failure,
544
+ consecutiveFailures: failures,
545
+ retryInSeconds,
546
+ })
547
+ );
548
+ await args.dependencies.clock.sleep(retryInSeconds);
549
+ continue;
550
+ }
551
+ if (result.kind === "terminal") return result.verdict;
552
+ if (result.kind === "sleep") {
553
+ onDeadline = result.onDeadline;
554
+ await args.dependencies.clock.sleep(
555
+ Math.min(result.seconds, deadline.remaining())
556
+ );
557
+ }
558
+ }
559
+ return onDeadline();
560
+ }
561
+ export async function runSimple(args: {
562
+ readonly dependencies: RunDependencies;
563
+ readonly contexts: T.NonEmpty<T.PrContext>;
564
+ readonly mode: T.WatchMode;
565
+ readonly statusOnly: boolean;
566
+ readonly options: T.PollingOptions;
567
+ }): Promise<T.TerminalVerdict> {
568
+ const stamp = verdictFactory(args.dependencies.clock, args.mode);
569
+ const confirmNoChecks = noChecksConfirmer(args.dependencies.clock);
570
+ const step = async (): Promise<StepResult<T.TerminalVerdict>> => {
571
+ const rows: T.PrSnapshot[] = [];
572
+ for (const context of args.contexts)
573
+ rows.push(
574
+ await readSnapshot({
575
+ reader: args.dependencies.reader,
576
+ context,
577
+ pendingHistory: "include",
578
+ allowDraft: args.options.allowDraft,
579
+ confirmNoChecks,
580
+ })
581
+ );
582
+ const complete = nonEmpty(rows);
583
+ if (complete === null) throw new Error("watch context cannot be empty");
584
+ if (args.statusOnly)
585
+ return {
586
+ kind: "terminal",
587
+ verdict: stamp({
588
+ kind: "STATUS",
589
+ terminal: true,
590
+ exitCode: 0,
591
+ reason: "status-only",
592
+ rows: complete,
593
+ }),
594
+ };
595
+ if (args.mode === "queued-stack")
596
+ throw new Error("queued-stack requires status-only in the simple runner");
597
+ if (args.mode === "stack")
598
+ args.dependencies.emit(
599
+ stamp(
600
+ { kind: "STATUS", terminal: false, reason: "poll", rows: complete },
601
+ args.mode
602
+ )
603
+ );
604
+ const decision =
605
+ args.mode === "single"
606
+ ? classifyPr(complete[0], args.options.allowDraft)
607
+ : selectTierMajorStackDecision(complete, args.options.allowDraft);
608
+ if (decision.kind === "blocker")
609
+ return {
610
+ kind: "terminal",
611
+ verdict: blockerVerdict(stamp, decision.blocker),
612
+ };
613
+ if (decision.kind === "ready" || decision.kind === "merged")
614
+ return {
615
+ kind: "terminal",
616
+ verdict: stamp(
617
+ {
618
+ kind: "READY",
619
+ terminal: true,
620
+ exitCode: 0,
621
+ scope: { kind: "single", pr: decision.pr },
622
+ },
623
+ args.mode
624
+ ),
625
+ };
626
+ if (decision.kind === "clear")
627
+ return {
628
+ kind: "terminal",
629
+ verdict: stamp(
630
+ {
631
+ kind: "READY",
632
+ terminal: true,
633
+ exitCode: 0,
634
+ scope: { kind: "stack", prs: decision.prs },
635
+ },
636
+ args.mode
637
+ ),
638
+ };
639
+ args.dependencies.emit(
640
+ stamp({
641
+ kind: "WAITING",
642
+ terminal: false,
643
+ frontier: decision.frontier,
644
+ reason: decision.reason,
645
+ })
646
+ );
647
+ return {
648
+ kind: "sleep",
649
+ seconds: args.options.interval,
650
+ onDeadline: () =>
651
+ stamp({
652
+ kind: "TIMEOUT",
653
+ terminal: true,
654
+ exitCode: 5,
655
+ reason: decision.reason,
656
+ }),
657
+ };
658
+ };
659
+ return pollUntilTerminal({
660
+ dependencies: args.dependencies,
661
+ options: args.options,
662
+ stamp,
663
+ step,
664
+ });
665
+ }
666
+ export type QueueWork =
667
+ | {
668
+ readonly kind: "whole-stack-sweep";
669
+ readonly remaining: T.NonEmpty<T.PrContext>;
670
+ }
671
+ | { readonly kind: "frontier-poll"; readonly frontier: T.PrContext };
672
+ export interface QueueState {
673
+ readonly queue: T.NonEmpty<T.PrContext>;
674
+ readonly snapshots: ReadonlyMap<T.PrNumber, T.PrSnapshot>;
675
+ readonly work: QueueWork | null;
676
+ readonly nextSweepAt: number;
677
+ readonly frontier: T.PrContext | null;
678
+ readonly lastWaitKey: string | null;
679
+ }
680
+ export const createQueueState = (
681
+ queue: T.NonEmpty<T.PrContext>,
682
+ now: number
683
+ ): QueueState => ({
684
+ queue,
685
+ snapshots: new Map(),
686
+ work: { kind: "whole-stack-sweep", remaining: queue },
687
+ nextSweepAt: now,
688
+ frontier: null,
689
+ lastWaitKey: null,
690
+ });
691
+ const orderedRows = (state: QueueState): T.PrSnapshot[] =>
692
+ state.queue.flatMap((context) => {
693
+ const row = state.snapshots.get(context.number);
694
+ return row === undefined ? [] : [row];
695
+ });
696
+ const activeRows = (state: QueueState): T.PrSnapshot[] =>
697
+ orderedRows(state).filter((row) => row.kind !== "merged");
698
+ export function planQueue(state: QueueState, now: number): QueueState {
699
+ if (state.work !== null) return state;
700
+ if (state.snapshots.size === 0 || now >= state.nextSweepAt) {
701
+ const remaining = nonEmpty(
702
+ state.queue.filter(
703
+ (context) => state.snapshots.get(context.number)?.kind !== "merged"
704
+ )
705
+ );
706
+ if (remaining !== null)
707
+ return { ...state, work: { kind: "whole-stack-sweep", remaining } };
708
+ }
709
+ const frontier = activeRows(state)[0]?.context;
710
+ return frontier === undefined
711
+ ? state
712
+ : { ...state, work: { kind: "frontier-poll", frontier } };
713
+ }
714
+ export interface QueueSnapshotResult {
715
+ readonly state: QueueState;
716
+ readonly completedSweepRows: T.NonEmpty<T.PrSnapshot> | null;
717
+ }
718
+ export function applyQueueSnapshot(
719
+ state: QueueState,
720
+ snapshot: T.PrSnapshot,
721
+ now: number,
722
+ options: T.PollingOptions
723
+ ): QueueSnapshotResult {
724
+ if (state.work === null) throw new Error("queue has no read in flight");
725
+ const snapshots = new Map(state.snapshots);
726
+ snapshots.set(snapshot.context.number, snapshot);
727
+ const base = { ...state, snapshots };
728
+ if (state.work.kind === "frontier-poll")
729
+ return { state: { ...base, work: null }, completedSweepRows: null };
730
+ const [head, ...tail] = state.work.remaining;
731
+ if (head.number !== snapshot.context.number)
732
+ throw new Error("snapshot does not match sweep head");
733
+ const remaining = nonEmpty(tail);
734
+ if (remaining !== null)
735
+ return {
736
+ state: { ...base, work: { kind: "whole-stack-sweep", remaining } },
737
+ completedSweepRows: null,
738
+ };
739
+ const rows = nonEmpty(
740
+ state.queue.flatMap((context) => {
741
+ const row = snapshots.get(context.number);
742
+ return row === undefined ? [] : [row];
743
+ })
744
+ );
745
+ if (rows === null || rows.length !== state.queue.length)
746
+ throw new Error("sweep completed without every snapshot");
747
+ return {
748
+ state: { ...base, work: null, nextSweepAt: now + options.sweepInterval },
749
+ completedSweepRows: rows,
750
+ };
751
+ }
752
+ export type QueueEvaluation =
753
+ | {
754
+ readonly kind: "complete";
755
+ readonly state: QueueState;
756
+ readonly merged: T.NonEmpty<T.MergedPr>;
757
+ }
758
+ | {
759
+ readonly kind: "blocker";
760
+ readonly state: QueueState;
761
+ readonly blocker: T.MergeBlocker;
762
+ }
763
+ | {
764
+ readonly kind: "advance";
765
+ readonly state: QueueState;
766
+ readonly merged: T.PrContext;
767
+ readonly frontier: T.PrContext;
768
+ readonly remaining: number;
769
+ }
770
+ | {
771
+ readonly kind: "waiting";
772
+ readonly state: QueueState;
773
+ readonly frontier: T.PrContext;
774
+ readonly reason:
775
+ | T.WaitReason
776
+ | { readonly kind: "merge-queue"; readonly unmergedCount: number };
777
+ readonly emit: boolean;
778
+ };
779
+ export function evaluateQueue(
780
+ state: QueueState,
781
+ options: T.PollingOptions
782
+ ): QueueEvaluation {
783
+ const active = activeRows(state);
784
+ if (active.length === 0) {
785
+ const merged = nonEmpty(
786
+ orderedRows(state).flatMap((row) =>
787
+ row.kind === "merged"
788
+ ? [
789
+ {
790
+ kind: "merged-pr" as const,
791
+ context: row.context,
792
+ mergedAt: row.facts.mergedAt,
793
+ },
794
+ ]
795
+ : []
796
+ )
797
+ );
798
+ if (merged === null) throw new Error("empty queue cannot complete");
799
+ return { kind: "complete", state, merged };
800
+ }
801
+ const rows = nonEmpty(active);
802
+ if (rows === null) throw new Error("active queue cannot be empty");
803
+ const decision = selectTierMajorStackDecision(rows, options.allowDraft);
804
+ if (decision.kind === "blocker")
805
+ return { kind: "blocker", state, blocker: decision.blocker };
806
+ const frontier = rows[0].context;
807
+ if (state.frontier !== null && state.frontier.number !== frontier.number)
808
+ return {
809
+ kind: "advance",
810
+ state: { ...state, frontier, lastWaitKey: null },
811
+ merged: state.frontier,
812
+ frontier,
813
+ remaining: active.length,
814
+ };
815
+ const reason = waitReason(rows[0]) ?? {
816
+ kind: "merge-queue" as const,
817
+ unmergedCount: active.length,
818
+ };
819
+ const waitKey =
820
+ reason.kind === "pending-checks"
821
+ ? `pending:${frontier.number}:${reason.pending.length}`
822
+ : reason.kind === "merge-queue"
823
+ ? `queue:${frontier.number}:${reason.unmergedCount}`
824
+ : `${reason.kind}:${frontier.number}`;
825
+ return {
826
+ kind: "waiting",
827
+ state: { ...state, frontier, lastWaitKey: waitKey },
828
+ frontier,
829
+ reason,
830
+ emit: state.lastWaitKey !== waitKey,
831
+ };
832
+ }
833
+ export async function runQueued(args: {
834
+ readonly dependencies: RunDependencies;
835
+ readonly contexts: T.NonEmpty<T.PrContext>;
836
+ readonly options: T.PollingOptions;
837
+ }): Promise<T.QueueTerminalVerdict> {
838
+ let state = createQueueState(args.contexts, args.dependencies.clock.now());
839
+ const stamp = verdictFactory(args.dependencies.clock, "queued-stack");
840
+ const confirmNoChecks = noChecksConfirmer(args.dependencies.clock);
841
+ args.dependencies.emit(
842
+ stamp({ kind: "QUEUE", terminal: false, queue: args.contexts })
843
+ );
844
+ const step = async (): Promise<StepResult<T.QueueTerminalVerdict>> => {
845
+ state = planQueue(state, args.dependencies.clock.now());
846
+ if (state.work === null) {
847
+ const complete = evaluateQueue(state, args.options);
848
+ if (complete.kind !== "complete")
849
+ throw new Error("queue has no work while active");
850
+ return {
851
+ kind: "terminal",
852
+ verdict: stamp({
853
+ kind: "COMPLETE",
854
+ terminal: true,
855
+ exitCode: 0,
856
+ queue: state.queue,
857
+ merged: complete.merged,
858
+ }),
859
+ };
860
+ }
861
+ const context =
862
+ state.work.kind === "whole-stack-sweep"
863
+ ? state.work.remaining[0]
864
+ : state.work.frontier;
865
+ const snapshot = await readSnapshot({
866
+ reader: args.dependencies.reader,
867
+ context,
868
+ pendingHistory: "omit",
869
+ allowDraft: args.options.allowDraft,
870
+ confirmNoChecks,
871
+ });
872
+ const applied = applyQueueSnapshot(
873
+ state,
874
+ snapshot,
875
+ args.dependencies.clock.now(),
876
+ args.options
877
+ );
878
+ state = applied.state;
879
+ if (applied.completedSweepRows !== null)
880
+ args.dependencies.emit(
881
+ stamp({
882
+ kind: "STATUS",
883
+ terminal: false,
884
+ reason: "whole-stack-sweep",
885
+ rows: applied.completedSweepRows,
886
+ })
887
+ );
888
+ if (state.work !== null) return { kind: "continue" };
889
+ const evaluation = evaluateQueue(state, args.options);
890
+ state = evaluation.state;
891
+ switch (evaluation.kind) {
892
+ case "complete":
893
+ return {
894
+ kind: "terminal",
895
+ verdict: stamp({
896
+ kind: "COMPLETE",
897
+ terminal: true,
898
+ exitCode: 0,
899
+ queue: state.queue,
900
+ merged: evaluation.merged,
901
+ }),
902
+ };
903
+ case "blocker":
904
+ return {
905
+ kind: "terminal",
906
+ verdict: blockerVerdict(stamp, evaluation.blocker),
907
+ };
908
+ case "advance":
909
+ args.dependencies.emit(
910
+ stamp({
911
+ kind: "ADVANCE",
912
+ terminal: false,
913
+ merged: evaluation.merged,
914
+ frontier: evaluation.frontier,
915
+ remaining: evaluation.remaining,
916
+ })
917
+ );
918
+ return { kind: "continue" };
919
+ case "waiting":
920
+ if (evaluation.emit)
921
+ args.dependencies.emit(
922
+ stamp({
923
+ kind: "WAITING",
924
+ terminal: false,
925
+ frontier: evaluation.frontier,
926
+ reason: evaluation.reason,
927
+ })
928
+ );
929
+ return {
930
+ kind: "sleep",
931
+ seconds: args.options.interval,
932
+ onDeadline: () =>
933
+ stamp({
934
+ kind: "TIMEOUT",
935
+ terminal: true,
936
+ exitCode: 5,
937
+ reason: {
938
+ kind: "queued-stack",
939
+ frontier: evaluation.frontier,
940
+ unmergedCount: activeRows(state).length,
941
+ },
942
+ }),
943
+ };
944
+ default: {
945
+ const exhaustive: never = evaluation;
946
+ return exhaustive;
947
+ }
948
+ }
949
+ };
950
+ return pollUntilTerminal({
951
+ dependencies: args.dependencies,
952
+ options: args.options,
953
+ stamp,
954
+ step,
955
+ });
956
+ }