@roomi-fields/grillhouse 0.54.1 → 0.55.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +69 -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 +16 -0
  77. package/dist/temporal/places/client.js +25 -1
  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/consommation-des-passes.mjs +67 -31
  118. package/scripts/consommation.mjs +152 -24
  119. package/scripts/copies-finies.mjs +15 -35
  120. package/scripts/dernier-vert.mjs +4 -5
  121. package/scripts/dette.mjs +5 -3
  122. package/scripts/droits.mjs +2 -2
  123. package/scripts/echantillonneur-de-la-passe.mjs +7 -31
  124. package/scripts/engendres.mjs +5 -61
  125. package/scripts/enveloppe/enveloppe.mjs +30 -34
  126. package/scripts/enveloppe/travail-de-la-copie.mjs +5 -0
  127. package/scripts/etapes.mjs +21 -7
  128. package/scripts/etat-du-depot.mjs +61 -0
  129. package/scripts/faits-du-circuit.mjs +7 -4
  130. package/scripts/fermeture-de-la-machine.d.mts +6 -4
  131. package/scripts/fermeture-de-la-machine.mjs +12 -16
  132. package/scripts/fichier-du-poste.d.mts +9 -0
  133. package/scripts/file-des-tickets.d.mts +0 -18
  134. package/scripts/file-des-tickets.mjs +0 -42
  135. package/scripts/fusion-du-changelog.mjs +1 -1
  136. package/scripts/grillhouse-maj.mjs +1 -1
  137. package/scripts/index-des-rouges.d.mts +40 -0
  138. package/scripts/index-des-rouges.mjs +104 -0
  139. package/scripts/integration/file.mjs +13 -63
  140. package/scripts/integration/integrer.mjs +157 -424
  141. package/scripts/integration/jugement.mjs +109 -0
  142. package/scripts/integration/rejeu.mjs +94 -71
  143. package/scripts/jointure.d.ts +34 -27
  144. package/scripts/journal-des-etats.d.mts +1 -1
  145. package/scripts/langages/c/commandes.mjs +27 -12
  146. package/scripts/langages/cargo/commandes.mjs +148 -94
  147. package/scripts/langages/cargo/index.mjs +2 -1
  148. package/scripts/langages/cargo/lectures-des-tests.mjs +132 -0
  149. package/scripts/langages/cargo/migrations/lectures-des-tests.mjs +31 -0
  150. package/scripts/langages/python/commandes.mjs +31 -15
  151. package/scripts/langages/python/index.mjs +2 -1
  152. package/scripts/langages/python/lectures-des-tests.mjs +148 -0
  153. package/scripts/langages/python/migrations/lectures-des-tests.mjs +31 -0
  154. package/scripts/langages/typescript/consommateurs-arbitres.mjs +2 -2
  155. package/scripts/langages/typescript/index.mjs +4 -0
  156. package/scripts/langages/typescript/lectures-des-tests.mjs +95 -0
  157. package/scripts/langages/typescript/migrations/lectures-des-tests.mjs +31 -0
  158. package/scripts/langages/typescript/tests-de-nuit.mjs +9 -15
  159. package/scripts/langages/typescript/tests.mjs +11 -37
  160. package/scripts/langages/typescript/titres-de-tests.mjs +5 -4
  161. package/scripts/langages/typescript/verifier.mjs +74 -44
  162. package/scripts/langages/typescript/vitest-config/base.mjs +3 -3
  163. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +6 -25
  164. package/scripts/lectures-communes.mjs +234 -0
  165. package/scripts/machine.mjs +11 -18
  166. package/scripts/mesure/base-de-passe.mjs +1 -2
  167. package/scripts/mesure-de-la-machine.d.mts +40 -3
  168. package/scripts/mesure-de-la-machine.mjs +201 -11
  169. package/scripts/migrations/0.33.0-ci-du-cadre.mjs +3 -3
  170. package/scripts/migrations/nuit-yml-retire.mjs +25 -0
  171. package/scripts/migrations/part-retiree.mjs +31 -0
  172. package/scripts/migrations.mjs +4 -0
  173. package/scripts/montee.mjs +9 -0
  174. package/scripts/nuit-de-pc2.mjs +628 -0
  175. package/scripts/nuit.sh +8 -131
  176. package/scripts/paquets.mjs +1 -1
  177. package/scripts/passe-de-la-machine.mjs +340 -103
  178. package/scripts/place-du-circuit.d.mts +15 -0
  179. package/scripts/place-du-circuit.mjs +32 -0
  180. package/scripts/places-de-la-machine.mjs +148 -626
  181. package/scripts/places-du-serveur.mjs +26 -13
  182. package/scripts/plafond-de-la-machine.d.mts +8 -13
  183. package/scripts/plafond-de-la-machine.mjs +26 -56
  184. package/scripts/registre-des-entrees.mjs +57 -0
  185. package/scripts/regles-des-places.d.mts +82 -50
  186. package/scripts/regles-des-places.mjs +192 -156
  187. package/scripts/retirer-copie.sh +2 -2
  188. package/scripts/seances.mjs +181 -63
  189. package/scripts/secours.mjs +95 -0
  190. package/scripts/services-du-noyau.mjs +11 -19
  191. package/scripts/sous-commandes.mjs +1 -0
  192. package/scripts/sous-modules.sh +1 -1
  193. package/scripts/superviseur.mjs +16 -7
  194. package/scripts/table-des-consommations.d.mts +9 -0
  195. package/scripts/table-des-consommations.mjs +35 -0
  196. package/scripts/tableau.mjs +33 -19
  197. package/scripts/taches-du-graphe.mjs +124 -2
  198. package/scripts/transitions.d.mts +27 -5
  199. package/scripts/transitions.mjs +122 -104
  200. package/scripts/verdict-de-la-nuit.d.mts +13 -0
  201. package/scripts/verdict-de-la-nuit.mjs +34 -7
  202. package/scripts/verrou-de-fichier.mjs +1 -2
  203. package/scripts/workflows-du-cadre.mjs +2 -2
  204. package/skills/developpeur/SKILL.md +8 -2
  205. package/skills/direct/SKILL.md +5 -0
  206. package/skills/explorateur/SKILL.md +10 -1
  207. package/skills/grill/SKILL.md +2 -4
  208. package/skills/pitmaster/SKILL.md +7 -5
  209. package/skills/pitmaster/references/consigne-agent.md +1 -1
  210. package/skills/relecteur/SKILL.md +4 -1
  211. package/skills/testwriter/SKILL.md +15 -2
  212. package/cadre/templates/projet/.env.example +0 -57
  213. package/cadre/templates/projet/.github/workflows/nuit.yml +0 -139
  214. package/cadre/templates/projet/deployment/README.md +0 -98
  215. package/cadre/templates/projet/deployment/docs/01-INSTALL.md +0 -145
  216. package/cadre/templates/projet/deployment/docs/02-CONFIGURATION.md +0 -117
  217. package/cadre/templates/projet/deployment/docs/03-API.md +0 -264
  218. package/cadre/templates/projet/deployment/docs/04-TROUBLESHOOTING.md +0 -262
  219. package/cadre/templates/projet/deployment/scripts/install.ps1 +0 -100
  220. package/cadre/templates/projet/deployment/scripts/start.ps1 +0 -61
  221. package/cadre/templates/projet/deployment/scripts/stop.ps1 +0 -37
  222. package/cadre/templates/projet/deployment/scripts/test.ps1 +0 -118
  223. package/cadre/templates/projet/ecosystem.config.cjs +0 -73
  224. package/cadre/templates/projet/src/config.ts +0 -68
  225. package/cadre/templates/projet/src/errors.ts +0 -102
  226. package/cadre/templates/projet/src/index.ts +0 -46
  227. package/cadre/templates/projet/src/services/.gitkeep +0 -8
  228. package/cadre/templates/projet/src/types/index.ts +0 -24
  229. package/cadre/templates/projet/src/utils/logger.ts +0 -106
  230. package/cadre/templates/projet/tests/unit/config.spec.ts +0 -68
  231. package/cadre/templates/projet/tests/unit/errors.spec.ts +0 -132
  232. package/cadre/templates/projet/tests/unit/types.spec.ts +0 -73
  233. package/cadre/templates/projet/tsconfig.build.json +0 -14
  234. package/scripts/flux-de-la-nuit.mjs +0 -39
  235. package/scripts/garde-de-la-memoire.mjs +0 -231
  236. package/scripts/repli-de-la-nuit.mjs +0 -184
