@roomi-fields/grillhouse 0.47.0 → 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 (102) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +54 -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 +221 -19
  53. package/scripts/circuit.mjs +47 -34
  54. package/scripts/commandes-composees.mjs +36 -6
  55. package/scripts/composition-des-langages.mjs +2 -0
  56. package/scripts/crochets.mjs +2 -2
  57. package/scripts/effets.mjs +2 -1
  58. package/scripts/enveloppe/enveloppe.mjs +61 -6
  59. package/scripts/enveloppe/travail-de-la-copie.mjs +2 -0
  60. package/scripts/etapes.mjs +11 -1
  61. package/scripts/etat-du-depot.mjs +23 -0
  62. package/scripts/faits-du-circuit.mjs +12 -23
  63. package/scripts/fermeture-de-la-machine.d.mts +27 -0
  64. package/scripts/fermeture-de-la-machine.mjs +108 -0
  65. package/scripts/greffons.mjs +1 -1
  66. package/scripts/integration/file.mjs +16 -13
  67. package/scripts/integration/integrer.mjs +2 -0
  68. package/scripts/jointure.d.ts +5 -0
  69. package/scripts/langages/c/index.mjs +2 -0
  70. package/scripts/langages/c/squelette.mjs +1 -1
  71. package/scripts/langages/cargo/index.mjs +2 -0
  72. package/scripts/langages/python/index.mjs +2 -0
  73. package/scripts/langages/typescript/index.mjs +3 -0
  74. package/scripts/langages/typescript/module-absent.mjs +24 -0
  75. package/scripts/langages/typescript/turbo-des-paquets.mjs +19 -1
  76. package/scripts/langages/typescript/vitest-config/lances.mjs +3 -1
  77. package/scripts/langages.mjs +25 -3
  78. package/scripts/machine.mjs +103 -0
  79. package/scripts/matieres-cles.mjs +17 -0
  80. package/scripts/matieres-lues.mjs +104 -0
  81. package/scripts/migrations/0.48.0-ci-declenchee-par-la-file.mjs +32 -0
  82. package/scripts/migrations/0.48.0-poussee-retiree.mjs +31 -0
  83. package/scripts/migrations.mjs +4 -0
  84. package/scripts/nuit.sh +16 -44
  85. package/scripts/passe-de-la-machine.mjs +9 -7
  86. package/scripts/places-de-la-machine.mjs +74 -11
  87. package/scripts/places-du-serveur.mjs +29 -8
  88. package/scripts/poussee-retiree.mjs +18 -0
  89. package/scripts/registre.d.mts +2 -2
  90. package/scripts/regles-des-places.d.mts +36 -5
  91. package/scripts/regles-des-places.mjs +56 -9
  92. package/scripts/reponses-du-circuit.d.mts +2 -0
  93. package/scripts/reponses-du-circuit.mjs +26 -0
  94. package/scripts/resultats.mjs +40 -0
  95. package/scripts/sous-commandes.mjs +15 -2
  96. package/scripts/superviseur.mjs +64 -57
  97. package/scripts/tableau.mjs +132 -67
  98. package/scripts/transitions.d.mts +8 -0
  99. package/scripts/transitions.mjs +21 -3
  100. package/skills/pitmaster/SKILL.md +6 -3
  101. package/skills/relecteur/SKILL.md +3 -1
  102. package/scripts/poussee-cles.mjs +0 -46
@@ -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,
@@ -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),