@roomi-fields/grillhouse 0.55.1 → 0.55.3

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 (76) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +28 -2
  3. package/charte/plan.md +8 -0
  4. package/charte/preuve.md +6 -2
  5. package/charte/superviseur.md +19 -0
  6. package/charte/tests.md +15 -0
  7. package/charte.md +1 -1
  8. package/dist/temporal/circuit/activites.js +2 -2
  9. package/dist/temporal/circuit/activites.js.map +1 -1
  10. package/dist/temporal/circuit/client.d.ts +2 -1
  11. package/dist/temporal/circuit/client.js +19 -7
  12. package/dist/temporal/circuit/client.js.map +1 -1
  13. package/dist/temporal/nuits/activites.d.ts +0 -4
  14. package/dist/temporal/nuits/activites.js +1 -7
  15. package/dist/temporal/nuits/activites.js.map +1 -1
  16. package/dist/temporal/nuits/choix.d.ts +0 -15
  17. package/dist/temporal/nuits/choix.js +0 -20
  18. package/dist/temporal/nuits/choix.js.map +1 -1
  19. package/dist/temporal/nuits/contrat.d.ts +0 -8
  20. package/dist/temporal/places/client.d.ts +2 -2
  21. package/dist/temporal/places/client.js +3 -2
  22. package/dist/temporal/places/client.js.map +1 -1
  23. package/dist/temporal/places/deroule.js +7 -1
  24. package/dist/temporal/places/deroule.js.map +1 -1
  25. package/docs/INTERFACE.md +2 -1
  26. package/docs/architecture/circuit.md +3 -3
  27. package/docs/architecture/entree.md +1 -1
  28. package/docs/architecture/greffon.md +2 -3
  29. package/docs/architecture/installation.md +2 -2
  30. package/docs/architecture/machine.md +6 -4
  31. package/docs/architecture/tests.md +51 -7
  32. package/hooks/hooks.json +0 -4
  33. package/package.json +1 -1
  34. package/scripts/aiguillage.mjs +1 -2
  35. package/scripts/bilan.mjs +116 -25
  36. package/scripts/branche-de-nuit.mjs +1 -15
  37. package/scripts/coeurs-dedies.mjs +19 -2
  38. package/scripts/composition-des-langages.mjs +2 -2
  39. package/scripts/consommation-des-passes.mjs +0 -4
  40. package/scripts/consommation.mjs +2 -2
  41. package/scripts/crochets.mjs +1 -1
  42. package/scripts/etapes.mjs +1 -10
  43. package/scripts/integration/file.mjs +2 -12
  44. package/scripts/jointure.d.ts +3 -0
  45. package/scripts/langages/c/index.mjs +2 -0
  46. package/scripts/langages/cargo/index.mjs +2 -0
  47. package/scripts/langages/python/index.mjs +2 -0
  48. package/scripts/langages/typescript/index.mjs +2 -0
  49. package/scripts/machine.mjs +0 -1
  50. package/scripts/mesure-de-la-machine.d.mts +3 -0
  51. package/scripts/mesure-de-la-machine.mjs +10 -2
  52. package/scripts/migrations/nuit-yml-retire.mjs +34 -4
  53. package/scripts/migrations/table-des-consommations.mjs +36 -0
  54. package/scripts/migrations.mjs +2 -0
  55. package/scripts/nuit.sh +3 -14
  56. package/scripts/passe-de-la-machine.mjs +25 -2
  57. package/scripts/places-de-la-machine.mjs +4 -39
  58. package/scripts/places-du-serveur.mjs +18 -4
  59. package/scripts/plafond-de-la-machine.d.mts +1 -1
  60. package/scripts/plafond-de-la-machine.mjs +15 -17
  61. package/scripts/regles-des-places.d.mts +2 -0
  62. package/scripts/regles-des-places.mjs +12 -4
  63. package/scripts/resultats.mjs +18 -14
  64. package/scripts/seances.mjs +7 -1
  65. package/scripts/sous-commandes.mjs +0 -1
  66. package/scripts/suiveur.mjs +96 -19
  67. package/scripts/tableau.mjs +16 -14
  68. package/scripts/transitions.mjs +3 -0
  69. package/scripts/un-commit-par-ticket.mjs +8 -0
  70. package/skills/developpeur/SKILL.md +1 -1
  71. package/skills/explorateur/SKILL.md +2 -2
  72. package/skills/questionneur/SKILL.md +3 -2
  73. package/skills/relecteur/SKILL.md +1 -1
  74. package/skills/testwriter/SKILL.md +1 -1
  75. package/scripts/attente-au-tour.mjs +0 -93
  76. package/scripts/poussee-retiree.mjs +0 -19
