@roomi-fields/grillhouse 0.28.2 → 0.29.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 (71) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/bin/grillhouse.mjs +55 -14
  3. package/cadre/templates/projet/CLAUDE.md +1 -1
  4. package/cadre/templates/projet/README.md +11 -11
  5. package/cadre/templates/projet/_gitignore +2 -5
  6. package/charte.md +24 -3
  7. package/docs/ARCHITECTURE.md +279 -31
  8. package/docs/INTERFACE.md +59 -11
  9. package/package.json +1 -1
  10. package/scripts/aiguillage.mjs +324 -0
  11. package/scripts/avancement.mjs +33 -50
  12. package/scripts/circuit.mjs +558 -146
  13. package/scripts/composition-des-langages.mjs +16 -1
  14. package/scripts/conformite.mjs +16 -0
  15. package/scripts/copies-finies.mjs +181 -29
  16. package/scripts/demon.mjs +134 -21
  17. package/scripts/enveloppe/enveloppe.mjs +8 -5
  18. package/scripts/enveloppe/lancer.sh +24 -15
  19. package/scripts/enveloppe/travail-de-la-copie.mjs +94 -11
  20. package/scripts/etapes.mjs +1 -1
  21. package/scripts/fusion-du-changelog.mjs +0 -1
  22. package/scripts/grillhouse-maj.mjs +16 -7
  23. package/scripts/integration/file.mjs +3 -3
  24. package/scripts/integration/integrer.mjs +3 -3
  25. package/scripts/jointure.d.ts +53 -17
  26. package/scripts/langages/cargo/commandes.mjs +152 -25
  27. package/scripts/langages/cargo/composants.mjs +94 -2
  28. package/scripts/langages/cargo/exemples.mjs +68 -1
  29. package/scripts/langages/cargo/index.mjs +21 -10
  30. package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +35 -0
  31. package/scripts/langages/cargo/sccache.mjs +89 -6
  32. package/scripts/langages/cargo/squelette.mjs +72 -3
  33. package/scripts/langages/cargo/tailles-des-tests.mjs +195 -0
  34. package/scripts/langages/cargo/tests-de-head.mjs +159 -0
  35. package/scripts/langages/python/commandes.mjs +53 -9
  36. package/scripts/langages/python/composants.mjs +33 -3
  37. package/scripts/langages/python/exemples.mjs +19 -0
  38. package/scripts/langages/python/index.mjs +7 -2
  39. package/scripts/langages/python/squelette.mjs +119 -17
  40. package/scripts/langages/typescript/exemples.mjs +16 -0
  41. package/scripts/langages/typescript/index.mjs +6 -3
  42. package/scripts/langages/typescript/regle-des-tests.mjs +13 -0
  43. package/scripts/langages/typescript/squelette.mjs +18 -2
  44. package/scripts/langages/typescript/tests-de-nuit.mjs +50 -20
  45. package/scripts/langages/typescript/verifier.mjs +82 -288
  46. package/scripts/langages/typescript/vitest-config/base.mjs +8 -9
  47. package/scripts/langages/typescript/vitest-config/cibles.mjs +92 -53
  48. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +11 -5
  49. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +6 -1
  50. package/scripts/langages/typescript/vitest-config/mesure.mjs +3 -2
  51. package/scripts/langages/typescript/vitest.nuit.config.mjs +18 -13
  52. package/scripts/lecture-unique.mjs +51 -0
  53. package/scripts/mesure/base-de-passe.mjs +202 -9
  54. package/scripts/mesure/pression.mjs +9 -7
  55. package/scripts/nuit.sh +19 -12
  56. package/scripts/outil.mjs +72 -0
  57. package/scripts/paquet.mjs +39 -10
  58. package/scripts/resultats.mjs +22 -5
  59. package/scripts/services-du-noyau.mjs +16 -10
  60. package/scripts/session-start.sh +10 -1
  61. package/scripts/sortie.mjs +20 -1
  62. package/scripts/sources.mjs +3 -3
  63. package/scripts/sous-commandes.mjs +2 -0
  64. package/scripts/superviseur.mjs +369 -14
  65. package/scripts/tableau.mjs +219 -58
  66. package/scripts/verrou-de-machine.mjs +425 -37
  67. package/skills/developpeur/SKILL.md +11 -3
  68. package/skills/pitmaster/SKILL.md +64 -23
  69. package/skills/pitmaster/references/consigne-agent.md +4 -0
  70. package/skills/relecteur/SKILL.md +18 -6
  71. package/skills/testwriter/SKILL.md +11 -15
@@ -17,6 +17,23 @@
17
17
  // beside its copy, which no sweep touches); `integration`, the working directory of an
18
18
  // integration (scripts/integration/integrer.mjs); `enveloppe`, the throwaway state of a session's envelope
19
19
  // (scripts/enveloppe/enveloppe.mjs).
