@roomi-fields/grillhouse 0.31.0 → 0.33.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 (149) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +40 -0
  3. package/bin/grillhouse.mjs +6 -4
  4. package/cadre/templates/projet/.github/workflows/ci.yml +136 -16
  5. package/cadre/templates/projet/.github/workflows/nuit.yml +111 -0
  6. package/cadre/templates/projet/deployment/docs/01-INSTALL.md +4 -4
  7. package/cadre/templates/projet/package.json +2 -2
  8. package/charte.md +8 -5
  9. package/dist/temporal/circuit/contrat.d.ts +15 -0
  10. package/dist/temporal/circuit/deroule.js +37 -14
  11. package/dist/temporal/circuit/deroule.js.map +1 -1
  12. package/dist/temporal/deroules.d.ts +1 -0
  13. package/dist/temporal/deroules.js +3 -1
  14. package/dist/temporal/deroules.js.map +1 -1
  15. package/dist/temporal/file/activites.d.ts +1 -0
  16. package/dist/temporal/file/activites.js +5 -2
  17. package/dist/temporal/file/activites.js.map +1 -1
  18. package/dist/temporal/file/contrat.d.ts +50 -33
  19. package/dist/temporal/file/contrat.js +2 -2
  20. package/dist/temporal/file/contrat.js.map +1 -1
  21. package/dist/temporal/file/deroule.d.ts +3 -1
  22. package/dist/temporal/file/deroule.js +128 -26
  23. package/dist/temporal/file/deroule.js.map +1 -1
  24. package/dist/temporal/installation.d.ts +3 -2
  25. package/dist/temporal/installation.js +7 -4
  26. package/dist/temporal/installation.js.map +1 -1
  27. package/dist/temporal/nuits/activites.d.ts +10 -0
  28. package/dist/temporal/nuits/activites.js +114 -0
  29. package/dist/temporal/nuits/activites.js.map +1 -0
  30. package/dist/temporal/nuits/appel.d.ts +23 -0
  31. package/dist/temporal/nuits/appel.js +40 -0
  32. package/dist/temporal/nuits/appel.js.map +1 -0
  33. package/dist/temporal/nuits/choix.d.ts +14 -0
  34. package/dist/temporal/nuits/choix.js +119 -0
  35. package/dist/temporal/nuits/choix.js.map +1 -0
  36. package/dist/temporal/nuits/client.d.ts +28 -0
  37. package/dist/temporal/nuits/client.js +83 -0
  38. package/dist/temporal/nuits/client.js.map +1 -0
  39. package/dist/temporal/nuits/commande.d.ts +2 -0
  40. package/dist/temporal/nuits/commande.js +107 -0
  41. package/dist/temporal/nuits/commande.js.map +1 -0
  42. package/dist/temporal/nuits/contrat.d.ts +98 -0
  43. package/dist/temporal/nuits/contrat.js +30 -0
  44. package/dist/temporal/nuits/contrat.js.map +1 -0
  45. package/dist/temporal/nuits/deroule.d.ts +5 -0
  46. package/dist/temporal/nuits/deroule.js +100 -0
  47. package/dist/temporal/nuits/deroule.js.map +1 -0
  48. package/dist/temporal/tickets/activites.d.ts +1 -0
  49. package/dist/temporal/tickets/activites.js +5 -0
  50. package/dist/temporal/tickets/activites.js.map +1 -1
  51. package/dist/temporal/tickets/contrat.d.ts +10 -0
  52. package/dist/temporal/tickets/deroule.js +8 -1
  53. package/dist/temporal/tickets/deroule.js.map +1 -1
  54. package/dist/temporal/travailleur.js +4 -1
  55. package/dist/temporal/travailleur.js.map +1 -1
  56. package/docs/ARCHITECTURE.md +257 -54
  57. package/docs/CADRE.md +41 -1
  58. package/docs/INTERFACE.md +54 -7
  59. package/hooks/hooks.json +4 -0
  60. package/hooks/register.tsx +11 -3
  61. package/package.json +4 -1
  62. package/scripts/abi-des-dependances.mjs +105 -0
  63. package/scripts/activites.mjs +99 -48
  64. package/scripts/aiguillage.mjs +3 -0
  65. package/scripts/attente-au-tour.mjs +99 -0
  66. package/scripts/avancement.mjs +8 -18
  67. package/scripts/base-des-workflows.mjs +57 -0
  68. package/scripts/ci-des-branches.mjs +91 -0
  69. package/scripts/circuit.mjs +99 -5
  70. package/scripts/composants-affectes.mjs +24 -7
  71. package/scripts/composition-des-langages.mjs +3 -0
  72. package/scripts/copies-finies.mjs +8 -1
  73. package/scripts/crochets.mjs +4 -0
  74. package/scripts/dernier-vert.mjs +30 -4
  75. package/scripts/effets.mjs +9 -0
  76. package/scripts/enveloppe/enveloppe.mjs +3 -1
  77. package/scripts/enveloppe/lancer.sh +1 -1
  78. package/scripts/enveloppe/travail-de-la-copie.mjs +219 -59
  79. package/scripts/etapes.mjs +19 -2
  80. package/scripts/faits-du-circuit.mjs +43 -20
  81. package/scripts/fichier-du-poste.mjs +87 -0
  82. package/scripts/grillhouse-maj.mjs +15 -1
  83. package/scripts/integration/file.mjs +215 -275
  84. package/scripts/integration/integrer.mjs +82 -41
  85. package/scripts/integration/rejeu.mjs +13 -64
  86. package/scripts/jointure.d.ts +30 -2
  87. package/scripts/journal-des-etats.d.mts +41 -0
  88. package/scripts/journal-des-etats.mjs +273 -0
  89. package/scripts/journal.mjs +119 -0
  90. package/scripts/langages/cargo/commandes.mjs +81 -19
  91. package/scripts/langages/cargo/exemples.mjs +2 -2
  92. package/scripts/langages/cargo/index.mjs +14 -5
  93. package/scripts/langages/cargo/tailles-des-tests.mjs +19 -11
  94. package/scripts/langages/python/commandes.mjs +11 -7
  95. package/scripts/langages/python/exemples.mjs +1 -1
  96. package/scripts/langages/python/index.mjs +11 -2
  97. package/scripts/langages/python/tailles-des-tests.mjs +19 -11
  98. package/scripts/langages/typescript/code-mort.mjs +41 -24
  99. package/scripts/langages/typescript/consommateurs.mjs +28 -17
  100. package/scripts/langages/typescript/exemples.mjs +2 -0
  101. package/scripts/langages/typescript/frontieres.mjs +46 -0
  102. package/scripts/langages/typescript/index.mjs +24 -3
  103. package/scripts/langages/typescript/migrations/0.33.0-binaire-de-jour.mjs +34 -0
  104. package/scripts/langages/typescript/migrations/0.33.0-tests-du-poste.mjs +31 -0
  105. package/scripts/langages/typescript/resumes.mjs +17 -7
  106. package/scripts/langages/typescript/tailles-des-tests.mjs +251 -22
  107. package/scripts/langages/typescript/tests-de-nuit.mjs +101 -9
  108. package/scripts/langages/typescript/tests-du-poste.mjs +172 -0
  109. package/scripts/langages/typescript/tranches.mjs +273 -0
  110. package/scripts/langages/typescript/verifier.mjs +154 -23
  111. package/scripts/langages/typescript/vitest-config/base.mjs +3 -0
  112. package/scripts/langages/typescript/vitest-config/cibles.mjs +78 -7
  113. package/scripts/langages/typescript/vitest-config/lances.mjs +4 -4
  114. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +9 -0
  115. package/scripts/langages/typescript/vitest.nuit.config.mjs +3 -2
  116. package/scripts/langages.d.mts +20 -0
  117. package/scripts/lint-des-scripts.mjs +23 -6
  118. package/scripts/matiere-de-test.d.ts +11 -0
  119. package/scripts/migrations/0.33.0-cache-distant.mjs +36 -0
  120. package/scripts/migrations/0.33.0-ci-des-branches-de-ticket.mjs +31 -0
  121. package/scripts/migrations/0.33.0-ci-du-cadre.mjs +31 -0
  122. package/scripts/migrations/0.33.0-node-26.mjs +58 -0
  123. package/scripts/migrations.mjs +8 -0
  124. package/scripts/newday.mjs +18 -0
  125. package/scripts/nuit.sh +40 -13
  126. package/scripts/places-de-la-machine.mjs +6 -0
  127. package/scripts/registre.d.mts +90 -0
  128. package/scripts/registre.mjs +28 -3
  129. package/scripts/reprise.mjs +12 -8
  130. package/scripts/services-du-noyau.mjs +4 -0
  131. package/scripts/session-start.sh +28 -32
  132. package/scripts/sous-commandes.mjs +31 -10
  133. package/scripts/superviseur.mjs +127 -75
  134. package/scripts/tableau.mjs +222 -17
  135. package/scripts/taches-du-graphe.mjs +39 -6
  136. package/scripts/ticket-du-circuit.mjs +37 -7
  137. package/scripts/transitions.mjs +60 -8
  138. package/scripts/verrou-de-machine.mjs +1 -2
  139. package/scripts/workflows-du-cadre.mjs +75 -0
  140. package/skills/developpeur/SKILL.md +1 -1
  141. package/skills/explorateur/SKILL.md +1 -1
  142. package/skills/grill/SKILL.md +10 -62
  143. package/skills/grill/references/paquets.md +60 -0
  144. package/skills/pitmaster/SKILL.md +21 -31
  145. package/skills/questionneur/SKILL.md +1 -1
  146. package/skills/relecteur/SKILL.md +1 -1
  147. package/skills/testwriter/SKILL.md +7 -1
  148. package/skills/release/SKILL.md +0 -134
  149. package/skills/release/scripts/update-version.cjs +0 -92
