@roomi-fields/grillhouse 0.48.0 → 0.49.1

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 (155) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +90 -0
  3. package/agents/direct.md +9 -0
  4. package/cadre/templates/projet/.github/workflows/ci.yml +11 -0
  5. package/cadre/templates/projet/.github/workflows/nuit.yml +15 -6
  6. package/cadre/templates/projet/CLAUDE.md +10 -6
  7. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  8. package/cadre/templates/turbo/paquets.json +3 -1
  9. package/cadre/templates/turbo/sans-paquets.json +3 -1
  10. package/charte.md +51 -14
  11. package/dist/temporal/acte.d.ts +9 -0
  12. package/dist/temporal/acte.js +43 -20
  13. package/dist/temporal/acte.js.map +1 -1
  14. package/dist/temporal/circuit/appel.d.ts +4 -1
  15. package/dist/temporal/circuit/appel.js +15 -1
  16. package/dist/temporal/circuit/appel.js.map +1 -1
  17. package/dist/temporal/circuit/client.d.ts +7 -1
  18. package/dist/temporal/circuit/client.js +54 -1
  19. package/dist/temporal/circuit/client.js.map +1 -1
  20. package/dist/temporal/circuit/commande.js +30 -57
  21. package/dist/temporal/circuit/commande.js.map +1 -1
  22. package/dist/temporal/circuit/contrat.d.ts +2 -1
  23. package/dist/temporal/circuit/contrat.js +2 -1
  24. package/dist/temporal/circuit/contrat.js.map +1 -1
  25. package/dist/temporal/circuit/deroule.js +9 -2
  26. package/dist/temporal/circuit/deroule.js.map +1 -1
  27. package/dist/temporal/file/contrat.d.ts +16 -2
  28. package/dist/temporal/file/contrat.js +27 -3
  29. package/dist/temporal/file/contrat.js.map +1 -1
  30. package/dist/temporal/file/deroule.js +4 -4
  31. package/dist/temporal/file/deroule.js.map +1 -1
  32. package/dist/temporal/nuits/activites.d.ts +1 -15
  33. package/dist/temporal/nuits/activites.js +3 -62
  34. package/dist/temporal/nuits/activites.js.map +1 -1
  35. package/dist/temporal/nuits/contrat.d.ts +3 -21
  36. package/dist/temporal/nuits/deroule.js +38 -74
  37. package/dist/temporal/nuits/deroule.js.map +1 -1
  38. package/dist/temporal/places/client.d.ts +3 -16
  39. package/dist/temporal/places/client.js +3 -26
  40. package/dist/temporal/places/client.js.map +1 -1
  41. package/dist/temporal/places/contrat.d.ts +15 -51
  42. package/dist/temporal/places/contrat.js +3 -13
  43. package/dist/temporal/places/contrat.js.map +1 -1
  44. package/dist/temporal/places/deroule.js +11 -61
  45. package/dist/temporal/places/deroule.js.map +1 -1
  46. package/dist/temporal/tickets/activites.js +4 -2
  47. package/dist/temporal/tickets/activites.js.map +1 -1
  48. package/dist/temporal/tickets/contrat.d.ts +2 -1
  49. package/docs/ARCHITECTURE.md +337 -120
  50. package/docs/CADRE.md +16 -13
  51. package/docs/INTERFACE.md +90 -25
  52. package/hooks/hooks.json +9 -0
  53. package/hooks/register.tsx +59 -5
  54. package/package.json +1 -1
  55. package/scripts/activites.mjs +271 -42
  56. package/scripts/aiguillage.mjs +4 -1
  57. package/scripts/bilan.mjs +125 -2
  58. package/scripts/circuit.mjs +233 -159
  59. package/scripts/circuits-cles.d.mts +3 -3
  60. package/scripts/circuits-cles.mjs +6 -5
  61. package/scripts/coeurs-dedies.mjs +4 -4
  62. package/scripts/commandes-composees.mjs +12 -5
  63. package/scripts/dette.d.ts +2 -1
  64. package/scripts/dette.mjs +49 -6
  65. package/scripts/direct.mjs +343 -0
  66. package/scripts/droits.mjs +26 -4
  67. package/scripts/effets.mjs +4 -4
  68. package/scripts/engendres.mjs +2 -1
  69. package/scripts/enveloppe/enveloppe.mjs +119 -18
  70. package/scripts/enveloppe/lancer.sh +14 -3
  71. package/scripts/enveloppe/paquets-du-plan.mjs +9 -0
  72. package/scripts/enveloppe/travail-de-la-copie.mjs +119 -21
  73. package/scripts/etapes.mjs +3 -3
  74. package/scripts/faits-du-circuit.mjs +12 -11
  75. package/scripts/fermeture-de-la-machine.d.mts +4 -4
  76. package/scripts/fermeture-de-la-machine.mjs +10 -20
  77. package/scripts/fichiers-nommes.mjs +27 -1
  78. package/scripts/file-des-tickets.d.mts +18 -1
  79. package/scripts/file-des-tickets.mjs +63 -15
  80. package/scripts/flux-de-la-nuit.mjs +38 -0
  81. package/scripts/grillhouse-maj.mjs +13 -25
  82. package/scripts/groupe-cles.d.mts +6 -0
  83. package/scripts/groupe-cles.mjs +29 -1
  84. package/scripts/integration/file.mjs +148 -37
  85. package/scripts/jointure.d.ts +20 -3
  86. package/scripts/journal-des-etats.d.mts +16 -0
  87. package/scripts/journal-des-etats.mjs +44 -2
  88. package/scripts/journal.mjs +3 -0
  89. package/scripts/langages/c/commandes.mjs +5 -5
  90. package/scripts/langages/c/composants.mjs +13 -5
  91. package/scripts/langages/cargo/commandes.mjs +5 -6
  92. package/scripts/langages/python/commandes.mjs +5 -5
  93. package/scripts/langages/python/composants.mjs +10 -2
  94. package/scripts/langages/typescript/composants.mjs +10 -3
  95. package/scripts/langages/typescript/consommateurs-arbitres.mjs +15 -3
  96. package/scripts/langages/typescript/construire.mjs +2 -0
  97. package/scripts/langages/typescript/exemples.mjs +33 -1
  98. package/scripts/langages/typescript/index.mjs +19 -0
  99. package/scripts/langages/typescript/migrations/0.49.0-tests-equipes.mjs +32 -0
  100. package/scripts/langages/typescript/tests-de-nuit.mjs +158 -32
  101. package/scripts/langages/typescript/tests-du-poste.mjs +112 -32
  102. package/scripts/langages/typescript/titres-de-tests.mjs +11 -7
  103. package/scripts/langages/typescript/turbo-des-paquets.mjs +21 -4
  104. package/scripts/langages/typescript/verifier.mjs +3 -5
  105. package/scripts/langages/typescript/verrou-des-dependances.mjs +161 -0
  106. package/scripts/langages/typescript/vitest-config/cibles.mjs +57 -6
  107. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +11 -5
  108. package/scripts/langages/typescript/vitest.nuit.config.mjs +53 -5
  109. package/scripts/machine.mjs +1 -1
  110. package/scripts/mesure/base-de-passe.mjs +2 -1
  111. package/scripts/migrations/0.49.0-reservation-de-trois-coeurs.mjs +30 -0
  112. package/scripts/migrations.mjs +2 -0
  113. package/scripts/nuit.sh +129 -3
  114. package/scripts/paquet.mjs +16 -5
  115. package/scripts/paquets.d.ts +4 -0
  116. package/scripts/paquets.mjs +57 -0
  117. package/scripts/passe-de-la-machine.mjs +4 -7
  118. package/scripts/places-de-la-machine.mjs +55 -42
  119. package/scripts/places-du-serveur.mjs +2 -2
  120. package/scripts/plafond-de-la-machine.d.mts +7 -13
  121. package/scripts/plafond-de-la-machine.mjs +19 -35
  122. package/scripts/prefixe-des-tickets.mjs +1 -1
  123. package/scripts/references-changees.mjs +159 -0
  124. package/scripts/regles-des-places.d.mts +8 -31
  125. package/scripts/regles-des-places.mjs +14 -64
  126. package/scripts/repli-de-la-nuit.mjs +183 -0
  127. package/scripts/reponses-du-circuit.d.mts +2 -2
  128. package/scripts/reponses-du-circuit.mjs +21 -12
  129. package/scripts/reprise.mjs +27 -8
  130. package/scripts/resultats.mjs +21 -9
  131. package/scripts/seances.mjs +258 -40
  132. package/scripts/services-du-noyau.mjs +4 -0
  133. package/scripts/sous-commandes.mjs +24 -7
  134. package/scripts/superviseur.mjs +185 -39
  135. package/scripts/tableau.mjs +226 -94
  136. package/scripts/taches-du-graphe.mjs +84 -4
  137. package/scripts/ticket.mjs +348 -0
  138. package/scripts/transitions.d.mts +44 -0
  139. package/scripts/transitions.mjs +188 -17
  140. package/scripts/un-commit-par-ticket.mjs +4 -3
  141. package/scripts/verdict-de-la-nuit.mjs +47 -20
  142. package/scripts/verrou-de-fichier.mjs +2 -2
  143. package/scripts/verrous/ecriture-hors-enveloppe.mjs +86 -0
  144. package/scripts/verrous/verrou.mjs +17 -1
  145. package/skills/architecte/SKILL.md +203 -0
  146. package/skills/architecte/references/exemple-d-architecture.md +159 -0
  147. package/skills/developpeur/SKILL.md +1 -1
  148. package/skills/direct/SKILL.md +57 -0
  149. package/skills/explorateur/SKILL.md +10 -6
  150. package/skills/pitmaster/SKILL.md +37 -14
  151. package/skills/pitmaster/references/consigne-agent.md +7 -1
  152. package/skills/redacteur/references/documents-d-un-composant.md +2 -1
  153. package/skills/relecteur/SKILL.md +8 -0
  154. package/skills/testwriter/SKILL.md +10 -0
  155. package/scripts/ticket.sh +0 -25
