@roomi-fields/grillhouse 0.47.1 → 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 (186) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +116 -0
  3. package/agents/direct.md +9 -0
  4. package/cadre/templates/projet/.github/workflows/ci.yml +24 -38
  5. package/cadre/templates/projet/.github/workflows/machine-vierge.yml +5 -0
  6. package/cadre/templates/projet/.github/workflows/nuit.yml +14 -2
  7. package/cadre/templates/projet/CLAUDE.md +31 -10
  8. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  9. package/cadre/templates/turbo/paquets.json +3 -1
  10. package/cadre/templates/turbo/sans-paquets.json +3 -1
  11. package/charte.md +46 -13
  12. package/dist/temporal/circuit/appel.d.ts +4 -1
  13. package/dist/temporal/circuit/appel.js +15 -1
  14. package/dist/temporal/circuit/appel.js.map +1 -1
  15. package/dist/temporal/circuit/client.d.ts +7 -1
  16. package/dist/temporal/circuit/client.js +54 -1
  17. package/dist/temporal/circuit/client.js.map +1 -1
  18. package/dist/temporal/circuit/commande.js +35 -60
  19. package/dist/temporal/circuit/commande.js.map +1 -1
  20. package/dist/temporal/circuit/contrat.d.ts +2 -1
  21. package/dist/temporal/circuit/contrat.js +2 -1
  22. package/dist/temporal/circuit/contrat.js.map +1 -1
  23. package/dist/temporal/circuit/deroule.js +9 -2
  24. package/dist/temporal/circuit/deroule.js.map +1 -1
  25. package/dist/temporal/commande.js +2 -13
  26. package/dist/temporal/commande.js.map +1 -1
  27. package/dist/temporal/deroules.d.ts +1 -1
  28. package/dist/temporal/deroules.js +2 -2
  29. package/dist/temporal/deroules.js.map +1 -1
  30. package/dist/temporal/file/activites.d.ts +1 -4
  31. package/dist/temporal/file/activites.js +13 -14
  32. package/dist/temporal/file/activites.js.map +1 -1
  33. package/dist/temporal/file/contrat.d.ts +34 -91
  34. package/dist/temporal/file/contrat.js +33 -5
  35. package/dist/temporal/file/contrat.js.map +1 -1
  36. package/dist/temporal/file/deroule.d.ts +1 -9
  37. package/dist/temporal/file/deroule.js +57 -166
  38. package/dist/temporal/file/deroule.js.map +1 -1
  39. package/dist/temporal/installation.d.ts +26 -1
  40. package/dist/temporal/installation.js +111 -2
  41. package/dist/temporal/installation.js.map +1 -1
  42. package/dist/temporal/nuits/activites.d.ts +5 -10
  43. package/dist/temporal/nuits/activites.js +9 -57
  44. package/dist/temporal/nuits/activites.js.map +1 -1
  45. package/dist/temporal/nuits/choix.d.ts +15 -0
  46. package/dist/temporal/nuits/choix.js +20 -0
  47. package/dist/temporal/nuits/choix.js.map +1 -1
  48. package/dist/temporal/nuits/contrat.d.ts +11 -16
  49. package/dist/temporal/nuits/deroule.js +38 -67
  50. package/dist/temporal/nuits/deroule.js.map +1 -1
  51. package/dist/temporal/places/client.d.ts +9 -11
  52. package/dist/temporal/places/client.js +11 -19
  53. package/dist/temporal/places/client.js.map +1 -1
  54. package/dist/temporal/places/contrat.d.ts +25 -24
  55. package/dist/temporal/places/contrat.js +5 -7
  56. package/dist/temporal/places/contrat.js.map +1 -1
  57. package/dist/temporal/places/deroule.js +26 -36
  58. package/dist/temporal/places/deroule.js.map +1 -1
  59. package/dist/temporal/tickets/activites.js +4 -2
  60. package/dist/temporal/tickets/activites.js.map +1 -1
  61. package/dist/temporal/tickets/contrat.d.ts +2 -1
  62. package/docs/ARCHITECTURE.md +453 -133
  63. package/docs/CADRE.md +16 -13
  64. package/docs/INTERFACE.md +100 -25
  65. package/hooks/hooks.json +9 -0
  66. package/hooks/register.tsx +59 -5
  67. package/package.json +1 -1
  68. package/scripts/activites.mjs +319 -52
  69. package/scripts/aiguillage.mjs +5 -1
  70. package/scripts/attente-a-l-arret.mjs +2 -5
  71. package/scripts/attente-au-tour.mjs +2 -5
  72. package/scripts/bilan.mjs +125 -2
  73. package/scripts/branche-de-nuit.mjs +32 -44
  74. package/scripts/ci-de-main.mjs +215 -16
  75. package/scripts/circuit.mjs +275 -189
  76. package/scripts/circuits-cles.d.mts +3 -3
  77. package/scripts/circuits-cles.mjs +6 -5
  78. package/scripts/coeurs-dedies.mjs +4 -4
  79. package/scripts/commandes-composees.mjs +12 -5
  80. package/scripts/composition-des-langages.mjs +2 -0
  81. package/scripts/crochets.mjs +2 -2
  82. package/scripts/dette.d.ts +2 -1
  83. package/scripts/dette.mjs +49 -6
  84. package/scripts/direct.mjs +343 -0
  85. package/scripts/droits.mjs +19 -0
  86. package/scripts/effets.mjs +6 -5
  87. package/scripts/engendres.mjs +2 -1
  88. package/scripts/enveloppe/enveloppe.mjs +127 -18
  89. package/scripts/enveloppe/lancer.sh +14 -3
  90. package/scripts/enveloppe/paquets-du-plan.mjs +9 -0
  91. package/scripts/enveloppe/travail-de-la-copie.mjs +121 -21
  92. package/scripts/etapes.mjs +14 -4
  93. package/scripts/etat-du-depot.mjs +23 -0
  94. package/scripts/faits-du-circuit.mjs +24 -34
  95. package/scripts/fermeture-de-la-machine.d.mts +27 -0
  96. package/scripts/fermeture-de-la-machine.mjs +98 -0
  97. package/scripts/fichiers-nommes.mjs +27 -1
  98. package/scripts/file-des-tickets.d.mts +18 -1
  99. package/scripts/file-des-tickets.mjs +63 -15
  100. package/scripts/greffons.mjs +1 -1
  101. package/scripts/grillhouse-maj.mjs +13 -25
  102. package/scripts/groupe-cles.d.mts +6 -0
  103. package/scripts/groupe-cles.mjs +29 -1
  104. package/scripts/integration/file.mjs +162 -48
  105. package/scripts/integration/integrer.mjs +2 -0
  106. package/scripts/jointure.d.ts +22 -3
  107. package/scripts/journal-des-etats.d.mts +16 -0
  108. package/scripts/journal-des-etats.mjs +44 -2
  109. package/scripts/journal.mjs +3 -0
  110. package/scripts/langages/c/commandes.mjs +5 -5
  111. package/scripts/langages/c/composants.mjs +13 -5
  112. package/scripts/langages/c/index.mjs +2 -0
  113. package/scripts/langages/c/squelette.mjs +1 -1
  114. package/scripts/langages/cargo/commandes.mjs +5 -6
  115. package/scripts/langages/cargo/index.mjs +2 -0
  116. package/scripts/langages/python/commandes.mjs +5 -5
  117. package/scripts/langages/python/composants.mjs +10 -2
  118. package/scripts/langages/python/index.mjs +2 -0
  119. package/scripts/langages/typescript/composants.mjs +10 -3
  120. package/scripts/langages/typescript/construire.mjs +2 -0
  121. package/scripts/langages/typescript/exemples.mjs +33 -1
  122. package/scripts/langages/typescript/index.mjs +22 -0
  123. package/scripts/langages/typescript/migrations/0.49.0-tests-equipes.mjs +32 -0
  124. package/scripts/langages/typescript/module-absent.mjs +24 -0
  125. package/scripts/langages/typescript/tests-de-nuit.mjs +152 -32
  126. package/scripts/langages/typescript/tests-du-poste.mjs +65 -23
  127. package/scripts/langages/typescript/titres-de-tests.mjs +11 -7
  128. package/scripts/langages/typescript/turbo-des-paquets.mjs +40 -5
  129. package/scripts/langages/typescript/verifier.mjs +3 -5
  130. package/scripts/langages/typescript/verrou-des-dependances.mjs +161 -0
  131. package/scripts/langages/typescript/vitest-config/cibles.mjs +57 -6
  132. package/scripts/langages/typescript/vitest-config/lances.mjs +3 -1
  133. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +11 -5
  134. package/scripts/langages/typescript/vitest.nuit.config.mjs +53 -5
  135. package/scripts/langages.mjs +25 -3
  136. package/scripts/machine.mjs +103 -0
  137. package/scripts/matieres-cles.mjs +17 -0
  138. package/scripts/matieres-lues.mjs +104 -0
  139. package/scripts/mesure/base-de-passe.mjs +2 -1
  140. package/scripts/migrations/0.48.0-ci-declenchee-par-la-file.mjs +32 -0
  141. package/scripts/migrations/0.48.0-poussee-retiree.mjs +31 -0
  142. package/scripts/migrations/0.49.0-reservation-de-trois-coeurs.mjs +30 -0
  143. package/scripts/migrations.mjs +6 -0
  144. package/scripts/nuit.sh +113 -46
  145. package/scripts/paquet.mjs +16 -5
  146. package/scripts/paquets.d.ts +4 -0
  147. package/scripts/paquets.mjs +57 -0
  148. package/scripts/passe-de-la-machine.mjs +13 -14
  149. package/scripts/places-de-la-machine.mjs +120 -44
  150. package/scripts/places-du-serveur.mjs +29 -8
  151. package/scripts/plafond-de-la-machine.d.mts +7 -13
  152. package/scripts/plafond-de-la-machine.mjs +19 -35
  153. package/scripts/poussee-retiree.mjs +18 -0
  154. package/scripts/prefixe-des-tickets.mjs +1 -1
  155. package/scripts/references-changees.mjs +159 -0
  156. package/scripts/registre.d.mts +2 -2
  157. package/scripts/regles-des-places.d.mts +20 -12
  158. package/scripts/regles-des-places.mjs +27 -30
  159. package/scripts/repli-de-la-nuit.mjs +112 -0
  160. package/scripts/reponses-du-circuit.d.mts +4 -2
  161. package/scripts/reponses-du-circuit.mjs +44 -9
  162. package/scripts/reprise.mjs +27 -8
  163. package/scripts/resultats.mjs +61 -9
  164. package/scripts/seances.mjs +258 -40
  165. package/scripts/services-du-noyau.mjs +3 -0
  166. package/scripts/sous-commandes.mjs +37 -7
  167. package/scripts/superviseur.mjs +241 -88
  168. package/scripts/tableau.mjs +327 -131
  169. package/scripts/taches-du-graphe.mjs +84 -4
  170. package/scripts/ticket.mjs +345 -0
  171. package/scripts/transitions.d.mts +52 -0
  172. package/scripts/transitions.mjs +194 -16
  173. package/scripts/un-commit-par-ticket.mjs +4 -3
  174. package/scripts/verdict-de-la-nuit.mjs +47 -20
  175. package/scripts/verrou-de-fichier.mjs +2 -2
  176. package/scripts/verrous/ecriture-hors-enveloppe.mjs +86 -0
  177. package/scripts/verrous/verrou.mjs +17 -1
  178. package/skills/developpeur/SKILL.md +1 -1
  179. package/skills/direct/SKILL.md +57 -0
  180. package/skills/explorateur/SKILL.md +10 -6
  181. package/skills/pitmaster/SKILL.md +37 -14
  182. package/skills/pitmaster/references/consigne-agent.md +7 -1
  183. package/skills/relecteur/SKILL.md +11 -1
  184. package/skills/testwriter/SKILL.md +10 -0
  185. package/scripts/poussee-cles.mjs +0 -46
  186. package/scripts/ticket.sh +0 -25