@@ -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
+ }
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env node
2
+ // The subcommand `grillhouse journal [--depuis <ISO>] [--jusqu-a <ISO>] [--ticket <id>]`: the
3
+ // chronology of the journal of states of the project (scripts/journal-des-etats.mjs), its lines in
4
+ // the order of their timestamps, and, after each launch or end of a circuit of the queue, the set
5
+ // of the tickets at work against the ceiling of the circuits (`grillhouse.circuits`): one ticket at
6
+ // work when the ceiling allows two shows at once. Bounds are ISO 8601 with the local offset,
7
+ // included; a line unreadable is left out; no journal or no line in the range is said, exit 0.
8
+ // Exit 2 for an option unknown or a date unreadable.
9
+ import { existsSync, readFileSync } from 'node:fs';
10
+ import path from 'node:path';
11
+ import { pathToFileURL } from 'node:url';
12
+ import { reglageDesCircuits } from './circuits-cles.mjs';
13
+ import { dossierDuJournal, ensemblesEnTravail, lireLeJournal } from './journal-des-etats.mjs';
14
+
15
+ const USAGE = 'usage : grillhouse journal [--depuis <ISO>] [--jusqu-a <ISO>] [--ticket <id>]\n';
16
+ const ISO = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?([+-]\d{2}:\d{2}|Z)?)?$/;
17
+
18
+ // The options of <argv>, `{ depuis, jusquA, ticket }`, or `{ faute }`.
19
+ function options(argv) {
20
+ const cles = { '--depuis': 'depuis', '--jusqu-a': 'jusquA', '--ticket': 'ticket' };
21
+ const o = {};
22
+ for (let i = 0; i < argv.length; i += 2) {
23
+ const cle = cles[argv[i]];
24
+ if (!cle) {
25
+ return { faute: `option inconnue : ${argv[i]}` };
26
+ }
27
+ const v = argv[i + 1];
28
+ if (v === undefined) {
29
+ return { faute: `${argv[i]} attend une valeur` };
30
+ }
31
+ if (cle !== 'ticket' && (!ISO.test(v) || Number.isNaN(Date.parse(v)))) {
32
+ return { faute: `${argv[i]} : « ${v} » n'est pas une date ISO 8601` };
33
+ }
34
+ o[cle] = v;
35
+ }
36
+ return o;
37
+ }
38
+
39
+ // The ceiling of the circuits of the project at <racine>: its key, 1 when absent.
40
+ function plafond(racine) {
41
+ const f = path.join(racine, 'package.json');
42
+ try {
43
+ return reglageDesCircuits(existsSync(f) ? JSON.parse(readFileSync(f, 'utf8')) : {}).max ?? 1;
44
+ } catch {
45
+ return 1;
46
+ }
47
+ }
48
+
49
+ const heure = ts => ts.slice(11);
50
+
51
+ const ligneDe = l =>
52
+ [
53
+ l.ts,
54
+ String(l.genre ?? '').padEnd(7),
55
+ l.ticket ?? '-',
56
+ l.etape ?? '-',
57
+ ...(l.boucle === null || l.boucle === undefined ? [] : [`boucle ${l.boucle}`]),
58
+ ...(l.place ? [`place ${l.place}`] : []),
59
+ ...(l.raison ? [`— ${l.raison}`] : []),
60
+ ].join(' ');
61
+
62
+ /**
63
+ * The subcommand: writes the chronology through <out>, its faults through <err>; the exit code.
64
+ * @param {string[]} argv
65
+ * @param {{ racine?: string, out?: (t: string) => void, err?: (t: string) => void }} [contexte]
66
+ * @returns {number}
67
+ */
68
+ export function journal(
69
+ argv,
70
+ {
71
+ racine = process.cwd(),
72
+ out = t => process.stdout.write(`${t}\n`),
73
+ err = t => process.stderr.write(`${t}\n`),
74
+ } = {}
75
+ ) {
76
+ const o = options(argv);
77
+ if (o.faute) {
78
+ err(`⛔ grillhouse journal : ${o.faute}\n${USAGE.trimEnd()}`);
79
+ return 2;
80
+ }
81
+ let dossier = null;
82
+ try {
83
+ dossier = dossierDuJournal(racine);
84
+ } catch {
85
+ // no git project: no journal
86
+ }
87
+ if (!dossier || !existsSync(dossier)) {
88
+ out('Aucun journal pour ce projet.');
89
+ return 0;
90
+ }
91
+ // The sets are rebuilt from the start of the journal up to the end of the range, so that a range
92
+ // that starts mid-work knows who was already at work.
93
+ const jusqua = o.jusquA === undefined ? {} : { jusquA: o.jusquA };
94
+ const toutes = lireLeJournal(racine, jusqua).lignes;
95
+ const depuis = o.depuis === undefined ? -Infinity : Date.parse(o.depuis);
96
+ const affichees = toutes.filter(
97
+ l => Date.parse(l.ts) >= depuis && (o.ticket === undefined || l.ticket === o.ticket)
98
+ );
99
+ if (affichees.length === 0) {
100
+ out('Aucune ligne dans la plage.');
101
+ return 0;
102
+ }
103
+ const max = plafond(racine);
104
+ const parInstant = new Map(ensemblesEnTravail(toutes).map(e => [e.ts, e.enTravail]));
105
+ for (const l of affichees) {
106
+ out(ligneDe(l));
107
+ const ensemble = l.genre === 'file' ? parInstant.get(l.ts) : undefined;
108
+ if (ensemble) {
109
+ out(
110
+ ` ${heure(l.ts)} en travail ${ensemble.length}/${max}${ensemble.length ? ` : ${ensemble.join(', ')}` : ''}`
111
+ );
112
+ }
113
+ }
114
+ return 0;
115
+ }
116
+
117
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
118
+ process.exitCode = journal(process.argv.slice(2));
119
+ }
@@ -7,7 +7,6 @@
7
7
  // npx grillhouse tests-du-paquet <chemin>… [--<option>…] tests-du-paquet