@@ -0,0 +1,161 @@
1
+ #!/usr/bin/env node
2
+ // The lock of the dependencies (package-lock.json) against the package.json it locks, on the model
3
+ // of `npm ci`, which refuses a lock out of step with its package.json: the lock is written by the
4
+ // frame at the integration (`fichiersEngendres` of ./index.mjs), and this guard refuses a copy
5
+ // whose lock is late.
6
+ //
7
+ // npx grillhouse verrou-des-dependances run from the repository root (a guard of grillhouse:gardes)
8
+ //
9
+ // - For each package.json of the repository (the root's, and each workspace's), its `dependencies`,
10
+ // `devDependencies`, `optionalDependencies` and `peerDependencies` are compared with the entry of
11
+ // its package in the `packages` key of the lock (`""` for the root), without the registry and
12
+ // whatever the version of npm: a declared dependency absent from the lock, a dependency removed
13
+ // from the package.json still in the lock's entry, a range that differs from the entry's, a
14
+ // resolved version of the lock that no longer satisfies the declared range.
15
+ // - A finding is `{ fichier, message }`, one per package and dependency, the message naming the
16
+ // command that writes the lock again (COMMANDE). A repository without a lock is not judged, nor
17
+ // one whose project declares package-lock.json in `grillhouse.engendres` (its command is its own).
18
+ // - This module's top level uses Node alone: ./index.mjs imports it for the command, and the write
19
+ // lock of a session loads that module where the package's dependencies may not be installed.
20
+ // semver is required when the guard compares (`verifierLesConstats`), as ./mise-a-jour.mjs does.
21
+ import { existsSync, readFileSync, readdirSync } from 'node:fs';
22
+ import { createRequire } from 'node:module';
23
+ import path from 'node:path';
24
+ import { pathToFileURL } from 'node:url';
25
+ import { ecrireSarif } from '../../resultats.mjs';
26
+
27
+ export const GARDE = 'verrou-des-dependances';
28
+ export const COMMANDE = 'npm install --package-lock-only --no-audit --no-fund';
29
+
30
+ const SORTES = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
31
+ const LOCK = 'package-lock.json';
32
+
33
+ const lireJson = f => {
34
+ try {
35
+ return JSON.parse(readFileSync(f, 'utf8'));
36
+ } catch {
37
+ return null;
38
+ }
39
+ };
40
+
41
+ // The directories (from <racine>) the workspaces of the root package.json name: a literal path, or
42
+ // `<dossier>/*`.
43
+ function espaces(racine, manifeste) {
44
+ const motifs = Array.isArray(manifeste?.workspaces)
45
+ ? manifeste.workspaces
46
+ : (manifeste?.workspaces?.packages ?? []);
47
+ const dossiers = [];
48
+ for (const m of motifs.filter(x => typeof x === 'string')) {
49
+ const motif = m.replace(/^\.\//, '').replace(/\/+$/, '');
50
+ if (motif.endsWith('/*')) {
51
+ const parent = motif.slice(0, -2);
52
+ const lus = existsSync(path.join(racine, parent))
53
+ ? readdirSync(path.join(racine, parent), { withFileTypes: true })
54
+ : [];
55
+ dossiers.push(...lus.filter(e => e.isDirectory()).map(e => `${parent}/${e.name}`));
56
+ } else if (!motif.includes('*')) {
57
+ dossiers.push(motif);
58
+ }
59
+ }
60
+ return dossiers.filter(d => existsSync(path.join(racine, d, 'package.json')));
61
+ }
62
+
63
+ // The version the lock resolves <nom> to for the entry <cle>: the nearest `node_modules/<nom>`,
64
+ // following the link of a package of the repository; null when the lock holds none.
65
+ function resolue(packages, cle, nom) {
66
+ const candidats = [];
67
+ let c = cle;
68
+ for (;;) {
69
+ candidats.push(c ? `${c}/node_modules/${nom}` : `node_modules/${nom}`);
70
+ if (!c) {
71
+ break;
72
+ }
73
+ const i = c.lastIndexOf('/node_modules/');
74
+ c = i === -1 ? '' : c.slice(0, i);
75
+ }
76
+ const trouve = candidats.map(c => packages[c]).find(Boolean);
77
+ if (!trouve) {
78
+ return null;
79
+ }
80
+ const cible = trouve.link && trouve.resolved ? packages[trouve.resolved] : trouve;
81
+ return typeof cible?.version === 'string' ? cible.version : null;
82
+ }
83
+
84
+ /**
85
+ * The findings of the repository at <racine>: `[{ fichier, message }]`, one per package and
86
+ * dependency whose lock entry is out of step with its package.json.
87
+ * @param {string} racine
88
+ * @returns {{ fichier: string, message: string }[]}
89
+ */
90
+ export function verifierLesConstats(racine) {
91
+ const verrou = lireJson(path.join(racine, LOCK));
92
+ const racineManifeste = lireJson(path.join(racine, 'package.json'));
93
+ if (!verrou || typeof verrou.packages !== 'object' || !racineManifeste) {
94
+ return [];
95
+ }
96
+ // semver, required when the guard compares, not when the module loads (see the header).
97
+ const semver = createRequire(import.meta.url)('semver');
98
+ const packages = verrou.packages;
99
+ const cles = ['', ...espaces(racine, racineManifeste)];
100
+ const constats = [];
101
+ for (const cle of cles) {
102
+ const fichier = cle ? `${cle}/package.json` : 'package.json';
103
+ const manifeste = cle ? lireJson(path.join(racine, fichier)) : racineManifeste;
104
+ const entree = packages[cle] ?? {};
105
+ const dit = (nom, raison) =>
106
+ constats.push({
107
+ fichier,
108
+ message: `${cle || 'package.json'} : la dépendance ${nom} ${raison} ; \`${COMMANDE}\` réécrit le verrou.`,
109
+ });
110
+ for (const sorte of SORTES) {
111
+ const declare = manifeste?.[sorte] ?? {};
112
+ const verrouille = entree[sorte] ?? {};
113
+ for (const [nom, plage] of Object.entries(declare)) {
114
+ if (!(nom in verrouille)) {
115
+ dit(nom, `(${sorte}, ${plage}) est absente de l'entrée du verrou`);
116
+ } else if (verrouille[nom] !== plage) {
117
+ dit(
118
+ nom,
119
+ `(${sorte}) déclare ${plage} dans le package.json et ${verrouille[nom]} dans le verrou`
120
+ );
121
+ } else {
122
+ const version = resolue(packages, cle, nom);
123
+ if (version && semver.validRange(plage) && !semver.satisfies(version, plage)) {
124
+ dit(
125
+ nom,
126
+ `(${sorte}) déclare ${plage}, que la version ${version} du verrou ne satisfait pas`
127
+ );
128
+ }
129
+ }
130
+ }
131
+ for (const nom of Object.keys(verrouille)) {
132
+ if (!(nom in declare)) {
133
+ dit(nom, `(${sorte}) est retirée du package.json et reste dans l'entrée du verrou`);
134
+ }
135
+ }
136
+ }
137
+ }
138
+ return constats;
139
+ }
140
+
141
+ /**
142
+ * The refusals of the repository at <racine>, one line per package and dependency.
143
+ * @param {string} racine
144
+ * @returns {string[]}
145
+ */
146
+ export const verifier = racine => verifierLesConstats(racine).map(c => c.message);
147
+
148
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
149
+ const racine = process.cwd();
150
+ // A project that declares the lock a generated file (`grillhouse.engendres`) keeps its command,
151
+ // and its own judgement of it: the guard does not play for it.
152
+ const duProjet = Object.values(
153
+ lireJson(path.join(racine, 'package.json'))?.grillhouse?.engendres ?? {}
154
+ ).some(e => Array.isArray(e?.fichiers) && e.fichiers.includes(LOCK));
155
+ const constats = duProjet ? [] : verifierLesConstats(racine);
156
+ for (const c of constats) {
157
+ process.stderr.write(`⛔ ${c.message}\n`);
158
+ }
159
+ ecrireSarif({ garde: GARDE, racine, constats });
160
+ process.exitCode = constats.length ? 1 : 0;
161
+ }
@@ -73,6 +73,13 @@ export const NUIT_VARIABLE = 'GRILLHOUSE_TESTS_DE_NUIT';
73
73
  * `i/n`, and `rapports`, the directory of its reports (`trancher`, ../tranches.mjs).