@@ -14,7 +14,7 @@
14
14
  // - `commentaire` `{ ticket, texte, auteur }`: a comment at a ticket, by its author;
15
15
  // - `fiche` `{ entree }`: a line of the ticket's sheets (`<ticket>.fiches.jsonl`), dated;
16
16
  // - `decouverte` `{ role, sujet, corps, composants }`: a discovery filed closed under the ticket
17
- // (scripts/ticket.sh, label `decouverte`), then its line among the sheets (`{ id, sujet }`);
17
+ // (scripts/ticket.mjs, label `decouverte`), then its line among the sheets (`{ id, sujet }`);
18
18
  // - `registre` `{ ligne }`: a line of the register of the steps (scripts/registre.mjs);
19
19
  // - `trace` `{ ligne }`: a line of the journal of states (scripts/journal-des-etats.mjs), whose
20
20
  // failure is said once and never stops the circuit;
@@ -44,6 +44,7 @@ import { stripVTControlCharacters } from 'node:util';
44
44
  import { ecrireLeBilan } from './bilan.mjs';
45
45
  import { ecrireLaTrace } from './journal-des-etats.mjs';
46
46
  import { ecrire as ecrireAuRegistre } from './registre.mjs';
47
+ import { AUTEUR_DU_CIRCUIT } from './etapes.mjs';
47
48
 