8
8
  // npx grillhouse verifier [--tout | --gardes] verifier
9
9
  // node commandes.mjs typer typer
10
- // npx grillhouse preparer preparer
11
10
  // npx grillhouse tests-de-nuit tests-de-nuit
12
11
  // npx grillhouse tailles-des-tests | clippy | frontieres | index-interfaces
13
12
  // each guard, its own script
@@ -34,7 +33,14 @@
34
33
  // (./composants.mjs, `joueDesTests`): the build of its test targets, `cargo test --no-run -p
35
34
  // <crate>`, a task `build` of its own, as Turborepo's `test` depends on `build` (grillhouse-egm);
36
35
  // then `cargo nextest run -p <crate> --no-fail-fast`, which finds them built. Then `cargo test
37
- // --doc -p <crate>` for a crate whose library has doctests, which nextest does not play. A failed
36
+ // --doc -p <crate>` for a crate whose library has doctests, which nextest does not play. Once
37
+ // the tests and the benches played, the run removes the test executables its builds made, each
38
+ // one cargo reports in JSON (`--message-format=json-render-diagnostics`, the `executable` of an
39
+ // artifact of a test profile), as Swatinem/rust-cache keeps the dependencies and drops the
40
+ // workspace's own artifacts: they weighed 3.4 of the 4.6 GiB of a copy of SyntHub
41
+ // (grillhouse-pkl.8), and cargo builds again an executable it misses. The libraries, the
42
+ // dependencies and the binaries of `cargo build` (`target/debug/<bin>`, a datum another package's
43
+ // tests run) stay; only the crate's own task runs its test executables. A failed
38
44
  // build leaves the crate's other tasks not played (`code` null): a test that does not compile is
