@roomi-fields/grillhouse 0.30.0 → 0.32.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 (153) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +48 -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/dist/temporal/circuit/client.d.ts +2 -2
  8. package/dist/temporal/circuit/client.js.map +1 -1
  9. package/dist/temporal/circuit/commande.js +4 -4
  10. package/dist/temporal/circuit/commande.js.map +1 -1
  11. package/dist/temporal/circuit/contrat.d.ts +3 -3
  12. package/dist/temporal/circuit/contrat.js +8 -2
  13. package/dist/temporal/circuit/contrat.js.map +1 -1
  14. package/dist/temporal/circuit/deroule.js +3 -3
  15. package/dist/temporal/circuit/deroule.js.map +1 -1
  16. package/dist/temporal/commande.js +5 -6
  17. package/dist/temporal/commande.js.map +1 -1
  18. package/dist/temporal/installation.d.ts +3 -6
  19. package/dist/temporal/installation.js +19 -38
  20. package/dist/temporal/installation.js.map +1 -1
  21. package/dist/temporal/tickets/activites.d.ts +1 -0
  22. package/dist/temporal/tickets/activites.js +5 -0
  23. package/dist/temporal/tickets/activites.js.map +1 -1
  24. package/dist/temporal/tickets/contrat.d.ts +10 -0
  25. package/dist/temporal/tickets/deroule.js +8 -1
  26. package/dist/temporal/tickets/deroule.js.map +1 -1
  27. package/docs/ARCHITECTURE.md +119 -27
  28. package/docs/CADRE.md +20 -0
  29. package/docs/INTERFACE.md +17 -4
  30. package/hooks/hooks.json +4 -0
  31. package/package.json +2 -2
  32. package/scripts/activites.mjs +155 -84
  33. package/scripts/aiguillage.mjs +35 -11
  34. package/scripts/attente-au-tour.mjs +99 -0
  35. package/scripts/avancement.mjs +27 -10
  36. package/scripts/base-des-workflows.mjs +57 -0
  37. package/scripts/bilan.mjs +101 -25
  38. package/scripts/cadre.mjs +5 -2
  39. package/scripts/circuit.mjs +173 -58
  40. package/scripts/composants-affectes.mjs +64 -21
  41. package/scripts/composition-des-langages.mjs +5 -3
  42. package/scripts/conformite.mjs +54 -19
  43. package/scripts/copies-finies.mjs +8 -1
  44. package/scripts/dependances-internes.mjs +9 -3
  45. package/scripts/dernier-vert.mjs +84 -23
  46. package/scripts/dette.mjs +32 -11
  47. package/scripts/donnees-cles.mjs +24 -8
  48. package/scripts/droits.mjs +40 -15
  49. package/scripts/effets.mjs +9 -0
  50. package/scripts/empreinte-d-etape.mjs +17 -0
  51. package/scripts/engendres.mjs +15 -5
  52. package/scripts/enveloppe/enveloppe.mjs +141 -48
  53. package/scripts/enveloppe/travail-de-la-copie.mjs +36 -12
  54. package/scripts/etapes.mjs +1 -1
  55. package/scripts/faits-du-circuit.mjs +1 -1
  56. package/scripts/flux-des-paquets.mjs +21 -7
  57. package/scripts/gardes-du-cadre.mjs +9 -3
  58. package/scripts/init.mjs +11 -4
  59. package/scripts/integration/file.mjs +84 -29
  60. package/scripts/integration/integrer.mjs +70 -24
  61. package/scripts/integration/rejeu.mjs +26 -9
  62. package/scripts/jointure.d.ts +10 -1
  63. package/scripts/journal-des-etats.d.mts +41 -0
  64. package/scripts/journal-des-etats.mjs +273 -0
  65. package/scripts/journal.mjs +119 -0
  66. package/scripts/langages/cargo/commandes.mjs +97 -18
  67. package/scripts/langages/cargo/composants.mjs +24 -8
  68. package/scripts/langages/cargo/index.mjs +7 -0
  69. package/scripts/langages/cargo/tests-de-head.mjs +25 -9
  70. package/scripts/langages/python/commandes.mjs +3 -1
  71. package/scripts/langages/python/index.mjs +6 -0
  72. package/scripts/langages/typescript/chemins-des-tests.mjs +6 -2
  73. package/scripts/langages/typescript/composants.mjs +9 -3
  74. package/scripts/langages/typescript/consommateurs-arbitres.mjs +40 -14
  75. package/scripts/langages/typescript/consommateurs.mjs +39 -14
  76. package/scripts/langages/typescript/elements-du-lot.mjs +36 -12
  77. package/scripts/langages/typescript/frontieres.mjs +112 -22
  78. package/scripts/langages/typescript/index-interfaces.mjs +36 -13
  79. package/scripts/langages/typescript/index.mjs +12 -3
  80. package/scripts/langages/typescript/interfaces-contre-code.mjs +109 -41
  81. package/scripts/langages/typescript/lecteurs.mjs +36 -11
  82. package/scripts/langages/typescript/migrations/0.23.0-config-vitest.mjs +15 -5
  83. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +6 -2
  84. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +6 -2
  85. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +3 -1
  86. package/scripts/langages/typescript/parcours.mjs +12 -4
  87. package/scripts/langages/typescript/regle-des-tests.mjs +9 -3
  88. package/scripts/langages/typescript/resumes.mjs +9 -3
  89. package/scripts/langages/typescript/tailles-des-tests.mjs +58 -16
  90. package/scripts/langages/typescript/tests-de-nuit.mjs +3 -1
  91. package/scripts/langages/typescript/tests.mjs +24 -8
  92. package/scripts/langages/typescript/titres-de-tests.mjs +35 -12
  93. package/scripts/langages/typescript/turbo-des-paquets.mjs +152 -51
  94. package/scripts/langages/typescript/verdict.mjs +3 -1
  95. package/scripts/langages/typescript/verifier.mjs +61 -14
  96. package/scripts/langages/typescript/vitest-config/avancement.reporter.mjs +15 -5
  97. package/scripts/langages/typescript/vitest-config/base.mjs +10 -2
  98. package/scripts/langages/typescript/vitest-config/changements.mjs +21 -8
  99. package/scripts/langages/typescript/vitest-config/delais.mjs +9 -3
  100. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +12 -4
  101. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +17 -6
  102. package/scripts/langages/typescript/vitest-config/lances.mjs +83 -27
  103. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +7 -0
  104. package/scripts/langages/typescript/vitest-config/resultats.mjs +3 -1
  105. package/scripts/langages.d.mts +20 -0
  106. package/scripts/lint-des-scripts.mjs +58 -0
  107. package/scripts/matiere-de-test.d.ts +11 -0
  108. package/scripts/mesure/base-de-passe.mjs +117 -25
  109. package/scripts/mesure/pression.mjs +9 -3
  110. package/scripts/migrations/0.23.0-charte-importee.mjs +6 -2
  111. package/scripts/migrations/0.23.0-crochets-de-seance.mjs +25 -8
  112. package/scripts/migrations/0.23.0-marche-du-projet.mjs +18 -6
  113. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +48 -16
  114. package/scripts/migrations/0.24.12-tri-des-decouvertes.mjs +6 -2
  115. package/scripts/migrations/0.25.0-script-des-tests.mjs +15 -5
  116. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +6 -2
  117. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +7 -7
  118. package/scripts/nuit.sh +24 -0
  119. package/scripts/outil.mjs +3 -1
  120. package/scripts/outils-cles.mjs +18 -7
  121. package/scripts/paquet-npm.mjs +15 -5
  122. package/scripts/paquets.mjs +12 -4
  123. package/scripts/passe-de-la-machine.mjs +7 -2
  124. package/scripts/places-de-la-machine.mjs +72 -12
  125. package/scripts/preparation.mjs +15 -5
  126. package/scripts/registre.mjs +6 -2
  127. package/scripts/reprise.mjs +66 -0
  128. package/scripts/resultats.mjs +105 -37
  129. package/scripts/seances.mjs +22 -4
  130. package/scripts/services-du-noyau.mjs +1 -0
  131. package/scripts/sous-commandes.mjs +5 -1
  132. package/scripts/style-a-l-ecriture.mjs +48 -17
  133. package/scripts/superviseur.mjs +127 -75
  134. package/scripts/tableau.mjs +133 -10
  135. package/scripts/taches-du-graphe.mjs +33 -13
  136. package/scripts/ticket-du-circuit.mjs +40 -0
  137. package/scripts/transitions.mjs +159 -29
  138. package/scripts/verrou-de-fichier.mjs +6 -2
  139. package/scripts/verrou-de-machine.mjs +123 -39
  140. package/scripts/verrous/commande.mjs +50 -17
  141. package/scripts/verrous/ticket-du-sous-agent.mjs +9 -3
  142. package/scripts/verrous/verrou.mjs +42 -14
  143. package/skills/developpeur/SKILL.md +1 -1
  144. package/skills/explorateur/SKILL.md +8 -2
  145. package/skills/grill/SKILL.md +3 -57
  146. package/skills/grill/references/paquets.md +60 -0
  147. package/skills/mesure/SKILL.md +3 -0
  148. package/skills/pitmaster/SKILL.md +16 -27
  149. package/skills/questionneur/SKILL.md +1 -1
  150. package/skills/relecteur/SKILL.md +2 -2
  151. package/skills/testwriter/SKILL.md +19 -7
  152. package/skills/release/SKILL.md +0 -134
  153. package/skills/release/scripts/update-version.cjs +0 -92