20
+ // - The owner of a base is the process that opens it, for a pass and a session out of a ticket
21
+ // (the night, a verification); a ticket (`ouvrirBaseDuTicket`: `<dans>/grillhouse-ticket-<id>/`,
22
+ // the temporary directory of the agents of one ticket, which the launcher gives each session of
23
+ // the ticket, scripts/enveloppe/lancer.sh, and `npx grillhouse temporaire <ticket>` the
24
+ // supervisor), kept from one session and one resumption to the next, removed when its ticket is
25
+ // closed (`balayerLesTickets`, which the removal of the finished copies plays,
26
+ // scripts/copies-finies.mjs), as a finished copy goes, and only then, frozen or not, as a
27
+ // retention policy fixed in advance; or a directory
28
+ // (`cacheDeLaRacine`: the cache of a build rooted in the temporary directory), swept once that
29
+ // directory is gone, from the namespace that opened it, or, from the host (the next base of a
30
+ // pass, out of an envelope, where the home is read-only), untouched for 7 days whatever its
31
+ // namespace, as GitHub Actions removes a cache unused for 7 days. What an agent needs to resume lives in its copy or its handover, never in
32
+ // the ticket's temporary directory alone, which holds what is made again.
33
+ // - The caches of compilation never lie in the temporary directory, a disk in memory that the
34
+ // sessions of the machine share: they go under `${XDG_CACHE_HOME:-~/.cache}/grillhouse/<outil>`
35
+ // (`cacheDeCompilation`), as Bazel keeps its output_base under ~/.cache; a build rooted in the
36
+ // temporary directory (a project of trial) keeps its outputs there too (`cacheDeLaRacine`).
20
37
  // - The base is removed at the end of the pass, green or red (`fermer`), and when the pass is
21
38
  // interrupted (SIGINT, SIGTERM, SIGHUP: `retirerALInterruption`), as pytest's `tmp_path` and
22
39
  // Rust's `tempfile` remove theirs.
@@ -29,17 +46,22 @@
29
46
  // namespace of the sweeper (an envelope has its own, bwrap --unshare-pid, where a number means
30
47
  // nothing outside): a base of another namespace, a base without a readable owner (one being
31
48
  // created) and a base whose owner lives are never touched.
49
+ import { createHash } from 'node:crypto';
32
50
  import {
51
+ existsSync,
33
52
  mkdirSync,
34
53
  mkdtempSync,
35
54
  readdirSync,
36
55
  readFileSync,
37
56
  readlinkSync,
38
57
  rmSync,
58
+ statSync,
59
+ utimesSync,
39
60
  writeFileSync,
40
61
  } from 'node:fs';
41
- import { tmpdir } from 'node:os';
62
+ import { homedir, tmpdir } from 'node:os';
42
63
  import path from 'node:path';
64
+ import { pathToFileURL } from 'node:url';
43
65
 
44
66
  // The prefix of a base's name, and the file of its owner.
45
67
  const PREFIXE = 'grillhouse-';
@@ -84,20 +106,31 @@ function espace() {
84
106
  }
85
107
  }
86
108
 
