@roomi-fields/grillhouse 0.48.0 → 0.49.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 (155) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +90 -0
  3. package/agents/direct.md +9 -0
  4. package/cadre/templates/projet/.github/workflows/ci.yml +11 -0
  5. package/cadre/templates/projet/.github/workflows/nuit.yml +15 -6
  6. package/cadre/templates/projet/CLAUDE.md +10 -6
  7. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  8. package/cadre/templates/turbo/paquets.json +3 -1
  9. package/cadre/templates/turbo/sans-paquets.json +3 -1
  10. package/charte.md +51 -14
  11. package/dist/temporal/acte.d.ts +9 -0
  12. package/dist/temporal/acte.js +43 -20
  13. package/dist/temporal/acte.js.map +1 -1
  14. package/dist/temporal/circuit/appel.d.ts +4 -1
  15. package/dist/temporal/circuit/appel.js +15 -1
  16. package/dist/temporal/circuit/appel.js.map +1 -1
  17. package/dist/temporal/circuit/client.d.ts +7 -1
  18. package/dist/temporal/circuit/client.js +54 -1
  19. package/dist/temporal/circuit/client.js.map +1 -1
  20. package/dist/temporal/circuit/commande.js +30 -57
  21. package/dist/temporal/circuit/commande.js.map +1 -1
  22. package/dist/temporal/circuit/contrat.d.ts +2 -1
  23. package/dist/temporal/circuit/contrat.js +2 -1
  24. package/dist/temporal/circuit/contrat.js.map +1 -1
  25. package/dist/temporal/circuit/deroule.js +9 -2
  26. package/dist/temporal/circuit/deroule.js.map +1 -1
  27. package/dist/temporal/file/contrat.d.ts +16 -2
  28. package/dist/temporal/file/contrat.js +27 -3
  29. package/dist/temporal/file/contrat.js.map +1 -1
  30. package/dist/temporal/file/deroule.js +4 -4
  31. package/dist/temporal/file/deroule.js.map +1 -1
  32. package/dist/temporal/nuits/activites.d.ts +1 -15
  33. package/dist/temporal/nuits/activites.js +3 -62
  34. package/dist/temporal/nuits/activites.js.map +1 -1
  35. package/dist/temporal/nuits/contrat.d.ts +3 -21
  36. package/dist/temporal/nuits/deroule.js +38 -74
  37. package/dist/temporal/nuits/deroule.js.map +1 -1
  38. package/dist/temporal/places/client.d.ts +3 -16
  39. package/dist/temporal/places/client.js +3 -26
  40. package/dist/temporal/places/client.js.map +1 -1
  41. package/dist/temporal/places/contrat.d.ts +15 -51
  42. package/dist/temporal/places/contrat.js +3 -13
  43. package/dist/temporal/places/contrat.js.map +1 -1
  44. package/dist/temporal/places/deroule.js +11 -61
  45. package/dist/temporal/places/deroule.js.map +1 -1
  46. package/dist/temporal/tickets/activites.js +4 -2
  47. package/dist/temporal/tickets/activites.js.map +1 -1
  48. package/dist/temporal/tickets/contrat.d.ts +2 -1
  49. package/docs/ARCHITECTURE.md +337 -120
  50. package/docs/CADRE.md +16 -13
  51. package/docs/INTERFACE.md +90 -25
  52. package/hooks/hooks.json +9 -0
  53. package/hooks/register.tsx +59 -5
  54. package/package.json +1 -1
  55. package/scripts/activites.mjs +271 -42
  56. package/scripts/aiguillage.mjs +4 -1
  57. package/scripts/bilan.mjs +125 -2
  58. package/scripts/circuit.mjs +233 -159
  59. package/scripts/circuits-cles.d.mts +3 -3
  60. package/scripts/circuits-cles.mjs +6 -5
  61. package/scripts/coeurs-dedies.mjs +4 -4
  62. package/scripts/commandes-composees.mjs +12 -5
  63. package/scripts/dette.d.ts +2 -1
  64. package/scripts/dette.mjs +49 -6
  65. package/scripts/direct.mjs +343 -0
  66. package/scripts/droits.mjs +26 -4
  67. package/scripts/effets.mjs +4 -4
  68. package/scripts/engendres.mjs +2 -1
  69. package/scripts/enveloppe/enveloppe.mjs +119 -18
  70. package/scripts/enveloppe/lancer.sh +14 -3
  71. package/scripts/enveloppe/paquets-du-plan.mjs +9 -0
  72. package/scripts/enveloppe/travail-de-la-copie.mjs +119 -21
  73. package/scripts/etapes.mjs +3 -3
  74. package/scripts/faits-du-circuit.mjs +12 -11
  75. package/scripts/fermeture-de-la-machine.d.mts +4 -4
  76. package/scripts/fermeture-de-la-machine.mjs +10 -20
  77. package/scripts/fichiers-nommes.mjs +27 -1
  78. package/scripts/file-des-tickets.d.mts +18 -1
  79. package/scripts/file-des-tickets.mjs +63 -15
  80. package/scripts/flux-de-la-nuit.mjs +38 -0
  81. package/scripts/grillhouse-maj.mjs +13 -25
  82. package/scripts/groupe-cles.d.mts +6 -0
  83. package/scripts/groupe-cles.mjs +29 -1
  84. package/scripts/integration/file.mjs +148 -37
  85. package/scripts/jointure.d.ts +20 -3
  86. package/scripts/journal-des-etats.d.mts +16 -0
  87. package/scripts/journal-des-etats.mjs +44 -2
  88. package/scripts/journal.mjs +3 -0
  89. package/scripts/langages/c/commandes.mjs +5 -5
  90. package/scripts/langages/c/composants.mjs +13 -5
  91. package/scripts/langages/cargo/commandes.mjs +5 -6
  92. package/scripts/langages/python/commandes.mjs +5 -5
  93. package/scripts/langages/python/composants.mjs +10 -2
  94. package/scripts/langages/typescript/composants.mjs +10 -3
  95. package/scripts/langages/typescript/consommateurs-arbitres.mjs +15 -3
  96. package/scripts/langages/typescript/construire.mjs +2 -0
  97. package/scripts/langages/typescript/exemples.mjs +33 -1
  98. package/scripts/langages/typescript/index.mjs +19 -0
  99. package/scripts/langages/typescript/migrations/0.49.0-tests-equipes.mjs +32 -0
  100. package/scripts/langages/typescript/tests-de-nuit.mjs +158 -32
  101. package/scripts/langages/typescript/tests-du-poste.mjs +112 -32
  102. package/scripts/langages/typescript/titres-de-tests.mjs +11 -7
  103. package/scripts/langages/typescript/turbo-des-paquets.mjs +21 -4
  104. package/scripts/langages/typescript/verifier.mjs +3 -5
  105. package/scripts/langages/typescript/verrou-des-dependances.mjs +161 -0
  106. package/scripts/langages/typescript/vitest-config/cibles.mjs +57 -6
  107. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +11 -5
  108. package/scripts/langages/typescript/vitest.nuit.config.mjs +53 -5
  109. package/scripts/machine.mjs +1 -1
  110. package/scripts/mesure/base-de-passe.mjs +2 -1
  111. package/scripts/migrations/0.49.0-reservation-de-trois-coeurs.mjs +30 -0
  112. package/scripts/migrations.mjs +2 -0
  113. package/scripts/nuit.sh +129 -3
  114. package/scripts/paquet.mjs +16 -5
  115. package/scripts/paquets.d.ts +4 -0
  116. package/scripts/paquets.mjs +57 -0
  117. package/scripts/passe-de-la-machine.mjs +4 -7
  118. package/scripts/places-de-la-machine.mjs +55 -42
  119. package/scripts/places-du-serveur.mjs +2 -2
  120. package/scripts/plafond-de-la-machine.d.mts +7 -13
  121. package/scripts/plafond-de-la-machine.mjs +19 -35
  122. package/scripts/prefixe-des-tickets.mjs +1 -1
  123. package/scripts/references-changees.mjs +159 -0
  124. package/scripts/regles-des-places.d.mts +8 -31
  125. package/scripts/regles-des-places.mjs +14 -64
  126. package/scripts/repli-de-la-nuit.mjs +183 -0
  127. package/scripts/reponses-du-circuit.d.mts +2 -2
  128. package/scripts/reponses-du-circuit.mjs +21 -12
  129. package/scripts/reprise.mjs +27 -8
  130. package/scripts/resultats.mjs +21 -9
  131. package/scripts/seances.mjs +258 -40
  132. package/scripts/services-du-noyau.mjs +4 -0
  133. package/scripts/sous-commandes.mjs +24 -7
  134. package/scripts/superviseur.mjs +185 -39
  135. package/scripts/tableau.mjs +226 -94
  136. package/scripts/taches-du-graphe.mjs +84 -4
  137. package/scripts/ticket.mjs +348 -0
  138. package/scripts/transitions.d.mts +44 -0
  139. package/scripts/transitions.mjs +188 -17
  140. package/scripts/un-commit-par-ticket.mjs +4 -3
  141. package/scripts/verdict-de-la-nuit.mjs +47 -20
  142. package/scripts/verrou-de-fichier.mjs +2 -2
  143. package/scripts/verrous/ecriture-hors-enveloppe.mjs +86 -0
  144. package/scripts/verrous/verrou.mjs +17 -1
  145. package/skills/architecte/SKILL.md +203 -0
  146. package/skills/architecte/references/exemple-d-architecture.md +159 -0
  147. package/skills/developpeur/SKILL.md +1 -1
  148. package/skills/direct/SKILL.md +57 -0
  149. package/skills/explorateur/SKILL.md +10 -6
  150. package/skills/pitmaster/SKILL.md +37 -14
  151. package/skills/pitmaster/references/consigne-agent.md +7 -1
  152. package/skills/redacteur/references/documents-d-un-composant.md +2 -1
  153. package/skills/relecteur/SKILL.md +8 -0
  154. package/skills/testwriter/SKILL.md +10 -0
  155. package/scripts/ticket.sh +0 -25
