@roomi-fields/grillhouse 0.36.0 → 0.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +22 -0
  3. package/cadre/templates/projet/.github/workflows/ci.yml +10 -0
  4. package/cadre/templates/projet/.github/workflows/nuit.yml +5 -0
  5. package/charte.md +5 -0
  6. package/dist/temporal/nuits/activites.d.ts +10 -1
  7. package/dist/temporal/nuits/activites.js +59 -3
  8. package/dist/temporal/nuits/activites.js.map +1 -1
  9. package/dist/temporal/nuits/contrat.d.ts +15 -0
  10. package/dist/temporal/nuits/deroule.js +67 -35
  11. package/dist/temporal/nuits/deroule.js.map +1 -1
  12. package/dist/temporal/places/client.d.ts +12 -0
  13. package/dist/temporal/places/client.js +23 -1
  14. package/dist/temporal/places/client.js.map +1 -1
  15. package/dist/temporal/places/contrat.d.ts +35 -0
  16. package/dist/temporal/places/contrat.js +11 -0
  17. package/dist/temporal/places/contrat.js.map +1 -1
  18. package/dist/temporal/places/deroule.js +47 -2
  19. package/dist/temporal/places/deroule.js.map +1 -1
  20. package/docs/ARCHITECTURE.md +14 -3
  21. package/docs/CADRE.md +11 -0
  22. package/docs/INTERFACE.md +6 -3
  23. package/package.json +1 -1
  24. package/scripts/activites.mjs +10 -4
  25. package/scripts/aiguillage.mjs +1 -0
  26. package/scripts/binaires.mjs +119 -0
  27. package/scripts/grillhouse-maj.mjs +3 -60
  28. package/scripts/integration/integrer.mjs +18 -10
  29. package/scripts/langages/cargo/binaires.mjs +1 -1
  30. package/scripts/langages/cargo/clippy.mjs +1 -1
  31. package/scripts/langages/cargo/commandes.mjs +1 -1
  32. package/scripts/langages/cargo/sccache.mjs +1 -1
  33. package/scripts/langages/python/commandes.mjs +1 -1
  34. package/scripts/paquet.mjs +2 -7
  35. package/scripts/places-de-la-machine.mjs +40 -28
  36. package/scripts/regles-des-places.d.mts +27 -2
  37. package/scripts/regles-des-places.mjs +66 -5
  38. package/scripts/sous-commandes.mjs +1 -0
  39. package/scripts/tableau.mjs +395 -180
@@ -98,7 +98,7 @@
98
98
  // (./sccache.mjs), in a copy as in an agent's envelope (grillhouse-cyr), its server started
99
99
  // under the machine's /tmp before each run of cargo that compiles (grillhouse-qmk).
100
100
  // `tests-du-paquet`, `verifier` and `typer` refuse, before any run of cargo, a PATH without sccache, in one line that names it
101
- // and `npx grillhouse maj`, which installs it (code 2).
101
+ // and `npx grillhouse binaires`, which installs it (code 2).
102
102
  // - Nextest reads the frame's profile `grillhouse` (./nextest.toml, a tool's configuration under
103
103
  // the project's own, `--tool-config-file`), whose JUnit report lands in nextest's store, at
104
104
  // `<workspace root>/target/nextest/grillhouse/junit.xml` (nextest's default `store.dir`, under
@@ -153,7 +153,7 @@ export function sccacheAbsent(racine, env) {
153
153
  }
154
154
  return trouverDansLePath('sccache', env)
155
155
  ? null
156
- : "⛔ sccache absent du PATH : cargo compile à travers lui (RUSTC_WRAPPER=sccache) ; `npx grillhouse maj` l'installe avec les autres binaires du module cargo.";
156
+ : "⛔ sccache absent du PATH : cargo compile à travers lui (RUSTC_WRAPPER=sccache) ; `npx grillhouse binaires` l'installe avec les autres binaires du module cargo.";
157
157
  }
158
158
 
