@roomi-fields/grillhouse 0.45.0 → 0.46.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 (80) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +46 -0
  3. package/cadre/templates/projet/.github/workflows/machine-vierge.yml +101 -0
  4. package/cadre/templates/projet/CLAUDE.md +22 -5
  5. package/charte.md +45 -15
  6. package/dist/temporal/circuit/appel.d.ts +7 -0
  7. package/dist/temporal/circuit/appel.js +17 -0
  8. package/dist/temporal/circuit/appel.js.map +1 -1
  9. package/dist/temporal/circuit/client.d.ts +14 -0
  10. package/dist/temporal/circuit/client.js +17 -4
  11. package/dist/temporal/circuit/client.js.map +1 -1
  12. package/dist/temporal/circuit/commande.js +16 -4
  13. package/dist/temporal/circuit/commande.js.map +1 -1
  14. package/dist/temporal/circuit/contrat.d.ts +22 -2
  15. package/dist/temporal/circuit/contrat.js +76 -0
  16. package/dist/temporal/circuit/contrat.js.map +1 -1
  17. package/dist/temporal/circuit/deroule.js +68 -11
  18. package/dist/temporal/circuit/deroule.js.map +1 -1
  19. package/dist/temporal/commande.js +3 -0
  20. package/dist/temporal/commande.js.map +1 -1
  21. package/dist/temporal/file/contrat.d.ts +2 -0
  22. package/dist/temporal/installation.d.ts +5 -0
  23. package/dist/temporal/installation.js +23 -15
  24. package/dist/temporal/installation.js.map +1 -1
  25. package/dist/temporal/tickets/activites.d.ts +1 -0
  26. package/dist/temporal/tickets/activites.js +37 -2
  27. package/dist/temporal/tickets/activites.js.map +1 -1
  28. package/dist/temporal/tickets/contrat.d.ts +14 -0
  29. package/dist/temporal/tickets/deroule.js +16 -3
  30. package/dist/temporal/tickets/deroule.js.map +1 -1
  31. package/docs/ARCHITECTURE.md +204 -55
  32. package/docs/INTERFACE.md +8 -5
  33. package/hooks/register.tsx +30 -0
  34. package/package.json +1 -1
  35. package/scripts/activites.mjs +64 -15
  36. package/scripts/attente-a-l-arret.mjs +29 -52
  37. package/scripts/attente-au-tour.mjs +8 -26
  38. package/scripts/circuit.mjs +204 -64
  39. package/scripts/circuits-cles.d.mts +9 -0
  40. package/scripts/circuits-cles.mjs +38 -0
  41. package/scripts/coeurs-dedies.mjs +4 -3
  42. package/scripts/dernier-vert.mjs +66 -2
  43. package/scripts/enveloppe/travail-de-la-copie.mjs +5 -2
  44. package/scripts/etapes.mjs +6 -1
  45. package/scripts/faits-du-circuit.mjs +22 -3
  46. package/scripts/fichiers-nommes.mjs +55 -0
  47. package/scripts/file-des-tickets.d.mts +17 -0
  48. package/scripts/file-des-tickets.mjs +39 -0
  49. package/scripts/grillhouse-maj.mjs +20 -1
  50. package/scripts/integration/file.mjs +11 -5
  51. package/scripts/integration/integrer.mjs +4 -2
  52. package/scripts/langages/cargo/clippy.mjs +16 -9
  53. package/scripts/langages/cargo/commandes.mjs +7 -2
  54. package/scripts/langages/cargo/sccache.mjs +19 -6
  55. package/scripts/langages/typescript/tests.mjs +31 -5
  56. package/scripts/langages/typescript/turbo-des-paquets.mjs +51 -3
  57. package/scripts/langages/typescript/vitest-config/changements.mjs +32 -3
  58. package/scripts/langages/typescript/vitest-config/lances.mjs +16 -0
  59. package/scripts/limite-d-usage.mjs +88 -0
  60. package/scripts/outils-cles.d.mts +13 -5
  61. package/scripts/outils-cles.mjs +157 -17
  62. package/scripts/passe-de-la-machine.mjs +26 -2
  63. package/scripts/places-de-la-machine.mjs +52 -6
  64. package/scripts/plafond-de-la-machine.d.mts +10 -2
  65. package/scripts/plafond-de-la-machine.mjs +39 -13
  66. package/scripts/reponses-du-circuit.d.mts +16 -0
  67. package/scripts/reponses-du-circuit.mjs +39 -3
  68. package/scripts/resultats.mjs +32 -11
  69. package/scripts/seances.mjs +211 -59
  70. package/scripts/session-start.sh +2 -2
  71. package/scripts/sous-commandes.mjs +5 -2
  72. package/scripts/superviseur.mjs +178 -226
  73. package/scripts/tableau.mjs +50 -37
  74. package/scripts/transitions.d.mts +22 -1
  75. package/scripts/transitions.mjs +111 -13
  76. package/scripts/workflows-du-cadre.mjs +21 -1
  77. package/skills/explorateur/SKILL.md +34 -13
  78. package/skills/pitmaster/SKILL.md +24 -20
  79. package/skills/relecteur/SKILL.md +6 -0
  80. package/skills/testwriter/SKILL.md +4 -0