@@ -13,7 +13,9 @@
13
13
  // path, or else the folder's name, as the guard of the languages reads a component; a row that
14
14
  // names the path itself comes first. Refused, by its name, and nothing written: a path no row
15
15
  // names; a row whose cell of the column « Langage » is empty; a language out of the frame's
16
- // list; a folder that already holds the manifest of its language (`manifeste` of its module). A
16
+ // list; a folder that already holds the manifest of its language (`manifeste` of its module); a
17
+ // key `grillhouse.groupe` the update would refuse (`groupeDe` of ./groupe-cles.mjs, read in the
18
+ // main tree of the repository: the command plays in a copy of work as in the main tree). A
17
19
  // folder that holds docs/ alone, the documents of the second time, is accepted, as `cargo init`
18
20
  // takes a folder without its Cargo.toml; a folder that already holds code is given to the
19
21
  // module with its files (`existants`), which takes them as they are, or refuses, by its name,
@@ -47,6 +49,7 @@ import { pathToFileURL } from 'node:url';
47
49
  import { CADRE } from './cadre.mjs';
48
50
  import { installerBinaires } from './binaires.mjs';
49
51
  import { aInstaller, mettreAJour, rapport, regenerer } from './grillhouse-maj.mjs';
52
+ import { groupeDe } from './groupe-cles.mjs';
50
53
  import { LANGAGES, langage } from './langages.mjs';
