@roomi-fields/grillhouse 0.29.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +769 -0
  3. package/agents/developpeur.md +0 -1
  4. package/agents/explorateur.md +0 -1
  5. package/agents/questionneur.md +0 -1
  6. package/agents/testwriter.md +0 -1
  7. package/bin/grillhouse.mjs +79 -18
  8. package/cadre/templates/projet/.github/workflows/ci.yml +2 -13
  9. package/cadre/templates/projet/CLAUDE.md +5 -1
  10. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  11. package/cadre/templates/projet/package.json +2 -2
  12. package/charte.md +24 -0
  13. package/dist/temporal/acte.d.ts +24 -0
  14. package/dist/temporal/acte.js +139 -0
  15. package/dist/temporal/acte.js.map +1 -0
  16. package/dist/temporal/attributs.d.ts +6 -0
  17. package/dist/temporal/attributs.js +15 -0
  18. package/dist/temporal/attributs.js.map +1 -0
  19. package/dist/temporal/circuit/activites.d.ts +13 -0
  20. package/dist/temporal/circuit/activites.js +33 -0
  21. package/dist/temporal/circuit/activites.js.map +1 -0
  22. package/dist/temporal/circuit/client.d.ts +72 -0
  23. package/dist/temporal/circuit/client.js +247 -0
  24. package/dist/temporal/circuit/client.js.map +1 -0
  25. package/dist/temporal/circuit/commande.d.ts +2 -0
  26. package/dist/temporal/circuit/commande.js +238 -0
  27. package/dist/temporal/circuit/commande.js.map +1 -0
  28. package/dist/temporal/circuit/contrat.d.ts +305 -0
  29. package/dist/temporal/circuit/contrat.js +30 -0
  30. package/dist/temporal/circuit/contrat.js.map +1 -0
  31. package/dist/temporal/circuit/deroule.d.ts +3 -0
  32. package/dist/temporal/circuit/deroule.js +540 -0
  33. package/dist/temporal/circuit/deroule.js.map +1 -0
  34. package/dist/temporal/client.d.ts +47 -0
  35. package/dist/temporal/client.js +69 -0
  36. package/dist/temporal/client.js.map +1 -0
  37. package/dist/temporal/commande.d.ts +2 -0
  38. package/dist/temporal/commande.js +94 -0
  39. package/dist/temporal/commande.js.map +1 -0
  40. package/dist/temporal/deroules.d.ts +5 -0
  41. package/dist/temporal/deroules.js +10 -0
  42. package/dist/temporal/deroules.js.map +1 -0
  43. package/dist/temporal/etat.d.ts +33 -0
  44. package/dist/temporal/etat.js +59 -0
  45. package/dist/temporal/etat.js.map +1 -0
  46. package/dist/temporal/file/activites.d.ts +10 -0
  47. package/dist/temporal/file/activites.js +25 -0
  48. package/dist/temporal/file/activites.js.map +1 -0
  49. package/dist/temporal/file/client.d.ts +4 -0
  50. package/dist/temporal/file/client.js +6 -0
  51. package/dist/temporal/file/client.js.map +1 -0
  52. package/dist/temporal/file/contrat.d.ts +158 -0
  53. package/dist/temporal/file/contrat.js +14 -0
  54. package/dist/temporal/file/contrat.js.map +1 -0
  55. package/dist/temporal/file/deroule.d.ts +15 -0
  56. package/dist/temporal/file/deroule.js +235 -0
  57. package/dist/temporal/file/deroule.js.map +1 -0
  58. package/dist/temporal/installation.d.ts +120 -0
  59. package/dist/temporal/installation.js +386 -0
  60. package/dist/temporal/installation.js.map +1 -0
  61. package/dist/temporal/places/activites.d.ts +8 -0
  62. package/dist/temporal/places/activites.js +13 -0
  63. package/dist/temporal/places/activites.js.map +1 -0
  64. package/dist/temporal/places/client.d.ts +28 -0
  65. package/dist/temporal/places/client.js +64 -0
  66. package/dist/temporal/places/client.js.map +1 -0
  67. package/dist/temporal/places/contrat.d.ts +106 -0
  68. package/dist/temporal/places/contrat.js +21 -0
  69. package/dist/temporal/places/contrat.js.map +1 -0
  70. package/dist/temporal/places/deroule.d.ts +3 -0
  71. package/dist/temporal/places/deroule.js +198 -0
  72. package/dist/temporal/places/deroule.js.map +1 -0
  73. package/dist/temporal/sonde/activites.d.ts +6 -0
  74. package/dist/temporal/sonde/activites.js +52 -0
  75. package/dist/temporal/sonde/activites.js.map +1 -0
  76. package/dist/temporal/sonde/contrat.d.ts +35 -0
  77. package/dist/temporal/sonde/contrat.js +10 -0
  78. package/dist/temporal/sonde/contrat.js.map +1 -0
  79. package/dist/temporal/sonde/deroule.d.ts +3 -0
  80. package/dist/temporal/sonde/deroule.js +39 -0
  81. package/dist/temporal/sonde/deroule.js.map +1 -0
  82. package/dist/temporal/tickets/activites.d.ts +7 -0
  83. package/dist/temporal/tickets/activites.js +81 -0
  84. package/dist/temporal/tickets/activites.js.map +1 -0
  85. package/dist/temporal/tickets/client.d.ts +10 -0
  86. package/dist/temporal/tickets/client.js +31 -0
  87. package/dist/temporal/tickets/client.js.map +1 -0
  88. package/dist/temporal/tickets/contrat.d.ts +56 -0
  89. package/dist/temporal/tickets/contrat.js +13 -0
  90. package/dist/temporal/tickets/contrat.js.map +1 -0
  91. package/dist/temporal/tickets/deroule.d.ts +3 -0
  92. package/dist/temporal/tickets/deroule.js +94 -0
  93. package/dist/temporal/tickets/deroule.js.map +1 -0
  94. package/dist/temporal/travailleur.d.ts +2 -0
  95. package/dist/temporal/travailleur.js +69 -0
  96. package/dist/temporal/travailleur.js.map +1 -0
  97. package/docs/ARCHITECTURE.md +646 -87
  98. package/docs/CADRE.md +27 -0
  99. package/docs/INTERFACE.md +139 -42
  100. package/hooks/crochet.mjs +19 -2
  101. package/hooks/hooks.json +11 -0
  102. package/package.json +16 -4
  103. package/scripts/activites.mjs +2255 -0
  104. package/scripts/aiguillage.d.mts +37 -0
  105. package/scripts/aiguillage.mjs +40 -14
  106. package/scripts/avancement.mjs +155 -26
  107. package/scripts/bilan.mjs +137 -43
  108. package/scripts/cadre.mjs +16 -4
  109. package/scripts/circuit.mjs +993 -4075
  110. package/scripts/circuits-cles.d.mts +4 -0
  111. package/scripts/circuits-cles.mjs +21 -0
  112. package/scripts/circuits-du-serveur.mjs +105 -0
  113. package/scripts/codes-de-sortie.mjs +9 -0
  114. package/scripts/commandes-composees.mjs +45 -41
  115. package/scripts/commandes-du-path.d.mts +7 -0
  116. package/scripts/commandes-du-path.mjs +25 -0
  117. package/scripts/composants-affectes.mjs +64 -21
  118. package/scripts/composition-des-langages.mjs +18 -12
  119. package/scripts/conformite.mjs +56 -28
  120. package/scripts/copies-finies.mjs +52 -47
  121. package/scripts/depart-du-ticket.d.mts +53 -0
  122. package/scripts/depart-du-ticket.mjs +124 -0
  123. package/scripts/dependances-internes.mjs +121 -0
  124. package/scripts/dernier-vert.mjs +61 -34
  125. package/scripts/dette.mjs +32 -11
  126. package/scripts/donnees-cles.mjs +244 -0
  127. package/scripts/droits.mjs +51 -16
  128. package/scripts/effets.mjs +352 -0
  129. package/scripts/empreinte-d-etape.mjs +17 -0
  130. package/scripts/engendres.mjs +15 -5
  131. package/scripts/enveloppe/enveloppe.mjs +259 -55
  132. package/scripts/enveloppe/lancer.sh +14 -18
  133. package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
  134. package/scripts/enveloppe/travail-de-la-copie.mjs +41 -13
  135. package/scripts/etapes.mjs +5 -2
  136. package/scripts/faits-du-circuit.mjs +493 -0
  137. package/scripts/file-des-tickets.d.mts +21 -0
  138. package/scripts/file-des-tickets.mjs +58 -0
  139. package/scripts/flux-des-paquets.mjs +201 -0
  140. package/scripts/gardes-du-cadre.mjs +21 -5
  141. package/scripts/init.mjs +11 -4
  142. package/scripts/integration/file.mjs +544 -434
  143. package/scripts/integration/integrer.mjs +87 -43
  144. package/scripts/integration/rejeu.mjs +45 -13
  145. package/scripts/jointure.d.ts +151 -28
  146. package/scripts/langages/cargo/commandes.mjs +383 -124
  147. package/scripts/langages/cargo/composants.mjs +154 -42
  148. package/scripts/langages/cargo/exemples.mjs +12 -21
  149. package/scripts/langages/cargo/index.mjs +22 -8
  150. package/scripts/langages/cargo/sccache.mjs +8 -14
  151. package/scripts/langages/cargo/tests-de-head.mjs +25 -9
  152. package/scripts/langages/python/commandes.mjs +218 -100
  153. package/scripts/langages/python/composants.mjs +53 -21
  154. package/scripts/langages/python/exemples.mjs +6 -16
  155. package/scripts/langages/python/index.mjs +28 -8
  156. package/scripts/langages/python/lot.mjs +1 -36
  157. package/scripts/langages/typescript/chemins-des-tests.mjs +6 -2
  158. package/scripts/langages/typescript/composants.mjs +9 -3
  159. package/scripts/langages/typescript/consommateurs-arbitres.mjs +40 -14
  160. package/scripts/langages/typescript/consommateurs.mjs +39 -14
  161. package/scripts/langages/typescript/construire.mjs +6 -163
  162. package/scripts/langages/typescript/elements-du-lot.mjs +36 -12
  163. package/scripts/langages/typescript/exemples.mjs +3 -11
  164. package/scripts/langages/typescript/frontieres.mjs +66 -22
  165. package/scripts/langages/typescript/index-interfaces.mjs +36 -13
  166. package/scripts/langages/typescript/index.mjs +50 -61
  167. package/scripts/langages/typescript/interfaces-contre-code.mjs +113 -45
  168. package/scripts/langages/typescript/lecteurs.mjs +36 -11
  169. package/scripts/langages/typescript/migrations/0.23.0-config-vitest.mjs +15 -5
  170. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +6 -2
  171. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +6 -2
  172. package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
  173. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +33 -0
  174. package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
  175. package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
  176. package/scripts/langages/typescript/parcours.mjs +12 -4
  177. package/scripts/langages/typescript/regle-des-tests.mjs +9 -3
  178. package/scripts/langages/typescript/resumes.mjs +9 -3
  179. package/scripts/langages/typescript/tailles-des-tests.mjs +93 -20
  180. package/scripts/langages/typescript/tests-de-nuit.mjs +15 -10
  181. package/scripts/langages/typescript/tests.mjs +40 -15
  182. package/scripts/langages/typescript/titres-de-tests.mjs +320 -0
  183. package/scripts/langages/typescript/turbo-des-paquets.mjs +327 -81
  184. package/scripts/langages/typescript/verdict.mjs +4 -2
  185. package/scripts/langages/typescript/verifier.mjs +58 -20
  186. package/scripts/langages/typescript/vitest-config/avancement.reporter.mjs +15 -5
  187. package/scripts/langages/typescript/vitest-config/base.mjs +29 -3
  188. package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
  189. package/scripts/langages/typescript/vitest-config/changements.mjs +21 -8
  190. package/scripts/langages/typescript/vitest-config/cibles.mjs +36 -14
  191. package/scripts/langages/typescript/vitest-config/delais.mjs +60 -0
  192. package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
  193. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +108 -0
  194. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +56 -59
  195. package/scripts/langages/typescript/vitest-config/lances.mjs +83 -27
  196. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +10 -0
  197. package/scripts/langages/typescript/vitest-config/resultats.mjs +3 -1
  198. package/scripts/langages/typescript/vitest.nuit.config.mjs +4 -0
  199. package/scripts/lint-des-scripts.mjs +58 -0
  200. package/scripts/mesure/base-de-passe.mjs +117 -25
  201. package/scripts/mesure/pression.mjs +12 -6
  202. package/scripts/mesure-de-la-machine.d.mts +21 -0
  203. package/scripts/mesure-de-la-machine.mjs +76 -0
  204. package/scripts/migrations/0.23.0-charte-importee.mjs +6 -2
  205. package/scripts/migrations/0.23.0-crochets-de-seance.mjs +25 -8
  206. package/scripts/migrations/0.23.0-marche-du-projet.mjs +18 -6
  207. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +56 -18
  208. package/scripts/migrations/0.24.12-tri-des-decouvertes.mjs +6 -2
  209. package/scripts/migrations/0.25.0-script-des-tests.mjs +15 -5
  210. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +124 -0
  211. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
  212. package/scripts/migrations.mjs +5 -0
  213. package/scripts/nuit.sh +25 -3
  214. package/scripts/outil.mjs +3 -1
  215. package/scripts/outils-cles.d.mts +24 -0
  216. package/scripts/outils-cles.mjs +18 -8
  217. package/scripts/paquet-npm.mjs +157 -0
  218. package/scripts/paquet.mjs +73 -4
  219. package/scripts/paquets.mjs +46 -10
  220. package/scripts/passe-de-la-machine.mjs +71 -0
  221. package/scripts/places-de-la-machine.mjs +414 -0
  222. package/scripts/places-du-serveur.mjs +170 -0
  223. package/scripts/prefixe-des-tickets.mjs +68 -0
  224. package/scripts/preparation.mjs +25 -8
  225. package/scripts/registre.mjs +9 -4
  226. package/scripts/regles-des-places.d.mts +36 -0
  227. package/scripts/regles-des-places.mjs +70 -0
  228. package/scripts/reponses-du-circuit.d.mts +6 -0
  229. package/scripts/reponses-du-circuit.mjs +28 -0
  230. package/scripts/reprise.mjs +66 -0
  231. package/scripts/resultats.mjs +112 -46
  232. package/scripts/retirer-les-copies-finies.mjs +25 -0
  233. package/scripts/sans-reponse.d.mts +4 -0
  234. package/scripts/sans-reponse.mjs +13 -0
  235. package/scripts/seances.mjs +936 -0
  236. package/scripts/services-du-noyau.mjs +27 -8
  237. package/scripts/session-start.sh +2 -2
  238. package/scripts/sortie.mjs +3 -3
  239. package/scripts/sous-commandes.mjs +41 -10
  240. package/scripts/style-a-l-ecriture.mjs +260 -0
  241. package/scripts/superviseur.mjs +122 -111
  242. package/scripts/tableau.mjs +180 -117
  243. package/scripts/taches-du-graphe.mjs +348 -0
  244. package/scripts/ticket-du-circuit.mjs +216 -0
  245. package/scripts/transitions.d.mts +148 -0
  246. package/scripts/transitions.mjs +1018 -0
  247. package/scripts/verrou-de-fichier.mjs +8 -4
  248. package/scripts/verrou-de-machine.mjs +150 -51
  249. package/scripts/verrous/commande.mjs +50 -17
  250. package/scripts/verrous/ticket-du-sous-agent.mjs +9 -3
  251. package/scripts/verrous/verrou.mjs +42 -14
  252. package/skills/explorateur/SKILL.md +9 -2
  253. package/skills/grill/SKILL.md +1 -1
  254. package/skills/mesure/SKILL.md +3 -0
  255. package/skills/pitmaster/SKILL.md +17 -18
  256. package/skills/pitmaster/references/consigne-agent.md +5 -1
  257. package/skills/release/SKILL.md +3 -3
  258. package/skills/relecteur/SKILL.md +5 -3
  259. package/skills/testwriter/SKILL.md +49 -31
  260. package/scripts/demon.mjs +0 -251
  261. package/scripts/integration/file-attente.mjs +0 -61
  262. package/scripts/langages/cargo/touches.mjs +0 -93
  263. package/scripts/langages/typescript/script-des-tests.mjs +0 -6
