@roomi-fields/grillhouse 0.33.0 → 0.34.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 (132) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +73 -0
  3. package/cadre/templates/projet/.github/workflows/ci.yml +35 -2
  4. package/cadre/templates/projet/CLAUDE.md +9 -3
  5. package/charte.md +23 -6
  6. package/dist/temporal/circuit/activites.d.ts +3 -1
  7. package/dist/temporal/circuit/activites.js +25 -1
  8. package/dist/temporal/circuit/activites.js.map +1 -1
  9. package/dist/temporal/circuit/appel.d.ts +19 -0
  10. package/dist/temporal/circuit/appel.js +93 -0
  11. package/dist/temporal/circuit/appel.js.map +1 -0
  12. package/dist/temporal/circuit/client.d.ts +17 -3
  13. package/dist/temporal/circuit/client.js +28 -4
  14. package/dist/temporal/circuit/client.js.map +1 -1
  15. package/dist/temporal/circuit/commande.js +27 -87
  16. package/dist/temporal/circuit/commande.js.map +1 -1
  17. package/dist/temporal/circuit/contrat.d.ts +29 -0
  18. package/dist/temporal/circuit/contrat.js +33 -0
  19. package/dist/temporal/circuit/contrat.js.map +1 -1
  20. package/dist/temporal/circuit/deroule.js +115 -34
  21. package/dist/temporal/circuit/deroule.js.map +1 -1
  22. package/dist/temporal/commande.js +13 -3
  23. package/dist/temporal/commande.js.map +1 -1
  24. package/dist/temporal/file/activites.d.ts +3 -0
  25. package/dist/temporal/file/activites.js +9 -0
  26. package/dist/temporal/file/activites.js.map +1 -1
  27. package/dist/temporal/file/contrat.d.ts +58 -0
  28. package/dist/temporal/file/deroule.d.ts +8 -1
  29. package/dist/temporal/file/deroule.js +100 -2
  30. package/dist/temporal/file/deroule.js.map +1 -1
  31. package/dist/temporal/installation.d.ts +15 -1
  32. package/dist/temporal/installation.js +57 -15
  33. package/dist/temporal/installation.js.map +1 -1
  34. package/dist/temporal/nuits/contrat.d.ts +2 -0
  35. package/dist/temporal/nuits/deroule.js +3 -0
  36. package/dist/temporal/nuits/deroule.js.map +1 -1
  37. package/dist/temporal/places/activites.d.ts +8 -0
  38. package/dist/temporal/places/activites.js +12 -1
  39. package/dist/temporal/places/activites.js.map +1 -1
  40. package/dist/temporal/places/client.d.ts +8 -1
  41. package/dist/temporal/places/client.js +25 -2
  42. package/dist/temporal/places/client.js.map +1 -1
  43. package/dist/temporal/places/contrat.d.ts +35 -3
  44. package/dist/temporal/places/contrat.js +5 -4
  45. package/dist/temporal/places/contrat.js.map +1 -1
  46. package/dist/temporal/places/deroule.js +55 -9
  47. package/dist/temporal/places/deroule.js.map +1 -1
  48. package/dist/temporal/tickets/activites.d.ts +3 -0
  49. package/dist/temporal/tickets/activites.js +73 -4
  50. package/dist/temporal/tickets/activites.js.map +1 -1
  51. package/dist/temporal/tickets/contrat.d.ts +31 -0
  52. package/dist/temporal/tickets/deroule.js +61 -10
  53. package/dist/temporal/tickets/deroule.js.map +1 -1
  54. package/docs/ARCHITECTURE.md +240 -60
  55. package/docs/CADRE.md +6 -1
  56. package/docs/INTERFACE.md +25 -8
  57. package/hooks/crochet.mjs +17 -2
  58. package/hooks/hooks.json +24 -0
  59. package/package.json +1 -1
  60. package/scripts/activites.mjs +96 -15
  61. package/scripts/aiguillage.mjs +2 -0
  62. package/scripts/attente-a-l-arret.mjs +141 -0
  63. package/scripts/attente-au-tour.mjs +32 -16
  64. package/scripts/avancement.mjs +5 -3
  65. package/scripts/branche-de-nuit.mjs +63 -3
  66. package/scripts/circuit.mjs +57 -4
  67. package/scripts/circuits-du-serveur.mjs +38 -4
  68. package/scripts/commandes-composees.mjs +11 -4
  69. package/scripts/copies-finies.mjs +43 -29
  70. package/scripts/crochets.mjs +1 -1
  71. package/scripts/dernier-vert.mjs +31 -10
  72. package/scripts/dette.mjs +55 -4
  73. package/scripts/disque-des-copies.d.mts +28 -0
  74. package/scripts/disque-des-copies.mjs +155 -0
  75. package/scripts/droits.mjs +2 -0
  76. package/scripts/faits-du-circuit.mjs +24 -0
  77. package/scripts/file-des-tickets.d.mts +16 -0
  78. package/scripts/file-des-tickets.mjs +65 -7
  79. package/scripts/gardes-du-cadre.mjs +4 -2
  80. package/scripts/integration/file.mjs +302 -5
  81. package/scripts/jointure.d.ts +33 -1
  82. package/scripts/langages/cargo/commandes.mjs +71 -10
  83. package/scripts/langages/cargo/composants.mjs +12 -4
  84. package/scripts/langages/cargo/executables-de-tests.mjs +118 -0
  85. package/scripts/langages/cargo/exemples.mjs +17 -3
  86. package/scripts/langages/cargo/index.mjs +8 -3
  87. package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +2 -2
  88. package/scripts/langages/cargo/migrations/0.34.0-executables-de-tests.mjs +35 -0
  89. package/scripts/langages/cargo/squelette.mjs +8 -3
  90. package/scripts/langages/cargo/tailles-des-tests.mjs +68 -6
  91. package/scripts/langages/cargo/tests-de-head.mjs +12 -9
  92. package/scripts/langages/cargo/verdict.mjs +40 -14
  93. package/scripts/langages/python/commandes.mjs +11 -2
  94. package/scripts/langages/python/index.mjs +12 -4
  95. package/scripts/langages/python/verdict.mjs +8 -1
  96. package/scripts/langages/typescript/index.mjs +9 -2
  97. package/scripts/langages/typescript/resume-du-lanceur.mjs +86 -0
  98. package/scripts/langages/typescript/tests.mjs +9 -3
  99. package/scripts/langages/typescript/verdict.mjs +4 -60
  100. package/scripts/langages/typescript/verifier.mjs +11 -4
  101. package/scripts/langages/typescript/vitest-config/changements.mjs +32 -15
  102. package/scripts/langages/typescript/vitest-config/lances.mjs +45 -0
  103. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +1 -0
  104. package/scripts/messages-non-lus.mjs +166 -0
  105. package/scripts/mesure-de-la-machine.mjs +7 -4
  106. package/scripts/migrations-des-gardes.mjs +168 -0
  107. package/scripts/places-de-la-machine.mjs +44 -40
  108. package/scripts/places-du-serveur.mjs +82 -14
  109. package/scripts/plafond-de-la-machine.d.mts +18 -0
  110. package/scripts/plafond-de-la-machine.mjs +45 -0
  111. package/scripts/recommencer.d.mts +4 -0
  112. package/scripts/recommencer.mjs +29 -0
  113. package/scripts/regles-des-places.d.mts +35 -0
  114. package/scripts/regles-des-places.mjs +82 -1
  115. package/scripts/resultats.mjs +38 -4
  116. package/scripts/retirer-les-copies-finies.mjs +11 -7
  117. package/scripts/seances.mjs +1 -1
  118. package/scripts/services-du-noyau.mjs +2 -1
  119. package/scripts/session-start.sh +12 -0
  120. package/scripts/sous-commandes.mjs +2 -0
  121. package/scripts/superviseur.mjs +283 -59
  122. package/scripts/tableau.mjs +390 -250
  123. package/scripts/taches-du-graphe.mjs +32 -5
  124. package/scripts/ticket-du-circuit.mjs +25 -0
  125. package/scripts/transitions.d.mts +27 -1
  126. package/scripts/transitions.mjs +96 -4
  127. package/scripts/verrou-de-machine.mjs +41 -17
  128. package/skills/explorateur/SKILL.md +8 -2
  129. package/skills/pitmaster/SKILL.md +26 -18
  130. package/skills/pitmaster/references/tour.md +3 -1
  131. package/skills/questionneur/SKILL.md +5 -1
  132. package/skills/testwriter/SKILL.md +32 -6