159
159
  /**
@@ -220,7 +220,7 @@ function passe(racine, env) {
220
220
  stdio: 'inherit',
221
221
  });
222
222
  if (r.error?.code === 'ENOENT' && programme === 'uv') {
223
- process.stderr.write("⛔ uv absent du PATH : `npx grillhouse maj` l'installe.\n");
223
+ process.stderr.write("⛔ uv absent du PATH : `npx grillhouse binaires` l'installe.\n");
224
224
  }
225
225
  t.code = r.error ? 127 : (r.status ?? 128 + (constants.signals[r.signal] ?? 0));
226
226
  if (vert.includes(t.code)) {
@@ -45,13 +45,8 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from
45
45
  import path from 'node:path';
46
46
  import { pathToFileURL } from 'node:url';
47
47
  import { CADRE } from './cadre.mjs';
48
- import {
49
- aInstaller,
50
- installerBinaires,
51
- mettreAJour,
52
- rapport,
53
- regenerer,
54
- } from './grillhouse-maj.mjs';
48
+ import { installerBinaires } from './binaires.mjs';
49
+ import { aInstaller, mettreAJour, rapport, regenerer } from './grillhouse-maj.mjs';
55
50
  import { LANGAGES, langage } from './langages.mjs';
56
51
  import {
57
52
  inscrireAuxEspaces,
@@ -42,9 +42,16 @@ import { paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
42
42
  import { ecrireLaTrace, traceDesPlaces } from './journal-des-etats.mjs';
43
43
  import { mesureDeLaMachine } from './mesure-de-la-machine.mjs';
44
44
  import { plafondDe } from './plafond-de-la-machine.mjs';
45
+ import { VARIABLE_JETON } from './regles-des-places.mjs';
45
46
  import { AttenteDeLaMachine, avecLaMachine, borneDe, racineDuDepot } from './verrou-de-machine.mjs';
46
47
 
47
- export const VARIABLE_ESPACEMENT = 'GRILLHOUSE_ESPACEMENT_MS';
48
+ // The spacing and the jeton of the night are rules (./regles-des-places.mjs), published here too.
49
+ export {
50
+ ESPACEMENT_MS,
51
+ espacementDe,
52
+ VARIABLE_ESPACEMENT,
53
+ VARIABLE_JETON,
54
+ } from './regles-des-places.mjs';
48
55
  export const VARIABLE_TRAVAILLEURS = 'GRILLHOUSE_TRAVAILLEURS';
49
56
  /** The mark of a place held, which the children of its holder inherit. */
50
57
  export const VARIABLE_TENUE = 'GRILLHOUSE_PLACE_TENUE';
@@ -53,31 +60,10 @@ export const VARIABLE_MESURE_D_ESSAI = 'GRILLHOUSE_MESURE_D_ESSAI';
53
60
  // The server of the places of a trial machine.
54
61
  const VARIABLE_ESSAI = 'GRILLHOUSE_PLACES_D_ESSAI';
55
62
 
56
- /** The gap between two starts when GRILLHOUSE_ESPACEMENT_MS names none, in ms. */
57
- export const ESPACEMENT_MS = 10_000;
58
63
  const RAPPEL_MS = 30_000;
59
64
  // The reading and the taking of the places on the server, in a process of their own.
60
65
  const PONT = path.join(import.meta.dirname, 'places-du-serveur.mjs');
61
66
 