@@ -19,11 +19,11 @@
19
19
  // since when it holds the lock, and asks to say so to the owner and to launch no circuit
20
20
  // (skill pitmaster, « Au lancement de la séance »).
21
21
  // - The session whose opening takes the lock (not one that keeps it) receives
22
- // (`circuitsALOuverture`) the section « ## L'attente des questions », which asks it to launch the
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 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
22
+ // (`circuitsALOuverture`) the section « ## Les questions des circuits », which says that the
23
+ // greffon of the session pushes the questions into its queue of messages and that the answer
24
+ // acknowledges them, then, when the repository has some (read from the Temporal server in one
25
+ // call, scripts/circuits-du-serveur.mjs), « ## Les circuits du dépôt »: each circuit that runs,
26
+ // named; each circuit stopped on a question, with its question and the command that answers it; each
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
@@ -31,35 +31,31 @@
31
31
  // tickets », the tickets of the queue without their section « ## Architecture », which the
32
32
  // queue never starts (scripts/file-des-tickets.mjs), for the supervisor to write it. A circuit
33
33
  // runs on the worker of the project, apart from the sessions, its launch returns at once, and its
34
- // question wakes the supervisor by the wait alone (grillhouse-mwz: SyntHub's SH-br0.1 stopped
35
- // 27 s after a relaunch of its session, read only on a word of the owner). The queue of the
34
+ // question reaches the supervisor by the push of the greffon (below). The queue of the
36
35
  // tickets under Temporal (src/temporal/tickets/) launches the tickets `circuit`, not the opening.
37
36
  // Exit 0, whatever it finds.
38
37
  //
39
- // npx grillhouse superviseur --attendre [<dossier>]
38
+ // npx grillhouse superviseur --relever [<dossier>]
40
39
  //
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,
50
- // which the opening reads too), whatever launched the circuit (alone, in a queue, by another
51
- // session): its ticket, step, question and the command that answers it (grillhouse-pq6:
52
- // SyntHub's SH-ae6.5.2, SH-ae6.5.6 and SH-br0.1.5, launched by a queue, waited hours on their
53
- // question). The stops gone up, by a wait or named at the opening, are kept in
54
- // `.claude/worktrees/questions-remontees.json`, each one by its ticket, the run of its workflow,
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).
40
+ // - One reading of the circuits for the greffon of the session of supervision (mods/grillhouse/
41
+ // hooks/register.tsx), which runs it at each period and submits what it writes to the session,
42
+ // in the queue of its messages (`$.prompt.submit`): the questions of a circuit are given as a
43
+ // queue gives its messages, and the answer acknowledges them. It reads nothing and writes
44
+ // nothing unless the session that runs it holds the lock of the supervisor (the one above). It
45
+ // writes the message of the reading (`texteDesQuestions`) when `relever` gives something,
46
+ // nothing otherwise; exit 1 and the fault on the error stream when `grillhouse.rappel` is at
47
+ // fault. A reading is one reading: no process waits.
48
+ // - `relever` is the one function of the reading, of the re-presentation and of the file of the
49
+ // stops gone up: each question of a circuit that never went up or whose last presentation is
50
+ // <rappelMs> old (`grillhouse.rappel` minutes, 5 by default, scripts/circuits-cles.mjs) is given,
51
+ // once per due time, whatever the state of the session, while its circuit stands on the same stop,
52
+ // as SQS gives a message not acknowledged again after its visibility timeout; one answered (its
53
+ // circuit left the stop) leaves the file `.claude/worktrees/questions-remontees.json` and is not
54
+ // given again. The stops are kept there each by its ticket, the run of its workflow, the rank of
55
+ // its question in that run and its stop, with the time of the first going up and of the last
56
+ // presentation. The end of a circuit integrated is given once (`integre`), kept in
57
+ // `.claude/worktrees/integrations-rendues.json`, and a ticket the queue reopened for a red
58
+ // workflow of main once per run (`.claude/worktrees/flux-rouges-rendus.json`).
63
59
  import { execFile, spawnSync } from 'node:child_process';
