@roomi-fields/grillhouse 0.47.1 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +48 -0
  3. package/cadre/templates/projet/.github/workflows/ci.yml +18 -38
  4. package/cadre/templates/projet/.github/workflows/machine-vierge.yml +5 -0
  5. package/cadre/templates/projet/.github/workflows/nuit.yml +5 -0
  6. package/cadre/templates/projet/CLAUDE.md +23 -6
  7. package/charte.md +9 -2
  8. package/dist/temporal/circuit/commande.js +5 -3
  9. package/dist/temporal/circuit/commande.js.map +1 -1
  10. package/dist/temporal/commande.js +2 -13
  11. package/dist/temporal/commande.js.map +1 -1
  12. package/dist/temporal/deroules.d.ts +1 -1
  13. package/dist/temporal/deroules.js +2 -2
  14. package/dist/temporal/deroules.js.map +1 -1
  15. package/dist/temporal/file/activites.d.ts +1 -4
  16. package/dist/temporal/file/activites.js +13 -14
  17. package/dist/temporal/file/activites.js.map +1 -1
  18. package/dist/temporal/file/contrat.d.ts +20 -91
  19. package/dist/temporal/file/contrat.js +7 -3
  20. package/dist/temporal/file/contrat.js.map +1 -1
  21. package/dist/temporal/file/deroule.d.ts +1 -9
  22. package/dist/temporal/file/deroule.js +54 -163
  23. package/dist/temporal/file/deroule.js.map +1 -1
  24. package/dist/temporal/installation.d.ts +26 -1
  25. package/dist/temporal/installation.js +111 -2
  26. package/dist/temporal/installation.js.map +1 -1
  27. package/dist/temporal/nuits/activites.d.ts +11 -2
  28. package/dist/temporal/nuits/activites.js +16 -5
  29. package/dist/temporal/nuits/activites.js.map +1 -1
  30. package/dist/temporal/nuits/choix.d.ts +15 -0
  31. package/dist/temporal/nuits/choix.js +20 -0
  32. package/dist/temporal/nuits/choix.js.map +1 -1
  33. package/dist/temporal/nuits/contrat.d.ts +16 -3
  34. package/dist/temporal/nuits/deroule.js +9 -2
  35. package/dist/temporal/nuits/deroule.js.map +1 -1
  36. package/dist/temporal/places/client.d.ts +13 -2
  37. package/dist/temporal/places/client.js +17 -2
  38. package/dist/temporal/places/client.js.map +1 -1
  39. package/dist/temporal/places/contrat.d.ts +41 -4
  40. package/dist/temporal/places/contrat.js +8 -0
  41. package/dist/temporal/places/contrat.js.map +1 -1
  42. package/dist/temporal/places/deroule.js +46 -6
  43. package/dist/temporal/places/deroule.js.map +1 -1
  44. package/docs/ARCHITECTURE.md +166 -41
  45. package/docs/INTERFACE.md +13 -3
  46. package/package.json +1 -1
  47. package/scripts/activites.mjs +48 -10
  48. package/scripts/aiguillage.mjs +1 -0
  49. package/scripts/attente-a-l-arret.mjs +2 -5
  50. package/scripts/attente-au-tour.mjs +2 -5
  51. package/scripts/branche-de-nuit.mjs +32 -44
  52. package/scripts/ci-de-main.mjs +215 -16
  53. package/scripts/circuit.mjs +45 -33
  54. package/scripts/composition-des-langages.mjs +2 -0
  55. package/scripts/crochets.mjs +2 -2
  56. package/scripts/effets.mjs +2 -1
  57. package/scripts/enveloppe/enveloppe.mjs +61 -6
  58. package/scripts/enveloppe/travail-de-la-copie.mjs +2 -0
  59. package/scripts/etapes.mjs +11 -1
  60. package/scripts/etat-du-depot.mjs +23 -0
  61. package/scripts/faits-du-circuit.mjs +12 -23
  62. package/scripts/fermeture-de-la-machine.d.mts +27 -0
  63. package/scripts/fermeture-de-la-machine.mjs +108 -0
  64. package/scripts/greffons.mjs +1 -1
  65. package/scripts/integration/file.mjs +16 -13
  66. package/scripts/integration/integrer.mjs +2 -0
  67. package/scripts/jointure.d.ts +5 -0
  68. package/scripts/langages/c/index.mjs +2 -0
  69. package/scripts/langages/c/squelette.mjs +1 -1
  70. package/scripts/langages/cargo/index.mjs +2 -0
  71. package/scripts/langages/python/index.mjs +2 -0
  72. package/scripts/langages/typescript/index.mjs +3 -0
  73. package/scripts/langages/typescript/module-absent.mjs +24 -0
  74. package/scripts/langages/typescript/turbo-des-paquets.mjs +19 -1
  75. package/scripts/langages/typescript/vitest-config/lances.mjs +3 -1
  76. package/scripts/langages.mjs +25 -3
  77. package/scripts/machine.mjs +103 -0
  78. package/scripts/matieres-cles.mjs +17 -0
  79. package/scripts/matieres-lues.mjs +104 -0
  80. package/scripts/migrations/0.48.0-ci-declenchee-par-la-file.mjs +32 -0
  81. package/scripts/migrations/0.48.0-poussee-retiree.mjs +31 -0
  82. package/scripts/migrations.mjs +4 -0
  83. package/scripts/nuit.sh +16 -44
  84. package/scripts/passe-de-la-machine.mjs +9 -7
  85. package/scripts/places-de-la-machine.mjs +74 -11
  86. package/scripts/places-du-serveur.mjs +29 -8
  87. package/scripts/poussee-retiree.mjs +18 -0
  88. package/scripts/registre.d.mts +2 -2
  89. package/scripts/regles-des-places.d.mts +36 -5
  90. package/scripts/regles-des-places.mjs +56 -9
  91. package/scripts/reponses-du-circuit.d.mts +2 -0
  92. package/scripts/reponses-du-circuit.mjs +26 -0
  93. package/scripts/resultats.mjs +40 -0
  94. package/scripts/sous-commandes.mjs +15 -2
  95. package/scripts/superviseur.mjs +64 -57
  96. package/scripts/tableau.mjs +132 -67
  97. package/scripts/transitions.d.mts +8 -0
  98. package/scripts/transitions.mjs +21 -3
  99. package/skills/pitmaster/SKILL.md +6 -3
  100. package/skills/relecteur/SKILL.md +3 -1
  101. package/scripts/poussee-cles.mjs +0 -46
