@roomi-fields/grillhouse 0.54.1 → 0.55.2

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 (238) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +73 -0
  3. package/cadre/templates/projet/.github/workflows/ci.yml +4 -2
  4. package/cadre/templates/projet/.github/workflows/machine-vierge.yml +5 -42
  5. package/cadre/templates/projet/CONTRIBUTING.md +0 -5
  6. package/cadre/templates/projet/README.md +0 -126
  7. package/cadre/templates/projet/_npmignore +1 -6
  8. package/cadre/templates/projet/package.json +5 -32
  9. package/cadre/templates/projet/tsconfig.json +4 -4
  10. package/cadre/templates/projet/vitest.config.cjs +3 -2
  11. package/charte/tests.md +14 -0
  12. package/dist/machine/part-par-sorte.d.ts +9 -9
  13. package/dist/machine/part-par-sorte.js +20 -24
  14. package/dist/machine/part-par-sorte.js.map +1 -1
  15. package/dist/machine/table-des-consommations.d.ts +65 -0
  16. package/dist/machine/table-des-consommations.js +94 -0
  17. package/dist/machine/table-des-consommations.js.map +1 -0
  18. package/dist/temporal/circuit/activites.d.ts +2 -0
  19. package/dist/temporal/circuit/activites.js +87 -3
  20. package/dist/temporal/circuit/activites.js.map +1 -1
  21. package/dist/temporal/circuit/client.js +9 -4
  22. package/dist/temporal/circuit/client.js.map +1 -1
  23. package/dist/temporal/circuit/contrat.d.ts +32 -4
  24. package/dist/temporal/circuit/deroule.js +54 -4
  25. package/dist/temporal/circuit/deroule.js.map +1 -1
  26. package/dist/temporal/circuit/versions.d.ts +12 -0
  27. package/dist/temporal/circuit/versions.js +22 -0
  28. package/dist/temporal/circuit/versions.js.map +1 -0
  29. package/dist/temporal/consommation/activites.d.ts +2 -0
  30. package/dist/temporal/consommation/activites.js +9 -0
  31. package/dist/temporal/consommation/activites.js.map +1 -0
  32. package/dist/temporal/consommation/actualisation.d.ts +2 -0
  33. package/dist/temporal/consommation/actualisation.js +71 -0
  34. package/dist/temporal/consommation/actualisation.js.map +1 -0
  35. package/dist/temporal/consommation/client.d.ts +12 -0
  36. package/dist/temporal/consommation/client.js +28 -0
  37. package/dist/temporal/consommation/client.js.map +1 -0
  38. package/dist/temporal/consommation/commande.d.ts +5 -0
  39. package/dist/temporal/consommation/commande.js +32 -0
  40. package/dist/temporal/consommation/commande.js.map +1 -0
  41. package/dist/temporal/consommation/contrat.d.ts +15 -0
  42. package/dist/temporal/consommation/contrat.js +13 -0
  43. package/dist/temporal/consommation/contrat.js.map +1 -0
  44. package/dist/temporal/consommation/deroule.d.ts +2 -0
  45. package/dist/temporal/consommation/deroule.js +14 -0
  46. package/dist/temporal/consommation/deroule.js.map +1 -0
  47. package/dist/temporal/deroules.d.ts +2 -1
  48. package/dist/temporal/deroules.js +3 -2
  49. package/dist/temporal/deroules.js.map +1 -1
  50. package/dist/temporal/file/contrat.d.ts +2 -0
  51. package/dist/temporal/file/deroule.js +14 -4
  52. package/dist/temporal/file/deroule.js.map +1 -1
  53. package/dist/temporal/installation.d.ts +6 -0
  54. package/dist/temporal/installation.js +15 -0
  55. package/dist/temporal/installation.js.map +1 -1
  56. package/dist/temporal/nuits/activites.d.ts +2 -1
  57. package/dist/temporal/nuits/activites.js +127 -3
  58. package/dist/temporal/nuits/activites.js.map +1 -1
  59. package/dist/temporal/nuits/client.d.ts +19 -5
  60. package/dist/temporal/nuits/client.js +33 -23
  61. package/dist/temporal/nuits/client.js.map +1 -1
  62. package/dist/temporal/nuits/commande.js +16 -11
  63. package/dist/temporal/nuits/commande.js.map +1 -1
  64. package/dist/temporal/nuits/contrat.d.ts +29 -0
  65. package/dist/temporal/nuits/contrat.js +10 -0
  66. package/dist/temporal/nuits/contrat.js.map +1 -1
  67. package/dist/temporal/nuits/deroule.d.ts +5 -0
  68. package/dist/temporal/nuits/deroule.js +18 -1
  69. package/dist/temporal/nuits/deroule.js.map +1 -1
  70. package/dist/temporal/nuits/pc2.d.ts +72 -0
  71. package/dist/temporal/nuits/pc2.js +206 -0
  72. package/dist/temporal/nuits/pc2.js.map +1 -0
  73. package/dist/temporal/places/activites.d.ts +23 -1
  74. package/dist/temporal/places/activites.js +38 -2
  75. package/dist/temporal/places/activites.js.map +1 -1
  76. package/dist/temporal/places/client.d.ts +18 -2
  77. package/dist/temporal/places/client.js +28 -3
  78. package/dist/temporal/places/client.js.map +1 -1
  79. package/dist/temporal/places/contrat.d.ts +79 -14
  80. package/dist/temporal/places/contrat.js +7 -0
  81. package/dist/temporal/places/contrat.js.map +1 -1
  82. package/dist/temporal/places/deroule.js +159 -23
  83. package/dist/temporal/places/deroule.js.map +1 -1
  84. package/dist/temporal/places/reservation.d.ts +54 -0
  85. package/dist/temporal/places/reservation.js +69 -0
  86. package/dist/temporal/places/reservation.js.map +1 -0
  87. package/dist/temporal/planification.d.ts +6 -0
  88. package/dist/temporal/planification.js +26 -0
  89. package/dist/temporal/planification.js.map +1 -0
  90. package/dist/temporal/tickets/activites.d.ts +0 -2
  91. package/dist/temporal/tickets/activites.js +2 -52
  92. package/dist/temporal/tickets/activites.js.map +1 -1
  93. package/dist/temporal/tickets/contrat.d.ts +7 -26
  94. package/dist/temporal/tickets/deroule.js +35 -23
  95. package/dist/temporal/tickets/deroule.js.map +1 -1
  96. package/dist/temporal/travailleur.js +2 -0
  97. package/dist/temporal/travailleur.js.map +1 -1
  98. package/docs/ARCHITECTURE.md +2 -2
  99. package/docs/CADRE.md +1 -1
  100. package/docs/INTERFACE.md +16 -11
  101. package/docs/architecture/circuit.md +62 -58
  102. package/docs/architecture/entree.md +87 -63
  103. package/docs/architecture/greffon.md +24 -21
  104. package/docs/architecture/installation.md +35 -30
  105. package/docs/architecture/machine.md +48 -40
  106. package/docs/architecture/tests.md +37 -33
  107. package/docs/lexique.md +4 -3
  108. package/package.json +1 -1
  109. package/scripts/activites.mjs +351 -180
  110. package/scripts/aiguillage.mjs +1 -0
  111. package/scripts/attente-de-la-machine.mjs +3 -22
  112. package/scripts/avancement.mjs +21 -30
  113. package/scripts/bilan.mjs +22 -2
  114. package/scripts/branche-de-nuit.mjs +1 -1
  115. package/scripts/circuit.mjs +75 -39
  116. package/scripts/codes-de-sortie.mjs +0 -6
  117. package/scripts/coeurs-dedies.mjs +19 -2
  118. package/scripts/consommation-des-passes.mjs +67 -35
  119. package/scripts/consommation.mjs +152 -24
  120. package/scripts/copies-finies.mjs +15 -35
  121. package/scripts/dernier-vert.mjs +4 -5
  122. package/scripts/dette.mjs +5 -3
  123. package/scripts/droits.mjs +2 -2
  124. package/scripts/echantillonneur-de-la-passe.mjs +7 -31
  125. package/scripts/engendres.mjs +5 -61
  126. package/scripts/enveloppe/enveloppe.mjs +30 -34
  127. package/scripts/enveloppe/travail-de-la-copie.mjs +5 -0
  128. package/scripts/etapes.mjs +21 -7
  129. package/scripts/etat-du-depot.mjs +61 -0
  130. package/scripts/faits-du-circuit.mjs +7 -4
  131. package/scripts/fermeture-de-la-machine.d.mts +6 -4
  132. package/scripts/fermeture-de-la-machine.mjs +12 -16
  133. package/scripts/fichier-du-poste.d.mts +9 -0
  134. package/scripts/file-des-tickets.d.mts +0 -18
  135. package/scripts/file-des-tickets.mjs +0 -42
  136. package/scripts/fusion-du-changelog.mjs +1 -1
  137. package/scripts/grillhouse-maj.mjs +1 -1
  138. package/scripts/index-des-rouges.d.mts +40 -0
  139. package/scripts/index-des-rouges.mjs +104 -0
  140. package/scripts/integration/file.mjs +13 -63
  141. package/scripts/integration/integrer.mjs +157 -424
  142. package/scripts/integration/jugement.mjs +109 -0
  143. package/scripts/integration/rejeu.mjs +94 -71
  144. package/scripts/jointure.d.ts +34 -27
  145. package/scripts/journal-des-etats.d.mts +1 -1
  146. package/scripts/langages/c/commandes.mjs +27 -12
  147. package/scripts/langages/cargo/commandes.mjs +148 -94
  148. package/scripts/langages/cargo/index.mjs +2 -1
  149. package/scripts/langages/cargo/lectures-des-tests.mjs +132 -0
  150. package/scripts/langages/cargo/migrations/lectures-des-tests.mjs +31 -0
  151. package/scripts/langages/python/commandes.mjs +31 -15
  152. package/scripts/langages/python/index.mjs +2 -1
  153. package/scripts/langages/python/lectures-des-tests.mjs +148 -0
  154. package/scripts/langages/python/migrations/lectures-des-tests.mjs +31 -0
  155. package/scripts/langages/typescript/consommateurs-arbitres.mjs +2 -2
  156. package/scripts/langages/typescript/index.mjs +4 -0
  157. package/scripts/langages/typescript/lectures-des-tests.mjs +95 -0
  158. package/scripts/langages/typescript/migrations/lectures-des-tests.mjs +31 -0
  159. package/scripts/langages/typescript/tests-de-nuit.mjs +9 -15
  160. package/scripts/langages/typescript/tests.mjs +11 -37
  161. package/scripts/langages/typescript/titres-de-tests.mjs +5 -4
  162. package/scripts/langages/typescript/verifier.mjs +74 -44
  163. package/scripts/langages/typescript/vitest-config/base.mjs +3 -3
  164. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +6 -25
  165. package/scripts/lectures-communes.mjs +234 -0
  166. package/scripts/machine.mjs +11 -18
  167. package/scripts/mesure/base-de-passe.mjs +1 -2
  168. package/scripts/mesure-de-la-machine.d.mts +43 -3
  169. package/scripts/mesure-de-la-machine.mjs +209 -11
  170. package/scripts/migrations/0.33.0-ci-du-cadre.mjs +3 -3
  171. package/scripts/migrations/nuit-yml-retire.mjs +25 -0
  172. package/scripts/migrations/part-retiree.mjs +31 -0
  173. package/scripts/migrations/table-des-consommations.mjs +36 -0
  174. package/scripts/migrations.mjs +6 -0
  175. package/scripts/montee.mjs +9 -0
  176. package/scripts/nuit-de-pc2.mjs +628 -0
  177. package/scripts/nuit.sh +8 -131
  178. package/scripts/paquets.mjs +1 -1
  179. package/scripts/passe-de-la-machine.mjs +365 -105
  180. package/scripts/place-du-circuit.d.mts +15 -0
  181. package/scripts/place-du-circuit.mjs +32 -0
  182. package/scripts/places-de-la-machine.mjs +148 -627
  183. package/scripts/places-du-serveur.mjs +43 -16
  184. package/scripts/plafond-de-la-machine.d.mts +8 -13
  185. package/scripts/plafond-de-la-machine.mjs +37 -69
  186. package/scripts/registre-des-entrees.mjs +57 -0
  187. package/scripts/regles-des-places.d.mts +84 -50
  188. package/scripts/regles-des-places.mjs +200 -156
  189. package/scripts/retirer-copie.sh +2 -2
  190. package/scripts/seances.mjs +181 -63
  191. package/scripts/secours.mjs +95 -0
  192. package/scripts/services-du-noyau.mjs +11 -19
  193. package/scripts/sous-commandes.mjs +1 -0
  194. package/scripts/sous-modules.sh +1 -1
  195. package/scripts/superviseur.mjs +16 -7
  196. package/scripts/table-des-consommations.d.mts +9 -0
  197. package/scripts/table-des-consommations.mjs +35 -0
  198. package/scripts/tableau.mjs +33 -19
  199. package/scripts/taches-du-graphe.mjs +124 -2
  200. package/scripts/transitions.d.mts +27 -5
  201. package/scripts/transitions.mjs +125 -104
  202. package/scripts/verdict-de-la-nuit.d.mts +13 -0
  203. package/scripts/verdict-de-la-nuit.mjs +34 -7
  204. package/scripts/verrou-de-fichier.mjs +1 -2
  205. package/scripts/workflows-du-cadre.mjs +2 -2
  206. package/skills/developpeur/SKILL.md +8 -2
  207. package/skills/direct/SKILL.md +5 -0
  208. package/skills/explorateur/SKILL.md +10 -1
  209. package/skills/grill/SKILL.md +2 -4
  210. package/skills/pitmaster/SKILL.md +7 -5
  211. package/skills/pitmaster/references/consigne-agent.md +1 -1
  212. package/skills/relecteur/SKILL.md +4 -1
  213. package/skills/testwriter/SKILL.md +15 -2
  214. package/cadre/templates/projet/.env.example +0 -57
  215. package/cadre/templates/projet/.github/workflows/nuit.yml +0 -139
  216. package/cadre/templates/projet/deployment/README.md +0 -98
  217. package/cadre/templates/projet/deployment/docs/01-INSTALL.md +0 -145
  218. package/cadre/templates/projet/deployment/docs/02-CONFIGURATION.md +0 -117
  219. package/cadre/templates/projet/deployment/docs/03-API.md +0 -264
  220. package/cadre/templates/projet/deployment/docs/04-TROUBLESHOOTING.md +0 -262
  221. package/cadre/templates/projet/deployment/scripts/install.ps1 +0 -100
  222. package/cadre/templates/projet/deployment/scripts/start.ps1 +0 -61
  223. package/cadre/templates/projet/deployment/scripts/stop.ps1 +0 -37
  224. package/cadre/templates/projet/deployment/scripts/test.ps1 +0 -118
  225. package/cadre/templates/projet/ecosystem.config.cjs +0 -73
  226. package/cadre/templates/projet/src/config.ts +0 -68
  227. package/cadre/templates/projet/src/errors.ts +0 -102
  228. package/cadre/templates/projet/src/index.ts +0 -46
  229. package/cadre/templates/projet/src/services/.gitkeep +0 -8
  230. package/cadre/templates/projet/src/types/index.ts +0 -24
  231. package/cadre/templates/projet/src/utils/logger.ts +0 -106
  232. package/cadre/templates/projet/tests/unit/config.spec.ts +0 -68
  233. package/cadre/templates/projet/tests/unit/errors.spec.ts +0 -132
  234. package/cadre/templates/projet/tests/unit/types.spec.ts +0 -73
  235. package/cadre/templates/projet/tsconfig.build.json +0 -14
  236. package/scripts/flux-de-la-nuit.mjs +0 -39
  237. package/scripts/garde-de-la-memoire.mjs +0 -231
  238. package/scripts/repli-de-la-nuit.mjs +0 -184