@@ -0,0 +1,36 @@
1
+ // A project holds the table of the consumptions of its phases: the reservation of a step comes
2
+ // from it (machine.md §5.2, §5.6), and a project mounted before the first daily recalculation had
3
+ // none, so every phase took the default part. The migration writes it once
4
+ // (`grillhouse consommation --ecrire`); the daily recalculation then rewrites it. Mechanism:
5
+ // installation.md §5.4 (packages/grillhouse/docs/architecture/).
6
+ import { existsSync } from 'node:fs';
7
+ import { consommation } from '../consommation.mjs';
8
+ import { fichierDeLaTable } from '../table-des-consommations.mjs';
9
+
10
+ // No version before its release: `grillhouse sortie` numbers it.
11
+ export const version = '0.55.2';
12
+ export const nom = 'table des consommations';
13
+
14
+ /**
15
+ * The table of the consumptions written for <projet> when it holds none; returns what it could not do (the writing itself is silent: the table is data).
16
+ * A table already there is left to the daily recalculation.
17
+ * @param {string} projet
18
+ * @param {{ ecrire?: (racine: string) => number | Promise<number> }} [o] the writing, for a trial
19
+ * @returns {string[]}
20
+ */
21
+ export function migrer(projet, { ecrire } = {}) {
22
+ const fichier = fichierDeLaTable(projet);
23
+ if (fichier === null || existsSync(fichier)) {
24
+ return [];
25
+ }
26
+ const jouer =
27
+ ecrire ?? (racine => consommation({ args: ['--ecrire'], racine, ecrire: () => undefined }));
28
+ try {
29
+ const code = jouer(projet);
30
+ return existsSync(fichier)
31
+ ? []
32
+ : [`la table des consommations n'est pas écrite (code ${String(code)}) : \`grillhouse consommation --ecrire\` la pose`];
33
+ } catch (e) {
34
+ return [`la table des consommations n'est pas écrite : ${(e instanceof Error ? e.message : String(e))}`];
35
+ }
36
+ }
@@ -55,6 +55,7 @@ import * as reservationDeTroisCoeurs from './migrations/0.49.0-reservation-de-tr
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
57
  import * as partRetiree from './migrations/part-retiree.mjs';
58
+ import * as tableDesConsommations from './migrations/table-des-consommations.mjs';
58
59
  import * as nuitYmlRetire from './migrations/nuit-yml-retire.mjs';
59
60
  import * as serveursDeLIndex from './migrations/serveurs-de-l-index.mjs';
60
61
  import * as coutDesJetons from './migrations/cout-des-jetons-au-registre.mjs';
@@ -89,6 +90,7 @@ export const MIGRATIONS = [
89
90
  suiviDuSuperviseurRetire,
90
91
  lireUnTicket,
91
92
  partRetiree,
93
+ tableDesConsommations,
92
94
  nuitYmlRetire,
93
95
  ];
94
96
 
package/scripts/nuit.sh CHANGED
@@ -80,10 +80,7 @@
80
80
  # no script of the project; a value that is not a non-blank string, or a name absent from the scripts of
81
81
  # that package.json, turns the night red, with a log line that cites it, and nothing runs.
82
82
  # - The night pushes nothing: main receives every lot by the queue, on a tree judged; the night keeps
83
- # its last green (`<git common dir>/nuit/dernier-vert`), a mark and not a branch. A project whose
84
- # package.json carries the retired key `grillhouse.poussee`, whatever its value, turns the night
85
- # red before any work, with a log line that names the key and the gesture (remove it,
86
- # scripts/poussee-retiree.mjs).
83
+ # its last green (`<git common dir>/nuit/dernier-vert`), a mark and not a branch.
87
84
  # - The copies whose content is on main: once its steps are played, whatever their verdict, the
88
85
  # night passes each copy `git worktree list` names, the main tree and its own left out, through
89
86
  # scripts/retirer-copie.sh without `--jetable` (scripts/retirer-les-copies-finies.mjs), as a CI cleans its