62
- /**
63
- * The gap between two starts under <env>, in ms.
64
- * @param {Record<string, string | undefined>} [env]
65
- * @returns {number}
66
- * @throws {Error} naming GRILLHOUSE_ESPACEMENT_MS when its value is not a number of ms
67
- */
68
- export function espacementDe(env = process.env) {
69
- const v = env[VARIABLE_ESPACEMENT];
70
- if (v === undefined || v === '') {
71
- return ESPACEMENT_MS;
72
- }
73
- if (!/^\d+$/.test(v)) {
74
- throw new Error(
75
- `${VARIABLE_ESPACEMENT} vaut « ${v} » : un nombre de millisecondes est attendu.`
76
- );
77
- }
78
- return Number(v);
79
- }
80
-
81
67
  /**
82
68
  * The number of workers of the tests of a session: max(1, cores ÷ places), the division whole.
83
69
  * @param {{ coeurs?: number, places?: number, env?: Record<string, string | undefined> }} [o]
@@ -171,6 +157,28 @@ export function prendreUnRang({ env = process.env } = {}) {
171
157
  return e ? auServeur(e, ['rang']).lignes[0] : null;
172
158
  }
173
159
 
160
+ /**
161
+ * The request of a place for the process <pid>: its start, its ticket, the root of its project,
162
+ * the rank of its circuit, and the jeton of the night when <env> carries it (VARIABLE_JETON: the
163
+ * passes of the night), which the workflow of the machine lets pass during the reservation of the
164
+ * machine.
165
+ * @param {{ env?: Record<string, string | undefined>, pid: number, depart?: string | null,
166
+ * ticket?: string | null, racine?: string, rang?: number | null }} o
167
+ * @returns {{ pid: number, depart: string | null, ticket: string | null, racine?: string | null,
168
+ * rang?: number, jeton?: string }}
169
+ */
170
+ export function demandeDePlace({ env = process.env, pid, depart, ticket = null, racine, rang }) {
171
+ const jeton = env[VARIABLE_JETON];
172
+ return {
173
+ pid,
174
+ depart: depart === undefined ? departDe(pid) : depart,
175
+ ticket,
176
+ ...(racine === undefined ? {} : { racine: racineDuDepot(racine) }),
177
+ ...(rang === undefined || rang === null ? {} : { rang }),
178
+ ...(jeton ? { jeton } : {}),
179
+ };
180
+ }
181
+
174
182
  /**
175
183
  * Takes a place of the machine, waiting for one, saying why it waits (`dire`), and returns the
176
184
  * place. Where no place is taken, or under a place already held (GRILLHOUSE_PLACE_TENUE), the
@@ -202,11 +210,7 @@ export function prendreUnePlace({
202
210
  return { id: null, rang: rang ?? null, env, rendre: () => {}, rattacher: () => {} };
203
211
  }
204
212
  const demande = {
205
- pid,
206
- depart: depart === undefined ? departDe(pid) : depart,
207
- ticket,
208
- racine: racineDuDepot(racine),
209
- ...(rang === undefined || rang === null ? {} : { rang }),
213
+ ...demandeDePlace({ env, pid, depart, ticket, racine, rang }),
210
214
  borneMs,
211
215
  rappelMs,
212
216
  };
@@ -413,11 +417,19 @@ function mesureDEssai(env) {
413
417
  */