@@ -21,14 +21,17 @@
21
21
  // - The session whose opening takes the lock (not one that keeps it) receives
22
22
  // (`circuitsALOuverture`) the section « ## L'attente des questions », which asks it to launch the
23
23
  // wait of the questions in the background (`--attendre`, below) without waiting for the owner's
24
- // word, then, when the repository has some (read by scripts/tableau.mjs `lireCircuits`), « ## Les
25
- // circuits du dépôt »: each circuit that runs, named; each circuit stopped on a question, with
26
- // its question and the command that answers it; each circuit dead without a final state, with
27
- // the command that resumes it (`--reprendre`), which the supervisor launches without waiting for
28
- // the owner's word; their ticket open, and the stopped and the dead ones then gone up. A circuit
29
- // runs detached from the sessions (scripts/demon.mjs), its launch returns at once, and its
24
+ // word, then, when the repository has some (read from the Temporal server in one call,
25
+ // scripts/circuits-du-serveur.mjs), « ## Les circuits du dépôt »: each circuit that runs, named;
26
+ // each circuit stopped on a question, with its question and the command that answers it; each
27
+ // circuit ended without its issue, with the command that resumes it (`--reprendre` from its last
28
+ // state written, else `--depuis <testwriter|developpeur> --contexte <texte>`), which the
29
+ // supervisor launches without waiting for the owner's word; their ticket open, and the stopped
30
+ // and the ended ones then gone up; a server that does not answer is said. A circuit
31
+ // runs on the worker of the project, apart from the sessions, its launch returns at once, and its
30
32
  // question wakes the supervisor by the wait alone (grillhouse-mwz: SyntHub's SH-br0.1 stopped
