@roomi-fields/grillhouse 0.47.1 → 0.48.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 (101) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +48 -0
  3. package/cadre/templates/projet/.github/workflows/ci.yml +18 -38
  4. package/cadre/templates/projet/.github/workflows/machine-vierge.yml +5 -0
  5. package/cadre/templates/projet/.github/workflows/nuit.yml +5 -0
  6. package/cadre/templates/projet/CLAUDE.md +23 -6
  7. package/charte.md +9 -2
  8. package/dist/temporal/circuit/commande.js +5 -3
  9. package/dist/temporal/circuit/commande.js.map +1 -1
  10. package/dist/temporal/commande.js +2 -13
  11. package/dist/temporal/commande.js.map +1 -1
  12. package/dist/temporal/deroules.d.ts +1 -1
  13. package/dist/temporal/deroules.js +2 -2
  14. package/dist/temporal/deroules.js.map +1 -1
  15. package/dist/temporal/file/activites.d.ts +1 -4
  16. package/dist/temporal/file/activites.js +13 -14
  17. package/dist/temporal/file/activites.js.map +1 -1
  18. package/dist/temporal/file/contrat.d.ts +20 -91
  19. package/dist/temporal/file/contrat.js +7 -3
  20. package/dist/temporal/file/contrat.js.map +1 -1
  21. package/dist/temporal/file/deroule.d.ts +1 -9
  22. package/dist/temporal/file/deroule.js +54 -163
  23. package/dist/temporal/file/deroule.js.map +1 -1
  24. package/dist/temporal/installation.d.ts +26 -1
  25. package/dist/temporal/installation.js +111 -2
  26. package/dist/temporal/installation.js.map +1 -1
  27. package/dist/temporal/nuits/activites.d.ts +11 -2
  28. package/dist/temporal/nuits/activites.js +16 -5
  29. package/dist/temporal/nuits/activites.js.map +1 -1
  30. package/dist/temporal/nuits/choix.d.ts +15 -0
  31. package/dist/temporal/nuits/choix.js +20 -0
  32. package/dist/temporal/nuits/choix.js.map +1 -1
  33. package/dist/temporal/nuits/contrat.d.ts +16 -3
  34. package/dist/temporal/nuits/deroule.js +9 -2
  35. package/dist/temporal/nuits/deroule.js.map +1 -1
  36. package/dist/temporal/places/client.d.ts +13 -2
  37. package/dist/temporal/places/client.js +17 -2
  38. package/dist/temporal/places/client.js.map +1 -1
  39. package/dist/temporal/places/contrat.d.ts +41 -4
  40. package/dist/temporal/places/contrat.js +8 -0
  41. package/dist/temporal/places/contrat.js.map +1 -1
  42. package/dist/temporal/places/deroule.js +46 -6
  43. package/dist/temporal/places/deroule.js.map +1 -1
  44. package/docs/ARCHITECTURE.md +166 -41
  45. package/docs/INTERFACE.md +13 -3
  46. package/package.json +1 -1
  47. package/scripts/activites.mjs +48 -10
  48. package/scripts/aiguillage.mjs +1 -0
  49. package/scripts/attente-a-l-arret.mjs +2 -5
  50. package/scripts/attente-au-tour.mjs +2 -5
  51. package/scripts/branche-de-nuit.mjs +32 -44
  52. package/scripts/ci-de-main.mjs +215 -16
  53. package/scripts/circuit.mjs +45 -33
  54. package/scripts/composition-des-langages.mjs +2 -0
  55. package/scripts/crochets.mjs +2 -2
  56. package/scripts/effets.mjs +2 -1
  57. package/scripts/enveloppe/enveloppe.mjs +61 -6
  58. package/scripts/enveloppe/travail-de-la-copie.mjs +2 -0
  59. package/scripts/etapes.mjs +11 -1
  60. package/scripts/etat-du-depot.mjs +23 -0
  61. package/scripts/faits-du-circuit.mjs +12 -23
  62. package/scripts/fermeture-de-la-machine.d.mts +27 -0
  63. package/scripts/fermeture-de-la-machine.mjs +108 -0
  64. package/scripts/greffons.mjs +1 -1
  65. package/scripts/integration/file.mjs +16 -13
  66. package/scripts/integration/integrer.mjs +2 -0
  67. package/scripts/jointure.d.ts +5 -0
  68. package/scripts/langages/c/index.mjs +2 -0
  69. package/scripts/langages/c/squelette.mjs +1 -1
  70. package/scripts/langages/cargo/index.mjs +2 -0
  71. package/scripts/langages/python/index.mjs +2 -0
  72. package/scripts/langages/typescript/index.mjs +3 -0
  73. package/scripts/langages/typescript/module-absent.mjs +24 -0
  74. package/scripts/langages/typescript/turbo-des-paquets.mjs +19 -1
  75. package/scripts/langages/typescript/vitest-config/lances.mjs +3 -1
  76. package/scripts/langages.mjs +25 -3
  77. package/scripts/machine.mjs +103 -0
  78. package/scripts/matieres-cles.mjs +17 -0
  79. package/scripts/matieres-lues.mjs +104 -0
  80. package/scripts/migrations/0.48.0-ci-declenchee-par-la-file.mjs +32 -0
  81. package/scripts/migrations/0.48.0-poussee-retiree.mjs +31 -0
  82. package/scripts/migrations.mjs +4 -0
  83. package/scripts/nuit.sh +16 -44
  84. package/scripts/passe-de-la-machine.mjs +9 -7
  85. package/scripts/places-de-la-machine.mjs +74 -11
  86. package/scripts/places-du-serveur.mjs +29 -8
  87. package/scripts/poussee-retiree.mjs +18 -0
  88. package/scripts/registre.d.mts +2 -2
  89. package/scripts/regles-des-places.d.mts +36 -5
  90. package/scripts/regles-des-places.mjs +56 -9
  91. package/scripts/reponses-du-circuit.d.mts +2 -0
  92. package/scripts/reponses-du-circuit.mjs +26 -0
  93. package/scripts/resultats.mjs +40 -0
  94. package/scripts/sous-commandes.mjs +15 -2
  95. package/scripts/superviseur.mjs +64 -57
  96. package/scripts/tableau.mjs +132 -67
  97. package/scripts/transitions.d.mts +8 -0
  98. package/scripts/transitions.mjs +21 -3
  99. package/skills/pitmaster/SKILL.md +6 -3
  100. package/skills/relecteur/SKILL.md +3 -1
  101. package/scripts/poussee-cles.mjs +0 -46
