@roomi-fields/grillhouse 0.48.0 → 0.49.0

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 (147) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +68 -0
  3. package/agents/direct.md +9 -0
  4. package/cadre/templates/projet/.github/workflows/ci.yml +6 -0
  5. package/cadre/templates/projet/.github/workflows/nuit.yml +9 -2
  6. package/cadre/templates/projet/CLAUDE.md +9 -5
  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 +40 -14
  11. package/dist/temporal/circuit/appel.d.ts +4 -1
  12. package/dist/temporal/circuit/appel.js +15 -1
  13. package/dist/temporal/circuit/appel.js.map +1 -1
  14. package/dist/temporal/circuit/client.d.ts +7 -1
  15. package/dist/temporal/circuit/client.js +54 -1
  16. package/dist/temporal/circuit/client.js.map +1 -1
  17. package/dist/temporal/circuit/commande.js +30 -57
  18. package/dist/temporal/circuit/commande.js.map +1 -1
  19. package/dist/temporal/circuit/contrat.d.ts +2 -1
  20. package/dist/temporal/circuit/contrat.js +2 -1
  21. package/dist/temporal/circuit/contrat.js.map +1 -1
  22. package/dist/temporal/circuit/deroule.js +9 -2
  23. package/dist/temporal/circuit/deroule.js.map +1 -1
  24. package/dist/temporal/file/contrat.d.ts +16 -2
  25. package/dist/temporal/file/contrat.js +27 -3
  26. package/dist/temporal/file/contrat.js.map +1 -1
  27. package/dist/temporal/file/deroule.js +4 -4
  28. package/dist/temporal/file/deroule.js.map +1 -1
  29. package/dist/temporal/nuits/activites.d.ts +1 -15
  30. package/dist/temporal/nuits/activites.js +3 -62
  31. package/dist/temporal/nuits/activites.js.map +1 -1
  32. package/dist/temporal/nuits/contrat.d.ts +3 -21
  33. package/dist/temporal/nuits/deroule.js +38 -74
  34. package/dist/temporal/nuits/deroule.js.map +1 -1
  35. package/dist/temporal/places/client.d.ts +3 -16
  36. package/dist/temporal/places/client.js +3 -26
  37. package/dist/temporal/places/client.js.map +1 -1
  38. package/dist/temporal/places/contrat.d.ts +15 -51
  39. package/dist/temporal/places/contrat.js +3 -13
  40. package/dist/temporal/places/contrat.js.map +1 -1
  41. package/dist/temporal/places/deroule.js +11 -61
  42. package/dist/temporal/places/deroule.js.map +1 -1
  43. package/dist/temporal/tickets/activites.js +4 -2
  44. package/dist/temporal/tickets/activites.js.map +1 -1
  45. package/dist/temporal/tickets/contrat.d.ts +2 -1
  46. package/docs/ARCHITECTURE.md +310 -115
  47. package/docs/CADRE.md +16 -13
  48. package/docs/INTERFACE.md +90 -25
  49. package/hooks/hooks.json +9 -0
  50. package/hooks/register.tsx +59 -5
  51. package/package.json +1 -1
  52. package/scripts/activites.mjs +271 -42
  53. package/scripts/aiguillage.mjs +4 -1
  54. package/scripts/bilan.mjs +125 -2
  55. package/scripts/circuit.mjs +233 -159
  56. package/scripts/circuits-cles.d.mts +3 -3
  57. package/scripts/circuits-cles.mjs +6 -5
  58. package/scripts/coeurs-dedies.mjs +4 -4
  59. package/scripts/commandes-composees.mjs +12 -5
  60. package/scripts/dette.d.ts +2 -1
  61. package/scripts/dette.mjs +49 -6
  62. package/scripts/direct.mjs +343 -0
  63. package/scripts/droits.mjs +19 -0
  64. package/scripts/effets.mjs +4 -4
  65. package/scripts/engendres.mjs +2 -1
  66. package/scripts/enveloppe/enveloppe.mjs +67 -13
  67. package/scripts/enveloppe/lancer.sh +14 -3
  68. package/scripts/enveloppe/paquets-du-plan.mjs +9 -0
  69. package/scripts/enveloppe/travail-de-la-copie.mjs +119 -21
  70. package/scripts/etapes.mjs +3 -3
  71. package/scripts/faits-du-circuit.mjs +12 -11
  72. package/scripts/fermeture-de-la-machine.d.mts +4 -4
  73. package/scripts/fermeture-de-la-machine.mjs +10 -20
  74. package/scripts/fichiers-nommes.mjs +27 -1
  75. package/scripts/file-des-tickets.d.mts +18 -1
  76. package/scripts/file-des-tickets.mjs +63 -15
  77. package/scripts/grillhouse-maj.mjs +13 -25
  78. package/scripts/groupe-cles.d.mts +6 -0
  79. package/scripts/groupe-cles.mjs +29 -1
  80. package/scripts/integration/file.mjs +148 -37
  81. package/scripts/jointure.d.ts +17 -3
  82. package/scripts/journal-des-etats.d.mts +16 -0
  83. package/scripts/journal-des-etats.mjs +44 -2
  84. package/scripts/journal.mjs +3 -0
  85. package/scripts/langages/c/commandes.mjs +5 -5
  86. package/scripts/langages/c/composants.mjs +13 -5
  87. package/scripts/langages/cargo/commandes.mjs +5 -6
  88. package/scripts/langages/python/commandes.mjs +5 -5
  89. package/scripts/langages/python/composants.mjs +10 -2
  90. package/scripts/langages/typescript/composants.mjs +10 -3
  91. package/scripts/langages/typescript/construire.mjs +2 -0
  92. package/scripts/langages/typescript/exemples.mjs +33 -1
  93. package/scripts/langages/typescript/index.mjs +19 -0
  94. package/scripts/langages/typescript/migrations/0.49.0-tests-equipes.mjs +32 -0
  95. package/scripts/langages/typescript/tests-de-nuit.mjs +152 -32
  96. package/scripts/langages/typescript/tests-du-poste.mjs +65 -23
  97. package/scripts/langages/typescript/titres-de-tests.mjs +11 -7
  98. package/scripts/langages/typescript/turbo-des-paquets.mjs +21 -4
  99. package/scripts/langages/typescript/verifier.mjs +3 -5
  100. package/scripts/langages/typescript/verrou-des-dependances.mjs +161 -0
  101. package/scripts/langages/typescript/vitest-config/cibles.mjs +57 -6
  102. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +11 -5
  103. package/scripts/langages/typescript/vitest.nuit.config.mjs +53 -5
  104. package/scripts/machine.mjs +1 -1
  105. package/scripts/mesure/base-de-passe.mjs +2 -1
  106. package/scripts/migrations/0.49.0-reservation-de-trois-coeurs.mjs +30 -0
  107. package/scripts/migrations.mjs +2 -0
  108. package/scripts/nuit.sh +97 -2
  109. package/scripts/paquet.mjs +16 -5
  110. package/scripts/paquets.d.ts +4 -0
  111. package/scripts/paquets.mjs +57 -0
  112. package/scripts/passe-de-la-machine.mjs +4 -7
  113. package/scripts/places-de-la-machine.mjs +55 -42
  114. package/scripts/places-du-serveur.mjs +2 -2
  115. package/scripts/plafond-de-la-machine.d.mts +7 -13
  116. package/scripts/plafond-de-la-machine.mjs +19 -35
  117. package/scripts/prefixe-des-tickets.mjs +1 -1
  118. package/scripts/references-changees.mjs +159 -0
  119. package/scripts/regles-des-places.d.mts +8 -31
  120. package/scripts/regles-des-places.mjs +14 -64
  121. package/scripts/repli-de-la-nuit.mjs +112 -0
  122. package/scripts/reponses-du-circuit.d.mts +2 -2
  123. package/scripts/reponses-du-circuit.mjs +21 -12
  124. package/scripts/reprise.mjs +27 -8
  125. package/scripts/resultats.mjs +21 -9
  126. package/scripts/seances.mjs +258 -40
  127. package/scripts/services-du-noyau.mjs +3 -0
  128. package/scripts/sous-commandes.mjs +24 -7
  129. package/scripts/superviseur.mjs +185 -39
  130. package/scripts/tableau.mjs +220 -89
  131. package/scripts/taches-du-graphe.mjs +84 -4
  132. package/scripts/ticket.mjs +345 -0
  133. package/scripts/transitions.d.mts +44 -0
  134. package/scripts/transitions.mjs +173 -13
  135. package/scripts/un-commit-par-ticket.mjs +4 -3
  136. package/scripts/verdict-de-la-nuit.mjs +47 -20
  137. package/scripts/verrou-de-fichier.mjs +2 -2
  138. package/scripts/verrous/ecriture-hors-enveloppe.mjs +86 -0
  139. package/scripts/verrous/verrou.mjs +17 -1
  140. package/skills/developpeur/SKILL.md +1 -1
  141. package/skills/direct/SKILL.md +57 -0
  142. package/skills/explorateur/SKILL.md +10 -6
  143. package/skills/pitmaster/SKILL.md +34 -14
  144. package/skills/pitmaster/references/consigne-agent.md +7 -1
  145. package/skills/relecteur/SKILL.md +8 -0
  146. package/skills/testwriter/SKILL.md +10 -0
  147. package/scripts/ticket.sh +0 -25