@@ -27,7 +27,9 @@
27
27
  // circuit ended without its issue, with the command that resumes it (`--reprendre` from its last
28
28
  // state written, else `--depuis <testwriter|developpeur> --contexte <texte>`), which the
29
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
30
+ // and the ended ones then gone up; a server that does not answer is said; then « ## La file des
31
+ // tickets », the tickets of the queue without their section « ## Architecture », which the
32
+ // queue never starts (scripts/file-des-tickets.mjs), for the supervisor to write it. A circuit
31
33
  // runs on the worker of the project, apart from the sessions, its launch returns at once, and its
32
34
  // question wakes the supervisor by the wait alone (grillhouse-mwz: SyntHub's SH-br0.1 stopped
33
35
  // 27 s after a relaunch of its session, read only on a word of the owner). The queue of the
@@ -36,22 +38,31 @@
36
38
  //
37
39
  // npx grillhouse superviseur --attendre [<dossier>]
38
40
  //
39
- // - The wait of the session of supervision (`attendreUneQuestion`), which the supervisor keeps in
40
- // the background, one at a time, the one way a question of a circuit wakes the session (the
41
- // owner's decision, grillhouse-pq6): it ends only when a question of a circuit appears that never
42
- // went up (`questionsEnAttente`, the one source of the questions that wait for the supervisor,
41
+ // - The wait of the session of supervision (`attendreUneQuestion`), which the supervisor launches
42
+ // in the background, one at a time, the one way a question of a circuit wakes the session (the
43
+ // owner's decision, grillhouse-pq6): it writes the batch of the questions already due at its
44
+ // start, else waits for one, and ENDS once it has written one batch, as `gh run watch` or
45
+ // `kubectl wait` return on their event: the end of its task wakes the session, whatever pipe
46
+ // follows it, and the session launches it again once the batch is dealt with
47
+ // (grillhouse-d4n.9: a wait that never ended, launched behind `| tail`, was read by no one for
48
+ // 40 min). A batch holds each question of a circuit that never went up or whose re-presentation
49
+ // is due (`questionsEnAttente`, the one source of the questions that wait for the supervisor,
43
50
  // which the opening reads too), whatever launched the circuit (alone, in a queue, by another