64
60
  import { promisify } from 'node:util';
65
61
  import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
@@ -72,10 +68,9 @@ import {
72
68
  attendLeSuperviseur,
73
69
  cleDe,
74
70
  lireLesRemontees,
75
- RAPPEL_PAR_DEFAUT,
76
71
  remonteesDe,
77
- verrouDeLAttente,
78
72
  } from './tableau.mjs';
73
+ import { rappelDuProjet, reglageDuRappel } from './circuits-cles.mjs';
79
74
  import { etapeDuCircuit, libelle, SUPERVISEUR } from './etapes.mjs';
80
75
  import { enFileSansArchitecture, lireLesTickets } from './file-des-tickets.mjs';
81
76
 
@@ -111,6 +106,23 @@ function seance(depart = process.ppid) {
111
106
  return depart;
112
107
  }
113
108
 
109
+ // Whether the process <pid> is above this one: the session that runs the command, whatever the
110
+ // processes between them (the `grillhouse` command's own, a shell).
111
+ function estAuDessus(pid) {
112
+ let courant = process.ppid;
113
+ for (let i = 0; i < 32 && courant > 1; i++) {
114
+ if (courant === pid) {
115
+ return true;
116
+ }
117
+ const p = processus(courant);
118
+ if (!p) {
119
+ return false;
120
+ }
121
+ courant = p.parent;
122
+ }
123
+ return false;
124
+ }
125
+
114
126
  // The time in ms of <texte>, a `defer_until` as Beads writes it: the local wall time of the
115
127
  // machine, followed by a « Z » it does not mean (`bd update --defer 17:30` gives `…T17:30:00Z`);
116
128
  // NaN without one.
@@ -156,11 +168,9 @@ const ou = c => {
156
168
  return e ? libelle(e) : c.etape;
157
169
  };
158
170
 
159
- // The file of the stops gone up to the session of supervision (`remonteesDe`) and the lock of its
160
- // one wait (`verrouDeLAttente`) are beside the states of the circuits (scripts/tableau.mjs reads
161
- // both: its alerts).
171
+ // The file of the stops gone up to the session of supervision (`remonteesDe`) is beside the states
172
+ // of the circuits (scripts/tableau.mjs reads it: its alerts).
162
173
  const etatsDe = racine => path.join(racine, '.claude', 'worktrees');
163
- export { verrouDeLAttente };
164
174
 
165
175
  // The integrations given by the waits of the repository at <racine>: `depuis`, the time (ms) of
166
176
  // the last reading of the last wait, from which an integration is new; `rendues`, the keys of the
@@ -269,20 +279,49 @@ function ecrireLesIntegrations(racine, depuis, rendues) {
269
279
  }
270
280
  }
271
281
 
