@roomi-fields/grillhouse 0.30.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +48 -0
  3. package/agents/developpeur.md +0 -1
  4. package/agents/explorateur.md +0 -1
  5. package/agents/questionneur.md +0 -1
  6. package/agents/testwriter.md +0 -1
  7. package/dist/temporal/circuit/client.d.ts +2 -2
  8. package/dist/temporal/circuit/client.js.map +1 -1
  9. package/dist/temporal/circuit/commande.js +4 -4
  10. package/dist/temporal/circuit/commande.js.map +1 -1
  11. package/dist/temporal/circuit/contrat.d.ts +3 -3
  12. package/dist/temporal/circuit/contrat.js +8 -2
  13. package/dist/temporal/circuit/contrat.js.map +1 -1
  14. package/dist/temporal/circuit/deroule.js +3 -3
  15. package/dist/temporal/circuit/deroule.js.map +1 -1
  16. package/dist/temporal/commande.js +5 -6
  17. package/dist/temporal/commande.js.map +1 -1
  18. package/dist/temporal/installation.d.ts +3 -6
  19. package/dist/temporal/installation.js +19 -38
  20. package/dist/temporal/installation.js.map +1 -1
  21. package/dist/temporal/tickets/activites.d.ts +1 -0
  22. package/dist/temporal/tickets/activites.js +5 -0
  23. package/dist/temporal/tickets/activites.js.map +1 -1
  24. package/dist/temporal/tickets/contrat.d.ts +10 -0
  25. package/dist/temporal/tickets/deroule.js +8 -1
  26. package/dist/temporal/tickets/deroule.js.map +1 -1
  27. package/docs/ARCHITECTURE.md +119 -27
  28. package/docs/CADRE.md +20 -0
  29. package/docs/INTERFACE.md +17 -4
  30. package/hooks/hooks.json +4 -0
  31. package/package.json +2 -2
  32. package/scripts/activites.mjs +155 -84
  33. package/scripts/aiguillage.mjs +35 -11
  34. package/scripts/attente-au-tour.mjs +99 -0
  35. package/scripts/avancement.mjs +27 -10
  36. package/scripts/base-des-workflows.mjs +57 -0
  37. package/scripts/bilan.mjs +101 -25
  38. package/scripts/cadre.mjs +5 -2
  39. package/scripts/circuit.mjs +173 -58
  40. package/scripts/composants-affectes.mjs +64 -21
  41. package/scripts/composition-des-langages.mjs +5 -3
  42. package/scripts/conformite.mjs +54 -19
  43. package/scripts/copies-finies.mjs +8 -1
  44. package/scripts/dependances-internes.mjs +9 -3
  45. package/scripts/dernier-vert.mjs +84 -23
  46. package/scripts/dette.mjs +32 -11
  47. package/scripts/donnees-cles.mjs +24 -8
  48. package/scripts/droits.mjs +40 -15
  49. package/scripts/effets.mjs +9 -0
  50. package/scripts/empreinte-d-etape.mjs +17 -0
  51. package/scripts/engendres.mjs +15 -5
  52. package/scripts/enveloppe/enveloppe.mjs +141 -48
  53. package/scripts/enveloppe/travail-de-la-copie.mjs +36 -12
  54. package/scripts/etapes.mjs +1 -1
  55. package/scripts/faits-du-circuit.mjs +1 -1
  56. package/scripts/flux-des-paquets.mjs +21 -7
  57. package/scripts/gardes-du-cadre.mjs +9 -3
  58. package/scripts/init.mjs +11 -4
  59. package/scripts/integration/file.mjs +84 -29
  60. package/scripts/integration/integrer.mjs +70 -24
  61. package/scripts/integration/rejeu.mjs +26 -9
  62. package/scripts/jointure.d.ts +10 -1
  63. package/scripts/journal-des-etats.d.mts +41 -0
  64. package/scripts/journal-des-etats.mjs +273 -0
  65. package/scripts/journal.mjs +119 -0
  66. package/scripts/langages/cargo/commandes.mjs +97 -18
  67. package/scripts/langages/cargo/composants.mjs +24 -8
  68. package/scripts/langages/cargo/index.mjs +7 -0
  69. package/scripts/langages/cargo/tests-de-head.mjs +25 -9
  70. package/scripts/langages/python/commandes.mjs +3 -1
  71. package/scripts/langages/python/index.mjs +6 -0
  72. package/scripts/langages/typescript/chemins-des-tests.mjs +6 -2
  73. package/scripts/langages/typescript/composants.mjs +9 -3
  74. package/scripts/langages/typescript/consommateurs-arbitres.mjs +40 -14
  75. package/scripts/langages/typescript/consommateurs.mjs +39 -14
  76. package/scripts/langages/typescript/elements-du-lot.mjs +36 -12
  77. package/scripts/langages/typescript/frontieres.mjs +112 -22
  78. package/scripts/langages/typescript/index-interfaces.mjs +36 -13
  79. package/scripts/langages/typescript/index.mjs +12 -3
  80. package/scripts/langages/typescript/interfaces-contre-code.mjs +109 -41
  81. package/scripts/langages/typescript/lecteurs.mjs +36 -11
  82. package/scripts/langages/typescript/migrations/0.23.0-config-vitest.mjs +15 -5
  83. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +6 -2
  84. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +6 -2
  85. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +3 -1
  86. package/scripts/langages/typescript/parcours.mjs +12 -4
  87. package/scripts/langages/typescript/regle-des-tests.mjs +9 -3
  88. package/scripts/langages/typescript/resumes.mjs +9 -3
  89. package/scripts/langages/typescript/tailles-des-tests.mjs +58 -16
  90. package/scripts/langages/typescript/tests-de-nuit.mjs +3 -1
  91. package/scripts/langages/typescript/tests.mjs +24 -8
  92. package/scripts/langages/typescript/titres-de-tests.mjs +35 -12
  93. package/scripts/langages/typescript/turbo-des-paquets.mjs +152 -51
  94. package/scripts/langages/typescript/verdict.mjs +3 -1
  95. package/scripts/langages/typescript/verifier.mjs +61 -14
  96. package/scripts/langages/typescript/vitest-config/avancement.reporter.mjs +15 -5
  97. package/scripts/langages/typescript/vitest-config/base.mjs +10 -2
  98. package/scripts/langages/typescript/vitest-config/changements.mjs +21 -8
  99. package/scripts/langages/typescript/vitest-config/delais.mjs +9 -3
  100. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +12 -4
  101. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +17 -6
  102. package/scripts/langages/typescript/vitest-config/lances.mjs +83 -27
  103. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +7 -0
  104. package/scripts/langages/typescript/vitest-config/resultats.mjs +3 -1
  105. package/scripts/langages.d.mts +20 -0
  106. package/scripts/lint-des-scripts.mjs +58 -0
  107. package/scripts/matiere-de-test.d.ts +11 -0
  108. package/scripts/mesure/base-de-passe.mjs +117 -25
  109. package/scripts/mesure/pression.mjs +9 -3
  110. package/scripts/migrations/0.23.0-charte-importee.mjs +6 -2
  111. package/scripts/migrations/0.23.0-crochets-de-seance.mjs +25 -8
  112. package/scripts/migrations/0.23.0-marche-du-projet.mjs +18 -6
  113. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +48 -16
  114. package/scripts/migrations/0.24.12-tri-des-decouvertes.mjs +6 -2
  115. package/scripts/migrations/0.25.0-script-des-tests.mjs +15 -5
  116. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +6 -2
  117. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +7 -7
  118. package/scripts/nuit.sh +24 -0
  119. package/scripts/outil.mjs +3 -1
  120. package/scripts/outils-cles.mjs +18 -7
  121. package/scripts/paquet-npm.mjs +15 -5
  122. package/scripts/paquets.mjs +12 -4
  123. package/scripts/passe-de-la-machine.mjs +7 -2
  124. package/scripts/places-de-la-machine.mjs +72 -12
  125. package/scripts/preparation.mjs +15 -5
  126. package/scripts/registre.mjs +6 -2
  127. package/scripts/reprise.mjs +66 -0
  128. package/scripts/resultats.mjs +105 -37
  129. package/scripts/seances.mjs +22 -4
  130. package/scripts/services-du-noyau.mjs +1 -0
  131. package/scripts/sous-commandes.mjs +5 -1
  132. package/scripts/style-a-l-ecriture.mjs +48 -17
  133. package/scripts/superviseur.mjs +127 -75
  134. package/scripts/tableau.mjs +133 -10
  135. package/scripts/taches-du-graphe.mjs +33 -13
  136. package/scripts/ticket-du-circuit.mjs +40 -0
  137. package/scripts/transitions.mjs +159 -29
  138. package/scripts/verrou-de-fichier.mjs +6 -2
  139. package/scripts/verrou-de-machine.mjs +123 -39
  140. package/scripts/verrous/commande.mjs +50 -17
  141. package/scripts/verrous/ticket-du-sous-agent.mjs +9 -3
  142. package/scripts/verrous/verrou.mjs +42 -14
  143. package/skills/developpeur/SKILL.md +1 -1
  144. package/skills/explorateur/SKILL.md +8 -2
  145. package/skills/grill/SKILL.md +3 -57
  146. package/skills/grill/references/paquets.md +60 -0
  147. package/skills/mesure/SKILL.md +3 -0
  148. package/skills/pitmaster/SKILL.md +16 -27
  149. package/skills/questionneur/SKILL.md +1 -1
  150. package/skills/relecteur/SKILL.md +2 -2
  151. package/skills/testwriter/SKILL.md +19 -7
  152. package/skills/release/SKILL.md +0 -134
  153. package/skills/release/scripts/update-version.cjs +0 -92