31
- // 27 s after a relaunch of its session, read only on a word of the owner).
33
+ // 27 s after a relaunch of its session, read only on a word of the owner). The queue of the
34
+ // tickets under Temporal (src/temporal/tickets/) launches the tickets `circuit`, not the opening.
32
35
  // Exit 0, whatever it finds.
33
36
  //
34
37
  // npx grillhouse superviseur --attendre [<dossier>]
@@ -42,16 +45,19 @@
42
45
  // the end of its task wakes the session, which spends nothing while it waits (grillhouse-pq6:
43
46
  // SyntHub's SH-ae6.5.2, SH-ae6.5.6 and SH-br0.1.5, launched by a queue, waited hours on their
44
47
  // question). The stops gone up, by a wait or named at the opening, are kept in
45
- // `.claude/worktrees/questions-remontees.json`, each one by its ticket, the run of its circuit
46
- // and its stop: one never wakes the session twice, and one answered leaves them. Exit 0 on its
48
+ // `.claude/worktrees/questions-remontees.json`, each one by its ticket, the run of its workflow,
49
+ // the rank of its question in that run and its stop: one never wakes the session twice, a
50
+ // session closed then opened again finds every one that waits, and one answered leaves them.
51
+ // Exit 0 on its
47
52
  // questions, 1 when another wait already runs (`.claude/worktrees/attente-des-questions.lock`).