39
45
  // a red of the build, which the proof of the red reads as one (« construction de <crate> »,
40
46
  // scripts/circuit.mjs), and the tests play at the checks. The output of the build goes to its log,
@@ -85,7 +91,7 @@
85
91
  // - `tests-de-nuit`: the night tests then the benches of each crate that holds some; none, nothing
86
92
  // plays and the code is 0. The night (scripts/nuit.sh) runs it after the full pass, and plays it
87
93
  // again at rest after a 75.
88
- // - `typer`: `cargo check --all-targets`. `preparer`: `cargo fetch --locked`.
94
+ // - `typer`: `cargo check --all-targets`.
89
95
  // - Cargo runs with rustc wrapped by sccache, its cache common to the copies of the machine
90
96
  // (./sccache.mjs), in a copy as in an agent's envelope (grillhouse-cyr), its server started
91
97
  // under the machine's /tmp before each run of cargo that compiles (grillhouse-qmk).
@@ -99,7 +105,7 @@
99
105
  // there what ./verdict.mjs reads: its tasks, each planned before it plays (`code` null until it
100
106
  // ran), and the JUnit report of each run of nextest. A task of the workspace is named after its
101
107
  // root, `//`, as Turborepo names the root's tasks.
102
- // - `tests-du-paquet`, `verifier` and `preparer` refuse, before any run of cargo, a workspace whose
108
+ // - `tests-du-paquet` and `verifier` refuse, before any run of cargo, a workspace whose
103
109
  // Cargo.lock git does not track (grillhouse-rph), in one line that names the file and the
