@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
@@ -13,11 +13,11 @@
13
13
  // node places-du-serveur.mjs rouvrir
14
14
  //
15
15
  // - Each mode first starts the workflow of the machine when none runs (`demarrerLesPlaces`, on the
16
- // task queue of the worker of the machine), its spacing GRILLHOUSE_ESPACEMENT_MS
17
- // (scripts/places-de-la-machine.mjs); it reads its ceiling from the poste itself.
16
+ // task queue of the worker of the machine); it reads its ceiling and its budget from the poste
17
+ // itself.
18
18
  // - `rang` writes the next rank of arrival of the machine, which a circuit draws at its launch.
19
- // - `prendre` asks for a place for <demande> (JSON: `{ pid, depart, ticket, rang, borneMs,
20
- // rappelMs }`, the process that holds it), then waits for it: each line it says, at the start of
19
+ // - `prendre` asks for a reservation for <demande> (JSON: `{ pid, depart, ticket, rang, coeurs,
20
+ // memoire, borneMs, rappelMs }`, the process that holds it), then waits for it: each line it says, at the start of
21
21
  // a wait and every <rappelMs>, is one JSON line `{ dire }` on the standard output, then the place
22
22
  // given, `{ id, rang }`. At the bound <borneMs>, the request is withdrawn, its line said, exit 75.
23
23
  // - `rendre` gives the place <id> back (or withdraws its request), `rattacher` names the process
@@ -29,12 +29,14 @@
29
29
  // transiently. Still failing, its port open: the server is busy, said on the error stream, exit
30
30
  // 75. A port refused (no server), another failure, or a client not built: said on the error
31
31
  // stream, exit 1. A malformed call, exit 2.
32
+ import { spawnSync } from 'node:child_process';
32
33
  import { randomUUID } from 'node:crypto';
33
34
  import { existsSync } from 'node:fs';
34
35
  import net from 'node:net';
35
36
  import path from 'node:path';
36
37
  import { pathToFileURL } from 'node:url';
37
38
  import { A_REPASSER } from './codes-de-sortie.mjs';
39
+ import { leverLaRestriction } from './coeurs-dedies.mjs';
38
40
  import { duree, RAISON_FERMEE } from './regles-des-places.mjs';
39
41
 
40
42
  // The start of the reason of a wait under the supervisor's closure.
@@ -111,12 +113,9 @@ export function ecoute(adresse, delaiMs = 2_000) {
111
113
  // How often a wait reads its request again.
112
114
  const VEILLE_MS = 1_000;
113
115
 
114
- // The spacing of the machine under <env>, as scripts/places-de-la-machine.mjs reads it; the
115
- // workflow's veille, a second. The ceiling, the workflow reads from the poste at each judgement.
116
- const entreeDe = async env => {
117
- const { espacementDe } = await import('./places-de-la-machine.mjs');
118
- return { espacementMs: espacementDe(env), veilleMs: 1_000 };
119
- };
116
+ // The entry of the workflow of the machine: its veille, a second. The ceiling and the budget, the
117
+ // workflow reads from the poste at each judgement.
118
+ const entreeDe = () => ({ veilleMs: 1_000 });
120
119
 
121
120
  const MODES = { rang: 0, prendre: 1, rendre: 1, rattacher: 3, lire: 0, fermer: 0, rouvrir: 0 };
122
121
  const ecrire = o => process.stdout.write(`${JSON.stringify(o)}\n`);
@@ -167,6 +166,36 @@ export async function attendreLaPlace(
167
166
  }
168
167
  }
169
168
 