414
418
  export function etatDesPlaces({ env = process.env, mesurer = mesureDeLaMachine, lues } = {}) {
415
419
  const fixee = mesureDEssai(env);
416
- const { plafond, faute = null, prises, attentes, circuits = [] } = lues ?? lirePlaces({ env });
420
+ const {
421
+ plafond,
422
+ faute = null,
423
+ prises,
424
+ attentes,
425
+ circuits = [],
426
+ nuit = null,
427
+ } = lues ?? lirePlaces({ env });
417
428
  const m = fixee ?? mesurer();
418
429
  return {
419
430
  prises: prises.length,
420
431
  tenues: prises.map(p => ({ ticket: p.ticket ?? null, racine: p.racine ?? null })),
432
+ nuit: nuit?.phase ?? null,
421
433
  plafond,
422
434
  faute,
423
435
  charge: Math.round(m.charge * 10) / 10,
@@ -4,6 +4,14 @@
4
4
  /** The memory a start wants free, in bytes: 4 GB. */
5
5
  export const MEMOIRE_MIN: number;
6
6
 
7
+ export const VARIABLE_ESPACEMENT: string;
8
+ /** The jeton of the reservation of the machine by the night, which the passes of the night carry. */
9
+ export const VARIABLE_JETON: string;
10
+ /** The gap between two starts when GRILLHOUSE_ESPACEMENT_MS names none, in ms. */
11
+ export const ESPACEMENT_MS: number;
12
+ /** The gap between two starts under <env>, in ms. */
13
+ export function espacementDe(env?: Record<string, string | undefined>): number;
14
+
7
15
  /** A duration as a line says it: seconds under 2 min, else minutes. */
8
16
  export function duree(ms: number): string;
9
17
 
@@ -22,8 +30,15 @@ export function admission(m: MesureDeLaMachine): { ok: true } | { ok: false; rai
22
30
  export function refusDeLaPlace(
23
31
  etat: {
24
32
  prises: readonly unknown[];
25
- attentes: readonly { id: string; rang: number; ticket?: string | null; raison?: string }[];
33
+ attentes: readonly {
34
+ id: string;
35
+ rang: number;
36
+ ticket?: string | null;
37
+ raison?: string;
38
+ jeton?: string | null;
39
+ }[];
26
40
  dernier: number;
41
+ reservation?: { jeton: string } | null;
27
42
  },
28
43
  o: {
29
44
  id: string;
@@ -32,12 +47,22 @@ export function refusDeLaPlace(
32
47
  espacementMs: number;
33
48
  maintenant: number;
34
49
  mesurer: () => MesureDeLaMachine;
50
+ jeton?: string | null;
35
51
  }
36
52
  ): string | null;
37
53
 
38
54
  /** A place of a circuit not given by its project's queue for this long is gone, in ms: 10 min. */
39
55
  export const PERIME_MS: number;
40
56
 
57
+ /** The phase of the night on the places: none without a reservation, waiting, or under way. */
58
+ export function phaseDeLaNuit(etat: {
59
+ prises: readonly { id?: string; jeton?: string | null }[];
60
+ reservation?: { jeton: string } | null;
61
+ }): 'attend' | 'en cours' | null;
62
+
63
+ /** Whether a reservation's last beat is PERIME_MS old at <maintenant>. */
64
+ export function reservationPerimee(reservation: { battement: number }, maintenant: number): boolean;
65
+
41
66
  /** The place of a circuit of the machine: held (`accordee`) or waited for, its rank of arrival. */
42
67
  export interface PlaceDeCircuit {
43
68
  racine: string;
@@ -74,5 +99,5 @@ export function reserverDesCircuits(
74
99
  groupe?: string;
75
100
  priorites?: Record<string, { priorite: number; creation: string }>;
76
101
  },
77
- o: { rang: number; plafond: number; maintenant: number }
102
+ o: { rang: number; plafond: number; maintenant: number; reservee?: boolean }
78
103
  ): { circuits: PlaceDeCircuit[]; rang: number; accordes: string[] };
@@ -9,6 +9,31 @@
9
9
  /** The memory a start wants free, in bytes: 4 GB. */
10
10
  export const MEMOIRE_MIN = 4 * 1024 ** 3;
11
11
 
12
+ export const VARIABLE_ESPACEMENT = 'GRILLHOUSE_ESPACEMENT_MS';
13
+ /** The jeton of the reservation of the machine by the night, which the passes of the night carry. */
14
+ export const VARIABLE_JETON = 'GRILLHOUSE_JETON_DE_LA_NUIT';
15
+ /** The gap between two starts when GRILLHOUSE_ESPACEMENT_MS names none, in ms. */
16
+ export const ESPACEMENT_MS = 10_000;
17
+
18
+ /**
19
+ * The gap between two starts under <env>, in ms.
20
+ * @param {Record<string, string | undefined>} [env]
21
+ * @returns {number}
22
+ * @throws {Error} naming GRILLHOUSE_ESPACEMENT_MS when its value is not a number of ms
23
+ */
24
+ export function espacementDe(env = process.env) {
25
+ const v = env[VARIABLE_ESPACEMENT];
26
+ if (v === undefined || v === '') {
27
+ return ESPACEMENT_MS;
28
+ }
29
+ if (!/^\d+$/.test(v)) {
30
+ throw new Error(
31
+ `${VARIABLE_ESPACEMENT} vaut « ${v} » : un nombre de millisecondes est attendu.`
32
+ );
33
+ }
34
+ return Number(v);
35
+ }
36
+
12
37
  // 11.2 → « 11,2 », 4 → « 4 ».
13
38
  const nombre = n => (Number.isInteger(n) ? String(n) : n.toFixed(1).replace('.', ','));
14
39
 
@@ -51,11 +76,21 @@ export function admission({ coeurs, charge, memoireLibre }) {
51
76
  * mesurer: () => { coeurs: number, charge: number, memoireLibre: number } }} o
52
77
  * @returns {string | null}
53
78
  */
54
- export function refusDeLaPlace(etat, { id, rang, plafond, espacementMs, maintenant, mesurer }) {
79
+ export function refusDeLaPlace(
80
+ etat,
81
+ { id, rang, plafond, espacementMs, maintenant, mesurer, jeton = null }
82
+ ) {
83
+ const reservation = etat.reservation ?? null;
84
+ if (reservation && jeton !== reservation.jeton) {
85
+ return 'la nuit tient la machine : la place est donnée à la fin des nuits';
86
+ }
55
87
  if (etat.prises.length >= plafond) {
56
88
  return `aucune place libre : ${etat.prises.length} prises sur ${plafond}`;
57
89
  }
58
- const avant = etat.attentes.find(a => a.id !== id && a.rang < rang);
90
+ // Under a reservation, only the waits of the night count for the turn: the others wait for it.
91
+ const avant = etat.attentes.find(
92
+ a => a.id !== id && a.rang < rang && (!reservation || (a.jeton ?? null) === reservation.jeton)
93
+ );
59
94
  if (avant) {
60
95
  return `place réservée : ${avant.ticket ?? 'un départ'} est arrivé avant et attend (${avant.raison})`;
61
96
  }
@@ -73,6 +108,30 @@ export function refusDeLaPlace(etat, { id, rang, plafond, espacementMs, maintena
73
108
  /** A place of a circuit not given by its project's queue for this long is gone, in ms: 10 min. */
74
109
  export const PERIME_MS = 10 * 60_000;
75
110
 
111
+ /**
112
+ * The phase of the night on a state of the places: null without a reservation of the machine;
113
+ * `'attend'` while a place is held that is not one of the night's passes (the stages under way
114
+ * finish); `'en cours'` once none is.
115
+ * @param {{ prises: { jeton?: string | null }[], reservation?: { jeton: string } | null }} etat
116
+ * @returns {'attend' | 'en cours' | null}
117
+ */
118
+ export function phaseDeLaNuit({ prises, reservation = null }) {
119
+ if (!reservation) {
120
+ return null;
121
+ }
122
+ return prises.some(p => (p.jeton ?? null) !== reservation.jeton) ? 'attend' : 'en cours';
123
+ }
124
+
125
+ /**
126
+ * Whether a reservation of the machine is out of date at <maintenant>: its last beat, the one the
127
+ * workflow of the nights renews, is PERIME_MS old, as a place of a circuit is.
128
+ * @param {{ battement: number }} reservation
129
+ * @param {number} maintenant
130
+ * @returns {boolean}
131
+ */
132
+ export const reservationPerimee = (reservation, maintenant) =>
133
+ maintenant - reservation.battement >= PERIME_MS;
134
+
76
135
  /**
77
136
  * The places of the circuits of the machine once a demand comes, as Buildkite bounds its pipelines
78
137
  * in one fleet of agents. The queue of the project <racine> gives its circuits active <vivants>
@@ -99,7 +158,8 @@ export const PERIME_MS = 10 * 60_000;
99
158
  * @param {{ racine: string, vivants?: string[], candidats?: string[], disque?: string | null,
100
159
  * reprise?: { ticket: string, rang: number | null }, groupe?: string,
101
160
  * priorites?: Record<string, { priorite: number, creation: string }> }} demande
102
- * @param {{ rang: number, plafond: number, maintenant: number }} o
161
+ * @param {{ rang: number, plafond: number, maintenant: number, reservee?: boolean }} o `reservee`:
162
+ * the machine is reserved by the night, no place is given
103
163
  */
104
164
  export function reserverDesCircuits(places, demande, o) {
105
165
  const {
@@ -111,7 +171,7 @@ export function reserverDesCircuits(places, demande, o) {
111
171
  groupe,
112
172
  priorites = {},
113
173
  } = demande;
114
- const { plafond, maintenant } = o;
174
+ const { plafond, maintenant, reservee = false } = o;
115
175
  let { rang } = o;
116
176
  const siens = new Set([...vivants, ...candidats]);
117
177
  const garde = c =>
@@ -176,7 +236,8 @@ export function reserverDesCircuits(places, demande, o) {
176
236
  }
177
237
  let tenues = circuits.filter(c => c.accordee).length;
178
238
  for (const c of circuits.filter(x => !x.accordee).sort((a, b) => a.rang - b.rang)) {
179
- if (tenues >= plafond) {
239
+ // Under the reservation of the night no place is new: circuits alive keep theirs.
240
+ if (reservee || tenues >= plafond) {
180
241
  break;
181
242
  }
182
243
  if (c.raison) {
@@ -32,6 +32,7 @@ export const SOUS_COMMANDES = {
32
32
  'attente-a-l-arret': 'attente-a-l-arret.mjs',
33
33
  'attente-au-tour': 'attente-au-tour.mjs',
34
34
  bilan: 'bilan.mjs',
35
+ binaires: 'binaires.mjs',
35
36
  circuit: '../dist/temporal/circuit/commande.js',
36
37
  commande: 'verrous/commande.mjs',
37
38
  'composants-affectes': 'composants-affectes.mjs',