51
54
  import {
52
55
  inscrireAuxEspaces,
@@ -284,15 +287,23 @@ const lancer = (commande, args, dossier) =>
284
287
  /**
285
288
  * Creates the package at <chemin> of the project at <racine>: its plan written, then the tools of
286
289
  * its language (see the header). Returns `{ ecrits, lignes, echecs }`: the files written, the
287
- * lines of the report, the lines of each command that fails. Throws a Refus as `planDuPaquet`.
290
+ * lines of the report, the lines of each command that fails. Throws a Refus as `planDuPaquet`,
291
+ * and on a faulty key `grillhouse.groupe`, before any file is written.
288
292
  * @param {string} racine
289
293
  * @param {string} chemin
290
- * @param {{ source?: string, executer?: (commande: string, args: string[], dossier: string) => number }} [o]
294
+ * @param {{ source?: string, executer?: (commande: string, args: string[], dossier: string) => number, bd?: (args: string[], cwd: string) => { status: number | null, stdout?: string, stderr?: string } }} [o]
295
+ * `bd`: the Beads the update plays (`mettreAJour`), the real one without it
291
296
  */
292
- export function creerPaquet(racine, chemin, { source = CADRE, executer = lancer } = {}) {
297
+ export function creerPaquet(racine, chemin, { source = CADRE, executer = lancer, bd } = {}) {
293
298
  const plan = planDuPaquet(racine, chemin, { source });
299
+ // What the update refuses by its key is refused here, before the first file is written.
300
+ try {
301
+ groupeDe(racine);
302
+ } catch (e) {
303
+ throw new Refus(e.message.replace(/^⛔ /, ''));
304
+ }
294
305
  const ecrits = ecrireLePaquet(racine, plan);
295
- const b = mettreAJour(racine, source);
306
+ const b = mettreAJour(racine, source, bd ? { bd } : {});
296
307
  const echecs = [];
297
308
  const vus = new Set();
298
309
  const jouer = (commande, args, dossier) => {
@@ -8,3 +8,7 @@ export const CODE: string;
8
8
  export const TYPAGE: string;
9
9
  /** The names listed in `racine`'s `docs/agents/hors-cadre.txt`: empty without the file. */
10
10
  export function horsCadre(racine: string): Set<string>;
11
+ /** Those of `chemins` (absolute, under `racine`), each as given, that git ignores in the repository
12
+ * at `racine`; a path under a submodule is never one. Empty when `racine` is not the root of a git
13
+ * repository (it holds no `.git`), or when git does not answer. */
14
+ export function ignoresParGit(racine: string, chemins: string[]): Set<string>;
@@ -10,11 +10,16 @@
10
10
  // `docs/agents/hors-cadre.txt` (read by `horsCadre`, below) lists it: a directory under
11
11
  // `packages/` or `src/`.
12
12
  //
13
+ // What git ignores holds no component (`ignoresParGit`, below): the modules of language that find
14
+ // their components on the disk (c, python, typescript) leave it out, as ripgrep and ESLint judge
15
+ // the tree git follows.
16
+ //
13
17
  // This module and the ones it imports use Node alone: the update runs them from a source checkout
14
18
  // of the frame that installs no dependency.
15
19
  //
16
20
  // A project's guard imports `horsCadre` by the package's entry `@roomi-fields/grillhouse/paquets`,
17
21
  // its types in ./paquets.d.ts (docs/ARCHITECTURE.md, the package's named entries).
22
+ import { spawnSync } from 'node:child_process';
18
23
  import { existsSync, globSync, readdirSync, readFileSync } from 'node:fs';
19
24
  import path from 'node:path';
20
25
 
@@ -45,6 +50,58 @@ export function horsCadre(racine) {
45
50
  return noms;
46
51
  }
47
52
 
53
+ /**
54
+ * Those of <chemins> (absolute, under <racine>), each as given, that git ignores in the repository
55
+ * at <racine>, as `git check-ignore` reads its exclusion rules: a path under an ignored folder is
56
+ * ignored, a file git tracks never is. A path under a submodule is never ignored: the submodule
57
+ * is tracked, and git refuses to judge a path inside it. Empty when <racine> is not the root of a
58
+ * git repository (it holds no `.git`), or when git does not answer: the disk alone is then read.
59
+ * @param {string} racine the root of the project
60
+ * @param {string[]} chemins
61
+ * @returns {Set<string>}
62
+ */
63
+ export function ignoresParGit(racine, chemins) {
64
+ if (chemins.length === 0 || !existsSync(path.join(racine, '.git'))) {
65
+ return new Set();
66
+ }
67
+ const git = (args, input) =>
68
+ spawnSync('git', ['-C', racine, ...args], {
69
+ input,
70
+ encoding: 'utf8',
71
+ maxBuffer: 256 * 1024 * 1024,
72
+ });
73
+ // The submodules of the index (its entries of mode 160000), each a path from the root.
74
+ const index = git(['ls-files', '--stage', '-z']);
75
+ if (index.status !== 0) {
76
+ return new Set();
77
+ }
78
+ const sousModules = index.stdout
79
+ .split('\0')
80
+ .filter(l => l.startsWith('160000 '))
81
+ .map(l => l.slice(l.indexOf('\t') + 1));
82
+ const parRel = new Map();
83
+ for (const c of chemins) {
84
+ const rel = path.relative(racine, c).split(path.sep).join('/');
85
+ if (!sousModules.some(s => rel === s || rel.startsWith(`${s}/`))) {
86
+ parRel.set(rel, c);
87
+ }
88
+ }
89
+ if (parRel.size === 0) {
90
+ return new Set();
91
+ }
92
+ const r = git(['check-ignore', '-z', '--stdin'], [...parRel.keys()].join('\0'));
93
+ // 0: at least one path is ignored; 1: none; any other code, git did not answer.
94
+ if (r.status !== 0) {
95
+ return new Set();
96
+ }
97
+ return new Set(
98
+ r.stdout
99
+ .split('\0')
100
+ .filter(rel => parRel.has(rel))
101
+ .map(rel => parRel.get(rel))
102
+ );
103
+ }
104
+
48
105
  // The names of <racine>'s `docs/agents/hors-cadre.txt` that no directory under `packages/` or
49
106
  // `src/` bears, in the order of the list: a line the session start names (a typo names nothing).
50
107
  export function horsCadreInconnus(racine) {
@@ -296,12 +296,12 @@ export const jugeLaChargeDuJeu = ({ dediee, voie, env = process.env }) =>
296
296
  * @param {(env: Record<string, string | undefined>,
297
297
  * contexte: { part: { coeurs: number, memoire: number } | null, groupe: boolean,
298
298
  * unite: string | null }) => T} mesure
299
- * @param {{ lourde?: boolean, mode?: 'processus' | 'commande', entiere?: boolean,
299
+ * @param {{ lourde?: boolean, mode?: 'processus' | 'commande',
300
300
  * env?: Record<string, string | undefined>, racine?: string, ticket?: string, sorte?: string,
301
301
  * dire?: (l: string) => void, borneMs?: number, rappelMs?: number, scope?: object,
302
302
  * horloge?: () => number, coeurs?: number, sonde?: () => boolean } & Record<string, unknown>} options
303
303
  * `mode` « processus » (by default): the pass is the process itself, which enters its group;
304
- * `entiere`: the whole budget, the night's part; `mesure`: a measure of time, which plays on
304
+ * `mesure`: a measure of time, which plays on
305
305
  * dedicated cores (scripts/coeurs-dedies.mjs), attached to them (`contexte.fils`,
306
306
  * `contexte.affinite`) and judged on the load of those cores out of it
307
307
  * @returns {T}
@@ -488,9 +488,8 @@ function attacherLeProcessus(fils) {
488
488
  * held, in the envelope of an agent).
489
489
  * @param {(env: Record<string, string | undefined>,
490
490
  * part: { coeurs: number, memoire: number } | null) => number} passe
491
- * @param {{ env?: Record<string, string | undefined>, racine?: string, entiere?: boolean,
492
- * mesure?: boolean, dire?: (l: string) => void }} [o] `entiere`: the whole budget as its part
493
- * (the night); `mesure`: dedicated physical cores as its part (a measure of time)
491
+ * @param {{ env?: Record<string, string | undefined>, racine?: string,
492
+ * mesure?: boolean, dire?: (l: string) => void }} [o] `mesure`: dedicated physical cores as its part (a measure of time)
494
493
  * @returns {number}
495
494
  */
496
495
  export function surUnePart(
@@ -498,7 +497,6 @@ export function surUnePart(
498
497
  {
499
498
  env = process.env,
500
499
  racine = process.cwd(),
501
- entiere = false,
502
500
  mesure = false,
503
501
  dire = l => process.stderr.write(`${l}\n`),
504
502
  } = {}
@@ -506,7 +504,6 @@ export function surUnePart(
506
504
  try {
507
505
  return avecLaPasse((e, { part }) => passe(e, part), {
508
506
  lourde: false,
509
- entiere,
510
507
  mesure,
511
508
  env,
512
509
  racine,
@@ -94,16 +94,11 @@ import {
94
94
  plafondDe,
95
95
  reserveDe,
96
96
  } from './plafond-de-la-machine.mjs';
97
- import { duree, refusDePart, VARIABLE_JETON } from './regles-des-places.mjs';
97
+ import { duree, refusDePart } from './regles-des-places.mjs';
98
98
  import { attendreUnPeu, lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
99
99
 
100
- // The spacing and the jeton of the night are rules (./regles-des-places.mjs), published here too.
101
- export {
102
- ESPACEMENT_MS,
103
- espacementDe,
104
- VARIABLE_ESPACEMENT,
105
- VARIABLE_JETON,
106
- } from './regles-des-places.mjs';
100
+ // The spacing is a rule (./regles-des-places.mjs), published here too.
101
+ export { ESPACEMENT_MS, espacementDe, VARIABLE_ESPACEMENT } from './regles-des-places.mjs';
107
102
  export const VARIABLE_TRAVAILLEURS = 'GRILLHOUSE_TRAVAILLEURS';
108
103
 
109
104
  /**
@@ -225,23 +220,19 @@ export function prendreUnRang({ env = process.env } = {}) {
225
220
 
226
221
  /**
227
222
  * The request of a place for the process <pid>: its start, its ticket, the root of its project,
228
- * the rank of its circuit, and the jeton of the night when <env> carries it (VARIABLE_JETON: the
229
- * passes of the night), which the workflow of the machine lets pass during the reservation of the
230
- * machine.
231
- * @param {{ env?: Record<string, string | undefined>, pid: number, depart?: string | null,
223
+ * and the rank of its circuit.
224
+ * @param {{ pid: number, depart?: string | null,
232
225
  * ticket?: string | null, racine?: string, rang?: number | null }} o
233
226
  * @returns {{ pid: number, depart: string | null, ticket: string | null, racine?: string | null,
234
- * rang?: number, jeton?: string }}
227
+ * rang?: number }}
235
228
  */
236
- export function demandeDePlace({ env = process.env, pid, depart, ticket = null, racine, rang }) {
237
- const jeton = env[VARIABLE_JETON];
229
+ export function demandeDePlace({ pid, depart, ticket = null, racine, rang }) {
238
230
  return {
239
231
  pid,
240
232
  depart: depart === undefined ? departDe(pid) : depart,
241
233
  ticket,
242
234
  ...(racine === undefined ? {} : { racine: racineDuDepot(racine) }),
243
235
  ...(rang === undefined || rang === null ? {} : { rang }),
244
- ...(jeton ? { jeton } : {}),
245
236
  };
246
237
  }
247
238
 
@@ -276,7 +267,7 @@ export function prendreUnePlace({
276
267
  return { id: null, rang: rang ?? null, env, rendre: () => {}, rattacher: () => {} };
277
268
  }
278
269
  const demande = {
279
- ...demandeDePlace({ env, pid, depart, ticket, racine, rang }),
270
+ ...demandeDePlace({ pid, depart, ticket, racine, rang }),
280
271
  borneMs,
281
272
  rappelMs,
282
273
  };
@@ -467,7 +458,7 @@ export function budgetDeLaPasse(env = process.env) {
467
458
  * @returns {{ coeurs: number, memoire: number }}
468
459
  * @throws {AttenteDeLaMachine} naming the key (code 1) when its value is faulty, before any work
469
460
  */
470
- export function partDeLaPasse({ racine, env = process.env }) {
461
+ export function partDeLaPasse({ racine, env = process.env, direct = false }) {
471
462
  const { declaree, faute } = partDeclareeDe(packageDuDepot(racine));
472
463
  if (faute) {
473
464
  throw new AttenteDeLaMachine(`✗ ${faute}`, 1);
@@ -475,7 +466,7 @@ export function partDeLaPasse({ racine, env = process.env }) {
475
466
  return partDe({
476
467
  declaree,
477
468
  budget: budgetDeLaPasse(env),
478
- places: plafondDe(env),
469
+ ...(direct ? { direct } : {}),
479
470
  pic: plusGrandPicDeJour(racineDuDepot(racine)),
480
471
  });
481
472
  }
@@ -525,12 +516,12 @@ function packageDuDepot(racine) {
525
516
  * @returns {number}
526
517
  * @throws {AttenteDeLaMachine} naming the key (code 1) when its value is faulty, before any work
527
518
  */
528
- function coeursDeLaMesure({ racine, budget, env }) {
519
+ function coeursDeLaMesure({ racine, budget }) {
529
520
  const { declaree, faute } = mesureDeclareeDe(packageDuDepot(racine));
530
521
  if (faute) {
531
522
  throw new AttenteDeLaMachine(`✗ ${faute}`, 1);
532
523
  }
533
- return coeursDeLaMesureDe({ declaree, budget, places: plafondDe(env) });
524
+ return coeursDeLaMesureDe({ declaree, budget });
534
525
  }
535
526
 
536
527
  const RANGS = { 1: 'mesure du cadre', 2: "mesure d'un projet" };
@@ -539,11 +530,22 @@ const RANGS = { 1: 'mesure du cadre', 2: "mesure d'un projet" };
539
530
  const ECHELLE_DES_RANGS = 1e14;
540
531
 
541
532
  // Plays <f> holding the short lock of the admission of <dossier>, so that two passes never judge
542
- // the same free budget at once.
533
+ // the same free budget at once. The directory is made again when it goes between its making and
534
+ // the lock: another pass that gives its part back removes it while it is empty (`rendreLaPart`).
535
+ // Once the lock lies in it, it stays.
543
536
  function sousLAdmission(dossier, f) {
544
- mkdirSync(dossier, { recursive: true });
545
537
  const verrou = path.join(dossier, '.admission');
546
- prendreVerrou(verrou, { attendre: true });
538
+ for (;;) {
539
+ mkdirSync(dossier, { recursive: true });
540
+ try {
541
+ prendreVerrou(verrou, { attendre: true });
542
+ break;
543
+ } catch (e) {
544
+ if (e?.code !== 'ENOENT') {
545
+ throw e;
546
+ }
547
+ }
548
+ }
547
549
  try {
548
550
  return f();
549
551
  } finally {
@@ -569,17 +571,16 @@ export function lecteurDeLaCharge(env = process.env, systeme = chargeDesCoeursDu
569
571
  * writes on (`attendreDeLaPlace`), then the part: it is taken once it fits in what the parts held
570
572
  * leave of the budget and the load and the memory of the machine admit it, the waits of a smaller
571
573
  * rank passing first. Its state is one file of the parts (`poserLaPart`), « attend » then
572
- * « tient ». The night (VARIABLE_JETON) and a pass that asks for the <entiere> budget take the
573
- * whole budget: they play alone. A <mesure> of time takes dedicated cores (`fils`, whole physical
574
+ * « tient ». The night of a project is a pass like another, of the sort « Nuit »: it takes the part of
575
+ * its project. A <mesure> of time takes dedicated cores (`fils`, whole physical
574
576
  * cores), waits for them and for their rest (<chargeDesCoeurs>: the load of the threads it gives,
575
577
  * null without a reading, by default `lecteurDeLaCharge`; <topologie>, the topology of the system, for a trial).
576
578
  * The reservation of the machine (<lireLaReservation>, the places of the server by default) is read at each
577
579
  * turn of the wait, before the admission lock: under the supervisor's closure the pass waits without bound
578
- * (« machine fermée par le superviseur »), under the night's it waits unless it carries its jeton, within
579
- * the bound; a reading that fails stands for no reservation. Where no part is taken (the envelope of an agent, a part already
580
+ * (« machine fermée par le superviseur »); a reading that fails stands for no reservation. Where no part is taken (the envelope of an agent, a part already
580
581
  * held: GRILLHOUSE_PART_TENUE) the part returned holds nothing.
581
582
  * @param {{ env?: Record<string, string | undefined>, racine?: string, ticket?: string | null,
582
- * sorte?: string, entiere?: boolean, borneMs?: number, rappelMs?: number,
583
+ * sorte?: string, mesure?: boolean, direct?: boolean, borneMs?: number, rappelMs?: number,
583
584
  * dire?: (l: string) => void, maintenant?: () => number, dormir?: (ms: number) => void,
584
585
  * libre?: (d: string) => number, occupe?: (d: string) => string,
585
586
  * occupeLaCopie?: (r: string) => string }} [o]
@@ -595,8 +596,8 @@ export function prendreUnePart({
595
596
  racine = process.cwd(),
596
597
  ticket,
597
598
  sorte,
598
- entiere = false,
599
599
  mesure = false,
600
+ direct = false,
600
601
  topologie,
601
602
  chargeDesCoeurs = lecteurDeLaCharge(env),
602
603
  borneMs = borneDe(env),
@@ -629,7 +630,7 @@ export function prendreUnePart({
629
630
  topo = topologie ?? lireLaTopologie({ nombreDeFils: machineDe(env).coeurs });
630
631
  budgetFils = budgetEnFils({ topologie: topo, budget: budget.coeurs });
631
632
  if (mesure) {
632
- const demande = coeursDeLaMesure({ racine, budget, env });
633
+ const demande = coeursDeLaMesure({ racine, budget });
633
634
  let fils = filsDeLaMesure({ budget: budgetFils, topologie: topo, demande });
634
635
  if (fils === null || !topo.lisible) {
635
636
  // No whole core in the budget, or a topology that does not read: each thread is a core.
@@ -639,7 +640,7 @@ export function prendreUnePart({
639
640
  }
640
641
  part = { coeurs: fils, memoire: Math.floor((budget.memoire * fils) / budget.coeurs) };
641
642
  } else {
642
- part = entiere || env[VARIABLE_JETON] ? budget : partDeLaPasse({ racine, env });
643
+ part = partDeLaPasse({ racine, env, direct });
643
644
  }
644
645
  } catch (e) {
645
646
  throw e instanceof AttenteDeLaMachine ? e : new AttenteDeLaMachine(`✗ ${e.message}`, 1);
@@ -701,7 +702,6 @@ export function prendreUnePart({
701
702
  mesurer: () => machineDe(env),
702
703
  dediee: mesure,
703
704
  reservation,
704
- jeton: env[VARIABLE_JETON] ?? null,
705
705
  }
706
706
  );
707
707
  let fils = null;
@@ -794,6 +794,19 @@ export function prendreUnePart({
794
794
  GRILLHOUSE_VERIFICATION_TICKET: _ticket,
795
795
  ...enfant
796
796
  } = env;
797
+ // The reservation of the part (cores, memory, who), written at its taking and its return, so
798
+ // that the parts held at an instant are read back from the journal alone.
799
+ const reservation = {
800
+ coeurs: part.coeurs,
801
+ memoireGo: Math.round((part.memoire / 2 ** 30) * 100) / 100,
802
+ qui: [ticket, sorte].filter(Boolean).join(' ') || 'passe',
803
+ };
804
+ const tracer = evenement =>
805
+ ecrireLaTrace(
806
+ racine,
807
+ traceDesPlaces({ evenement, ticket: ticket ?? null, place: moi.id, reservation })
808
+ );
809
+ tracer('prise');
797
810
  return {
798
811
  id: moi.id,
799
812
  part,
@@ -806,7 +819,10 @@ export function prendreUnePart({
806
819
  [VARIABLE_PART_TENUE]: moi.id,
807
820
  [VARIABLE_TRAVAILLEURS]: String(part.coeurs),
808
821
  },
809
- rendre: () => rendreLaPart(dossier, moi.id),
822
+ rendre: () => {
823
+ rendreLaPart(dossier, moi.id);
824
+ tracer('rendue');
825
+ },
810
826
  raison: null,
811
827
  };
812
828
  }
@@ -894,17 +910,16 @@ function commandeDeLaFermeture(mode, env) {
894
910
 
895
911
  /**
896
912
  * Closes the machine under <env> (the supervisor's reservation of the places, `cordon` of
897
- * kubectl): its issue, `fermee`, `deja-fermee`, or `nuit-tient` when the night holds the machine.
913
+ * kubectl): its issue, `fermee` or `deja-fermee`.
898
914
  * @param {{ env?: Record<string, string | undefined> }} [o]
899
- * @returns {'fermee' | 'deja-fermee' | 'nuit-tient'}
915
+ * @returns {'fermee' | 'deja-fermee'}
900
916
  */
901
917
  export const fermerLaMachine = ({ env = process.env } = {}) => commandeDeLaFermeture('fermer', env);
902
918
 
903
919
  /**
904
- * Reopens the machine under <env>: its issue, `rouverte`, `deja-ouverte`, or `nuit-tient` (the
905
- * reopening never lifts a night's reservation).
920
+ * Reopens the machine under <env>: its issue, `rouverte` or `deja-ouverte`.
906
921
  * @param {{ env?: Record<string, string | undefined> }} [o]
907
- * @returns {'rouverte' | 'deja-ouverte' | 'nuit-tient'}
922
+ * @returns {'rouverte' | 'deja-ouverte'}
908
923
  */
909
924
  export const rouvrirLaMachine = ({ env = process.env } = {}) =>
910
925
  commandeDeLaFermeture('rouvrir', env);
@@ -960,7 +975,7 @@ function mesureDEssai(env) {
960
975
  * }} [o] `lues`, the places as the server holds them (`lirePlaces` by default); `tenues` of the
961
976
  * result gives each place taken, its ticket and the root of its project (null without one)
962
977
  * @returns {{ prises: number, tenues: { ticket: string | null, racine: string | null }[],
963
- * fermeture: { auteur: 'nuit' | 'superviseur', depuis: number, phase: string } | null,
978
+ * fermeture: { auteur: 'superviseur', depuis: number, phase: string } | null,
964
979
  * plafond: number, faute: string | null, charge: number, coeurs: number, memoireGo: number,
965
980
  * memoireTotaleGo: number, attentes: { ticket: string, depuis: number, disque?: string | null }[] }}
966
981
  * @throws {Error} naming GRILLHOUSE_MESURE_D_ESSAI when its value is faulty
@@ -972,7 +987,6 @@ export function etatDesPlaces({ env = process.env, mesurer = mesureDeLaMachine,
972
987
  faute = null,
973
988
  attentes,
974
989
  circuits = [],
975
- nuit = null,
976
990
  fermeture = null,
977
991
  } = lues ?? lirePlaces({ env });
978
992
  const m = fixee ?? mesurer();
@@ -984,7 +998,6 @@ export function etatDesPlaces({ env = process.env, mesurer = mesureDeLaMachine,
984
998
  return {
985
999
  prises: tenues.length,
986
1000
  tenues,
987
- nuit: nuit?.phase ?? null,
988
1001
  fermeture,
989
1002
  plafond,
990
1003
  faute,
@@ -22,8 +22,8 @@
22
22
  // - `rendre` gives the place <id> back (or withdraws its request), `rattacher` names the process
23
23
  // that holds it; `lire` writes the places as the board reads them (`{ plafond, faute, prises,
24
24
  // attentes }`); `fermer` and `rouvrir` close and reopen the machine (the supervisor's
25
- // reservation), and write their issue (`fermee`, `deja-fermee`, `nuit-tient`; `rouverte`,
26
- // `deja-ouverte`, `nuit-tient`).
25
+ // reservation), and write their issue (`fermee`, `deja-fermee`; `rouverte`,
26
+ // `deja-ouverte`).
27
27
  // - Each call waits DELAI_MS for the server, and is played again ESSAIS times when it fails
28
28
  // transiently. Still failing, its port open: the server is busy, said on the error stream, exit
29
29
  // 75. A port refused (no server), another failure, or a client not built: said on the error
@@ -14,8 +14,10 @@ export const PLAFOND_PAR_DEFAUT: 3;
14
14
  export const RESERVE_COEURS_PAR_DEFAUT: 4;
15
15
  /** The memory the reserve of the user keeps when nothing names another, in GB. */
16
16
  export const RESERVE_MEMOIRE_GO_PAR_DEFAUT: 4;
17
- /** The cores a default part holds at least. */
18
- export const MIN_COEURS_DE_LA_PART: 4;
17
+ /** The cores the reservation of an ordinary pass holds when its project declares none. */
18
+ export const COEURS_PAR_DEFAUT: 3;
19
+ /** The cores the reservation of a direct pass holds, fixed. */
20
+ export const COEURS_DU_DIRECT: 2;
19
21
 
20
22
  /**
21
23
  * The ceiling of the places under <env>: GRILLHOUSE_PLACES of the environment, else of the file of
@@ -41,21 +43,13 @@ export function budgetDe(
41
43
  reserve: PartDeLaPasse
42
44
  ): PartDeLaPasse;
43
45
 
44
- /** The part of a pass when its project declares none: the budget divided by the places (2 cores
45
- * at least), the largest measured peak of memory plus a quarter, never under its floor, a third of
46
- * the budget (the floor alone without a measure). */
47
- export function partParDefautDe(
48
- budget: PartDeLaPasse,
49
- places: number,
50
- pic: number | undefined
51
- ): PartDeLaPasse;
52
-
53
- /** The part of a pass: the declared one, its missing values from the default, within the budget. */
46
+ /** The reservation of a pass: the declared cores, else 3, within the budget (a direct pass: 2,
47
+ * fixed); its memory the declared one, else the default memory, within the budget. */
54
48
  export function partDe(o: {
55
49
  declaree: { coeurs?: number; memoire?: number } | null;
56
50
  budget: PartDeLaPasse;
57
- places: number;
58
51
  pic: number | undefined;
52
+ direct?: boolean;
59
53
  }): PartDeLaPasse;
60
54
 
61
55
  /** The part a project declares in `grillhouse.part` of its package.json, or the fault naming it. */
@@ -46,8 +46,12 @@ export const PLAFOND_PAR_DEFAUT = 3;
46
46
  export const RESERVE_COEURS_PAR_DEFAUT = 4;
47
47
  /** The memory the reserve of the user keeps when nothing names another, in GB. */
48
48
  export const RESERVE_MEMOIRE_GO_PAR_DEFAUT = 4;
49
- /** The cores a default part holds at least. */
50
- export const MIN_COEURS_DE_LA_PART = 4;
49
+ /** The cores the reservation of an ordinary pass holds when its project declares none. */
50
+ export const COEURS_PAR_DEFAUT = 3;
51
+ /** The cores the reservation of a direct pass holds, fixed. */
52
+ export const COEURS_DU_DIRECT = 2;
53
+ // The cores the reserve of the user leaves the passes at least; the floor of the memory.
54
+ const COEURS_LAISSES_AUX_PASSES = 4;
51
55
 
52
56
  /**
53
57
  * The ceiling of the places under <env>: GRILLHOUSE_PLACES of the environment, else of the file
@@ -121,7 +125,7 @@ export function reserveDe(env = process.env, o = {}) {
121
125
  const coeursDeLaMachine = o.coeurs ?? cpus().length;
122
126
  const parDefaut = Math.min(
123
127
  RESERVE_COEURS_PAR_DEFAUT,
124
- Math.max(0, coeursDeLaMachine - MIN_COEURS_DE_LA_PART)
128
+ Math.max(0, coeursDeLaMachine - COEURS_LAISSES_AUX_PASSES)
125
129
  );
126
130
  return {
127
131
  coeurs: entierDuPoste(env, VARIABLE_RESERVE_COEURS, parDefaut, o.lire),
@@ -155,54 +159,34 @@ export function budgetDe({ coeurs, memoireTotale }, reserve) {
155
159
  /** The margin over the largest measured peak of memory: a quarter. */
156
160
  const MARGE_DE_LA_MEMOIRE = 1.25;
157
161
 
158
- /**
159
- * The part of a pass when its project declares none, pure: the budget divided by the <places> of
160
- * the machine in cores (whole division, 2 at least, within the budget and one core at least), and
161
- * in memory the largest measured peak <pic> plus a quarter (the hard ceiling of the group kills a
162
- * pass above it, so a percentile would not do), within the budget and never under its floor, the
163
- * proportion of the cores of a part before the division (a third of the budget): the peak raises
164
- * the memory, it does not lower it; the floor alone when <pic> is absent.
165
- * @param {{ coeurs: number, memoire: number }} budget
166
- * @param {number} places
167
- * @param {number | undefined} pic the largest peak of memory of the day passes, absent unmeasured
168
- * @returns {{ coeurs: number, memoire: number }}
169
- */
170
- export function partParDefautDe(budget, places, pic) {
171
- const coeurs = Math.max(
172
- 1,
173
- Math.min(budget.coeurs, Math.max(2, Math.floor(budget.coeurs / places)))
174
- );
175
- return { coeurs, memoire: memoireParDefautDe(budget, pic) };
176
- }
177
-
178
- // The default memory, independent of the division by the places: its floor, the proportion of the
179
- // cores a part had before the division (MIN_COEURS_DE_LA_PART, or a third of the budget rounded up
180
- // when that is more), raised to the peak plus a quarter when the register measured more. A
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
164
+ // quarter (the hard ceiling of the group kills a pass above it) when the register measured more. A
181
165
  // register that holds light passes alone (the guards, a pass of 50 ms: a peak of 16 Mo) would
182
166
  // else give the next pass a ceiling its kernel kills it under, as the Vertical Pod Autoscaler
183
167
  // bounds its recommendation by a minimum (`minAllowed`).
184
168
  function memoireParDefautDe(budget, pic) {
185
169
  const coeursDAvant = Math.max(
186
170
  1,
187
- Math.min(budget.coeurs, Math.max(MIN_COEURS_DE_LA_PART, Math.ceil(budget.coeurs / 3)))
171
+ Math.min(budget.coeurs, Math.max(COEURS_LAISSES_AUX_PASSES, Math.ceil(budget.coeurs / 3)))
188
172
  );
189
173
  const plancher = Math.floor((budget.memoire * coeursDAvant) / budget.coeurs);
190
174
  return Math.min(budget.memoire, Math.max(plancher, Math.floor((pic ?? 0) * MARGE_DE_LA_MEMOIRE)));
191
175
  }
192
176
 
193
177
  /**
194
- * The part of a pass: the one its project declares (`partDeclareeDe`), its missing values from the
195
- * default part, within the budget and one core at least.
178
+ * The reservation of a pass: the cores its project declares (`partDeclareeDe`), else 3, within the
179
+ * budget and one core at least; a direct pass reserves 2 cores, fixed. Its memory is the declared
180
+ * one, else the default memory, within the budget.
196
181
  * @param {{ declaree: { coeurs?: number, memoire?: number } | null,
197
- * budget: { coeurs: number, memoire: number }, places: number, pic: number | undefined }} o
182
+ * budget: { coeurs: number, memoire: number }, pic: number | undefined, direct?: boolean }} o
198
183
  * @returns {{ coeurs: number, memoire: number }}
199
184
  */
200
- export function partDe({ declaree, budget, places, pic }) {
201
- const defaut = partParDefautDe(budget, places, pic);
202
- const coeurs = Math.max(1, Math.min(budget.coeurs, declaree?.coeurs ?? defaut.coeurs));
185
+ export function partDe({ declaree, budget, pic, direct = false }) {
186
+ const voulus = direct ? COEURS_DU_DIRECT : (declaree?.coeurs ?? COEURS_PAR_DEFAUT);
203
187
  return {
204
- coeurs,
205
- memoire: Math.min(budget.memoire, declaree?.memoire ?? defaut.memoire),
188
+ coeurs: Math.max(1, Math.min(budget.coeurs, voulus)),
189
+ memoire: Math.min(budget.memoire, declaree?.memoire ?? memoireParDefautDe(budget, pic)),
206
190
  };
207
191
  }
208
192
 
@@ -82,7 +82,7 @@ export function ecrireLePrefixe(racine, valeur) {
82
82
  return ligne;
83
83
  }
84
84
 
85
- // Run as `node prefixe-des-tickets.mjs <racine>`, the shell scripts (ticket.sh, nuit.sh) read the
85
+ // Run as `node prefixe-des-tickets.mjs <racine>`, the shell scripts (nuit.sh) read the
86
86
  // prefix by the same function: it prints the prefix, or the message of the refusal with exit 1.
87
87
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
88
88
  try {