@@ -11,7 +11,39 @@ export function lireLaMemoire(texte: string): { disponible: number | null; echan
11
11
  /** What the machine still gives now: the memory available and the free swap, in bytes. */
12
12
  export function memoireRestante(): { disponible: number | null; echange: number };
13
13
 
14
- /** The machine now: its cores, its load over one minute, its free memory in bytes. */
14
+ /** The window the cores occupied are read on, in ms: ten seconds. */
15
+ export const FENETRE_DE_CHARGE_MS: number;
16
+
17
+ /** The idle and the total processor time the aggregate line of <texte> (/proc/stat) says; null without it. */
18
+ export function lireLeTempsDuProcesseur(texte: string): { inactif: number; total: number } | null;
19
+
20
+ /** The cores occupied over the last ten seconds, from the samples of /proc/stat. */
21
+ export function coeursOccupes(
22
+ echantillons: readonly { t: number; inactif: number; total: number }[],
23
+ o: { coeurs: number; maintenant: number }
24
+ ): number;
25
+
26
+ /** The pressure `full avg10` of the memory in <texte> (/proc/pressure/memory), in %; null without. */
27
+ export function lireLaPressionDeLaMemoire(texte: string): number | null;
28
+
29
+ /** What the watch of the arbiter reads of the memory now (bytes, %). */
30
+ export function lireLaMemoireSurveillee(): {
31
+ pression: number | null;
32
+ disponible: number | null;
33
+ echangeEnMemoire: number;
34
+ echangeSurDisqueUtilise: number;
35
+ };
36
+
37
+ /** The memory the group of the step <id> holds now, in bytes; null when it does not answer. */
38
+ export function memoireDeLEtape(id: string): number | null;
39
+
40
+ /** Stops the group of the step <id> (SIGTERM, then SIGKILL); false when it has none. */
41
+ export function arreterLEtape(id: string, delaiMs?: number): boolean;
42
+
43
+ /** The scope of the group of the step <id>. */
44
+ export function uniteDeLEtape(id: string): string;
45
+
46
+ /** The machine now: its cores, the cores occupied over ten seconds, its free memory in bytes. */
15
47
  export function mesureDeLaMachine(): MesureDeLaMachine;
16
48
 
17
49
  /** The start of the process <pid> as the system gives it, null when it is gone. */
@@ -21,7 +53,12 @@ export function departDe(pid: number): string | null;
21
53
  export function processusVivant(p: { pid: number; depart: string | null }): boolean;
22
54
 
23
55
  /** <signal> to the process group <groupe>; false when the group is gone. */
24
- export function signalerGroupe(groupe: number | null | undefined, signal: NodeJS.Signals | 0): boolean;
56
+ export function signalerGroupe(
57
+ groupe: number | null | undefined,
58
+ signal: NodeJS.Signals | 0
59
+ ): boolean;
25
60
 
26
61
  /** Whether the group a sign of life <vie> names still runs, its leader dead or alive. */
27
- export function groupeVivant(vie: { pid: number; depart?: string | null } | null | undefined): boolean;
62
+ export function groupeVivant(
63
+ vie: { pid: number; depart?: string | null } | null | undefined
64
+ ): boolean;
@@ -1,13 +1,14 @@
1
1
  // What the machine gives at a moment, which the admission of a start reads
2
- // (scripts/regles-des-places.mjs): its cores, its load over one minute, its free memory, and its
3
- // total memory, which the board shows beside it. The
2
+ // (scripts/regles-des-places.mjs): its cores, the cores occupied over the last ten seconds (read
3
+ // on the idle time of /proc/stat), its free memory, and its total memory, which the board shows beside it. The
4
4
  // activity of the workflow of the machine (src/temporal/places/activites.ts) measures it here, and
5
5
  // whether the process of a place still lives; a signal to a process group, and whether the group
6
6
  // a sign of life names still runs, which the sessions (scripts/seances.mjs), the circuit and the
7
7
  // acts under Temporal (src/temporal/acte.ts) share. Architecture: docs/architecture/machine.md
8
8
  // (§3.1, §5.2).
9
+ import { spawnSync } from 'node:child_process';
9
10
  import { readFileSync } from 'node:fs';
10
- import { availableParallelism, freemem, loadavg, totalmem } from 'node:os';
11
+ import { availableParallelism, freemem, totalmem } from 'node:os';
11
12
  import { departDe, leMemeVivant, vivant } from './mesure/base-de-passe.mjs';
12
13
 
13
14
  export { departDe };
@@ -40,6 +41,107 @@ export function memoireRestante() {
40
41
  }
41
42
  }