@@ -1,8 +1,11 @@
1
1
  // The CI of main, read after the lots entered, as Google's TAP plays the whole suite after the
2
2
  // submit, by batches of changes, and a red looks for its culprit among the lots entered since the
3
3
  // last green. A lot enters main on its final pass (scripts/integration/file.mjs); the CI plays on
4
- // main on an hourly schedule, and this module reads it:
4
+ // main, started by the queue itself after a lot entered, one pass an hour at most, and this module
5
+ // starts it then reads it:
5
6
  //
7
+ // - `declencherLaCiDeMain`: the start (`gh workflow run`), its delay and its fault kept in a file of
8
+ // the project; `alerteDeDeclenchement` tells the supervisor of a start GitHub refused.
6
9
  // - `lireLaCiDeMain`: the latest finished pass of each workflow of the branch (`gh run list`),
7
10
  // green when every one succeeded, red as soon as one failed (any conclusion but `success`,
8
11
  // `cancelled` and `skipped`: a cancelled pass is replaced by a later one, the one before it
@@ -20,6 +23,7 @@ import { spawnSync } from 'node:child_process';
20
23
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
21
24
  import path from 'node:path';
22
25
  import { git, sortie } from './etat-du-depot.mjs';
26
+ import { lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
23
27
 
24
28
  const COURT = 7;
25
29
  const court = sha => String(sha).slice(0, COURT);
@@ -88,6 +92,127 @@ export function lireLaCiDeMain(o, { branche = 'main' } = {}) {
88
92
  return { etat: 'verte', commit: tete.headSha, passage: String(tete.databaseId) };
89
93
  }
90
94
 
95
+ const HEURE = 3_600_000;
96
+ const FLUX_DE_LA_CI = 'ci.yml';
97
+ const EN_ATTENTE = state => state !== 'completed';
98
+
99
+ const etatDuDeclenchement = racine =>
100
+ path.join(racine, '.claude', 'worktrees', 'ci-de-main-declenchee.json');
101
+
102
+ // What the queue keeps of its starts: `declenche` (the instant of the last start, which covers the
103
+ // delay before the pass shows), `entree` (a lot entered whose pass is not started yet) and `faute`
104
+ // (the reason of the last refused start, null when none).
105
+ function lireLEtat(racine) {
106
+ try {
107
+ const lu = JSON.parse(readFileSync(etatDuDeclenchement(racine), 'utf8'));
108
+ return {
109
+ declenche: Number.isFinite(lu?.declenche) ? lu.declenche : null,
110
+ entree: lu?.entree === true,
111
+ faute: typeof lu?.faute === 'string' ? lu.faute : null,
112
+ };
113
+ } catch {
114
+ return { declenche: null, entree: false, faute: null };
115
+ }
116
+ }
117
+ function ecrireLEtat(racine, etat) {
118
+ try {
119
+ const f = etatDuDeclenchement(racine);
120
+ mkdirSync(path.dirname(f), { recursive: true });
121
+ writeFileSync(f, `${JSON.stringify(etat)}\n`);
122
+ } catch {
123
+ // not kept: the next quarter of an hour reads the passes again
124
+ }
125
+ }
126
+
127
+ /** The fault of the last refused start of the CI of the project at <racine>, null when none. */
128
+ export const fauteDeDeclenchement = racine => lireLEtat(racine).faute;
129
+
130
+ /**
131
+ * What the supervisor is told of a start of the CI that GitHub refused: `{ genre, cle, texte }`,
132
+ * a kind apart from « CI de main non lue » and from a red.
133
+ */
134
+ export function alerteDeDeclenchement(faute) {
135
+ return {
136
+ genre: 'declenchement',
137
+ cle: 'declenchement',
138
+ texte: `La CI de main n'a pas pu être déclenchée : ${uneLigne(faute)} La file continue et retente au quart d'heure suivant.`,
139
+ };
140
+ }
141
+
142
+ /**
143
+ * The queue starts the CI of main itself, as the schedulers of Google's TAP and Chromium's LUCI
144
+ * start the pass after the submit, by batches: it reads the passes of the workflow ci.yml on main
145
+ * (whatever started them) with <o.gh> in <o.racine>, and starts it (`gh workflow run`) when the tip
146
+ * of main differs from the commit of the last pass, no pass is running or waiting, and the last
147
+ * pass or the last start is an hour old or more. Without any pass known, only a lot entered
148
+ * (<p.apresEntree>, kept until a start succeeds) starts it, never the sole start of the queue.
149
+ * `{ declenche }`, with `faute` when GitHub refused: the fault is kept for the alert, the next
150
+ * quarter of an hour tries again, and nothing throws.
151
+ */
152
+ export function declencherLaCiDeMain(o, { apresEntree = false, maintenant = Date.now() } = {}) {
153
+ const { racine } = o;
154
+ const avant = lireLEtat(racine);
155
+ const entree = apresEntree || avant.entree;
156
+ const garder = suite => ecrireLEtat(racine, { ...avant, entree, ...suite });
157
+ const lu = o.gh([
158
+ 'run',
159
+ 'list',
160
+ '--workflow',
161
+ FLUX_DE_LA_CI,
162
+ '--branch',
163
+ 'main',
164
+ '--limit',
165
+ '20',
166
+ '--json',
167
+ 'databaseId,status,conclusion,headSha,event,createdAt',
168
+ ]);
169
+ let passages;
170
+ try {
171
+ if (lu.error || lu.status !== 0) {
172
+ throw new Error('illisible');
173
+ }
174
+ passages = JSON.parse(lu.stdout || '[]');
175
+ if (!Array.isArray(passages)) {
176
+ throw new Error('illisible');
177
+ }
178
+ } catch {
179
+ garder({});
180
+ return { declenche: false };
181
+ }
182
+ const connus = passages
183
+ .filter(p => p?.headSha)
184
+ .sort(
185
+ (a, b) => Date.parse(b.createdAt) - Date.parse(a.createdAt) || b.databaseId - a.databaseId
186
+ );
187
+ if (connus.some(p => EN_ATTENTE(p.status))) {
188
+ garder({});
189
+ return { declenche: false };
190
+ }
191
+ const dernier = connus[0];
192
+ const pointe = sortie(racine, ['rev-parse', 'main']) || sortie(racine, ['rev-parse', 'HEAD']);
193
+ if (dernier ? dernier.headSha === pointe : !entree) {
194
+ garder({ entree: false });
195
+ return { declenche: false };
196
+ }
197
+ const instants = [dernier ? Date.parse(dernier.createdAt) : null, avant.declenche].filter(
198
+ Number.isFinite
199
+ );
200
+ if (instants.length > 0 && maintenant - Math.max(...instants) < HEURE) {
201
+ garder({});
202
+ return { declenche: false };
203
+ }
204
+ const r = o.gh(['workflow', 'run', FLUX_DE_LA_CI, '--ref', 'main']);
205
+ if (r.error || r.status !== 0) {
206
+ const faute = r.error
207
+ ? `gh ne se lance pas (${r.error.code ?? r.error.message}).`
208
+ : `gh workflow run refuse : ${uneLigne(`${r.stderr ?? ''} ${r.stdout ?? ''}`)}`;
209
+ garder({ faute });
210
+ return { declenche: false, faute };
211
+ }
212
+ ecrireLEtat(racine, { declenche: maintenant, entree: false, faute: null });
213
+ return { declenche: true };
214
+ }
215
+
91
216
  // The ticket a subject « … (<ticket>) » of the circuit's commits ends with, null otherwise.
92
217
  const TICKET = /\(([A-Za-z0-9]+-[A-Za-z0-9.]+)\)\s*$/;
93
218
 
@@ -120,10 +245,12 @@ export function lotsDepuisLeVert(racine, { vert, pointe }) {
120
245
 
121
246
  /**
122
247
  * What a reading tells the supervisor: `{ genre, cle, texte }`, null for a green (the alert clears).
123
- * A red names the workflow, its pass, its commit and each lot <lots> entered since the last green;
124
- * a CI not read is the alert « CI de main non lue ».
248
+ * A red names the workflow, its pass, its commit and each lot <lots> entered since the last green,
249
+ * then its defect ticket <defaut> (`ouvrirLeDefautDeMain`): the ticket by its number, a ticket open
250
+ * with no number read, or the fault that kept it from opening (its own key, so that the alert with
251
+ * the ticket is given in its turn); a CI not read is the alert « CI de main non lue ».
125
252
  */
126
- export function alerteDeLaCiDeMain(lecture, lots) {
253
+ export function alerteDeLaCiDeMain(lecture, lots, defaut) {
127
254
  if (lecture.etat === 'verte') {
128
255
  return null;
129
256
  }
@@ -139,10 +266,18 @@ export function alerteDeLaCiDeMain(lecture, lots) {
139
266
  ? `Lots entrés depuis le dernier vert (${court(lecture.vert)}) : ${lots.map(l => l.ticket).join(', ')}.`
140
267
  : `aucun lot du circuit entré depuis le dernier vert (${court(lecture.vert)}).`
141
268
  : 'aucun vert connu pour ce flux : les lots entrés ne se nomment pas.';
269
+ const sans = Boolean(defaut?.faute);
270
+ const defautDit = !defaut
271
+ ? ''
272
+ : sans
273
+ ? ` Le ticket de défaut n'a pas pu s'ouvrir : ${uneLigne(defaut.faute)} Chaque relevé retente.`
274
+ : defaut.ticket
275
+ ? ` La recherche du coupable est le ticket de défaut ${defaut.ticket}, ouvert pour le responsable.`
276
+ : ` Un ticket de défaut est ouvert pour le responsable (son numéro ne s'est pas lu).`;
142
277
  return {
143
278
  genre: 'rouge',
144
- cle: `rouge ${lecture.passage}`,
145
- texte: `CI de main rouge : ${lecture.flux}, passage ${lecture.passage} (commit ${court(lecture.commit)}). ${depuis} La file continue d'avancer main ; la recherche du coupable est le ticket de défaut ouvert pour le responsable.`,
279
+ cle: sans ? `rouge ${lecture.passage} sans ticket` : `rouge ${lecture.passage}`,
280
+ texte: `CI de main rouge : ${lecture.flux}, passage ${lecture.passage} (commit ${court(lecture.commit)}). ${depuis} La file continue d'avancer main.${defautDit}`,
146
281
  };
147
282
  }
148
283
 
@@ -164,13 +299,39 @@ const titreDuDefaut = l => `CI de main rouge — ${l.flux}, passage ${l.passage}
164
299
  * The defect ticket a red <lecture> opens under `a-valider` with the tools <o> (`bd` of the
165
300
  * project): its title names the workflow and the red pass, its description the commit and each
166
301
  * candidate lot <lots>. One ticket per pass, closed or not: a pass that already has its ticket opens
167
- * none, and `doublon` names it. A green or a CI not read opens none (the alert says it, no defect is
168
- * proven). `{ ouvert, doublon?, faute? }`: a creation Beads refuses is a fault named.
302
+ * none. The queue and the supervisor's reading both open it through this function, and the search
303
+ * of a doublon and the creation are played under a file lock of the project <o.racine>, so that
304
+ * two openings at once make one ticket. A green or a CI not read opens none (the alert says it, no
305
+ * defect is proven). `{ ouvert, ticket, faute? }`: `ticket` is the number of the ticket created
306
+ * (read on the output of the creation) or already holding the pass, null when none is readable; a
307
+ * creation Beads refuses is a fault named.
169
308
  */
170
309
  export function ouvrirLeDefautDeMain(o, lecture, lots) {
171
310
  if (lecture.etat !== 'rouge') {
172
- return { ouvert: false };
311
+ return { ouvert: false, ticket: null };
173
312
  }
313
+ const verrou = path.join(o.racine, '.claude', 'worktrees', 'ci-de-main-defaut.verrou');
314
+ try {
315
+ mkdirSync(path.dirname(verrou), { recursive: true });
316
+ } catch {
317
+ // the lock is then taken without its directory and fails: the creation goes on unlocked
318
+ }
319
+ let pris = false;
320
+ try {
321
+ pris = prendreVerrou(verrou, { attendre: true });
322
+ } catch {
323
+ // a lock that cannot be taken costs the race guard, not the ticket
324
+ }
325
+ try {
326
+ return ouvrirSousVerrou(o, lecture, lots);
327
+ } finally {
328
+ if (pris) {
329
+ lacherVerrou(verrou);
330
+ }
331
+ }
332
+ }
333
+
334
+ function ouvrirSousVerrou(o, lecture, lots) {
174
335
  const titre = titreDuDefaut(lecture);
175
336
  const existants = o.bd('list', '--all', '--label', A_VALIDER, '--limit', '0', '--json');
176
337
  if (existants.status === 0) {
@@ -178,7 +339,7 @@ export function ouvrirLeDefautDeMain(o, lecture, lots) {
178
339
  const l = JSON.parse(existants.stdout || '[]');
179
340
  const deja = (Array.isArray(l) ? l : []).find(t => t?.title === titre);
180
341
  if (deja) {
181
- return { ouvert: false, doublon: deja.id };
342
+ return { ouvert: false, ticket: deja.id ?? null, doublon: deja.id };
182
343
  }
183
344
  } catch {
184
345
  // A list that does not read opens the ticket: a doublon is the lesser fault.
@@ -209,12 +370,26 @@ export function ouvrirLeDefautDeMain(o, lecture, lots) {
209
370
  if (r.status !== 0) {
210
371
  return {
211
372
  ouvert: false,
373
+ ticket: null,
212
374
  faute: `bd create refuse : ${uneLigne(`${r.stderr ?? ''}${r.stdout ?? ''}`)}`,
213
375
  };
214
376
  }
215
- return { ouvert: true };
377
+ const numero = /^([A-Za-z0-9]+-[A-Za-z0-9.]+)$/.exec(String(r.stdout ?? '').trim())?.[1];
378
+ return { ouvert: true, ticket: numero ?? null };
216
379
  }
217
380
 
381
+ // `bd` run in the project at <racine>, found on the PATH as the project's own.
382
+ export const bdDans =
383
+ racine =>
384
+ (...args) =>
385
+ spawnSync('bd', args, {
386
+ cwd: racine,
387
+ env: process.env,
388
+ encoding: 'utf8',
389
+ timeout: 60_000,
390
+ maxBuffer: 256 * 1024 * 1024,
391
+ });
392
+
218
393
  // The GitHub CLI run in the main tree <racine>.
219
394
  export const ghDans =
220
395
  racine =>
@@ -228,7 +403,7 @@ export const ghDans =
228
403
  });
229
404
 
230
405
  // How long a reading of the CI of main stays as read, for the board and the greffon, which ask
231
- // again and again: the CI plays hourly, GitHub need not be asked at each refresh.
406
+ // again and again: the CI plays an hour apart at most, GitHub need not be asked at each refresh.
232
407
  const VALIDITE_DE_LA_LECTURE = 5 * 60_000;
233
408
 
234
409
  /**
@@ -266,11 +441,35 @@ export function ciDeMainGardee(
266
441
  * The alert of a <lecture> of the CI of the project at <racine>, its lots named by git up to the
267
442
  * tip of its main tree: `{ genre, cle, texte }`, null for a green.
268
443
  */
269
- export function alerteDuProjet(racine, lecture) {
444
+ export function alerteDuProjet(racine, lecture, defaut) {
445
+ return alerteDeLaCiDeMain(lecture, lotsDuProjet(racine, lecture), defaut);
446
+ }
447
+
448
+ /** The lots entered since the last green of a red <lecture>, up to the tip of the tree at <racine>. */
449
+ export function lotsDuProjet(racine, lecture) {
270
450
  if (lecture.etat !== 'rouge') {
271
- return alerteDeLaCiDeMain(lecture, []);
451
+ return [];
272
452
  }
273
453
  const pointe = sortie(racine, ['rev-parse', 'HEAD']);
274
- const lots = pointe ? lotsDepuisLeVert(racine, { vert: lecture.vert, pointe }) : [];
275
- return alerteDeLaCiDeMain(lecture, lots);
454
+ return pointe ? lotsDepuisLeVert(racine, { vert: lecture.vert, pointe }) : [];
455
+ }
456
+
457
+ /**
458
+ * The CI of main read for the supervisor at <racine>, its defect ticket opened by the same function
459
+ * as the queue's (`ouvrirLeDefautDeMain`, in this project, with its own Beads): the alert, null for
460
+ * a green, undefined for a project with no CI to read. Only the supervisor's reading calls it, the
461
+ * board reads `ciDeMainGardee` alone.
462
+ */
463
+ export function lireEtOuvrirLeDefautDeMain(racine, { gh } = {}) {
464
+ const lecture = ciDeMainGardee(racine, gh ? { gh } : {});
465
+ if (!lecture) {
466
+ return undefined;
467
+ }
468
+ const defaut =
469
+ lecture.etat === 'rouge'
470
+ ? ouvrirLeDefautDeMain({ racine, bd: bdDans(racine) }, lecture, lotsDuProjet(racine, lecture))
471
+ : undefined;
472
+ const alerte = alerteDuProjet(racine, lecture, defaut);
473
+ const faute = fauteDeDeclenchement(racine);
474
+ return alerte ?? (faute ? alerteDeDeclenchement(faute) : alerte);
276
475
  }
@@ -626,6 +626,7 @@ import path from 'node:path';
626
626
  import { empreintesDe, outilsDe } from './outils-cles.mjs';
627
627
  import { donneesDe } from './donnees-cles.mjs';
628
628
  import { engendresDe } from './engendres.mjs';
629
+ import { matieresDeclareesDe } from './matieres-cles.mjs';
629
630
  import { fluxDe } from './flux-des-paquets.mjs';
630
631
  import {
631
632
  AGENTS_DU_LOT,
@@ -649,6 +650,7 @@ import {
649
650
  questionsPosees,
650
651
  rapportDuRefus,
651
652
  TESTS,
653
+ testwriterDemande,
652
654
  } from './transitions.mjs';
653
655
  import { departDepuis } from './reprise.mjs';
654
656
  import {
@@ -704,9 +706,16 @@ import { ligneDEtape, transcriptionsDeLaCopie } from './registre.mjs';
704
706
  import {
705
707
  bloquantsDeLaFiche,
706
708
  cleDuConstat,
709
+ estUneBascule,
710
+ estUnPlan,
711
+ ficheDuPlan,
707
712
  reponsesAuxQuestions,
713
+ sorteDesFiches,
708
714
  sorteDuPlan,
709
715
  } from './resultats.mjs';
716
+
717
+ // The sheet of the plan that says a field, as scripts/resultats.mjs reads it.
718
+ export { ficheDuPlan };
710
719
  import { preparer, rolesDuConflit } from './enveloppe/travail-de-la-copie.mjs';
711
720
  import { refusArbitrage } from './integration/integrer.mjs';
712
721
  import { prendreUnRang } from './places-de-la-machine.mjs';
@@ -1187,6 +1196,27 @@ export function engendresAuLancement(racine) {
1187
1196
  }
1188
1197
  }
1189
1198
 
1199
+ // The folders of test material the project declares (`grillhouse.matieres`,
1200
+ // scripts/matieres-cles.mjs), read at the launch of a run from its main tree: `{ matieres }`, or
1201
+ // `{ arret }`, the stop « lancement » that goes up to the supervisor before any session, the
1202
+ // faults of the key named.
1203
+ export function matieresAuLancement(racine) {
1204
+ try {
1205
+ return { matieres: matieresDeclareesDe(racine) };
1206
+ } catch (err) {
1207
+ const rapport = `La clé grillhouse.matieres du package.json est refusée :\n${err.message}`;
1208
+ return {
1209
+ arret: {
1210
+ code: ARRETS.lancement,
1211
+ nom: 'lancement',
1212
+ rapport,
1213
+ piece: `$ npm pkg get grillhouse.matieres\n${rapport}`,
1214
+ question: `${rapport}\nLa clé se corrige au package.json du projet, puis \`--reprendre\`.`,
1215
+ },
1216
+ };
1217
+ }
1218
+ }
1219
+
1190
1220
  // The flows of the CI the project declares (`grillhouse.flux`, scripts/flux-des-paquets.mjs), read