104
110
  // gesture: `git add Cargo.lock`, or `cargo generate-lockfile` first when it is absent. Cargo
105
111
  // recommends committing it for every project, and the verification plays the exact versions of
@@ -136,6 +142,7 @@ import {
136
142
  construireDepuisLesArguments,
137
143
  ecrirePression,
138
144
  GRAPHE_JOUE,
145
+ joueCeQuiNeSeDivisePas,
139
146
  lancerLesTaches,
140
147
  ligneDesRestes,
141
148
  lirePression,
@@ -168,7 +175,6 @@ export const NOMS = [
168
175
  'verifier',
169
176
  'typer',
170
177
  'construire',
171
- 'preparer',
172
178
  'tests-de-nuit',
173
179
  ];
174
180
  // The task runner of the graph of the packages.
@@ -179,9 +185,12 @@ const RACINE = '//';
179
185
  const BUDGET = 'budget';
180
186
  const VERROU = 'Cargo.lock';
181
187
  // The commands that play the exact versions of the repository, refused without its Cargo.lock.
182
- const VERROUILLEES = ['tests-du-paquet', 'verifier', 'preparer', 'tests-de-nuit'];
188
+ const VERROUILLEES = ['tests-du-paquet', 'verifier', 'tests-de-nuit'];
183
189
  // The commands that compile, refused without sccache on the PATH (./sccache.mjs).
184
190
  const COMPILENT = ['tests-du-paquet', 'verifier', 'typer', 'construire', 'tests-de-nuit'];
191
+ // The format of the build of the test targets: the messages of cargo in JSON on its output stream,
192
+ // its diagnostics rendered on its error stream, as without it (`executablesDeTest`).
193
+ const MESSAGES = '--message-format=json-render-diagnostics';
185
194
  // The kinds of a target that are no library.
186
195
  const PAS_UNE_BIBLIOTHEQUE = ['test', 'bin', 'example', 'bench', 'custom-build'];
187
196
 
@@ -288,7 +297,13 @@ function passe(racine, env) {
288
297
  },
289
298
  jouer(
290
299
  { t, args },
291
- { junit = null, journal = null, programme = 'cargo', temporaire = {} } = {}
300
+ {
301
+ junit = null,
302
+ journal = null,
303
+ programme = 'cargo',
304
+ temporaire = {},
305
+ executables = null,
306
+ } = {}
292
307
  ) {
293
308
  // A report of an earlier run is no report of this one, which may write none.
294
309
  if (junit) {
@@ -307,14 +322,20 @@ function passe(racine, env) {
307
322
  mkdirSync(path.dirname(journal), { recursive: true });
308
323
  const fd = openSync(journal, 'w');
309
324
  try {
325
+ // With <executables>, cargo's messages in JSON come on its output stream, read, out of
326
+ // the log (`executablesDeTest`).
310
327
  r = spawnSync(programme, args, {
311
328
  cwd: racine,
312
329
  env: { ...compilation, ...temporaire },
313
- stdio: ['inherit', fd, fd],
330
+ stdio: ['inherit', executables ? 'pipe' : fd, fd],
331
+ maxBuffer: 256 * 1024 * 1024,
314
332
  });
315
333
  } finally {
316
334
  closeSync(fd);
317
335
  }
336
+ if (executables && r.stdout) {
337
+ executables.push(...executablesDeTest(r.stdout.toString('utf8')));
338
+ }
318
339
  process.stderr.write(readFileSync(journal, 'utf8'));
319
340
  t.journal = path.relative(racine, journal);
320
341
  } else {
@@ -355,6 +376,29 @@ function passe(racine, env) {
355
376
  };
356
377
  }
357
378
 
379
+ /**
380
+ * The test executables cargo reports in its messages in JSON <sortie> (`--message-format`, one
381
+ * message a line): the `executable` of each `compiler-artifact` built under a test profile
382
+ * (`profile.test`), fresh or rebuilt; a line that is no message is passed over.
383
+ * @param {string} sortie
384
+ * @returns {string[]}
385
+ */
386
+ export function executablesDeTest(sortie) {
387
+ const vus = [];
388
+ for (const ligne of sortie.split('\n')) {
389
+ let m;
390
+ try {
391
+ m = JSON.parse(ligne);
392
+ } catch {
393
+ continue;
394
+ }
395
+ if (m?.reason === 'compiler-artifact' && m.profile?.test && typeof m.executable === 'string') {
396
+ vus.push(m.executable);
397
+ }
398
+ }
399
+ return vus;
400
+ }
401
+
358
402
  // A red of the time budget benches of the task <t>, the pressures <pressions> measured at its start
359
403
  // and at its end: « à repasser » (75) when one is at or above the threshold, said; else its code
360
404
  // stands, a pressure that does not read said.
@@ -374,13 +418,26 @@ function sousCharge(t, pressions) {
374
418
  t.code = A_REPASSER;
375
419
  }
376
420
 
421
+ /**
422
+ * The arguments of nextest for the tranche <tranche> of a pass (`verifier --tranche i/n`): its own
423
+ * split, `--partition hash:i/n` (each test by the hash of its name, so the n tranches together
424
+ * play each test once), and `--no-tests=warn`, a crate whose part is empty being green; none
425
+ * without a tranche.
426
+ * @param {{ index: number, count: number } | null | undefined} tranche
427
+ * @returns {string[]}
428
+ */
429
+ export const partitionDeNextest = tranche =>
430
+ tranche ? ['--partition', `hash:${tranche.index}/${tranche.count}`, '--no-tests=warn'] : [];
431
+
377
432
  // Plans and plays the tests of the crates <choix> in the run <p>, each `{ c, cibles }`: `cibles`
378
433
  // the test targets named, empty for the whole crate of the day (its night tests and its benches
379
434
  // left out). For a crate that plays tests:
380
435
  // the build of its test targets first, then nextest, then its doctests; a failed build leaves the
381
436
  // crate's other tasks not played. The benches named, each crate's in a task `budget`, are
382
437
  // planned with the rest and played by the function this one returns, after the other tests.
383
- function jouerLesTests(racine, p, choix, options, temporaire = () => ({})) {
438
+ // In a tranche <tranche>, nextest plays its part (`partitionDeNextest`); the doctests and the
439
+ // benches, which nextest does not split, play in the first tranche alone.
440
+ function jouerLesTests(racine, p, choix, options, temporaire = () => ({}), tranche = null) {
384
441
  const m = metadonnees(racine);
385
442
  // Nextest's store is `target/nextest` under the workspace's root (its default `store.dir`),
386
443
  // whatever the target directory of the compilations (./sccache.mjs).
@@ -394,9 +451,12 @@ function jouerLesTests(racine, p, choix, options, temporaire = () => ({})) {
394
451
  // A bench plays on one thread (`--test-threads 1`, which `-j` of nextest is the alias of): it
395
452
  // takes the arguments without `-j`.
396
453
  const nextestDuBanc = [...nextest];
397
- nextest.push(...j);
454
+ nextest.push(...j, ...partitionDeNextest(tranche));
455
+ const indivisible = joueCeQuiNeSeDivisePas(tranche);
398
456
  const parCrate = [];
399
457
  const bancs = [];
458
+ // The test executables the builds of the run report, removed once its tests played.
459
+ const executables = [];
400
460
  for (const { c, cibles: nommees, jour } of choix) {
401
461
  // Targets named beside the day of the crate (`jour`, a unit test of `src/` named): the day
402
462
  // builds whole, and plays besides the targets named.
@@ -416,12 +476,13 @@ function jouerLesTests(racine, p, choix, options, temporaire = () => ({})) {
416
476
  const construction = [
417
477
  'test',
418
478
  '--no-run',
479
+ MESSAGES,
419
480
  ...j,
420
481
  '-p',
421
482
  nom,
422
483
  ...(avecLeJour ? [] : cibles.flatMap(n => ['--test', n])),
423
484
  ];
424
- prevues.push([p.prevoir(nom, d, 'build', false, construction), { journal }]);
485
+ prevues.push([p.prevoir(nom, d, 'build', false, construction), { journal, executables }]);
425
486
  if (cibles.length === 0 || autres.length || avecLeJour) {
426
487
  const duC = duJour(c);
427
488
  const nommes = autres.flatMap(n => ['--test', n]);
@@ -438,7 +499,7 @@ function jouerLesTests(racine, p, choix, options, temporaire = () => ({})) {
438
499
  { junit, temporaire: temporaire(nom) },
439
500
  ]);
440
501
  }
441
- if (desBancs.length) {
502
+ if (desBancs.length && indivisible) {
442
503
  const args = [...nextestDuBanc, '-p', nom, ...desBancs.flatMap(n => ['--test', n])];
443
504
  bancs.push({
444
505
  nom,
@@ -450,7 +511,7 @@ function jouerLesTests(racine, p, choix, options, temporaire = () => ({})) {
450
511
  }
451
512
  }
452
513
  const doctests = c.cibles.some(t => t.kind.includes('lib') && t.doctest !== false);
453
- if ((cibles.length === 0 || avecLeJour) && doctests) {
514
+ if ((cibles.length === 0 || avecLeJour) && doctests && indivisible) {
454
515
  const args = ['test', '--doc', ...j, '-p', nom];
455
516
  prevues.push([p.prevoir(nom, d, 'doctest', true, args), { temporaire: temporaire(nom) }]);
456
517
  }
@@ -475,6 +536,10 @@ function jouerLesTests(racine, p, choix, options, temporaire = () => ({})) {
475
536
  p.jouer(t, { junit, temporaire });
476
537
  }
477
538
  }
539
+ // The copy keeps no test executable between two passes: cargo builds again the one it misses.
540
+ for (const f of executables) {
541
+ rmSync(f, { force: true });
542
+ }
478
543
  };
479
544
  }
480
545
 
@@ -734,10 +799,6 @@ export function lancer(nom, args, { racine = process.cwd(), env = process.env }
734
799
  p.jouer(p.prevoir(RACINE, racine, 'check', false, ['check', '--all-targets']));
735
800
  return p.code();
736
801
  }
737
- if (nom === 'preparer') {
738
- p.jouer(p.prevoir(RACINE, racine, 'fetch', false, ['fetch', '--locked']));
739
- return p.code();
740
- }
741
802
  if (nom === 'verifier') {
742
803
  const dire = l => process.stdout.write(`${l}\n`);
743
804
  try {
@@ -830,7 +891,7 @@ function testsDuPaquet(racine, tous, args, env, parPaquet) {
830
891
  racine,
831
892
  abs
832
893
  )?.dossier ?? null;
833
- const { chemins, options } = cheminsDeLaTache({ racine, donnes, env, dossierDe });
894
+ const { chemins, options, tranche } = cheminsDeLaTache({ racine, donnes, env, dossierDe });
834
895
  const r = choisir(racine, tous, chemins);
835
896
  if (r.refus) {
836
897
  for (const l of r.refus) {
@@ -844,7 +905,8 @@ function testsDuPaquet(racine, tous, args, env, parPaquet) {
844
905
  p,
845
906
  r.choix,
846
907
  [...args.filter(a => a.startsWith('-')), ...options],
847
- parPaquet.temporaire
908
+ parPaquet.temporaire,
909
+ tranche
848
910
  )();
849
911
  restesParPaquet(p, r.choix, parPaquet);
850
912
  return p.code();
@@ -12,7 +12,7 @@
12
12
  // that changes `ws-core`, adds the crate `ws-neuf` and removes `ws-outil`: `lot`; the same, the
13
13
  // interface of `ws-core` then changed, its index late: `enRetard`.
14
14
  // - Each workspace commits its Cargo.lock, the one cargo writes (grillhouse-rph): the commands
15
- // tester, verifier and preparer refuse a workspace whose Cargo.lock git does not track.
15
+ // tester, verifier and tests-de-nuit refuse a workspace whose Cargo.lock git does not track.
16
16
  // - A crate at the root, its workspace `members = ["."]`, with its tests, as OSC Bridge: `seul`;
17
17
  // a crate at the root holding a second crate, `crates/aide`, none with tests: `imbrique`.
18
18
  // - A directory without Cargo.toml: `vide`.
@@ -316,7 +316,7 @@ export default {
316
316
  ],
317
317
  },
318
318
  commandes: {
319
- valide: ['tester', 'verifier', 'typer', 'preparer'],
319
+ valide: ['tester', 'verifier', 'typer', 'tests-de-nuit'],
320
320
  invalide: ['tester', 'deployer'],
321
321
  attendu: ['deployer : absente'],
322
322
  },