@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
@@ -8,6 +8,8 @@
8
8
  // node places-du-serveur.mjs rendre <id>
9
9
  // node places-du-serveur.mjs rattacher <id> <pid> <depart>
10
10
  // node places-du-serveur.mjs lire
11
+ // node places-du-serveur.mjs fermer
12
+ // node places-du-serveur.mjs rouvrir
11
13
  //
12
14
  // - Each mode first starts the workflow of the machine when none runs (`demarrerLesPlaces`, on the
13
15
  // task queue of the worker of the machine), its spacing GRILLHOUSE_ESPACEMENT_MS
@@ -19,7 +21,9 @@
19
21
  // given, `{ id, rang }`. At the bound <borneMs>, the request is withdrawn, its line said, exit 75.
20
22
  // - `rendre` gives the place <id> back (or withdraws its request), `rattacher` names the process
21
23
  // that holds it; `lire` writes the places as the board reads them (`{ plafond, faute, prises,
22
- // attentes }`).
24
+ // attentes }`); `fermer` and `rouvrir` close and reopen the machine (the supervisor's
25
+ // reservation), and write their issue (`fermee`, `deja-fermee`, `nuit-tient`; `rouverte`,
26
+ // `deja-ouverte`, `nuit-tient`).
23
27
  // - Each call waits DELAI_MS for the server, and is played again ESSAIS times when it fails
24
28
  // transiently. Still failing, its port open: the server is busy, said on the error stream, exit
25
29
  // 75. A port refused (no server), another failure, or a client not built: said on the error
@@ -30,7 +34,10 @@ import net from 'node:net';
30
34
  import path from 'node:path';
31
35
  import { pathToFileURL } from 'node:url';
32
36
  import { A_REPASSER } from './codes-de-sortie.mjs';
33
- import { duree } from './regles-des-places.mjs';
37
+ import { duree, RAISON_FERMEE } from './regles-des-places.mjs';
38
+
39
+ // The start of the reason of a wait under the supervisor's closure.
40
+ const RAISON_FERMEE_DEBUT = RAISON_FERMEE.split(' : ')[0];
34
41
 
35
42
  const DIST = path.join(import.meta.dirname, '..', 'dist', 'temporal');
36
43
  // How long a call waits for the server to answer, each attempt.
@@ -110,12 +117,19 @@ const entreeDe = async env => {
110
117
  return { espacementMs: espacementDe(env), veilleMs: 1_000 };
111
118
  };
112
119
 
113
- const MODES = { rang: 0, prendre: 1, rendre: 1, rattacher: 3, lire: 0 };
120
+ const MODES = { rang: 0, prendre: 1, rendre: 1, rattacher: 3, lire: 0, fermer: 0, rouvrir: 0 };
114
121
  const ecrire = o => process.stdout.write(`${JSON.stringify(o)}\n`);
115
122
 
116
123
  // The wait of the request <id> for its place, under the handle <h> of the workflow of the