@@ -57,7 +57,14 @@ import { pathToFileURL } from 'node:url';
57
57
  import { lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
58
58
  import { vivant } from './mesure/base-de-passe.mjs';
59
59
  import { circuitsDuServeur, ServeurMuet } from './circuits-du-serveur.mjs';
60
- import { attendLeSuperviseur } from './tableau.mjs';
60
+ import {
61
+ attendLeSuperviseur,
62
+ cleDe,
63
+ lireLesRemontees,
64
+ RAPPEL_PAR_DEFAUT,
65
+ remonteesDe,
66
+ verrouDeLAttente,
67
+ } from './tableau.mjs';
61
68
  import { etapeDuCircuit, libelle, SUPERVISEUR } from './etapes.mjs';
62
69
 
63
70
  const VERROU_SUPERVISEUR = 'grillhouse-superviseur.lock';
@@ -94,7 +101,7 @@ function seance(depart = process.ppid) {
94
101
 
95
102
  // Of the tickets <ids> of the repository at <racine>, those that bd gives closed; none when bd does
96
103
  // not read them.
97
- function ticketsFermes(racine, ids) {
104
+ export function ticketsFermes(racine, ids) {
98
105
  const r = spawnSync('bd', ['show', ...ids, '--json'], {
99
106
  cwd: racine,
100
107
  encoding: 'utf8',
@@ -112,52 +119,77 @@ function ticketsFermes(racine, ids) {
112
119
  }
113
120
  }
114
121
 
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(':');
119
-
120
122
  // The step where the circuit <c> stands, in words (« 3.1 Contrôles »), else its state's.
121
123
  const ou = c => {
122
124
  const e = etapeDuCircuit({ ...c, raison: c.arret });
123
125
  return e ? libelle(e) : c.etape;
124
126
  };
125
127
 
126
- // The file of the stops gone up to the session of supervision of the repository at <racine>, and
127
- // the lock of its one wait, beside the states of the circuits.
128
+ // The file of the stops gone up to the session of supervision (`remonteesDe`) and the lock of its
129
+ // one wait (`verrouDeLAttente`) are beside the states of the circuits (scripts/tableau.mjs reads
130
+ // both: its alerts).
128
131
  const etatsDe = racine => path.join(racine, '.claude', 'worktrees');
129
- const remonteesDe = racine => path.join(etatsDe(racine), 'questions-remontees.json');
130
- const verrouDeLAttente = racine => path.join(etatsDe(racine), 'attente-des-questions.lock');
132
+ export { verrouDeLAttente };
131
133
 
132
- // The stops gone up to the session of supervision of the repository at <racine>: their keys.
133
- function lireRemontees(racine) {
134
- try {
135
- const lu = JSON.parse(readFileSync(remonteesDe(racine), 'utf8'));
136
- return new Set(Array.isArray(lu?.remontees) ? lu.remontees.map(String) : []);
137
- } catch {
138
- return new Set();
139
- }
140
- }
141
-
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
146
- // `rendu`.
147
- function remonter(racine, circuits, faire) {
134
+ // The stops gone up of the repository at <racine>, its circuits <circuits> read, under the lock of
135
+ // their file, at <maintenant> ms. Each stop that waits for the supervisor and never went up, or
136
+ // whose last presentation is <rappelMs> ms old or more (<toutes>: every one), is given, its ticket
137
+ // <fermes> gives closed left out (bd is asked of those alone); a stop given is presented now, and
138
+ // one that goes up has its `depuis` set now. The file is written whole with the stops that still
139
+ // stand, their circuit waiting for the supervisor: a question answered so leaves it. The `rendu`
140
+ // is the questions given, each marked `representee` when it comes back.
141
+ function relever(racine, circuits, { fermes, maintenant, rappelMs, toutes = false }) {
148
142
  const f = remonteesDe(racine);
149
143
  mkdirSync(path.dirname(f), { recursive: true });
150
144
  const verrou = `${f}.verrou`;
151
145
  // Held for one reading of the circuits: older than that, abandoned.
152
146
  prendreVerrou(verrou, { attendre: true, perime: 30_000 });
153
147
  try {
154
- const avant = lireRemontees(racine);
155
- const { cles, rendu } = faire(avant);
156
- const debout = new Set(circuits.filter(attendLeSuperviseur).map(cleDe));
157
- const apres = new Set([...cles, ...[...avant].filter(c => debout.has(c))]);
158
- if (avant.size !== apres.size || [...apres].some(c => !avant.has(c))) {
148
+ const avant = new Map(lireLesRemontees(racine, maintenant).map(r => [r.cle, r]));
149
+ const debout = questionsEnAttente(racine, circuits, { fermes: aucunFerme });
150
+ const aRendre = debout.filter(q => {
151
+ const r = avant.get(q.cle);
152
+ return toutes || !r || maintenant - r.presentee >= rappelMs;
153
+ });
154
+ const fermesDe = aRendre.length
155
+ ? fermes(
156
+ racine,
157
+ aRendre.map(q => q.ticket)
158
+ )
159
+ : new Set();
160
+ const rendu = aRendre
161
+ .filter(q => !fermesDe.has(q.ticket))
162
+ .map(q => (avant.has(q.cle) && !toutes ? { ...q, representee: true } : q));
163
+ const presentes = new Set(aRendre.map(q => q.cle));
164
+ const enTexte = liste =>
165
+ `${JSON.stringify(
166
+ {
167
+ remontees: liste
168
+ .map(r => ({ cle: r.cle, depuis: r.depuis, presentee: r.presentee }))
169
+ .sort((a, b) => a.cle.localeCompare(b.cle, 'en')),
170
+ },
171
+ null,
172
+ 2
173
+ )}\n`;
174
+ const ecrit = enTexte(
175
+ debout.map(q => {
176
+ const r = avant.get(q.cle);
177
+ return {
178
+ cle: q.cle,
179
+ depuis: r?.depuis ?? maintenant,
180
+ presentee: presentes.has(q.cle) ? maintenant : r.presentee,
181
+ };
182
+ })
183
+ );
184
+ let enFichier = '';
185
+ try {
186
+ enFichier = readFileSync(f, 'utf8');
187
+ } catch {
188
+ // no file yet
189
+ }
190
+ if (ecrit !== enFichier && !(debout.length === 0 && avant.size === 0)) {
159
191
  const provisoire = `${f}.${process.pid}`;
160
- writeFileSync(provisoire, `${JSON.stringify({ remontees: [...apres].sort() }, null, 2)}\n`);
192
+ writeFileSync(provisoire, ecrit);
161
193
  renameSync(provisoire, f);
162
194
  }
163
195
  return rendu;
@@ -225,39 +257,33 @@ export function questionsEnAttente(
225
257
  // No ticket closed: the questions read without asking bd.
226
258
  const aucunFerme = () => new Set();
227
259
 
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 }),
236
- }));
237
- }
238
-
239
260
  /**
240
261
  * The wait of the session of supervision of the repository at <racine> (`npx grillhouse
241
- * superviseur --attendre`, which the supervisor keeps in the background, as a review requested on
242
- * GitHub or Gerrit's attention set calls the one a change waits for): it ends only when a question
243
- * that never went up waits for the supervisor (`questionsEnAttente`), whatever launched its
244
- * circuit, and gives those questions, now gone up; a question already gone up (by a wait, or named
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
252
- * @returns {Promise<{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string }[]>}
262
+ * superviseur --attendre`, which the supervisor reads as a stream, as a worker of Temporal keeps its
263
+ * task queue): an asynchronous iterator that gives one batch of questions at a time and goes on
264
+ * listening by itself, with no relaunch. It gives a question that waits for the supervisor
265
+ * (`questionsEnAttente`), whatever launched its circuit, once it never went up, and again, marked
266
+ * `representee`, every <rappel> minutes (5 by default) while its circuit stands on the same stop,
267
+ * as SQS gives a message not acknowledged again after its visibility timeout; a question
268
+ * answered (its circuit left the stop) leaves those gone up and is not given again, and the normal
269
+ * end of a circuit is never one. A stop whose key changes is a new question, given at once. The
270
+ * times are those of <maintenant> (`Date.now` by default). It reads the circuits every <pas> ms by
271
+ * <circuitsDe> (one call to the Temporal server, scripts/circuits-du-serveur.mjs, by default), as
272
+ * the UI of Temporal refreshes its list; a reading that fails (the server down) is tried again at
273
+ * the next step, the questions gone up kept. One wait at a time per repository: a second one is
274
+ * refused while the first runs. Its <signal> ends it.
275
+ * @param {{ racine: string, fermes?: (racine: string, ids: string[]) => Set<string>, pas?: number, signal?: AbortSignal, circuitsDe?: (racine: string) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]>, maintenant?: () => number, rappel?: number }} options
276
+ * @returns {AsyncGenerator<{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string, representee?: boolean }[], void, void>}
253
277
  * @throws {Error} another wait runs
254
278
  */
255
- export async function attendreUneQuestion({
279
+ export async function* attendreUneQuestion({
256
280
  racine,
257
281
  fermes = ticketsFermes,
258
282
  pas = 5_000,
259
283
  signal,
260
284
  circuitsDe = circuitsDuServeur,
285
+ maintenant = Date.now,
286
+ rappel = RAPPEL_PAR_DEFAUT,
261
287
  }) {
262
288
  mkdirSync(etatsDe(racine), { recursive: true });
263
289
  const verrou = verrouDeLAttente(racine);
@@ -281,14 +307,17 @@ export async function attendreUneQuestion({
281
307
  circuits = null;
282
308
  }
283
309
  if (circuits && !signal?.aborted) {
284
- const neuves = releverLesNeuves(racine, circuits, fermes);
285
- if (neuves.length) {
286
- return neuves;
310
+ const lot = relever(racine, circuits, {
311
+ fermes,
312
+ maintenant: maintenant(),
313
+ rappelMs: rappel * 60_000,
314
+ });
315
+ if (lot.length) {
316
+ yield lot;
287
317
  }
288
318
  }
289
319
  await attendre(pas, signal);
290
320
  }
291
- return [];
292
321
  } finally {
293
322
  lacherVerrou(verrou);
294
323
  }
@@ -307,21 +336,29 @@ const attendre = (ms, signal) =>
307
336
 
308
337
  /**
309
338
  * The text that wakes the session of supervision on the questions <questions>: for each one, its
310
- * ticket, step, who must answer it, its question and the command that answers it; then the wait to
311
- * launch again once they are answered.
312
- * @param {{ ticket: string, etape: string, question: string, qui: string, commande: string }[]} questions
339
+ * ticket, step, who must answer it, its question and the command that answers it. The wait goes
340
+ * on by itself: the text asks for no relaunch. A question presented again (`representee`) says that
341
+ * it still waits for an answer.
342
+ * @param {{ ticket: string, etape: string, question: string, qui: string, commande: string, representee?: boolean }[]} questions
313
343
  * @returns {string}
314
344
  */
315
345
  export function texteDesQuestions(questions) {
346
+ const neuves = questions.filter(q => !q.representee);
347
+ const titre = neuves.length
348
+ ? questions.length > 1
349
+ ? '## Questions neuves des circuits'
350
+ : "## Question neuve d'un circuit"
351
+ : questions.length > 1
352
+ ? '## Questions toujours sans réponse'
353
+ : '## Question toujours sans réponse';
316
354
  return [
317
- questions.length > 1 ? '## Questions neuves des circuits' : "## Question neuve d'un circuit",
355
+ titre,
318
356
  ...questions.map(q =>
319
357
  [
320
- `- ${q.ticket}, à ${q.etape}, au ${q.qui} : ${q.question.replace(/\n/g, '\n ')}`,
358
+ `- ${q.ticket}, à ${q.etape}, au ${q.qui}${q.representee ? ' (toujours sans réponse)' : ''} : ${q.question.replace(/\n/g, '\n ')}`,
321
359
  ` La réponse : \`${q.commande}\`.`,
322
360
  ].join('\n')
323
361
  ),
324
- "Une fois répondu, relance l'attente en arrière-plan (`run_in_background`) : `npx grillhouse superviseur --attendre`.",
325
362
  ].join('\n');
326
363
  }
327
364
 
@@ -357,9 +394,11 @@ export async function circuitsALOuverture(
357
394
  : `Les circuits ne se lisent pas : ${message}.`;
358
395
  }
359
396
  const questions = circuits
360
- ? remonter(racine, circuits, () => {
361
- const q = questionsEnAttente(racine, circuits, { fermes });
362
- return { cles: q.map(x => x.cle), rendu: q };
397
+ ? relever(racine, circuits, {
398
+ fermes,
399
+ maintenant: Date.now(),
400
+ rappelMs: RAPPEL_PAR_DEFAUT * 60_000,
401
+ toutes: true,
363
402
  })
364
403
  : [];
365
404
  const tournent = enAttente(
@@ -381,7 +420,7 @@ export async function circuitsALOuverture(
381
420
  );
382
421
  return [
383
422
  "## L'attente des questions",
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.",
423
+ "Dès ta première réponse, sans attendre le mot du responsable, lance l'attente des questions en arrière-plan (`run_in_background`) et surveille sa sortie en continu (l'outil `Monitor`) : `npx grillhouse superviseur --attendre`. Elle ne se termine pas : elle imprime un lot à chaque question neuve d'un circuit, quel que soit son lanceur, et te réveille ainsi ; elle reprend l'écoute seule, sans relance. Une question sans réponse revient toutes les 5 min (`--rappel <minutes>` règle l'intervalle) jusqu'à sa réponse. 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
424
  ...(panne ? ['', '## Les circuits du dépôt', panne] : []),
386
425
  ...(nommes.length ? ['', '## Les circuits du dépôt', ...nommes.map(n => n.ligne)] : []),
387
426
  ].join('\n');
@@ -451,10 +490,23 @@ function racineDe(dossier) {
451
490
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
452
491
  if (process.argv[2] === '--attendre') {
453
492
  try {
454
- const questions = await attendreUneQuestion({
455
- racine: racineDe(process.argv[3] ?? process.cwd()),
456
- });
457
- process.stdout.write(`${texteDesQuestions(questions)}\n`);
493
+ const args = process.argv.slice(3);
494
+ const i = args.indexOf('--rappel');
495
+ let rappel = RAPPEL_PAR_DEFAUT;
496
+ if (i !== -1) {
497
+ rappel = Number(args[i + 1]);
498
+ if (!(rappel > 0)) {
499
+ throw new Error('--rappel attend un nombre de minutes supérieur à 0.');
500
+ }
501
+ args.splice(i, 2);
502
+ }
503
+ for await (const questions of attendreUneQuestion({
504
+ racine: racineDe(args[0] ?? process.cwd()),
505
+ rappel,
506
+ })) {
507
+ // One batch, one block ended by a blank line: a stream read line by line.
508
+ process.stdout.write(`${texteDesQuestions(questions)}\n\n`);
509
+ }
458
510
  } catch (e) {
459
511
  process.stderr.write(`${e.message}\n`);
460
512
  process.exitCode = 1;
@@ -117,6 +117,7 @@ import { verdictDe } from './integration/verdict.mjs';
117
117
  import { lireLaMesure } from './avancement.mjs';
118
118
  import { SANS_REPONSE_EN, ServeurMuet, circuitsDuServeur } from './circuits-du-serveur.mjs';
119
119
  import { etatDesPlaces } from './places-de-la-machine.mjs';
120
+ import { vivant } from './mesure/base-de-passe.mjs';
120
121
 
121
122
  const MINUTE = 60_000;
122
123
  export const SILENCE = 10 * MINUTE;
@@ -612,6 +613,70 @@ export function lireVivant({ racine, home, prefix, maintenant, ps, cache = {} })
612
613
  export const attendLeSuperviseur = c =>
613
614
  !c.vivant && Boolean(c.interrompu || c.question || (c.arret && c.arret !== 'arrete'));
614
615
 
616
+ /**
617
+ * The key of one stop of the circuit <c>: its ticket, the run of its workflow, the rank of its
618
+ * question in that run and its stop, so that the next stop of a circuit resumed is another one. The
619
+ * one key of the file of the stops gone up (scripts/superviseur.mjs) and of the board's alerts.
620
+ * @param {{ ticket: string, run?: string, numero?: number, arret?: string | null }} c
621
+ * @returns {string}
622
+ */
623
+ export const cleDe = c => [c.ticket, c.run, c.numero, c.arret ?? 'interrompu'].join(':');
624
+
625
+ /** The file of the stops gone up to the supervisor of the repository at <racine>. */
626
+ export const remonteesDe = racine =>
627
+ path.join(racine, '.claude', 'worktrees', 'questions-remontees.json');
628
+
629
+ /**
630
+ * The stops gone up of the repository at <racine>, each with its key, `depuis` (the time of its
631
+ * first going up) and `presentee` (the time of its last presentation), in ms. An older file, a
632
+ * list of keys, reads without error: its stops take the time <maintenant> of the reading. A file
633
+ * that does not read holds none.
634
+ * @param {string} racine
635
+ * @param {number} maintenant
636
+ * @returns {{ cle: string, depuis: number, presentee: number }[]}
637
+ */
638
+ export function lireLesRemontees(racine, maintenant) {
639
+ try {
640
+ const lu = JSON.parse(readFileSync(remonteesDe(racine), 'utf8'));
641
+ if (!Array.isArray(lu?.remontees)) {
642
+ return [];
643
+ }
644
+ return lu.remontees.map(r =>
645
+ typeof r === 'string'
646
+ ? { cle: r, depuis: maintenant, presentee: maintenant }
647
+ : {
648
+ cle: String(r.cle),
649
+ depuis: Number.isFinite(r.depuis) ? r.depuis : maintenant,
650
+ presentee: Number.isFinite(r.presentee) ? r.presentee : maintenant,
651
+ }
652
+ );
653
+ } catch {
654
+ return [];
655
+ }
656
+ }
657
+
658
+ /** The lock of the one wait of the questions of the repository at <racine>. */
659
+ export const verrouDeLAttente = racine =>
660
+ path.join(racine, '.claude', 'worktrees', 'attente-des-questions.lock');
661
+
662
+ /**
663
+ * Whether a wait of the questions lives for the repository at <racine>: its lock names a process
664
+ * that lives (the pid is read again; a lock left by a dead process does not count).
665
+ * @param {string} racine
666
+ * @returns {boolean}
667
+ */
668
+ export function attenteVivante(racine) {
669
+ try {
670
+ const pid = Number(/^(\d+)/.exec(readFileSync(verrouDeLAttente(racine), 'utf8'))?.[1]);
671
+ return Number.isInteger(pid) && pid > 0 && vivant(pid);
672
+ } catch {
673
+ return false;
674
+ }
675
+ }
676
+
677
+ // The minutes between two presentations of a question not answered, by default.
678
+ export const RAPPEL_PAR_DEFAUT = 5;
679
+
615
680
  // The reviewer's last verdict among a ticket's comments (verdictDe: a comment of the reviewer's
616
681
  // author), or null.
617
682
  export function verdict(commentaires) {
@@ -685,12 +750,14 @@ export function lecture(t, prefix) {
685
750
  * repository (scripts/aiguillage.mjs `echecDeLOutil`); `places`, the places of the machine
686
751
  * (scripts/places-de-la-machine.mjs `etatDesPlaces`), whose line heads AGENTS; `muet`, the Temporal
687
752
  * server did not answer the reading of the circuits, which the first alert says; `faute`, any
688
- * other fault of that reading, said in the first alert as it is.
753
+ * other fault of that reading, said in the first alert as it is; `echecPrefixe`, the cause of a
754
+ * ticket prefix that did not read, named in an alert.
689
755
  * @param {{ tous: any[], prefix?: string, registre: any[], vivants: any[], circuits?: any[],
690
756
  * verdicts?: Record<string, any>, maintenant: number, jour: number,
691
757
  * machine?: Machine | null, outil?: { version: string, raison: string } | null,
692
758
  * places?: { prises: number, plafond: number, charge: number, coeurs: number, memoireGo: number,
693
- * attentes: { ticket: string, depuis: number }[] } | null, muet?: boolean, faute?: string | null }} lu
759
+ * attentes: { ticket: string, depuis: number }[] } | null, muet?: boolean, faute?: string | null,
760
+ * echecPrefixe?: string | null }} lu
694
761
  */
695
762
  export function assembler({
696
763
  tous,
@@ -706,6 +773,10 @@ export function assembler({
706
773
  places: placesDeLaMachine = null,
707
774
  muet = false,
708
775
  faute = null,
776
+ echecPrefixe = null,
777
+ remontees = [],
778
+ rappel = RAPPEL_PAR_DEFAUT,
779
+ attenteVivante: attenteQuiVit = true,
709
780
  }) {
710
781
  // A circuit's lines are its steps, no agent's passage.
711
782
  const etapesFinies = lignesDuRegistre.filter(r => r.role === ROLE_DU_CIRCUIT);
@@ -742,8 +813,13 @@ export function assembler({
742
813
  for (const l of enfants.values()) {
743
814
  l.sort(ordre);
744
815
  }
745
- // The circuits of the open tickets; a ticket whose circuit runs is in progress.
746
- const parCircuit = new Map(circuits.filter(c => ouvert(c.ticket)).map(c => [c.ticket, c]));
816
+ // The circuits of the open tickets, and the running ones of the closed tickets (the queue closes
817
+ // a ticket before it reads the CI); a ticket whose circuit runs is in progress.
818
+ const parCircuit = new Map(
819
+ circuits
820
+ .filter(c => ouvert(c.ticket) || (c.vivant && parId.has(c.ticket)))
821
+ .map(c => [c.ticket, c])
822
+ );
747
823
  const actifs = new Set([
748
824
  ...enCoursMesures.map(v => v.ticket).filter(Boolean),
749
825
  ...[...parCircuit.values()].filter(c => c.vivant).map(c => c.ticket),
@@ -762,12 +838,12 @@ export function assembler({
762
838
  // A ticket's state: done, in progress, deferred, awaiting validation; else, with the owner's go,
763
839
  // waiting (ready) or blocked (an open ticket it depends on); without it, awaiting his go.
764
840
  const etat = t => {
765
- if (t.status === 'closed') {
766
- return 'fermes';
767
- }
768
841
  if (t.status === 'in_progress' || actifs.has(t.id)) {
769
842
  return 'enCours';
770
843
  }
844
+ if (t.status === 'closed') {
845
+ return 'fermes';
846
+ }
771
847
  if (t.status === 'deferred') {
772
848
  return 'reportes';
773
849
  }
@@ -990,7 +1066,9 @@ export function assembler({
990
1066
  }
991
1067
  const debutJour = jour;
992
1068
  const faitsDuJour = tous
993
- .filter(t => travail(t) && t.closed_at && Date.parse(t.closed_at) >= debutJour)
1069
+ .filter(
1070
+ t => travail(t) && !actifs.has(t.id) && t.closed_at && Date.parse(t.closed_at) >= debutJour
1071
+ )
994
1072
  .sort((a, b) => Date.parse(b.closed_at) - Date.parse(a.closed_at))
995
1073
  .map(t => ({
996
1074
  id: t.id,
@@ -1008,6 +1086,10 @@ export function assembler({
1008
1086
  } else if (faute) {
1009
1087
  alertes.push({ niveau: 'rouge', texte: `Circuits illisibles : ${faute}` });
1010
1088
  }
1089
+ // The ticket prefix did not read: the project keeps its folder's name, and the alert says why.
1090
+ if (echecPrefixe) {
1091
+ alertes.push({ niveau: 'rouge', texte: `Préfixe des tickets illisible : ${echecPrefixe}` });
1092
+ }
1011
1093
  // A red night says the night it turned red, short enough to stand whole on its line: the local
1012
1094
  // day and month its ticket was opened, the night's date (scripts/nuit.sh), whatever its title names, a
1013
1095
  // commit in older ones.
@@ -1036,6 +1118,33 @@ export function assembler({
1036
1118
  texte: `Outil ${outil.version} non installable : code du dépôt`,
1037
1119
  });
1038
1120
  }
1121
+ // A circuit stopped on a question to the supervisor: orange, how long it has waited (from the
1122
+ // `depuis` of its stop in the file of the stops gone up), red past two intervals of
1123
+ // re-presentation (two presentations with no answer); it falls when the circuit leaves the stop.
1124
+ // One red alert « à corriger » when some wait and no wait lives.
1125
+ const depuisDe = new Map(remontees.map(r => [r.cle, r.depuis]));
1126
+ const enAttenteDuSuperviseur = [...parCircuit.values()]
1127
+ .filter(attendLeSuperviseur)
1128
+ .sort((a, b) => ordre({ id: a.ticket }, { id: b.ticket }));
1129
+ for (const c of enAttenteDuSuperviseur) {
1130
+ const depuis = depuisDe.get(cleDe(c));
1131
+ if (depuis === undefined) {
1132
+ continue;
1133
+ }
1134
+ const attendu = Math.max(0, maintenant - depuis);
1135
+ alertes.push({
1136
+ niveau: attendu > 2 * rappel * MINUTE ? 'rouge' : 'orange',
1137
+ signe: '⏳',
1138
+ texte: `${numero(c.ticket)} attend le superviseur depuis ${Math.floor(attendu / MINUTE)} min`,
1139
+ });
1140
+ }
1141
+ if (enAttenteDuSuperviseur.length && !attenteQuiVit) {
1142
+ alertes.push({
1143
+ niveau: 'rouge',
1144
+ signe: '🔕',
1145
+ texte: 'À corriger : une question au superviseur reste sans réponse, aucune attente ne tourne',
1146
+ });
1147
+ }
1039
1148
  for (const b of blocs) {
1040
1149
  for (const x of b.enCours) {
1041
1150
  if (x.ligne && x.silence !== null && x.silence > SILENCE) {
@@ -1413,7 +1522,8 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1413
1522
  const reste = avec =>
1414
1523
  largeur - (droite ? colonnes(droite) + 1 : 0) - colonnes(tete) - colonnes(avec);
1415
1524
  const place = attendUnePlace.has(c.id) ? ' · attend une place' : '';
1416
- const suite = `${
1525
+ const tag = enQuestion(c) === SUPERVISEUR ? ' · en attente du superviseur' : '';
1526
+ const suite = `${tag}${
1417
1527
  !temoin
1418
1528
  ? boucles
1419
1529
  : reste(`${boucles}${temoin.texte}`) >= Math.min(PLACE_DU_SUJET, c.sujet.length)
@@ -1831,15 +1941,25 @@ function lire(
1831
1941
  racine,
1832
1942
  { home, maintenant, circuits, muet = false, faute = null, machine = null, places = null }
1833
1943
  ) {
1944
+ // The prefix is read once, with no delay of its own; a read that fails leaves it empty (the
1945
+ // project is labelled by its folder) and its cause is named in an alert (`echecPrefixe`).
1834
1946
  let prefix = '';
1947
+ let echecPrefixe = null;
1835
1948
  try {
1836
1949
  prefix = execFileSync('bd', ['config', 'get', 'issue_prefix'], {
1837
1950
  cwd: racine,
1838
1951
  encoding: 'utf8',
1952
+ stdio: ['ignore', 'pipe', 'pipe'],
1839
1953
  maxBuffer: 256 * 1024 * 1024,
1840
1954
  }).trim();
1841
- } catch {
1955
+ } catch (e) {
1842
1956
  prefix = '';
1957
+ const message = String(e?.stderr ?? '').trim() || String(e?.message ?? e);
1958
+ const ligne = message.split('\n')[0];
1959
+ echecPrefixe =
1960
+ e?.status === null || e?.status === undefined
1961
+ ? `${e?.code ?? 'échec'} ${ligne}`.trim()
1962
+ : `code ${e.status} ${ligne}`.trim();
1843
1963
  }
1844
1964
  let ps = '';
1845
1965
  try {
@@ -1920,7 +2040,10 @@ function lire(
1920
2040
  places,
1921
2041
  muet,
1922
2042
  faute,
2043
+ echecPrefixe,
1923
2044
  outil: echecDeLOutil(racine),
2045
+ remontees: lireLesRemontees(racine, maintenant),
2046
+ attenteVivante: attenteVivante(racine),
1924
2047
  });
1925
2048
  return { t, prefix, tous, vivants, commun };
1926
2049
  }
@@ -82,25 +82,18 @@ export function nomDuPaquet(racine, dossier) {
82
82
  * tests?: { arguments: string[], rejouer?: string }, env?: NodeJS.ProcessEnv }} o
83
83
  * @returns {number}
84
84
  */
85
- export function lancerLesTaches({
86
- outil,
87
- racine,
88
- taches,
89
- noms = [],
90
- tests,
91
- env = process.env,
92
- }) {
85
+ export function lancerLesTaches({ outil, racine, taches, noms = [], tests, env = process.env }) {
93
86
  const e = { ...env };
94
87
  delete e[TESTS_CIBLES];
95
88
  if (tests) {
96
89
  e[TESTS_CIBLES] = JSON.stringify(tests);
97
90
  }
98
91
  const filtres = [...new Set(noms)].sort().map(n => `--filter=${n}`);
99
- const r = spawnSync(
100
- outil,
101
- ['run', ...taches, ...filtres, '--continue=dependencies-successful'],
102
- { cwd: racine, stdio: 'inherit', env: e }
103
- );
92
+ const r = spawnSync(outil, ['run', ...taches, ...filtres, '--continue=dependencies-successful'], {
93
+ cwd: racine,
94
+ stdio: 'inherit',
95
+ env: e,
96
+ });
104
97
  return r.status ?? 1;
105
98
  }
106
99
 
@@ -210,6 +203,33 @@ function plan(outil, racine, args) {
210
203
  return JSON.parse(r.stdout);
211
204
  }
212
205
 
206
+ /**
207
+ * The hashes of the inputs of the tests tasks of the packages <noms> (by their package name) and
208
+ * of their dependents, as the runner <outil> plans them in <racine> (the hash of a task covers the
209
+ * content of the files it reads and of the tasks it waits for): `{ <paquet>: <hash> }`; null when
210
+ * the runner gives no plan. The fingerprint of a step of the circuit reads it
211
+ * (scripts/reprise.mjs).
212
+ * @param {string} outil the task runner
213
+ * @param {string} racine
214
+ * @param {string[]} noms
215
+ * @returns {Record<string, string> | null}
216
+ */
217
+ export function empreintesDesTaches(outil, racine, noms) {
218
+ if (!noms.length) {
219
+ return {};
220
+ }
221
+ try {
222
+ const graphe = plan(outil, racine, [
223
+ 'run',
224
+ SCRIPT_DES_TESTS,
225
+ ...noms.map(n => `--filter=...${n}`),
226
+ ]);
227
+ return Object.fromEntries((graphe.tasks ?? []).map(t => [t.package, t.hash]));
228
+ } catch {
229
+ return null;
230
+ }
231
+ }
232
+
213
233
  // The build <args> in <racine>, its output in <echec> then on this process's: when it fails,
214
234
  // <echec> holds <ligne> then that output, and the warning <alerte> follows it.
215
235
  function construireJusquOuIlConstruit(outil, racine, args, echec, ligne, alerte) {
@@ -6,6 +6,7 @@
6
6
  // `racine`) and holds no state of its own. Its writings at the ticket and among the sheets are
7
7
  // effects (scripts/effets.mjs `emettre`), and its readings see those an act of the workflow
8
8
  // emitted and has not yet played (`rendusDe`).
9
+ import { spawnSync } from 'node:child_process';
9
10
  import { appendFileSync, existsSync, readFileSync } from 'node:fs';
10
11
  import { gesteDe } from './etapes.mjs';
11
12
  import { paquetsDuLangage } from './enveloppe/paquets-du-plan.mjs';
@@ -153,6 +154,45 @@ export const fichesDe = (ctx, role) =>
153
154
  .filter(e => e.role === role)
154
155
  .map(e => e.fiche);
155
156
 
157
+ // Whether the code of the behaviour is already in the copy: a developpeur session has run (the
158
+ // sheets hold one) and the copy still carries a change of production the testwriter does not write
159
+ // (`estUnTest` null: neither a test file nor the shared test material). This is the ground truth,
160
+ // not the order of the sessions: a testwriter session after the developpeur's (a RENDU to fix a
161
+ // test) does not remove the code, so the sign stays raised; a new lot whose code is not in the copy
162
+ // never raises it. With it, no test can turn red, and the proof abstains.
163
+ export const codeDejaPresent = ctx => {
164
+ if (!lesFiches(ctx).some(e => e.role === 'developpeur')) {
165
+ return false;
166
+ }
167
+ const r = spawnSync(
168
+ 'git',
169
+ ['-C', ctx.copie, 'status', '--porcelain', '-z', '--untracked-files=all'],
170
+ { encoding: 'utf8' }
171
+ );
172
+ if (r.status !== 0) {
173
+ return false;
174
+ }
175
+ const langage = langageDe(ctx.copie);
176
+ const entrees = r.stdout.split('\0');
177
+ for (let i = 0; i < entrees.length; i++) {
178
+ const e = entrees[i];
179
+ if (e.length < 4) {
180
+ continue;
181
+ }
182
+ const xy = e.slice(0, 2);
183
+ const fichier = e.slice(3);
184
+ // A rename or a copy names its source in the next entry, which is not a change of its own.
185
+ if (xy.includes('R') || xy.includes('C')) {
186
+ i++;
187
+ }
188
+ // A production file the testwriter does not write, present (not deleted): the developer's code.
189
+ if (!xy.includes('D') && langage.estUnTest(fichier, ctx.copie) === null) {
190
+ return true;
191
+ }
192
+ }
193
+ return false;
194
+ };
195
+
156
196
  // One line of the circuit's history at the ticket: `Circuit · <étape> : <texte>`, the effect
157
197
  // `commentaire`; one not written is said, and the circuit goes on (`ecrireLEffet`).
158
198
  export function commenter(ctx, etape, texte) {