169
+ // Builds the package (`npm run build`) when the
170
+ // client is not yet built, so a fresh copy (the final pass of the queue) asks the arbiter without
171
+ // a build of its own before; false when the build fails, its output on the error stream.
172
+ function construireLeClient() {
173
+ const racine = path.join(import.meta.dirname, '..');
174
+ const r = spawnSync('npm', ['run', 'build'], {
175
+ cwd: racine,
176
+ encoding: 'utf8',
177
+ });
178
+ if (r.status !== 0) {
179
+ process.stderr.write(`${r.stdout ?? ''}${r.stderr ?? ''}${r.error?.message ?? ''}\n`);
180
+ }
181
+ return r.status === 0 && existsSync(path.join(DIST, 'places', 'client.js'));
182
+ }
183
+
184
+ /**
185
+ * Opens the arbiter when none runs. No measure holds a place when it opens, so the restriction a
186
+ * dead measure left on the programs out of the frame is lifted then (`lever`).
187
+ * @param {{ places: { demarrerLesPlaces: Function }, client: unknown, entree: unknown, file: string,
188
+ * lever?: () => unknown }} o
189
+ * @returns {Promise<boolean>} true when this call opened the arbiter
190
+ */
191
+ export async function ouvrirLArbitre({ places, client, entree, file, lever = leverLaRestriction }) {
192
+ const ouvert = await places.demarrerLesPlaces(client, entree, { file });
193
+ if (ouvert) {
194
+ lever();
195
+ }
196
+ return ouvert;
197
+ }
198
+
170
199
  // The call <mode> with <args>: its exit code.