1191
1221
  // at the launch of a run from its main tree: `{ flux }`, or `{ arret }`, the stop « lancement »
1192
1222
  // that goes up to the supervisor before any session, the faults of the key named.
@@ -1294,39 +1324,9 @@ export function constatsOuverts(ctx, fiche, texte) {
1294
1324
  return [...restes, ...neufs];
1295
1325
  }
1296
1326
 
1297
- // The sheet of the plan that says its field <champ> (`sorte`, `noms_publies`) among the
1298
- // explorateur's sheets of the plan <plans>, in their order (`{ fiche, reponse }` entries): the last
1299
- // one, or, when it is his answer to the questionneur (`reponse`) and says none, the plan it
1300
- // answers, so that the field survives the answer; null without a sheet of the plan.
1301
- export function ficheDuPlan(plans, champ) {
1302
- const derniere = plans.at(-1);
1303
- if (!derniere) {
1304
- return null;
1305
- }
1306
- if (derniere.reponse && !(champ in derniere.fiche) && plans.length > 1) {
1307
- return plans.at(-2).fiche;
1308
- }
1309
- return derniere.fiche;
1310
- }
1311
-
1312
- // A sheet of the plan (the explorateur's, which holds criteria), and a line of the circuit that
1313
- // turns the sort of the ticket on the same plan (`ecrireLaSorte`: the supervisor's `--mecanique`,
1314
- // the reviewer's `comportement-change`).
1315
- const estUnPlan = e => e.role === EXPLORATEUR && Array.isArray(e.fiche?.criteres);
1316
- const estUneBascule = e =>
1317
- e.role === AUTEUR_DU_CIRCUIT && typeof e.sorte === 'object' && e.sorte !== null;
1318
-
1319
- // The sort of the ticket its plan says (`sorteDuPlan` of scripts/resultats.mjs): the sheet of the
1320
- // plan that says it (`ficheDuPlan`), comportement without one (grillhouse-sos); a line that turns
1321
- // the sort after the last sheet of the plan stands over it, the plan kept as it is.
1322
- function sorteDuTicket(ctx) {
1323
- const tous = lesFiches(ctx);
1324
- const bascule = tous.findLastIndex(estUneBascule);
1325
- if (bascule > tous.findLastIndex(estUnPlan)) {
1326
- return tous[bascule].sorte;
1327
- }
1328
- return sorteDuPlan(ficheDuPlan(tous.filter(estUnPlan), 'sorte'));
1329
- }
1327
+ // The sort of the ticket of <ctx>, read from its kept results (`sorteDesFiches` of
1328
+ // scripts/resultats.mjs).
1329
+ const sorteDuTicket = ctx => sorteDesFiches(lesFiches(ctx));
1330
1330
 