42
43
 
44
+ /**
45
+ * The pressure `full avg10` of the memory in <texte> (/proc/pressure/memory), in %: the share of
46
+ * the last ten seconds in which every task waited for memory; null when it does not say it.
47
+ * @param {string} texte
48
+ * @returns {number | null}
49
+ */
50
+ export function lireLaPressionDeLaMemoire(texte) {
51
+ const m = /^full\b.*\bavg10=(\d+(?:\.\d+)?)/m.exec(texte);
52
+ return m ? Number(m[1]) : null;
53
+ }
54
+
55
+ /**
56
+ * The swap <texte> (/proc/swaps) says, in bytes: what is free in a swap held in memory (zram) and
57
+ * what is used on a disk.
58
+ * @param {string} texte
59
+ * @returns {{ enMemoire: number, surDisque: number }}
60
+ */
61
+ export function lireLesEchanges(texte) {
62
+ let enMemoire = 0;
63
+ let surDisque = 0;
64
+ for (const ligne of texte.split('\n').slice(1)) {
65
+ const [fichier, , taille, utilise] = ligne.trim().split(/\s+/);
66
+ if (!fichier || !/^\d+$/.test(taille ?? '') || !/^\d+$/.test(utilise ?? '')) {
67
+ continue;
68
+ }
69
+ if (/\/zram\d+$/.test(fichier)) {
70
+ enMemoire += (Number(taille) - Number(utilise)) * 1024;
71
+ } else {
72
+ surDisque += Number(utilise) * 1024;
73
+ }
74
+ }
75
+ return { enMemoire, surDisque };
76
+ }
77
+
78
+ const lireOuVide = fichier => {
79
+ try {
80
+ return readFileSync(fichier, 'utf8');
81
+ } catch {
82
+ return null;
83
+ }
84
+ };
85
+
86
+ /**
87
+ * What the watch of the arbiter reads of the memory now: the pressure (null where the machine
88
+ * does not say it), the memory available (null likewise), the swap free in memory and the swap
89
+ * used on disk, in bytes.
90
+ * @returns {{ pression: number | null, disponible: number | null, echangeEnMemoire: number,
91
+ * echangeSurDisqueUtilise: number }}
92
+ */
93
+ export function lireLaMemoireSurveillee() {
94
+ const pression = lireOuVide('/proc/pressure/memory');
95
+ const echanges = lireLesEchanges(lireOuVide('/proc/swaps') ?? '');
96
+ return {
97
+ pression: pression === null ? null : lireLaPressionDeLaMemoire(pression),
98
+ disponible: memoireRestante().disponible,
99
+ echangeEnMemoire: echanges.enMemoire,
100
+ echangeSurDisqueUtilise: echanges.surDisque,
101
+ };
102
+ }
103
+
104
+ /** The scope of the group of a step: a pass or a session is named after the id of its reservation. */
105
+ export const uniteDeLEtape = id => `grillhouse-passe-${id}.scope`;
106
+
107
+ /**
108
+ * The memory the group of the step <id> holds now, in bytes; null when the group does not answer.
109
+ * @param {string} id
110
+ * @returns {number | null}
111
+ */
112
+ export function memoireDeLEtape(id) {
113
+ const r = spawnSync(
114
+ 'systemctl',
115
+ ['--user', 'show', uniteDeLEtape(id), '-p', 'MemoryCurrent', '--value'],
116
+ {
117
+ encoding: 'utf8',
118
+ timeout: 10_000,
119
+ }
120
+ );
121
+ const n = Number((r.stdout ?? '').trim());
122
+ return r.status === 0 && Number.isFinite(n) && /^\d+$/.test((r.stdout ?? '').trim()) ? n : null;
123
+ }
124
+
125
+ /**
126
+ * Stops the group of the step <id> and every process in it (SIGTERM, then SIGKILL after
127
+ * <delaiMs>); false when the system has no such group.
128
+ * @param {string} id
129
+ * @param {number} [delaiMs]
130
+ * @returns {boolean}
131
+ */
132
+ export function arreterLEtape(id, delaiMs = 5000) {
133
+ const signaler = signal =>
134
+ spawnSync('systemctl', ['--user', 'kill', `--signal=${signal}`, uniteDeLEtape(id)], {
135
+ timeout: 10_000,
136
+ }).status === 0;
137
+ if (!signaler('SIGTERM')) {
138
+ return false;
139
+ }
140
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, delaiMs);
141
+ signaler('SIGKILL');
142
+ return true;
143
+ }
144
+
43
145
  /**
44
146
  * The memory available now, in bytes (MemAvailable of the kernel, else the free memory of node).
45
147
  * @returns {number}
@@ -48,17 +150,105 @@ export function memoireDisponible() {
48
150
  return memoireRestante().disponible ?? freemem();
49
151
  }
50
152
 
153
+ /** The window the cores occupied are read on, in ms: the last ten seconds. */
154
+ export const FENETRE_DE_CHARGE_MS = 10_000;
155
+
156
+ /**
157
+ * The processor time the aggregate line `cpu` of <texte> (/proc/stat) says, in clock ticks: the
158
+ * idle time (idle and iowait) and the total (the eight first fields, steal included); null without
159
+ * that line. The lines of each core (`cpu0`…) are not read.
160
+ * @param {string} texte
161
+ * @returns {{ inactif: number, total: number } | null}
162
+ */
163
+ export function lireLeTempsDuProcesseur(texte) {
164
+ const ligne = /^cpu\s+(.*)$/m.exec(texte);
165
+ if (!ligne) {
166
+ return null;
167
+ }
168
+ const champs = ligne[1].trim().split(/\s+/).map(Number);
169
+ return {
170
+ inactif: (champs[3] ?? 0) + (champs[4] ?? 0),
171
+ total: champs.slice(0, 8).reduce((n, c) => n + (c || 0), 0),
172
+ };
173
+ }
174
+
51
175
  /**
52
- * The machine now: `{ coeurs, charge, memoireLibre, memoireTotale }`, the load over one minute,
53
- * the memories in bytes.
176
+ * The cores occupied over the last FENETRE_DE_CHARGE_MS before <maintenant>: the cores times the
177
+ * occupied share of the processor time between the oldest sample of the window and the last. A
178
+ * sample is `{ t, inactif, total }` (`t` in ms, the times of `lireLeTempsDuProcesseur`); no time
179
+ * elapsed between them gives zero.
180
+ * @param {{ t: number, inactif: number, total: number }[]} echantillons in order
181
+ * @param {{ coeurs: number, maintenant: number }} o
182
+ * @returns {number}
183
+ */
184
+ export function coeursOccupes(echantillons, { coeurs, maintenant }) {
185
+ const dernier = echantillons.at(-1);
186
+ const debut = echantillons.find(e => e.t >= maintenant - FENETRE_DE_CHARGE_MS);
187
+ if (!dernier || !debut) {
188
+ return 0;
189
+ }
190
+ const total = dernier.total - debut.total;
191
+ if (total <= 0) {
192
+ return 0;
193
+ }
194
+ const occupee = 1 - (dernier.inactif - debut.inactif) / total;
195
+ return Math.min(coeurs, Math.max(0, coeurs * occupee));
196
+ }
197
+
198
+ // The samples of the processor time this process took, the window and the one before it.
199
+ const echantillons = [];
200
+ const PAUSE_DU_PREMIER_RELEVE_MS = 200;
201
+
202
+ // Takes a sample now; false where /proc/stat does not read.
203
+ function echantillonner() {
204
+ try {
205
+ const temps = lireLeTempsDuProcesseur(readFileSync('/proc/stat', 'utf8'));
206
+ if (!temps) {
207
+ return false;
208
+ }
209
+ const t = Date.now();
210
+ echantillons.push({ t, ...temps });
211
+ while (echantillons.length > 2 && echantillons[1].t < t - FENETRE_DE_CHARGE_MS) {
212
+ echantillons.shift();
213
+ }
214
+ return true;
215
+ } catch {
216
+ return false;
217
+ }
218
+ }
219
+
220
+ /**
221
+ * The cores occupied now over the last ten seconds, on /proc/stat: a long-lived process (the
222
+ * arbiter) samples at each call and reads its window; a first call has no past, and waits a
223
+ * moment between two samples. Zero where /proc/stat does not read.
224
+ * @param {number} coeurs
225
+ * @returns {number}
226
+ */
227
+ function coeursOccupesMaintenant(coeurs) {
228
+ if (!echantillonner()) {
229
+ return 0;
230
+ }
231
+ if (echantillons.length < 2) {
232
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, PAUSE_DU_PREMIER_RELEVE_MS);
233
+ echantillonner();
234
+ }
235
+ return coeursOccupes(echantillons, { coeurs, maintenant: Date.now() });
236
+ }
237
+
238
+ /**
239
+ * The machine now: `{ coeurs, charge, memoireLibre, memoireTotale }`, `charge` the cores occupied
240
+ * over the last ten seconds, the memories in bytes.
54
241
  * @returns {{ coeurs: number, charge: number, memoireLibre: number, memoireTotale: number }}
55
242
  */