171
200
  async function principal(mode, args) {
172
201
  if (!Object.hasOwn(MODES, mode ?? '') || args.length !== MODES[mode]) {
@@ -175,9 +204,9 @@ async function principal(mode, args) {
175
204
  );
176
205
  return 2;
177
206
  }
178
- if (!existsSync(path.join(DIST, 'places', 'client.js'))) {
207
+ if (!existsSync(path.join(DIST, 'places', 'client.js')) && !construireLeClient()) {
179
208
  process.stderr.write(
180
- `le client Temporal n'est pas construit (${DIST}) : la construction du paquet le pose, \`npm run build --workspace @roomi-fields/grillhouse\`.\n`
209
+ `le client Temporal n'est pas construit (${DIST}) et sa construction échoue, \`npm run build --workspace @roomi-fields/grillhouse\`.\n`
181
210
  );
182
211
  return 1;
183
212
  }
@@ -191,10 +220,8 @@ async function principal(mode, args) {
191
220
  const sous = f => avecReprises(() => c.client.connection.withDeadline(Date.now() + DELAI_MS, f));
192
221
  try {
193
222
  try {
194
- await sous(async () =>
195
- places.demarrerLesPlaces(c.client, await entreeDe(process.env), {
196
- file: FILE_DE_LA_MACHINE,
197
- })
223
+ await sous(() =>
224
+ ouvrirLArbitre({ places, client: c.client, entree: entreeDe(), file: FILE_DE_LA_MACHINE })
198
225
  );
199
226
  } catch (x) {
200
227
  if (x?.name !== 'WorkflowExecutionAlreadyStartedError') {
@@ -41,19 +41,14 @@ export function budgetDe(
41
41
  reserve: PartDeLaPasse
42
42
  ): PartDeLaPasse;
43
43
 
44
- /** The reservation of a pass: the declared cores, else 3, within the budget; its memory the
45
- * declared one, else the default memory, within the budget. */
46
- export function partDe(o: {
47
- declaree: { coeurs?: number; memoire?: number } | null;
48
- budget: PartDeLaPasse;
49
- pic: number | undefined;
50
- }): PartDeLaPasse;
51
-
52
- /** The part a project declares in `grillhouse.part` of its package.json, or the fault naming it. */
53
- export function partDeclareeDe(pkg: { grillhouse?: unknown } | null | undefined): {
54
- declaree: { coeurs?: number; memoire?: number } | null;
55
- faute: string | null;
56
- };
44
+ /** The default reservation of a pass: 3 cores within the budget, the default memory within it. */
45
+ export function partDe(o: { budget: PartDeLaPasse; pic?: number; places?: number }): PartDeLaPasse;
46
+
47
+ /** The ceiling of a part without a measure: its reservation plus a quarter, within the budget. */
48
+ export function plafondDeDepart(
49
+ part: PartDeLaPasse,
50
+ budget: PartDeLaPasse
51
+ ): { limite: number; limiteCoeurs: number };
57
52
 
58
53
  /** The hardware of this machine: its cores and its total memory (bytes). */
59
54
  export function materielDeLaMachine(): { coeurs: number; memoireTotale: number };
@@ -11,25 +11,22 @@
11
11
  // file. Without either, PLAFOND_PAR_DEFAUT, 3.
12
12
  // - A value that is not a positive integer is refused by its name and its place.
13
13
  //
14
- // The budget of the machine and the part of a pass (functions with the hardware and the settings
15
- // as input, nothing read from the machine):
14
+ // The budget of the machine and the default reservation of a pass (functions with the hardware and
15
+ // the settings as input, nothing read from the machine):
16
16
  // - The reserve of the user, the share of the machine no pass takes: GRILLHOUSE_RESERVE_COEURS
17
17
  // (by default min(4, max(0, cores − 4)): 0 on 4 cores or fewer, 2 on 6, 4 from 8) and
18
18
  // GRILLHOUSE_RESERVE_MEMOIRE_GO (4 GB), the environment first, then `machine.env`; zero is
19
19
  // admitted, a value that is not a whole number ≥ 0 is refused by its name.
20
20
  // - The budget is the cores and the memory of the machine less the reserve; a reserve that leaves
21
21
  // no core or no memory is refused by its name.
22
- // - The part of a pass (`partDe`) is its cores and its memory, within the budget and one core at
23
- // least. Its cores are those its project declares (`grillhouse.part` of its `package.json`),
24
- // else COEURS_PAR_DEFAUT. Its memory is the declared
25
- // one, else the largest peak the project measured plus a quarter, never under a floor (the
26
- // share of the budget that max(4, a third of its cores) cores hold, which it is without a
27
- // measure). A part larger than the budget is the budget (one pass at a time). That memory stands
28
- // for a sort of pass the register measured less than 20 times (`partDeLaPasse` of
29
- // ./places-de-la-machine.mjs).
22
+ // - The default reservation of a pass (`partDe`) is 3 cores, within the budget and one core at
23
+ // least, and its memory the budget divided by the places (the ceiling of the places, 3 by default),
24
+ // raised to the largest peak given plus a quarter, within the budget. A project's table of the
25
+ // consumptions gives a phase its own (`reservationDeLaPasse` of ./places-de-la-machine.mjs).
30
26
  import { readFileSync } from 'node:fs';
31
- import { cpus, totalmem } from 'node:os';
27
+ import { totalmem } from 'node:os';
32
28
  import path from 'node:path';
29
+ import { coeursDeLaMachine } from './mesure-de-la-machine.mjs';
33
30
  import {
34
31
  avecLeFichierDuPoste,
35
32
  configurationDuPoste,
@@ -50,7 +47,7 @@ export const RESERVE_COEURS_PAR_DEFAUT = 4;
50
47
  export const RESERVE_MEMOIRE_GO_PAR_DEFAUT = 4;
51
48
  /** The cores the reservation of an ordinary pass holds when its project declares none. */
52
49
  export const COEURS_PAR_DEFAUT = 3;
53
- // The cores the reserve of the user leaves the passes at least; the floor of the memory.
50
+ // The cores the reserve of the user leaves the passes at least.
54
51
  const COEURS_LAISSES_AUX_PASSES = 4;
55
52
 
56
53
  /**
@@ -96,7 +93,9 @@ function fichierDuPoste(env) {
96
93
  function entierDuPoste(env, nom, defaut, lire) {
97
94
  const dedans = env[nom] !== undefined && env[nom] !== '';
98
95
  const fichier = variablesDuTexte(
99
- (lire ? lire(path.join(configurationDuPoste(env) ?? '', FICHIER_DE_LA_MACHINE)) : fichierDuPoste(env)) ?? ''
96
+ (lire
97
+ ? lire(path.join(configurationDuPoste(env) ?? '', FICHIER_DE_LA_MACHINE))
98
+ : fichierDuPoste(env)) ?? ''
100
99
  );
101
100
  const v = dedans ? env[nom] : fichier[nom];
102
101
  if (v === undefined || v === '') {
@@ -122,10 +121,10 @@ function entierDuPoste(env, nom, defaut, lire) {
122
121
  * @throws {Error} naming the variable whose value is not a whole number ≥ 0
123
122
  */
124
123
  export function reserveDe(env = process.env, o = {}) {
125
- const coeursDeLaMachine = o.coeurs ?? cpus().length;
124
+ const coeursDuPoste = o.coeurs ?? coeursDeLaMachine();
126
125
  const parDefaut = Math.min(
127
126
  RESERVE_COEURS_PAR_DEFAUT,
128
- Math.max(0, coeursDeLaMachine - COEURS_LAISSES_AUX_PASSES)
127
+ Math.max(0, coeursDuPoste - COEURS_LAISSES_AUX_PASSES)
129
128
  );
130
129
  return {
131
130
  coeurs: entierDuPoste(env, VARIABLE_RESERVE_COEURS, parDefaut, o.lire),
@@ -159,81 +158,50 @@ export function budgetDe({ coeurs, memoireTotale }, reserve) {
159
158
  /** The margin over the largest measured peak of memory: a quarter. */
160
159
  const MARGE_DE_LA_MEMOIRE = 1.25;
161
160
 
162
- // The default memory: its floor, the proportion of the budget a part of 4 cores held (or a third
163
- // of the budget rounded up when that is more), raised to the largest measured peak <pic> plus a
161
+ // The default memory: its floor, the budget divided by the places (the part before the
162
+ // specialisation, grillhouse-3uv.126), rounded up, raised to the largest measured peak <pic> plus a
164
163
  // quarter (the hard ceiling of the group kills a pass above it) when the register measured more. A
165
164
  // register that holds light passes alone (the guards, a pass of 50 ms: a peak of 16 Mo) would
166
165
  // else give the next pass a ceiling its kernel kills it under, as the Vertical Pod Autoscaler
167
166
  // bounds its recommendation by a minimum (`minAllowed`).
168
- function memoireParDefautDe(budget, pic) {
169
- const coeursDAvant = Math.max(
170
- 1,
171
- Math.min(budget.coeurs, Math.max(COEURS_LAISSES_AUX_PASSES, Math.ceil(budget.coeurs / 3)))
172
- );
173
- const plancher = Math.floor((budget.memoire * coeursDAvant) / budget.coeurs);
167
+ function memoireParDefautDe(budget, pic, places) {
168
+ const plancher = Math.ceil(budget.memoire / Math.max(1, places));
174
169
  return Math.min(budget.memoire, Math.max(plancher, Math.floor((pic ?? 0) * MARGE_DE_LA_MEMOIRE)));
175
170
  }
176
171
 
177
172
  /**
178
- * The reservation of a pass: the cores its project declares (`partDeclareeDe`), else 3, within the
179
- * budget and one core at least. Its memory is the declared one, else the default memory, within
180
- * the budget.
181
- * @param {{ declaree: { coeurs?: number, memoire?: number } | null,
182
- * budget: { coeurs: number, memoire: number }, pic: number | undefined }} o
173
+ * The default reservation of a pass: 3 cores within the budget and one core at least, its memory
174
+ * the default memory within the budget. A project's table of the consumptions gives a phase its own
175
+ * measure (`reservationDeLaPasse` of ./places-de-la-machine.mjs); no key of its `package.json`
176
+ * enters it.
177
+ * @param {{ budget: { coeurs: number, memoire: number }, pic?: number, places?: number }} o
178
+ * `places`, the ceiling of the places (3 by default)
183
179
  * @returns {{ coeurs: number, memoire: number }}
184
180
  */
185
- export function partDe({ declaree, budget, pic }) {
186
- const voulus = declaree?.coeurs ?? COEURS_PAR_DEFAUT;
181
+ export function partDe({ budget, pic, places = PLAFOND_PAR_DEFAUT }) {
187
182
  return {
188
- coeurs: Math.max(1, Math.min(budget.coeurs, voulus)),
189
- memoire: Math.min(budget.memoire, declaree?.memoire ?? memoireParDefautDe(budget, pic)),
183
+ coeurs: Math.max(1, Math.min(budget.coeurs, COEURS_PAR_DEFAUT)),
184
+ memoire: Math.min(budget.memoire, memoireParDefautDe(budget, pic, places)),
190
185
  };
191
186
  }
192
187
 
193
188
  /**
194
- * The part a project declares in the key `grillhouse.part` of its `package.json` <pkg>
195
- * (`{ coeurs, memoireGo }`, each optional): `{ declaree, faute }`, `declaree` null without the
196
- * key, `faute` the line that names the key and what is wrong when it is.
197
- * @param {{ grillhouse?: { part?: unknown } }} pkg
198
- * @returns {{ declaree: { coeurs?: number, memoire?: number } | null, faute: string | null }}
189
+ * The ceiling of a part without a measure of its phase: its reservation plus a quarter, cores
190
+ * rounded up to the whole core, memory in bytes, both within the <budget>.
191
+ * @param {{ coeurs: number, memoire: number }} part
192
+ * @param {{ coeurs: number, memoire: number }} budget
193
+ * @returns {{ limite: number, limiteCoeurs: number }}
199
194
  */
200
- export function partDeclareeDe(pkg) {
201
- const part = pkg?.grillhouse?.part;
202
- if (part === undefined) {
203
- return { declaree: null, faute: null };
204
- }
205
- const faute = dit => ({
206
- declaree: null,
207
- faute: `grillhouse.part : ${dit} ({ "coeurs": <entier ≥ 1>, "memoireGo": <nombre > 0> } est attendu).`,
208
- });
209
- if (part === null || typeof part !== 'object' || Array.isArray(part)) {
210
- return faute(`« ${JSON.stringify(part)} » n’est pas un objet`);
211
- }
212
- const inconnue = Object.keys(part).find(k => k !== 'coeurs' && k !== 'memoireGo');
213
- if (inconnue !== undefined) {
214
- return faute(`la clé « ${inconnue} » est inconnue`);
215
- }
216
- const { coeurs, memoireGo } = part;
217
- if (coeurs !== undefined && !(Number.isInteger(coeurs) && coeurs >= 1)) {
218
- return faute(`coeurs vaut ${JSON.stringify(coeurs)}`);
219
- }
220
- if (memoireGo !== undefined && !(typeof memoireGo === 'number' && memoireGo > 0)) {
221
- return faute(`memoireGo vaut ${JSON.stringify(memoireGo)}`);
222
- }
223
- return {
224
- declaree: {
225
- ...(coeurs === undefined ? {} : { coeurs }),
226
- ...(memoireGo === undefined ? {} : { memoire: memoireGo * GO }),
227
- },
228
- faute: null,
229
- };
230
- }
195
+ export const plafondDeDepart = (part, budget) => ({
196
+ limite: Math.min(budget.memoire, Math.floor(part.memoire * 1.25)),
197
+ limiteCoeurs: Math.max(1, Math.min(budget.coeurs, Math.ceil(part.coeurs * 1.25 - 1e-9))),
198
+ });
231
199
 
232
200
  /**
233
201
  * The hardware of this machine: its cores and its total memory (bytes).
234
202
  * @returns {{ coeurs: number, memoireTotale: number }}
235
203
  */
236
- export const materielDeLaMachine = () => ({ coeurs: cpus().length, memoireTotale: totalmem() });
204
+ export const materielDeLaMachine = () => ({ coeurs: coeursDeLaMachine(), memoireTotale: totalmem() });
237
205
 
238
206
  /**
239
207
  * The budget of this machine under <env>: its hardware less the reserve of the user.
@@ -0,0 +1,57 @@
1
+ // The registry of the entries of the queue (`.claude/file-des-entrees.jsonl`, entree.md §4): one
2
+ // line per ticket entered, `{ ticket, quand, mainABouge }`, `mainABouge` true when the lot was laid
3
+ // again on main's tip and judged again, false when the tree already judged entered. The queue
4
+ // writes it (`releverLEntree`); `npx grillhouse bilan --file` reads the rate of replay there
5
+ // (`tauxDeRejeu`), the measure that decides later whether the lots waiting are grouped.
6
+ import { appendFileSync, existsSync, mkdirSync, readFileSync } from 'node:fs';
7
+ import path from 'node:path';
8
+
9
+ export const REGISTRE_DES_ENTREES = path.join('.claude', 'file-des-entrees.jsonl');
10
+
11
+ // The lines of the registry of the project <racine>, each a parsed object; a line that is no JSON
12
+ // is left out.
13
+ function lignesDe(racine) {
14
+ const fichier = path.join(racine, REGISTRE_DES_ENTREES);
15
+ if (!existsSync(fichier)) {
16
+ return [];
17
+ }
18
+ return readFileSync(fichier, 'utf8')
19
+ .split('\n')
20
+ .filter(Boolean)
21
+ .flatMap(l => {
22
+ try {
23
+ return [JSON.parse(l)];
24
+ } catch {
25
+ return [];
26
+ }
27
+ });
28
+ }
29
+
30
+ /**
31
+ * The entry <entree> (`{ ticket, mainABouge }`) added to the registry of <racine>; an entry played
32
+ * again after an incident adds no second line.
33
+ */
34
+ export function releverLEntree(racine, entree) {
35
+ if (lignesDe(racine).some(l => l.ticket === entree.ticket)) {
36
+ return;
37
+ }
38
+ const fichier = path.join(racine, REGISTRE_DES_ENTREES);
39
+ mkdirSync(path.dirname(fichier), { recursive: true });
40
+ const ligne = {
41
+ ticket: entree.ticket,
42
+ quand: new Date().toISOString(),
43
+ mainABouge: entree.mainABouge === true,
44
+ };
45
+ appendFileSync(fichier, `${JSON.stringify(ligne)}\n`);
46
+ }
47
+
48
+ /** The rate of replay of the project <racine>: `{ rejeux, entrees, pourcent }`, pourcent null without entry. */
49
+ export function tauxDeRejeu(racine) {
50
+ const lignes = lignesDe(racine);
51
+ const rejeux = lignes.filter(l => l.mainABouge === true).length;
52
+ return {
53
+ rejeux,
54
+ entrees: lignes.length,
55
+ pourcent: lignes.length ? Math.round((100 * rejeux) / lignes.length) : null,
56
+ };
57
+ }
@@ -4,16 +4,57 @@
4
4
  /** The memory a start wants free, in bytes: 4 GB. */
5
5
  export const MEMOIRE_MIN: number;
6
6
 
7
- export const VARIABLE_ESPACEMENT: string;
8
- /** The gap between two starts when GRILLHOUSE_ESPACEMENT_MS names none, in ms. */
9
- export const ESPACEMENT_MS: number;
10
- /** The gap between two starts under <env>, in ms. */
11
- export function espacementDe(env?: Record<string, string | undefined>): number;
7
+ /** The sort of the verification of the update, which the closure of the machine does not refuse. */
8
+ export const SORTE_DE_LA_MONTEE: string;
9
+
10
+ /** The steps of the overbooking of the memory: 1, 1,2 and 1,5. */
11
+ export const CRANS: number[];
12
+
13
+ /** The level of the memory: calm, alert (pressure above 10 % or swap on disk serving) or threat. */
14
+ export function niveauDeLaMemoire(m: {
15
+ pression: number | null;
16
+ disponible: number | null;
17
+ echangeEnMemoire: number;
18
+ echangeSurDisque: boolean;
19
+ }): 'calme' | 'alerte' | 'menace';
20
+
21
+ /** Whether an alert is lifted: under the threshold for a minute, the swap on disk not growing. */
22
+ export function alerteLevee(o: {
23
+ sousLeSeuilDepuis: number | null;
24
+ maintenant: number;
25
+ echangeSurDisqueGrandit: boolean;
26
+ }): boolean;
27
+
28
+ /** The ids of the steps in the order a threat stops them. */
29
+ export function ordreDArret(
30
+ etapes: readonly {
31
+ id: string;
32
+ memoire: number;
33
+ reservation: number;
34
+ passe: boolean;
35
+ depuis: number;
36
+ }[]
37
+ ): string[];
38
+
39
+ /** The step of the overbooking after a moment: down on a signal, up after three days without one. */
40
+ export function ajusterLeCran(o: {
41
+ cran: number;
42
+ depuis: number;
43
+ maintenant: number;
44
+ signal: string | null;
45
+ }): {
46
+ cran: number;
47
+ depuis: number;
48
+ changement: { de: number; a: number; raison: string; instant: number } | null;
49
+ };
50
+
51
+ /** How long after its grant a step is not yet read by the measure of the machine, in ms. */
52
+ export const FENETRE_DE_DEPART_MS: number;
12
53
 
13
54
  /** A duration as a line says it: seconds under 2 min, else minutes. */
14
55
  export function duree(ms: number): string;
15
56
 
16
- /** What the machine gives at a moment: its cores, its load over one minute, its free memory. */
57
+ /** What the machine gives at a moment: its cores, the cores occupied over ten seconds, its free memory. */
17
58
  export interface MesureDeLaMachine {
18
59
  coeurs: number;
19
60
  charge: number;
@@ -21,29 +62,48 @@ export interface MesureDeLaMachine {
21
62
  memoireLibre: number;
22
63
  }
23
64
 
24
- /** Whether a start is admitted at this load and this free memory; a refusal says why. */
25
- export function admission(m: MesureDeLaMachine): { ok: true } | { ok: false; raison: string };
65
+ /** How many times a wait may be passed before nothing passes it more. */
66
+ export const PASSAGES_MAX: number;
26
67
 
27
- /** Why a taking does not pass now on a state of the places, null when it passes. */
28
- export function refusDeLaPlace(
68
+ /** Each wait of a rank lower than the granted request <id> gains a passage (state changed in place). */
69
+ export function compterLesPassages(
70
+ etat: { attentes: { id: string; rang: number; passages?: number }[] },
71
+ o: { id: string; rang: number }
72
+ ): void;
73
+
74
+ /** Why the reservation of a step is not granted now on a state of the places, null when it is. */
75
+ export function refusDeLaReservation(
29
76
  etat: {
30
- prises: readonly unknown[];
77
+ prises: readonly {
78
+ id?: string;
79
+ coeurs: number;
80
+ memoire: number;
81
+ depuis?: number;
82
+ ticket?: string | null;
83
+ }[];
31
84
  attentes: readonly {
32
85
  id: string;
33
86
  rang: number;
34
87
  ticket?: string | null;
35
88
  raison?: string;
89
+ coeurs?: number;
90
+ memoire?: number;
91
+ /** The requests that fit and were granted before it. */
92
+ passages?: number;
36
93
  }[];
37
- dernier: number;
38
94
  reservation?: ReservationDeLaMachine | null;
39
95
  },
40
96
  o: {
41
97
  id: string;
42
98
  rang: number;
43
- plafond: number;
44
- espacementMs: number;
99
+ reservation: { coeurs: number; memoire: number };
100
+ budget: { coeurs: number; memoire: number };
45
101
  maintenant: number;
46
102
  mesurer: () => MesureDeLaMachine;
103
+ /** The step of the overbooking, which multiplies the memory of the budget (1 by default). */
104
+ cran?: number;
105
+ /** A reservation the closure of the machine does not refuse (the update of the frame). */
106
+ exemptee?: boolean;
47
107
  }
48
108
  ): string | null;
49
109
 
@@ -53,49 +113,18 @@ export interface PartDeLaPasse {
53
113
  memoire: number;
54
114
  }
55
115
 
56
- /** What a pass waits for: the cores or the memory of the budget, or the load of the machine. */
57
- export type CeQueAttendUnePart = 'cœurs' | 'mémoire' | 'charge';
116
+ /** What a reservation waits for in the budget: its cores or its memory. */
117
+ export type CeQueAttendUnePart = 'cœurs' | 'mémoire';
58
118
 
59
119
  /** Whether a part fits in what the parts held leave of the budget; a refusal says what it waits for. */
60
120
  export function partDansLeBudget(o: {
61
121
  part: PartDeLaPasse;
62
122
  budget: PartDeLaPasse;
63
123
  prises: readonly PartDeLaPasse[];
124
+ /** The step of the overbooking, which multiplies the memory of the budget, not its cores. */
125
+ cran?: number;
64
126
  }): { ok: boolean; attend?: CeQueAttendUnePart; raison?: string };
65
127
 
66
- /** Whether a pass of the part <part> is admitted: its part fits in the budget left, then the load and
67
- * the memory of the machine admit it; a refusal says what it waits for, with its figures. */
68
- export function admissionDePart(o: {
69
- part: PartDeLaPasse;
70
- budget: PartDeLaPasse;
71
- prises: readonly PartDeLaPasse[];
72
- mesure: MesureDeLaMachine;
73
- }): { ok: boolean; attend?: CeQueAttendUnePart; raison?: string };
74
-
75
- /** Why a pass does not take its part now on a state of the parts, null when it does. */
76
- export function refusDePart(
77
- etat: {
78
- prises: readonly { id?: string; coeurs: number; memoire: number }[];
79
- attentes: readonly { id: string; rang: number; ticket?: string | null; raison?: string }[];
80
- },
81
- o: {
82
- id: string;
83
- rang: number;
84
- part: PartDeLaPasse;
85
- budget: PartDeLaPasse;
86
- mesurer: () => MesureDeLaMachine;
87
- dediee?: boolean;
88
- /** The reservation of the machine read this turn, null without. */
89
- reservation?: ReservationDeLaMachine | null;
90
- }
91
- ): string | null;
92
-
93
- /** Why a pass waits under the supervisor's closure of the machine. */
94
- export const RAISON_DE_LA_FERMETURE: string;
95
-
96
- /** A place of a circuit not given by its project's queue for this long is gone, in ms: 10 min. */
97
- export const PERIME_MS: number;
98
-
99
128
  /** The reservation of the machine: the supervisor's closure, the only one. */
100
129
  export interface ReservationDeLaMachine {
101
130
  auteur?: 'superviseur';
@@ -118,7 +147,6 @@ export interface PlaceDeCircuit {
118
147
  rang: number;
119
148
  accordee: boolean;
120
149
  depuis: number;
121
- vu: number;
122
150
  /** A circuit resumed after its question, which asks again by itself. */
123
151
  reprise?: boolean;
124
152
  /** Why it waits apart from the order of arrival (its disk of copies), null without. */
@@ -153,3 +181,9 @@ export function reserverDesCircuits(
153
181
  },
154
182
  o: { rang: number; plafond: number; maintenant: number; reservee?: boolean }
155
183
  ): { circuits: PlaceDeCircuit[]; rang: number; accordes: string[] };
184
+
185
+ /** The places once a circuit gives its place back: its place is taken off the limit and the ceiling. */
186
+ export function rendreSaPlace<P extends { racine: string; ticket: string }>(
187
+ places: readonly P[],
188
+ q: { racine: string; ticket: string }
189
+ ): P[];