@@ -0,0 +1,103 @@
1
+ // `grillhouse machine fermer [--attendre]` and `grillhouse machine rouvrir`: closes the machine to
2
+ // new work and reopens it, as `kubectl cordon` / `drain` / `uncordon` do for a node, so that the
3
+ // poste restarts without cutting a circuit in the middle of its work.
4
+ //
5
+ // - `fermer`: no place is given any more, to any project of the poste, and no ticket starts; each
6
+ // circuit alive finishes its step, then waits without starting the next. The command returns at
7
+ // once (as `cordon`), saying what still runs by project and by ticket, and « la machine est
8
+ // vide » when nothing plays; played again, it reads that state. With `--attendre` it returns
9
+ // only once the machine is empty (as `drain`): exit 0.
10
+ // - `rouvrir`: the circuits go on by themselves at the next step.
11
+ // - A night that holds the machine is never doubled nor lifted: the command says so (exit 0).
12
+ // - The closure lives in the state of the places on the Temporal server: it survives a restart of
13
+ // the poste, and no circuit starts again before the reopening.
14
+ import path from 'node:path';
15
+ import { setTimeout as dormirVraiment } from 'node:timers/promises';
16
+ import { direLaFermeture } from './fermeture-de-la-machine.mjs';
17
+ import {
18
+ dossierDesParts,
19
+ fermerLaMachine,
20
+ lireLesParts,
21
+ lirePlaces,
22
+ rouvrirLaMachine,
23
+ } from './places-de-la-machine.mjs';
24
+
25
+ const SONDE_MS = 2_000;
26
+
27
+ /**
28
+ * What the machine holds now: the sessions (places) and the passes (parts that hold their part),
29
+ * and the reservation in place.
30
+ * @param {Record<string, string | undefined>} env
31
+ */
32
+ export function lireLaMachine(env = process.env) {
33
+ const lues = lirePlaces({ env });
34
+ return {
35
+ prises: lues.prises ?? [],
36
+ parts: lireLesParts(dossierDesParts(env)).prises,
37
+ fermeture: lues.fermeture ?? null,
38
+ };
39
+ }
40
+
41
+ /**
42
+ * Plays the command <mode> (`fermer` or `rouvrir`) with its arguments <args>: its lines, one per
43
+ * call of <dire>; the exit code.
44
+ * @param {string | undefined} mode
45
+ * @param {string[]} args
46
+ * @param {{ env?: Record<string, string | undefined>, dire?: (l: string) => void,
47
+ * maintenant?: () => number,
48
+ * agir?: (mode: 'fermer' | 'rouvrir', o: { env: Record<string, string | undefined> }) => string,
49
+ * lire?: (env: Record<string, string | undefined>) => ReturnType<typeof lireLaMachine>,
50
+ * dormir?: (ms: number) => Promise<unknown> }} [o]
51
+ * @returns {Promise<number>}
52
+ */
53
+ export async function jouer(
54
+ mode,
55
+ args,
56
+ {
57
+ env = process.env,
58
+ dire = l => console.log(l),
59
+ maintenant = Date.now,
60
+ agir = (m, o) => (m === 'fermer' ? fermerLaMachine(o) : rouvrirLaMachine(o)),
61
+ lire = lireLaMachine,
62
+ dormir = dormirVraiment,
63
+ } = {},
64
+ ) {
65
+ const attendre = args.includes('--attendre');
66
+ if ((mode !== 'fermer' && mode !== 'rouvrir') || args.some(a => a !== '--attendre') || (attendre && mode !== 'fermer')) {
67
+ process.stderr.write('usage : grillhouse machine fermer [--attendre] | rouvrir\n');
68
+ return 2;
69
+ }
70
+ const issue = agir(mode, { env });
71
+ const dit = () => {
72
+ const { prises, parts, fermeture } = lire(env);
73
+ for (const l of direLaFermeture({ issue, reservation: fermeture, prises, parts, maintenant: maintenant() })) {
74
+ dire(l);
75
+ }
76
+ return prises.length + parts.length;
77
+ };
78
+ const restent = dit();
79
+ if (!attendre || issue === 'nuit-tient') {
80
+ return 0;
81
+ }
82
+ let encore = restent;
83
+ while (encore > 0) {
84
+ await dormir(SONDE_MS);
85
+ const { prises, parts } = lire(env);
86
+ if (prises.length + parts.length === 0) {
87
+ dire('la machine est vide');
88
+ return 0;
89
+ }
90
+ encore = prises.length + parts.length;
91
+ }
92
+ return 0;
93
+ }
94
+
95
+ if (process.argv[1] && path.basename(process.argv[1]) === 'machine.mjs') {
96
+ const [mode, ...args] = process.argv.slice(2);
97
+ try {
98
+ process.exitCode = await jouer(mode, args);
99
+ } catch (x) {
100
+ process.stderr.write(`⛔ grillhouse machine : ${x?.message ?? x}\n`);
101
+ process.exitCode = 1;
102
+ }
103
+ }
@@ -0,0 +1,17 @@
1
+ // The folders of test material a project declares (`grillhouse.matieres` of its root package.json,
2
+ // read by ./matieres-lues.mjs, which holds the rules of the key), asked by a directory of the
3
+ // project: the callers of the circuit, the envelope, the integration, the queue and the move of a
4
+ // copy, which refuse a faulty key by its name before any work.
5
+ import { langageDe } from './langages.mjs';
6
+ import { matieresDeclarees } from './matieres-lues.mjs';
7
+
8
+ /**
9
+ * The folders of test material that the project that holds <dir> declares, from the root, in the
10
+ * order of the key; none without the key.
11
+ * @param {string} dir a directory of the project: its main tree or a copy
12
+ * @returns {string[]}
13
+ * @throws {Error} the faults of the key, one per line
14
+ */
15
+ export function matieresDeclareesDe(dir) {
16
+ return matieresDeclarees(dir, d => langageDe(d).composants(d));
17
+ }
@@ -0,0 +1,104 @@
1
+ // The reading of the `grillhouse.matieres` key of a package.json, the folders of test material out
2
+ // of every package, as Bazel declares a `filegroup(testonly = True)` named in the `data` of a test
3
+ // and as the compiler of Rust keeps `tests/ui` at its root, out of every crate, its cases added
4
+ // with the code (Web Platform Tests keep their cases the same way): a list of folders of the
5
+ // repository, each from the root. The testwriter writes any file under one, as a file of shared
6
+ // test material; the developpeur does not (`estUnTest` of the join of the languages,
7
+ // scripts/langages.mjs, which the lock, the envelope and the conflicts of a copy read).
8
+ //
9
+ // This module holds the reading itself, given the components of the project; it imports no
10
+ // language, so that the join of the languages can use it. The reading a caller asks by a
11
+ // directory alone is `matieresDeclareesDe` (./matieres-cles.mjs).
12
+ //
13
+ // - The key is read from the package.json of the main tree of the repository, never of a copy, as
14
+ // `grillhouse.engendres` (scripts/engendres.mjs): a lot never declares the folder it then
15
+ // writes; each folder is resolved from the root of the tree given, the copy. Read once per pass
16
+ // (`luUneFois`).
17
+ // - A fault is refused by its key `grillhouse.matieres`, named: not a list of strings, an empty
18
+ // path, an absolute one, one that leaves the root, a folder absent of the main tree, a folder
19
+ // that is a package, holds one or lies inside one (the declaration gives the testwriter no
20
+ // manifest, and no package is opened to him by it). The nature of the files of a folder is not
21
+ // bounded, as the `data` of a `filegroup(testonly)` and `tests/ui`.
22
+ import { existsSync, readFileSync, statSync } from 'node:fs';
23
+ import path from 'node:path';
24
+ import { luUneFois } from './lecture-unique.mjs';
25
+ import { arbrePrincipal } from './outils-cles.mjs';
26
+
27
+ /**
28
+ * The folders of test material that the project that holds <dir> declares, from the root, in the
29
+ * order of the key; none without the key.
30
+ * @param {string} dir a directory of the project: its main tree or a copy
31
+ * @param {(dir: string) => { dossier: string }[]} composants the components of the project
32
+ * @returns {string[]}
33
+ * @throws {Error} the faults of the key, one per line
34
+ */
35
+ export function matieresDeclarees(dir, composants) {
36
+ return luUneFois(`matieres ${path.resolve(dir)}`, () => lire(dir, composants));
37
+ }
38
+
39
+ function lire(dir, composants) {
40
+ const principal = arbrePrincipal(dir);
41
+ const f = path.join(principal, 'package.json');
42
+ const brut = existsSync(f) ? JSON.parse(readFileSync(f, 'utf8'))?.grillhouse?.matieres : undefined;
43
+ if (brut === undefined || brut === null) {
44
+ return [];
45
+ }
46
+ if (!Array.isArray(brut) || !brut.every(m => typeof m === 'string')) {
47
+ throw new Error(
48
+ `la clé grillhouse.matieres vaut ${JSON.stringify(brut)}, pas une liste de chemins de dossiers depuis la racine.`
49
+ );
50
+ }
51
+ if (brut.length === 0) {
52
+ return [];
53
+ }
54
+ const paquets = composants(dir)
55
+ .map(c => path.relative(dir, c.dossier).split(path.sep).join('/'))
56
+ .filter(p => p !== '' && p !== '.');
57
+ const fautes = [];
58
+ const dossiers = [];
59
+ for (const m of brut) {
60
+ const n = path.posix.normalize(m === '' ? '.' : m).replace(/\/+$/, '');
61
+ const nom = `la clé grillhouse.matieres nomme « ${m} »`;
62
+ if (n === '.' || n === '') {
63
+ fautes.push(
64
+ 'la clé grillhouse.matieres nomme un chemin vide ou la racine : un dossier est sous la racine.'
65
+ );
66
+ } else if (path.isAbsolute(m)) {
67
+ fautes.push(`${nom}, un chemin absolu : un dossier part de la racine du dépôt.`);
68
+ } else if (n.split('/')[0] === '..') {
69
+ fautes.push(`${nom}, hors du dépôt : un dossier part de la racine.`);
70
+ } else if (
71
+ !existsSync(path.join(principal, n)) ||
72
+ !statSync(path.join(principal, n)).isDirectory()
73
+ ) {
74
+ fautes.push(`${nom}, qui n'est pas un dossier de l'arbre principal.`);
75
+ } else {
76
+ const paquet = paquets.find(p => n === p || n.startsWith(`${p}/`) || p.startsWith(`${n}/`));
77
+ if (paquet) {
78
+ fautes.push(
79
+ `${nom}, qui recouvre le paquet ${paquet} : un dossier de matière est hors de tout paquet.`
80
+ );
81
+ } else {
82
+ dossiers.push(n);
83
+ }
84
+ }
85
+ }
86
+ if (fautes.length) {
87
+ throw new Error(fautes.join('\n'));
88
+ }
89
+ return dossiers;
90
+ }
91
+
92
+ /**
93
+ * Whether <fichier> (absolute, or from <racine>) lies under one of the folders <dossiers>.
94
+ * @param {string[]} dossiers
95
+ * @param {string} racine
96
+ * @param {string} fichier
97
+ */
98
+ export function sousUneMatiere(dossiers, racine, fichier) {
99
+ if (dossiers.length === 0) {
100
+ return false;
101
+ }
102
+ const rel = path.relative(racine, path.resolve(racine, fichier)).split(path.sep).join('/');
103
+ return dossiers.some(d => rel.startsWith(`${d}/`));
104
+ }
@@ -0,0 +1,32 @@
1
+ // From 0.48.0 the queue of the project starts the CI of main itself after a lot entered, one pass
2
+ // an hour at most (scripts/ci-de-main.mjs `declencherLaCiDeMain`): the frame's ci.yml loses its
3
+ // hourly schedule and its job `moved`, and keeps `workflow_dispatch` and `workflow_call`.
4
+ //
5
+ // - A ci.yml of the frame (its mark on the first line, scripts/workflows-du-cadre.mjs) is rewritten
6
+ // on the template's new one; a ci.yml without the mark, and every other workflow, stay as they
7
+ // are. A second pass changes nothing and says nothing.
8
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
9
+ import path from 'node:path';
10
+ import { CADRE } from '../cadre.mjs';
11
+ import { estDuCadre, GABARIT_DES_WORKFLOWS, WORKFLOWS } from '../workflows-du-cadre.mjs';
12
+
13
+ export const version = '0.48.0';
14
+ export const nom = 'ci declenchee par la file';
15
+
16
+ /** The ci.yml of the frame of <projet> written on the template's; returns what it did. */
17
+ export function migrer(projet) {
18
+ const fichier = path.join(projet, WORKFLOWS, 'ci.yml');
19
+ const modele = path.join(CADRE, GABARIT_DES_WORKFLOWS, 'ci.yml');
20
+ if (!existsSync(fichier) || !existsSync(modele)) {
21
+ return [];
22
+ }
23
+ const actuel = readFileSync(fichier, 'utf8');
24
+ const voulu = readFileSync(modele, 'utf8');
25
+ if (!estDuCadre(actuel) || actuel === voulu) {
26
+ return [];
27
+ }
28
+ writeFileSync(fichier, voulu);
29
+ return [
30
+ `${WORKFLOWS}/ci.yml : la planification horaire et le travail moved sont retirés, la file déclenche elle-même la CI de main après l'entrée d'un lot, au plus une fois par heure`,
31
+ ];
32
+ }
@@ -0,0 +1,31 @@
1
+ // From 0.48.0 the key `grillhouse.poussee` (the commit branch and the night branch) is retired from
2
+ // the frame: main receives every lot, and the night pushes nothing. A package.json of the project
3
+ // that carries the key, with any value, loses it, its other keys, its layout and its end of line
4
+ // kept; a project without the key, without `grillhouse` or without package.json is left, and a
5
+ // second pass changes nothing and says nothing. The remote branches of the project are not touched.
6
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
7
+ import path from 'node:path';
8
+
9
+ export const version = '0.48.0';
10
+ export const nom = 'poussee retiree';
11
+
12
+ /** `grillhouse.poussee` taken out of the package.json of <projet>; returns what it did. */
13
+ export function migrer(projet) {
14
+ const fichier = path.join(projet, 'package.json');
15
+ if (!existsSync(fichier)) {
16
+ return [];
17
+ }
18
+ const texte = readFileSync(fichier, 'utf8');
19
+ const pkg = JSON.parse(texte);
20
+ const grillhouse = pkg?.grillhouse;
21
+ if (!grillhouse || typeof grillhouse !== 'object' || !Object.hasOwn(grillhouse, 'poussee')) {
22
+ return [];
23
+ }
24
+ delete grillhouse.poussee;
25
+ const indent = /^\n?(\s+)"/m.exec(texte)?.[1] ?? 2;
26
+ const fin = texte.endsWith('\n') ? '\n' : '';
27
+ writeFileSync(fichier, `${JSON.stringify(pkg, null, indent)}${fin}`);
28
+ return [
29
+ "package.json : la clé grillhouse.poussee est retirée, main reçoit seule chaque lot et la nuit ne pousse plus ; les branches distantes du projet (l'ancienne branche de commit, la branche de nuit) ne sont pas touchées",
30
+ ];
31
+ }
@@ -42,6 +42,8 @@ import * as greffonMattpocockRetire from './migrations/0.35.0-greffon-mattpocock
42
42
  import * as node26Seul from './migrations/0.44.0-node-26-seul.mjs';