56
- export const mesureDeLaMachine = () => ({
57
- coeurs: availableParallelism(),
58
- charge: loadavg()[0],
59
- memoireLibre: memoireDisponible(),
60
- memoireTotale: totalmem(),
61
- });
243
+ export const mesureDeLaMachine = () => {
244
+ const coeurs = availableParallelism();
245
+ return {
246
+ coeurs,
247
+ charge: coeursOccupesMaintenant(coeurs),
248
+ memoireLibre: memoireDisponible(),
249
+ memoireTotale: totalmem(),
250
+ };
251
+ };
62
252
 
63
253
  /**
64
254
  * Whether the process <pid> lives and is the one of its start <depart> (`departDe`; any process
@@ -1,5 +1,5 @@
1
- // The frame carries the CI of a project: the template's `.github/workflows/ci.yml` and `nuit.yml`,
2
- // each bearing the frame's mark on its first line (scripts/workflows-du-cadre.mjs). Mechanism:
1
+ // The frame carries the CI of a project: the template's `.github/workflows/ci.yml`,
2
+ // bearing the frame's mark on its first line (scripts/workflows-du-cadre.mjs). Mechanism:
3
3
  // installation.md §5.2 and §5.4 (packages/grillhouse/docs/architecture/).
4
4
  //
5
5
  // - The migration changes no file: a project's CI is its own until it adopts the frame's.
@@ -23,6 +23,6 @@ export function restes(projet) {
23
23
  }
24
24
  const modele = path.relative(projet, path.join(CADRE, GABARIT_DES_WORKFLOWS, 'ci.yml'));
25
25
  return [
26
- `${WORKFLOWS} : le cadre porte la CI d'un projet (ci.yml, le lot en tranches ; nuit.yml, les tests de nuit hors du poste). Pour l'adopter, copier \`${modele}\` dans \`${WORKFLOWS}/\` (un ci.yml du projet cède sa place, ses étapes propres versées ailleurs), puis \`npx grillhouse maj\`, qui écrit nuit.yml et tient les deux à jour. Leur machine : la variable RUNNER du dépôt sur GitHub, facultative (ubuntu-latest sans elle).`,
26
+ `${WORKFLOWS} : le cadre porte la CI d'un projet (ci.yml, le lot en tranches). Pour l'adopter, copier \`${modele}\` dans \`${WORKFLOWS}/\` (un ci.yml du projet cède sa place, ses étapes propres versées ailleurs), puis \`npx grillhouse maj\`, qui le tient à jour. Leur machine : la variable RUNNER du dépôt sur GitHub, facultative (ubuntu-latest sans elle).`,
27
27
  ];
28
28
  }
@@ -0,0 +1,25 @@
1
+ // The night no longer plays on GitHub: the frame neither reads nor writes `.github/workflows/nuit.yml`
2
+ // any more (entree.md §5.3). The file of a project that bears the frame's mark on its first line is
3
+ // removed; one without the mark is the project's own, stays, and is reported. Mechanism:
4
+ // installation.md §5.4 (packages/grillhouse/docs/architecture/).
5
+ import { existsSync, readFileSync, rmSync } from 'node:fs';
6
+ import path from 'node:path';
7
+ import { estDuCadre, WORKFLOWS } from '../workflows-du-cadre.mjs';
8
+
9
+ // Not released yet: it plays for a project that recorded no version or one below the package's.
10
+ export const version = '0.55.0';
11
+ export const nom = 'nuit yml retire';
12
+
13
+ /** The `nuit.yml` of the frame removed from the project at <projet>; returns what it did. */
14
+ export function migrer(projet) {
15
+ const relatif = `${WORKFLOWS}/nuit.yml`;
16
+ const fichier = path.join(projet, relatif);
17
+ if (!existsSync(fichier)) {
18
+ return [];
19
+ }
20
+ if (estDuCadre(readFileSync(fichier, 'utf8'))) {
21
+ rmSync(fichier);
22
+ return [`${relatif} : le flux de la nuit du cadre est retiré, la nuit ne tourne plus sur GitHub`];
23
+ }
24
+ return [`${relatif} : nuit.yml du projet, que le cadre ne lit plus : à retirer ou à garder`];
25
+ }
@@ -0,0 +1,31 @@
1
+ // A project holds no key `grillhouse.part`: the reservation of a pass comes from the table of the
2
+ // consumptions of its sort, which the arbiter admits, and nothing reads the key any more. The key
3
+ // goes from the package.json of the project, its other keys `grillhouse.*`, its layout and its end of
4
+ // line kept, and the `grillhouse` object that held nothing else goes with it. Mechanism:
5
+ // installation.md §5.4 (packages/grillhouse/docs/architecture/).
6
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
7
+ import path from 'node:path';
8
+
9
+ // Not released yet: it plays for a project that recorded no version or one below the package's.
10
+ export const version = '0.55.0';
11
+ export const nom = 'part retiree';
12
+
13
+ /** The key `grillhouse.part` removed from the package.json of <projet>; returns what it did. */
14
+ export function migrer(projet) {
15
+ const fichier = path.join(projet, 'package.json');
16
+ if (!existsSync(fichier)) {
17
+ return [];
18
+ }
19
+ const texte = readFileSync(fichier, 'utf8');
20
+ const pkg = JSON.parse(texte);
21
+ if (!pkg?.grillhouse || typeof pkg.grillhouse !== 'object' || !('part' in pkg.grillhouse)) {
22
+ return [];
23
+ }
24
+ delete pkg.grillhouse.part;
25
+ const indent = /^\n?(\s+)"/m.exec(texte)?.[1] ?? 2;
26
+ const fin = texte.endsWith('\n') ? '\n' : '';
27
+ writeFileSync(fichier, `${JSON.stringify(pkg, null, indent)}${fin}`);
28
+ return [
29
+ 'package.json : la clé grillhouse.part est retirée, la réservation d’une passe vient de la table des consommations',
30
+ ];
31
+ }
@@ -54,6 +54,8 @@ import * as reservationDeTroisCoeurs from './migrations/0.49.0-reservation-de-tr
54
54
 