@@ -200,14 +197,11 @@ jouer() {
200
197
  return 1
201
198
  fi
202
199
  # The reading gives one line per finding: « script<TAB>name », or a fault « nuit-invalide<TAB>value
203
- # as JSON », « nuit-absent<TAB>name », « poussee-retiree<TAB>line ». Every faulty key is reported
204
- # before any work.
200
+ # as JSON », or « nuit-absent<TAB>name ».
205
201
  local lecture ligne nuit=
206
202
  lecture="$(node --input-type=module -e '
207
203
  import { readFileSync } from "node:fs";
208
- import { pathToFileURL } from "node:url";
209
204
  const pkg = JSON.parse(readFileSync(process.argv[1], "utf8"));
210
- const { pousseeRetiree } = await import(pathToFileURL(process.argv[2]).href);
211
205
  const out = (...l) => process.stdout.write(l.join("\t") + "\n");
212
206
  const vide = v => typeof v !== "string" || !v.trim();
213
207
  const v = pkg.grillhouse?.nuit;
@@ -216,9 +210,7 @@ jouer() {
216
210
  else if (!Object.hasOwn(pkg.scripts ?? {}, v)) out("nuit-absent", v);
217
211
  else out("script", v);
218
212
  }
219
- const retiree = pousseeRetiree(pkg);
220
- if (retiree) out("poussee-retiree", retiree);
221
- ' "$copie/package.json" "$ici/poussee-retiree.mjs" 2>/dev/null)"
213
+ ' "$copie/package.json" 2>/dev/null)"
222
214
  local faute=0
223
215
  while IFS= read -r ligne; do
224
216
  case "$ligne" in
@@ -229,9 +221,6 @@ jouer() {
229
221
  nuit-absent$'\t'*)
230
222
  echo "✗ la clé grillhouse.nuit nomme « ${ligne#nuit-absent$'\t'} », absent des scripts du package.json : rien n'est joué."
231
223
  faute=1 ;;
232
- poussee-retiree$'\t'*)
233
- echo "✗ ${ligne#poussee-retiree$'\t'} Rien n'est joué."
234
- faute=1 ;;
235
224
  esac
236
225
  done <<< "$lecture"
237
226
  [ "$faute" -eq 0 ] || return 1
@@ -29,8 +29,8 @@
29
29
  import { spawnSync } from 'node:child_process';
30
30
  import { randomUUID } from 'node:crypto';
31
31
  import { readFileSync } from 'node:fs';
