@roomi-fields/grillhouse 0.47.0 → 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 (102) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +54 -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 +221 -19
  53. package/scripts/circuit.mjs +47 -34
  54. package/scripts/commandes-composees.mjs +36 -6
  55. package/scripts/composition-des-langages.mjs +2 -0
  56. package/scripts/crochets.mjs +2 -2
  57. package/scripts/effets.mjs +2 -1
  58. package/scripts/enveloppe/enveloppe.mjs +61 -6
  59. package/scripts/enveloppe/travail-de-la-copie.mjs +2 -0
  60. package/scripts/etapes.mjs +11 -1
  61. package/scripts/etat-du-depot.mjs +23 -0
  62. package/scripts/faits-du-circuit.mjs +12 -23
  63. package/scripts/fermeture-de-la-machine.d.mts +27 -0
  64. package/scripts/fermeture-de-la-machine.mjs +108 -0
  65. package/scripts/greffons.mjs +1 -1
  66. package/scripts/integration/file.mjs +16 -13
  67. package/scripts/integration/integrer.mjs +2 -0
  68. package/scripts/jointure.d.ts +5 -0
  69. package/scripts/langages/c/index.mjs +2 -0
  70. package/scripts/langages/c/squelette.mjs +1 -1
  71. package/scripts/langages/cargo/index.mjs +2 -0
  72. package/scripts/langages/python/index.mjs +2 -0
  73. package/scripts/langages/typescript/index.mjs +3 -0
  74. package/scripts/langages/typescript/module-absent.mjs +24 -0
  75. package/scripts/langages/typescript/turbo-des-paquets.mjs +19 -1
  76. package/scripts/langages/typescript/vitest-config/lances.mjs +3 -1
  77. package/scripts/langages.mjs +25 -3
  78. package/scripts/machine.mjs +103 -0
  79. package/scripts/matieres-cles.mjs +17 -0
  80. package/scripts/matieres-lues.mjs +104 -0
  81. package/scripts/migrations/0.48.0-ci-declenchee-par-la-file.mjs +32 -0
  82. package/scripts/migrations/0.48.0-poussee-retiree.mjs +31 -0
  83. package/scripts/migrations.mjs +4 -0
  84. package/scripts/nuit.sh +16 -44
  85. package/scripts/passe-de-la-machine.mjs +9 -7
  86. package/scripts/places-de-la-machine.mjs +74 -11
  87. package/scripts/places-du-serveur.mjs +29 -8
  88. package/scripts/poussee-retiree.mjs +18 -0
  89. package/scripts/registre.d.mts +2 -2
  90. package/scripts/regles-des-places.d.mts +36 -5
  91. package/scripts/regles-des-places.mjs +56 -9
  92. package/scripts/reponses-du-circuit.d.mts +2 -0
  93. package/scripts/reponses-du-circuit.mjs +26 -0
  94. package/scripts/resultats.mjs +40 -0
  95. package/scripts/sous-commandes.mjs +15 -2
  96. package/scripts/superviseur.mjs +64 -57
  97. package/scripts/tableau.mjs +132 -67
  98. package/scripts/transitions.d.mts +8 -0
  99. package/scripts/transitions.mjs +21 -3
  100. package/skills/pitmaster/SKILL.md +6 -3
  101. package/skills/relecteur/SKILL.md +3 -1
  102. package/scripts/poussee-cles.mjs +0 -46
@@ -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;
@@ -11,6 +11,9 @@ import path from 'node:path';
11
11
 
12
12
  export const SHA = /^[0-9a-f]{40,64}$/;
13
13
 
14
+ // The journal every bd command writes: the tree judged takes its version of the commit.
15
+ export const JOURNAL = '.beads/interactions.jsonl';
16
+
14
17
  export const git = (racine, args, env = process.env) =>