55
55
  import * as reglagesHorsDeLaCharte from './migrations/0.50.0-reglages-hors-de-la-charte.mjs';
56
56
  import * as lireUnTicket from './migrations/lire-un-ticket.mjs';
57
+ import * as partRetiree from './migrations/part-retiree.mjs';
58
+ import * as nuitYmlRetire from './migrations/nuit-yml-retire.mjs';
57
59
  import * as serveursDeLIndex from './migrations/serveurs-de-l-index.mjs';
58
60
  import * as coutDesJetons from './migrations/cout-des-jetons-au-registre.mjs';
59
61
  import * as suiviDuSuperviseurRetire from './migrations/suivi-du-superviseur-retire.mjs';
@@ -86,6 +88,8 @@ export const MIGRATIONS = [
86
88
  coutDesJetons,
87
89
  suiviDuSuperviseurRetire,
88
90
  lireUnTicket,
91
+ partRetiree,
92
+ nuitYmlRetire,
89
93
  ];
90
94
 
91
95
  /**
@@ -385,6 +385,15 @@ export function jouerLePoste(montee, echoues = []) {
385
385
  ['--planifier']
386
386
  )
387
387
  );
388
+ essayer('npx grillhouse consommation --planifier', () =>
389
+ duPoste(
390
+ principal,
391
+ 'npx grillhouse consommation --planifier',
392
+ paquetDuPoste(montee),
393
+ 'scripts/consommation.mjs',
394
+ ['--planifier']
395
+ )
396
+ );
388
397
  echecs.forEach(signaler);
389
398
  if (echecs.length > 0) {
390
399
  signaler(