32
+ import { coeursDeLaMachine } from './mesure-de-la-machine.mjs';
32
33
  import {
33
- coeursDeLaMachine,
34
34
  depasseLaPart,
35
35
  garderLaConsommation,
36
36
  marquesDeLaPasse,
@@ -148,7 +148,9 @@ export function commandeDuGroupe({
148
148
  'MemoryAccounting=yes',
149
149
  '-p',
150
150
  `CPUWeight=${poidsDeLaPart(part)}`,
151
- ...(memoire ? ['-p', `MemoryMax=${Math.floor(part.limite ?? part.memoire)}`] : []),
151
+ ...(memoire && Math.floor(part.limite ?? part.memoire) > 0
152
+ ? ['-p', `MemoryMax=${Math.floor(part.limite ?? part.memoire)}`]
153
+ : []),
152
154
  ...(plafond ? ['-p', `CPUQuota=${(part.limiteCoeurs ?? part.coeurs) * 100}%`] : []),
153
155
  ...(fils ? ['-p', `AllowedCPUs=${listeDeCoeurs(fils)}`] : []),
154
156
  '--',
@@ -615,6 +617,26 @@ export function avecLaPasse(
615
617
  }
616
618
  rendreLesCoeurs = () => void ecarter({ dedies: [], fils: tous });
617
619
  }
620
+ // An interrupted measure (SIGINT, SIGTERM, SIGHUP) lifts the restriction before it dies: the
621
+ // end of the `finally` below is not reached when a signal kills the process.
622
+ const signaux = ['SIGINT', 'SIGTERM', 'SIGHUP'];
623
+ const fin = signal => {
624
+ rendreLesCoeurs();
625
+ for (const s of signaux) {
626
+ process.removeListener(s, fin);
627
+ }
628
+ process.kill(process.pid, signal);
629
+ };
630
+ if (attache?.voie === 'groupe') {
631
+ for (const s of signaux) {
632
+ process.once(s, fin);
633
+ }
634
+ }
635
+ const retirerLesSignaux = () => {
636
+ for (const s of signaux) {
637
+ process.removeListener(s, fin);
638
+ }
639
+ };
618
640
  const identite = {
619
641
  racine,
620
642
  sorte: sorteLue,
@@ -721,6 +743,7 @@ export function avecLaPasse(
721
743
  rendreLAffinite();
722
744
  }
723
745
  } finally {
746
+ retirerLesSignaux();
724
747
  rendreLesCoeurs();
725
748
  }
726
749
  } finally {
@@ -29,7 +29,6 @@
29
29
  // to the tool of each language (GRILLHOUSE_TRAVAILLEURS).
30
30
  import { spawnSync } from 'node:child_process';
31
31
  import { readFileSync } from 'node:fs';
32
- import { availableParallelism } from 'node:os';
33
32
  import path from 'node:path';
34
33
  import { departDe } from './mesure/base-de-passe.mjs';
35
34
  import { coeursDeLaMesureDe, mesureDeclareeDe } from './coeurs-dedies.mjs';
@@ -37,7 +36,7 @@ import { A_REPASSER } from './codes-de-sortie.mjs';
37
36
  import { AttenteDeLaMachine, borneDe, racineDuDepot } from './attente-de-la-machine.mjs';
38
37
  import { paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
39
38
  import { ecrireLaTrace, traceDesPlaces } from './journal-des-etats.mjs';
40
- import { mesureDeLaMachine } from './mesure-de-la-machine.mjs';
39
+ import { coeursDeLaMachine, mesureDeLaMachine } from './mesure-de-la-machine.mjs';
41
40
  import {
42
41
  budgetDe,
43
42
  partDe,
@@ -122,7 +121,7 @@ const PONT = path.join(import.meta.dirname, 'places-du-serveur.mjs');
122
121
  * @returns {number}
123
122
  */
124
123
  export function travailleursDe({
125
- coeurs = availableParallelism(),
124
+ coeurs = coeursDeLaMachine(),
126
125
  places,
127
126
  env = process.env,
128
127
  } = {}) {
@@ -321,40 +320,6 @@ export function prendreUnePlace({
321
320
  };
322
321
  }
323
322
 
324
- /**
325
- * Plays <seance> holding a place, given back at its end, whether it returns, throws or (for an
326
- * asynchronous one) settles; <seance> receives the place, its `env` the environment of its
327
- * children.
328
- * @param {(place: ReturnType<typeof prendreUnePlace>) => T} seance
329
- * @param {Parameters<typeof prendreUnePlace>[0]} [options]
330
- * @returns {T}
331
- * @template T
332
- */
333
- export function avecUnePlace(seance, options) {
334
- const place = prendreUnePlace(options);
335
- let r;
336
- try {
337
- r = seance(place);
338
- } catch (e) {
339
- place.rendre();
340
- throw e;
341
- }
342
- if (r && typeof r.then === 'function') {
343
- return r.then(
344
- v => {
345
- place.rendre();
346
- return v;
347
- },
348
- e => {
349
- place.rendre();
350
- throw e;
351
- }
352
- );
353
- }
354
- place.rendre();
355
- return r;
356
- }
357
-
358
323
  /**
359
324
  * The machine a pass is judged on under <env>: the one a trial fixes (GRILLHOUSE_MESURE_D_ESSAI),
360
325
  * else the real one.
@@ -380,7 +345,7 @@ export function budgetDeLaPasse(env = process.env) {
380
345
  /**
381
346
  * The reservation of a pass of the phase <phase> of the project at <racine> under <env>: the cores
382
347
  * and the memory the table of the consumptions of the project gives that phase, else the default
383
- * reservation of the budget (`partDe`: 3 cores); and its ceiling (`limite` in bytes,
348
+ * reservation of the budget (`partDe`: 3 cores, the budget divided by the places); and its ceiling (`limite` in bytes,
384
349
  * `limiteCoeurs`: where the group of the step is cut), that of the line of its phase, else its
385
350
  * reservation plus a quarter; all within the budget of the machine. No key of the `package.json`
386
351
  * of the project enters it.
@@ -396,7 +361,7 @@ export function reservationDeLaPasse({ racine, env = process.env, phase }) {
396
361
  coeurs: Math.max(1, Math.min(budget.coeurs, voulue.coeurs)),
397
362
  memoire: Math.min(budget.memoire, voulue.memoire),
398
363
  }
399
- : partDe({ budget });
364
+ : partDe({ budget, places: plafondDe(env) });
400
365
  const depart = plafondDeDepart({ coeurs, memoire }, budget);
401
366
  return {
402
367
  coeurs,
@@ -36,6 +36,7 @@ import net from 'node:net';
36
36
  import path from 'node:path';
37
37
  import { pathToFileURL } from 'node:url';
38
38
  import { A_REPASSER } from './codes-de-sortie.mjs';
39
+ import { leverLaRestriction } from './coeurs-dedies.mjs';
39
40
  import { duree, RAISON_FERMEE } from './regles-des-places.mjs';
40
41
 
41
42
  // The start of the reason of a wait under the supervisor's closure.
@@ -180,6 +181,21 @@ function construireLeClient() {
180
181
  return r.status === 0 && existsSync(path.join(DIST, 'places', 'client.js'));
181
182
  }
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
+
183
199
  // The call <mode> with <args>: its exit code.
184
200
  async function principal(mode, args) {
185
201
  if (!Object.hasOwn(MODES, mode ?? '') || args.length !== MODES[mode]) {
@@ -204,10 +220,8 @@ async function principal(mode, args) {
204
220
  const sous = f => avecReprises(() => c.client.connection.withDeadline(Date.now() + DELAI_MS, f));
205
221
  try {
206
222
  try {
207
- await sous(async () =>
208
- places.demarrerLesPlaces(c.client, entreeDe(), {
209
- file: FILE_DE_LA_MACHINE,
210
- })
223
+ await sous(() =>
224
+ ouvrirLArbitre({ places, client: c.client, entree: entreeDe(), file: FILE_DE_LA_MACHINE })
211
225
  );
212
226
  } catch (x) {
213
227
  if (x?.name !== 'WorkflowExecutionAlreadyStartedError') {
@@ -42,7 +42,7 @@ export function budgetDe(
42
42
  ): PartDeLaPasse;
43
43
 
44
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;
45
+ export function partDe(o: { budget: PartDeLaPasse; pic?: number; places?: number }): PartDeLaPasse;
46
46
 
47
47
  /** The ceiling of a part without a measure: its reservation plus a quarter, within the budget. */
48
48
  export function plafondDeDepart(
@@ -20,12 +20,13 @@
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
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,
23
+ // least, and its memory the budget divided by the places (the ceiling of the places, 3 by default),
24
24
  // raised to the largest peak given plus a quarter, within the budget. A project's table of the
25
25
  // consumptions gives a phase its own (`reservationDeLaPasse` of ./places-de-la-machine.mjs).
26
26
  import { readFileSync } from 'node:fs';
27
- import { cpus, totalmem } from 'node:os';
27
+ import { totalmem } from 'node:os';
28
28
  import path from 'node:path';
29
+ import { coeursDeLaMachine } from './mesure-de-la-machine.mjs';
29
30
  import {
30
31
  avecLeFichierDuPoste,
31
32
  configurationDuPoste,
@@ -46,7 +47,7 @@ export const RESERVE_COEURS_PAR_DEFAUT = 4;
46
47
  export const RESERVE_MEMOIRE_GO_PAR_DEFAUT = 4;
47
48
  /** The cores the reservation of an ordinary pass holds when its project declares none. */
48
49
  export const COEURS_PAR_DEFAUT = 3;
49
- // 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.
50
51
  const COEURS_LAISSES_AUX_PASSES = 4;
51
52
 
52
53
  /**
@@ -120,10 +121,10 @@ function entierDuPoste(env, nom, defaut, lire) {
120
121
  * @throws {Error} naming the variable whose value is not a whole number ≥ 0
121
122
  */
122
123
  export function reserveDe(env = process.env, o = {}) {
123
- const coeursDeLaMachine = o.coeurs ?? cpus().length;
124
+ const coeursDuPoste = o.coeurs ?? coeursDeLaMachine();
124
125
  const parDefaut = Math.min(
125
126
  RESERVE_COEURS_PAR_DEFAUT,
126
- Math.max(0, coeursDeLaMachine - COEURS_LAISSES_AUX_PASSES)
127
+ Math.max(0, coeursDuPoste - COEURS_LAISSES_AUX_PASSES)
127
128
  );
128
129
  return {
129
130
  coeurs: entierDuPoste(env, VARIABLE_RESERVE_COEURS, parDefaut, o.lire),
@@ -157,18 +158,14 @@ export function budgetDe({ coeurs, memoireTotale }, reserve) {
157
158
  /** The margin over the largest measured peak of memory: a quarter. */
158
159
  const MARGE_DE_LA_MEMOIRE = 1.25;
159
160
 
160
- // The default memory: its floor, the proportion of the budget a part of 4 cores held (or a third
161
- // 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
162
163
  // quarter (the hard ceiling of the group kills a pass above it) when the register measured more. A
163
164
  // register that holds light passes alone (the guards, a pass of 50 ms: a peak of 16 Mo) would
164
165
  // else give the next pass a ceiling its kernel kills it under, as the Vertical Pod Autoscaler
165
166
  // bounds its recommendation by a minimum (`minAllowed`).
166
- function memoireParDefautDe(budget, pic) {
167
- const coeursDAvant = Math.max(
168
- 1,
169
- Math.min(budget.coeurs, Math.max(COEURS_LAISSES_AUX_PASSES, Math.ceil(budget.coeurs / 3)))
170
- );
171
- 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));
172
169
  return Math.min(budget.memoire, Math.max(plancher, Math.floor((pic ?? 0) * MARGE_DE_LA_MEMOIRE)));
173
170
  }
174
171
 
@@ -177,13 +174,14 @@ function memoireParDefautDe(budget, pic) {
177
174
  * the default memory within the budget. A project's table of the consumptions gives a phase its own
178
175
  * measure (`reservationDeLaPasse` of ./places-de-la-machine.mjs); no key of its `package.json`
179
176
  * enters it.
180
- * @param {{ budget: { coeurs: number, memoire: number }, pic?: number }} o
177
+ * @param {{ budget: { coeurs: number, memoire: number }, pic?: number, places?: number }} o
178
+ * `places`, the ceiling of the places (3 by default)
181
179
  * @returns {{ coeurs: number, memoire: number }}
182
180
  */
183
- export function partDe({ budget, pic }) {
181
+ export function partDe({ budget, pic, places = PLAFOND_PAR_DEFAUT }) {
184
182
  return {
185
183
  coeurs: Math.max(1, Math.min(budget.coeurs, COEURS_PAR_DEFAUT)),
186
- memoire: Math.min(budget.memoire, memoireParDefautDe(budget, pic)),
184
+ memoire: Math.min(budget.memoire, memoireParDefautDe(budget, pic, places)),
187
185
  };
188
186
  }
189
187
 
@@ -203,7 +201,7 @@ export const plafondDeDepart = (part, budget) => ({
203
201
  * The hardware of this machine: its cores and its total memory (bytes).
204
202
  * @returns {{ coeurs: number, memoireTotale: number }}
205
203
  */
206
- export const materielDeLaMachine = () => ({ coeurs: cpus().length, memoireTotale: totalmem() });
204
+ export const materielDeLaMachine = () => ({ coeurs: coeursDeLaMachine(), memoireTotale: totalmem() });
207
205
 
208
206
  /**
209
207
  * The budget of this machine under <env>: its hardware less the reserve of the user.
@@ -86,6 +86,8 @@ export function refusDeLaReservation(
86
86
  rang: number;
87
87
  ticket?: string | null;
88
88
  raison?: string;
89
+ coeurs?: number;
90
+ memoire?: number;
89
91
  /** The requests that fit and were granted before it. */
90
92
  passages?: number;
91
93
  }[];
@@ -174,8 +174,14 @@ export function refusDeLaReservation(
174
174
  }
175
175
  // A request that fits passes before the waits of a lower rank, until one of them has been
176
176
  // passed PASSAGES_MAX times (the backfill of Slurm, bounded in passages, not in minutes).
177
+ // A wait whose reservation can never fit in the budget (unschedulable, as Kubernetes refuses it
178
+ // at admission) protects no rank: no other wait is held back for it.
179
+ const tientUnJour = a =>
180
+ a.coeurs === undefined ||
181
+ a.memoire === undefined ||
182
+ partDansLeBudget({ part: a, budget, prises: [], cran }).ok;
177
183
  const bloquante = etat.attentes.find(
178
- a => a.id !== id && a.rang < rang && (a.passages ?? 0) >= PASSAGES_MAX
184
+ a => a.id !== id && a.rang < rang && (a.passages ?? 0) >= PASSAGES_MAX && tientUnJour(a)
179
185
  );
180
186
  if (bloquante) {
181
187
  return `rang réservé : ${bloquante.ticket ?? 'une étape'} attend, la borne de ${PASSAGES_MAX} passages est atteinte (${bloquante.raison})`;
@@ -183,7 +189,9 @@ export function refusDeLaReservation(
183
189
  const prises = etat.prises.filter(p => p.id !== id);
184
190
  const tient = partDansLeBudget({ part: reservation, budget, prises, cran });
185
191
  if (!tient.ok) {
186
- return tient.raison;
192
+ return partDansLeBudget({ part: reservation, budget, prises: [], cran }).ok
193
+ ? tient.raison
194
+ : `ne tient jamais dans le budget du poste, ${tient.raison}`;
187
195
  }
188
196
  const mesure = mesurer();
189
197
  const parties = prises.filter(p => maintenant - (p.depuis ?? 0) < FENETRE_DE_DEPART_MS);
@@ -275,7 +283,7 @@ export function phaseDeLaReservation({ prises, reservation = null }) {
275
283
  * reprise?: { ticket: string, rang: number | null }, groupe?: string,
276
284
  * priorites?: Record<string, { priorite: number, creation: string }>, max?: number }} demande
277
285
  * @param {{ rang: number, plafond: number, maintenant: number, reservee?: boolean }} o `reservee`:
278
- * the machine is reserved by the night, no place is given
286
+ * the machine is closed by the supervisor, no place is given
279
287
  */
280
288
  export function reserverDesCircuits(places, demande, o) {
281
289
  const {
@@ -356,7 +364,7 @@ export function reserverDesCircuits(places, demande, o) {
356
364
  // The places of circuits each project holds, under the bound its last demand carried (`max`).
357
365
  const tenuesDe = r => circuits.filter(c => c.accordee && c.racine === r).length;
358
366
  for (const c of circuits.filter(x => !x.accordee).sort((a, b) => a.rang - b.rang)) {
359
- // Under the reservation of the night no place is new: circuits alive keep theirs.
367
+ // Under the closure of the machine no place is new: circuits alive keep theirs.
360
368
  if (reservee || tenues >= plafond) {
361
369
  break;
362
370
  }
@@ -155,7 +155,7 @@ const objet = (properties, required = [], description) => ({
155
155
  });
156
156
  // The description of a piece in a sheet's schema, the format `lirePiece` reads.
157
157
  const PIECE =
158
- 'fichier:ligne depuis la racine de la copie, puis ce qu’elle montre ; ou « $ <commande> » et sa sortie aux lignes suivantes ; ou, pour ce que dit le ticket, « ticket, critère <N> » ou « ticket, § <section> », puis « : » et ce qu’elle montre';
158
+ 'fichier:ligne, fichier:ligne-ligne (plage) ou fichier:ligne,ligne (liste) depuis la racine de la copie, puis ce qu’elle montre ; ou « $ <commande> » et sa sortie aux lignes suivantes ; ou, pour ce que dit le ticket, « ticket, critère <N> » ou « ticket, § <section> », puis « : » et ce qu’elle montre';
159
159
  const piece = quoi => texte(`${quoi} : ${PIECE}.`);
160
160
  const STATUT = {
161
161
  statut: { type: 'string', enum: ['FAIT', 'BLOQUÉ', 'BESOIN'] },
@@ -785,7 +785,8 @@ export function conformiteDuTri(fiche, decouvertes) {
785
785
 
786
786
  // The piece of a fact <texte>: `{ fichier, ligne }` for « <fichier>:<ligne> », `{ fichier, ligne,
787
787
  // fin }` for « <fichier>:<ligne>-<fin> » (as SARIF's region has a start line and an optional end
788
- // line), then what it shows after a space, the place in backquotes or followed by punctuation
788
+ // line), `{ fichier, ligne, items }` for a list « <fichier>:15,38,44 » (each item a line or a range
789
+ // `{ ligne, fin? }`, `ligne` the first), then what it shows after a space, the place in backquotes or followed by punctuation
789
790
  // read the same; `{ commande, sortie }` for « $ <commande> » and its output on the lines after,
790
791
  // a « \n » written in two characters read as the line break of a piece written on one line;
791
792
  // `{ critere }` for « ticket, critère <N> » and `{ section }`
@@ -812,19 +813,22 @@ export function lirePiece(texte) {
812
813
  lieu = lieu.slice(1);
813
814
  }
814
815
  const deux = lieu.lastIndexOf(':');
815
- const [debut, fin, ...reste] = lieu.slice(deux + 1).split('-');
816
816
  const nombre = n => (/^\d+$/.test(n ?? '') && Number(n) >= 1 ? Number(n) : null);
817
- const ligne = nombre(debut);
818
- if (deux < 1 || !ligne || reste.length) {
819
- return null;
820
- }
821
- if (fin === undefined) {
822
- return { fichier: lieu.slice(0, deux), ligne };
817
+ // Each item of the list is a line or a range.
818
+ const items = [];
819
+ for (const item of lieu.slice(deux + 1).split(',')) {
820
+ const [debut, fin, ...reste] = item.split('-');
821
+ const ligne = nombre(debut);
822
+ if (!ligne || reste.length || (fin !== undefined && (!nombre(fin) || nombre(fin) < ligne))) {
823
+ return null;
824
+ }
825
+ items.push(fin === undefined ? { ligne } : { ligne, fin: nombre(fin) });
823
826
  }
824
- if (!nombre(fin) || nombre(fin) < ligne) {
827
+ if (deux < 1) {
825
828
  return null;
826
829
  }
827
- return { fichier: lieu.slice(0, deux), ligne, fin: nombre(fin) };
830
+ const fichier = lieu.slice(0, deux);
831
+ return items.length === 1 ? { fichier, ...items[0] } : { fichier, ligne: items[0].ligne, items };
828
832
  }
829
833
 
830
834
  // The piece of the ticket <reste>, what follows « ticket, »: `{ critere }` for « critère <N> »,
@@ -866,7 +870,7 @@ function introuvables(f, copie) {
866
870
  continue;
867
871
  }
868
872
  let abs = path.resolve(racine, lu.fichier);
869
- const lieu = `${lu.fichier}:${lu.ligne}${lu.fin ? `-${lu.fin}` : ''}`;
873
+ const lieu = `${lu.fichier}:${lu.items ? lu.items.map(i => i.ligne + (i.fin ? `-${i.fin}` : '')).join(',') : lu.ligne + (lu.fin ? `-${lu.fin}` : '')}`;
870
874
  // The journal of the ticket, `<copie>.log` next to the copy, named by its absolute path or by
871
875
  // `<nom de la copie>.log`; a file of the copy of that name is judged as that file.
872
876
  const journal = `${racine}.log`;
@@ -883,7 +887,7 @@ function introuvables(f, copie) {
883
887
  }
884
888
  const contenu = readFileSync(abs, 'utf8');
885
889
  const lignes = contenu.split('\n').length - (contenu.endsWith('\n') ? 1 : 0);
886
- if ((lu.fin ?? lu.ligne) > lignes) {
890
+ if (Math.max(...(lu.items ?? [lu]).map(i => i.fin ?? i.ligne)) > lignes) {
887
891
  out.push(`${ou} : ${lieu} introuvable dans la copie : le fichier a ${lignes} lignes`);
888
892
  }
889
893
  }
@@ -973,7 +977,7 @@ function manques(role, f) {
973
977
  for (const [ou, p] of piecesDe(f)) {
974
978
  if (!lirePiece(p)) {
975
979
  out.push(
976
- `${ou} : « ${p} » n'est pas une pièce (fichier:ligne, « $ <commande> » et sa sortie, ou « ticket, critère <N> » ou « ticket, § <section> »)`
980
+ `${ou} : « ${p} » n'est pas une pièce (fichier:ligne, fichier:ligne-ligne, fichier:ligne,ligne, « $ <commande> » et sa sortie, ou « ticket, critère <N> » ou « ticket, § <section> »)`
977
981
  );
978
982
  }
979
983
  }
@@ -54,7 +54,7 @@ import {
54
54
  import { langageDe, langageDeLaCopie } from './langages.mjs';
55
55
  import { DEMANDE_UN_PLAN, leRole, nomDuRole, phaseDeLaSeance } from './etapes.mjs';
56
56
  import { departDe, VARIABLE_SEANCE } from './mesure/base-de-passe.mjs';
57
- import { groupeVivant, signalerGroupe } from './mesure-de-la-machine.mjs';
57
+ import { arreterLEtape, groupeVivant, signalerGroupe } from './mesure-de-la-machine.mjs';
58
58
  import {
59
59
  commandeDuGroupe,
60
60
  groupeIndisponible,
@@ -498,6 +498,12 @@ export async function lancer(
498
498
  error: r.erreur ?? undefined,
499
499
  signal: r.bloque || r.annulee ? 'SIGTERM' : null,
500
500
  });
501
+ // The unit of the reservation outlives a command that left a detached process, and the
502
+ // resumption of the step names it again: the end of the session stops it (machine.md §5.2).
503
+ const etape = mesure ? reservationDeLEtape(lancement.env)?.id : undefined;
504
+ if (etape) {
505
+ arreterLEtape(etape);
506
+ }
501
507
  if (r.pid === null && r.annulee) {
502
508
  fermer();
503
509
  }
@@ -36,7 +36,6 @@ const SCRIPTS = path.dirname(fileURLToPath(import.meta.url));
36
36
  // Each subcommand and its script, under `scripts/`, or the command of the module of the language
37
37
  // that runs it (`{ langage }`, its name in `commandes`).
38
38
  export const SOUS_COMMANDES = {
39
- 'attente-au-tour': 'attente-au-tour.mjs',
40
39
  bilan: 'bilan.mjs',
41
40
  binaires: 'binaires.mjs',
42
41
  circuit: '../dist/temporal/circuit/commande.js',