package/scripts/nuit.sh CHANGED
@@ -66,6 +66,16 @@
66
66
  # depended on a duration, one under load) waits for rest (`npx grillhouse pression attendre`,
67
67
  # bound 15 min) and plays once more; green then, the night goes on; à repasser again, or no rest in the bound, the night
68
68
  # ends there, « à repasser », red if the full pass is.
69
+ # - The two parts of the night: a project whose `.github/workflows/nuit.yml` plays on the label
70
+ # `pc2` leaves PC2 its night tests but those tagged @poste and the measures of time (the flow's
71
+ # tranches, `tests-de-nuit --hors-du-poste`, then `--mesures`). The night of PC3 plays the tests
72
+ # tagged @poste alone (`tests-de-nuit --du-poste`, on its part), then reads the day's flow by `gh`
73
+ # (scripts/repli-de-la-nuit.mjs): a tranche whose job has not started 60 minutes after the flow's
74
+ # hour is cancelled and played on PC3, a tranche started then interrupted plays whole again, a
75
+ # tranche finished on PC2, green or red, is never replayed; the log says which tranches played
76
+ # where. Each part keeps its verdict (scripts/verdict-de-la-nuit.mjs: `nuit/verdict` for PC3,
77
+ # `nuit/verdict-pc2`), the night is red when either is, and a red tranche opens or comments its
78
+ # night ticket.
69
79
  # - « À repasser » (exit 75): neither green nor red. The last green stays, no ticket opens,
