@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
@@ -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,6 +29,7 @@
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';
@@ -111,12 +112,9 @@ export function ecoute(adresse, delaiMs = 2_000) {
111
112
  // How often a wait reads its request again.
112
113
  const VEILLE_MS = 1_000;
113
114
 
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
- };
115
+ // The entry of the workflow of the machine: its veille, a second. The ceiling and the budget, the
116
+ // workflow reads from the poste at each judgement.
117
+ const entreeDe = () => ({ veilleMs: 1_000 });
120
118
 
121
119
  const MODES = { rang: 0, prendre: 1, rendre: 1, rattacher: 3, lire: 0, fermer: 0, rouvrir: 0 };
122
120
  const ecrire = o => process.stdout.write(`${JSON.stringify(o)}\n`);
@@ -167,6 +165,21 @@ export async function attendreLaPlace(
167
165
  }
168
166
  }
169
167
 
168
+ // Builds the package (`npm run build`) when the
169
+ // client is not yet built, so a fresh copy (the final pass of the queue) asks the arbiter without
170
+ // a build of its own before; false when the build fails, its output on the error stream.
171
+ function construireLeClient() {
172
+ const racine = path.join(import.meta.dirname, '..');
173
+ const r = spawnSync('npm', ['run', 'build'], {
174
+ cwd: racine,
175
+ encoding: 'utf8',
176
+ });
177
+ if (r.status !== 0) {
178
+ process.stderr.write(`${r.stdout ?? ''}${r.stderr ?? ''}${r.error?.message ?? ''}\n`);
179
+ }
180
+ return r.status === 0 && existsSync(path.join(DIST, 'places', 'client.js'));
181
+ }
182
+
170
183
  // The call <mode> with <args>: its exit code.