48
49
  /** The line of HTML comment that carries the key <cle> in a text at a ticket. */
49
50
  export const marqueDeCle = cle => `<!-- grillhouse : ${cle} -->`;
@@ -62,9 +63,9 @@ export const AVEC_CLE = new Set([
62
63
  // git user.name, $USER »), each session's its role; the author of the circuit's own lines, and
63
64
  // the start of each of them at a ticket.
64
65
  export const ACTEUR = 'BEADS_ACTOR';
65
- export const AUTEUR_DU_CIRCUIT = 'circuit';
66
+ export { AUTEUR_DU_CIRCUIT };
66
67
  export const PREFIXE = 'Circuit · ';
67
- const TICKET_SH = path.join(import.meta.dirname, 'ticket.sh');
68
+ const TICKET = path.join(import.meta.dirname, 'ticket.mjs');
68
69
 
69
70
  const ok = { status: 0, stdout: '', stderr: '' };
70
71
  // A failure of a player, as bd answers one.
@@ -188,9 +189,9 @@ const JOUEURS = {
188
189
  }
189
190
  if (!id) {
190
191
  const r = spawnSync(
191
- 'bash',
192
+ process.execPath,
192
193
  [
193
- TICKET_SH,
194
+ TICKET,
194
195
  ctx.ticket,
195
196
  sujet,
196
197
  composants,
@@ -271,7 +271,8 @@ export const touchesPar = (engendres, fichiers) =>
271
271
  * Plays the command of each of <refs>, in order (`lancer`, which runs a line of the shell at the
272
272
  * root of the tree and gives the result of spawnSync), then stages every file they changed (`dansCopie`, git in the
273
273
  * tree, its strings in UTF-8). Null, or the refusal (see the header). The output of a command that
274
- * passes goes to <ecrire>.
274
+ * passes goes to <ecrire>, the standard output by default: a caller whose standard output is read
275
+ * as data gives its own (scripts/enveloppe/travail-de-la-copie.mjs).
275
276
  * @param {{ refs: { nom: string, commande: string, fichiers: string[], cadre?: boolean }[], lancer: (commande: string) => import('node:child_process').SpawnSyncReturns<string>, dansCopie: (...args: string[]) => import('node:child_process').SpawnSyncReturns<string>, ecrire?: (s: string) => void }} o
276
277
  * @returns {string | null}
277
278
  */
@@ -72,7 +72,8 @@
72
72
  // at its real path, never at a link, by that same mechanism.
73
73
  // - A worktree of the repository under an emptied directory (the home, `/tmp`) comes back
74
74
  // read-only, `.git` included; the copy's packages of the plan and the tickets base are then
75
- // written as above.
75
+ // written as above. The copy of another ticket is an optional mount (`--ro-bind-try`): its
76
+ // circuit removes it at any moment, and the session leaves without it.
76
77
  // - An envelope on the main tree is refused, so is a plan that names no package, and so is a path
77
78
  // of the plan that does not exist; when it is the name of a package of the copy, the refusal
78
79
  // gives its path.
@@ -124,18 +125,29 @@ import {
124
125
  ecrireLaListe,
125
126
  lireLaListe,
126
127
  paquetsDuLangage,
128
+ testsEtendusDeLEnveloppe,
127
129
  VARIABLE,
130
+ VARIABLE_TESTS_ETENDUS,
128
131
  } from './paquets-du-plan.mjs';
129
132
 
130
133
  export { paquetsDuLangage };
131
134
  import { cacheDesOutils, installer, versionDeLOutil } from '../aiguillage.mjs';
132
135
  import { ouvrirBase } from '../mesure/base-de-passe.mjs';
133
- import { sousNiceEtIonice, travailleursDe, VARIABLE_TENUE } from '../places-de-la-machine.mjs';
136
+ import {
137
+ partDeLaPasse,
138
+ prendreUnePart,
139
+ sousNiceEtIonice,
140
+ travailleursDe,
141
+ VARIABLE_TENUE,
142
+ } from '../places-de-la-machine.mjs';
143
+ import { commandeDuGroupe, groupeIndisponible } from '../passe-de-la-machine.mjs';
134
144
  import { donneesDe } from '../donnees-cles.mjs';
145
+ import { matieresDeclareesDe } from '../matieres-cles.mjs';
135
146
  import { outilsDe } from '../outils-cles.mjs';
136
147
 
137
- // The role that writes the package of the shared test material and the lock files of the versions.
138
- const ROLE_MATIERE = 'testwriter';
148
+ // The roles that write the package of the shared test material and the lock files of the versions:
149
+ // the testwriter, and the agent of a direct, who writes tests and code together.
150
+ const ROLES_MATIERE = ['testwriter', 'direct'];
139
151
  // The directories <sorties> of <dir>, each relative to it.
140
152
  // One that a symbolic link carries out of <dir> (a `node_modules` linked to another tree's) is
141
153
  // left out: it is not the copy's, and bwrap could not mount over it. `lien(path)` gives the text
@@ -150,6 +162,20 @@ const sortiesDe = (dir, sorties, lien = () => null) =>
150
162
  });
151
163
  })
152
164
  .map(s => path.join(dir, s));
165
+ /**
166
+ * The test material of the copy <copie>, relative to it: the packages of the shared material
167
+ * (`matieres` of the language) and the folders the project declares (`grillhouse.matieres`,
168
+ * scripts/matieres-cles.mjs). The testwriter mounts each in writing, every other role read-only.
169
+ * @param {import('../jointure.js').Composition} langage
170
+ * @param {string} copie
171
+ * @returns {string[]}
172
+ */
173
+ export function matieresDeLaCopie(langage, copie) {
174
+ return [
175
+ ...langage.matieres(copie).map(m => path.relative(copie, m.dossier)),
176
+ ...matieresDeclareesDe(copie),
177
+ ];
178
+ }
153
179
  // The packages of the copy that the plan <paquets> does not name and that are not the shared test
154
180
  // material, relative to the copy: where the envelope opens an empty own output to each run. The
155
181
  // root package is the copy's own root, treated apart.
@@ -165,8 +191,9 @@ const paquetsHorsDuPlan = (paquets, paquetsDeLaCopie, matieres) => {
165
191
  // link carries out of the copy is left out. bwrap then has a directory to mount an empty one over.
166
192
  export function preparerLesSorties({ copie, paquets, paquetsDeLaCopie, matieres, role, sorties }) {
167
193
  const dossiers = paquetsHorsDuPlan(paquets, paquetsDeLaCopie, matieres);
168
- if (role !== ROLE_MATIERE) {
169
- dossiers.push(...matieres);
194
+ if (!ROLES_MATIERE.includes(role)) {
195
+ // A declared folder of test material is no package: no run of tests writes outputs in it.
196
+ dossiers.push(...matieres.filter(m => paquetsDeLaCopie.some(p => p.dossier === m)));
170
197
  }
171
198
  if (!ecritsDuPlan(paquets, paquetsDeLaCopie).includes('.')) {
172
199
  dossiers.push('.');
@@ -242,9 +269,16 @@ const VARIABLES_DE_CHEMIN = [
242
269
  'NVM_DIR',
243
270
  'XDG_RUNTIME_DIR',
244
271
  ];
245
- // Run inside the envelope before the command: unsets each named variable whose path does not
246
- // exist there, then runs the command. `sh -c EPREUVE sh <variables…> -- <commande…>`.
272
+ // The witness that the envelope started its command: an empty file the command writes as its first
273
+ // gesture inside the envelope, in the session's working directory (`TMPDIR` there). The launcher
274
+ // (lancer.sh) removes it before the envelope and ranges it with the session's result after: a
275
+ // launch bwrap refuses, on a mount or anything else, leaves none.
276
+ export const TEMOIN_DE_DEMARRAGE = '.demarree';
277
+ // Run inside the envelope before the command: leaves the witness of its start, unsets each named
278
+ // variable whose path does not exist there, then runs the command.
279
+ // `sh -c EPREUVE sh <variables…> -- <commande…>`.
247
280
  const EPREUVE =
281
+ `[ -z "\${TMPDIR-}" ] || touch "$TMPDIR/${TEMOIN_DE_DEMARRAGE}" || :; ` +
248
282
  'while [ "$1" != -- ]; do eval "p=\\${$1-}"; ' +
249
283
  'if [ -n "$p" ] && [ ! -e "$p" ]; then unset "$1"; fi; shift; done; shift; exec "$@"';
250
284
 
@@ -278,7 +312,7 @@ export function dossierDeTravail(copie, env = process.env) {
278
312
  // Nothing else of <env> enters.
279
313
  export function environnementDeLaSeance(
280
314
  env,
281
- { cacheNpm, paquets, travail, outils = {}, donnees = {}, travailleurs }
315
+ { cacheNpm, paquets, travail, outils = {}, donnees = {}, travailleurs, testsEtendus = [] }
282
316
  ) {
283
317
  const declare = nom =>
284
318
  ENVIRONNEMENT_DECLARE.includes(nom) ||
@@ -295,6 +329,7 @@ export function environnementDeLaSeance(
295
329
  TMP: travail,
296
330
  TEMP: travail,
297
331
  [VARIABLE]: ecrireLaListe(paquets),
332
+ ...(testsEtendus.length ? { [VARIABLE_TESTS_ETENDUS]: ecrireLaListe(testsEtendus) } : {}),
298
333
  ...(travailleurs === undefined ? {} : { GRILLHOUSE_TRAVAILLEURS: String(travailleurs) }),
299
334
  };
300
335
  }
@@ -305,8 +340,15 @@ export function environnementDeLaSeance(
305
340
  * environment of the session, GRILLHOUSE_TRAVAILLEURS set to max(1, cores ÷ places) of <env>.
306
341
  * @param {{ argsBwrap: string[], commande: string[], env: Record<string, string | undefined>,
307
342
  * cacheNpm: string, paquets: string[], travail: string, outils?: Record<string, string>,
308
- * donnees?: Record<string, string> }} o
309
- * @returns {{ cmd: string, args: string[], env: Record<string, string> }}
343
+ * donnees?: Record<string, string>, part?: { coeurs: number, memoire: number },
344
+ * sonde?: () => boolean }} o
345
+ * @returns {{ cmd: string, args: string[], env: Record<string, string>, sansBorne: string | null }}
346
+ * `sansBorne`: why the session starts without a group (null when it has one)
347
+ *
348
+ * The session runs in a scope of its own (`systemd-run --user --scope`, a foreground scope that
349
+ * leaves with its process) with a hard CPU ceiling of the cores of the part of the project; the
350
+ * passes it launches play inside that ceiling. Without a part or a manager of groups, it starts as
351
+ * it is.
310
352
  */
311
353
  export function lancementDeLaSeance({
312
354
  argsBwrap,
@@ -317,16 +359,31 @@ export function lancementDeLaSeance({
317
359
  travail,
318
360
  outils,
319
361
  donnees,
362
+ part,
363
+ sonde,
364
+ testsEtendus,
320
365
  }) {
321
- return {
366
+ const seance = {
322
367
  cmd: 'bwrap',
323
368
  args: [...argsBwrap, ...commandeEprouvee(sousNiceEtIonice(commande))],
369
+ };
370
+ const sansBorne = part
371
+ ? groupeIndisponible({ env, ...(sonde ? { sonde } : {}) })
372
+ : 'aucune part du projet connue';
373
+ const lancee =
374
+ sansBorne === null
375
+ ? commandeDuGroupe({ part, cmd: seance.cmd, args: seance.args, plafond: true, memoire: false })
376
+ : seance;
377
+ return {
378
+ ...lancee,
379
+ sansBorne,
324
380
  env: environnementDeLaSeance(env, {
325
381
  cacheNpm,
326
382
  paquets,
327
383
  travail,
328
384
  outils,
329
385
  donnees,
386
+ testsEtendus,
330
387
  travailleurs: travailleursDe({ env }),
331
388
  }),
332
389
  };
@@ -554,6 +611,7 @@ export function jugerComposant({ depot, composant, paquets = [] }, fs) {
554
611
  * paquets?: string[],
555
612
  * role?: string,
556
613
  * matieres?: string[],
614
+ * testsEtendus?: string[],
557
615
  * verrous?: string[],
558
616
  * montages?: { chemin: string, source?: string, ecriture?: boolean, vide?: boolean, scelle?: boolean, lien?: string }[],
559
617
  * magasins?: string[],
@@ -571,6 +629,7 @@ export function plan(
571
629
  paquets = [],
572
630
  role,
573
631
  matieres = [],
632
+ testsEtendus = [],
574
633
  verrous = [],
575
634
  montages = [],
576
635
  magasins = [],
@@ -650,8 +709,17 @@ export function plan(
650
709
  args.push('--symlink', lien, chemin);
651
710
  }
652
711
  // A worktree that an emptied directory covers comes back read-only, before the copy is written.
712
+ // The main tree and the copy of the session are mounted as they are found; the copy of another
713
+ // ticket, which its circuit removes at any moment, is an optional mount: bwrap skips it when its
714
+ // source is gone by then, as a container skips an optional mount.
653
715
  for (const t of trees) {
654
- if (videes.some(v => inside(t, v)) && fs.existe(t)) {
716
+ if (!videes.some(v => inside(t, v))) {
717
+ continue;
718
+ }
719
+ const tenu = [trees[0], copie].some(a => path.resolve(a) === path.resolve(t));
720
+ if (!tenu) {
721
+ args.push('--ro-bind-try', t, t);
722
+ } else if (fs.existe(t)) {
655
723
  args.push('--ro-bind', t, t);
656
724
  }
657
725
  }
@@ -706,19 +774,27 @@ export function plan(
706
774
  const d = path.join(copie, e);
707
775
  args.push('--bind', d, d);
708
776
  }
777
+ // The reader packages the plan extended to their tests: the testwriter writes them (his lock
778
+ // lets only their test files through), every other role reads them.
779
+ for (const e of testsEtendus.filter(t => !ecrits.includes(t))) {
780
+ const d = path.join(copie, e);
781
+ if (fs.existe(d)) {
782
+ args.push(role === 'testwriter' ? '--bind' : '--ro-bind', d, d);
783
+ }
784
+ }
709
785
  // The lock files of the versions, which a run of the testwriter's tests brings in line with
710
786
  // the dependencies of his tests, are written by him alone.
711
787
  for (const v of verrous.map(v => path.join(copie, v))) {
712
- if (role === ROLE_MATIERE && fs.existe(v)) {
788
+ if (ROLES_MATIERE.includes(role) && fs.existe(v)) {
713
789
  args.push('--bind', v, v);
714
790
  }
715
791
  }
716
792
  }
717
793
  for (const m of matieres.map(m => path.join(copie, m))) {
718
- args.push(role === ROLE_MATIERE ? '--bind' : '--ro-bind', m, m);
794
+ args.push(ROLES_MATIERE.includes(role) ? '--bind' : '--ro-bind', m, m);
719
795
  // What a run of its tests writes goes, for a role that does not write it, to an empty
720
796
  // directory proper to the session, as Bazel writes a test's logs out of its source.
721
- if (role === ROLE_MATIERE) {
797
+ if (ROLES_MATIERE.includes(role)) {
722
798
  continue;
723
799
  }
724
800
  for (const s of sortiesDe(m, sorties.propres, fs.lien)) {
@@ -779,6 +855,8 @@ function envelopper(argv) {
779
855
  }
780
856
  const copie = path.resolve(copieArg);
781
857
  const paquets = lireLaListe(liste);
858
+ // The reader packages extended to their tests, for the testwriter alone.
859
+ const testsEtendus = role === 'testwriter' ? testsEtendusDeLEnveloppe(process.env) : [];
782
860
  // A launch from a package of a repository of workspaces sets npm's `workspace`, which
783
861
  // `npm config` refuses: the cache is the user's, whatever the workspace.
784
862
  const cacheNpm = execFileSync('npm', ['config', 'get', 'cache', '--workspaces=false'], {
@@ -807,6 +885,7 @@ function envelopper(argv) {
807
885
  montages: [copie, claude, scratchpads, cacheNpm, TEMPORAIRE, ...sessions],
808
886
  });
809
887
  donnees = donneesDe(copie);
888
+ matieresDeclareesDe(copie);
810
889
  } catch (e) {
811
890
  process.stderr.write(`⛔ ENVELOPPE REFUSÉE — ${e.message}\n`);
812
891
  return CODE_REFUS;
@@ -840,7 +919,7 @@ function envelopper(argv) {
840
919
  lienSurDisque
841
920
  );
842
921
  const langage = langageDeLaCopie(copie);
843
- const matieres = langage.matieres(copie).map(m => path.relative(copie, m.dossier));
922
+ const matieres = matieresDeLaCopie(langage, copie);
844
923
  // The outputs of the language: its stores in the home or in the main tree (the folder of git's
845
924
  // common directory), and where its tools write in the copy.
846
925
  const commun = execFileSync(
@@ -875,6 +954,7 @@ function envelopper(argv) {
875
954
  paquets,
876
955
  role,
877
956
  matieres,
957
+ testsEtendus,
878
958
  verrous: langage.manifestes.verrous,
879
959
  montages,
880
960
  magasins,
@@ -889,6 +969,25 @@ function envelopper(argv) {
889
969
  process.stderr.write(`⛔ ENVELOPPE REFUSÉE — ${refus}\n`);
890
970
  code = CODE_REFUS;
891
971
  } else {
972
+ // The session reserves its cores for its phase alone (3, a direct's 2) against the budget of
973
+ // the machine, and gives them back at its end; under a part already held, its cap is that part.
974
+ let part;
975
+ let prise = null;
976
+ try {
977
+ const direct = role === 'direct';
978
+ prise = prendreUnePart({
979
+ racine: copie,
980
+ ticket: path.basename(copie),
981
+ sorte: `séance ${role ?? ''}`.trim(),
982
+ direct,
983
+ dire: l => process.stderr.write(`${l}\n`),
984
+ });
985
+ part = prise.part ?? partDeLaPasse({ racine: copie, direct });
986
+ } catch (e) {
987
+ process.stderr.write(`⛔ ENVELOPPE REFUSÉE — ${e.message}\n`);
988
+ temporaire.fermer();
989
+ return CODE_REFUS;
990
+ }
892
991
  const lancement = lancementDeLaSeance({
893
992
  argsBwrap: args,
894
993
  commande,
@@ -898,8 +997,18 @@ function envelopper(argv) {
898
997
  travail,
899
998
  outils,
900
999
  donnees,
1000
+ part,
1001
+ testsEtendus,
901
1002
  });
902
- const r = spawnSync(lancement.cmd, lancement.args, { stdio: 'inherit', env: lancement.env });
1003
+ if (lancement.sansBorne !== null) {
1004
+ process.stderr.write(`⚠ la séance part sans borne de processeur : ${lancement.sansBorne}\n`);
1005
+ }
1006
+ let r;
1007
+ try {
1008
+ r = spawnSync(lancement.cmd, lancement.args, { stdio: 'inherit', env: lancement.env });
1009
+ } finally {
1010
+ prise.rendre();
1011
+ }
903
1012
  if (r.error) {
904
1013
  process.stderr.write(`⛔ ENVELOPPE IMPOSSIBLE — ${r.error.message}\n`);
905
1014
  }
@@ -108,6 +108,9 @@
108
108
  # launcher writes the session's exit code to `fin` in the folder of the session, which a launch
109
109
  # removes first: a launch that stops before its session leaves none, so the circuit
110
110
  # (scripts/circuit.mjs) tells a code of the session from CODE_USAGE, CODE_REFUS and CODE_COPIE.
111
+ # The command the envelope runs leaves a witness of its start in the working directory, which the
112
+ # launcher ranges beside it (`demarree`, removed first): an envelope that ends without it refused
113
+ # the launch before the session, whatever its code (scripts/seances.mjs `seanceLancee`).
111
114
  # A session its lock stopped on a write out of the plan (scripts/verrous/verrou.mjs) left the
112
115
  # reason in its working directory (`hors-plan`, removed before the session): the launcher moves
113
116
  # it to `hors-plan` in the folder of the session, which a launch removes first and the circuit reads,
@@ -183,8 +186,9 @@ fin="$rang/fin"
183
186
  resultat="$rang/resultat.json"
184
187
  hors_plan="$rang/hors-plan"
185
188
  hors_plan_fait="$rang/hors-plan.json"
189
+ demarree="$rang/demarree"
186
190
  mkdir -p "$(dirname "$copie")" "$rang"
187
- rm -f "$fin" "$resultat" "$hors_plan" "$hors_plan_fait"
191
+ rm -f "$fin" "$resultat" "$hors_plan" "$hors_plan_fait" "$demarree"
188
192
  printf '=== %s · %s · %s ===\n' "$(date -Iseconds)" "$role" "$composant" >> "$journal"
189
193
  # The temporary directory of the ticket (`ouvrirBaseDuTicket`, scripts/mesure/base-de-passe.mjs):
190
194
  # TMPDIR, TMP and TEMP of the rest of the launch and of the session, whose scratchpads and working
@@ -244,8 +248,10 @@ publie=$(cd "$copie" && node "$ici/../../bin/grillhouse.mjs" index-interfaces --
244
248
  # The session's working directory, the one the envelope gives as TMPDIR, follows them.
245
249
  travail=$(node --input-type=module -e "import { dossierDeTravail } from '$ici/enveloppe.mjs'; process.stdout.write(dossierDeTravail(process.argv[1]));" "$copie" 2>> "$journal") \
246
250
  || { rm -f "$echec"; echo "⛔ Le dossier de travail de la séance n'a pas pu se lire : voir $journal." >&2; exit "$CODE_COPIE"; }
247
- # The mark a lock leaves there when it stops the session out of the plan: none before the session.
248
- rm -f "$travail/hors-plan"
251
+ # The mark a lock leaves there when it stops the session out of the plan, and the witness the
252
+ # envelope's command leaves there at its start (`TEMOIN_DE_DEMARRAGE` of enveloppe.mjs): none before
253
+ # the session.
254
+ rm -f "$travail/hors-plan" "$travail/.demarree"
249
255
  dossier=$'\n\n'"## Ton dossier de travail"$'\n\n'"Tout fichier temporaire s'écrit dans \`$travail\`, que \`\$TMPDIR\` nomme aussi."
250
256
  construction=
251
257
  if [ -s "$echec" ]; then
@@ -288,6 +294,11 @@ else
288
294
  lancer_claude >> "$journal" 2>&1 || code=$?
289
295
  fi
290
296
  rm -f "$prompt"
297
+ # The witness that the envelope started its command goes to the circuit: a launch the envelope
298
+ # refuses before the session (a mount bwrap cannot make) leaves none.
299
+ if [ -f "$travail/.demarree" ]; then
300
+ mv "$travail/.demarree" "$demarree"
301
+ fi
291
302
  # A session its lock stopped out of the plan (scripts/verrous/verrou.mjs): its reason goes to the
292
303
  # circuit, and to the log.
293
304
  if [ -f "$travail/hors-plan" ]; then
@@ -28,6 +28,15 @@ export const lireLaListe = texte =>
28
28
  .split(path.delimiter)
29
29
  .filter(Boolean);
30
30
 
31
+ // The variable that lists, in the same form, the reader packages the circuit extended the plan to
32
+ // for their tests alone: given to the session of the testwriter only, which writes their test
33
+ // files and no other file of those packages.
34
+ export const VARIABLE_TESTS_ETENDUS = 'GRILLHOUSE_TESTS_ETENDUS';
35
+
36
+ // The directories of the reader packages extended to their tests named in <env>.
37
+ export const testsEtendusDeLEnveloppe = (env = process.env) =>
38
+ env[VARIABLE_TESTS_ETENDUS] ? lireLaListe(env[VARIABLE_TESTS_ETENDUS]) : [];
39
+
31
40
  // The packages of the plan of the envelope named in <env>, or null outside an envelope.
32
41
  export const paquetsDeLEnveloppe = (env = process.env) =>
33
42
  env[VARIABLE] ? lireLaListe(env[VARIABLE]) : null;