74
74
  */
75
75
  export const NUIT_TRANCHE = 'GRILLHOUSE_TRANCHE_DE_NUIT';
76
+ /**
77
+ * The variable that carries the unit of a run of the night's configuration, JSON: `config`, the
78
+ * configuration of the package of the run (absent for the root), and `exclus`, the patterns of
79
+ * the units below it, which it leaves out. The night's configuration takes it out of the environment
80
+ * once read: no process the tests start receives it.
81
+ */
82
+ export const NUIT_PAQUET = 'GRILLHOUSE_NUIT_PAQUET';
76
83
  // Whether the file at <fichier> bears the name of <motif>, a globstar then a name: by the name of
77
84
  // the file, since a globstar passes no directory whose name starts with a dot, and a ticket's copy
78
85
  // lives under `.claude/worktrees/`.
@@ -106,6 +113,26 @@ export function porteLEtiquetteDuPoste(texte) {
106
113
  }
107
114
  return false;
108
115
  }
116
+ // The tag of a night test that needs the equipment of a machine (the envelope, a Temporal server,
117
+ // the binaries of the module cargo): `// @equipee: <reason>` in the comment at the head of the file,
118
+ // beside `@poste` when the test needs both. A runner without equipment leaves it out.
119
+ const ETIQUETTE_EQUIPEE = /^\/\/\s*@equipee\b/;
120
+ /**
121
+ * Whether the text <texte> of a test file bears the tag `@equipee` in the comment at its head.
122
+ * @param {string} texte the text of the file
123
+ */
124
+ export function porteLEtiquetteEquipee(texte) {
125
+ for (const ligne of texte.split('\n')) {
126
+ const l = ligne.trim();
127
+ if (ETIQUETTE_EQUIPEE.test(l)) {
128
+ return true;
129
+ }
130
+ if (l !== '' && !l.startsWith('//') && !l.startsWith('#!')) {
131
+ return false;
132
+ }
133
+ }
134
+ return false;
135
+ }
109
136
  // Vitest's default `include` (its configDefaults).