171
184
  async function principal(mode, args) {
172
185
  if (!Object.hasOwn(MODES, mode ?? '') || args.length !== MODES[mode]) {
@@ -175,9 +188,9 @@ async function principal(mode, args) {
175
188
  );
176
189
  return 2;
177
190
  }
178
- if (!existsSync(path.join(DIST, 'places', 'client.js'))) {
191
+ if (!existsSync(path.join(DIST, 'places', 'client.js')) && !construireLeClient()) {
179
192
  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`
193
+ `le client Temporal n'est pas construit (${DIST}) et sa construction échoue, \`npm run build --workspace @roomi-fields/grillhouse\`.\n`
181
194
  );
182
195
  return 1;
183
196
  }
@@ -192,7 +205,7 @@ async function principal(mode, args) {
192
205
  try {
193
206
  try {
194
207
  await sous(async () =>
195
- places.demarrerLesPlaces(c.client, await entreeDe(process.env), {
208
+ places.demarrerLesPlaces(c.client, entreeDe(), {
196
209
  file: FILE_DE_LA_MACHINE,
197
210
  })
198
211
  );
@@ -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 }): 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,22 +11,18 @@
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 share of the budget that max(4, a third of its cores) cores hold,
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
27
  import { cpus, totalmem } from 'node:os';
32
28
  import path from 'node:path';
@@ -96,7 +92,9 @@ function fichierDuPoste(env) {
96
92
  function entierDuPoste(env, nom, defaut, lire) {
97
93
  const dedans = env[nom] !== undefined && env[nom] !== '';
98
94
  const fichier = variablesDuTexte(
99
- (lire ? lire(path.join(configurationDuPoste(env) ?? '', FICHIER_DE_LA_MACHINE)) : fichierDuPoste(env)) ?? ''
95
+ (lire
96
+ ? lire(path.join(configurationDuPoste(env) ?? '', FICHIER_DE_LA_MACHINE))
97
+ : fichierDuPoste(env)) ?? ''
100
98
  );
101
99
  const v = dedans ? env[nom] : fichier[nom];
102
100
  if (v === undefined || v === '') {
@@ -175,59 +173,31 @@ function memoireParDefautDe(budget, pic) {
175
173
  }
176
174
 
177
175
  /**
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
176
+ * The default reservation of a pass: 3 cores within the budget and one core at least, its memory
177
+ * the default memory within the budget. A project's table of the consumptions gives a phase its own
178
+ * measure (`reservationDeLaPasse` of ./places-de-la-machine.mjs); no key of its `package.json`
179
+ * enters it.
180
+ * @param {{ budget: { coeurs: number, memoire: number }, pic?: number }} o
183
181
  * @returns {{ coeurs: number, memoire: number }}
184
182
  */
185
- export function partDe({ declaree, budget, pic }) {
186
- const voulus = declaree?.coeurs ?? COEURS_PAR_DEFAUT;
183
+ export function partDe({ budget, pic }) {
187
184
  return {
188
- coeurs: Math.max(1, Math.min(budget.coeurs, voulus)),
189
- memoire: Math.min(budget.memoire, declaree?.memoire ?? memoireParDefautDe(budget, pic)),
185
+ coeurs: Math.max(1, Math.min(budget.coeurs, COEURS_PAR_DEFAUT)),
186
+ memoire: Math.min(budget.memoire, memoireParDefautDe(budget, pic)),
190
187
  };
191
188
  }
192
189
 
193
190
  /**
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 }}
191
+ * The ceiling of a part without a measure of its phase: its reservation plus a quarter, cores
192
+ * rounded up to the whole core, memory in bytes, both within the <budget>.
193
+ * @param {{ coeurs: number, memoire: number }} part
194
+ * @param {{ coeurs: number, memoire: number }} budget
195
+ * @returns {{ limite: number, limiteCoeurs: number }}
199
196
  */
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
- }
197
+ export const plafondDeDepart = (part, budget) => ({
198
+ limite: Math.min(budget.memoire, Math.floor(part.memoire * 1.25)),
199
+ limiteCoeurs: Math.max(1, Math.min(budget.coeurs, Math.ceil(part.coeurs * 1.25 - 1e-9))),
200
+ });
231
201
 
232
202
  /**
233
203
  * The hardware of this machine: its cores and its total memory (bytes).
@@ -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,46 @@ 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
+ /** The requests that fit and were granted before it. */
90
+ passages?: number;
36
91
  }[];
37
- dernier: number;
38
92
  reservation?: ReservationDeLaMachine | null;
39
93
  },
40
94
  o: {
41
95
  id: string;
42
96
  rang: number;
43
- plafond: number;
44
- espacementMs: number;
97
+ reservation: { coeurs: number; memoire: number };
98
+ budget: { coeurs: number; memoire: number };
45
99
  maintenant: number;
46
100
  mesurer: () => MesureDeLaMachine;
101
+ /** The step of the overbooking, which multiplies the memory of the budget (1 by default). */
102
+ cran?: number;
103
+ /** A reservation the closure of the machine does not refuse (the update of the frame). */
104
+ exemptee?: boolean;
47
105
  }
48
106
  ): string | null;
49
107
 
@@ -53,49 +111,18 @@ export interface PartDeLaPasse {
53
111
  memoire: number;
54
112
  }
55
113
 
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';
114
+ /** What a reservation waits for in the budget: its cores or its memory. */
115
+ export type CeQueAttendUnePart = 'cœurs' | 'mémoire';
58
116
 
59
117
  /** Whether a part fits in what the parts held leave of the budget; a refusal says what it waits for. */
60
118
  export function partDansLeBudget(o: {
61
119
  part: PartDeLaPasse;
62
120
  budget: PartDeLaPasse;
63
121
  prises: readonly PartDeLaPasse[];
122
+ /** The step of the overbooking, which multiplies the memory of the budget, not its cores. */
123
+ cran?: number;
64
124
  }): { ok: boolean; attend?: CeQueAttendUnePart; raison?: string };
65
125
 
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
126
  /** The reservation of the machine: the supervisor's closure, the only one. */
100
127
  export interface ReservationDeLaMachine {
101
128
  auteur?: 'superviseur';
@@ -118,7 +145,6 @@ export interface PlaceDeCircuit {
118
145
  rang: number;
119
146
  accordee: boolean;
120
147
  depuis: number;
121
- vu: number;
122
148
  /** A circuit resumed after its question, which asks again by itself. */
123
149
  reprise?: boolean;
124
150
  /** Why it waits apart from the order of arrival (its disk of copies), null without. */
@@ -153,3 +179,9 @@ export function reserverDesCircuits(
153
179
  },
154
180
  o: { rang: number; plafond: number; maintenant: number; reservee?: boolean }
155
181
  ): { circuits: PlaceDeCircuit[]; rang: number; accordes: string[] };
182
+
183
+ /** The places once a circuit gives its place back: its place is taken off the limit and the ceiling. */
184
+ export function rendreSaPlace<P extends { racine: string; ticket: string }>(
185
+ places: readonly P[],
186
+ q: { racine: string; ticket: string }
187
+ ): P[];