43
43
  import * as seuilDesCodesDeTickets from './migrations/0.44.0-seuil-des-codes-de-tickets.mjs';
44
44
  import * as ciDeMain from './migrations/0.47.0-ci-de-main.mjs';
45
+ import * as pousseeRetiree from './migrations/0.48.0-poussee-retiree.mjs';
46
+ import * as ciDeclencheeParLaFile from './migrations/0.48.0-ci-declenchee-par-la-file.mjs';
45
47
 
46
48
  /** The migrations of the core. */
47
49
  export const MIGRATIONS = [
@@ -63,6 +65,8 @@ export const MIGRATIONS = [
63
65
  node26Seul,
64
66
  seuilDesCodesDeTickets,
65
67
  ciDeMain,
68
+ pousseeRetiree,
69
+ ciDeclencheeParLaFile,
66
70
  ];
67
71
 
68
72
  /**
package/scripts/nuit.sh CHANGED
@@ -66,26 +66,19 @@
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
- # - « À repasser » (exit 75): neither green nor red. The last green stays, no ticket opens, nothing
70
- # is pushed, the log says so; the next night plays again.
69
+ # - « À repasser » (exit 75): neither green nor red. The last green stays, no ticket opens,
70
+ # the log says so; the next night plays again.
71
71
  # - The project's night script: `grillhouse.nuit` in the package.json of the commit it plays names
72
72
  # an npm script (`npm pkg set grillhouse.nuit=<script>`). After the night tests, the night plays
73
73
  # `npm run <script>` in its copy; a red script turns the night red, with a log line that names it.
74
74
  # The key is read as written, before any work: without it (or with null) the night plays
75
75
  # no script of the project; a value that is not a non-blank string, or a name absent from the scripts of
76
76
  # that package.json, turns the night red, with a log line that cites it, and nothing runs.
77
- # - The night push: `grillhouse.poussee.nuit` in the package.json of the commit it plays names a
78
- # remote branch (`npm pkg set grillhouse.poussee.nuit=<branch>`). After a green night, once the
79
- # last green is written, the night runs `git push origin <commit>:<branch>` with GRILLHOUSE_NUIT=1
80
- # set for that push alone, the mark by which the pre-push guard (scripts/branche-de-nuit.mjs)
81
- # lets it through; any other push to that branch is refused there. Without the key
82
- # (or with null, as for grillhouse.poussee itself) or after a red night it pushes nothing. The
83
- # keys are read as written, before any work: a grillhouse.poussee that is neither null nor an
84
- # object, or a grillhouse.poussee.nuit that is not a non-blank string, turns the night red with
85
- # a log line that cites it, one line per faulty key. A refused push keeps the last green, opens
86
- # the night ticket « La poussée de la nuit est refusée sur <commit> vers « origin/<branch> » »
87
- # (or comments the open one that names « origin/<branch> »), and exits 1; a remote already at
88
- # the commit accepts the push.
77
+ # - The night pushes nothing: main receives every lot by the queue, on a tree judged; the night keeps
78
+ # its last green (`<git common dir>/nuit/dernier-vert`), a mark and not a branch. A project whose
79
+ # package.json carries the retired key `grillhouse.poussee`, whatever its value, turns the night
80
+ # red before any work, with a log line that names the key and the gesture (remove it,
81
+ # scripts/poussee-retiree.mjs).
89
82
  # - The copies whose content is on main: once its steps are played, whatever their verdict, the
90
83
  # night passes each copy `git worktree list` names, the main tree and its own left out, through
91
84
  # scripts/retirer-copie.sh without `--jetable` (scripts/retirer-les-copies-finies.mjs), as a CI cleans its
@@ -158,7 +151,6 @@ mkdir -p "$resultats"
158
151
 
159
152
  tete="$(git -C "$racine" rev-parse HEAD)"
160
153
  copie="$racine/.claude/worktrees/nuit"
161
- branche=
162
154
  # The red steps of the night, and its red tasks: those of the full pass, each with the command
163
155
  # that replays it alone when the language has one (in `rejeux`, which a bisect runs), then a step
164
156
  # red without a task of its own, named by its command (no command).
@@ -198,15 +190,15 @@ jouer() {
198
190
  echo "$raison"
199
191
  return 1
200
192
  fi
201
- # The reading gives one line per finding: « script<TAB>name », « pousse<TAB>branch », or a fault
202
- # « nuit-invalide<TAB>value as JSON », « nuit-absent<TAB>name », « poussee-invalide<TAB>value »,
203
- # « poussee-nuit-invalide<TAB>value ». Every faulty key is reported before any work.
193
+ # The reading gives one line per finding: « script<TAB>name », or a fault « nuit-invalide<TAB>value
194
+ # as JSON », « nuit-absent<TAB>name », « poussee-retiree<TAB>line ». Every faulty key is reported
195
+ # before any work.
204
196
  local lecture ligne nuit=
205
197
  lecture="$(node --input-type=module -e '
206
198
  import { readFileSync } from "node:fs";
207
199
  import { pathToFileURL } from "node:url";
208
200
  const pkg = JSON.parse(readFileSync(process.argv[1], "utf8"));
209
- const { lirePoussee } = await import(pathToFileURL(process.argv[2]).href);
201
+ const { pousseeRetiree } = await import(pathToFileURL(process.argv[2]).href);
210
202
  const out = (...l) => process.stdout.write(l.join("\t") + "\n");
211
203
  const vide = v => typeof v !== "string" || !v.trim();
212
204
  const v = pkg.grillhouse?.nuit;
@@ -215,26 +207,21 @@ jouer() {
215
207
  else if (!Object.hasOwn(pkg.scripts ?? {}, v)) out("nuit-absent", v);
216
208
  else out("script", v);
217
209
  }
218
- const { nuit, fautes } = lirePoussee(pkg);
219
- for (const f of fautes) out(f.cle === "grillhouse.poussee" ? "poussee-invalide" : "poussee-nuit-invalide", f.valeur);
220
- if (nuit) out("pousse", nuit);
221
- ' "$copie/package.json" "$ici/poussee-cles.mjs" 2>/dev/null)"
210
+ const retiree = pousseeRetiree(pkg);
211
+ if (retiree) out("poussee-retiree", retiree);
212
+ ' "$copie/package.json" "$ici/poussee-retiree.mjs" 2>/dev/null)"
222
213
  local faute=0
223
214
  while IFS= read -r ligne; do
224
215
  case "$ligne" in
225
216
  script$'\t'*) nuit="${ligne#script$'\t'}" ;;
226
- pousse$'\t'*) branche="${ligne#pousse$'\t'}" ;;
227
217
  nuit-invalide$'\t'*)
228
218
  echo "✗ la clé grillhouse.nuit vaut ${ligne#nuit-invalide$'\t'}, pas un nom de script npm : rien n'est joué."
229
219
  faute=1 ;;
230
220
  nuit-absent$'\t'*)
231
221
  echo "✗ la clé grillhouse.nuit nomme « ${ligne#nuit-absent$'\t'} », absent des scripts du package.json : rien n'est joué."
232
222
  faute=1 ;;
233
- poussee-invalide$'\t'*)
234
- echo "✗ la clé grillhouse.poussee vaut ${ligne#poussee-invalide$'\t'}, pas un objet : rien n'est joué."
235
- faute=1 ;;
236
- poussee-nuit-invalide$'\t'*)
237
- echo "✗ la clé grillhouse.poussee.nuit vaut ${ligne#poussee-nuit-invalide$'\t'}, pas un nom de branche : rien n'est joué."
223
+ poussee-retiree$'\t'*)
224
+ echo "✗ ${ligne#poussee-retiree$'\t'} Rien n'est joué."
238
225
  faute=1 ;;
239
226
  esac
240
227
  done <<< "$lecture"
@@ -393,21 +380,6 @@ signaler() {
393
380
  if [ "$verdict" -eq 0 ]; then
394
381
  echo "$tete" > "$dossier/dernier-vert"
395
382
  echo "✓ vert : ${tete:0:7} est le dernier vert." >> "$journal"
396
- if [ -n "$branche" ]; then
397
- if GRILLHOUSE_NUIT=1 GIT_TERMINAL_PROMPT=0 git -C "$racine" push origin "$tete:$branche" >> "$journal" 2>&1; then
398
- echo "✓ poussée : ${tete:0:7} est sur origin/$branche." >> "$journal"
399
- else
400
- echo "✗ la poussée de ${tete:0:7} vers origin/$branche (grillhouse.poussee.nuit) est refusée." >> "$journal"
401
- texte="La poussée de la nuit du $(date +%Y-%m-%d) est refusée : ${tete:0:7} vers origin/$branche (grillhouse.poussee.nuit).
402
- Le dernier vert reste ${tete:0:7}.
403
- Journal : $journal
404
- Fin du journal :
405
- $(tail -40 "$journal")"
406
- signaler "origin/$branche" "La poussée de la nuit est refusée sur ${tete:0:7} vers « origin/$branche »" "$texte"
407
- echo "✗ vert, poussée refusée : ticket ${numero:-neuf} (étiquette nuit)." >> "$journal"
408
- exit 1
409
- fi
410
- fi
411
383
  exit 0
412
384
  fi
413
385
 
@@ -90,31 +90,33 @@ export function lancementDeLaPasse({ lourde, cmd, args, env }) {
90
90
  * The command line that runs <cmd> in a control group of its own under the part <part>: `systemd-run
91
91
  * --user --scope` (the manager of the user, no privilege), its CPU weight and its memory bound
92
92
  * drawn from the part, no hard ceiling of CPU, the command of the pass whole at the end after
93
- * `--`. <unite> names the scope, which a sampler reads. With <fils> (the precise threads of the
93
+ * `--`, given as written (`--expand-environment=no`: systemd-run would otherwise expand each
94
+ * `${…}` of its arguments, a shell script's included). <plafond> adds the hard CPU ceiling (`CPUQuota`, the cores of the part: the group of an
95
+ * agent's session); <memoire> false leaves the memory unbound. <unite> names the scope, which a
96
+ * sampler reads. With <fils> (the precise threads of the
94
97
  * part, the system delegating the cpuset controller to the account) the group allows those
95
98
  * threads only (`AllowedCPUs`), under the slice of the frame, which the programs out of the frame
96
99
  * are kept out of.
97
100
  * @param {{ part: { coeurs: number, memoire: number }, cmd: string, args: string[],
98
- * unite?: string | null, fils?: number[] | null }} o
101
+ * unite?: string | null, fils?: number[] | null, plafond?: boolean, memoire?: boolean }} o
99
102
  * @returns {{ cmd: string, args: string[] }}
100
103
  */
101
- export function commandeDuGroupe({ part, cmd, args, unite = null, fils = null }) {
104
+ export function commandeDuGroupe({ part, cmd, args, unite = null, fils = null, plafond = false, memoire = true }) {
102
105
  return {
103
106
  cmd: LANCEUR_DE_GROUPE,
104
107
  args: [
105
108
  '--user',
106
109
  '--scope',
107
110
  '--quiet',
111
+ '--expand-environment=no',
108
112
  ...(unite ? [`--unit=${unite}`] : []),
109
113
  ...(fils ? [`--slice=${TRANCHE_DU_CADRE}`] : []),
110
114
  '-p',
111
- 'CPUAccounting=yes',
112
- '-p',
113
115
  'MemoryAccounting=yes',
114
116
  '-p',
115
117
  `CPUWeight=${poidsDeLaPart(part)}`,
116
- '-p',
117
- `MemoryMax=${Math.floor(part.memoire)}`,
118
+ ...(memoire ? ['-p', `MemoryMax=${Math.floor(part.memoire)}`] : []),
119
+ ...(plafond ? ['-p', `CPUQuota=${part.coeurs * 100}%`] : []),
118
120
  ...(fils ? ['-p', `AllowedCPUs=${listeDeCoeurs(fils)}`] : []),
119
121
  '--',
120
122
  cmd,
@@ -280,7 +280,9 @@ export function prendreUnePlace({
280
280
  borneMs,
281
281
  rappelMs,
282
282
  };
283
- const { code, lignes } = auServeur(e, ['prendre', JSON.stringify(demande)], borneMs + 60_000);
283
+ // No deadline of the process: the bridge holds the bound itself (`attendreLaPlace`), and under
284
+ // the supervisor's closure the wait lasts until the reopening.
285
+ const { code, lignes } = auServeur(e, ['prendre', JSON.stringify(demande)], 0);
284
286
  for (const l of lignes) {
285
287
  if (l.dire) {
286
288
  // The wait, said and dated in the journal of states, its reason the message said.
@@ -570,7 +572,11 @@ export function lecteurDeLaCharge(env = process.env, systeme = chargeDesCoeursDu
570
572
  * « tient ». The night (VARIABLE_JETON) and a pass that asks for the <entiere> budget take the
571
573
  * whole budget: they play alone. A <mesure> of time takes dedicated cores (`fils`, whole physical
572
574
  * cores), waits for them and for their rest (<chargeDesCoeurs>: the load of the threads it gives,
573
- * null without a reading, by default `lecteurDeLaCharge`; <topologie>, the topology of the system, for a trial). Where no part is taken (the envelope of an agent, a part already
575
+ * null without a reading, by default `lecteurDeLaCharge`; <topologie>, the topology of the system, for a trial).
576
+ * The reservation of the machine (<lireLaReservation>, the places of the server by default) is read at each
577
+ * turn of the wait, before the admission lock: under the supervisor's closure the pass waits without bound
578
+ * (« machine fermée par le superviseur »), under the night's it waits unless it carries its jeton, within
579
+ * the bound; a reading that fails stands for no reservation. Where no part is taken (the envelope of an agent, a part already
574
580
  * held: GRILLHOUSE_PART_TENUE) the part returned holds nothing.
575
581
  * @param {{ env?: Record<string, string | undefined>, racine?: string, ticket?: string | null,
576
582
  * sorte?: string, entiere?: boolean, borneMs?: number, rappelMs?: number,
@@ -598,6 +604,7 @@ export function prendreUnePart({
598
604
  dire = l => process.stdout.write(`${l}\n`),
599
605
  maintenant = Date.now,
600
606
  dormir = attendreUnPeu,
607
+ lireLaReservation = () => lirePlaces({ env }).reservation ?? null,
601
608
  ...disques
602
609
  } = {}) {
603
610
  const sans = raison => ({ id: null, part: null, fils: null, env, rendre: () => {}, raison });
@@ -670,14 +677,32 @@ export function prendreUnePart({
670
677
  return () => {};
671
678
  },
672
679
  });
673
- const debut = maintenant();
680
+ let debut = maintenant();
674
681
  let dit = null;
675
682
  for (;;) {
683
+ // The reservation of the machine is read each turn, before the admission lock, bounded by
684
+ // the delay of a call to the server; a reading that fails stands for « no reservation ».
685
+ let reservation = null;
686
+ try {
687
+ reservation = lireLaReservation() ?? null;
688
+ } catch {
689
+ reservation = null;
690
+ }
691
+ const fermee = reservation?.auteur === 'superviseur';
676
692
  const refus = sousLAdmission(dossier, () => {
677
693
  const { prises, attentes } = lireLesParts(dossier);
678
694
  let r = refusDePart(
679
695
  { prises, attentes },
680
- { id: moi.id, rang: moi.rang, part, budget, mesurer: () => machineDe(env), dediee: mesure }
696
+ {
697
+ id: moi.id,
698
+ rang: moi.rang,
699
+ part,
700
+ budget,
701
+ mesurer: () => machineDe(env),
702
+ dediee: mesure,
703
+ reservation,
704
+ jeton: env[VARIABLE_JETON] ?? null,
705
+ }
681
706
  );
682
707
  let fils = null;
683
708
  if (r === null) {
@@ -707,6 +732,10 @@ export function prendreUnePart({
707
732
  break;
708
733
  }
709
734
  const t = maintenant();
735
+ if (fermee) {
736
+ // The supervisor's order lasts until its contrary: no bound, the wait counts from the reopening.
737
+ debut = t;
738
+ }
710
739
  if (t - debut >= borneMs) {
711
740
  throw new AttenteDeLaMachine(
712
741
  `⏱ attente de la part bornée à ${duree(borneMs)} (GRILLHOUSE_ATTENTE_MACHINE_MS), ${RANGS[rangDeLaPasse]} : ${refus} ; à repasser (code ${A_REPASSER}).`,
@@ -715,7 +744,7 @@ export function prendreUnePart({
715
744
  }
716
745
  if (dit === null) {
717
746
  dire(
718
- `⏳ ${RANGS[rangDeLaPasse]}, la passe attend sa part (${part.coeurs} cœurs) : ${refus} ; ${duree(borneMs)} au plus.`
747
+ `⏳ ${RANGS[rangDeLaPasse]}, la passe attend sa part (${part.coeurs} cœurs) : ${refus}${fermee ? ' ; sans borne, jusqu’à la réouverture.' : ` ; ${duree(borneMs)} au plus.`}`
719
748
  );
720
749
  } else if (t - dit >= rappelMs) {
721
750
  dire(`⏳ la passe attend sa part depuis ${duree(t - debut)} : ${refus}.`);
@@ -846,13 +875,40 @@ export function surUnePart(
846
875
  * order of arrival `{ id, pid, ticket, rang, raison, depuis }`; none where no place is taken.
847
876
  * @param {{ env?: Record<string, string | undefined> }} [o]
848
877
  */
849
- export function lirePlaces({ env = process.env } = {}) {
878
+ export function lirePlaces({ env = process.env, ms = 30_000 } = {}) {
850
879
  const e = surLeServeur(env);
851
880
  return e
852
- ? auServeur(e, ['lire']).lignes[0]
881
+ ? auServeur(e, ['lire'], ms).lignes[0]
853
882
  : { plafond: plafondDe(env), prises: [], attentes: [] };
854
883
  }
855
884
 
885
+ // The command <mode> (`fermer`, `rouvrir`) of the bridge to the server under <env>: its issue. No
886
+ // server where no place is taken (the CI, the envelope of an agent), which cannot close a machine.
887
+ function commandeDeLaFermeture(mode, env) {
888
+ const e = surLeServeur(env);
889
+ if (!e) {
890
+ throw new Error('aucun serveur Temporal ici : la machine ne se ferme que sur le poste');
891
+ }
892
+ return auServeur(e, [mode]).lignes[0];
893
+ }
894
+
895
+ /**
896
+ * Closes the machine under <env> (the supervisor's reservation of the places, `cordon` of
897
+ * kubectl): its issue, `fermee`, `deja-fermee`, or `nuit-tient` when the night holds the machine.
898
+ * @param {{ env?: Record<string, string | undefined> }} [o]
899
+ * @returns {'fermee' | 'deja-fermee' | 'nuit-tient'}
900
+ */
901
+ export const fermerLaMachine = ({ env = process.env } = {}) => commandeDeLaFermeture('fermer', env);
902
+
903
+ /**
904
+ * Reopens the machine under <env>: its issue, `rouverte`, `deja-ouverte`, or `nuit-tient` (the
905
+ * reopening never lifts a night's reservation).
906
+ * @param {{ env?: Record<string, string | undefined> }} [o]
907
+ * @returns {'rouverte' | 'deja-ouverte' | 'nuit-tient'}
908
+ */
909
+ export const rouvrirLaMachine = ({ env = process.env } = {}) =>
910
+ commandeDeLaFermeture('rouvrir', env);
911
+
856
912
  /**
857
913
  * The machine a trial fixes under <env> (GRILLHOUSE_MESURE_D_ESSAI, JSON `{ coeurs, charge,
858
914
  * memoireLibre, memoireTotale }`), or null without the variable.
@@ -891,7 +947,7 @@ function mesureDEssai(env) {
891
947
  }
892
948
 
893
949
  /**
894
- * The places as the board shows them: taken and ceiling, the load over one minute and the cores,
950
+ * The places as the board shows them: the places of circuits held (`prises`, `tenues`) and the ceiling, the load over one minute and the cores,
895
951
  * the free memory and the total memory in whole GB, and the waits (ticket, since when) in the order of arrival: those
896
952
  * of a place for a session or a pass, then the tickets that wait for a place of a circuit, not
897
953
  * started (`circuits` of the server, which the queue of each project reserves). The
@@ -904,6 +960,7 @@ function mesureDEssai(env) {
904
960
  * }} [o] `lues`, the places as the server holds them (`lirePlaces` by default); `tenues` of the
905
961
  * result gives each place taken, its ticket and the root of its project (null without one)
906
962
  * @returns {{ prises: number, tenues: { ticket: string | null, racine: string | null }[],
963
+ * fermeture: { auteur: 'nuit' | 'superviseur', depuis: number, phase: string } | null,
907
964
  * plafond: number, faute: string | null, charge: number, coeurs: number, memoireGo: number,
908
965
  * memoireTotaleGo: number, attentes: { ticket: string, depuis: number, disque?: string | null }[] }}
909
966
  * @throws {Error} naming GRILLHOUSE_MESURE_D_ESSAI when its value is faulty
@@ -913,16 +970,22 @@ export function etatDesPlaces({ env = process.env, mesurer = mesureDeLaMachine,
913
970
  const {
914
971
  plafond,
915
972
  faute = null,
916
- prises,
917
973
  attentes,
918
974
  circuits = [],
919
975
  nuit = null,
976
+ fermeture = null,
920
977
  } = lues ?? lirePlaces({ env });
921
978
  const m = fixee ?? mesurer();
979
+ // The places the board counts are the circuits': a circuit holds its place from its start to its
980
+ // end, its stops included, and the ceiling bounds them.
981
+ const tenues = circuits
982
+ .filter(c => c.accordee)
983
+ .map(c => ({ ticket: c.ticket ?? null, racine: c.racine ?? null }));
922
984
  return {
923
- prises: prises.length,
924
- tenues: prises.map(p => ({ ticket: p.ticket ?? null, racine: p.racine ?? null })),
985
+ prises: tenues.length,
986
+ tenues,
925
987
  nuit: nuit?.phase ?? null,
988
+ fermeture,
926
989
  plafond,
927
990
  faute,
928
991
  charge: Math.round(m.charge * 10) / 10,