70
80
  # the log says so; the next night plays again.
71
81
  # - The project's night script: `grillhouse.nuit` in the package.json of the commit it plays names
@@ -157,6 +167,12 @@ copie="$racine/.claude/worktrees/nuit"
157
167
  etapes=()
158
168
  taches=()
159
169
  rejeux=()
170
+ # The part of PC2 of the night (the tranches of the Nuit flow), when the project's flow plays on PC2:
171
+ # its red steps and tasks, kept apart from PC3's so that each part has its own verdict, and its exit
172
+ # code (empty when the project has no part on PC2; 75 when a tranche is still to play there).
173
+ etapes_pc2=()
174
+ taches_pc2=()
175
+ code_pc2=
160
176
  # Gets the copy ready on HEAD: detached, cleaned, its submodules set; `partages` holds the list the
161
177
  # pose fixes, which every mount gets. Prints the reason on failure.
162
178
  partages=
@@ -169,6 +185,57 @@ preparer() {
169
185
  fi
170
186
  partages=$(bash "$ici/sous-modules.sh" pose "$copie")
171
187
  }
188
+ # The part of PC2: reads the day's Nuit flow by `gh` (scripts/repli-de-la-nuit.mjs), which cancels the
189
+ # run when a tranche has not started 60 minutes after the flow's hour, then plays on PC3, whole, each
190
+ # tranche not played on PC2 (never one finished there, green or red). A tranche still running or
191
+ # waiting leaves the part of PC2 « à repasser » (75). The statement says which tranches played where.
192
+ repli() {
193
+ local depot decision ligne
194
+ code_pc2=0
195
+ if ! depot="$(cd "$racine" && gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null)" || [ -z "$depot" ]; then
196
+ echo "⏱ le repli de la nuit ne lit pas le dépôt GitHub (gh) : la part de PC2 reste à repasser."
197
+ code_pc2=75
198
+ return
199
+ fi
200
+ if ! decision="$(node "$ici/repli-de-la-nuit.mjs" "$depot" "$tranches")"; then
201
+ echo "⏱ le repli de la nuit ne lit pas le flux Nuit : la part de PC2 reste à repasser."
202
+ code_pc2=75
203
+ return
204
+ fi
205
+ local lignes rejouer= rouges_pc2= attend=
206
+ lignes="$(printf '%s' "$decision" | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const d=JSON.parse(s);const l=k=>(d[k]??[]).join(" ");process.stdout.write(["pc2","pc3","rouges","enAttente","enCours"].map(k=>k+"\t"+l(k)).join("\n")+"\n")})')"
207
+ while IFS= read -r ligne; do
208
+ case "$ligne" in
209
+ pc2$'\t'*) echo "relevé de la nuit : tranches jouées sur PC2 : ${ligne#pc2$'\t'}" ;;
210
+ pc3$'\t'*) rejouer="${ligne#pc3$'\t'}"; echo "relevé de la nuit : tranches jouées sur PC3 : ${rejouer:-aucune}" ;;
211
+ rouges$'\t'*) rouges_pc2="${ligne#rouges$'\t'}" ;;
212
+ enAttente$'\t'*|enCours$'\t'*) attend="$attend ${ligne#*$'\t'}" ;;
213
+ esac
214
+ done <<< "$lignes"
215
+ local t code
216
+ for t in $rouges_pc2; do
217
+ echo "✗ la tranche $t de la nuit est rouge sur PC2."
218
+ etapes_pc2+=("la tranche $t de la nuit sur PC2")
219
+ taches_pc2+=("la tranche $t de la nuit sur PC2")
220
+ done
221
+ for t in $rejouer; do
222
+ (cd "$copie" && monter node "$ici/commande-du-langage.mjs" tests-de-nuit --hors-du-poste --tranche "$t/$tranches")
223
+ code=$?
224
+ if [ "$code" -ne 0 ] && [ "$code" -ne 75 ]; then
225
+ echo "✗ la tranche $t, rejouée sur PC3, est rouge."
226
+ etapes_pc2+=("la tranche $t de la nuit, rejouée sur PC3")
227
+ taches_pc2+=("la tranche $t de la nuit sur PC3 (repli)")
228
+ elif [ "$code" -eq 75 ]; then
229
+ attend="$attend $t"
230
+ fi
231
+ done
232
+ if [ "${#etapes_pc2[@]}" -gt 0 ]; then
233
+ code_pc2=1
234
+ elif [ -n "${attend// /}" ]; then
235
+ echo "⏱ la part de PC2 reste à repasser : tranche(s) en cours, en attente ou à repasser :$attend."
236
+ code_pc2=75
237
+ fi
238
+ }
172
239
  # Plays the copy; its status is the night's verdict. An existing copy that does not get ready is