117
- // machine, its lines said: 0 once given, 75 at the bound <borneMs>, the request withdrawn.
118
- async function attendreLaPlace(c, places, { h, id, rang, borneMs, rappelMs, sous, LA_DEMANDE }) {
124
+ // machine, its lines said: 0 once given, 75 at the bound <borneMs>, the request withdrawn. Under the
125
+ // supervisor's closure the bound does not apply: the wait lasts until the reopening, where the
126
+ // request is judged again (as `drain` waits, and a node cordoned keeps its pods). Exported for its
127
+ // test.
128
+ export async function attendreLaPlace(
129
+ c,
130
+ places,
131
+ { h, id, rang, borneMs, rappelMs, sous, LA_DEMANDE }
132
+ ) {
119
133
  const debut = Date.now();
120
134
  let dit = null;
121
135
  for (;;) {
@@ -131,7 +145,8 @@ async function attendreLaPlace(c, places, { h, id, rang, borneMs, rappelMs, sous
131
145
  throw new Error(`la demande de place ${id} n'est plus : retirée, ou son processus a disparu`);
132
146
  }
133
147
  const t = Date.now();
134
- if (t - debut >= borneMs) {
148
+ const fermee = e.raison?.startsWith(RAISON_FERMEE_DEBUT) ?? false;
149
+ if (!fermee && t - debut >= borneMs) {
135
150
  await sous(() => places.rendreLaPlace(c.client, id));
136
151
  ecrire({
137
152
  dire: `⏱ attente de place bornée à ${duree(borneMs)} (GRILLHOUSE_ATTENTE_MACHINE_MS) : ${e.raison} ; à repasser (code ${A_REPASSER}).`,
@@ -139,7 +154,9 @@ async function attendreLaPlace(c, places, { h, id, rang, borneMs, rappelMs, sous
139
154
  return A_REPASSER;
140
155
  }
141
156
  if (dit === null) {
142
- ecrire({ dire: `⏳ attente d'une place : ${e.raison} ; ${duree(borneMs)} au plus.` });
157
+ ecrire({
158
+ dire: `⏳ attente d'une place : ${e.raison} ; ${fermee ? 'sans borne jusqu’à la réouverture' : `${duree(borneMs)} au plus`}.`,
159
+ });
143
160
  dit = t;
144
161
  } else if (t - dit >= rappelMs) {
145
162
  ecrire({ dire: `⏳ attente d'une place depuis ${duree(t - debut)} : ${e.raison}.` });
@@ -153,7 +170,7 @@ async function attendreLaPlace(c, places, { h, id, rang, borneMs, rappelMs, sous
153
170
  async function principal(mode, args) {
154
171
  if (!Object.hasOwn(MODES, mode ?? '') || args.length !== MODES[mode]) {
155
172
  process.stderr.write(
156
- 'usage : places-du-serveur.mjs rang | prendre <demande> | rendre <id> | rattacher <id> <pid> <depart> | lire\n'
173
+ 'usage : places-du-serveur.mjs rang | prendre <demande> | rendre <id> | rattacher <id> <pid> <depart> | lire | fermer | rouvrir\n'
157
174
  );
158
175
  return 2;
159
176
  }
@@ -197,6 +214,10 @@ async function principal(mode, args) {
197
214
  );
198
215
  } else if (mode === 'lire') {
199
216
  ecrire(await sous(() => places.lireLesPlaces(c.client)));
217
+ } else if (mode === 'fermer') {
218
+ ecrire(await sous(() => places.fermerLaMachine(c.client)));
219
+ } else if (mode === 'rouvrir') {
220
+ ecrire(await sous(() => places.rouvrirLaMachine(c.client)));
200
221
  } else {
201
222
  const { borneMs, rappelMs, ...demande } = JSON.parse(args[0]);
202
223
  const h = c.client.workflow.getHandle(ID_DES_PLACES);
@@ -0,0 +1,18 @@
1
+ // The key `grillhouse.poussee` is retired from the frame: one branch, main, receives every lot (the
2
+ // trunk-based development of Google and Chromium). This one reading serves the queue
3
+ // (scripts/integration/file.mjs), the night (scripts/nuit.sh) and the pre-push guard
4
+ // (scripts/branche-de-nuit.mjs): whatever the value of the key (null, an object, a string), the
5
+ // project that carries it is refused by its name, with the gesture (remove the key).
6
+
7
+ /**
8
+ * The refusal line of a package.json that carries `grillhouse.poussee`, or null without it.
9
+ * @param {unknown} pkg
10
+ * @returns {string | null}
11
+ */
12
+ export function pousseeRetiree(pkg) {
13
+ const grillhouse = pkg?.grillhouse;
14
+ if (!grillhouse || typeof grillhouse !== 'object' || !Object.hasOwn(grillhouse, 'poussee')) {
15
+ return null;
16
+ }
17
+ return 'La clé grillhouse.poussee est retirée du cadre : main reçoit seule chaque lot. Retire-la du package.json (npm pkg delete grillhouse.poussee).';
18
+ }
@@ -37,7 +37,7 @@ export interface LigneDuRegistre {
37
37
  cache: number;
38
38
  cout: number | null;
39
39
  cle?: string;
40
- nuit?: { verdict: 'sautee'; raison: string; sommet: string; reference: string };
40
+ nuit?: { verdict: 'sautee'; raison: string; sommet: string; reference: string | null };
41
41
  }
42
42
 
43
43
  /** The register's file: GRILLHOUSE_REGISTRE, else ~/.claude/grillhouse/registre.jsonl. */
@@ -77,7 +77,7 @@ export function ligneDeNuit(e: {
77
77
  quand: string;
78
78
  raison: string;
79
79
  sommet: string;
80
- reference: string;
80
+ reference: string | null;
81
81
  }): LigneDuRegistre;
82
82
  export function aRattraper(
83
83
  racine: string,
@@ -38,7 +38,7 @@ export function refusDeLaPlace(
38
38
  jeton?: string | null;
39
39
  }[];
40
40
  dernier: number;
41
- reservation?: { jeton: string } | null;
41
+ reservation?: { jeton: string; auteur?: 'nuit' | 'superviseur' } | null;
42
42
  },
43
43
  o: {
44
44
  id: string;
@@ -88,20 +88,51 @@ export function refusDePart(
88
88
  part: PartDeLaPasse;
89
89
  budget: PartDeLaPasse;
90
90
  mesurer: () => MesureDeLaMachine;
91
+ dediee?: boolean;
92
+ /** The reservation of the machine read this turn, null without. */
93
+ reservation?: { auteur?: 'nuit' | 'superviseur'; jeton: string } | null;
94
+ /** The jeton of the night the pass carries (its variable), null without. */
95
+ jeton?: string | null;
91
96
  }
92
97
  ): string | null;
93
98
 
99
+ /** Why a pass waits under the supervisor's closure of the machine. */
100
+ export const RAISON_DE_LA_FERMETURE: string;
101
+ /** Why a pass without the jeton of the night waits under its reservation. */
102
+ export const RAISON_DE_LA_NUIT: string;
103
+
94
104
  /** A place of a circuit not given by its project's queue for this long is gone, in ms: 10 min. */
95
105
  export const PERIME_MS: number;
96
106
 
97
- /** The phase of the night on the places: none without a reservation, waiting, or under way. */
107
+ /** The reservation of the machine: the night's (absent author) or the supervisor's closure. */
108
+ export interface ReservationDeLaMachine {
109
+ auteur?: 'nuit' | 'superviseur';
110
+ jeton: string;
111
+ depuis: number;
112
+ /** The night's last beat; the supervisor's closure has none. */
113
+ battement?: number;
114
+ }
115
+
116
+ /** The phase of a reservation: none without one, waiting, under way (night) or empty (closure). */
117
+ export function phaseDeLaReservation(etat: {
118
+ prises: readonly { id?: string; jeton?: string | null }[];
119
+ reservation?: { jeton: string; auteur?: 'nuit' | 'superviseur' } | null;
120
+ }): 'attend' | 'en cours' | 'vide' | null;
121
+
122
+ /** The phase of the night on the places: none without a reservation or under a closure. */
98
123
  export function phaseDeLaNuit(etat: {
99
124
  prises: readonly { id?: string; jeton?: string | null }[];
100
- reservation?: { jeton: string } | null;
125
+ reservation?: { jeton: string; auteur?: 'nuit' | 'superviseur' } | null;
101
126
  }): 'attend' | 'en cours' | null;
102
127
 
103
- /** Whether a reservation's last beat is PERIME_MS old at <maintenant>. */
104
- export function reservationPerimee(reservation: { battement: number }, maintenant: number): boolean;
128
+ /** Whether a reservation's last beat is PERIME_MS old at <maintenant>; a closure never is. */
129
+ export function reservationPerimee(
130
+ reservation: { battement?: number; auteur?: 'nuit' | 'superviseur' },
131
+ maintenant: number
132
+ ): boolean;
133
+
134
+ /** Why a place waits under the supervisor's closure. */
135
+ export const RAISON_FERMEE: string;
105
136
 
106
137
  /** The place of a circuit of the machine: held (`accordee`) or waited for, its rank of arrival. */
107
138
  export interface PlaceDeCircuit {
@@ -12,6 +12,9 @@ export const MEMOIRE_MIN = 4 * 1024 ** 3;
12
12
  export const VARIABLE_ESPACEMENT = 'GRILLHOUSE_ESPACEMENT_MS';
13
13
  /** The jeton of the reservation of the machine by the night, which the passes of the night carry. */
14
14
  export const VARIABLE_JETON = 'GRILLHOUSE_JETON_DE_LA_NUIT';
15
+ /** Why a place waits under the closure of the machine by the supervisor (`cordon` of kubectl). */
16
+ export const RAISON_FERMEE =
17
+ 'machine fermée par le superviseur : la place est donnée à la réouverture';
15
18
  /** The gap between two starts when GRILLHOUSE_ESPACEMENT_MS names none, in ms. */
16
19
  export const ESPACEMENT_MS = 10_000;
17
20
 
@@ -81,6 +84,11 @@ export function refusDeLaPlace(
81
84
  { id, rang, plafond, espacementMs, maintenant, mesurer, jeton = null }
82
85
  ) {
83
86
  const reservation = etat.reservation ?? null;
87
+ // The supervisor's closure gives no place to anyone, its own jeton included: no pass nor session
88
+ // carries it.
89
+ if (reservation?.auteur === 'superviseur') {
90
+ return RAISON_FERMEE;
91
+ }
84
92
  if (reservation && jeton !== reservation.jeton) {
85
93
  return 'la nuit tient la machine : la place est donnée à la fin des nuits';
86
94
  }
@@ -156,6 +164,11 @@ export function admissionDePart({ part, budget, prises, mesure }) {
156
164
  : { ...a, attend: mesure.charge >= mesure.coeurs ? 'charge' : 'mémoire' };
157
165
  }
158
166
 
167
+ /** Why a pass waits under the supervisor's closure of the machine. */
168
+ export const RAISON_DE_LA_FERMETURE = 'machine fermée par le superviseur';
169
+ /** Why a pass without the jeton of the night waits under its reservation. */
170
+ export const RAISON_DE_LA_NUIT = 'la nuit tient la machine';
171
+
159
172
  /**
160
173
  * Why the pass <id> of the rank <rang> does not take its part <part> now on the state <etat>
161
174
  * (`prises`, `attentes`), null when it does: its part does not fit in the <budget>; a wait of a
@@ -173,7 +186,20 @@ export function admissionDePart({ part, budget, prises, mesure }) {
173
186
  * mesurer: () => { coeurs: number, charge: number, memoireLibre: number } }} o
174
187
  * @returns {string | null}
175
188
  */
176
- export function refusDePart(etat, { id, rang, part, budget, mesurer, dediee = false }) {
189
+ export function refusDePart(
190
+ etat,
191
+ { id, rang, part, budget, mesurer, dediee = false, reservation = null, jeton = null }
192
+ ) {
193
+ // A closed machine gives no new work (`cordon` of kubectl): the supervisor's closure refuses
194
+ // every pass, whatever its jeton; the night's reservation refuses the pass without its jeton.
195
+ if (reservation) {
196
+ if (reservation.auteur === 'superviseur') {
197
+ return RAISON_DE_LA_FERMETURE;
198
+ }
199
+ if (jeton !== reservation.jeton) {
200
+ return RAISON_DE_LA_NUIT;
201
+ }
202
+ }
177
203
  const prises = etat.prises.filter(p => p.id !== id);
178
204
  // Two measures of time never play side by side: each would be the load the other is judged on.
179
205
  const autre = dediee ? prises.find(p => p.dediee) : undefined;
@@ -200,28 +226,49 @@ export function refusDePart(etat, { id, rang, part, budget, mesurer, dediee = fa
200
226
  export const PERIME_MS = 10 * 60_000;
201
227
 
202
228
  /**
203
- * The phase of the night on a state of the places: null without a reservation of the machine;
229
+ * The phase of a reservation of the machine, whoever its author: null without a reservation;
204
230
  * `'attend'` while a place is held that is not one of the night's passes (the stages under way
205
- * finish); `'en cours'` once none is.
206
- * @param {{ prises: { jeton?: string | null }[], reservation?: { jeton: string } | null }} etat
207
- * @returns {'attend' | 'en cours' | null}
231
+ * finish); then `'en cours'` for the night, `'vide'` for the supervisor's closure (it holds no
232
+ * place itself: every place held waits to be given back).
233
+ * @param {{ prises: { jeton?: string | null }[],
234
+ * reservation?: { jeton: string, auteur?: 'nuit' | 'superviseur' } | null }} etat
235
+ * @returns {'attend' | 'en cours' | 'vide' | null}
208
236
  */
209
- export function phaseDeLaNuit({ prises, reservation = null }) {
237
+ export function phaseDeLaReservation({ prises, reservation = null }) {
210
238
  if (!reservation) {
211
239
  return null;
212
240
  }
241
+ if (reservation.auteur === 'superviseur') {
242
+ return prises.length > 0 ? 'attend' : 'vide';
243
+ }
213
244
  return prises.some(p => (p.jeton ?? null) !== reservation.jeton) ? 'attend' : 'en cours';
214
245
  }
215
246
 
247
+ /**
248
+ * The phase of the night on a state of the places: that of its reservation, null without one or
249
+ * when the reservation is the supervisor's closure, which is not a night.
250
+ * @param {{ prises: { jeton?: string | null }[],
251
+ * reservation?: { jeton: string, auteur?: 'nuit' | 'superviseur' } | null }} etat
252
+ * @returns {'attend' | 'en cours' | null}
253
+ */
254
+ export function phaseDeLaNuit(etat) {
255
+ if (etat.reservation?.auteur === 'superviseur') {
256
+ return null;
257
+ }
258
+ const phase = phaseDeLaReservation(etat);
259
+ return phase === 'vide' ? null : phase;
260
+ }
261
+
216
262
  /**
217
263
  * Whether a reservation of the machine is out of date at <maintenant>: its last beat, the one the
218
- * workflow of the nights renews, is PERIME_MS old, as a place of a circuit is.
219
- * @param {{ battement: number }} reservation
264
+ * workflow of the nights renews, is PERIME_MS old, as a place of a circuit is. The supervisor's
265
+ * closure has no beat and never goes out of date, as `cordon` has no delay.
266
+ * @param {{ battement?: number, auteur?: 'nuit' | 'superviseur' }} reservation
220
267
  * @param {number} maintenant
221
268
  * @returns {boolean}
222
269
  */
223
270
  export const reservationPerimee = (reservation, maintenant) =>
224
- maintenant - reservation.battement >= PERIME_MS;
271
+ reservation.auteur !== 'superviseur' && maintenant - (reservation.battement ?? 0) >= PERIME_MS;
225
272
 
226
273
  /**
227
274
  * The places of the circuits of the machine once a demand comes, as Buildkite bounds its pipelines
@@ -4,6 +4,8 @@
4
4
  export const SANS_ISSUE: Set<string>;
5
5
  /** The answers accepted for the circuit of <ticket> whose workflow has the status <statut>. */
6
6
  export function lesReponses(ticket: string, statut: string, ecrit: boolean): string;
7
+ /** The hour `bd update --defer` receives for `--reporter <heure>`, and the phrase of its texts. */
8
+ export function heureDuReport(heure: string, maintenant: Date): { defer: string; quand: string };
7
9
  /** The stops of the testwriter that `--mecanique` answers. */
8
10
  export const ARRETS_DU_TESTWRITER: string[];
9
11
  /** The sort of a ticket, as the plan says it (scripts/resultats.mjs `sorteDuPlan`). */
@@ -33,6 +33,32 @@ export function lesReponses(ticket, statut, ecrit) {
33
33
  : `${circuit} --reprendre\`, \`${depuis}\`, \`${mecanique}\` ou \`${etendre}`;
34
34
  }
35
35
 
36
+ /**
37
+ * The hour of a deferral (`--reporter <heure>`): a lone hour (`H:MM` or `HH:MM`, 0-23 and 00-59)
38
+ * aims at its next occurrence in the machine's local time, today when strictly after <maintenant>
39
+ * (to the second), else tomorrow, and is handed to `bd update --defer` as `AAAA-MM-JJ HH:MM`; any
40
+ * other form goes to bd as written. `quand` is the phrase of the texts (« reportée <quand> »).
41
+ * @param {string} heure
42
+ * @param {Date} maintenant
43
+ * @returns {{ defer: string, quand: string }}
44
+ */
45
+ export function heureDuReport(heure, maintenant) {
46
+ const lue = /^(\d{1,2}):([0-5]\d)$/.exec(heure);
47
+ if (!lue || Number(lue[1]) > 23) {
48
+ return { defer: heure, quand: `au ${heure}` };
49
+ }
50
+ const cible = new Date(maintenant);
51
+ cible.setHours(Number(lue[1]), Number(lue[2]), 0, 0);
52
+ const demain = cible.getTime() <= maintenant.getTime();
53
+ if (demain) {
54
+ cible.setDate(cible.getDate() + 1);
55
+ }
56
+ const deux = (n) => String(n).padStart(2, '0');
57
+ const hhmm = `${deux(cible.getHours())}:${deux(cible.getMinutes())}`;
58
+ const defer = `${cible.getFullYear()}-${deux(cible.getMonth() + 1)}-${deux(cible.getDate())} ${hhmm}`;
59
+ return { defer, quand: demain ? `à demain ${hhmm}` : `au ${heure}` };
60
+ }
61
+
36
62
  /**
37
63
  * The answer `--mecanique [<commande>] --contexte <raison>` to the stop <etat> (`{ etape, raison }`)
38
64
  * of a ticket of sort <sorte>: a refusal `{ refus }` unless the ticket is stopped on the testwriter
@@ -137,6 +137,7 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSy
137
137
  import path from 'node:path';
138
138
  import { pathToFileURL } from 'node:url';
139
139
  import { paquets } from './paquets.mjs';
140
+ import { AUTEUR_DU_CIRCUIT, EXPLORATEUR } from './etapes.mjs';
140
141
 
141
142
  // The variable that names the results directory of a run.
142
143
  export const RESULTATS = 'GRILLHOUSE_RESULTATS';
@@ -540,6 +541,45 @@ export function sorteDuPlan(fiche) {
540
541
  };
541
542
  }
542
543
 
544
+ // The sheet of the plan that says its field <champ> (`sorte`, `noms_publies`) among the
545
+ // explorateur's sheets of the plan <plans>, in their order (`{ fiche, reponse }` entries): the last
546
+ // one, or, when it is his answer to the questionneur (`reponse`) and says none, the plan it
547
+ // answers, so that the field survives the answer; null without a sheet of the plan.
548
+ export function ficheDuPlan(plans, champ) {
549
+ const derniere = plans.at(-1);
550
+ if (!derniere) {
551
+ return null;
552
+ }
553
+ if (derniere.reponse && !(champ in derniere.fiche) && plans.length > 1) {
554
+ return plans.at(-2).fiche;
555
+ }
556
+ return derniere.fiche;
557
+ }
558
+
559
+ // Among the kept results of a ticket: a sheet of the plan, the explorateur's with its criteria;
560
+ // a line of the circuit that turns the sort of the ticket (`--mecanique`, « comportement-change »).
561
+ export const estUnPlan = e => e.role === EXPLORATEUR && Array.isArray(e.fiche?.criteres);
562
+ export const estUneBascule = e =>
563
+ e.role === AUTEUR_DU_CIRCUIT && typeof e.sorte === 'object' && e.sorte !== null;
564
+
565
+ /**
566
+ * The sort of a ticket, read from its kept results <tous> in their order: the sort its plan says
567
+ * (`sorteDuPlan` of the sheet `ficheDuPlan` gives), comportement without one; a line that turns the
568
+ * sort after the last sheet of the plan stands over it, the plan kept as it is.
569
+ * @param {any[]} tous
570
+ */
571
+ export function sorteDesFiches(tous) {
572
+ const bascule = tous.findLastIndex(estUneBascule);
573
+ if (bascule > tous.findLastIndex(estUnPlan)) {
574
+ return tous[bascule].sorte;
575
+ }
576
+ return sorteDuPlan(ficheDuPlan(tous.filter(estUnPlan), 'sorte'));
577
+ }
578
+
579
+ /** Whether a ticket of the sort <sorte> takes the short circuit: a mechanical gesture a command plays, or one written by hand. */
580
+ export const estLeCircuitCourt = sorte =>
581
+ sorte?.genre === 'mécanique' || sorte?.comportement === 'inchangé';
582
+
543
583
  // The errors of <valeur> against <schema>, each naming its field by its path <ou>.
544
584
  function erreurs(schema, valeur, ou) {
545
585
  const nom = ou || 'la fiche';
@@ -20,8 +20,9 @@
20
20
  import { existsSync } from 'node:fs';
21
21
  import path from 'node:path';
22
22
  import { fileURLToPath } from 'node:url';
23
- import { langageDe } from './langages.mjs';
23
+ import { langageDe, langagesDe } from './langages.mjs';
24
24
  import { avecLesDonnees, donneesDe } from './donnees-cles.mjs';
25
+ import { matieresDeclareesDe } from './matieres-cles.mjs';
25
26
  import { avecLesOutils, empreintesDe, outilsDe } from './outils-cles.mjs';
26
27
 
27
28
  const SCRIPTS = path.dirname(fileURLToPath(import.meta.url));
@@ -52,6 +53,7 @@ export const SOUS_COMMANDES = {
52
53
  lancer: 'enveloppe/lancer.sh',
53
54
  journal: 'journal.mjs',
54
55
  'ligne-etat': 'ligne-etat/ligne-etat.mjs',
56
+ machine: 'machine.mjs',
55
57
  maj: 'grillhouse-maj.mjs',
56
58
  'messages-non-lus': 'messages-non-lus.mjs',
57
59
  newday: 'newday.mjs',
@@ -115,7 +117,17 @@ export function commandeDe(nom, racine = process.cwd()) {
115
117
  }
116
118
  const commandes = langageDe(racine).commandes(racine);
117
119
  const n = s?.langage ?? (DU_NOYAU.has(nom) ? null : nom);
118
- return n !== null && Object.hasOwn(commandes, n) ? commandes[n] : null;
120
+ if (n === null || !Object.hasOwn(commandes, n)) {
121
+ return null;
122
+ }
123
+ // The verification of a project whose one module is not the one of package.json (cargo alone,
124
+ // python alone) goes by the composed command, which keeps its last green and its judged tree: no
125
+ // pass of the graph does it there (scripts/commandes-composees.mjs, `garderSansLeGraphe`).
126
+ const modules = langagesDe(racine);
127
+ if (n === 'verifier' && modules.length === 1 && modules[0].manifeste !== 'package.json') {
128
+ return { script: path.join(SCRIPTS, 'commandes-composees.mjs'), args: [n] };
129
+ }
130
+ return commandes[n];
119
131
  }
120
132
 
121
133
  /**
@@ -154,6 +166,7 @@ export function environnementDe(nom, racine = process.cwd(), env = process.env)
154
166
  if (typeof SOUS_COMMANDES[nom] === 'string') {
155
167
  return env;
156
168
  }
169
+ matieresDeclareesDe(racine);
157
170
  const poste = langageDe(racine).environnementDuPoste(env);
158
171
  return avecLesDonnees(
159
172
  donneesDe(racine),
@@ -65,19 +65,15 @@ import { spawnSync } from 'node:child_process';
65
65
  import { mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
66
66
  import path from 'node:path';
67
67
  import { pathToFileURL } from 'node:url';
68
- import { alerteDuProjet, ciDeMainGardee } from './ci-de-main.mjs';
68
+ import { lireEtOuvrirLeDefautDeMain } from './ci-de-main.mjs';
69
69
  import { lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
70
70
  import { vivant } from './mesure/base-de-passe.mjs';
71
71
  import { circuitsDuServeur, ServeurMuet } from './circuits-du-serveur.mjs';
72
- import {
73
- attendLeSuperviseur,
74
- cleDe,
75
- lireLesRemontees,
76
- remonteesDe,
77
- } from './tableau.mjs';
72
+ import { attendLeSuperviseur, cleDe, lireLesRemontees, remonteesDe } from './tableau.mjs';
78
73
  import { rappelDuProjet, reglageDuRappel } from './circuits-cles.mjs';
79
74
  import { lireGroupe } from './groupe-cles.mjs';
80
- import { etapeDuCircuit, libelle, SUPERVISEUR } from './etapes.mjs';
75
+ import { etapeDuCircuit, libelle, REPONSES, sansLesReponses, SUPERVISEUR } from './etapes.mjs';
76
+ import { sigleDuProjet } from './sigle-du-projet.mjs';
81
77
  import { enFileSansArchitecture, lireLesTickets } from './file-des-tickets.mjs';
82
78
 
83
79
  const VERROU_SUPERVISEUR = 'grillhouse-superviseur.lock';
@@ -211,13 +207,9 @@ function lireLesIntegrations(racine, maintenant) {
211
207
  // supervisor: `{ cle, texte }` for a red or a CI not read, null for a green (the alert clears),
212
208
  // undefined for a project with no CI to read. The lots entered since the last green are named by
213
209
  // git; nothing is kept but the reading, for five minutes.
214
- export function ciDeMainDe(racine) {
215
- const lecture = ciDeMainGardee(racine);
216
- if (!lecture) {
217
- return undefined;
218
- }
219
- const a = alerteDuProjet(racine, lecture);
220
- return a ? { cle: a.cle, texte: a.texte } : null;
210
+ export function ciDeMainDe(racine, o = {}) {
211
+ const a = lireEtOuvrirLeDefautDeMain(racine, o);
212
+ return a ? { cle: a.cle, texte: a.texte } : a;
221
213
  }
222
214
 
223
215
  // The alert of the CI of main given by the waits of the repository at <racine>, its key: kept while
@@ -311,14 +303,18 @@ export function relever(
311
303
  try {
312
304
  const { depuis: depuisIntegrations, rendues } = lireLesIntegrations(racine, maintenant);
313
305
  const integres = circuits
314
- .filter(c => c.integre && c.fin !== null && c.fin >= depuisIntegrations && !rendues.has(cleDe(c)))
306
+ .filter(
307
+ c => c.integre && c.fin !== null && c.fin >= depuisIntegrations && !rendues.has(cleDe(c))
308
+ )
315
309
  .map(enFin)
316
310
  .sort((a, b) => a.ticket.localeCompare(b.ticket, 'en'));
317
311
  const fins = new Map(circuits.map(c => [cleDe(c), c.fin]));
318
312
  ecrireLesIntegrations(
319
313
  racine,
320
314
  maintenant,
321
- [...rendues, ...integres.map(i => i.cle)].filter(k => (fins.get(k) ?? -Infinity) >= maintenant)
315
+ [...rendues, ...integres.map(i => i.cle)].filter(
316
+ k => (fins.get(k) ?? -Infinity) >= maintenant
317
+ )
322
318
  );
323
319
  const rouges = ciDeMain === undefined ? [] : releverLaCiDeMain(racine, ciDeMain, toutes);
324
320
  circuits = circuits.filter(c => !c.integre);
@@ -459,13 +455,46 @@ export function questionsEnAttente(
459
455
  // No ticket closed: the questions read without asking bd.
460
456
  const aucunFerme = () => new Set();
461
457
 
462
- // The lines of one question in the one rendering of the questions, shared by the message of the
463
- // greffon, the opening and the hooks of the session.
464
- export const ligneDeQuestion = q =>
458
+ // The command that answers the question <q>, played from <dossier> when it is another project's:
459
+ // the command of the circuit of its ticket, its answer left to the supervisor (the answers are
460
+ // listed once, at the opening of the session), or the command of a question of no circuit (the CI
461
+ // of main), as it is.
462
+ const commandeDe = (q, dossier) => {
463
+ const duCircuit = `npx grillhouse circuit ${q.ticket}`;
464
+ const commande = String(q.commande ?? '').startsWith(`${duCircuit} `)
465
+ ? `${duCircuit} <réponse>`
466
+ : String(q.commande ?? '');
467
+ return commande && dossier ? `env -C ${dossier} ${commande}` : commande;
468
+ };
469
+
470
+ // The head of the line of <q>: what it is, its ticket, its step, its stop, and who answers it when
471
+ // it is not the supervisor; under the sigle of its project (<o.sigle>) when it is another one's.
472
+ const teteDe = (q, genre, { sigle } = {}) =>
465
473
  [
466
- `- ${q.ticket}, à ${q.etape}, au ${q.qui}${q.representee ? ' (toujours sans réponse)' : ''} : ${q.question.replace(/\n/g, '\n ')}`,
467
- ` La réponse : \`${q.commande}\`.`,
468
- ].join('\n');
474
+ `${sigle ? `[${sigle}] ` : ''}${genre}`,
475
+ q.ticket,
476
+ q.etape,
477
+ ...(q.arret ? [q.arret] : []),
478
+ ...(q.qui && q.qui !== SUPERVISEUR ? [`au ${q.qui}`] : []),
479
+ ].join(' · ');
480
+
481
+ /**
482
+ * The lines of one question in the one rendering of the questions, shared by the message of the
483
+ * greffon, the opening and the hooks of the session: its head, its question without the list of
484
+ * the answers, and the command that answers it. A question presented again (`representee`) is its
485
+ * head alone, and one that waits at a hook of the session too (<o.courte>). <o.sigle> and
486
+ * <o.dossier> name the project of the question when it is not the session's.
487
+ */
488
+ export const ligneDeQuestion = (q, o = {}) => {
489
+ if (q.representee) {
490
+ return teteDe(q, 'Toujours sans réponse', o);
491
+ }
492
+ const tete = teteDe(q, 'Question', o);
493
+ const commande = commandeDe(q, o.dossier);
494
+ return o.courte
495
+ ? tete
496
+ : [tete, sansLesReponses(q.question), ...(commande ? [`→ ${commande}`] : [])].join('\n');
497
+ };
469
498
 
470
499
  /**
471
500
  * The message the greffon submits to the session of supervision for the questions <questions> of
@@ -476,33 +505,12 @@ export const ligneDeQuestion = q =>
476
505
  * @param {{ ticket: string, etape: string, question: string, qui: string, commande: string, representee?: boolean, integre?: boolean }[]} questions
477
506
  * @returns {string}
478
507
  */
479
- export function texteDesQuestions(questions) {
508
+ export function texteDesQuestions(questions, o = {}) {
480
509
  const fins = questions.filter(q => q.integre);
481
510
  const attente = questions.filter(q => !q.integre);
482
- const neuves = attente.filter(q => !q.representee);
483
- const titre = neuves.length
484
- ? attente.length > 1
485
- ? '## Questions neuves des circuits'
486
- : "## Question neuve d'un circuit"
487
- : attente.length > 1
488
- ? '## Questions toujours sans réponse'
489
- : '## Question toujours sans réponse';
490
- const enQuestions = attente.length
491
- ? [
492
- titre,
493
- ...attente.map(ligneDeQuestion),
494
- ]
495
- : [];
496
- const enFins = fins.length
497
- ? [
498
- fins.length > 1 ? '## Circuits intégrés' : '## Circuit intégré',
499
- ...fins.map(q => `- ${q.ticket} est intégré, à ${q.etape} : son lot est sur main.`),
500
- ]
501
- : [];
502
511
  return [
503
- ...enQuestions,
504
- ...(enQuestions.length && enFins.length ? [''] : []),
505
- ...enFins,
512
+ ...attente.map(q => ligneDeQuestion(q, o)),
513
+ ...fins.map(q => `${o.sigle ? `[${o.sigle}] ` : ''}Intégré · ${q.ticket}`),
506
514
  ].join('\n');
507
515
  }
508
516
 
@@ -580,6 +588,7 @@ export async function circuitsALOuverture(
580
588
  "Le greffon de ta séance pousse dans la file de tes messages chaque question neuve d'un circuit du dépôt, quel que soit son lanceur, et chaque fin de circuit, une fois ; il n'y a aucune attente à lancer. Une question sans réponse revient à intervalle réglable (`grillhouse.rappel`, 5 min par défaut) : ta réponse au circuit l'acquitte, et répondue elle ne revient plus. Tu ne te mets pas en attente du responsable tant qu'une question d'un circuit attend ta réponse : le crochet de fin de tour te le rappelle. Les questions en attente sont listées ci-dessous.",
581
589
  ...(panne ? ['', '## Les circuits du dépôt', panne] : []),
582
590
  ...(nommes.length ? ['', '## Les circuits du dépôt', ...nommes.map(n => n.ligne)] : []),
591
+ ...(questions.length ? ['', `Les réponses à une question : ${REPONSES}`] : []),
583
592
  ...(sansArchitecture.length
584
593
  ? [
585
594
  '',
@@ -693,15 +702,9 @@ export async function releverPourLeGreffon(
693
702
  }
694
703
  const parts = [await leReleveDe(racine, circuitsDe)];
695
704
  for (const p of voisinsSansSuperviseur(racine)) {
696
- const texte = await leReleveDe(p.chemin, circuitsDe);
705
+ const texte = await leReleveDe(p.chemin, circuitsDe, true);
697
706
  if (texte) {
698
- parts.push(
699
- [
700
- `# Projet ${p.nom} (${p.chemin})`,
701
- `Ses réponses se jouent dans son dossier : \`env -C ${p.chemin} <la réponse>\`.`,
702
- texte,
703
- ].join('\n')
704
- );
707
+ parts.push(texte);
705
708
  }
706
709
  }
707
710
  return parts.filter(Boolean).join('\n\n');
@@ -719,7 +722,7 @@ function paquetDe(racine) {
719
722
  // The message of one reading of the project at <racine>, under its own interval
720
723
  // (`grillhouse.rappel`) and its own state of the questions presented; empty when it gives nothing
721
724
  // or when its circuits do not read. A faulty interval throws, the project named.
722
- async function leReleveDe(racine, circuitsDe) {
725
+ async function leReleveDe(racine, circuitsDe, voisin = false) {
723
726
  const { minutes, faute } = reglageDuRappel(paquetDe(racine));
724
727
  if (faute) {
725
728
  throw new Error(`${path.basename(racine)} : ${faute}`);
@@ -736,7 +739,11 @@ async function leReleveDe(racine, circuitsDe) {
736
739
  rappelMs: minutes * 60_000,
737
740
  ciDeMain: ciDeMainDe(racine),
738
741
  });
739
- return lot.length ? texteDesQuestions(lot) : '';
742
+ // Another project's part bears its sigle, and its commands the folder they are played in.
743
+ const projet = voisin
744
+ ? { sigle: sigleDuProjet(racine).sigle ?? path.basename(racine), dossier: racine }
745
+ : {};
746
+ return lot.length ? texteDesQuestions(lot, projet) : '';
740
747
  }
741
748
 
742
749
  // The other projects of the group of the project at <racine> (`grillhouse.groupe`) that no other