@@ -1,38 +1,118 @@
1
- // The rules of the places of the machine, with no input nor output: whether a start is admitted
2
- // at a load and a free memory (the load under the cores, MEMOIRE_MIN free), and why a taking does
3
- // not pass now. The workflow of the machine (src/temporal/places/) decides by them and bundles
1
+ // The rules of the places of the machine, with no input nor output: why the reservation
2
+ // of a step is not granted now, and the places of the circuits. The workflow of the machine (src/temporal/places/) decides by them and bundles
4
3
  // this module, which imports nothing; the load and the memory come from
5
4
  // scripts/mesure-de-la-machine.mjs. Architecture: docs/architecture/machine.md (§3.1, §5.2).
6
5
 
7
6
  /** The memory a start wants free, in bytes: 4 GB. */
8
7
  export const MEMOIRE_MIN = 4 * 1024 ** 3;
9
8
 
10
- export const VARIABLE_ESPACEMENT = 'GRILLHOUSE_ESPACEMENT_MS';
11
- /** Why a place waits under the closure of the machine by the supervisor (`cordon` of kubectl). */
12
- export const RAISON_FERMEE =
13
- 'machine fermée par le superviseur : la place est donnée à la réouverture';
14
- /** The gap between two starts when GRILLHOUSE_ESPACEMENT_MS names none, in ms. */
15
- export const ESPACEMENT_MS = 10_000;
9
+ /** The pressure of the memory (%) above which the watch of the arbiter is on alert. */
10
+ export const SEUIL_D_ALERTE = 10;
11
+ /** The pressure of the memory (%) at which the memory is threatened: a step is stopped. */
12
+ export const SEUIL_DE_MENACE = 50;
13
+ /** How long the pressure stays under the alert, and the swap on disk stops growing, to lift it, in ms. */
14
+ export const DUREE_DE_LA_LEVEE_MS = 60_000;
15
+ /**
16
+ * The steps of the overbooking of the memory the admission counts: the memory of the budget is
17
+ * multiplied by the step in force (the cores are not).
18
+ */
19
+ export const CRANS = [1, 1.2, 1.5];
20
+ /** How long without alert nor stop for lack of memory before the step goes up, in ms: three days. */
21
+ export const DELAI_DE_MONTEE_MS = 3 * 24 * 3600 * 1000;
22
+
23
+ /**
24
+ * The level of the memory of the machine, the three levels of the watch of the arbiter
25
+ * (machine.md §5.3): `menace` at a pressure of 50 % or more, or the memory available and the swap
26
+ * held in memory together under MEMOIRE_MIN; `alerte` above a pressure of 10 %, or when the swap
27
+ * on disk serves; else `calme`. A field that is null says nothing.
28
+ * @param {{ pression: number | null, disponible: number | null, echangeEnMemoire: number,
29
+ * echangeSurDisque: boolean }} m bytes, %
30
+ * @returns {'calme' | 'alerte' | 'menace'}
31
+ */
32
+ export function niveauDeLaMemoire({ pression, disponible, echangeEnMemoire, echangeSurDisque }) {
33
+ if (
34
+ (pression !== null && pression >= SEUIL_DE_MENACE) ||
35
+ (disponible !== null && disponible + echangeEnMemoire < MEMOIRE_MIN)
36
+ ) {
37
+ return 'menace';
38
+ }
39
+ if ((pression !== null && pression > SEUIL_D_ALERTE) || echangeSurDisque) {
40
+ return 'alerte';
41
+ }
42
+ return 'calme';
43
+ }
44
+
45
+ /**
46
+ * Whether an alert is lifted: the pressure stayed under the threshold since `sousLeSeuilDepuis`
47
+ * (ms, null while it is not under) for DUREE_DE_LA_LEVEE_MS at least, and the swap on disk does
48
+ * not grow any more.
49
+ * @param {{ sousLeSeuilDepuis: number | null, maintenant: number, echangeSurDisqueGrandit: boolean }} o
50
+ * @returns {boolean}
51
+ */
52
+ export const alerteLevee = ({ sousLeSeuilDepuis, maintenant, echangeSurDisqueGrandit }) =>
53
+ sousLeSeuilDepuis !== null &&
54
+ maintenant - sousLeSeuilDepuis >= DUREE_DE_LA_LEVEE_MS &&
55
+ !echangeSurDisqueGrandit;
56
+
57
+ /**
58
+ * The ids of the steps in the order a threat stops them: first those beyond their reservation, the
59
+ * largest in proportion of it first; then the others, the largest in memory first; on equality a
60
+ * pass before a session, then the most recent before the oldest.
61
+ * @param {{ id: string, memoire: number, reservation: number, passe: boolean, depuis: number }[]} etapes
62
+ * @returns {string[]}
63
+ */
64
+ export function ordreDArret(etapes) {
65
+ const depasse = e => e.memoire > e.reservation;
66
+ const part = e => (e.reservation > 0 ? e.memoire / e.reservation : Infinity);
67
+ return etapes
68
+ .toSorted(
69
+ (a, b) =>
70
+ Number(depasse(b)) - Number(depasse(a)) ||
71
+ (depasse(a) ? part(b) - part(a) : 0) ||
72
+ b.memoire - a.memoire ||
73
+ Number(b.passe) - Number(a.passe) ||
74
+ b.depuis - a.depuis
75
+ )
76
+ .map(e => e.id);
77
+ }
16
78
 