173
240
  # removed (scripts/retirer-copie.sh --jetable) and created again, once.
174
241
  jouer() {
@@ -297,7 +364,19 @@ process.exit(paquets(process.argv[2]).some(p => p.pkg.name === "@roomi-fields/gr
297
364
  rejeux+=("")
298
365
  fi
299
366
  fi
300
- bancs() { (cd "$copie" && monter node "$ici/commande-du-langage.mjs" tests-de-nuit); }
367
+ # A project whose Nuit flow plays on PC2 (its runner label `pc2`) leaves PC2 the night tests that
368
+ # do not need the poste: PC3 plays the tests tagged @poste alone, then the tranches PC2 did not
369
+ # play (the fallback, scripts/repli-de-la-nuit.mjs); the measures of time play on PC2.
370
+ local sur_pc2=0 tranches=
371
+ if grep -q "\bpc2\b" "$copie/.github/workflows/nuit.yml" 2>/dev/null; then
372
+ sur_pc2=1
373
+ tranches="$(sed -n 's/^ TRANCHES: *\([0-9]*\).*/\1/p' "$copie/.github/workflows/nuit.yml")"
374
+ fi
375
+ bancs() {
376
+ local args=()
377
+ [ "$sur_pc2" -eq 0 ] || args=(--du-poste)
378
+ (cd "$copie" && monter node "$ici/commande-du-langage.mjs" tests-de-nuit "${args[@]}")
379
+ }
301
380
  bancs
302
381
  code=$?
303
382
  if [ "$code" -eq 75 ]; then
@@ -321,6 +400,9 @@ process.exit(paquets(process.argv[2]).some(p => p.pkg.name === "@roomi-fields/gr
321
400
  taches+=("les bancs de temps et les tests de nuit")
322
401
  rejeux+=("")
323
402
  fi
403
+ if [ "$sur_pc2" -eq 1 ]; then
404
+ repli
405
+ fi
324
406
  if [ -n "$nuit" ] && ! monter npm --prefix "$copie" run "$nuit"; then
325
407
  echo "✗ le script de nuit du projet \`npm run $nuit\` (grillhouse.nuit) a échoué."
326
408
  etapes+=("le script de nuit du projet (npm run $nuit, grillhouse.nuit)")
@@ -341,7 +423,20 @@ verdict=$?
341
423
  (cd "$racine" && node "$ici/retirer-les-copies-finies.mjs" "$copie") >> "$journal" 2>&1 || true
342
424
  # The project's durable verdict, read by the board: green on 0, red on any other code but 75, which
343
425
  # writes nothing (the previous verdict stays).
344
- node "$ici/verdict-de-la-nuit.mjs" "$commun" "$verdict" >> "$journal" 2>&1 || true
426
+ node "$ici/verdict-de-la-nuit.mjs" "$commun" "$verdict" pc3 >> "$journal" 2>&1 || true
427
+ # The part of PC2, when the project has one: its own durable verdict, and the night's, which is red
428
+ # when either part is red and « à repasser » while a tranche of PC2 is still to play.
429
+ if [ -n "$code_pc2" ]; then
430
+ node "$ici/verdict-de-la-nuit.mjs" "$commun" "$code_pc2" pc2 >> "$journal" 2>&1 || true
431
+ if [ "$code_pc2" -eq 1 ]; then
432
+ etapes+=("${etapes_pc2[@]}")
433
+ taches+=("${taches_pc2[@]}")
434
+ for _ in "${taches_pc2[@]}"; do rejeux+=(""); done
435
+ verdict=1
436
+ elif [ "$code_pc2" -eq 75 ] && [ "$verdict" -eq 0 ]; then
437
+ verdict=75
438
+ fi
439
+ fi
345
440
 
346
441
  if [ "$verdict" -eq 75 ]; then
347
442
  echo "⏱ à repasser : ${tete:0:7} n'est ni vert ni rouge, la machine est restée chargée ; le dernier vert reste, aucun ticket, la nuit suivante rejoue." >> "$journal"
@@ -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. */