87
- // Whether the base <base> is an orphan: its owner reads, lives in this namespace, and is gone.
88
- function orpheline(base) {
89
- let p;
109
+ // The owner of the base <base>, or null when it does not read.
110
+ function proprietaire(base) {
90
111
  try {
91
- p = JSON.parse(readFileSync(path.join(base, PROPRIETAIRE), 'utf8'));
112
+ return JSON.parse(readFileSync(path.join(base, PROPRIETAIRE), 'utf8'));
92
113
  } catch {
93
- return false;
114
+ return null;
94
115
  }
116
+ }
117
+
118
+ // Whether the base <base> is an orphan: its owner, a directory or a process, belongs to this
119
+ // namespace of processes and is gone; a directory another namespace sees (an envelope's private
120
+ // /tmp) or a process of another namespace is never judged here. A ticket's base goes with its
121
+ // ticket (`balayerLesTickets`).
122
+ function orpheline(base) {
123
+ const p = proprietaire(base);
95
124
  const ici = espace();
96
- return ici !== null && p.espace === ici && Number.isInteger(p.pid) && !vivant(p.pid);
125
+ if (p === null || ici === null || p.espace !== ici) return false;
126
+ if (typeof p.racine === 'string') return !existsSync(p.racine);
127
+ return Number.isInteger(p.pid) && !vivant(p.pid);
97
128
  }
98
129
 
99
130
  // Removes every orphan base in <dans>.
100
- function balayer(dans) {
131
+ // <vieilles> true (on the host): a base of a cache of a root untouched for AGE_DU_CACHE_MS goes too,
132
+ // whatever namespace opened it.
133
+ function balayer(dans, { vieilles = false } = {}) {
101
134
  let noms;
102
135
  try {
103
136
  noms = readdirSync(dans);
@@ -106,10 +139,36 @@ function balayer(dans) {
106
139
  }
107
140
  for (const nom of noms) {
108
141
  const base = path.join(dans, nom);
109
- if (nom.startsWith(PREFIXE) && orpheline(base)) rmSync(base, { recursive: true, force: true });
142
+ if (nom.startsWith(PREFIXE) && (orpheline(base) || (vieilles && vieille(base))))
143
+ rmSync(base, { recursive: true, force: true });
144
+ }
145
+ }
146
+
147
+ /** How long a cache of a root lives untouched: 7 days, as GitHub Actions keeps a cache unused. */
148
+ export const AGE_DU_CACHE_MS = 7 * 24 * 3600 * 1000;
149
+
150
+ // Whether <base> is a base of a cache of a root untouched (its directory's mtime) for
151
+ // AGE_DU_CACHE_MS.
152
+ function vieille(base) {
153
+ if (typeof proprietaire(base)?.racine !== 'string') return false;
154
+ try {
155
+ return Date.now() - statSync(base).mtimeMs > AGE_DU_CACHE_MS;
156
+ } catch {
157
+ return false;
110
158
  }
111
159
  }
112
160
 
161
+ // Whether <env> is an agent's envelope, where the home is read-only (scripts/enveloppe/).
162
+ const enEnveloppe = env => Boolean(env.GRILLHOUSE_ENVELOPPE);
163
+
164
+ // The sweep of the caches of the roots under <env> (`cacheDeLaRacine`, in each tool's directory of
165
+ // the frame's caches), from the host only: the orphans and the old ones.
166
+ function balayerLesCaches(env) {
167
+ if (enEnveloppe(env)) return;
168
+ const racine = path.dirname(cacheDeCompilation('-', env));
169
+ for (const outil of contenu(racine)) balayer(path.join(racine, outil), { vieilles: true });
170
+ }
171
+
113
172
  // The variables that name the temporary directory: TMPDIR (POSIX, Node, Rust), TMP and TEMP
114
173
  // (Windows, Python's `tempfile`).
115
174
  const TEMPORAIRES = ['TMPDIR', 'TMP', 'TEMP'];
@@ -167,6 +226,7 @@ export function retirerALInterruption(retirer) {
167
226
  */
168
227
  export function ouvrirBase(genre, { dans = tmpdir() } = {}) {
169
228
  balayer(dans);
229
+ balayerLesCaches(process.env);
170
230
  mkdirSync(dans, { recursive: true });
171
231
  const base = mkdtempSync(path.join(dans, `${PREFIXE}${genre}-`));
172
232
  writeFileSync(
@@ -183,3 +243,136 @@ export function ouvrirBase(genre, { dans = tmpdir() } = {}) {
183
243
  fermer: () => rmSync(base, { recursive: true, force: true }),
184
244
  };
185
245
  }
246
+
247
+ // The prefix of the base of a ticket, and the form of a ticket's id.
248
+ const DU_TICKET = `${PREFIXE}ticket-`;
249
+ const ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
250
+
251
+ /**
252
+ * The base of the ticket <ticket> in <dans>: `<dans>/grillhouse-ticket-<ticket>/`, its owner the
253
+ * ticket, made when absent and the same at each call; the temporary directory of the agents of
254
+ * one ticket, kept from one session to the next, removed when it is closed (`balayerLesTickets`).
255
+ * @param {string} ticket the ticket's id
256
+ * @param {{ dans?: string }} options `dans`, the directory of the base (`os.tmpdir()`)
257
+ * @returns {{ base: string, dossier: string }} the base, and the directory its agents write in
258
+ */
259
+ export function ouvrirBaseDuTicket(ticket, { dans = tmpdir() } = {}) {
260
+ if (!ID.test(ticket)) throw new Error(`⛔ « ${ticket} » n'est pas l'identifiant d'un ticket.`);
261
+ const base = path.join(dans, `${DU_TICKET}${ticket}`);
262
+ const dossier = path.join(base, 't');
263
+ mkdirSync(dossier, { recursive: true });
264
+ if (proprietaire(base) === null) {
265
+ writeFileSync(path.join(base, PROPRIETAIRE), `${JSON.stringify({ ticket })}\n`);
266
+ }
267
+ return { base, dossier };
268
+ }
269
+
270
+ /**
271
+ * Removes from <dans> the base of each ticket that is closed; the ids of the tickets whose base
272
+ * went. A ticket open, frozen or not, keeps its base, as a retention policy fixed in advance.
273
+ * <fermes> reads the closed tickets, null when they do not read: called once, and only when a
274
+ * ticket's base is there.
275
+ * @param {() => Set<string> | null} fermes
276
+ * @param {{ dans?: string }} options `dans`, the directory of the bases (`os.tmpdir()`)
277
+ * @returns {string[]}
278
+ */
279
+ export function balayerLesTickets(fermes, { dans = tmpdir() } = {}) {
280
+ const tickets = contenu(dans)
281
+ .filter(n => n.startsWith(DU_TICKET))
282
+ .map(n => ({ base: path.join(dans, n), ticket: proprietaire(path.join(dans, n))?.ticket }))
283
+ .filter(b => typeof b.ticket === 'string');
284
+ if (tickets.length === 0) return [];
285
+ const clos = fermes();
286
+ if (clos === null) return [];
287
+ const retires = tickets.filter(b => clos.has(b.ticket));
288
+ for (const b of retires) rmSync(b.base, { recursive: true, force: true });
289
+ return retires.map(b => b.ticket);
290
+ }
291
+
292
+ /**
293
+ * The ticket whose base is the entry <nom> of the temporary directory, or null.
294
+ * @param {string} nom
295
+ */
296
+ export function ticketDeLaBase(nom) {
297
+ return nom.startsWith(DU_TICKET) ? nom.slice(DU_TICKET.length) : null;
298
+ }
299
+
300
+ // Whether <chemin> lies in <dossier> or is it.
301
+ const sous = (chemin, dossier) => {
302
+ const rel = path.relative(dossier, chemin);
303
+ return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
304
+ };
305
+
306
+ // The temporary directories under <env>: the one it names, the system's, and /tmp.
307
+ const temporaires = env =>
308
+ [env.TMPDIR || env.TMP || env.TEMP, tmpdir(), '/tmp'].filter(Boolean).map(d => path.resolve(d));
309
+
310
+ /**
311
+ * Whether <chemin> lies in a temporary directory under <env> (`TMPDIR`, `os.tmpdir()`, `/tmp`).
312
+ * @param {string} chemin
313
+ * @param {Record<string, string | undefined>} [env]
314
+ */
315
+ export function dansLeTemporaire(chemin, env = process.env) {
316
+ return temporaires(env).some(t => sous(path.resolve(chemin), t));
317
+ }
318
+
319
+ /**
320
+ * The cache of compilation of <outil> under <env>: `${XDG_CACHE_HOME:-$HOME/.cache}/grillhouse/
321
+ * <outil>`, as the lock of the machine lives there (scripts/verrou-de-machine.mjs).
322
+ * @param {string} outil `sccache`, `uv`, `cargo`…
323
+ * @param {Record<string, string | undefined>} [env]
324
+ */
325
+ export function cacheDeCompilation(outil, env = process.env) {
326
+ const cache = env.XDG_CACHE_HOME || path.join(env.HOME || homedir(), '.cache');
327
+ return path.join(path.resolve(cache), 'grillhouse', outil);
328
+ }
329
+
330
+ /**
331
+ * The cache of <outil> for the build rooted at <racine>: `<cacheDeCompilation(outil)>/
332
+ * grillhouse-<empreinte of racine>/`, its owner <racine> and the namespace of processes that
333
+ * opened it, made when absent; the caches of the roots that this namespace sees gone are swept
334
+ * first, and from the host the ones untouched for 7 days, whatever their namespace (`AGE_DU_CACHE_MS`,
335
+ * as GitHub Actions and cargo-sweep); each use renews its age. With `creer` false, its path alone, nothing made nor swept (a reading, `cargo metadata`).
336
+ * @param {string} outil
337
+ * @param {string} racine
338
+ * @param {Record<string, string | undefined>} [env]
339
+ */
340
+ export function cacheDeLaRacine(outil, racine, env = process.env, { creer = true } = {}) {
341
+ const dans = cacheDeCompilation(outil, env);
342
+ const reelle = path.resolve(racine);
343
+ const empreinte = createHash('sha256').update(reelle).digest('hex').slice(0, 16);
344
+ const cache = path.join(dans, `${PREFIXE}${empreinte}`);
345
+ if (!creer) return cache;
346
+ if (enEnveloppe(env)) balayer(dans);
347
+ else balayerLesCaches(env);
348
+ mkdirSync(cache, { recursive: true });
349
+ // A use renews it: its age counts from the last.
350
+ const maintenant = new Date();
351
+ utimesSync(cache, maintenant, maintenant);
352
+ if (proprietaire(cache) === null) {
353
+ writeFileSync(
354
+ path.join(cache, PROPRIETAIRE),
355
+ `${JSON.stringify({ racine: reelle, espace: espace() })}\n`
356
+ );
357
+ }
358
+ return cache;
359
+ }
360
+
361
+ // `npx grillhouse temporaire <ticket>`: prints the directory of the ticket's agents.
362
+ function commande(argv) {
363
+ if (argv.length !== 1 || argv[0].startsWith('-')) {
364
+ process.stderr.write('usage: npx grillhouse temporaire <ticket>\n');
365
+ return 2;
366
+ }
367
+ try {
368
+ process.stdout.write(`${ouvrirBaseDuTicket(argv[0]).dossier}\n`);
369
+ return 0;
370
+ } catch (e) {
371
+ process.stderr.write(`${e.message}\n`);
372
+ return 2;
373
+ }
374
+ }
375
+
376
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
377
+ process.exitCode = commande(process.argv.slice(2));
378
+ }
@@ -1,7 +1,8 @@
1
- // The CPU pressure of the machine, the witness of rest for every measure of time: a time witness
2
- // is measured with the CPU at rest, and a failure that depends on a duration under load is played
3
- // again at rest (« à repasser »), never taken as a red nor as a green. The model is Bazel's
4
- // TIMEOUT/FLAKY and CTest's `--repeat after-timeout`: classify, then play again.
1
+ // The CPU pressure of the machine, the witness of rest for every measure of time, which plays at
2
+ // night (grillhouse-bd7): a measure is taken with the CPU at rest, and a failure that depends on a
3
+ // duration under load is played again at rest (« à repasser »), never taken as a red nor as a
4
+ // green. The model is Bazel's TIMEOUT/FLAKY and CTest's `--repeat after-timeout`: classify, then
5
+ // play again.
5
6
  //
6
7
  // - The signal is the kernel's pressure stall information, `/proc/pressure/cpu`, line `some`,
7
8
  // field `avg10`: the share of the last ten seconds in which a task waited for a CPU, in %.
@@ -10,9 +11,10 @@
10
11
  // - A file that does not read (no pressure stall information on the machine) gives null: whoever
11
12
  // reads it says « pression illisible » and leaves the verdict to the runner of the tests.
12
13
  // - A_REPASSER, 75, is the exit code of « à repasser » (EX_TEMPFAIL of sysexits.h: try again
13
- // later), neither green nor red: the duration reporter of the module of the language gives it
14
- // (scripts/langages/typescript/vitest-config/duree.reporter.mjs), `npm run verifier` reads it (scripts/langages/typescript/verifier.mjs),
15
- // and so do the integration, the queue and the night.
14
+ // later), neither green nor red: the measure of time of each module of language gives it
15
+ // (scripts/langages/typescript/vitest-config/duree.reporter.mjs, the benches of the module cargo),
16
+ // and the night reads it (scripts/nuit.sh). The day waits for no rest: `npm run verifier` takes a
17
+ // task at 75 for a red (scripts/langages/typescript/verifier.mjs).
16
18
  //
17
19
  // npx grillhouse pression attendre
18
20
  //
package/scripts/nuit.sh CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  # The night: once a day, the full pass played for real, then what the day never plays: the night
3
- # tests and the time budget benches. During the day `npm run verifier` (the integration's) plays
3
+ # tests and the measures of time (the time budget benches and the time witnesses). During the day `npm run verifier` (the integration's) plays
4
4
  # what the changes since the last green touch (scripts/integration/integrer.mjs,
5
5
  # scripts/dernier-vert.mjs); the module of the project's language plays each step
6
6
  # (scripts/jointure.d.ts).
@@ -23,8 +23,9 @@
23
23
  # becomes the last green of the day's passes.
24
24
  # Its three steps (the full pass, the night tests, the project's night script) each play even
25
25
  # when one before is red, as a CI plays its independent jobs; the night is red when one of them
26
- # is. A full pass « à repasser » (75: a failure of duration under load, which found no rest in
27
- # its bound) ends the night there, « à repasser », below.
26
+ # is. A full pass « à repasser » (75: the wait for the machine reached its bound; the pass plays
27
+ # no measure of time, and a delay past is a red there) ends the night there, « à repasser »,
28
+ # below.
28
29
  # An existing copy that does not get ready (its move onto HEAD, its cleaning or the setting of
29
30
  # its submodules fails) is removed by `scripts/retirer-copie.sh --jetable` (local work does not
30
31
  # hold it, a lock does) and created again, once; a copy that does not get ready the second time
@@ -38,10 +39,13 @@
38
39
  # (scripts/outils-cles.mjs) gives each command of the project its variables, each set to its
39
40
  # path, whatever the environment of the night's launcher; a faulty key turns the night red, the
40
41
  # log naming it, and nothing runs.
41
- # - The night tests: after the full pass, the night tests and the time budget benches, which
42
- # `npm test` and the integration leave out, played by the command `tests-de-nuit` of the module
43
- # of the copy's language (the module typescript's: the files `*.nuit.test.*`, `*.nuit.spec.*`,
44
- # `*.budget.test.*` and `*.budget.spec.*`, by Vitest), when the project declares a language
42
+ # - The night tests: after the full pass, the night tests, then the measures of time alone (the
43
+ # time budget benches and the time witnesses), which `npm test` and the integration leave out
44
+ # (grillhouse-bd7), played by the command `tests-de-nuit` of the module of the copy's language
45
+ # (the module typescript's: the files `*.nuit.test.*` and `*.nuit.spec.*`, then the files
46
+ # `*.budget.test.*`, `*.budget.spec.*` and those that import `mesurerAuRepos`, one at a time, by
47
+ # Vitest; the module python's, `*_nuit_test.py`; the module cargo's, the test targets
48
+ # `tests/*_nuit.rs` then the benches `tests/*_budget.rs`, by nextest), when the project declares a language
45
49
  # whose module describes it (scripts/commande-du-langage.mjs); none otherwise. A red turns the night red, with a log line that
46
50
  # says so, and the project's night script still plays. A run « à repasser » (75: every failure
47
51
  # depended on a duration, one under load) waits for rest (`npx grillhouse pression attendre`,
@@ -75,8 +79,11 @@
75
79
  # refused (commits or work not entered, a lock) or held by a running circuit (its ticket in progress, its
76
80
  # `<copie>.travail`, the lock of the integration or of the queue) stays, its log line naming
77
81
  # why and the place it holds, a kept copy whose ticket is closed losing what the tools of its
78
- # languages wrote there. The removal never changes the night's verdict; the end of each
79
- # circuit runs it too (scripts/circuit.mjs).
82
+ # languages wrote there. The night names its own copy to the removal, its steps played: the copy
83
+ # stays, and loses what the tools of its languages wrote there (`target`, `.turbo`), its
84
+ # `node_modules` kept, which its next preparation would remove anyway (grillhouse-k5y). The
85
+ # removal never changes the night's verdict; the end of each circuit runs it too
86
+ # (scripts/circuit.mjs), the night's copy untouched.
80
87
  # - It takes no lock of the integration or of the queue (scripts/integration/file.mjs): an
81
88
  # integration and the queue run during the night, each in its own copy.
82
89
  # - Its log is <git common dir>/nuit/<date>.log. Green: HEAD becomes the last green commit
@@ -229,7 +236,7 @@ jouer() {
229
236
  GRILLHOUSE_ROUGES="$rouges" monter npm --prefix "$copie" run verifier -- --force
230
237
  code=$?
231
238
  if [ "$code" -eq 75 ]; then
232
- echo "⏱ la passe complète est à repasser (code 75) : un échec de durée sous charge, sans repos dans la borne."
239
+ echo "⏱ la passe complète est à repasser (code 75) : l'attente de la machine a atteint sa borne."
233
240
  return 75
234
241
  fi
235
242
  if [ "$code" -ne 0 ]; then
@@ -287,8 +294,8 @@ fin() {
287
294
  }
288
295
  jouer >> "$journal" 2>&1
289
296
  verdict=$?
290
- # The copies whose content is on main go once the steps are played, the night's own kept; their
291
- # removal never changes the verdict.
297
+ # The copies whose content is on main go once the steps are played, the night's own kept and
298
+ # pruned of its tools' outputs; their removal never changes the verdict.
292
299
  (cd "$racine" && node "$ici/copies-finies.mjs" "$copie") >> "$journal" 2>&1 || true
293
300
 
294
301
  if [ "$verdict" -eq 75 ]; then
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ // The installation of the published version that leads the frame's repository
3
+ // (scripts/aiguillage.mjs, the key `grillhouse.outil`, the cache, the switch).
4
+ //
5
+ // npx grillhouse outil installs the version the key names, nothing when it is there
6
+ // npx grillhouse outil <x.y.z> writes the key, then installs that version
7
+ //
8
+ // - The key is written in the package.json of the working directory, its other fields and its
9
+ // indentation kept; a version is installed under ~/.cache/grillhouse/outil/<version>/.
10
+ // - Without the key and without a version, the command says so, exit 2; a faulty key or argument
11
+ // too; a failed installation, exit 1. Changing the published version is this one gesture, which
12
+ // the release proposes (`grillhouse sortie --etiqueter`).
13
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
14
+ import path from 'node:path';
15
+ import { pathToFileURL } from 'node:url';
16
+ import { CLE, installer, NOM_DU_PAQUET, versionDeLOutil, X_Y_Z } from './aiguillage.mjs';
17
+
18
+ // Writes <version> as the key of the package.json at <racine>, its other fields and its
19
+ // indentation kept.
20
+ function ecrireLaCle(racine, version) {
21
+ const f = path.join(racine, 'package.json');
22
+ const texte = readFileSync(f, 'utf8');
23
+ const pkg = JSON.parse(texte);
24
+ pkg.grillhouse = { ...(pkg.grillhouse ?? {}), outil: version };
25
+ const retrait = /^\{\n([ \t]+)/.exec(texte)?.[1] ?? ' ';
26
+ writeFileSync(f, `${JSON.stringify(pkg, null, retrait)}\n`);
27
+ }
28
+
29
+ const USAGE = 'Usage : npx grillhouse outil [<x.y.z>]\n';
30
+
31
+ // The version to install in <racine>: <args>[0] written as the key, else the key's; the exit code
32
+ // 2 and its message for a faulty argument or key, or a key absent.
33
+ function versionAInstaller(racine, args) {
34
+ if (args.length > 1 || (args[0] !== undefined && !X_Y_Z.test(args[0]))) {
35
+ return { refus: USAGE };
36
+ }
37
+ if (!existsSync(path.join(racine, 'package.json'))) {
38
+ return {
39
+ refus: `⛔ grillhouse outil : aucun package.json dans ${racine} ; la clé ${CLE} s'écrit au package.json racine du dépôt.\n`,
40
+ };
41
+ }
42
+ if (args[0] !== undefined) ecrireLaCle(racine, args[0]);
43
+ try {
44
+ const version = versionDeLOutil(racine);
45
+ return version === null
46
+ ? {
47
+ refus: `⛔ la clé ${CLE} manque au package.json : \`npx grillhouse outil <x.y.z>\` l'écrit et installe la version.\n`,
48
+ }
49
+ : { version };
50
+ } catch (e) {
51
+ return { refus: `⛔ grillhouse outil : ${e.message}\n` };
52
+ }
53
+ }
54
+
55
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
56
+ const { version, refus } = versionAInstaller(process.cwd(), process.argv.slice(2));
57
+ if (refus) {
58
+ process.stderr.write(refus);
59
+ process.exitCode = 2;
60
+ } else {
61
+ try {
62
+ // Asked by hand: a failure kept by a launch does not stop it.
63
+ const r = installer(version, { retenue: 0 });
64
+ process.stdout.write(
65
+ `✓ ${NOM_DU_PAQUET}@${version} ${r.installe ? 'installé' : 'déjà installé'} sous ${r.dossier}.\n`
66
+ );
67
+ } catch (e) {
68
+ process.stderr.write(`⛔ grillhouse outil : ${e.message}\n`);
69
+ process.exitCode = 1;
70
+ }
71
+ }
72
+ }
@@ -15,7 +15,9 @@
15
15
  // names; a row whose cell of the column « Langage » is empty; a language out of the frame's
16
16
  // list; a folder that already holds the manifest of its language (`manifeste` of its module). A
17
17
  // folder that holds docs/ alone, the documents of the second time, is accepted, as `cargo init`
18
- // takes a folder without its Cargo.toml.
18
+ // takes a folder without its Cargo.toml; a folder that already holds code is given to the
19
+ // module with its files (`existants`), which takes them as they are, or refuses, by its name,
20
+ // what it cannot take.
19
21
  // - The skeleton: the module of the row's language gives the files of the package and the entry
20
22
  // of the workspace (`squelette`, scripts/jointure.d.ts), the versions of its tools from its
21
23
  // template (`miseAJour.gabarit`); the documents of the package, docs/CADRE.md and
@@ -26,15 +28,15 @@
26
28
  // - The tools of the language, as `nx add` installs them before the first generator: the share
27
29
  // of the update of each declared language (`mettreAJour` of ./grillhouse-maj.mjs: its tools at
28
30
  // its template's versions, its scripts, its files, `turbo.json` for typescript), then `npm
29
- // install` when the update asks it, the module's command that locks the versions of the new
30
- // package (`verrouiller`), the binaries of the declared languages (`installerBinaires`), and the
31
+ // install` when the update asks it, the module's commands that lock the versions of the new
32
+ // package (`verrouiller`), in their order, the binaries of the declared languages (`installerBinaires`), and the
31
33
  // generators (`regenerer`), those of the package's language whatever files the project holds:
32
34
  // the first package of a language receives its boundaries' configuration and its index.
33
35
  // - The report: each file written, then the lines of the update; on the error stream, each
34
36
  // command that fails, named with its output. The exit code: 0; 1 for a refusal (⛔ and its
35
37
  // reason) or a command that fails; 2 for the usage.
36
38
  import { spawnSync } from 'node:child_process';
37
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
39
+ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
38
40
  import path from 'node:path';
39
41
  import { pathToFileURL } from 'node:url';
40
42
  import { CADRE } from './cadre.mjs';
@@ -46,6 +48,7 @@ import {
46
48
  regenerer,
47
49
  } from './grillhouse-maj.mjs';
48
50
  import { LANGAGES, langage } from './langages.mjs';
51
+ import { hors } from './sources.mjs';
49
52
  import {
50
53
  ARCHITECTURE,
51
54
  colonneDesNoms,
@@ -100,13 +103,34 @@ export function ligneDuPaquet(racine, rel) {
100
103
 
101
104
  const lireJson = f => (existsSync(f) ? JSON.parse(readFileSync(f, 'utf8')) : {});
102
105
 
106
+ // The files the folder <dossier> of the project at <racine> already holds, from it, in the order of
107
+ // their path: its docs/ (the documents of the second time), its hidden entries and the folders the
108
+ // sources of the project leave out (`hors` of ./sources.mjs: the frame's, node_modules and dist,
109
+ // and what the tools of its languages write, cargo's target, Python's .venv and
110
+ // __pycache__) left out.
111
+ function existants(racine, dossier) {
112
+ const exclus = hors(racine);
113
+ if (!existsSync(dossier)) {
114
+ return [];
115
+ }
116
+ return readdirSync(dossier, { recursive: true, withFileTypes: true })
117
+ .filter(e => e.isFile())
118
+ .map(e => path.relative(dossier, path.join(e.parentPath, e.name)).split(path.sep).join('/'))
119
+ .filter(
120
+ f => !f.startsWith('docs/') && !f.split('/').some(p => p.startsWith('.') || exclus.has(p))
121
+ )
122
+ .sort();
123
+ }
124
+
103
125
  /**
104
126
  * The plan of the package at <chemin> of the project at <racine>, nothing written: `{ chemin,
105
127
  * langage, fichiers, espace, verrouiller }`, `fichiers` the skeleton of its language and its
106
128
  * documents (path from the root → text), `espace` the manifest of the workspace with its entry
107
- * (null when it holds it), `verrouiller` the command that locks its versions. Throws a Refus, by
108
- * its name, for a path no row names, a row without language, a language out of the frame's list,
109
- * or a folder that holds the manifest of its language.
129
+ * (null when it holds it), `verrouiller` the commands that lock its versions, played in their
130
+ * order. Throws a Refus, by its name, for a path no row names, a row without language, a language
131
+ * out of the frame's list, a folder that holds the manifest of its language, and a folder whose
132
+ * code the module cannot take (a manifest of Python it does not read, Rust or TypeScript out of
133
+ * its layout), what is missing named.
110
134
  * @param {string} racine the root of the project
111
135
  * @param {string} chemin the package's folder, from the root
112
136
  * @param {{ source?: string }} [o] the frame's files (CADRE)
@@ -139,7 +163,11 @@ export function planDuPaquet(racine, chemin, { source = CADRE } = {}) {
139
163
  const modele = lireJson(path.join(source, m.miseAJour.gabarit, 'package.json'));
140
164
  let s;
141
165
  try {
142
- s = m.squelette(racine, { chemin: rel, modele });
166
+ s = m.squelette(racine, {
167
+ chemin: rel,
168
+ modele,
169
+ existants: existants(racine, path.join(racine, rel)),
170
+ });
143
171
  } catch (e) {
144
172
  throw new Refus(e.message);
145
173
  }
@@ -219,8 +247,9 @@ export function creerPaquet(racine, chemin, { source = CADRE, executer = lancer
219
247
  if (aInstaller(b)) {
220
248
  jouer('npm', ['install'], '.');
221
249
  }
222
- const v = plan.verrouiller;
223
- jouer(v.commande, v.args, v.dossier);
250
+ for (const v of plan.verrouiller) {
251
+ jouer(v.commande, v.args, v.dossier);
252
+ }
224
253
  const binaires = installerBinaires(racine);
225
254
  echecs.push(...binaires.lignes, ...regenerer(racine, { langage: plan.langage.nom }));
226
255
  const lignes = rapport(b)
@@ -51,10 +51,11 @@
51
51
  // and the circuit refuses a sheet without a line for each element, or with a line on an
52
52
  // element out of the list, a file the lot changes named alone or as `<fichier>#<nom>`
53
53
  // (`conformiteDuLot`) (reviewer);
54
- // - `suivi` (`titre`, `etat` levé or non levé, `preuve`): after a review sent back, each finding
55
- // before it judged on the difference of the lot, by its title (its number « Constat N — »
56
- // recognised, `cleDuConstat`), which the circuit writes at the ticket with the verdict, for
57
- // the human (reviewer);
54
+ // - `suivi` (`titre`, `etat` levé or non levé, `preuve`): each finding still open judged on the
55
+ // lot, bounded or whole, by its title (its number « Constat N — » recognised, `cleDuConstat`),
56
+ // which the circuit writes at the ticket with the verdict, for the human; the circuit refuses
57
+ // a sheet without a line for one, or an ACCEPTÉ that holds one not lifted
58
+ // (`suiviDesConstats`) (reviewer);
58
59
  // - `question`, with its `piece` (reviewer): what goes up to the owner, a real word of the
59
60
  // language written in the code; the circuit stops at « besoin » before it commits or
60
61
  // relaunches anyone;
@@ -425,7 +426,7 @@ const FICHES = {
425
426
  },
426
427
  ['titre', 'etat']
427
428
  ),
428
- 'Relecture bornée : chaque constat de la relecture d’avant, levé ou non.'
429
+ 'Chaque constat encore ouvert, levé ou non, en relecture bornée comme entière.'
429
430
  ),
430
431
  question: texte(
431
432
  'Ce qui revient au responsable (par exemple un vrai mot du langage écrit en dur) : la question et ta recommandation ; le circuit s’arrête avant de commiter ou de relancer.'
@@ -618,6 +619,22 @@ export function reponsesAuxConstats(fiche, titres) {
618
619
  return `reponses : sans réponse ${sans.length > 1 ? 'aux constats' : 'au constat'} ${sans.join(', ')}`;
619
620
  }
620
621
 
622
+ // What makes the reviewer's sheet <fiche> out of conformity with the findings still open (their
623
+ // <titres>), as Gerrit carries each unresolved comment to the next patch set whatever the form of
624
+ // the review: a finding without its line in `suivi` (by its title, numbered or not), or an ACCEPTÉ
625
+ // that holds one not lifted. The fault, or null.
626
+ export function suiviDesConstats(fiche, titres) {
627
+ const etats = new Map((fiche.suivi ?? []).map(s => [cleDuConstat(s.titre), s.etat]));
628
+ const liste = l => l.map(t => `« ${t} »`).join(', ');
629
+ const sans = titres.filter(t => !etats.has(t));
630
+ if (sans.length) {
631
+ return `suivi : sans ligne pour ${sans.length > 1 ? 'les constats' : 'le constat'} ${liste(sans)}`;
632
+ }
633
+ const tenus = fiche.verdict === 'ACCEPTÉ' ? titres.filter(t => etats.get(t) !== 'levé') : [];
634
+ if (!tenus.length) return null;
635
+ return `suivi : un ACCEPTÉ tient ${tenus.length > 1 ? 'les constats' : 'le constat'} ${liste(tenus)} non levé${tenus.length > 1 ? 's' : ''}`;
636
+ }
637
+
621
638
  // What makes the sheet of the tri <fiche> out of conformity with the discoveries <decouvertes> of
622
639
  // the ticket (their ids), as a reviewer gives a line to each element of its lot: a discovery
623
640
  // without its line, a line on an id out of the list, a discovery with two lines. The fault, or
@@ -13,18 +13,24 @@ export * from './langages.mjs';
13
13
  // pass and its measure, the base of a pass, the pressure of the machine and its lock, the last
14
14
  // green, the arbitrages of a ticket, the source files of a project.
15
15
  export { arbitrageTranche, estArbitrage } from './arbitrages.mjs';
16
- export { ecrireLaMesure, garderLeTotal, inscrireLePlan, ouvrirAvancement } from './avancement.mjs';
16
+ export { garderLeTotal, inscrireLePlan, ouvrirAvancement } from './avancement.mjs';
17
17
  export { sources } from './sources.mjs';
18
+ export { luUneFois } from './lecture-unique.mjs';
18
19
  export { CHANGEMENTS, DEPUIS_LE_VERT, garderLeVert, mesure } from './dernier-vert.mjs';
19
20
  export { lireLaListe, paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
20
21
  export { AVANCEMENT, ecrireTache } from './mesure/avancement.mjs';
21
- export { ligneDesRestes, ouvrirBase, retirerALInterruption } from './mesure/base-de-passe.mjs';
22
22
  export {
23
- A_REPASSER,
24
- attendreLeRepos,
25
- BORNE_ATTENTE_MS,
26
- ecrirePression,
27
- lirePression,
28
- SEUIL_PRESSION,
29
- } from './mesure/pression.mjs';
30
- export { AttenteDeLaMachine, avecLaMachine } from './verrou-de-machine.mjs';
23
+ cacheDeCompilation,
24
+ cacheDeLaRacine,
25
+ dansLeTemporaire,
26
+ ligneDesRestes,
27
+ ouvrirBase,
28
+ retirerALInterruption,
29
+ } from './mesure/base-de-passe.mjs';
30
+ export { A_REPASSER, ecrirePression, lirePression, SEUIL_PRESSION } from './mesure/pression.mjs';
31
+ export {
32
+ attendreDeLaPlace,
33
+ AttenteDeLaMachine,
34
+ avecLaMachine,
35
+ nommerLAvancement,
36
+ } from './verrou-de-machine.mjs';
@@ -28,7 +28,11 @@
28
28
  # one version, with the command that aligns the one behind. An agent's copy does not read them.
29
29
  #
30
30
  # One supervisor per project (scripts/superviseur.mjs): the session takes the lock of its
31
- # repository; a second session, while the first one lives, receives first the section « Un autre
31
+ # repository, and, when its opening takes the lock (not when it keeps it, after a compaction or a
32
+ # /clear), receives the section « L'attente des questions », the wait to launch in the background,
33
+ # then « Les circuits du dépôt » when there are some: each circuit that runs, each one stopped on a
34
+ # question with its question and the command that answers it, each one dead without a final state
35
+ # with the command that resumes it; a second session, while the first one lives, receives first the section « Un autre
32
36
  # superviseur tient ce dépôt », which asks it to say so to the owner and to launch no circuit. An
33
37
  # agent's copy and a session of a role the circuit launches take nothing and receive nothing.
34
38
  #
@@ -56,6 +60,11 @@ fi
56
60
  # One supervisor per project: the lock of the repository, or the section that says who holds it.
57
61
  superviseur="$(node "$ici/superviseur.mjs" "$root" 2>/dev/null)"
58
62
  [ -z "$superviseur" ] || echo "$superviseur"
63
+ # The published version that leads the repository (grillhouse.outil), when it cannot be installed:
64
+ # the orchestration runs on the code of the repository, which the session is told
65
+ # (scripts/aiguillage.mjs).
66
+ outil="$(node "$ici/aiguillage.mjs" --echec "$root" 2>/dev/null)"
67
+ [ -z "$outil" ] || echo "$outil"
59
68
 
60
69
  missing=()
61
70