17
79
  /**
18
- * The gap between two starts under <env>, in ms.
19
- * @param {Record<string, string | undefined>} [env]
20
- * @returns {number}
21
- * @throws {Error} naming GRILLHOUSE_ESPACEMENT_MS when its value is not a number of ms
80
+ * The step of the overbooking after a moment: one step down on a `signal` (an alert, a stop for lack
81
+ * of memory; its reason), one step up when `DELAI_DE_MONTEE_MS` passed since the last change or
82
+ * signal (`depuis`) without one. A signal at the lowest step restarts the wait. `changement` says
83
+ * the change, its instant and its reason; null when the step stays.
84
+ * @param {{ cran: number, depuis: number, maintenant: number, signal: string | null }} o
85
+ * @returns {{ cran: number, depuis: number, changement: { de: number, a: number, raison: string,
86
+ * instant: number } | null }}
22
87
  */
23
- export function espacementDe(env = process.env) {
24
- const v = env[VARIABLE_ESPACEMENT];
25
- if (v === undefined || v === '') {
26
- return ESPACEMENT_MS;
88
+ export function ajusterLeCran({ cran, depuis, maintenant, signal }) {
89
+ const i = Math.max(0, CRANS.indexOf(cran));
90
+ const change = (j, raison) => ({
91
+ cran: CRANS[j],
92
+ depuis: maintenant,
93
+ changement: { de: cran, a: CRANS[j], raison, instant: maintenant },
94
+ });
95
+ if (signal) {
96
+ return i > 0 ? change(i - 1, signal) : { cran, depuis: maintenant, changement: null };
27
97
  }
28
- if (!/^\d+$/.test(v)) {
29
- throw new Error(
30
- `${VARIABLE_ESPACEMENT} vaut « ${v} » : un nombre de millisecondes est attendu.`
31
- );
98
+ if (i < CRANS.length - 1 && maintenant - depuis >= DELAI_DE_MONTEE_MS) {
99
+ return change(i + 1, 'trois jours sans alerte ni arrêt faute de mémoire');
32
100
  }
33
- return Number(v);
101
+ return { cran, depuis, changement: null };
34
102
  }
35
103
 
104
+ /** Why a request waits under the closure of the machine by the supervisor (`cordon` of kubectl). */
105
+ export const RAISON_FERMEE =
106
+ 'machine fermée par le superviseur : la réservation est accordée à la réouverture';
107
+ /**
108
+ * How long after its grant a step is not yet read by the measure of the machine, in ms: the
109
+ * reservation of the steps granted since less than that is taken off the measured availability.
110
+ */
111
+ export const FENETRE_DE_DEPART_MS = 30_000;
112
+
113
+ /** The sort of the verification of the update (scripts/grillhouse-maj.mjs), a gesture of the maintenance. */
114
+ export const SORTE_DE_LA_MONTEE = 'Montée';
115
+
36
116
  // 11.2 → « 11,2 », 4 → « 4 ».
37
117
  const nombre = n => (Number.isInteger(n) ? String(n) : n.toFixed(1).replace('.', ','));
38
118
 
@@ -44,59 +124,80 @@ const nombre = n => (Number.isInteger(n) ? String(n) : n.toFixed(1).replace('.',
44
124
  export const duree = ms =>
45
125
  ms < 120_000 ? `${Math.round(ms / 1000)} s` : `${Math.round(ms / 60_000)} min`;
46
126
 
127
+ /** How many times a wait may be passed by a request that fits, before nothing passes it more. */
128
+ export const PASSAGES_MAX = 5;
129
+
47
130
  /**
48
- * Whether a start is admitted at this load and this free memory, as `make -l` admits it: the load
49
- * under the number of cores, and at least MEMOIRE_MIN free. A refusal says why.
50
- * @param {{ coeurs: number, charge: number, memoireLibre: number }} o `memoireLibre` in bytes
51
- * @returns {{ ok: true } | { ok: false, raison: string }}
131
+ * A request <id> of the rank <rang> is granted before the waits of a lower rank: each gains a
132
+ * passage. Called before the granted request leaves the waits; the state is changed in place.
133
+ * @param {{ attentes: { id: string, rang: number, passages?: number }[] }} etat
134
+ * @param {{ id: string, rang: number }} o
135
+ * @returns {void}
52
136
  */
53
- export function admission({ coeurs, charge, memoireLibre }) {
54
- if (charge >= coeurs) {
55
- return { ok: false, raison: `charge de la machine ${nombre(charge)} sur ${coeurs} cœurs` };
56
- }
57
- if (memoireLibre < MEMOIRE_MIN) {
58
- return {
59
- ok: false,
60
- raison: `mémoire libre ${nombre(memoireLibre / 1024 ** 3)} Go, sous les ${MEMOIRE_MIN / 1024 ** 3} Go demandés`,
61
- };
137
+ export function compterLesPassages(etat, { id, rang }) {
138
+ for (const a of etat.attentes) {
139
+ if (a.id !== id && a.rang < rang) {
140
+ a.passages = (a.passages ?? 0) + 1;
141
+ }
62
142
  }
63
- return { ok: true };
64
143
  }
65
144
 
66
145
  /**
67
- * Why the taking <id> of the rank <rang> does not pass now on the state <etat> (`prises`,
68
- * `attentes`, `dernier`, the time of the last start), null when it passes: no free place under
69
- * <plafond>; a wait of a lower rank alive, which keeps its turn between projects; the admission at
70
- * the load and the memory <mesurer> gives (read only when the place and the turn pass); two starts
71
- * closer than <espacementMs> at the time <maintenant>.
72
- * @param {{ prises: object[], attentes: { id: string, rang: number, ticket?: string | null,
73
- * raison?: string }[], dernier: number }} etat
74
- * @param {{ id: string, rang: number, plafond: number, espacementMs: number, maintenant: number,
75
- * mesurer: () => { coeurs: number, charge: number, memoireLibre: number } }} o
146
+ * Why the reservation of a step <id> of the rank <rang> is not granted now on the state <etat>
147
+ * (`prises`: the reservations granted, with the time `depuis` of their grant; `attentes`;
148
+ * `reservation`: the supervisor's closure), null when it is: the closure of the machine; a wait of
149
+ * a lower rank passed PASSAGES_MAX times, which keeps its turn; the reservation within the <budget>
150
+ * in cores, then in memory (what the others granted leave of it); then the free memory the
151
+ * measure <mesurer> gives (read only when the closure, the turn and the budget pass), less the
152
+ * memory reserved by the steps granted since less than FENETRE_DE_DEPART_MS at the time
153
+ * <maintenant>, which the measure does not show yet. The load of the processes outside the frame
154
+ * refuses nothing: the cores count by the reservations only (machine.md §5.2). A refusal names the first condition missed and its figures.
155
+ * @param {{ prises: { id?: string, coeurs: number, memoire: number, depuis?: number,
156
+ * ticket?: string | null }[],
157
+ * attentes: { id: string, rang: number, ticket?: string | null, raison?: string,
158
+ * passages?: number }[],
159
+ * reservation?: object | null }} etat
160
+ * @param {{ id: string, rang: number, reservation: { coeurs: number, memoire: number },
161
+ * budget: { coeurs: number, memoire: number }, maintenant: number, exemptee?: boolean,
162
+ * cran?: number, mesurer: () => { memoireLibre: number } }} o
163
+ * `cran`: the step of the overbooking, which multiplies the memory of the budget (1 by default)
76
164
  * @returns {string | null}
77
165
  */
78
- export function refusDeLaPlace(
166
+ export function refusDeLaReservation(
79
167
  etat,
80
- { id, rang, plafond, espacementMs, maintenant, mesurer }
168
+ { id, rang, reservation, budget, maintenant, mesurer, exemptee = false, cran = 1 }
81
169
  ) {
82
- // The supervisor's closure, the only reservation of the machine, gives no place to anyone.
83
- if (etat.reservation) {
170
+ // The closure refuses every new reservation but one <exemptee> (the update of the frame, a gesture
171
+ // of the maintenance, as a drain keeps the pods of the system).
172
+ if (etat.reservation && !exemptee) {
84
173
  return RAISON_FERMEE;
85
174
  }
86
- if (etat.prises.length >= plafond) {
87
- return `aucune place libre : ${etat.prises.length} prises sur ${plafond}`;
88
- }
89
- const avant = etat.attentes.find(a => a.id !== id && a.rang < rang);
90
- if (avant) {
91
- return `place réservée : ${avant.ticket ?? 'un départ'} est arrivé avant et attend (${avant.raison})`;
175
+ // A request that fits passes before the waits of a lower rank, until one of them has been
176
+ // passed PASSAGES_MAX times (the backfill of Slurm, bounded in passages, not in minutes).
177
+ // A wait whose reservation can never fit in the budget (unschedulable, as Kubernetes refuses it
178
+ // at admission) protects no rank: no other wait is held back for it.
179
+ const tientUnJour = a =>
180
+ a.coeurs === undefined ||
181
+ a.memoire === undefined ||
182
+ partDansLeBudget({ part: a, budget, prises: [], cran }).ok;
183
+ const bloquante = etat.attentes.find(
184
+ a => a.id !== id && a.rang < rang && (a.passages ?? 0) >= PASSAGES_MAX && tientUnJour(a)
185
+ );
186
+ if (bloquante) {
187
+ return `rang réservé : ${bloquante.ticket ?? 'une étape'} attend, la borne de ${PASSAGES_MAX} passages est atteinte (${bloquante.raison})`;
92
188
  }
93
- const a = admission(mesurer());
94
- if (!a.ok) {
95
- return a.raison;
189
+ const prises = etat.prises.filter(p => p.id !== id);
190
+ const tient = partDansLeBudget({ part: reservation, budget, prises, cran });
191
+ if (!tient.ok) {
192
+ return partDansLeBudget({ part: reservation, budget, prises: [], cran }).ok
193
+ ? tient.raison
194
+ : `ne tient jamais dans le budget du poste, ${tient.raison}`;
96
195
  }
97
- const ecoule = maintenant - etat.dernier;
98
- if (ecoule < espacementMs) {
99
- return `espacement des départs : le dernier date de ${duree(ecoule)}, ${duree(espacementMs)} au moins`;
196
+ const mesure = mesurer();
197
+ const parties = prises.filter(p => maintenant - (p.depuis ?? 0) < FENETRE_DE_DEPART_MS);
198
+ const memoireLibre = mesure.memoireLibre - parties.reduce((n, p) => n + p.memoire, 0);
199
+ if (reservation.memoire > memoireLibre) {
200
+ return `mémoire libre de la machine : ${go(reservation.memoire)} demandés, ${go(Math.max(0, memoireLibre))} libres`;
100
201
  }
101
202
  return null;
102
203
  }
@@ -108,10 +209,11 @@ const go = octets => `${nombre(octets / 1024 ** 3)} Go`;
108
209
  * the <budget> of the machine: cores, then memory. A refusal says what it waits for (`attend`:
109
210
  * « cœurs » or « mémoire ») and its figures, « cœurs : 6 demandés, 4 libres sur 8 ».
110
211
  * @param {{ part: { coeurs: number, memoire: number }, budget: { coeurs: number, memoire: number },
111
- * prises: { coeurs: number, memoire: number }[] }} o
212
+ * prises: { coeurs: number, memoire: number }[], cran?: number }} o `cran` multiplies the memory
213
+ * of the budget, not its cores
112
214
  * @returns {{ ok: true } | { ok: false, attend: 'cœurs' | 'mémoire', raison: string }}
113
215
  */
114
- export function partDansLeBudget({ part, budget, prises }) {
216
+ export function partDansLeBudget({ part, budget, prises, cran = 1 }) {
115
217
  const coeursLibres = budget.coeurs - prises.reduce((n, p) => n + p.coeurs, 0);
116
218
  if (part.coeurs > coeursLibres) {
117
219
  return {
@@ -120,90 +222,18 @@ export function partDansLeBudget({ part, budget, prises }) {
120
222
  raison: `cœurs : ${part.coeurs} demandés, ${Math.max(0, coeursLibres)} libres sur ${budget.coeurs}`,
121
223
  };
122
224
  }
123
- const memoireLibre = budget.memoire - prises.reduce((n, p) => n + p.memoire, 0);
225
+ const memoireDuBudget = budget.memoire * cran;
226
+ const memoireLibre = memoireDuBudget - prises.reduce((n, p) => n + p.memoire, 0);
124
227
  if (part.memoire > memoireLibre) {
125
228
  return {
126
229
  ok: false,
127
230
  attend: 'mémoire',
128
- raison: `mémoire : ${go(part.memoire)} demandés, ${go(Math.max(0, memoireLibre))} libres sur ${go(budget.memoire)}`,
231
+ raison: `mémoire : ${go(part.memoire)} demandés, ${go(Math.max(0, memoireLibre))} libres sur ${go(memoireDuBudget)}`,
129
232
  };
130
233
  }
131
234
  return { ok: true };
132
235
  }
133
236
 
134
- /**
135
- * Whether a pass of the part <part> is admitted: its part fits in what the parts <prises> leave of
136
- * the <budget> (`partDansLeBudget`), then the thresholds of `admission` hold on the machine
137
- * <mesure> (load under the cores, MEMOIRE_MIN free). A refusal says what it waits for (`attend`:
138
- * « cœurs », « mémoire » or « charge ») and its figures.
139
- * @param {{ part: { coeurs: number, memoire: number }, budget: { coeurs: number, memoire: number },
140
- * prises: { coeurs: number, memoire: number }[],
141
- * mesure: { coeurs: number, charge: number, memoireLibre: number } }} o
142
- * @returns {{ ok: true } | { ok: false, attend: 'cœurs' | 'mémoire' | 'charge', raison: string }}
143
- */
144
- export function admissionDePart({ part, budget, prises, mesure }) {
145
- const tient = partDansLeBudget({ part, budget, prises });
146
- if (!tient.ok) {
147
- return tient;
148
- }
149
- const a = admission(mesure);
150
- return a.ok
151
- ? a
152
- : { ...a, attend: mesure.charge >= mesure.coeurs ? 'charge' : 'mémoire' };
153
- }
154
-
155
- /** Why a pass waits under the supervisor's closure of the machine. */
156
- export const RAISON_DE_LA_FERMETURE = 'machine fermée par le superviseur';
157
-
158
- /**
159
- * Why the pass <id> of the rank <rang> does not take its part <part> now on the state <etat>
160
- * (`prises`, `attentes`), null when it does: its part does not fit in the <budget>; a wait of a
161
- * lower rank, alive, which keeps its turn (the measure of the frame has the lower rank of a
162
- * project's, then the order of arrival); the admission at the load and the memory <mesurer> gives
163
- * (read only when the part and the turn pass). A measure of time (<dediee>) asks for dedicated cores: when they lack, its refusal
164
- * says « cœurs dédiés » and names the passes that hold them; a pass that comes after it waits
165
- * behind it, its rank reserved, and one measure plays at a time, whatever its part would fit in the free cores; once it plays, an
166
- * ordinary pass whose part fits in the cores left goes on.
167
- * @param {{ prises: { id?: string, coeurs: number, memoire: number, ticket?: string | null }[],
168
- * attentes: { id: string, rang: number, ticket?: string | null, raison?: string }[] }} etat
169
- * @param {{ id: string, rang: number, part: { coeurs: number, memoire: number },
170
- * budget: { coeurs: number, memoire: number }, dediee?: boolean,
171
- * mesurer: () => { coeurs: number, charge: number, memoireLibre: number } }} o
172
- * @returns {string | null}
173
- */
174
- export function refusDePart(
175
- etat,
176
- { id, rang, part, budget, mesurer, dediee = false, reservation = null }
177
- ) {
178
- // A closed machine gives no new work (`cordon` of kubectl): the supervisor's closure refuses every pass.
179
- if (reservation) {
180
- return RAISON_DE_LA_FERMETURE;
181
- }
182
- const prises = etat.prises.filter(p => p.id !== id);
183
- // Two measures of time never play side by side: each would be the load the other is judged on.
184
- const autre = dediee ? prises.find(p => p.dediee) : undefined;
185
- if (autre) {
186
- return `cœurs dédiés : la mesure de ${autre.ticket ?? 'une passe'} les tient, une mesure à la fois`;
187
- }
188
- const tient = partDansLeBudget({ part, budget, prises });
189
- if (!tient.ok) {
190
- if (dediee && tient.attend === 'cœurs') {
191
- const tenues = prises.map(p => p.ticket ?? 'une passe').join(', ');
192
- return `cœurs dédiés${tient.raison.slice('cœurs'.length)}${tenues ? ` ; tenus par ${tenues}` : ''}`;
193
- }
194
- return tient.raison;
195
- }
196
- const avant = etat.attentes.find(a => a.id !== id && a.rang < rang);
197
- if (avant) {
198
- return `rang réservé : ${avant.ticket ?? 'une passe'} est arrivée avant et attend (${avant.raison})`;
199
- }
200
- const a = admissionDePart({ part, budget, prises, mesure: mesurer() });
201
- return a.ok ? null : a.raison;
202
- }
203
-
204
- /** A place of a circuit not given by its project's queue for this long is gone, in ms: 10 min. */
205
- export const PERIME_MS = 10 * 60_000;
206
-
207
237
  /**
208
238
  * The phase of the supervisor's closure of the machine: null without one; `'attend'` while a place
209
239
  * is held (the stages under way finish); then `'vide'` (it holds no place itself: every place held
@@ -219,18 +249,21 @@ export function phaseDeLaReservation({ prises, reservation = null }) {
219
249
  }
220
250
 
221
251
  /**
222
- * The places of the circuits of the machine once a demand comes, as Buildkite bounds its pipelines
223
- * in one fleet of agents. The queue of the project <racine> gives its circuits active <vivants>
224
- * (a circuit paused on a question gives its place back) and the tickets it would start
225
- * <candidats>, with the reason its disk of copies lacks room (<disque>, null with room): its
226
- * circuits active hold their place, its candidates wait for one, each its rank of arrival among
227
- * every project, drawn from <rang>; its other places, but a circuit resumed that waits, and those
228
- * no demand gave for PERIME_MS, are gone. A circuit resumed after its question asks again by
229
- * itself (<reprise>: its ticket and its rank of arrival, a new one when null), as a candidate,
230
- * without the disk, its copy already there. The places are granted in the order of arrival while
231
- * the circuits that hold one are fewer than <plafond>: the first that waits keeps the next ones
232
- * waiting, but a candidate short of disk, which waits with its reason and keeps no one. Gives the
233
- * places, the last rank drawn, and the tickets of the demand that hold a place.
252
+ * The places of the circuits of the machine once a demand comes, as the scheduler of Kubernetes
253
+ * holds one place per task. A circuit has one place, held by this arbiter: counted in the limit of
254
+ * its project and in the ceiling of the machine, kept until the circuit gives it back
255
+ * (`rendreSaPlace`) or its workflow ends. The queue of the project <racine> gives the circuits
256
+ * the server lists alive <vivants> and the tickets it would start <candidats> (all of them: the
257
+ * limit is counted here), with the reason its disk of copies lacks room (<disque>, null with
258
+ * room). <vivants> creates no place: a circuit that gave its place back asks it again by
259
+ * <reprise>. The garbage collector: a place of the project held by no circuit of <vivants> nor
260
+ * <candidats> is gone (its owner has disappeared), but a circuit resumed that waits. A circuit
261
+ * resumed after its question asks again by itself (<reprise>: its ticket and its rank of arrival,
262
+ * a new one when null), as a candidate, without the disk, its copy already there. The places are
263
+ * granted in the order of arrival while the circuits that hold one are fewer than <plafond>: the
264
+ * first that waits keeps the next ones waiting, but a candidate short of disk, which waits with
265
+ * its reason and keeps no one. Gives the places, the last rank drawn, and the tickets of the
266
+ * demand that hold a place.
234
267
  *
235
268
  * Between the projects of one group (`grillhouse.groupe`, `groupe` its identity, absent out of a
236
269
  * group), the priority orders the circuits that wait: each candidate carries its Beads priority and
@@ -244,7 +277,7 @@ export function phaseDeLaReservation({ prises, reservation = null }) {
244
277
  * its circuits that wait keep waiting, whichever project's demand judges them, and the other
245
278
  * projects still pass.
246
279
  * @param {Array<{ racine: string, ticket: string, rang: number, accordee: boolean, depuis: number,
247
- * vu: number, reprise?: boolean, raison?: string | null, priorite?: number, creation?: string,
280
+ * reprise?: boolean, raison?: string | null, priorite?: number, creation?: string,
248
281
  * groupe?: string }>} places
249
282
  * @param {{ racine: string, vivants?: string[], candidats?: string[], disque?: string | null,
250
283
  * reprise?: { ticket: string, rang: number | null }, groupe?: string,
@@ -267,8 +300,7 @@ export function reserverDesCircuits(places, demande, o) {
267
300
  let { rang } = o;
268
301
  const siens = new Set([...vivants, ...candidats]);
269
302
  const garde = c =>
270
- maintenant - c.vu < PERIME_MS &&
271
- (c.racine !== racine || siens.has(c.ticket) || Boolean(reprise) || (c.reprise && !c.accordee));
303
+ c.racine !== racine || siens.has(c.ticket) || Boolean(reprise) || (c.reprise && !c.accordee);
272
304
  const circuits = places.filter(garde).map(c => ({ ...c }));
273
305
  // What the demand says of a ticket's place: its group, its priority and its creation.
274
306
  const dit = ticket => ({
@@ -281,7 +313,6 @@ export function reserverDesCircuits(places, demande, o) {
281
313
  const placer = (ticket, accordee, o2 = {}) => {
282
314
  const c = circuits.find(x => x.racine === racine && x.ticket === ticket);
283
315
  if (c) {
284
- c.vu = maintenant;
285
316
  c.accordee = c.accordee || accordee;
286
317
  if (accordee) {
287
318
  c.reprise = false;
@@ -297,12 +328,14 @@ export function reserverDesCircuits(places, demande, o) {
297
328
  rang: r,
298
329
  accordee,
299
330
  depuis: maintenant,
300
- vu: maintenant,
301
331
  ...dit(ticket),
302
332
  ...(o2.maj ?? {}),
303
333
  });
304
334
  };
305
- vivants.forEach(t => placer(t, true));
335
+ // A circuit alive holds the place it has: it creates none (it gave its place back, or asks by `reprise`).
336
+ vivants
337
+ .filter(t => circuits.some(c => c.racine === racine && c.ticket === t))
338
+ .forEach(t => placer(t, false));
306
339
  candidats.forEach(t => placer(t, false, { maj: { raison: disque } }));
307
340
  if (reprise) {
308
341
  placer(reprise.ticket, false, {
@@ -347,3 +380,14 @@ export function reserverDesCircuits(places, demande, o) {
347
380
  );
348
381
  return { circuits, rang, accordes };
349
382
  }
383
+
384
+ /**
385
+ * The places once the circuit <ticket> of the project <racine> gives its place back: that place is
386
+ * taken off the limit of the project and off the ceiling of the machine in one gesture. A circuit
387
+ * that holds none leaves the places as they are; the same circuit of another project keeps its own.
388
+ * @param {Array<{ racine: string, ticket: string }>} places
389
+ * @param {{ racine: string, ticket: string }} q
390
+ */
391
+ export function rendreSaPlace(places, { racine, ticket }) {
392
+ return places.filter(c => !(c.racine === racine && c.ticket === ticket));
393
+ }
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env bash
2
2
  # The removal of a working copy (packages/grillhouse/docs/architecture/entree.md §5.3, « Après les
3
3
  # étapes »; §5.1 for the queue's copy), called by the three places that end one: the agent copy (by
4
- # scripts/integration/integrer.mjs once its lot is committed, and by the supervisor for a ticket
5
- # closed without integration), the integration copy (by the same script) and the night copy
4
+ # scripts/integration/integrer.mjs once its lot is in the queue, and by the supervisor for a ticket
5
+ # closed without integration), the queue's copy (scripts/integration/rejeu.mjs) and the night copy
6
6
  # (scripts/nuit.sh), the last two when their existing copy does not get ready; and by the night
7
7
  # for every other copy once its steps are played (scripts/copies-finies.mjs), without `--jetable`.
8
8
  #