15
18
  spawnSync('git', ['-C', racine, ...args], {
16
19
  encoding: 'utf8',
@@ -51,6 +54,17 @@ function sousModuleModifie(racine) {
51
54
  return r.stdout.split('\0').some(e => /^[12] \S+ S/.test(e));
52
55
  }
53
56
 
57
+ // The files where the tree judged of the folder at <racine> differs from the tree of its HEAD
58
+ // (the journal of bd left out, it takes its version of the commit); [] when none or git fails.
59
+ export function ecartsDuDossier(racine) {
60
+ const etat = etatDuDepot(racine);
61
+ if (!etat.arbre) {
62
+ return [];
63
+ }
64
+ const r = git(etat.racine, ['diff-tree', '-r', '--name-only', '-z', etat.commit, etat.arbre]);
65
+ return r.status === 0 ? r.stdout.split('\0').filter(Boolean) : [];
66
+ }
67
+
54
68
  // The state of the repository at <racine> as it stands: `{ racine, commit, arbre, branche, main }`,
55
69
  // its top (its real path), HEAD, the tree of its working tree, the branch of HEAD (null when
56
70
  // detached) and main (brancheDeMain); `{ raison }` when no last green can count.
@@ -80,6 +94,15 @@ export function etatDuDepot(racine) {
80
94
  if (git(top, ['add', '-A'], env).status !== 0) {
81
95
  return { raison: 'git échoue' };
82
96
  }
97
+ // The journal of bd takes its version of the commit (removed when the commit lacks it).
98
+ const dansLeCommit = sortie(top, ['ls-tree', 'HEAD', '--', JOURNAL]);
99
+ const entree = dansLeCommit?.match(/^(\d+) blob ([0-9a-f]+)\t/);
100
+ const retablir = entree
101
+ ? git(top, ['update-index', '--add', '--cacheinfo', `${entree[1]},${entree[2]},${JOURNAL}`], env)
102
+ : git(top, ['update-index', '--force-remove', JOURNAL], env);
103
+ if (retablir.status !== 0) {
104
+ return { raison: 'git échoue' };
105
+ }
83
106
  const arbre = sortie(top, ['write-tree'], env);
84
107
  if (!arbre) {
85
108
  return { raison: 'git échoue' };
@@ -50,10 +50,8 @@
50
50
  // an effect not written has its outcome, said on the error output or the failure of its
51
51
  // activity;
52
52
  // - the acts of the queue of a project (scripts/integration/file.mjs, grillhouse-4nr.8): `situer`,
53
- // where the lot of a ticket stands (`situerLeLot`); `brancher`, the branch made the candidate its
54
- // CI judges and pushed (`preparerLaBranche`); `passages`, one reading of the CI of a commit, its
55
- // expected workflows together (`lireLesPassagesDeLaCI`); `conclure`, the CI concluded at the
56
- // ticket (`conclureLaCI`); `avancer`,
53
+ // where the lot of a ticket stands (`situerLeLot`); `brancher`, the branch made the candidate the
54
+ // final pass judges (`preparerLaBranche`); `avancer`,
57
55
  // main moved onto the candidate (`avancerMain`); each of `brancher` and `avancer` telling the
58
56
  // ticket of a branch out of the queue or kept (`direLIssue`); `fermer`, the ticket closed and main
59
57
  // pushed (`fermerLEntree`); `effet-de-la-file`, one effect they gave back, under the key of its
@@ -91,6 +89,7 @@ import {
91
89
  } from './integration/file.mjs';
92
90
  import {
93
91
  ghDans,
92
+ declencherLaCiDeMain,
94
93
  lireLaCiDeMain,
95
94
  lotsDepuisLeVert,
96
95
  ouvrirLeDefautDeMain,
@@ -477,9 +476,16 @@ Object.assign(ACTES, {
477
476
  // The CI of main read once, in the main tree: the defect ticket of a red passage opened for the
478
477
  // owner (`ouvrirLeDefautDeMain`, one per passage), the lots entered since the last green named by
479
478
  // git. `{ etat }`: `verte`, `rouge` or `non-lue`.
480
- async 'surveiller-la-ci-de-main'({ racine }) {
479
+ // It starts the CI first when the delay and the tip ask for it (`declencherLaCiDeMain`, <apresEntree>
480
+ // after an entry): a start GitHub refuses leaves its fault, the queue goes on.
481
+ async 'surveiller-la-ci-de-main'({ racine, apresEntree }) {
481
482
  const o = laFile(racine);
482
- const lecture = lireLaCiDeMain({ racine, gh: ghDans(racine) });
483
+ const gh = ghDans(racine);
484
+ const lancement = declencherLaCiDeMain({ racine, gh }, { apresEntree: apresEntree === true });
485
+ if (lancement.faute) {
486
+ o.dire(`⚠ ${lancement.faute}`);
487
+ }
488
+ const lecture = lireLaCiDeMain({ racine, gh });
483
489
  if (lecture.etat === 'rouge') {
484
490
  const pointe = o.principale ?? 'main';
485
491
  const lots = lotsDepuisLeVert(racine, { vert: lecture.vert, pointe });
@@ -490,23 +496,6 @@ Object.assign(ACTES, {
490
496
  }
491
497
  return { etat: lecture.etat };
492
498
  },
493
- // The acts of the former path of the queue (the CI of a ticket's branch, the readings of the
494
- // workflows of main), kept for the executions in flight whose history replays them, retired
495
- // by grillhouse-3uv.131 once they are drained: they read nothing and judge nothing, the lot
496
- // having been prepared as the queue's former path did, and the final pass of its circuit
497
- // having judged it.
498
- async passages() {
499
- return { etat: 'verte', passage: 'ancien-chemin' };
500
- },
501
- async 'inscrire-flux-de-main'() {
502
- return null;
503
- },
504
- async 'relire-flux-de-main'() {
505
- return { dues: 0, effets: [] };
506
- },
507
- async conclure() {
508
- return { avancer: true, effets: [] };
509
- },
510
499
  // One effect an act of the queue gave back, under the key of its activity, with the outcome of
511
500
  // the queue when it is not written (`ecrireLEffet`).
512
501
  async 'effet-de-la-file'({ racine, effet, cle, derniere }) {
@@ -0,0 +1,27 @@
1
+ // The types of the closure of the machine (./fermeture-de-la-machine.mjs), which the workflow of
2
+ // the places (src/temporal/places/) imports.
3
+
4
+ /** What the command of closure does on the reservation in place. */
5
+ export function decisionDeFermeture(
6
+ reservation: { auteur?: 'nuit' | 'superviseur' } | null | undefined
7
+ ): 'fermer' | 'deja-fermee' | 'nuit-tient';
8
+
9
+ /** What the command of reopening does on the reservation in place. */
10
+ export function decisionDeReouverture(
11
+ reservation: { auteur?: 'nuit' | 'superviseur' } | null | undefined
12
+ ): 'rouvrir' | 'deja-ouverte' | 'nuit-tient';
13
+
14
+ /** What still runs by project and by ticket, or « la machine est vide ». */
15
+ export function direCeQuiTourne(o: {
16
+ prises: readonly { ticket?: string | null; racine?: string | null }[];
17
+ parts: readonly { ticket?: string | null; projet?: string | null; etat?: string }[];
18
+ }): string[];
19
+
20
+ /** The lines a command says once it has played. */
21
+ export function direLaFermeture(o: {
22
+ issue: string;
23
+ reservation: { depuis: number } | null;
24
+ prises: readonly { ticket?: string | null; racine?: string | null }[];
25
+ parts: readonly { ticket?: string | null; projet?: string | null; etat?: string }[];
26
+ maintenant: number;
27
+ }): string[];
@@ -0,0 +1,108 @@
1
+ // The closure of the machine by the supervisor, as `kubectl cordon` and `drain` close a node to new
2
+ // work: the decision of each command on the reservation of the machine in place, and the lines it
3
+ // says, what still runs by project and by ticket (sessions: the places of the workflow of the
4
+ // machine; passes: their parts), « la machine est vide » when nothing plays, and how long the
5
+ // closure has lasted. Pure: the workflow of the places (src/temporal/places/deroule.ts) bundles
6
+ // the decisions, so this module imports only a rule that imports nothing. The commands themselves
7
+ // are scripts/machine.mjs.
8
+ import { duree } from './regles-des-places.mjs';
9
+
10
+ /**
11
+ * What the command of closure does on the reservation <reservation> of the machine (null without):
12
+ * `'fermer'` when none stands, `'deja-fermee'` under the supervisor's own closure, `'nuit-tient'`
13
+ * when the night holds the machine (an absent author is the night's): no second reservation.
14
+ * @param {{ auteur?: 'nuit' | 'superviseur' } | null | undefined} reservation
15
+ * @returns {'fermer' | 'deja-fermee' | 'nuit-tient'}
16
+ */
17
+ export function decisionDeFermeture(reservation) {
18
+ if (!reservation) {
19
+ return 'fermer';
20
+ }
21
+ return reservation.auteur === 'superviseur' ? 'deja-fermee' : 'nuit-tient';
22
+ }
23
+
24
+ /**
25
+ * What the command of reopening does on the reservation <reservation>: `'rouvrir'` the supervisor's
26
+ * closure, `'deja-ouverte'` when none stands, `'nuit-tient'` for a night's, which it never lifts.
27
+ * @param {{ auteur?: 'nuit' | 'superviseur' } | null | undefined} reservation
28
+ * @returns {'rouvrir' | 'deja-ouverte' | 'nuit-tient'}
29
+ */
30
+ export function decisionDeReouverture(reservation) {
31
+ if (!reservation) {
32
+ return 'deja-ouverte';
33
+ }
34
+ return reservation.auteur === 'superviseur' ? 'rouvrir' : 'nuit-tient';
35
+ }
36
+
37
+ // The folder name of a root of project, « alpha » for « /depots/alpha ».
38
+ const nomDuProjet = racine => (racine ? (racine.split('/').filter(Boolean).at(-1) ?? racine) : '?');
39
+
40
+ const pluriel = (n, mot) => `${n} ${mot}${n > 1 ? 's' : ''}`;
41
+
42
+ /**
43
+ * What still runs, one line by project: its sessions (`prises`, the places of the workflow of the
44
+ * machine) and its passes (`parts` that hold their part; a pass that waits does not run), each with
45
+ * its tickets. Only « la machine est vide » when nothing runs.
46
+ * @param {{ prises: { ticket?: string | null, racine?: string | null }[],
47
+ * parts: { ticket?: string | null, projet?: string | null, etat?: string }[] }} o
48
+ * @returns {string[]}
49
+ */
50
+ export function direCeQuiTourne({ prises, parts }) {
51
+ /** @type {Map<string, { seances: string[], passes: string[] }>} */
52
+ const projets = new Map();
53
+ const de = nom => {
54
+ if (!projets.has(nom)) {
55
+ projets.set(nom, { seances: [], passes: [] });
56
+ }
57
+ return projets.get(nom);
58
+ };
59
+ for (const p of prises) {
60
+ de(nomDuProjet(p.racine)).seances.push(p.ticket ?? 'sans ticket');
61
+ }
62
+ for (const p of parts.filter(x => x.etat !== 'attend')) {
63
+ de(nomDuProjet(p.projet)).passes.push(p.ticket ?? 'sans ticket');
64
+ }
65
+ if (!projets.size) {
66
+ return ['la machine est vide'];
67
+ }
68
+ return [...projets.entries()]
69
+ .sort(([a], [b]) => a.localeCompare(b, 'en'))
70
+ .map(([nom, { seances, passes }]) =>
71
+ [
72
+ nom,
73
+ ...(seances.length ? [`${pluriel(seances.length, 'séance')} (${seances.join(', ')})`] : []),
74
+ ...(passes.length ? [`${pluriel(passes.length, 'passe')} (${passes.join(', ')})`] : []),
75
+ ].join(' · ')
76
+ );
77
+ }
78
+
79
+ /**
80
+ * The lines a command says once it has played: its <issue> (`fermee`, `deja-fermee`, `nuit-tient`
81
+ * for the closure; `rouverte`, `deja-ouverte`, `nuit-tient` for the reopening), then, for a closure
82
+ * or a night that holds the machine, what still runs. <reservation> is the one in place after the
83
+ * command (its start gives how long the closure has lasted), <maintenant> the time in ms.
84
+ * @param {{ issue: string, reservation: { depuis: number } | null,
85
+ * prises: Parameters<typeof direCeQuiTourne>[0]['prises'],
86
+ * parts: Parameters<typeof direCeQuiTourne>[0]['parts'], maintenant: number }} o
87
+ * @returns {string[]}
88
+ */
89
+ export function direLaFermeture({ issue, reservation, prises, parts, maintenant }) {
90
+ const tourne = direCeQuiTourne({ prises, parts });
91
+ switch (issue) {
92
+ case 'fermee':
93
+ return ['machine fermée par le superviseur : aucune place neuve, aucun circuit neuf', ...tourne];
94
+ case 'deja-fermee':
95
+ return [
96
+ `machine déjà fermée par le superviseur, depuis ${reservation ? duree(maintenant - reservation.depuis) : '?'}`,
97
+ ...tourne,
98
+ ];
99
+ case 'nuit-tient':
100
+ return ['la nuit tient la machine : elle garde sa réservation, aucune autre n’est prise', ...tourne];
101
+ case 'rouverte':
102
+ return ['machine rouverte : les circuits reprennent d’eux-mêmes à l’étape suivante'];
103
+ case 'deja-ouverte':
104
+ return ['machine déjà ouverte : rien à faire'];
105
+ default:
106
+ throw new Error(`issue inconnue : ${issue}`);
107
+ }
108
+ }
@@ -302,7 +302,7 @@ export function greffonsAbsents(projet) {
302
302
  const GREFFON_DU_CADRE = 'grillhouse';
303
303
  const NOM_DU_PAQUET = '@roomi-fields/grillhouse';
304
304
  const X_Y_Z = /^\d+\.\d+\.\d+$/;
305
- function versionDuPaquet() {
305
+ export function versionDuPaquet() {
306
306
  try {
307
307
  const p = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
308
308
  return p.name === NOM_DU_PAQUET && typeof p.version === 'string' ? p.version : null;
@@ -47,9 +47,9 @@
47
47
  // ticket that fixes it.
48
48
  // At its entry on main (`fermerLEntree`), the branch's ticket closes « intégré : <commit> », loses
49
49
  // `en-file`, and the branch is deleted; a branch git does not delete (its copy still in place) is
50
- // written to the ticket, which closes all the same. Then main is pushed to origin, on the branch
51
- // `grillhouse.poussee.commit` of main's package.json (`main` without the key), which the pre-push
52
- // hook lets go as the tree is judged; a refused push is written to the ticket and does not stop the
50
+ // written to the ticket, which closes all the same. Then main is pushed to origin, to the branch
51
+ // main, which the pre-push hook lets go as the tree is judged (a main whose package.json carries the
52
+ // retired key `grillhouse.poussee` is refused by its name, nothing pushed); a refused push is written to the ticket and does not stop the
53
53
  // queue. The working directory of its circuit (`.claude/worktrees/<ticket>.travail`,
54
54
  // scripts/circuit.mjs), which lives as long as the ticket, is removed then (`retirerLeTravail`).
55
55
  // Every comment and change of the queue at a ticket is written under the author `file`, which bd
@@ -69,8 +69,9 @@ import { arbreEstJuge, garderLArbreJuge } from '../arbres-juges.mjs';
69
69
  import { A_REPASSER } from '../codes-de-sortie.mjs';
70
70
  import { BASE_DU_LOT } from '../dernier-vert.mjs';
71
71
  import { avecLesDonnees, donneesDe } from '../donnees-cles.mjs';
72
+ import { matieresDeclareesDe } from '../matieres-cles.mjs';
72
73
  import { avecLesOutils, empreintesDe, outilsDe } from '../outils-cles.mjs';
73
- import { lireCommit } from '../poussee-cles.mjs';
74
+ import { pousseeRetiree } from '../poussee-retiree.mjs';
74
75
  import { ouvrirCopie } from './rejeu.mjs';
75
76
  import { lotSurMain } from './integrer.mjs';
76
77
  import { ACTEUR, emettre } from '../effets.mjs';
@@ -191,6 +192,7 @@ function remplacer(o, tip, tete) {
191
192
  let env;
192
193
  try {
193
194
  engendres = engendresDe(racine);
195
+ matieresDeclareesDe(racine);
194
196
  env = avecLesDonnees(
195
197
  donneesDe(racine),
196
198
  avecLesOutils(outilsDe(racine), process.env, empreintesDe(racine))
@@ -427,11 +429,12 @@ function livrerLesCapacites(o, ticket, labels) {
427
429
  * The ticket of <entree> (`{ ticket, branche, commit }`) entered on main at <commit>, with the
428
430
  * tools <o>: it closes « intégré : <commit> » and loses `en-file` (a ticket already closed is left
429
431
  * as it is), the branch is deleted, then main is pushed to origin on the branch
430
- * `grillhouse.poussee.commit` of main's package.json; the queue is then done with the ticket, and
432
+ * main, unless main's package.json carries the retired key `grillhouse.poussee` (refused by its
433
+ * name, nothing pushed); the queue is then done with the ticket, and
431
434
  * removes the working directory of its circuit (`retirerLeTravail`). Each of its gestures replays
432
435
  * without harm (a ticket closed is left closed, a branch gone stays gone, a commit pushed is pushed
433
436
  * again as it is), and never reopens the ticket; its comments are effects (`commenterAu`), which
434
- * the workflow of the queue writes once each. `{ poussee, raison }`: the branch pushed to, or null
437
+ * the workflow of the queue writes once each. `{ poussee, raison }`: `main` once pushed, or null
435
438
  * and why, in one line (`enUneLigne`), its comment at the ticket whole.
436
439
  */
437
440
  export function fermerLEntree(o, entree) {
@@ -459,26 +462,26 @@ export function fermerLEntree(o, entree) {
459
462
  }
460
463
  retirerLeTravail(o, entree.ticket);
461
464
  const paquet = git('show', `refs/heads/${o.principale}:package.json`);
462
- const { commit, faute } = lireCommit(paquet.status === 0 ? JSON.parse(paquet.stdout) : null);
463
- if (faute) {
464
- const raison = `Poussée non faite : grillhouse.poussee.commit vaut ${faute}, pas un nom de branche.`;
465
+ const retiree = pousseeRetiree(paquet.status === 0 ? JSON.parse(paquet.stdout) : null);
466
+ if (retiree) {
467
+ const raison = `Poussée non faite : ${retiree}`;
465
468
  commenter(raison);
466
469
  return { poussee: null, raison: enUneLigne(raison), ...ferme };
467
470
  }
468
471
  const sansInvite = { encoding: 'utf8', env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } };
469
472
  const pousse = spawnSync(
470
473
  'git',
471
- ['-C', racine, 'push', 'origin', `${entree.commit}:refs/heads/${commit}`],
474
+ ['-C', racine, 'push', 'origin', `${entree.commit}:refs/heads/main`],
472
475
  sansInvite
473
476
  );
474
477
  if (pousse.status !== 0) {
475
- const raison = `La poussée de ${court} vers origin/${commit} (grillhouse.poussee.commit) est refusée :\n${pousse.stderr.trim()}`;
478
+ const raison = `La poussée de ${court} vers origin/main est refusée :\n${pousse.stderr.trim()}`;
476
479
  commenter(raison);
477
480
  o.dire(`⚠ poussée de ${court} refusée`);
478
481
  return { poussee: null, raison: enUneLigne(raison), ...ferme };
479
482
  }
480
- o.dire(`✓ poussée : ${court} est sur origin/${commit}`);
481
- return { poussee: commit, raison: null, ...ferme };
483
+ o.dire(`✓ poussée : ${court} est sur origin/main`);
484
+ return { poussee: 'main', raison: null, ...ferme };
482
485
  }
483
486
 
484
487
  /**
@@ -99,6 +99,7 @@ import { langageDe } from '../langages.mjs';
99
99
  import { prefixe } from '../prefixe-des-tickets.mjs';
100
100
  import { commitsDelivering, gitLog } from '../un-commit-par-ticket.mjs';
101
101
  import { avecLesDonnees, donneesDe } from '../donnees-cles.mjs';
102
+ import { matieresDeclareesDe } from '../matieres-cles.mjs';
102
103
  import { avecLesOutils, empreintesDe, outilsDe } from '../outils-cles.mjs';
103
104
  import { lacherVerrou, prendreVerrou } from '../verrou-de-fichier.mjs';
104
105
  import { ouvrirCopie, RETIRER_COPIE } from './rejeu.mjs';
@@ -382,6 +383,7 @@ function main(argv) {
382
383
  outils = outilsDe(racine);
383
384
  empreintes = empreintesDe(racine);
384
385
  donnees = donneesDe(racine);
386
+ matieresDeclareesDe(racine);
385
387
  } catch (e) {
386
388
  return refuser(`Une clé grillhouse du package.json est refusée :\n${e.message}`);
387
389
  }
@@ -250,6 +250,11 @@ export interface Composition {
250
250
  * whatever the task that bears it — the build task, or the test task with no report
251
251
  * (grillhouse-lv9). Every module answers it; a language with no compilation step answers false. */
252
252
  echecDeCompilation(texte: string): boolean;
253
+ /** The absolute path of the module the load failure `message` of the test file `fichier` names
254
+ * as absent, null when it names none: the proof of the red reads a test that imports a module
255
+ * the ticket creates as red, as a test target that does not compile. A language whose compiler
256
+ * bears it (`echecDeCompilation`) answers null. */
257
+ moduleAbsent(message: string, fichier: string): string | null;
253
258
  estUnTest(chemin: string, racine: string): ClasseDeTest;
254
259
  /** Whether the test file `chemin` (from `racine`) is out of the day, one that only the night
255
260
  * plays (a night test, a time budget bench, a time witness), by the module's own definitions;
@@ -97,6 +97,8 @@ export default {
97
97
  commandes,
98
98
  verdict,
99
99
  echecDeCompilation,
100
+ // A test that includes an absent header does not compile: `echecDeCompilation` bears it.
101
+ moduleAbsent: () => null,
100
102
  estUnTest,
101
103
  // No night test in C yet.
102
104
  horsDuJour: () => false,
@@ -50,7 +50,7 @@ export function squelette(_racine, { chemin }) {
50
50
  fichiers: {
51
51
  [`${chemin}/CMakeLists.txt`]: cmake,
52
52
  [`${chemin}/src/${fichier}.h`]: `#ifndef ${garde}\n#define ${garde}\n\n#endif\n`,
53
- [`${chemin}/src/${fichier}.c`]: `#include "${fichier}.h"\n\n/* A translation unit holds one declaration (ISO C): the first function of the package replaces it. */\ntypedef int ${fichier}_sans_code;\n`,
53
+ [`${chemin}/src/${fichier}.c`]: `#include "${fichier}.h"\n\n/* A translation unit holds one declaration (ISO C): the package's first function replaces it. */\ntypedef int ${fichier}_sans_code;\n`,
54
54
  [`${chemin}/tests/CMakeLists.txt`]: tests,
55
55
  [`${chemin}/.clang-format`]: 'BasedOnStyle: LLVM\nColumnLimit: 100\n',
56
56
  [`${chemin}/.clang-tidy`]: "Checks: '-*,bugprone-*,cert-*,clang-analyzer-*,misc-*'\nWarningsAsErrors: '*'\n",
@@ -139,6 +139,8 @@ export default {
139
139
  commandes,
140
140
  verdict,
141
141
  echecDeCompilation,
142
+ // A test that imports an absent module does not compile: `echecDeCompilation` bears it.
143
+ moduleAbsent: () => null,
142
144
  estUnTest,
143
145
  horsDuJour: fichierHorsDuJour,
144
146
  manifestes,
@@ -110,6 +110,8 @@ export default {
110
110
  verdict,
111
111
  // Python has no compilation step: no test task bears a compilation failure (jointure.d.ts).
112
112
  echecDeCompilation: () => false,
113
+ // No load failure of pytest is read as an absent module.
114
+ moduleAbsent: () => null,
113
115
  estUnTest,
114
116
  // A night test, `*_nuit_test.py` (`estDeNuit`).
115
117
  horsDuJour: chemin => estDeNuit(path.basename(chemin)),
@@ -61,6 +61,7 @@ import { garderLesResumes, lireLesResumes, resumesDuLancement } from './resume-d
61
61
  import { miseAJour } from './mise-a-jour.mjs';
62
62
  import { squelette } from './squelette.mjs';
63
63
  import { estHorsDuJour } from './vitest-config/cibles.mjs';
64
+ import { moduleAbsent } from './module-absent.mjs';
64
65
  import * as configVitest from './migrations/0.23.0-config-vitest.mjs';
65
66
  import * as nomsDeclaresInutilises from './migrations/0.24.4-noms-declares-inutilises.mjs';
66
67
  import * as lignesMalFormees from './migrations/0.24.6-lignes-mal-formees.mjs';
@@ -271,6 +272,8 @@ export default {
271
272
  verdict,
272
273
  // A build failure is already a red `build` task here; no test task bears a compilation failure.
273
274
  echecDeCompilation: () => false,
275
+ // The module a test file imports and Vitest did not find (./module-absent.mjs).
276
+ moduleAbsent,
274
277
  estUnTest,
275
278
  // A night test, a bench or a time witness (./vitest-config/cibles.mjs, `estHorsDuJour`).
276
279
  horsDuJour: (chemin, racine) => estHorsDuJour(path.resolve(racine, chemin)),
@@ -0,0 +1,24 @@
1
+ // The module a test file imports that Vitest did not find, read from the message of its load
2
+ // failure: the path the import names, resolved from the test file. A test written before its code
3
+ // imports the module the ticket creates; that load failure is its red, as a test target that does
4
+ // not compile is in a compiled language (`echecDeCompilation` of cargo and c). An import of a
5
+ // package (a bare name) is no module of the project: null.
6
+ import path from 'node:path';
7
+
8
+ const DE_VITEST = /Failed to load url (\S+) \(resolved id: [^)]*\)/;
9
+ const DE_NODE = /Cannot find module '([^']+)'/;
10
+
11
+ /**
12
+ * The absolute path of the module the load failure <message> of the test file <fichier> names as
13
+ * absent, or null when the message names none or names a package.
14
+ * @param {string} message
15
+ * @param {string} fichier
16
+ * @returns {string | null}
17
+ */
18
+ export function moduleAbsent(message, fichier) {
19
+ const nomme = (DE_VITEST.exec(message) ?? DE_NODE.exec(message))?.[1];
20
+ if (!nomme || !(nomme.startsWith('.') || path.isAbsolute(nomme))) {
21
+ return null;
22
+ }
23
+ return path.resolve(path.dirname(fichier), nomme);
24
+ }