48
53
  import { spawnSync } from 'node:child_process';
49
- import { mkdirSync, readFileSync, renameSync, statSync, watch, writeFileSync } from 'node:fs';
54
+ import { mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
50
55
  import path from 'node:path';
51
56
  import { pathToFileURL } from 'node:url';
52
57
  import { lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
53
58
  import { vivant } from './mesure/base-de-passe.mjs';
54
- import { attendLeSuperviseur, lireCircuits } from './tableau.mjs';
59
+ import { circuitsDuServeur, ServeurMuet } from './circuits-du-serveur.mjs';
60
+ import { attendLeSuperviseur } from './tableau.mjs';
55
61
  import { etapeDuCircuit, libelle, SUPERVISEUR } from './etapes.mjs';
56
62
 
57
63
  const VERROU_SUPERVISEUR = 'grillhouse-superviseur.lock';
@@ -106,10 +112,10 @@ function ticketsFermes(racine, ids) {
106
112
  }
107
113
  }
108
114
 
109
- // One stop of the circuit <c>: its ticket, the run that wrote it (`processus`, `depart`) and its
110
- // stop, so that the next stop of a circuit resumed is another one.
111
- const cleDe = c =>
112
- [c.ticket, c.processus ?? '?', c.depart ?? '?', c.arret ?? 'interrompu'].join(':');
115
+ // One stop of the circuit <c>: its ticket, the run of its workflow (`run`), the rank of its
116
+ // question in that run (`numero`) and its stop, so that the next stop of a circuit resumed is
117
+ // another one.
118
+ const cleDe = c => [c.ticket, c.run, c.numero, c.arret ?? 'interrompu'].join(':');
113
119
 
114
120
  // The step where the circuit <c> stands, in words (« 3.1 Contrôles »), else its state's.
115
121
  const ou = c => {
@@ -133,26 +139,21 @@ function lireRemontees(racine) {
133
139
  }
134
140
  }
135
141
 
136
- // The stops gone up of the repository at <racine>, under the lock of their file: <faire>(<avant>,
137
- // those gone up before) returns the keys it makes go up (`cles`) and what it gives (`rendu`); the
138
- // file is written whole with them and those of <avant> whose stop still stands, its circuit waiting
139
- // for the supervisor, or alive and stopped, a question its caller read on its output
140
- // (`inscrireLaQuestionLue`) until its process ends. A question answered so leaves them. Its
142
+ // The stops gone up of the repository at <racine>, its circuits <circuits> read, under the lock
143
+ // of their file: <faire>(<avant>, those gone up before) returns the keys it makes go up (`cles`)
144
+ // and what it gives (`rendu`); the file is written whole with them and those of <avant> whose stop
145
+ // still stands, its circuit waiting for the supervisor. A question answered so leaves them. Its
141
146
  // `rendu`.
142
- function remonter(racine, faire) {
147
+ function remonter(racine, circuits, faire) {
143
148
  const f = remonteesDe(racine);
144
149
  mkdirSync(path.dirname(f), { recursive: true });
145
150
  const verrou = `${f}.verrou`;
146
- // Held for one reading of the states: older than that, abandoned.
151
+ // Held for one reading of the circuits: older than that, abandoned.
147
152
  prendreVerrou(verrou, { attendre: true, perime: 30_000 });
148
153
  try {
149
154
  const avant = lireRemontees(racine);
150
155
  const { cles, rendu } = faire(avant);
151
- const debout = new Set(
152
- lireCircuits({ racine })
153
- .filter(c => attendLeSuperviseur(c) || (c.vivant && c.arret))
154
- .map(cleDe)
155
- );
156
+ const debout = new Set(circuits.filter(attendLeSuperviseur).map(cleDe));
156
157
  const apres = new Set([...cles, ...[...avant].filter(c => debout.has(c))]);
157
158
  if (avant.size !== apres.size || [...apres].some(c => !avant.has(c))) {
158
159
  const provisoire = `${f}.${process.pid}`;
@@ -165,18 +166,6 @@ function remonter(racine, faire) {
165
166
  }
166
167
  }
167
168
 
168
- /**
169
- * Inscribes as gone up the question of the circuit of <ticket>, its run (`processus`, `depart`)
170
- * stopped on <arret>, that its caller read on its output (grillhouse-pq6.1: a launch in the
171
- * foreground that stops before any session, scripts/circuit.mjs `monter`): the wait of the
172
- * questions does not wake on it, by the one source of the stops gone up.
173
- * @param {string} racine
174
- * @param {{ ticket: string, processus: number, depart: string, arret: string }} arret
175
- */
176
- export function inscrireLaQuestionLue(racine, arret) {
177
- remonter(racine, () => ({ cles: [cleDe(arret)] }));
178
- }
179
-
180
169
  // The question that waits for the supervisor from the circuit <c>: its ticket, its step, its
181
170
  // question, who must answer it, the command that answers it, and its stop's key.
182
171
  const enQuestion = c => ({
@@ -186,9 +175,8 @@ const enQuestion = c => ({
186
175
  c.question ??
187
176
  `arrêt ${c.arret}${c.code === null ? '' : ` (code ${c.code})`}${c.raison ? ` : ${c.raison}` : ''}`,
188
177
  qui: c.qui ?? SUPERVISEUR,
189
- commande: c.interrompu
190
- ? `npx grillhouse circuit ${c.ticket} --reprendre`
191
- : `npx grillhouse circuit ${c.ticket} --reprendre\`, \`--depuis <testwriter|developpeur>\`, \`--etendre <paquet>\` ou \`--arreter`,
178
+ // The answers the client accepts, as it gives them (src/temporal/circuit/client.ts).
179
+ commande: c.reponse,
192
180
  cle: cleDe(c),
193
181
  interrompu: c.interrompu,
194
182
  arret: c.arret,
@@ -209,21 +197,26 @@ function enAttente(lus, racine, fermes) {
209
197
  }
210
198
 
211
199
  /**
212
- * The questions that wait for the supervisor in the repository at <racine>, the one source of the
213
- * opening (`circuitsALOuverture`) and of the wait (`attendreUneQuestion`), by the rule the board's
214
- * « ⤷ Question » reads too (scripts/tableau.mjs `attendLeSuperviseur`, beside `lireCircuits`, which
215
- * this module imports): each circuit whose process is gone, stopped (any stop but the
216
- * supervisor's own « arrete », « à repasser » included) or dead without a final state,
217
- * those whose stop's key <sauf> holds left out, then those whose ticket <fermes> gives closed
218
- * (bd is asked of the others alone), sorted by ticket. Each one says whether its circuit died
219
- * without a final state (`interrompu`) and its stop (`arret`).
200
+ * The questions that wait for the supervisor among the circuits <circuits> of the repository at
201
+ * <racine> (scripts/circuits-du-serveur.mjs), the one source of the opening
202
+ * (`circuitsALOuverture`) and of the wait (`attendreUneQuestion`), by the rule the board's
203
+ * « ⤷ Question » reads too (scripts/tableau.mjs `attendLeSuperviseur`): each circuit stopped on a
204
+ * question (any stop but the supervisor's own « arrete », « à repasser » included) or ended
205
+ * without its issue, those whose stop's key <sauf> holds left out, then those whose ticket
206
+ * <fermes> gives closed (bd is asked of the others alone), sorted by ticket. Each one says whether
207
+ * its circuit ended without its issue (`interrompu`) and its stop (`arret`).
220
208
  * @param {string} racine the root of the repository
209
+ * @param {import('./circuits-du-serveur.mjs').CircuitDuServeur[]} circuits
221
210
  * @param {{ fermes?: (racine: string, ids: string[]) => Set<string>, sauf?: Set<string> }} options
222
211
  * @returns {{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string, interrompu: boolean, arret: string | null }[]}
223
212
  */
224
- export function questionsEnAttente(racine, { fermes = ticketsFermes, sauf = new Set() } = {}) {
213
+ export function questionsEnAttente(
214
+ racine,
215
+ circuits,
216
+ { fermes = ticketsFermes, sauf = new Set() } = {}
217
+ ) {
225
218
  return enAttente(
226
- lireCircuits({ racine }).filter(c => attendLeSuperviseur(c) && !sauf.has(cleDe(c))),
219
+ circuits.filter(c => attendLeSuperviseur(c) && !sauf.has(cleDe(c))),
227
220
  racine,
228
221
  fermes
229
222
  ).map(enQuestion);
@@ -232,13 +225,14 @@ export function questionsEnAttente(racine, { fermes = ticketsFermes, sauf = new
232
225
  // No ticket closed: the questions read without asking bd.
233
226
  const aucunFerme = () => new Set();
234
227
 
235
- // The questions of the repository at <racine> that never went up (`questionsEnAttente`): returned,
236
- // and now gone up; a question answered (its circuit runs again, or ended) leaves those gone up, and
237
- // one whose ticket <fermes> gives closed goes up without a word. bd is asked of the new ones alone.
238
- function releverLesNeuves(racine, fermes) {
239
- return remonter(racine, avant => ({
240
- cles: questionsEnAttente(racine, { fermes: aucunFerme }).map(q => q.cle),
241
- rendu: questionsEnAttente(racine, { fermes, sauf: avant }),
228
+ // The questions of the repository at <racine>, its circuits <circuits> read, that never went up
229
+ // (`questionsEnAttente`): returned, and now gone up; a question answered (its circuit runs again,
230
+ // or ended) leaves those gone up, and one whose ticket <fermes> gives closed goes up without a
231
+ // word. bd is asked of the new ones alone.
232
+ function releverLesNeuves(racine, circuits, fermes) {
233
+ return remonter(racine, circuits, avant => ({
234
+ cles: questionsEnAttente(racine, circuits, { fermes: aucunFerme }).map(q => q.cle),
235
+ rendu: questionsEnAttente(racine, circuits, { fermes, sauf: avant }),
242
236
  }));
243
237
  }
244
238
 
@@ -248,24 +242,24 @@ function releverLesNeuves(racine, fermes) {
248
242
  * GitHub or Gerrit's attention set calls the one a change waits for): it ends only when a question
249
243
  * that never went up waits for the supervisor (`questionsEnAttente`), whatever launched its
250
244
  * circuit, and gives those questions, now gone up; a question already gone up (by a wait, or named
251
- * at the opening) never ends it again, and a question answered leaves those gone up. It watches
252
- * the directory of the states of the circuits (fs.watch, inotify on Linux), and reads them again
253
- * every <pas> ms for a circuit killed, the one end that leaves no mark (a circuit marks its exit,
254
- * its state touched, scripts/circuit.mjs); the session spends
255
- * nothing while it waits. One wait at a time per repository: a second one is refused while the
256
- * first runs. Its <signal> ends it with no question.
257
- * @param {{ racine: string, fermes?: (racine: string, ids: string[]) => Set<string>, pas?: number, signal?: AbortSignal }} options
245
+ * at the opening) never ends it again, a question answered leaves those gone up, and the normal end
246
+ * of a circuit is never one. It reads the circuits every <pas> ms by <circuitsDe> (one call to the
247
+ * Temporal server, scripts/circuits-du-serveur.mjs, by default), as the UI of Temporal refreshes
248
+ * its list; a reading that fails (the server down) is tried again at the next step, the questions
249
+ * gone up kept. The session spends nothing while it waits. One wait at a time per repository: a
250
+ * second one is refused while the first runs. Its <signal> ends it with no question.
251
+ * @param {{ racine: string, fermes?: (racine: string, ids: string[]) => Set<string>, pas?: number, signal?: AbortSignal, circuitsDe?: (racine: string) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]> }} options
258
252
  * @returns {Promise<{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string }[]>}
259
253
  * @throws {Error} another wait runs
260
254
  */
261
255
  export async function attendreUneQuestion({
262
256
  racine,
263
257
  fermes = ticketsFermes,
264
- pas = 30_000,
258
+ pas = 5_000,
265
259
  signal,
260
+ circuitsDe = circuitsDuServeur,
266
261
  }) {
267
- const dossier = etatsDe(racine);
268
- mkdirSync(dossier, { recursive: true });
262
+ mkdirSync(etatsDe(racine), { recursive: true });
269
263
  const verrou = verrouDeLAttente(racine);
270
264
  if (!prendreVerrou(verrou, { attendre: false })) {
271
265
  let qui = '';
@@ -279,42 +273,38 @@ export async function attendreUneQuestion({
279
273
  );
280
274
  }
281
275
  try {
282
- return await new Promise(resolve => {
283
- if (signal?.aborted) {
284
- resolve([]);
285
- return;
276
+ while (!signal?.aborted) {
277
+ let circuits = null;
278
+ try {
279
+ circuits = await circuitsDe(racine);
280
+ } catch {
281
+ circuits = null;
286
282
  }
287
- let fini = false;
288
- let differe;
289
- const voir = () => {
290
- if (fini) {
291
- return;
292
- }
293
- const neuves = releverLesNeuves(racine, fermes);
283
+ if (circuits && !signal?.aborted) {
284
+ const neuves = releverLesNeuves(racine, circuits, fermes);
294
285
  if (neuves.length) {
295
- finir(neuves);
286
+ return neuves;
296
287
  }
297
- };
298
- const surveillance = watch(dossier, () => {
299
- clearTimeout(differe);
300
- differe = setTimeout(voir, 250);
301
- });
302
- const minuteur = setInterval(voir, pas);
303
- const finir = q => {
304
- fini = true;
305
- surveillance.close();
306
- clearTimeout(differe);
307
- clearInterval(minuteur);
308
- resolve(q);
309
- };
310
- signal?.addEventListener('abort', () => finir([]), { once: true });
311
- voir();
312
- });
288
+ }
289
+ await attendre(pas, signal);
290
+ }
291
+ return [];
313
292
  } finally {
314
293
  lacherVerrou(verrou);
315
294
  }
316
295
  }
317
296
 
297
+ // Waits <ms> ms, or until <signal> ends the wait.
298
+ const attendre = (ms, signal) =>
299
+ new Promise(resolve => {
300
+ const fin = () => {
301
+ clearTimeout(minuteur);
302
+ resolve();
303
+ };
304
+ const minuteur = setTimeout(fin, ms);
305
+ signal?.addEventListener('abort', fin, { once: true });
306
+ });
307
+
318
308
  /**
319
309
  * The text that wakes the session of supervision on the questions <questions>: for each one, its
320
310
  * ticket, step, who must answer it, its question and the command that answers it; then the wait to
@@ -341,26 +331,46 @@ export function texteDesQuestions(questions) {
341
331
  * the one way a question of a circuit wakes the session; then the circuits of the repository,
342
332
  * those whose ticket <fermes> gives closed left out: each one that runs, named; each one stopped on
343
333
  * a question (a stop other than the supervisor's own « arrete »), with its question and the command
344
- * that answers it; each one dead without a final state, with the command that resumes it. The
345
- * stopped and the dead ones are then gone up: the wait does not give them again.
334
+ * that answers it; each one ended without its issue, with the command that resumes it. The
335
+ * stopped and the ended ones are then gone up: the wait does not give them again.
346
336
  * @param {string} racine the root of the repository
347
- * @param {{ fermes?: (racine: string, ids: string[]) => Set<string> }} options
348
- * @returns {string}
337
+ * The circuits are read once, by <circuitsDe> (one call to the Temporal server,
338
+ * scripts/circuits-du-serveur.mjs, by default); a server that does not answer is said, and no
339
+ * question goes up.
340
+ * @param {{ fermes?: (racine: string, ids: string[]) => Set<string>,
341
+ * circuitsDe?: (racine: string) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]> }} options
342
+ * @returns {Promise<string>}
349
343
  */
350
- export function circuitsALOuverture(racine, { fermes = ticketsFermes } = {}) {
351
- const questions = remonter(racine, () => {
352
- const q = questionsEnAttente(racine, { fermes });
353
- return { cles: q.map(x => x.cle), rendu: q };
354
- });
344
+ export async function circuitsALOuverture(
345
+ racine,
346
+ { fermes = ticketsFermes, circuitsDe = circuitsDuServeur } = {}
347
+ ) {
348
+ let circuits = null;
349
+ let panne = null;
350
+ try {
351
+ circuits = await circuitsDe(racine);
352
+ } catch (e) {
353
+ const message = String(e?.message ?? e).split('\n')[0];
354
+ panne =
355
+ e instanceof ServeurMuet
356
+ ? `${e.message} : les circuits ne se lisent pas.`
357
+ : `Les circuits ne se lisent pas : ${message}.`;
358
+ }
359
+ const questions = circuits
360
+ ? remonter(racine, circuits, () => {
361
+ const q = questionsEnAttente(racine, circuits, { fermes });
362
+ return { cles: q.map(x => x.cle), rendu: q };
363
+ })
364
+ : [];
355
365
  const tournent = enAttente(
356
- lireCircuits({ racine }).filter(c => c.vivant),
366
+ (circuits ?? []).filter(c => c.vivant),
357
367
  racine,
358
368
  fermes
359
369
  ).map(c => ({ ticket: c.ticket, ligne: `- ${c.ticket} tourne, à ${ou(c)}.` }));
360
370
  const enLigne = q => ({
361
371
  ticket: q.ticket,
362
372
  ligne: q.interrompu
363
- ? `- ${q.ticket} est mort sans état final (son processus parti, aucun arrêt écrit), à ${q.etape} : relance-le sans attendre le mot du responsable, \`${q.commande}\`.`
373
+ ? `- ${q.ticket} a fini sans son issue (aucun arrêt écrit), à ${q.etape} : relance-le sans attendre le mot du responsable, \`${q.commande}\`.`
364
374
  : [
365
375
  `- ${q.ticket} est arrêté sur une question (${q.arret}), à ${q.etape}, au ${q.qui} : ${q.question.replace(/\n/g, '\n ')}`,
366
376
  ` La réponse : \`${q.commande}\`.`,
@@ -372,6 +382,7 @@ export function circuitsALOuverture(racine, { fermes = ticketsFermes } = {}) {
372
382
  return [
373
383
  "## L'attente des questions",
374
384
  "Dès ta première réponse, sans attendre le mot du responsable, lance en arrière-plan (`run_in_background`) l'attente des questions : `npx grillhouse superviseur --attendre`. Elle se termine sur la question neuve d'un circuit, quel que soit son lanceur, et te réveille ainsi ; un lancement de circuit rend la main tout de suite, et la fin normale d'un circuit ne te réveille pas : le panneau la montre.",
385
+ ...(panne ? ['', '## Les circuits du dépôt', panne] : []),
375
386
  ...(nommes.length ? ['', '## Les circuits du dépôt', ...nommes.map(n => n.ligne)] : []),
376
387
  ].join('\n');
377
388
  }
@@ -386,9 +397,9 @@ const git = (racine, ...args) =>
386
397
  * nothing), the lock taken when it is free.
387
398
  * @param {string} racine the directory the session opens in
388
399
  * @param {{ env?: Record<string, string | undefined> }} options
389
- * @returns {string}
400
+ * @returns {Promise<string>}
390
401
  */
391
- function superviseur(racine, { env = process.env } = {}) {
402
+ async function superviseur(racine, { env = process.env } = {}) {
392
403
  if (env.BEADS_ACTOR) {
393
404
  return '';
394
405
  }
@@ -449,7 +460,7 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
449
460
  process.exitCode = 1;
450
461
  }
451
462
  } else {
452
- const texte = superviseur(process.argv[2] ?? process.cwd());
463
+ const texte = await superviseur(process.argv[2] ?? process.cwd());
453
464
  if (texte) {
454
465
  process.stdout.write(`${texte}\n`);
455
466
  }