110
137
  const INCLUDE = ['**/*.{test,spec}.?(c|m)[jt]s?(x)'];
111
138
  // The mark of a time witness: the import of `mesurerAuRepos`, on a line of its own, from the
@@ -289,6 +316,18 @@ async function cibler(config, test, valeur, temoins) {
289
316
  * @param {string} dir the directory searched
290
317
  */
291
318
  export function testsDuPoste(dir) {
319
+ return testsEtiquetes(dir, porteLEtiquetteDuPoste);
320
+ }
321
+
322
+ /**
323
+ * The night tests under <dir> that bear the tag `@equipee`, listed as `testsDuPoste` lists its own.
324
+ * @param {string} dir the directory searched
325
+ */
326
+ export function testsEquipes(dir) {
327
+ return testsEtiquetes(dir, porteLEtiquetteEquipee);
328
+ }
329
+
330
+ function testsEtiquetes(dir, porte) {
292
331
  return [
293
332
  ...new Set(
294
333
  globSync([NUIT], { cwd: dir, exclude: d => HORS_TEMOINS.has(path.basename(d)) }).map(f =>
@@ -296,14 +335,16 @@ export function testsDuPoste(dir) {
296
335
  )
297
336
  ),
298
337
  ]
299
- .filter(f => porteLEtiquetteDuPoste(lireTexte(path.join(dir, f))))
338
+ .filter(f => porte(lireTexte(path.join(dir, f))))
300
339
  .sort();
301
340
  }
302
341
 
303
342
  /**
304
343
  * The plugin of the night's configuration: the night tests, the benches and the time witnesses
305
344
  * under its directory, or, as <env> chooses in NUIT_VARIABLE, the night tests alone (`nuit`), the
306
- * night tests but those tagged `@poste` (`hors-poste`, the night of a shared machine: a CI), or the
345
+ * night tests but those tagged `@poste` (`hors-poste`, the night of an equipped runner), those
346
+ * tagged `@poste` or `@equipee` left out too (`hors-poste-sans-equipement`), those tagged `@poste`
347
+ * alone (`du-poste`, the night of the poste), or the
307
348
  * measures alone (`mesures`), the benches and the witnesses; every choice plays one file at a time
308
349
  * (`fileParallelism: false`), the night at rest; with NUIT_TRANCHE, the tranche it carries of these
309
350
  * files.
@@ -324,15 +365,25 @@ export const nuit = (env = process.env) => ({
324
365
  test.fileParallelism = false;
325
366
  if (choix === 'nuit') {
326
367
  test.include = [NUIT];
327
- } else if (choix === 'hors-poste') {
368
+ } else if (choix === 'hors-poste' || choix === 'hors-poste-sans-equipement') {
328
369
  test.include = [NUIT];
329
- const duPoste = testsDuPoste(path.resolve(config.root ?? process.cwd(), test.dir ?? ''));
330
- if (duPoste.length) {
370
+ const dir = path.resolve(config.root ?? process.cwd(), test.dir ?? '');
371
+ const laisses = [
372
+ ...new Set([
373
+ ...testsDuPoste(dir),
374
+ ...(choix === 'hors-poste-sans-equipement' ? testsEquipes(dir) : []),
375
+ ]),
376
+ ].sort();
377
+ if (laisses.length) {
331
378
  test.exclude = [
332
379
  ...(test.exclude ?? ['**/node_modules/**']),
333
- ...duPoste.map(r => r.replace(SPECIAUX, '\\$&')),
380
+ ...laisses.map(r => r.replace(SPECIAUX, '\\$&')),
334
381
  ];
335
382
  }
383
+ } else if (choix === 'du-poste') {
384
+ test.include = testsDuPoste(path.resolve(config.root ?? process.cwd(), test.dir ?? '')).map(
385
+ r => r.replace(SPECIAUX, '\\$&')
386
+ );
336
387
  } else if (choix === 'mesures') {
337
388
  test.include = [BUDGET, ...temoins];
338
389
  } else {
@@ -3,7 +3,10 @@
3
3
  // the temporary directory named after its process and a token, scripts/places-de-la-machine.mjs),
4
4
  // which every process it starts inherits: a `npm run verifier` or a circuit that a test plays in
5
5
  // a repository of trial takes its part there, among its own parts alone, and no test writes in the
6
- // user's state. A directory already named in the environment stays. Its passes want no room in
6
+ // user's state. A directory already named in the environment stays. The directory the file named
7
+ // is removed at its end, with what a pass left there (the part of a pass a test killed, which
8
+ // never gave it back), as the register of the file is (./registre.setup.mjs): the guard of the
9
+ // temporary directory of the run finds nothing of it. Its passes want no room in
7
10
  // the temporary directory (GRILLHOUSE_TEMPORAIRE_LIBRE, 0) nor on the disk of their copy
8
11
  // (GRILLHOUSE_COPIE_LIBRE, 0): the room of the machine is the pass's that plays the file, which
9
12
  // waited for it.
@@ -11,13 +14,16 @@
11
14
  // That trial machine takes no place of the user's machine (scripts/places-de-la-machine.mjs): only
12
15
  // the server of trial a test names (GRILLHOUSE_PLACES_D_ESSAI).
13
16
  import { randomUUID } from 'node:crypto';
17
+ import { rmSync } from 'node:fs';
14
18
  import { tmpdir } from 'node:os';
15
19
  import path from 'node:path';
20
+ import { afterAll } from 'vitest';
16
21
 
17
- process.env.GRILLHOUSE_PARTS_DE_LA_MACHINE ||= path.join(
18
- tmpdir(),
19
- `grillhouse-parts-${process.pid}-${randomUUID()}`
20
- );
22
+ if (!process.env.GRILLHOUSE_PARTS_DE_LA_MACHINE) {
23
+ const parts = path.join(tmpdir(), `grillhouse-parts-${process.pid}-${randomUUID()}`);
24
+ process.env.GRILLHOUSE_PARTS_DE_LA_MACHINE = parts;
25
+ afterAll(() => rmSync(parts, { recursive: true, force: true }));
26
+ }
21
27
  // The machine a test reads is a fixed one (GRILLHOUSE_MESURE_D_ESSAI, scripts/places-de-la-machine.mjs
22
28
  // `etatDesPlaces`): no test reads the real load or memory of the user's machine.
23
29
  process.env.GRILLHOUSE_MESURE_D_ESSAI ||= JSON.stringify({
@@ -10,17 +10,50 @@
10
10
  // and the benches, and its plugin adds the witnesses under the root, or chooses the night tests
11
11
  // alone, the night tests but those tagged `@poste` (the night of a shared machine, a CI), or the
12
12
  // measures alone, one file at a time (`nuit` of ./vitest-config/cibles.mjs, the variable
13
- // GRILLHOUSE_TESTS_DE_NUIT). It reads no day configuration of the project, whether the
14
- // project has one at its root or one per package; it takes from the base configuration the common
13
+ // GRILLHOUSE_TESTS_DE_NUIT). It reads no day configuration of the root, and that of each package
14
+ // only for its own files (below); it takes from the base configuration the common
15
15
  // environment (git's settings) and the measure of time: the setup file that notes the CPU pressure
16
16
  // of each test and the duration reporter, which gives 75, « à repasser », to a measure that fails
17
17
  // under load (scripts/langages/typescript/vitest-config/duree.reporter.mjs).
18
+ //
19
+ // A run plays one unit of the project: the root, under this configuration alone, or a package that
20
+ // has a Vitest configuration (`vitest.config.*`, else `vite.config.*`, in its directory, found by
21
+ // ./tests-de-nuit.mjs), under this configuration merged over the package's, as Vitest's projects
22
+ // merge a package's configuration with the root's: what the package sets and the night does not
23
+ // set (environment, alias, plugins) stays, its setup files precede those of the base, and what the
24
+ // night sets wins (include, exclusions, reporters, delays, one file at a time, the tranche). The
25
+ // variable GRILLHOUSE_NUIT_PAQUET (NUIT_PAQUET), JSON, names the configuration of the package of
26
+ // the run (`config`) and the directories of the units below the unit of the run (`exclus`), which
27
+ // it leaves out; this configuration takes it out of the environment once read, as the plugin of
28
+ // the night does its choice and its tranche: the unit is the run's own, and a Vitest that a night
29
+ // test starts itself, in another package, plays under no configuration but its own. Node (>= 26)
30
+ // reads the package's configuration itself, TypeScript included; a configuration written as a
31
+ // function is called as Vite calls it, for a test run.
32
+ import { pathToFileURL } from 'node:url';
33
+ import { mergeConfig } from 'vitest/config';
18
34
  import base from './vitest-config/base.mjs';
19
- import { HORS_DU_JOUR, nuit } from './vitest-config/cibles.mjs';
35
+ import { HORS_DU_JOUR, nuit, NUIT_PAQUET } from './vitest-config/cibles.mjs';
20
36
  import { DELAI_NUIT_MS } from './vitest-config/bornes.mjs';
21
37
 
22
- export default {
23
- plugins: [nuit()],
38
+ const { config: fichier, exclus = [] } = process.env[NUIT_PAQUET]
39
+ ? JSON.parse(process.env[NUIT_PAQUET])
40
+ : {};
41
+ delete process.env[NUIT_PAQUET];
42
+
43
+ // What the night sets wins over the configuration of a package, whose plugins have run first: the
44
+ // exclusions of its unit, the reporters, and the setup files, the package's before the base's.
45
+ const nuitGagne = {
46
+ name: 'grillhouse:nuit-gagne',
47
+ config(config) {
48
+ const test = (config.test ??= {});
49
+ test.exclude = ['**/node_modules/**', '**/dist/**', '**/.git/**', ...exclus];
50
+ test.reporters = base.test.reporters;
51
+ test.setupFiles = [...new Set([...(test.setupFiles ?? []), ...base.test.setupFiles])];
52
+ },
53
+ };
54
+
55
+ const cadre = {
56
+ plugins: [nuitGagne, nuit()],
24
57
  cacheDir: base.cacheDir,
25
58
  test: {
26
59
  env: base.test.env,
@@ -29,9 +62,24 @@ export default {
29
62
  setupFiles: base.test.setupFiles,
30
63
  include: HORS_DU_JOUR,
31
64
  exclude: ['**/node_modules/**', '**/dist/**', '**/.git/**'],
65
+ // A unit may hold none of the files the run chooses.
66
+ passWithNoTests: true,
32
67
  // The large delay of Bazel for a night test: 900 s (./vitest-config/delais.mjs).
33
68
  testTimeout: DELAI_NUIT_MS,
34
69
  hookTimeout: DELAI_NUIT_MS,
35
70
  watch: false,
36
71
  },
37
72
  };
73
+
74
+ async function dePaquet(f) {
75
+ const lu = (await import(pathToFileURL(f).href)).default;
76
+ const paquet = typeof lu === 'function' ? await lu({ command: 'serve', mode: 'test' }) : lu;
77
+ // The environment and the setup files of the package are its own to set.
78
+ const { environment: _e, setupFiles: _s, ...test } = cadre.test;
79
+ return mergeConfig(paquet ?? {}, { ...cadre, test });
80
+ }
81
+
82
+ /** @type {typeof cadre} */
83
+ const configuration = fichier ? await dePaquet(fichier) : cadre;
84
+
85
+ export default configuration;
@@ -76,7 +76,7 @@ export async function jouer(
76
76
  return prises.length + parts.length;
77
77
  };
78
78
  const restent = dit();
79
- if (!attendre || issue === 'nuit-tient') {
79
+ if (!attendre) {
80
80
  return 0;
81
81
  }
82
82
  let encore = restent;
@@ -15,7 +15,8 @@
15
15
  // (`globalPassThroughEnv`, scripts/langages/typescript/turbo-des-paquets.mjs); `circuit`, the results and progress
16
16
  // of the passes of a circuit's run (scripts/circuit.mjs; its working directory is the ticket's,
17
17
  // beside its copy, which no sweep touches); `integration`, the working directory of an
18
- // integration (scripts/integration/integrer.mjs); `enveloppe`, the throwaway state of a session's envelope
18
+ // integration (scripts/integration/integrer.mjs); `file`, the results of the final pass of the queue
19
+ // (scripts/integration/file.mjs); `enveloppe`, the throwaway state of a session's envelope
19
20
  // (scripts/enveloppe/enveloppe.mjs).
20
21
  // - The owner of a base is the process that opens it, for a pass and a session out of a ticket
21
22
  // (the night, a verification); a ticket (`ouvrirBaseDuTicket`: `<dans>/grillhouse-ticket-<id>/`,
@@ -0,0 +1,30 @@
1
+ // From 0.49.0 a circuit reserves 3 cores (it reserved 4). A package.json of the project whose
2
+ // `grillhouse.part.coeurs` is 4 gets 3, its other keys, its layout and its end of line kept; a
3
+ // project without that value, without `grillhouse` or without package.json is left, and a second
4
+ // pass changes nothing and says nothing.
5
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
6
+ import path from 'node:path';
7
+
8
+ export const version = '0.49.0';
9
+ export const nom = 'reservation de trois coeurs';
10
+
11
+ /** `grillhouse.part.coeurs` 4 turned into 3 in the package.json of <projet>; returns what it did. */
12
+ export function migrer(projet) {
13
+ const fichier = path.join(projet, 'package.json');
14
+ if (!existsSync(fichier)) {
15
+ return [];
16
+ }
17
+ const texte = readFileSync(fichier, 'utf8');
18
+ const pkg = JSON.parse(texte);
19
+ const part = pkg?.grillhouse?.part;
20
+ if (!part || typeof part !== 'object' || part.coeurs !== 4) {
21
+ return [];
22
+ }
23
+ part.coeurs = 3;
24
+ const indent = /^\n?(\s+)"/m.exec(texte)?.[1] ?? 2;
25
+ const fin = texte.endsWith('\n') ? '\n' : '';
26
+ writeFileSync(fichier, `${JSON.stringify(pkg, null, indent)}${fin}`);
27
+ return [
28
+ 'package.json : grillhouse.part.coeurs passe de 4 à 3, la réservation de cœurs d’un circuit ordinaire',
29
+ ];
30
+ }
@@ -44,6 +44,7 @@ import * as seuilDesCodesDeTickets from './migrations/0.44.0-seuil-des-codes-de-
44
44
  import * as ciDeMain from './migrations/0.47.0-ci-de-main.mjs';
45
45
  import * as pousseeRetiree from './migrations/0.48.0-poussee-retiree.mjs';
46
46
  import * as ciDeclencheeParLaFile from './migrations/0.48.0-ci-declenchee-par-la-file.mjs';
47
+ import * as reservationDeTroisCoeurs from './migrations/0.49.0-reservation-de-trois-coeurs.mjs';
47
48
 
48
49
  /** The migrations of the core. */
49
50
  export const MIGRATIONS = [
@@ -67,6 +68,7 @@ export const MIGRATIONS = [
67
68
  ciDeMain,
68
69
  pousseeRetiree,
69
70
  ciDeclencheeParLaFile,
71
+ reservationDeTroisCoeurs,
70
72
  ];
71
73
 
72
74
  /**
package/scripts/nuit.sh CHANGED
@@ -66,6 +66,20 @@
66
66
  # depended on a duration, one under load) waits for rest (`npx grillhouse pression attendre`,
67
67
  # bound 15 min) and plays once more; green then, the night goes on; à repasser again, or no rest in the bound, the night
68
68
  # ends there, « à repasser », red if the full pass is.
69
+ # - The two parts of the night: a project whose `.github/workflows/nuit.yml` plays on the label
70
+ # `pc2` leaves PC2 its night tests but those tagged @poste (the flow's tranches,
71
+ # `tests-de-nuit --hors-du-poste`). The measures of time play on PC3, on dedicated cores, unless
72
+ # the flow declares a job that plays them (a command `tests-de-nuit --mesures`, as the flow of
73
+ # Grillhouse: scripts/flux-de-la-nuit.mjs): then that job's verdict, read for the commit of the
74
+ # night, stands for them, and PC3 plays them only when the job was interrupted. The night of PC3
75
+ # plays the tests tagged @poste, then the measures (`tests-de-nuit --du-poste`, on its part), then
76
+ # reads the flow of its commit by `gh`
77
+ # (scripts/repli-de-la-nuit.mjs): a tranche whose job has not started 60 minutes after the flow's
78
+ # hour is cancelled and played on PC3, a tranche started then interrupted plays whole again, a
79
+ # tranche finished on PC2, green or red, is never replayed; the log says which tranches played
80
+ # where. Each part keeps its verdict (scripts/verdict-de-la-nuit.mjs: `nuit/verdict` for PC3,
81
+ # `nuit/verdict-pc2`), the night is red when either is, and a red tranche opens or comments its
82
+ # night ticket.
69
83
  # - « À repasser » (exit 75): neither green nor red. The last green stays, no ticket opens,
70
84
  # the log says so; the next night plays again.
71
85
  # - The project's night script: `grillhouse.nuit` in the package.json of the commit it plays names
@@ -95,7 +109,8 @@
95
109
  # - It takes no lock of the integration or of the queue (scripts/integration/file.mjs): an
96
110
  # integration and the queue run during the night, each in its own copy.
97
111
  # - Its log is <git common dir>/nuit/<date>.log. Green: HEAD becomes the last green commit
98
- # (<git common dir>/nuit/dernier-vert). Red: the red tasks, each grouped by its cause as an
112
+ # (<git common dir>/nuit/dernier-vert), only once the measures of time were played and are green,
113
+ # by PC3 or by the flow's job for that commit. Red: the red tasks, each grouped by its cause as an
99
114
  # alerting system groups by fingerprint: each red task of the full pass (the file
100
115
  # GRILLHOUSE_ROUGES names, which the verification of the module writes: `<task>` per line, then
101
116
  # a tab and the command that replays it alone when the language has one, no task à repasser
@@ -157,6 +172,12 @@ copie="$racine/.claude/worktrees/nuit"
157
172
  etapes=()
158
173
  taches=()
159
174
  rejeux=()
175
+ # The part of PC2 of the night (the tranches of the Nuit flow), when the project's flow plays on PC2:
176
+ # its red steps and tasks, kept apart from PC3's so that each part has its own verdict, and its exit
177
+ # code (empty when the project has no part on PC2; 75 when a tranche is still to play there).
178
+ etapes_pc2=()
179
+ taches_pc2=()
180
+ code_pc2=
160
181
  # Gets the copy ready on HEAD: detached, cleaned, its submodules set; `partages` holds the list the
161
182
  # pose fixes, which every mount gets. Prints the reason on failure.
162
183
  partages=
@@ -169,6 +190,80 @@ preparer() {
169
190
  fi
170
191
  partages=$(bash "$ici/sous-modules.sh" pose "$copie")
171
192
  }
193
+ # The part of PC2: reads the Nuit flow of the commit the night plays by `gh` (scripts/repli-de-la-nuit.mjs), which cancels the
194
+ # run when a tranche has not started 60 minutes after the flow's hour, then plays on PC3, whole, each
195
+ # tranche not played on PC2 (never one finished there, green or red). A tranche still running or
196
+ # waiting leaves the part of PC2 « à repasser » (75). The statement says which tranches played where.
197
+ repli() {
198
+ local depot decision ligne
199
+ code_pc2=0
200
+ if ! depot="$(cd "$racine" && gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null)" || [ -z "$depot" ]; then
201
+ echo "⏱ le repli de la nuit ne lit pas le dépôt GitHub (gh) : la part de PC2 reste à repasser."
202
+ code_pc2=75
203
+ return
204
+ fi
205
+ if ! decision="$(node "$ici/repli-de-la-nuit.mjs" "$depot" "$tranches" "" "$tete")"; then
206
+ echo "⏱ le repli de la nuit ne lit pas le flux Nuit : la part de PC2 reste à repasser."
207
+ code_pc2=75
208
+ return
209
+ fi
210
+ local lignes rejouer= rouges_pc2= attend= mesures_du_flux=
211
+ lignes="$(printf '%s' "$decision" | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const d=JSON.parse(s);const l=k=>(d[k]??[]).join(" ");process.stdout.write(["pc2","pc3","rouges","enAttente","enCours","mesures"].map(k=>k+"\t"+l(k)).join("\n")+"\n")})')"
212
+ while IFS= read -r ligne; do
213
+ case "$ligne" in
214
+ pc2$'\t'*) echo "relevé de la nuit : tranches jouées sur PC2 : ${ligne#pc2$'\t'}" ;;
215
+ pc3$'\t'*) rejouer="${ligne#pc3$'\t'}"; echo "relevé de la nuit : tranches jouées sur PC3 : ${rejouer:-aucune}" ;;
216
+ rouges$'\t'*) rouges_pc2="${ligne#rouges$'\t'}" ;;
217
+ mesures$'\t'*) mesures_du_flux="${ligne#mesures$'\t'}"; echo "relevé de la nuit : mesures de temps du flux : ${mesures_du_flux}" ;;
218
+ enAttente$'\t'*|enCours$'\t'*) attend="$attend ${ligne#*$'\t'}" ;;
219
+ esac
220
+ done <<< "$lignes"
221
+ local t code
222
+ for t in $rouges_pc2; do
223
+ echo "✗ la tranche $t de la nuit est rouge sur PC2."
224
+ etapes_pc2+=("la tranche $t de la nuit sur PC2")
225
+ taches_pc2+=("la tranche $t de la nuit sur PC2")
226
+ done
227
+ for t in $rejouer; do
228
+ (cd "$copie" && monter node "$ici/commande-du-langage.mjs" tests-de-nuit --hors-du-poste --tranche "$t/$tranches")
229
+ code=$?
230
+ if [ "$code" -ne 0 ] && [ "$code" -ne 75 ]; then
231
+ echo "✗ la tranche $t, rejouée sur PC3, est rouge."
232
+ etapes_pc2+=("la tranche $t de la nuit, rejouée sur PC3")
233
+ taches_pc2+=("la tranche $t de la nuit sur PC3 (repli)")
234
+ elif [ "$code" -eq 75 ]; then
235
+ attend="$attend $t"
236
+ fi
237
+ done
238
+ # The measures of time: the flow's job plays them when its file declares one; the night of the
239
+ # poste plays them itself otherwise (tests-de-nuit --du-poste), so no last green without them.
240
+ if node "$ici/flux-de-la-nuit.mjs" mesures "$copie"; then
241
+ case "$mesures_du_flux" in
242
+ rouge)
243
+ echo "✗ les mesures de temps du flux sont rouges sur PC2."
244
+ etapes_pc2+=("les mesures de temps de la nuit sur PC2")
245
+ taches_pc2+=("les mesures de temps de la nuit sur PC2") ;;
246
+ a-rejouer)
247
+ (cd "$copie" && monter node "$ici/commande-du-langage.mjs" tests-de-nuit --mesures)
248
+ code=$?
249
+ if [ "$code" -eq 75 ]; then
250
+ attend="$attend mesures"
251
+ elif [ "$code" -ne 0 ]; then
252
+ echo "✗ les mesures de temps, rejouées sur PC3, sont rouges."
253
+ etapes_pc2+=("les mesures de temps de la nuit, rejouées sur PC3")
254
+ taches_pc2+=("les mesures de temps de la nuit sur PC3 (repli)")
255
+ fi ;;
256
+ verte) ;;
257
+ *) attend="$attend mesures" ;;
258
+ esac
259
+ fi
260
+ if [ "${#etapes_pc2[@]}" -gt 0 ]; then
261
+ code_pc2=1
262
+ elif [ -n "${attend// /}" ]; then
263
+ echo "⏱ la part de PC2 reste à repasser : tranche(s) en cours, en attente ou à repasser :$attend."
264
+ code_pc2=75
265
+ fi
266
+ }
172
267
  # Plays the copy; its status is the night's verdict. An existing copy that does not get ready is
173
268
  # removed (scripts/retirer-copie.sh --jetable) and created again, once.
174
269
  jouer() {
@@ -297,7 +392,22 @@ process.exit(paquets(process.argv[2]).some(p => p.pkg.name === "@roomi-fields/gr
297
392
  rejeux+=("")
298
393
  fi
299
394
  fi
300
- bancs() { (cd "$copie" && monter node "$ici/commande-du-langage.mjs" tests-de-nuit); }
395
+ # A project whose Nuit flow plays on PC2 (its runner label `pc2`) leaves PC2 the night tests that
396
+ # do not need the poste: PC3 plays the tests tagged @poste, then the tranches PC2 did not play
397
+ # (the fallback, scripts/repli-de-la-nuit.mjs). The measures of time play on PC3 too, unless the
398
+ # flow declares a job that plays them (`tests-de-nuit --mesures`, scripts/flux-de-la-nuit.mjs,
399
+ # the flow of Grillhouse): then the verdict of its job, read for the commit of the night, counts.
400
+ # The last green is set only when the measures were played and are green, by PC3 or by that job.
401
+ local sur_pc2=0 tranches=
402
+ if grep -q "\bpc2\b" "$copie/.github/workflows/nuit.yml" 2>/dev/null; then
403
+ sur_pc2=1
404
+ tranches="$(sed -n 's/^ TRANCHES: *\([0-9]*\).*/\1/p' "$copie/.github/workflows/nuit.yml")"
405
+ fi
406
+ bancs() {
407
+ local args=()
408
+ [ "$sur_pc2" -eq 0 ] || args=(--du-poste)
409
+ (cd "$copie" && monter node "$ici/commande-du-langage.mjs" tests-de-nuit "${args[@]}")
410
+ }
301
411
  bancs
302
412
  code=$?
303
413
  if [ "$code" -eq 75 ]; then
@@ -321,6 +431,9 @@ process.exit(paquets(process.argv[2]).some(p => p.pkg.name === "@roomi-fields/gr
321
431
  taches+=("les bancs de temps et les tests de nuit")
322
432
  rejeux+=("")
323
433
  fi
434
+ if [ "$sur_pc2" -eq 1 ]; then
435
+ repli
436
+ fi
324
437
  if [ -n "$nuit" ] && ! monter npm --prefix "$copie" run "$nuit"; then
325
438
  echo "✗ le script de nuit du projet \`npm run $nuit\` (grillhouse.nuit) a échoué."
326
439
  etapes+=("le script de nuit du projet (npm run $nuit, grillhouse.nuit)")
@@ -341,7 +454,20 @@ verdict=$?
341
454
  (cd "$racine" && node "$ici/retirer-les-copies-finies.mjs" "$copie") >> "$journal" 2>&1 || true
342
455
  # The project's durable verdict, read by the board: green on 0, red on any other code but 75, which
343
456
  # writes nothing (the previous verdict stays).
344
- node "$ici/verdict-de-la-nuit.mjs" "$commun" "$verdict" >> "$journal" 2>&1 || true
457
+ node "$ici/verdict-de-la-nuit.mjs" "$commun" "$verdict" pc3 >> "$journal" 2>&1 || true
458
+ # The part of PC2, when the project has one: its own durable verdict, and the night's, which is red
459
+ # when either part is red and « à repasser » while a tranche of PC2 is still to play.
460
+ if [ -n "$code_pc2" ]; then
461
+ node "$ici/verdict-de-la-nuit.mjs" "$commun" "$code_pc2" pc2 >> "$journal" 2>&1 || true
462
+ if [ "$code_pc2" -eq 1 ]; then
463
+ etapes+=("${etapes_pc2[@]}")
464
+ taches+=("${taches_pc2[@]}")
465
+ for _ in "${taches_pc2[@]}"; do rejeux+=(""); done
466
+ verdict=1
467
+ elif [ "$code_pc2" -eq 75 ] && [ "$verdict" -eq 0 ]; then
468
+ verdict=75
469
+ fi
470
+ fi
345
471
 
346
472
  if [ "$verdict" -eq 75 ]; then
347
473
  echo "⏱ à repasser : ${tete:0:7} n'est ni vert ni rouge, la machine est restée chargée ; le dernier vert reste, aucun ticket, la nuit suivante rejoue." >> "$journal"