44
- // session), and writes each one, its ticket, step, question and the command that answers it;
45
- // the end of its task wakes the session, which spends nothing while it waits (grillhouse-pq6:
51
+ // session): its ticket, step, question and the command that answers it (grillhouse-pq6:
46
52
  // SyntHub's SH-ae6.5.2, SH-ae6.5.6 and SH-br0.1.5, launched by a queue, waited hours on their
47
53
  // question). The stops gone up, by a wait or named at the opening, are kept in
48
54
  // `.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
52
- // questions, 1 when another wait already runs (`.claude/worktrees/attente-des-questions.lock`).
53
- import { spawnSync } from 'node:child_process';
54
- import { mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
55
+ // the rank of its question in that run and its stop: one never wakes the session twice before
56
+ // its re-presentation, a session closed then opened again finds every one that waits, and one
57
+ // answered leaves them. The end of a circuit wakes it too: a stop as a question; a circuit
58
+ // integrated once (`integre`), its end after the last reading of the previous wait, kept in
59
+ // `.claude/worktrees/integrations-rendues.json` (the opening sets it to its own time), so that
60
+ // an integration between two waits is not lost. Exit 0 on its batch, 1 when another wait
61
+ // already runs (`.claude/worktrees/attente-des-questions.lock`, which names its process: the
62
+ // presence of the wait that the board and the hooks read).
63
+ import { execFile, spawnSync } from 'node:child_process';
64
+ import { promisify } from 'node:util';
65
+ import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
55
66
  import path from 'node:path';
56
67
  import { pathToFileURL } from 'node:url';
57
68
  import { lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
@@ -66,6 +77,7 @@ import {
66
77
  verrouDeLAttente,
67
78
  } from './tableau.mjs';
68
79
  import { etapeDuCircuit, libelle, SUPERVISEUR } from './etapes.mjs';
80
+ import { enFileSansArchitecture, lireLesTickets } from './file-des-tickets.mjs';
69
81
 
70
82
  const VERROU_SUPERVISEUR = 'grillhouse-superviseur.lock';
71
83
  const COQUILLES = new Set(['sh', 'bash', 'dash', 'zsh']);
@@ -131,6 +143,112 @@ const ou = c => {
131
143
  const etatsDe = racine => path.join(racine, '.claude', 'worktrees');
132
144
  export { verrouDeLAttente };
133
145
 
146
+ // The integrations given by the waits of the repository at <racine>: `depuis`, the time (ms) of
147
+ // the last reading of the last wait, from which an integration is new; `rendues`, the keys of the
148
+ // integrations it gave, ended at that time or after. Absent or unreadable: none since <maintenant>.
149
+ const integrationsDe = racine => path.join(etatsDe(racine), 'integrations-rendues.json');
150
+ function lireLesIntegrations(racine, maintenant) {
151
+ try {
152
+ const lu = JSON.parse(readFileSync(integrationsDe(racine), 'utf8'));
153
+ if (Number.isFinite(lu?.depuis) && Array.isArray(lu?.rendues)) {
154
+ return { depuis: lu.depuis, rendues: new Set(lu.rendues.map(String)) };
155
+ }
156
+ } catch {
157
+ // none yet
158
+ }
159
+ return { depuis: maintenant, rendues: new Set() };
160
+ }
161
+ // The tickets the queue reopened for a red workflow of main (label `flux-rouge`) that wait open, with
162
+ // the address of the run, which the title of the queue's comment (scripts/integration/file.mjs)
163
+ // gives in its second paragraph; none when bd does not read them.
164
+ export async function fluxRougesDe(racine) {
165
+ // A repository without its base of tickets has no ticket to give, and bd is never launched.
166
+ if (!existsSync(path.join(racine, '.beads'))) {
167
+ return [];
168
+ }
169
+ const bd = async (...a) =>
170
+ (
171
+ await promisify(execFile)('bd', a, {
172
+ cwd: racine,
173
+ encoding: 'utf8',
174
+ timeout: 5000,
175
+ maxBuffer: 64 * 1024 * 1024,
176
+ })
177
+ ).stdout;
178
+ try {
179
+ const l = JSON.parse(await bd('list', '--label', 'flux-rouge', '--status', 'open', '--json'));
180
+ const lots = await Promise.all(
181
+ l.map(async t => {
182
+ const dits = JSON.parse((await bd('comments', t.id, '--json')) || '[]');
183
+ const c = dits.findLast(x => String(x?.text ?? '').startsWith('## Flux de main rouge'));
184
+ return c ? [{ ticket: t.id, adresse: String(c.text).split('\n\n')[1] ?? '' }] : [];
185
+ })
186
+ );
187
+ return lots.flat();
188
+ } catch {
189
+ return [];
190
+ }
191
+ }
192
+
193
+ // The red workflows of main given by the waits of the repository at <racine>, `ticket adresse` keys:
194
+ // those that still stand are kept, so that one is given once and again at another run.
195
+ const fluxRougesRendus = racine => path.join(etatsDe(racine), 'flux-rouges-rendus.json');
196
+ function lireLesFluxRougesRendus(racine) {
197
+ try {
198
+ const lu = JSON.parse(readFileSync(fluxRougesRendus(racine), 'utf8'));
199
+ return new Set(Array.isArray(lu?.rendus) ? lu.rendus.map(String) : []);
200
+ } catch {
201
+ return new Set();
202
+ }
203
+ }
204
+ function ecrireLesFluxRougesRendus(racine, cles) {
205
+ const f = fluxRougesRendus(racine);
206
+ try {
207
+ mkdirSync(path.dirname(f), { recursive: true });
208
+ const provisoire = `${f}.${process.pid}`;
209
+ writeFileSync(provisoire, `${JSON.stringify({ rendus: [...cles].sort() })}\n`);
210
+ renameSync(provisoire, f);
211
+ } catch {
212
+ // kept as it was
213
+ }
214
+ }
215
+
216
+ // The batch of the tickets reopened by a red workflow of main among <rouges> and not yet given, as
217
+ // questions sorted by ticket; the file of those given keeps the ones that stand.
218
+ function releverLesFluxRouges(racine, rouges) {
219
+ const cleDuRouge = r => `${r.ticket} ${r.adresse}`;
220
+ const avant = lireLesFluxRougesRendus(racine);
221
+ const debout = new Set(rouges.map(cleDuRouge));
222
+ const neufs = rouges.filter(r => !avant.has(cleDuRouge(r)));
223
+ if (neufs.length || debout.size !== avant.size || [...debout].some(k => !avant.has(k))) {
224
+ ecrireLesFluxRougesRendus(racine, debout);
225
+ }
226
+ return neufs
227
+ .sort((a, b) => a.ticket.localeCompare(b.ticket, 'en'))
228
+ .map(r => ({
229
+ ticket: r.ticket,
230
+ etape: '5 Intégration',
231
+ question: `un flux de main est rouge après l'entrée de son lot, le ticket est rouvert : ${r.adresse}`,
232
+ qui: SUPERVISEUR,
233
+ commande: `bd show ${r.ticket}`,
234
+ cle: `flux-rouge ${cleDuRouge(r)}`,
235
+ adresse: r.adresse,
236
+ }));
237
+ }
238
+
239
+ // A file that cannot be written never costs the batch: the next wait reads the former one.
240
+ function ecrireLesIntegrations(racine, depuis, rendues) {
241
+ const f = integrationsDe(racine);
242
+ try {
243
+ mkdirSync(path.dirname(f), { recursive: true });
244
+ const provisoire = `${f}.${process.pid}`;
245
+ writeFileSync(provisoire, `${JSON.stringify({ depuis, rendues: [...rendues].sort() })}\n`);
246
+ renameSync(provisoire, f);
247
+ } catch {
248
+ // kept as it was
249
+ }
250
+ }
251
+
134
252
  // The stops gone up of the repository at <racine>, its circuits <circuits> read, under the lock of
135
253
  // their file, at <maintenant> ms. Each stop that waits for the supervisor and never went up, or
136
254
  // whose last presentation is <rappelMs> ms old or more (<toutes>: every one), is given, its ticket
@@ -214,6 +332,17 @@ const enQuestion = c => ({
214
332
  arret: c.arret,
215
333
  });
216
334
 
335
+ // The end of the circuit <c> integrated, given once by the wait: its ticket, its step, and its key.
336
+ const enFin = c => ({
337
+ ticket: c.ticket,
338
+ etape: '5 Intégration',
339
+ question: 'son lot est sur main.',
340
+ qui: SUPERVISEUR,
341
+ commande: '',
342
+ cle: cleDe(c),
343
+ integre: true,
344
+ });
345
+
217
346
  // Of the circuits <lus> of the repository at <racine>, those whose ticket <fermes> does not give
218
347
  // closed, sorted by ticket.
219
348
  function enAttente(lus, racine, fermes) {
@@ -259,29 +388,36 @@ const aucunFerme = () => new Set();
259
388
 
260
389
  /**
261
390
  * The wait of the session of supervision of the repository at <racine> (`npx grillhouse
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>}
391
+ * superviseur --attendre`): the first batch of questions, given as soon as one is due, after
392
+ * which the wait ends; the session launches it again once the batch is dealt with. A batch holds
393
+ * each question that waits for the supervisor (`questionsEnAttente`), whatever launched its
394
+ * circuit, once it never went up, and again, marked `representee`, every <rappel> minutes (5 by
395
+ * default) while its circuit stands on the same stop, as SQS gives a message not acknowledged
396
+ * again after its visibility timeout; a question answered (its circuit left the stop) leaves those
397
+ * gone up and is not given again. A stop whose key changes is a new question, given at once. The
398
+ * end of a circuit integrated after the last reading of the previous wait (the file of the
399
+ * integrations given; none, the start of this one) is given once, marked `integre`, never again
400
+ * (the circuits integrated read too, by `{ integres: true }`); the supervisor's own « arrete » is
401
+ * never one. The times are those of <maintenant> (`Date.now` by default). It reads the circuits
402
+ * every <pas> ms by <circuitsDe> (one call to the Temporal server, scripts/circuits-du-serveur.mjs,
403
+ * by default), as the UI of Temporal refreshes its list; a reading that fails (the server down) is
404
+ * tried again at the next step, the questions gone up kept. One wait at a time per repository: a
405
+ * second one is refused while the first runs. Its <signal> ends it with an empty batch. A ticket
406
+ * the queue reopened for a red workflow of main (label `flux-rouge`, waiting open, read by
407
+ * <fluxRouges>: bd by default) is given as a batch of its own, once per run (`adresse`: the
408
+ * workflow, the URL of the run, the commit), and again at another run; taken up or closed, it is
409
+ * no longer given.
410
+ * @param {{ racine: string, fermes?: (racine: string, ids: string[]) => Set<string>, pas?: number, signal?: AbortSignal, circuitsDe?: (racine: string, options?: { integres?: boolean }) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]>, fluxRouges?: (racine: string) => { ticket: string, adresse: string }[] | Promise<{ ticket: string, adresse: string }[]>, maintenant?: () => number, rappel?: number }} options
411
+ * @returns {Promise<{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string, representee?: boolean, integre?: boolean }[]>}
277
412
  * @throws {Error} another wait runs
278
413
  */
279
- export async function* attendreUneQuestion({
414
+ export async function attendreUneQuestion({
280
415
  racine,
281
416
  fermes = ticketsFermes,
282
417
  pas = 5_000,
283
418
  signal,
284
419
  circuitsDe = circuitsDuServeur,
420
+ fluxRouges = fluxRougesDe,
285
421
  maintenant = Date.now,
286
422
  rappel = RAPPEL_PAR_DEFAUT,
287
423
  }) {
@@ -298,26 +434,74 @@ export async function* attendreUneQuestion({
298
434
  `Une attente des questions tourne déjà pour ce dépôt${qui}, ${verrou} : une seule à la fois.`
299
435
  );
300
436
  }
437
+ // The integrations new since the last reading of the previous wait, each given once.
438
+ const { depuis: debut, rendues } = lireLesIntegrations(racine, maintenant());
439
+ let lue = debut;
440
+ let lectureDesRouges = null;
441
+ let rougesLus = null;
301
442
  try {
302
443
  while (!signal?.aborted) {
444
+ const avant = maintenant();
303
445
  let circuits = null;
446
+ // Read beside the circuits, never awaited: a slow bd never delays a step, and a reading not
447
+ // yet ended is taken at the next one.
448
+ lectureDesRouges ??= Promise.resolve()
449
+ .then(() => fluxRouges(racine))
450
+ .then(
451
+ r => (rougesLus = Array.isArray(r) ? r : []),
452
+ () => (rougesLus = [])
453
+ );
304
454
  try {
305
- circuits = await circuitsDe(racine);
455
+ circuits = await circuitsDe(racine, { integres: true });
306
456
  } catch {
307
457
  circuits = null;
308
458
  }
459
+ await new Promise(resolve => setImmediate(resolve));
460
+ let rouges = [];
461
+ if (rougesLus) {
462
+ rouges = releverLesFluxRouges(racine, rougesLus);
463
+ rougesLus = null;
464
+ lectureDesRouges = null;
465
+ }
466
+ if (signal?.aborted) {
467
+ break;
468
+ }
469
+ if (rouges.length && !circuits) {
470
+ return rouges;
471
+ }
309
472
  if (circuits && !signal?.aborted) {
310
- const lot = relever(racine, circuits, {
311
- fermes,
312
- maintenant: maintenant(),
313
- rappelMs: rappel * 60_000,
314
- });
473
+ lue = avant;
474
+ const integres = circuits
475
+ .filter(c => c.integre && c.fin !== null && c.fin >= debut && !rendues.has(cleDe(c)))
476
+ .map(enFin);
477
+ const lot = [
478
+ ...relever(
479
+ racine,
480
+ circuits.filter(c => !c.integre),
481
+ {
482
+ fermes,
483
+ maintenant: maintenant(),
484
+ rappelMs: rappel * 60_000,
485
+ }
486
+ ),
487
+ ...integres,
488
+ ...rouges,
489
+ ];
315
490
  if (lot.length) {
316
- yield lot;
491
+ // The integrations given, those ended since this reading kept, so that the next wait
492
+ // gives none of them again.
493
+ const fins = new Map(circuits.map(c => [cleDe(c), c.fin]));
494
+ ecrireLesIntegrations(
495
+ racine,
496
+ lue,
497
+ [...rendues, ...integres.map(i => i.cle)].filter(k => (fins.get(k) ?? -Infinity) >= lue)
498
+ );
499
+ return lot;
317
500
  }
318
501
  }
319
502
  await attendre(pas, signal);
320
503
  }
504
+ return [];
321
505
  } finally {
322
506
  lacherVerrou(verrou);
323
507
  }
@@ -334,31 +518,53 @@ const attendre = (ms, signal) =>
334
518
  signal?.addEventListener('abort', fin, { once: true });
335
519
  });
336
520
 
521
+ // The relaunch of the wait, which ends on each batch: the last line of a batch.
522
+ const RELANCE =
523
+ "Ce lot traité, relance l'attente en arrière-plan (`run_in_background`), sans tube ni veille à durée : `npx grillhouse superviseur --attendre`. Sa fin te réveille au lot suivant.";
524
+
337
525
  /**
338
526
  * The text that wakes the session of supervision on the questions <questions>: for each one, its
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
527
+ * ticket, step, who must answer it, its question and the command that answers it; then each end of
528
+ * a circuit integrated (`integre`), its ticket and its step; last, the wait to launch again once
529
+ * the batch is dealt with, since the wait ended on it. A question presented again (`representee`)
530
+ * says that it still waits for an answer.
531
+ * @param {{ ticket: string, etape: string, question: string, qui: string, commande: string, representee?: boolean, integre?: boolean }[]} questions
343
532
  * @returns {string}
344
533
  */
345
534
  export function texteDesQuestions(questions) {
346
- const neuves = questions.filter(q => !q.representee);
535
+ const fins = questions.filter(q => q.integre);
536
+ const attente = questions.filter(q => !q.integre);
537
+ const neuves = attente.filter(q => !q.representee);
347
538
  const titre = neuves.length
348
- ? questions.length > 1
539
+ ? attente.length > 1
349
540
  ? '## Questions neuves des circuits'
350
541
  : "## Question neuve d'un circuit"
351
- : questions.length > 1
542
+ : attente.length > 1
352
543
  ? '## Questions toujours sans réponse'
353
544
  : '## Question toujours sans réponse';
545
+ const enQuestions = attente.length
546
+ ? [
547
+ titre,
548
+ ...attente.map(q =>
549
+ [
550
+ `- ${q.ticket}, à ${q.etape}, au ${q.qui}${q.representee ? ' (toujours sans réponse)' : ''} : ${q.question.replace(/\n/g, '\n ')}`,
551
+ ` La réponse : \`${q.commande}\`.`,
552
+ ].join('\n')
553
+ ),
554
+ ]
555
+ : [];
556
+ const enFins = fins.length
557
+ ? [
558
+ fins.length > 1 ? '## Circuits intégrés' : '## Circuit intégré',
559
+ ...fins.map(q => `- ${q.ticket} est intégré, à ${q.etape} : son lot est sur main.`),
560
+ ]
561
+ : [];
354
562
  return [
355
- titre,
356
- ...questions.map(q =>
357
- [
358
- `- ${q.ticket}, à ${q.etape}, au ${q.qui}${q.representee ? ' (toujours sans réponse)' : ''} : ${q.question.replace(/\n/g, '\n ')}`,
359
- ` La réponse : \`${q.commande}\`.`,
360
- ].join('\n')
361
- ),
563
+ ...enQuestions,
564
+ ...(enQuestions.length && enFins.length ? [''] : []),
565
+ ...enFins,
566
+ '',
567
+ RELANCE,
362
568
  ].join('\n');
363
569
  }
364
570
 
@@ -369,18 +575,22 @@ export function texteDesQuestions(questions) {
369
575
  * those whose ticket <fermes> gives closed left out: each one that runs, named; each one stopped on
370
576
  * a question (a stop other than the supervisor's own « arrete »), with its question and the command
371
577
  * that answers it; each one ended without its issue, with the command that resumes it. The
372
- * stopped and the ended ones are then gone up: the wait does not give them again.
578
+ * stopped and the ended ones are then gone up: the wait does not give them again. Last, « ## La
579
+ * file des tickets » names the tickets of the queue without their section « ## Architecture »
580
+ * (`enFileSansArchitecture` of scripts/file-des-tickets.mjs, the tickets read by <ticketsDe>,
581
+ * `lireLesTickets` by default; a Beads that fails says nothing), which the queue never starts.
373
582
  * @param {string} racine the root of the repository
374
583
  * The circuits are read once, by <circuitsDe> (one call to the Temporal server,
375
584
  * scripts/circuits-du-serveur.mjs, by default); a server that does not answer is said, and no
376
585
  * question goes up.
377
586
  * @param {{ fermes?: (racine: string, ids: string[]) => Set<string>,
378
- * circuitsDe?: (racine: string) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]> }} options
587
+ * circuitsDe?: (racine: string) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]>,
588
+ * ticketsDe?: (racine: string) => import('./file-des-tickets.mjs').TicketDeBeads[] }} options
379
589
  * @returns {Promise<string>}
380
590
  */
381
591
  export async function circuitsALOuverture(
382
592
  racine,
383
- { fermes = ticketsFermes, circuitsDe = circuitsDuServeur } = {}
593
+ { fermes = ticketsFermes, circuitsDe = circuitsDuServeur, ticketsDe = lireLesTickets } = {}
384
594
  ) {
385
595
  let circuits = null;
386
596
  let panne = null;
@@ -393,6 +603,7 @@ export async function circuitsALOuverture(
393
603
  ? `${e.message} : les circuits ne se lisent pas.`
394
604
  : `Les circuits ne se lisent pas : ${message}.`;
395
605
  }
606
+ ecrireLesIntegrations(racine, Date.now(), []);
396
607
  const questions = circuits
397
608
  ? relever(racine, circuits, {
398
609
  fermes,
@@ -415,14 +626,29 @@ export async function circuitsALOuverture(
415
626
  ` La réponse : \`${q.commande}\`.`,
416
627
  ].join('\n'),
417
628
  });
629
+ let sansArchitecture = [];
630
+ try {
631
+ sansArchitecture = enFileSansArchitecture(ticketsDe(racine), {
632
+ enCours: new Set((circuits ?? []).map(c => c.ticket)),
633
+ }).map(t => t.id);
634
+ } catch {
635
+ // Beads fails: the board says it, the opening names no ticket.
636
+ }
418
637
  const nommes = [...tournent, ...questions.map(enLigne)].sort((a, b) =>
419
638
  a.ticket.localeCompare(b.ticket, 'en')
420
639
  );
421
640
  return [
422
641
  "## L'attente des questions",
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.",
642
+ "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`), sans tube ni veille à durée : `npx grillhouse superviseur --attendre`. Elle imprime un lot (une question neuve d'un circuit, quel que soit son lanceur, une fin de circuit) et se termine : sa fin te réveille. Relance-la après chaque lot traité. 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 ; la fin d'un circuit te réveille aussi, un arrêt comme une question, une intégration une fois. Tu ne te mets pas en attente du responsable tant qu'une question d'un circuit attend ta réponse, ni tant qu'un circuit tourne sans attente vivante : le crochet de fin de tour te le rappelle.",
424
643
  ...(panne ? ['', '## Les circuits du dépôt', panne] : []),
425
644
  ...(nommes.length ? ['', '## Les circuits du dépôt', ...nommes.map(n => n.ligne)] : []),
645
+ ...(sansArchitecture.length
646
+ ? [
647
+ '',
648
+ '## La file des tickets',
649
+ `En file sans architecture : ${sansArchitecture.join(', ')}. La file ne démarre pas un ticket sans la section « ## Architecture » de sa description : écris-la (le modèle mûr, l'adresse, le mécanisme commun), puis la file le démarre.`,
650
+ ]
651
+ : []),
426
652
  ].join('\n');
427
653
  }
428
654
 
@@ -500,13 +726,11 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
500
726
  }
501
727
  args.splice(i, 2);
502
728
  }
503
- for await (const questions of attendreUneQuestion({
729
+ const lot = await attendreUneQuestion({
504
730
  racine: racineDe(args[0] ?? process.cwd()),
505
731
  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
- }
732
+ });
733
+ process.stdout.write(`${texteDesQuestions(lot)}\n`);
510
734
  } catch (e) {
511
735
  process.stderr.write(`${e.message}\n`);
512
736
  process.exitCode = 1;