@@ -104,7 +104,9 @@ import { ouvrirBase } from '../mesure/base-de-passe.mjs';
104
104
  // backslash or a control character comes between quotes with C escapes (`\303\251` for `é`).
105
105
  // Returns the name itself.
106
106
  function nomDeGit(ecrit) {
107
- if (!ecrit.startsWith('"')) return ecrit;
107
+ if (!ecrit.startsWith('"')) {
108
+ return ecrit;
109
+ }
108
110
  const octets = [];
109
111
  const echappes = { n: 10, t: 9, r: 13, a: 7, b: 8, f: 12, v: 11 };
110
112
  const corps = Buffer.from(ecrit.slice(1, -1), 'utf8');
@@ -142,11 +144,14 @@ export function refusVerdicts(ticket, comments) {
142
144
  // resumption (scripts/circuit.mjs), as a CI refuses a pull request without its required label
143
145
  // before it runs a job. `ticket` and `comments` are Beads' JSON.
144
146
  export function refusArbitrage(ticket, comments) {
145
- if (!(ticket.labels ?? []).includes('arbitrage')) return null;
147
+ if (!(ticket.labels ?? []).includes('arbitrage')) {
148
+ return null;
149
+ }
146
150
  const id = ticket.id;
147
151
  const arbitrages = comments.filter(c => estArbitrage(c.text));
148
- if (arbitrages.length === 0)
152
+ if (arbitrages.length === 0) {
149
153
  return `${id} est étiqueté arbitrage sans commentaire « Arbitrage ».`;
154
+ }
150
155
  for (const a of arbitrages) {
151
156
  if (!arbitrageTranche(comments, a)) {
152
157
  const titre = a.text.trim().split('\n')[0];
@@ -162,10 +167,13 @@ export function refusLots(tests, code, racine) {
162
167
  const langage = langageDe(racine);
163
168
  const testwriter = f => langage.estUnTest(f, racine) !== null;
164
169
  const horsTests = tests.filter(f => !testwriter(f));
165
- if (horsTests.length) return `Le lot de tests touche du code : ${horsTests.join(', ')}.`;
170
+ if (horsTests.length) {
171
+ return `Le lot de tests touche du code : ${horsTests.join(', ')}.`;
172
+ }
166
173
  const duTestwriter = code.filter(testwriter);
167
- if (duTestwriter.length)
174
+ if (duTestwriter.length) {
168
175
  return `Le lot de code touche des fichiers du testwriter (tests ou matière de test partagée) : ${duTestwriter.join(', ')}.`;
176
+ }
169
177
  return null;
170
178
  }
171
179
 
@@ -176,10 +184,11 @@ function lire(argv) {
176
184
  const v = argv[i + 1];
177
185
  switch (argv[i]) {
178
186
  case '--ticket':
179
- if (o.ticket !== null)
187
+ if (o.ticket !== null) {
180
188
  return {
181
189
  faute: `un seul --ticket : ${v} en est un second, et une livraison est un ticket.`,
182
190
  };
191
+ }
183
192
  o.ticket = v;
184
193
  i++;
185
194
  break;
@@ -203,7 +212,9 @@ function lire(argv) {
203
212
  return { faute: null };
204
213
  }
205
214
  }
206
- if (!o.ticket || !o.message || !(o.tests || o.code)) return { faute: null };
215
+ if (!o.ticket || !o.message || !(o.tests || o.code)) {
216
+ return { faute: null };
217
+ }
207
218
  return o;
208
219
  }
209
220
 
@@ -215,7 +226,9 @@ function horsLot(copieTicket, fichiers) {
215
226
  ['-C', copieTicket, 'status', '--porcelain=v1', '-z', '-uall', '--no-renames'],
216
227
  { encoding: 'utf8' }
217
228
  );
218
- if (r.status !== 0) return null;
229
+ if (r.status !== 0) {
230
+ return null;
231
+ }
219
232
  const dans = new Set(fichiers);
220
233
  return r.stdout
221
234
  .split('\0')
@@ -232,10 +245,18 @@ function differents(copieTicket, lots, fichiers, tmp) {
232
245
  const env = { ...process.env, GIT_INDEX_FILE: index };
233
246
  const dansCopie = (...args) =>
234
247
  spawnSync('git', ['-C', copieTicket, ...args], { encoding: 'utf8', env });
235
- if (dansCopie('read-tree', 'HEAD').status !== 0) return fichiers;
236
- for (const p of lots) if (dansCopie('apply', '--cached', p).status !== 0) return fichiers;
248
+ if (dansCopie('read-tree', 'HEAD').status !== 0) {
249
+ return fichiers;
250
+ }
251
+ for (const p of lots) {
252
+ if (dansCopie('apply', '--cached', p).status !== 0) {
253
+ return fichiers;
254
+ }
255
+ }
237
256
  const r = dansCopie('diff', '--name-only', '--no-renames', '-z', '--', ...fichiers);
238
- if (r.status !== 0) return fichiers;
257
+ if (r.status !== 0) {
258
+ return fichiers;
259
+ }
239
260
  return r.stdout.split('\0').filter(Boolean);
240
261
  }
241
262
 
@@ -288,17 +309,22 @@ function main(argv) {
288
309
  // 1. The verdict.
289
310
  const show = bd('show', o.ticket, '--json');
290
311
  const comments = bd('comments', o.ticket, '--json');
291
- if (show.status !== 0 || comments.status !== 0)
312
+ if (show.status !== 0 || comments.status !== 0) {
292
313
  return refuser(`Ticket ${o.ticket} illisible : ${show.stderr}${comments.stderr}`);
314
+ }
293
315
  const r1 = refusVerdicts(JSON.parse(show.stdout)[0], JSON.parse(comments.stdout || '[]'));
294
- if (r1) return refuser(r1);
316
+ if (r1) {
317
+ return refuser(r1);
318
+ }
295
319
  dire('✓ verdicts');
296
320
 
297
321
  // 2. The lots.
298
322
  const lots = [o.tests, o.code].filter(Boolean).map(absolu);
299
323
  const fichiersDe = p => {
300
324
  const r = git('apply', '--numstat', '-z', p);
301
- if (r.status !== 0) return null;
325
+ if (r.status !== 0) {
326
+ return null;
327
+ }
302
328
  const destinations = r.stdout
303
329
  .split('\0')
304
330
  .map(l => l.split('\t')[2])
@@ -312,9 +338,13 @@ function main(argv) {
312
338
  };
313
339
  const tests = o.tests ? fichiersDe(absolu(o.tests)) : [];
314
340
  const code = o.code ? fichiersDe(absolu(o.code)) : [];
315
- if (!tests || !code) return refuser('Un patch du lot est illisible.');
341
+ if (!tests || !code) {
342
+ return refuser('Un patch du lot est illisible.');
343
+ }
316
344
  const r2 = refusLots(tests, code, racine);
317
- if (r2) return refuser(r2);
345
+ if (r2) {
346
+ return refuser(r2);
347
+ }
318
348
  const fichiers = [...new Set([...tests, ...code])];
319
349
  dire(`✓ lots : ${fichiers.length} fichiers`);
320
350
  let duCircuit = [];
@@ -336,7 +366,9 @@ function main(argv) {
336
366
  // 3. The main tree: the lots' files are free there, so the queue can bring them. The ticket's
337
367
  // copy holds the lot and nothing else.
338
368
  const tenus = git('status', '--porcelain', '--', ...fichiers).stdout.trim();
339
- if (tenus) return refuser(`Des fichiers du lot sont modifiés dans l'arbre :\n${tenus}`);
369
+ if (tenus) {
370
+ return refuser(`Des fichiers du lot sont modifiés dans l'arbre :\n${tenus}`);
371
+ }
340
372
  dire('✓ arbre principal libre');
341
373
  const branche = `agent/${o.ticket}`;
342
374
  const copieTicket = path.join(racine, '.claude', 'worktrees', o.ticket);
@@ -352,7 +384,9 @@ function main(argv) {
352
384
  return refuser(`La copie du ticket ${copieTicket} n'est pas sur la branche ${branche}.`);
353
385
  }
354
386
  const autres = horsLot(copieTicket, fichiers);
355
- if (autres === null) return refuser(`L'état de la copie ${copieTicket} ne se lit pas.`);
387
+ if (autres === null) {
388
+ return refuser(`L'état de la copie ${copieTicket} ne se lit pas.`);
389
+ }
356
390
  if (autres.length) {
357
391
  return refuser(
358
392
  `La copie du ticket porte autre chose que le lot :\n${autres.map(f => ` ${f}`).join('\n')}`
@@ -365,7 +399,9 @@ function main(argv) {
365
399
  // are kept only while the lock file and the manifests are the same (a CI cache keyed by them).
366
400
  const copie = path.join(racine, '.claude', 'worktrees', 'integration');
367
401
  const ouverte = ouvrirCopie({ racine, copie, ref: 'HEAD', dire });
368
- if (ouverte.refus) return refuser(ouverte.refus);
402
+ if (ouverte.refus) {
403
+ return refuser(ouverte.refus);
404
+ }
369
405
  const { dansCopie, monter, installer, tester } = ouverte;
370
406
 
371
407
  // 5. The lots, applied in the copy without the files a reference writes in full, then
@@ -373,7 +409,9 @@ function main(argv) {
373
409
  const sansEntiers = entiers.map(f => `--exclude=${f}`);
374
410
  for (const p of lots) {
375
411
  const r = dansCopie('apply', '--3way', '--index', ...sansEntiers, p);
376
- if (r.status !== 0) return refuser(`Le lot ${p} ne s'applique pas :\n${r.stdout}${r.stderr}`);
412
+ if (r.status !== 0) {
413
+ return refuser(`Le lot ${p} ne s'applique pas :\n${r.stdout}${r.stderr}`);
414
+ }
377
415
  }
378
416
  const divergents = avecCopie ? differents(copieTicket, lots, fichiers, tmp) : [];
379
417
  if (divergents.length) {
@@ -383,7 +421,9 @@ function main(argv) {
383
421
  }
384
422
  dire('✓ lots appliqués');
385
423
  const installation = installer();
386
- if (installation) return refuser(installation);
424
+ if (installation) {
425
+ return refuser(installation);
426
+ }
387
427
  if (aRegenerer.length) {
388
428
  const env = avecLesDonnees(donnees, avecLesOutils(outils, process.env));
389
429
  const refus = regenerer({
@@ -397,7 +437,9 @@ function main(argv) {
397
437
  env,
398
438
  }),
399
439
  });
400
- if (refus) return refuser(refus);
440
+ if (refus) {
441
+ return refuser(refus);
442
+ }
401
443
  dire(`✓ références régénérées sur main à jour : ${aRegenerer.map(r => r.nom).join(', ')}`);
402
444
  }
403
445
 
@@ -410,7 +452,9 @@ function main(argv) {
410
452
  );
411
453
  return A_REPASSER;
412
454
  }
413
- if (verdict !== 0) return refuser('Les tests refusent le lot (sortie ci-dessus).');
455
+ if (verdict !== 0) {
456
+ return refuser('Les tests refusent le lot (sortie ci-dessus).');
457
+ }
414
458
  dire('✓ tests');
415
459
 
416
460
  // 7. The commit, in the copy: the commit validated is the commit that enters.
@@ -424,7 +468,9 @@ function main(argv) {
424
468
  env: { ...process.env, GRILLHOUSE_INTEGRATION: '1' },
425
469
  }
426
470
  );
427
- if (c.status !== 0) return refuser(`Le commit est refusé :\n${c.stdout}${c.stderr}`);
471
+ if (c.status !== 0) {
472
+ return refuser(`Le commit est refusé :\n${c.stdout}${c.stderr}`);
473
+ }
428
474
  const commit = dansCopie('rev-parse', 'HEAD').stdout.trim();
429
475
 
430
476
  // 8. The branch of the ticket takes the commit; the ticket's copy follows it (it carried the
@@ -59,7 +59,9 @@ function empreinteDesDependances(copie, verrou, dansCopie) {
59
59
  .filter(Boolean)
60
60
  .sort();
61
61
  const h = createHash('sha256').update(readFileSync(verrou));
62
- for (const f of suivis) h.update(`\0${f}\0`).update(readFileSync(path.join(copie, f)));
62
+ for (const f of suivis) {
63
+ h.update(`\0${f}\0`).update(readFileSync(path.join(copie, f)));
64
+ }
63
65
  return h.digest('hex');
64
66
  }
65
67
 
@@ -91,9 +93,13 @@ export function ouvrirCopie({ racine, copie, ref, dire }) {
91
93
  ? dansCopie('checkout', '-q', '--detach', '--force', tete).status === 0 &&
92
94
  dansCopie('clean', '-q', '-f', '-d', '-x', '-e', 'node_modules').status === 0
93
95
  : git('worktree', 'add', '-q', '--detach', copie, tete).status === 0;
94
- if (!prete) return `La copie ${copie} ne se prépare pas.`;
96
+ if (!prete) {
97
+ return `La copie ${copie} ne se prépare pas.`;
98
+ }
95
99
  const poses = spawnSync('bash', [SOUS_MODULES, 'pose', copie], { encoding: 'utf8' });
96
- if (poses.status !== 0) return `La copie ne pose pas ses sous-modules : ${poses.stderr.trim()}`;
100
+ if (poses.status !== 0) {
101
+ return `La copie ne pose pas ses sous-modules : ${poses.stderr.trim()}`;
102
+ }
97
103
  partages = poses.stdout;
98
104
  return null;
99
105
  };
@@ -109,7 +115,9 @@ export function ouvrirCopie({ racine, copie, ref, dire }) {
109
115
  }
110
116
  refus = preparer();
111
117
  }
112
- if (refus) return { refus };
118
+ if (refus) {
119
+ return { refus };
120
+ }
113
121
  const monter = (...commande) => [
114
122
  SOUS_MODULES,
115
123
  'monter',
@@ -119,7 +127,9 @@ export function ouvrirCopie({ racine, copie, ref, dire }) {
119
127
  ...commande,
120
128
  ];
121
129
  const montage = spawnSync('bash', monter('true'), { encoding: 'utf8' });
122
- if (montage.status !== 0) return { refus: montage.stderr.trim() };
130
+ if (montage.status !== 0) {
131
+ return { refus: montage.stderr.trim() };
132
+ }
123
133
  const lancer = (commande, args, envPlus = null) => {
124
134
  const r = spawnSync('bash', monter(commande, ...args), {
125
135
  cwd: copie,
@@ -140,17 +150,24 @@ export function ouvrirCopie({ racine, copie, ref, dire }) {
140
150
  // differ, the key is written again. Null when they agree, else the refusal.
141
151
  const accorder = () => {
142
152
  const verrouNpm = path.join(copie, VERROU);
143
- if (!existsSync(verrouNpm)) return null;
153
+ if (!existsSync(verrouNpm)) {
154
+ return null;
155
+ }
144
156
  const cle = path.join(copie, 'node_modules', '.integration-lock');
145
157
  const empreinte = empreinteDesDependances(copie, verrouNpm, dansCopie);
146
- if (existsSync(cle) && readFileSync(cle, 'utf8') === empreinte) return null;
147
- if (npm(['ci', '--no-audit', '--no-fund', '--silent']).status !== 0)
158
+ if (existsSync(cle) && readFileSync(cle, 'utf8') === empreinte) {
159
+ return null;
160
+ }
161
+ if (npm(['ci', '--no-audit', '--no-fund', '--silent']).status !== 0) {
148
162
  return DEPENDANCES_REFUSEES;
163
+ }
149
164
  writeFileSync(cle, empreinte);
150
165
  return null;
151
166
  };
152
167
  const refusOuverture = accorder();
153
- if (refusOuverture) return { refus: refusOuverture };
168
+ if (refusOuverture) {
169
+ return { refus: refusOuverture };
170
+ }
154
171
  dire(`✓ copie propre sur ${tete.slice(0, 7)}`);
155
172
 
156
173
  // The checks of the copy: its preparation, then its verification; the first that is not green
@@ -226,6 +226,11 @@ export interface Composition {
226
226
  matieres(racine: string): Composant[];
227
227
  /** Whether the component plays tests: the runner of the language has tests to play in it. */
228
228
  joueDesTests(racine: string, composant: Composant): boolean;
229
+ /** The hashes of the inputs of the tests tasks of the components `noms` (their package names)
230
+ * and of their dependents, `{ <paquet>: <hash> }`, as the task runner plans them (the hash of a
231
+ * task covers the content of the files it reads and of what it waits for); null when the runner
232
+ * gives no plan. The fingerprint of a step of the circuit reads them. */
233
+ empreintes(racine: string, noms: string[]): Record<string, string> | null;
229
234
  lecteurs(
230
235
  racine: string,
231
236
  o: { composants: Composant[]; noms: string[]; texte: string; nommes: Composant[] }
@@ -276,6 +281,10 @@ export interface Composition {
276
281
 
277
282
  /** A module of language, the default export of `scripts/langages/<nom>/index.mjs`. */
278
283
  export interface Langage extends Composition {
284
+ /** The programs of this language's toolchain (`cargo`, `python3`) that the installer of Temporal
285
+ * requires in its PATH, each refused by its name when absent; none for TypeScript, Node being a
286
+ * tool of the account. */
287
+ executables: string[];
279
288
  /** The manifest of a package of this language, in its folder (`package.json`, `Cargo.toml`):
280
289
  * the guard of the languages asks it of a package the architecture declares of this language. */
281
290
  manifeste: string;
@@ -397,7 +406,7 @@ export function cacheDeLaRacine(
397
406
  ): string;
398
407
  /** The line of the guard of a pass of tests, what its tests left in their temporary directory
399
408
  * named; null when they left nothing. */
400
- export function ligneDesRestes(restes: string[]): string | null;
409
+ export function ligneDesRestes(restes: string[], paquet?: string): string | null;
401
410
  /** Runs `retirer` when the process is interrupted, then lets the signal end it; the removal of
402
411
  * the handlers. */
403
412
  export function retirerALInterruption(retirer: () => void): () => void;
@@ -0,0 +1,41 @@
1
+ // The types of the journal of states (./journal-des-etats.mjs).
2
+
3
+ /** A line of the journal of states. */
4
+ export interface LigneDuJournal {
5
+ ts: string;
6
+ genre: 'circuit' | 'file' | 'places';
7
+ ticket: string | null;
8
+ etape: string | null;
9
+ boucle: number | null;
10
+ place: string | null;
11
+ raison: string;
12
+ }
13
+
14
+ /** A trace to write: a line, `ts` set when it already has its date. */
15
+ export type Trace = Partial<LigneDuJournal> & { genre: LigneDuJournal['genre'] };
16
+
17
+ export const AGE_MAX_JOURS: number;
18
+ export const TAILLE_MAX: number;
19
+ export function heureLocale(date?: Date): string;
20
+ export function dossierDuJournal(racine: string): string;
21
+ export function ecrireLaTrace(
22
+ racine: string,
23
+ trace: Trace,
24
+ options?: { maintenant?: Date; dire?: (message: string) => void }
25
+ ): { ecrit: boolean };
26
+ export function traceDeLaFile(e: { ticket: string; evenement: 'lance' | 'termine' }): Trace;
27
+ export function traceDesPlaces(e: {
28
+ evenement: 'prise' | 'rendue' | 'attente';
29
+ ticket?: string | null;
30
+ place?: string | null;
31
+ raison?: string;
32
+ }): Trace;
33
+ export function lireLeJournal(
34
+ racine: string,
35
+ plage?: { depuis?: string; jusquA?: string; ticket?: string }
36
+ ): { lignes: LigneDuJournal[] };
37
+ export function nettoyerLeJournal(
38
+ racine: string,
39
+ options?: { maintenant?: Date; ageMaxJours?: number; tailleMax?: number }
40
+ ): { retires: string[] };
41
+ export function ensemblesEnTravail(lignes: LigneDuJournal[]): { ts: string; enTravail: string[] }[];
@@ -0,0 +1,273 @@
1
+ // The journal of states of a project (grillhouse-4nr.20, docs/ARCHITECTURE.md « Le journal des
2
+ // états »): one dated JSONL line per change of state of the circuits, the queue and the places, a
3
+ // segment per local date under the common git directory (`<git-common-dir>/grillhouse-journal/
4
+ // <YYYY-MM-DD>.jsonl`, never versioned), read back as a chronology. As the log of a scheduler: a
5
+ // whole line in one append, no lock, no wait, so that it never delays what it traces.
6
+ //
7
+ // A line: `{ ts, genre, ticket, etape, boucle, place, raison }`, `genre` one of `circuit`, `file`,
8
+ // `places`; `ts` ISO 8601 with the local offset; `raison` empty for a normal transition, the name
9
+ // of the stop for a stop, the cause of the return for a loop, the message of the wait for a wait
10
+ // for a place.
11
+ import { execFileSync } from 'node:child_process';
12
+ import {
13
+ appendFileSync,
14
+ existsSync,
15
+ mkdirSync,
16
+ readdirSync,
17
+ readFileSync,
18
+ statSync,
19
+ unlinkSync,
20
+ } from 'node:fs';
21
+ import path from 'node:path';
22
+
23
+ /** The age, in days, beyond which the cleaning removes a segment. */
24
+ export const AGE_MAX_JOURS = 14;
25
+ /** The total size, in bytes, beyond which the cleaning removes the oldest segments (50 Mo). */
26
+ export const TAILLE_MAX = 50 * 1024 * 1024;
27
+ // A line, its newline included, fits in this many bytes: an append of that size stays whole
28
+ // (POSIX `PIPE_BUF` order, the size git and journald hold their lines to).
29
+ const LIGNE_MAX = 4096;
30
+ const SEGMENT = /^(\d{4}-\d{2}-\d{2})\.jsonl$/;
31
+
32
+ const deux = n => String(n).padStart(2, '0');
33
+
34
+ /**
35
+ * <date> in ISO 8601 with the local offset (`2026-11-09T10:00:00.250+01:00`).
36
+ * @param {Date} [date]
37
+ * @returns {string}
38
+ */
39
+ export function heureLocale(date = new Date()) {
40
+ const d = date;
41
+ const decalage = -d.getTimezoneOffset();
42
+ const signe = decalage < 0 ? '-' : '+';
43
+ const h = Math.floor(Math.abs(decalage) / 60);
44
+ const m = Math.abs(decalage) % 60;
45
+ return (
46
+ `${d.getFullYear()}-${deux(d.getMonth() + 1)}-${deux(d.getDate())}` +
47
+ `T${deux(d.getHours())}:${deux(d.getMinutes())}:${deux(d.getSeconds())}` +
48
+ `.${String(d.getMilliseconds()).padStart(3, '0')}${signe}${deux(h)}:${deux(m)}`
49
+ );
50
+ }
51
+
52
+ const communs = new Map();
53
+
54
+ /**
55
+ * The directory of the journal of the project at <racine>: under its common git directory.
56
+ * @param {string} racine
57
+ * @returns {string}
58
+ * @throws {Error} when <racine> is no git project
59
+ */
60
+ export function dossierDuJournal(racine) {
61
+ let commun = communs.get(racine);
62
+ if (!commun) {
63
+ commun = execFileSync(
64
+ 'git',
65
+ ['-C', racine, 'rev-parse', '--path-format=absolute', '--git-common-dir'],
66
+ { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }
67
+ ).trim();
68
+ communs.set(racine, commun);
69
+ }
70
+ return path.join(commun, 'grillhouse-journal');
71
+ }
72
+
73
+ // The line of <trace> with every field, the raison cut so that the whole line, newline included,
74
+ // fits under LIGNE_MAX bytes (by characters, never through one).
75
+ function ligneEntiere(trace, ts) {
76
+ const champ = v => (v === undefined ? null : v);
77
+ const ligne = {
78
+ ts,
79
+ genre: trace.genre,
80
+ ticket: champ(trace.ticket),
81
+ etape: champ(trace.etape),
82
+ boucle: champ(trace.boucle),
83
+ place: champ(trace.place),
84
+ raison: trace.raison ?? '',
85
+ };
86
+ let raison = Array.from(String(ligne.raison));
87
+ let texte = JSON.stringify(ligne);
88
+ while (Buffer.byteLength(texte) + 1 > LIGNE_MAX && raison.length > 0) {
89
+ const exces = Buffer.byteLength(texte) + 1 - LIGNE_MAX;
90
+ raison = raison.slice(0, Math.max(0, raison.length - Math.max(1, Math.ceil(exces / 4))));
91
+ texte = JSON.stringify({ ...ligne, raison: raison.join('') });
92
+ }
93
+ return `${texte}\n`;
94
+ }
95
+
96
+ let echecDit = false;
97
+
98
+ /**
99
+ * The trace <trace> (`{ genre, ticket, etape, boucle, place, raison }`, `ts` when it already has
100
+ * one) appended to the segment of its local date, in one write. A trace that cannot be written
101
+ * (no project, a full disk) never throws: `{ ecrit: false }`, said once through <dire>.
102
+ * @param {string} racine the project
103
+ * @param {object} trace
104
+ * @param {{ maintenant?: Date, dire?: (m: string) => void }} [options]
105
+ * @returns {{ ecrit: boolean }}
106
+ */
107
+ export function ecrireLaTrace(racine, trace, { maintenant, dire } = {}) {
108
+ try {
109
+ const ts = trace.ts ?? heureLocale(maintenant ?? new Date());
110
+ const dossier = dossierDuJournal(racine);
111
+ mkdirSync(dossier, { recursive: true });
112
+ appendFileSync(path.join(dossier, `${ts.slice(0, 10)}.jsonl`), ligneEntiere(trace, ts), {
113
+ flag: 'a',
114
+ });
115
+ return { ecrit: true };
116
+ } catch (e) {
117
+ return dit(e, dire);
118
+ }
119
+ }
120
+
121
+ function dit(erreur, dire) {
122
+ if (!echecDit) {
123
+ echecDit = true;
124
+ const m = `⚠️ journal des états non écrit : ${erreur?.message ?? erreur}`;
125
+ (dire ?? (t => process.stderr.write(`${t}\n`)))(m);
126
+ }
127
+ return { ecrit: false };
128
+ }
129
+
130
+ /** The trace of a circuit of the queue launched (`lance`) or ended (`termine`). */
131
+ export function traceDeLaFile({ ticket, evenement }) {
132
+ return { genre: 'file', ticket, etape: evenement, boucle: null, place: null, raison: '' };
133
+ }
134
+
135
+ /** The trace of a place taken (`prise`), given back (`rendue`) or waited for (`attente`). */
136
+ export function traceDesPlaces({ evenement, ticket = null, place = null, raison = '' }) {
137
+ return { genre: 'places', ticket, etape: evenement, boucle: null, place, raison };
138
+ }
139
+
140
+ const instant = ts => Date.parse(ts);
141
+
142
+ /**
143
+ * The lines of the journal of <racine> within the range, from every segment, in the order of their
144
+ * timestamps (instants, the order of the lines for a tie); a line unreadable is left out.
145
+ * @param {string} racine
146
+ * @param {{ depuis?: string, jusquA?: string, ticket?: string }} [plage] ISO 8601, bounds included
147
+ * @returns {{ lignes: object[] }}
148
+ */
149
+ export function lireLeJournal(racine, { depuis, jusquA, ticket } = {}) {
150
+ let dossier;
151
+ try {
152
+ dossier = dossierDuJournal(racine);
153
+ } catch {
154
+ return { lignes: [] };
155
+ }
156
+ if (!existsSync(dossier)) {
157
+ return { lignes: [] };
158
+ }
159
+ const du = depuis === undefined ? -Infinity : instant(depuis);
160
+ const au = jusquA === undefined ? Infinity : instant(jusquA);
161
+ const lignes = [];
162
+ for (const nom of readdirSync(dossier)
163
+ .filter(n => SEGMENT.test(n))
164
+ .sort()) {
165
+ let brut;
166
+ try {
167
+ brut = readFileSync(path.join(dossier, nom), 'utf8');
168
+ } catch {
169
+ continue;
170
+ }
171
+ for (const l of brut.split('\n')) {
172
+ let v;
173
+ try {
174
+ v = l ? JSON.parse(l) : null;
175
+ } catch {
176
+ continue;
177
+ }
178
+ if (!v || typeof v !== 'object' || Array.isArray(v) || Number.isNaN(instant(v.ts))) {
179
+ continue;
180
+ }
181
+ const t = instant(v.ts);
182
+ if (t >= du && t <= au && (ticket === undefined || v.ticket === ticket)) {
183
+ lignes.push({ v, t });
184
+ }
185
+ }
186
+ }
187
+ return { lignes: lignes.sort((a, b) => a.t - b.t).map(x => x.v) };
188
+ }
189
+
190
+ const jourDe = nom =>
191
+ Date.UTC(
192
+ ...nom
193
+ .slice(0, 10)
194
+ .split('-')
195
+ .map((n, i) => Number(n) - (i === 1 ? 1 : 0))
196
+ );
197
+
198
+ /**
199
+ * The cleaning: removes whole segments older than <ageMaxJours> days, then, past <tailleMax> bytes
200
+ * in all, the oldest first, never the latest. It rewrites no segment, so a line written meanwhile
201
+ * is not lost; it touches only the journal of <racine>.
202
+ * @param {string} racine
203
+ * @param {{ maintenant?: Date, ageMaxJours?: number, tailleMax?: number }} [options]
204
+ * @returns {{ retires: string[] }}
205
+ */
206
+ export function nettoyerLeJournal(
207
+ racine,
208
+ { maintenant = new Date(), ageMaxJours = AGE_MAX_JOURS, tailleMax = TAILLE_MAX } = {}
209
+ ) {
210
+ let dossier;
211
+ try {
212
+ dossier = dossierDuJournal(racine);
213
+ } catch {
214
+ return { retires: [] };
215
+ }
216
+ if (!existsSync(dossier)) {
217
+ return { retires: [] };
218
+ }
219
+ const aujourdhui = jourDe(heureLocale(maintenant));
220
+ const retires = [];
221
+ const retirer = nom => {
222
+ try {
223
+ unlinkSync(path.join(dossier, nom));
224
+ } catch {
225
+ // already gone
226
+ }
227
+ retires.push(nom);
228
+ };
229
+ let restants = readdirSync(dossier)
230
+ .filter(n => SEGMENT.test(n))
231
+ .sort();
232
+ for (const nom of restants.filter(n => (aujourdhui - jourDe(n)) / 86_400_000 > ageMaxJours)) {
233
+ retirer(nom);
234
+ }
235
+ restants = restants.filter(n => !retires.includes(n));
236
+ const tailles = new Map(restants.map(n => [n, statSync(path.join(dossier, n)).size]));
237
+ let total = [...tailles.values()].reduce((a, b) => a + b, 0);
238
+ for (const nom of restants.slice(0, -1)) {
239
+ if (total <= tailleMax) {
240
+ break;
241
+ }
242
+ retirer(nom);
243
+ total -= tailles.get(nom);
244
+ }
245
+ return { retires };
246
+ }
247
+
248
+ /**
249
+ * The set of tickets at work after each launch or end of a circuit of the queue (the lines `file`
250
+ * `lance` and `termine`), in the order of the instants: `[{ ts, enTravail }]`, one entry per change.
251
+ * @param {object[]} lignes
252
+ * @returns {{ ts: string, enTravail: string[] }[]}
253
+ */
254
+ export function ensemblesEnTravail(lignes) {
255
+ const file = lignes
256
+ .filter(l => l.genre === 'file' && (l.etape === 'lance' || l.etape === 'termine'))
257
+ .map((l, i) => ({ l, i, t: instant(l.ts) }))
258
+ .sort((a, b) => a.t - b.t || a.i - b.i);
259
+ const en = new Set();
260
+ const rendu = [];
261
+ for (const { l } of file) {
262
+ if (l.etape === 'lance') {
263
+ if (en.has(l.ticket)) {
264
+ continue;
265
+ }
266
+ en.add(l.ticket);
267
+ } else if (!en.delete(l.ticket)) {
268
+ continue;
269
+ }
270
+ rendu.push({ ts: l.ts, enTravail: [...en] });
271
+ }
272
+ return rendu;
273
+ }