1331
1331
  // Whether a testwriter or a developpeur has worked the lot since the last sheet of the plan or the
1332
1332
  // last turn of its sort.
@@ -1675,6 +1675,12 @@ const laQuestion = (ticket, { arret, qui, ou, question }) =>
1675
1675
  // the state <e> (null without one) on --reprendre, the integration or the queue played again on
1676
1676
  // the same lot after their stop, as bors retries, else the testwriter, the run starting over.
1677
1677
  function depart(ctx, e) {
1678
+ // The supervisor's command wins over the sort of the plan: the mark of his `--depuis testwriter`.
1679
+ ctx.testwriterDemande = testwriterDemande({
1680
+ depuis: ctx.depuis ?? null,
1681
+ reprendre: Boolean(ctx.reprendre),
1682
+ marque: Boolean(ctx.testwriterDemande),
1683
+ });
1678
1684
  // A --depuis plays its step and the ones after it, no result read back: no fingerprint kept, no
1679
1685
  // resumption at a red, no attribution counted.
1680
1686
  if (ctx.depuis) {
@@ -2596,6 +2602,12 @@ async function avantLePlan(ctx, e) {
2596
2602
  return { code: monter(ctx, { ...engendres.arret, etat: d }) };
2597
2603
  }
2598
2604
  ctx.engendres = engendres.engendres;
2605
+ // The folders of test material the project declares: refused at the launch when the key is
2606
+ // faulty, before any session.
2607
+ const matieres = matieresAuLancement(ctx.racine);
2608
+ if (matieres.arret) {
2609
+ return { code: monter(ctx, { ...matieres.arret, etat: d }) };
2610
+ }
2599
2611
  // The flows of the CI, refused at the launch when their key is faulty: the reviewer's instruction
2600
2612
  // reads those the lot touches (`consigneDesFlux`).
2601
2613
  const flux = fluxAuLancement(ctx.racine);
@@ -265,6 +265,8 @@ export function composer(modules) {
265
265
  };
266
266
  },
267
267
  echecDeCompilation: texte => modules.some(m => m.echecDeCompilation?.(texte) ?? false),
268
+ moduleAbsent: (message, fichier) =>
269
+ modules.map(m => m.moduleAbsent?.(message, fichier) ?? null).find(Boolean) ?? null,
268
270
  estUnTest: (chemin, racine) =>
269
271
  premiereReponse(modules, racine, chemin, m => m.estUnTest(chemin, racine)),
270
272
  horsDuJour: (chemin, racine) =>
@@ -7,7 +7,7 @@
7
7
  // npx grillhouse hooks --absents [<project>] prints the name of each absent hook, one per line
8
8
  //
9
9
  // - commit-msg: « un ticket fermé garde sa livraison ; un ticket rouvert reçoit ses corrections » (scripts/un-commit-par-ticket.mjs).
10
- // - pre-push: the night branch guard and the judged main (scripts/branche-de-nuit.mjs).
10
+ // - pre-push: the judged main guard and the refusal of the retired key (scripts/branche-de-nuit.mjs).
11
11
  // - A hook lives in the folder git reads for the project (`git rev-parse --git-path hooks`, which
12
12
  // follows `core.hooksPath`, Beads' `.beads/hooks` included); `core.hooksPath` is never changed
13
13
  // here. The update of the frame (scripts/grillhouse-maj.mjs) places them by the same function.
@@ -50,7 +50,7 @@ export const CROCHETS = {
50
50
  'pre-push': {
51
51
  garde: 'branche-de-nuit.mjs',
52
52
  lignes: [
53
- '# Night branch guard (Grillhouse): only the night pushes the branch of grillhouse.poussee.nuit, after its green. Without the package @roomi-fields/grillhouse installed, nothing.',
53
+ '# Judged main guard (Grillhouse): main receives only a tree a final pass or a verification judged green; a project that carries the retired grillhouse.poussee is refused. Without the package @roomi-fields/grillhouse installed, nothing.',
54
54
  COMMANDE,
55
55
  'if [ -x "$_gh_commande" ]; then _gh_entree=$(mktemp) && cat > "$_gh_entree" && "$_gh_commande" hook pre-push "$@" < "$_gh_entree" || { rm -f "$_gh_entree"; exit 1; }; exec < "$_gh_entree"; rm -f "$_gh_entree"; fi',
56
56
  ],
@@ -44,6 +44,7 @@ import { stripVTControlCharacters } from 'node:util';
44
44
  import { ecrireLeBilan } from './bilan.mjs';
45
45
  import { ecrireLaTrace } from './journal-des-etats.mjs';
46
46
  import { ecrire as ecrireAuRegistre } from './registre.mjs';
47
+ import { AUTEUR_DU_CIRCUIT } from './etapes.mjs';
47
48
 
48
49
  /** The line of HTML comment that carries the key <cle> in a text at a ticket. */
49
50
  export const marqueDeCle = cle => `<!-- grillhouse : ${cle} -->`;
@@ -62,7 +63,7 @@ export const AVEC_CLE = new Set([
62
63
  // git user.name, $USER »), each session's its role; the author of the circuit's own lines, and
63
64
  // the start of each of them at a ticket.
64
65
  export const ACTEUR = 'BEADS_ACTOR';
65
- export const AUTEUR_DU_CIRCUIT = 'circuit';
66
+ export { AUTEUR_DU_CIRCUIT };
66
67
  export const PREFIXE = 'Circuit · ';
67
68
  const TICKET_SH = path.join(import.meta.dirname, 'ticket.sh');
68
69
 
@@ -130,8 +130,15 @@ import {
130
130
  export { paquetsDuLangage };
131
131
  import { cacheDesOutils, installer, versionDeLOutil } from '../aiguillage.mjs';
132
132
  import { ouvrirBase } from '../mesure/base-de-passe.mjs';
133
- import { sousNiceEtIonice, travailleursDe, VARIABLE_TENUE } from '../places-de-la-machine.mjs';
133
+ import {
134
+ partDeLaPasse,
135
+ sousNiceEtIonice,
136
+ travailleursDe,
137
+ VARIABLE_TENUE,
138
+ } from '../places-de-la-machine.mjs';
139
+ import { commandeDuGroupe, groupeIndisponible } from '../passe-de-la-machine.mjs';
134
140
  import { donneesDe } from '../donnees-cles.mjs';
141
+ import { matieresDeclareesDe } from '../matieres-cles.mjs';
135
142
  import { outilsDe } from '../outils-cles.mjs';
136
143
 
137
144
  // The role that writes the package of the shared test material and the lock files of the versions.
@@ -150,6 +157,20 @@ const sortiesDe = (dir, sorties, lien = () => null) =>
150
157
  });
151
158
  })
152
159
  .map(s => path.join(dir, s));
160
+ /**
161
+ * The test material of the copy <copie>, relative to it: the packages of the shared material
162
+ * (`matieres` of the language) and the folders the project declares (`grillhouse.matieres`,
163
+ * scripts/matieres-cles.mjs). The testwriter mounts each in writing, every other role read-only.
164
+ * @param {import('../jointure.js').Composition} langage
165
+ * @param {string} copie
166
+ * @returns {string[]}
167
+ */
168
+ export function matieresDeLaCopie(langage, copie) {
169
+ return [
170
+ ...langage.matieres(copie).map(m => path.relative(copie, m.dossier)),
171
+ ...matieresDeclareesDe(copie),
172
+ ];
173
+ }
153
174
  // The packages of the copy that the plan <paquets> does not name and that are not the shared test
154
175
  // material, relative to the copy: where the envelope opens an empty own output to each run. The
155
176
  // root package is the copy's own root, treated apart.
@@ -166,7 +187,8 @@ const paquetsHorsDuPlan = (paquets, paquetsDeLaCopie, matieres) => {
166
187
  export function preparerLesSorties({ copie, paquets, paquetsDeLaCopie, matieres, role, sorties }) {
167
188
  const dossiers = paquetsHorsDuPlan(paquets, paquetsDeLaCopie, matieres);
168
189
  if (role !== ROLE_MATIERE) {
169
- dossiers.push(...matieres);
190
+ // A declared folder of test material is no package: no run of tests writes outputs in it.
191
+ dossiers.push(...matieres.filter(m => paquetsDeLaCopie.some(p => p.dossier === m)));
170
192
  }
171
193
  if (!ecritsDuPlan(paquets, paquetsDeLaCopie).includes('.')) {
172
194
  dossiers.push('.');
@@ -305,8 +327,15 @@ export function environnementDeLaSeance(
305
327
  * environment of the session, GRILLHOUSE_TRAVAILLEURS set to max(1, cores ÷ places) of <env>.
306
328
  * @param {{ argsBwrap: string[], commande: string[], env: Record<string, string | undefined>,
307
329
  * cacheNpm: string, paquets: string[], travail: string, outils?: Record<string, string>,
308
- * donnees?: Record<string, string> }} o
309
- * @returns {{ cmd: string, args: string[], env: Record<string, string> }}
330
+ * donnees?: Record<string, string>, part?: { coeurs: number, memoire: number },
331
+ * sonde?: () => boolean }} o
332
+ * @returns {{ cmd: string, args: string[], env: Record<string, string>, sansBorne: string | null }}
333
+ * `sansBorne`: why the session starts without a group (null when it has one)
334
+ *
335
+ * The session runs in a scope of its own (`systemd-run --user --scope`, a foreground scope that
336
+ * leaves with its process) with a hard CPU ceiling of the cores of the part of the project; the
337
+ * passes it launches play inside that ceiling. Without a part or a manager of groups, it starts as
338
+ * it is.
310
339
  */
311
340
  export function lancementDeLaSeance({
312
341
  argsBwrap,
@@ -317,10 +346,23 @@ export function lancementDeLaSeance({
317
346
  travail,
318
347
  outils,
319
348
  donnees,
349
+ part,
350
+ sonde,
320
351
  }) {
321
- return {
352
+ const seance = {
322
353
  cmd: 'bwrap',
323
354
  args: [...argsBwrap, ...commandeEprouvee(sousNiceEtIonice(commande))],
355
+ };
356
+ const sansBorne = part
357
+ ? groupeIndisponible({ env, ...(sonde ? { sonde } : {}) })
358
+ : 'aucune part du projet connue';
359
+ const lancee =
360
+ sansBorne === null
361
+ ? commandeDuGroupe({ part, cmd: seance.cmd, args: seance.args, plafond: true, memoire: false })
362
+ : seance;
363
+ return {
364
+ ...lancee,
365
+ sansBorne,
324
366
  env: environnementDeLaSeance(env, {
325
367
  cacheNpm,
326
368
  paquets,
@@ -807,6 +849,7 @@ function envelopper(argv) {
807
849
  montages: [copie, claude, scratchpads, cacheNpm, TEMPORAIRE, ...sessions],
808
850
  });
809
851
  donnees = donneesDe(copie);
852
+ matieresDeclareesDe(copie);
810
853
  } catch (e) {
811
854
  process.stderr.write(`⛔ ENVELOPPE REFUSÉE — ${e.message}\n`);
812
855
  return CODE_REFUS;
@@ -840,7 +883,7 @@ function envelopper(argv) {
840
883
  lienSurDisque
841
884
  );
842
885
  const langage = langageDeLaCopie(copie);
843
- const matieres = langage.matieres(copie).map(m => path.relative(copie, m.dossier));
886
+ const matieres = matieresDeLaCopie(langage, copie);
844
887
  // The outputs of the language: its stores in the home or in the main tree (the folder of git's
845
888
  // common directory), and where its tools write in the copy.
846
889
  const commun = execFileSync(
@@ -889,6 +932,14 @@ function envelopper(argv) {
889
932
  process.stderr.write(`⛔ ENVELOPPE REFUSÉE — ${refus}\n`);
890
933
  code = CODE_REFUS;
891
934
  } else {
935
+ let part;
936
+ try {
937
+ part = partDeLaPasse({ racine: copie });
938
+ } catch (e) {
939
+ process.stderr.write(`⛔ ENVELOPPE REFUSÉE — ${e.message}\n`);
940
+ temporaire.fermer();
941
+ return CODE_REFUS;
942
+ }
892
943
  const lancement = lancementDeLaSeance({
893
944
  argsBwrap: args,
894
945
  commande,
@@ -898,7 +949,11 @@ function envelopper(argv) {
898
949
  travail,
899
950
  outils,
900
951
  donnees,
952
+ part,
901
953
  });
954
+ if (lancement.sansBorne !== null) {
955
+ process.stderr.write(`⚠ la séance part sans borne de processeur : ${lancement.sansBorne}\n`);
956
+ }
902
957
  const r = spawnSync(lancement.cmd, lancement.args, { stdio: 'inherit', env: lancement.env });
903
958
  if (r.error) {
904
959
  process.stderr.write(`⛔ ENVELOPPE IMPOSSIBLE — ${r.error.message}\n`);
@@ -72,6 +72,7 @@ import path from 'node:path';
72
72
  import { pathToFileURL } from 'node:url';
73
73
  import { couvertPar, encoreDeclares, engendresDe, regenerer, touchesPar } from '../engendres.mjs';
74
74
  import { avecLesDonnees, donneesDe } from '../donnees-cles.mjs';
75
+ import { matieresDeclareesDe } from '../matieres-cles.mjs';
75
76
  import { avecLesOutils, empreintesDe, outilsDe } from '../outils-cles.mjs';
76
77
 
77
78
  const LOT = 'grillhouse-travail.patch';
@@ -104,6 +105,7 @@ const fichiersDuLot = (copie, lot) =>
104
105
  */
105
106
  function lesCles(copie) {
106
107
  try {
108
+ matieresDeclareesDe(copie);
107
109
  return {
108
110
  engendres: engendresDe(copie),
109
111
  env: avecLesDonnees(
@@ -38,6 +38,8 @@ export const AUTO = 'auto';
38
38
  // The role that writes the plan and answers its questions once, and sorts the discoveries of the
39
39
  // ticket once its lot is on main; the role that questions the plan.
40
40
  export const EXPLORATEUR = 'explorateur';
41
+ // The author of the circuit's own lines, at a ticket and among its kept results.
42
+ export const AUTEUR_DU_CIRCUIT = 'circuit';
41
43
  export const QUESTIONNEUR = 'questionneur';
42
44
 
43
45
  export const ETAPES = [
@@ -256,7 +258,7 @@ export const RESPONSABLE = 'responsable';
256
258
 
257
259
  // The commands by which the supervisor answers a question (scripts/circuit.mjs): resume, extend
258
260
  // the plan, stop.
259
- const REPONSES =
261
+ export const REPONSES =
260
262
  'Le superviseur répond par une commande du circuit : `--reprendre` (avec `--contexte`) ou `--depuis <testwriter|developpeur>` (avec `--contexte`), `--mecanique [<commande>]` (avec `--contexte` : à l’arrêt du testwriter qui ne trouve aucun comportement à tester, le ticket bascule en circuit court sur le même plan, vers 1.1 avec sa commande, vers le développeur sans elle), `--etendre <paquet>` (le plan gagne ce paquet, puis l’étape en cours reprend), `--reporter <heure>` (la question se tait jusqu’à l’heure, le circuit en attente), ou `--arreter`.';
261
263
 
262
264
  // The question of each stop no gesture settles, as a CI calls a person only for what no rule
@@ -306,5 +308,13 @@ export const MONTEES = Object.fromEntries(
306
308
  }).map(([arret, question]) => [arret, { question: `${question} ${REPONSES}`, qui: SUPERVISEUR }])
307
309
  );
308
310
 
311
+ // The question <question> of a stop without the list of the answers it ends with (`REPONSES`), which
312
+ // the session of supervision reads once, at its opening.
313
+ const AMORCE_DES_REPONSES = REPONSES.slice(0, REPONSES.indexOf(':') + 1);
314
+ export const sansLesReponses = question =>
315
+ String(question ?? '')
316
+ .split(AMORCE_DES_REPONSES)[0]
317
+ .trim();
318
+
309
319
  // The question of the stop <arret>, `{ question, qui }`, or null for a stop of no circuit.
310
320
  export const monteeDe = arret => MONTEES[arret] ?? null;