272
- // The stops gone up of the repository at <racine>, its circuits <circuits> read, under the lock of
273
- // their file, at <maintenant> ms. Each stop that waits for the supervisor and never went up, or
274
- // whose last presentation is <rappelMs> ms old or more (<toutes>: every one), is given, its ticket
275
- // <fermes> gives closed left out (bd is asked of those alone); a stop given is presented now, and
276
- // one that goes up has its `depuis` set now. The file is written whole with the stops that still
277
- // stand, their circuit waiting for the supervisor: a question answered so leaves it. The `rendu`
278
- // is the questions given, each marked `representee` when it comes back.
279
- function relever(racine, circuits, { fermes, maintenant, rappelMs, toutes = false }) {
282
+ /**
283
+ * One reading of the circuits <circuits> (those integrated included) of the repository at <racine>,
284
+ * at <maintenant> ms, under the lock of the file of the stops gone up; what the greffon of the
285
+ * session of supervision submits, and the opening lists. Each stop that waits for the supervisor
286
+ * and never went up, or whose last presentation is <rappelMs> ms old or more (<toutes>: every
287
+ * one), is given, its ticket <fermes> gives closed left out (bd is asked of those alone); a stop
288
+ * given is presented now, and one that goes up has its `depuis` set now. The file is written whole
289
+ * with the stops that still stand, their circuit waiting for the supervisor: a question answered
290
+ * so leaves it, and the next stop of its circuit is new. The end of a circuit integrated since the
291
+ * last reading is given once (`integre`; the file of the integrations holds the time of that
292
+ * reading), and each ticket of <fluxRouges> (the tickets the queue reopened for a red workflow of
293
+ * main, `{ ticket, adresse }`; null when bd does not read them, undefined when they are not read)
294
+ * once per run (`adresse`). The result is the questions given, each marked `representee` when it
295
+ * comes back, then the ends, then the reds.
296
+ * @param {string} racine
297
+ * @param {import('./circuits-du-serveur.mjs').CircuitDuServeur[]} circuits
298
+ * @param {{ fermes: (racine: string, ids: string[]) => Set<string> | null, maintenant: number, rappelMs: number, toutes?: boolean, fluxRouges?: { ticket: string, adresse: string }[] | null }} options
299
+ * @returns {{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string, representee?: boolean, integre?: boolean, adresse?: string }[]}
300
+ */
301
+ export function relever(
302
+ racine,
303
+ circuits,
304
+ { fermes, maintenant, rappelMs, toutes = false, fluxRouges }
305
+ ) {
280
306
  const f = remonteesDe(racine);
281
307
  mkdirSync(path.dirname(f), { recursive: true });
282
308
  const verrou = `${f}.verrou`;
283
309
  // Held for one reading of the circuits: older than that, abandoned.
284
310
  prendreVerrou(verrou, { attendre: true, perime: 30_000 });
285
311
  try {
312
+ const { depuis: depuisIntegrations, rendues } = lireLesIntegrations(racine, maintenant);
313
+ const integres = circuits
314
+ .filter(c => c.integre && c.fin !== null && c.fin >= depuisIntegrations && !rendues.has(cleDe(c)))
315
+ .map(enFin)
316
+ .sort((a, b) => a.ticket.localeCompare(b.ticket, 'en'));
317
+ const fins = new Map(circuits.map(c => [cleDe(c), c.fin]));
318
+ ecrireLesIntegrations(
319
+ racine,
320
+ maintenant,
321
+ [...rendues, ...integres.map(i => i.cle)].filter(k => (fins.get(k) ?? -Infinity) >= maintenant)
322
+ );
323
+ const rouges = Array.isArray(fluxRouges) ? releverLesFluxRouges(racine, fluxRouges) : [];
324
+ circuits = circuits.filter(c => !c.integre);
286
325
  const avant = new Map(lireLesRemontees(racine, maintenant).map(r => [r.cle, r]));
287
326
  const debout = questionsEnAttente(racine, circuits, { fermes: aucunFerme });
288
327
  const aRendre = debout.filter(q => {
@@ -303,7 +342,9 @@ function relever(racine, circuits, { fermes, maintenant, rappelMs, toutes = fals
303
342
  .filter(q => !fermesDe.has(q.ticket))
304
343
  .map(q => (avant.has(q.cle) && !toutes ? { ...q, representee: true } : q))
305
344
  : [];
306
- const presentes = new Set(lisible ? aRendre.map(q => q.cle) : []);
345
+ // A question whose ticket is closed is not given, so not counted presented: it is given once
346
+ // its ticket waits again.
347
+ const presentes = new Set(rendu.map(q => q.cle));
307
348
  const enTexte = liste =>
308
349
  `${JSON.stringify(
309
350
  {
@@ -338,7 +379,7 @@ function relever(racine, circuits, { fermes, maintenant, rappelMs, toutes = fals
338
379
  writeFileSync(provisoire, ecrit);
339
380
  renameSync(provisoire, f);
340
381
  }
341
- return rendu;
382
+ return [...rendu, ...integres, ...rouges];
342
383
  } finally {
343
384
  lacherVerrou(verrou);
344
385
  }
@@ -392,7 +433,7 @@ function enAttente(lus, racine, fermes) {
392
433
  /**
393
434
  * The questions that wait for the supervisor among the circuits <circuits> of the repository at
394
435
  * <racine> (scripts/circuits-du-serveur.mjs), the one source of the opening
395
- * (`circuitsALOuverture`) and of the wait (`attendreUneQuestion`), by the rule the board's
436
+ * (`circuitsALOuverture`) and of the reading (`relever`), by the rule the board's
396
437
  * « ⤷ Question » reads too (scripts/tableau.mjs `attendLeSuperviseur`): each circuit stopped on a
397
438
  * question (any stop but the supervisor's own « arrete », « à repasser » included) or ended
398
439
  * without its issue, those whose stop's key <sauf> holds left out, then those whose ticket
@@ -418,152 +459,20 @@ export function questionsEnAttente(
418
459
  // No ticket closed: the questions read without asking bd.
419
460
  const aucunFerme = () => new Set();
420
461
 
421
- /**
422
- * The wait of the session of supervision of the repository at <racine> (`npx grillhouse
423
- * superviseur --attendre`): the first batch of questions, given as soon as one is due, after
424
- * which the wait ends; the session launches it again once the batch is dealt with. A batch holds
425
- * each question that waits for the supervisor (`questionsEnAttente`), whatever launched its
426
- * circuit, once it never went up, and again, marked `representee`, every <rappel> minutes (5 by
427
- * default) while its circuit stands on the same stop, as SQS gives a message not acknowledged
428
- * again after its visibility timeout; a question answered (its circuit left the stop) leaves those
429
- * gone up and is not given again. A stop whose key changes is a new question, given at once. The
430
- * end of a circuit integrated after the last reading of the previous wait (the file of the
431
- * integrations given; none, the start of this one) is given once, marked `integre`, never again
432
- * (the circuits integrated read too, by `{ integres: true }`); the supervisor's own « arrete » is
433
- * never one. The times are those of <maintenant> (`Date.now` by default). It reads the circuits
434
- * every <pas> ms by <circuitsDe> (one call to the Temporal server, scripts/circuits-du-serveur.mjs,
435
- * by default), as the UI of Temporal refreshes its list; a reading that fails (the server down) is
436
- * tried again at the next step, the questions gone up kept. One wait at a time per repository: a
437
- * second one is refused while the first runs. Its <signal> ends it with an empty batch. A ticket
438
- * the queue reopened for a red workflow of main (label `flux-rouge`, waiting open, read by
439
- * <fluxRouges>: bd by default) is given as a batch of its own, once per run (`adresse`: the
440
- * workflow, the URL of the run, the commit), and again at another run; taken up or closed, it is
441
- * no longer given.
442
- * @param {{ racine: string, fermes?: (racine: string, ids: string[]) => Set<string> | null, pas?: number, signal?: AbortSignal, circuitsDe?: (racine: string, options?: { integres?: boolean }) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]>, fluxRouges?: (racine: string) => { ticket: string, adresse: string }[] | null | Promise<{ ticket: string, adresse: string }[] | null>, maintenant?: () => number, rappel?: number }} options
443
- * @returns {Promise<{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string, representee?: boolean, integre?: boolean }[]>}
444
- * @throws {Error} another wait runs
445
- */
446
- export async function attendreUneQuestion({
447
- racine,
448
- fermes = ticketsHorsAttente,
449
- pas = 5_000,
450
- signal,
451
- circuitsDe = circuitsDuServeur,
452
- fluxRouges = fluxRougesDe,
453
- maintenant = Date.now,
454
- rappel = RAPPEL_PAR_DEFAUT,
455
- }) {
456
- mkdirSync(etatsDe(racine), { recursive: true });
457
- const verrou = verrouDeLAttente(racine);
458
- if (!prendreVerrou(verrou, { attendre: false })) {
459
- let qui = '';
460
- try {
461
- qui = ` (processus ${/^(\d+)/.exec(readFileSync(verrou, 'utf8'))?.[1] ?? '?'})`;
462
- } catch {
463
- // the lock is gone meanwhile
464
- }
465
- throw new Error(
466
- `Une attente des questions tourne déjà pour ce dépôt${qui}, ${verrou} : une seule à la fois.`
467
- );
468
- }
469
- // The integrations new since the last reading of the previous wait, each given once.
470
- const { depuis: debut, rendues } = lireLesIntegrations(racine, maintenant());
471
- let lue = debut;
472
- let lectureDesRouges = null;
473
- // The reds read: undefined while the reading runs, null when it failed.
474
- let rougesLus;
475
- try {
476
- while (!signal?.aborted) {
477
- const avant = maintenant();
478
- let circuits = null;
479
- // Read beside the circuits, never awaited: a slow bd never delays a step, and a reading not
480
- // yet ended is taken at the next one.
481
- lectureDesRouges ??= Promise.resolve()
482
- .then(() => fluxRouges(racine))
483
- .then(
484
- r => (rougesLus = Array.isArray(r) ? r : null),
485
- () => (rougesLus = null)
486
- );
487
- try {
488
- circuits = await circuitsDe(racine, { integres: true });
489
- } catch {
490
- circuits = null;
491
- }
492
- await new Promise(resolve => setImmediate(resolve));
493
- let rouges = [];
494
- if (rougesLus !== undefined) {
495
- // A failed reading leaves the reds given as they are: the next one judges them.
496
- if (rougesLus) {
497
- rouges = releverLesFluxRouges(racine, rougesLus);
498
- }
499
- rougesLus = undefined;
500
- lectureDesRouges = null;
501
- }
502
- if (signal?.aborted) {
503
- break;
504
- }
505
- if (rouges.length && !circuits) {
506
- return rouges;
507
- }
508
- if (circuits && !signal?.aborted) {
509
- lue = avant;
510
- const integres = circuits
511
- .filter(c => c.integre && c.fin !== null && c.fin >= debut && !rendues.has(cleDe(c)))
512
- .map(enFin);
513
- const lot = [
514
- ...relever(
515
- racine,
516
- circuits.filter(c => !c.integre),
517
- {
518
- fermes,
519
- maintenant: maintenant(),
520
- rappelMs: rappel * 60_000,
521
- }
522
- ),
523
- ...integres,
524
- ...rouges,
525
- ];
526
- if (lot.length) {
527
- // The integrations given, those ended since this reading kept, so that the next wait
528
- // gives none of them again.
529
- const fins = new Map(circuits.map(c => [cleDe(c), c.fin]));
530
- ecrireLesIntegrations(
531
- racine,
532
- lue,
533
- [...rendues, ...integres.map(i => i.cle)].filter(k => (fins.get(k) ?? -Infinity) >= lue)
534
- );
535
- return lot;
536
- }
537
- }
538
- await attendre(pas, signal);
539
- }
540
- return [];
541
- } finally {
542
- lacherVerrou(verrou);
543
- }
544
- }
545
-
546
- // Waits <ms> ms, or until <signal> ends the wait.
547
- const attendre = (ms, signal) =>
548
- new Promise(resolve => {
549
- const fin = () => {
550
- clearTimeout(minuteur);
551
- resolve();
552
- };
553
- const minuteur = setTimeout(fin, ms);
554
- signal?.addEventListener('abort', fin, { once: true });
555
- });
556
-
557
- // The relaunch of the wait, which ends on each batch: the last line of a batch.
558
- const RELANCE =
559
- "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.";
462
+ // The lines of one question in the one rendering of the questions, shared by the message of the
463
+ // greffon, the opening and the hooks of the session.
464
+ export const ligneDeQuestion = q =>
465
+ [
466
+ `- ${q.ticket}, à ${q.etape}, au ${q.qui}${q.representee ? ' (toujours sans réponse)' : ''} : ${q.question.replace(/\n/g, '\n ')}`,
467
+ ` La réponse : \`${q.commande}\`.`,
468
+ ].join('\n');
560
469
 
561
470
  /**
562
- * The text that wakes the session of supervision on the questions <questions>: for each one, its
563
- * ticket, step, who must answer it, its question and the command that answers it; then each end of
564
- * a circuit integrated (`integre`), its ticket and its step; last, the wait to launch again once
565
- * the batch is dealt with, since the wait ended on it. A question presented again (`representee`)
566
- * says that it still waits for an answer.
471
+ * The message the greffon submits to the session of supervision for the questions <questions> of
472
+ * one reading (`relever`), and the lines of the opening: for each one, its ticket, step, who must
473
+ * answer it, its question and the command that answers it; then each end of a circuit integrated
474
+ * (`integre`), its ticket and its step. A question presented again (`representee`) says that it
475
+ * still waits for an answer.
567
476
  * @param {{ ticket: string, etape: string, question: string, qui: string, commande: string, representee?: boolean, integre?: boolean }[]} questions
568
477
  * @returns {string}
569
478
  */
@@ -581,12 +490,7 @@ export function texteDesQuestions(questions) {
581
490
  const enQuestions = attente.length
582
491
  ? [
583
492
  titre,
584
- ...attente.map(q =>
585
- [
586
- `- ${q.ticket}, à ${q.etape}, au ${q.qui}${q.representee ? ' (toujours sans réponse)' : ''} : ${q.question.replace(/\n/g, '\n ')}`,
587
- ` La réponse : \`${q.commande}\`.`,
588
- ].join('\n')
589
- ),
493
+ ...attente.map(ligneDeQuestion),
590
494
  ]
591
495
  : [];
592
496
  const enFins = fins.length
@@ -599,19 +503,19 @@ export function texteDesQuestions(questions) {
599
503
  ...enQuestions,
600
504
  ...(enQuestions.length && enFins.length ? [''] : []),
601
505
  ...enFins,
602
- '',
603
- RELANCE,
604
506
  ].join('\n');
605
507
  }
606
508
 
607
509
  /**
608
510
  * The section a session of supervision receives at its opening in <racine>, when it takes the lock:
609
- * the wait of the questions to launch in the background (`npx grillhouse superviseur --attendre`),
610
- * the one way a question of a circuit wakes the session; then the circuits of the repository,
511
+ * what the greffon does (it pushes the questions into the queue of the session, the answer
512
+ * acknowledges them); then the circuits of the repository,
611
513
  * those whose ticket <fermes> gives closed left out: each one that runs, named; each one stopped on
612
514
  * a question (a stop other than the supervisor's own « arrete »), with its question and the command
613
- * that answers it; each one ended without its issue, with the command that resumes it. The
614
- * stopped and the ended ones are then gone up: the wait does not give them again. Last, « ## La
515
+ * that answers it, in the lines of the shared rendering (`ligneDeQuestion`); each one ended without
516
+ * its issue, with the command that resumes it. All the questions that wait are listed, those
517
+ * already pushed included, and counted presented: the greffon does not give them again before
518
+ * their re-presentation. Last, « ## La
615
519
  * file des tickets » names the tickets of the queue without their section « ## Architecture »
616
520
  * (`enFileSansArchitecture` of scripts/file-des-tickets.mjs, the tickets read by <ticketsDe>,
617
521
  * `lireLesTickets` by default; a Beads that fails says nothing), which the queue never starts.
@@ -644,9 +548,9 @@ export async function circuitsALOuverture(
644
548
  ? relever(racine, circuits, {
645
549
  fermes,
646
550
  maintenant: Date.now(),
647
- rappelMs: RAPPEL_PAR_DEFAUT * 60_000,
551
+ rappelMs: rappelDuProjet(racine) * 60_000,
648
552
  toutes: true,
649
- })
553
+ }).filter(q => !q.integre)
650
554
  : [];
651
555
  const tournent = enAttente(
652
556
  (circuits ?? []).filter(c => c.vivant),
@@ -657,10 +561,7 @@ export async function circuitsALOuverture(
657
561
  ticket: q.ticket,
658
562
  ligne: q.interrompu
659
563
  ? `- ${q.ticket} a fini sans son issue (aucun arrêt écrit), à ${q.etape} : relance-le sans attendre le mot du responsable, \`${q.commande}\`.`
660
- : [
661
- `- ${q.ticket} est arrêté sur une question (${q.arret}), à ${q.etape}, au ${q.qui} : ${q.question.replace(/\n/g, '\n ')}`,
662
- ` La réponse : \`${q.commande}\`.`,
663
- ].join('\n'),
564
+ : ligneDeQuestion(q),
664
565
  });
665
566
  let sansArchitecture = [];
666
567
  try {
@@ -674,8 +575,8 @@ export async function circuitsALOuverture(
674
575
  a.ticket.localeCompare(b.ticket, 'en')
675
576
  );
676
577
  return [
677
- "## L'attente des questions",
678
- "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.",
578
+ '## Les questions des circuits',
579
+ "Le greffon de ta séance pousse dans la file de tes messages chaque question neuve d'un circuit du dépôt, quel que soit son lanceur, et chaque fin de circuit, une fois ; il n'y a aucune attente à lancer. Une question sans réponse revient à intervalle réglable (`grillhouse.rappel`, 5 min par défaut) : ta réponse au circuit l'acquitte, et répondue elle ne revient plus. Tu ne te mets pas en attente du responsable tant qu'une question d'un circuit attend ta réponse : le crochet de fin de tour te le rappelle. Les questions en attente sont listées ci-dessous.",
679
580
  ...(panne ? ['', '## Les circuits du dépôt', panne] : []),
680
581
  ...(nommes.length ? ['', '## Les circuits du dépôt', ...nommes.map(n => n.ligne)] : []),
681
582
  ...(sansArchitecture.length
@@ -743,6 +644,68 @@ async function superviseur(racine, { env = process.env } = {}) {
743
644
  ].join('\n');
744
645
  }
745
646
 
647
+ /**
648
+ * One reading for the greffon of the session of supervision of the repository at <racine>
649
+ * (`npx grillhouse superviseur --relever`): the message of what `relever` gives (the questions of
650
+ * the circuits due, the ends of circuits, the reds of main), empty when it gives nothing, when the
651
+ * circuits do not read, or when the session that runs it is not the one that holds the lock of the
652
+ * supervisor (a role's session, an agent's copy, another project's, a session that took no lock).
653
+ * The interval of the re-presentation is the key `grillhouse.rappel` of the project, applied at
654
+ * each reading.
655
+ * @param {string} racine
656
+ * @param {{ env?: Record<string, string | undefined>, circuitsDe?: (racine: string, options?: { integres?: boolean }) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]> }} [options]
657
+ * @returns {Promise<string>}
658
+ * @throws {Error} `grillhouse.rappel` is at fault, named with its value
659
+ */
660
+ export async function releverPourLeGreffon(
661
+ racine,
662
+ { env = process.env, circuitsDe = circuitsDuServeur } = {}
663
+ ) {
664
+ if (env.BEADS_ACTOR) {
665
+ return '';
666
+ }
667
+ const r = git(racine, '--git-dir', '--git-common-dir');
668
+ if (r.status !== 0) {
669
+ return '';
670
+ }
671
+ const [dossierGit, commun] = r.stdout.trim().split('\n');
672
+ if (path.resolve(dossierGit) !== path.resolve(commun)) {
673
+ return '';
674
+ }
675
+ let tenant = null;
676
+ try {
677
+ tenant = Number(/^(\d+)/.exec(readFileSync(path.join(commun, VERROU_SUPERVISEUR), 'utf8'))?.[1]);
678
+ } catch {
679
+ return '';
680
+ }
681
+ if (!Number.isInteger(tenant) || !estAuDessus(tenant)) {
682
+ return '';
683
+ }
684
+ let pkg = {};
685
+ try {
686
+ pkg = JSON.parse(readFileSync(path.join(racine, 'package.json'), 'utf8'));
687
+ } catch {
688
+ // a package.json that does not read sets no key: the default interval
689
+ }
690
+ const { minutes, faute } = reglageDuRappel(pkg);
691
+ if (faute) {
692
+ throw new Error(faute);
693
+ }
694
+ let circuits;
695
+ try {
696
+ circuits = await circuitsDe(racine, { integres: true });
697
+ } catch {
698
+ return '';
699
+ }
700
+ const lot = relever(racine, circuits, {
701
+ fermes: ticketsHorsAttente,
702
+ maintenant: Date.now(),
703
+ rappelMs: minutes * 60_000,
704
+ fluxRouges: await fluxRougesDe(racine),
705
+ });
706
+ return lot.length ? texteDesQuestions(lot) : '';
707
+ }
708
+
746
709
  // The root of the repository at <dossier>, its main tree for a copy; <dossier> out of git.
747
710
  function racineDe(dossier) {
748
711
  const r = git(dossier, '--git-common-dir');
@@ -750,23 +713,12 @@ function racineDe(dossier) {
750
713
  }
751
714
 
752
715
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
753
- if (process.argv[2] === '--attendre') {
716
+ if (process.argv[2] === '--relever') {
754
717
  try {
755
- const args = process.argv.slice(3);
756
- const i = args.indexOf('--rappel');
757
- let rappel = RAPPEL_PAR_DEFAUT;
758
- if (i !== -1) {
759
- rappel = Number(args[i + 1]);
760
- if (!(rappel > 0)) {
761
- throw new Error('--rappel attend un nombre de minutes supérieur à 0.');
762
- }
763
- args.splice(i, 2);
718
+ const texte = await releverPourLeGreffon(racineDe(process.argv[3] ?? process.cwd()));
719
+ if (texte) {
720
+ process.stdout.write(`${texte}\n`);
764
721
  }
765
- const lot = await attendreUneQuestion({
766
- racine: racineDe(args[0] ?? process.cwd()),
767
- rappel,
768
- });
769
- process.stdout.write(`${texteDesQuestions(lot)}\n`);
770
722
  } catch (e) {
771
723
  process.stderr.write(`${e.message}\n`);
772
724
  process.exitCode = 1;