@roomi-fields/grillhouse 0.54.1 → 0.55.2

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 (238) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +73 -0
  3. package/cadre/templates/projet/.github/workflows/ci.yml +4 -2
  4. package/cadre/templates/projet/.github/workflows/machine-vierge.yml +5 -42
  5. package/cadre/templates/projet/CONTRIBUTING.md +0 -5
  6. package/cadre/templates/projet/README.md +0 -126
  7. package/cadre/templates/projet/_npmignore +1 -6
  8. package/cadre/templates/projet/package.json +5 -32
  9. package/cadre/templates/projet/tsconfig.json +4 -4
  10. package/cadre/templates/projet/vitest.config.cjs +3 -2
  11. package/charte/tests.md +14 -0
  12. package/dist/machine/part-par-sorte.d.ts +9 -9
  13. package/dist/machine/part-par-sorte.js +20 -24
  14. package/dist/machine/part-par-sorte.js.map +1 -1
  15. package/dist/machine/table-des-consommations.d.ts +65 -0
  16. package/dist/machine/table-des-consommations.js +94 -0
  17. package/dist/machine/table-des-consommations.js.map +1 -0
  18. package/dist/temporal/circuit/activites.d.ts +2 -0
  19. package/dist/temporal/circuit/activites.js +87 -3
  20. package/dist/temporal/circuit/activites.js.map +1 -1
  21. package/dist/temporal/circuit/client.js +9 -4
  22. package/dist/temporal/circuit/client.js.map +1 -1
  23. package/dist/temporal/circuit/contrat.d.ts +32 -4
  24. package/dist/temporal/circuit/deroule.js +54 -4
  25. package/dist/temporal/circuit/deroule.js.map +1 -1
  26. package/dist/temporal/circuit/versions.d.ts +12 -0
  27. package/dist/temporal/circuit/versions.js +22 -0
  28. package/dist/temporal/circuit/versions.js.map +1 -0
  29. package/dist/temporal/consommation/activites.d.ts +2 -0
  30. package/dist/temporal/consommation/activites.js +9 -0
  31. package/dist/temporal/consommation/activites.js.map +1 -0
  32. package/dist/temporal/consommation/actualisation.d.ts +2 -0
  33. package/dist/temporal/consommation/actualisation.js +71 -0
  34. package/dist/temporal/consommation/actualisation.js.map +1 -0
  35. package/dist/temporal/consommation/client.d.ts +12 -0
  36. package/dist/temporal/consommation/client.js +28 -0
  37. package/dist/temporal/consommation/client.js.map +1 -0
  38. package/dist/temporal/consommation/commande.d.ts +5 -0
  39. package/dist/temporal/consommation/commande.js +32 -0
  40. package/dist/temporal/consommation/commande.js.map +1 -0
  41. package/dist/temporal/consommation/contrat.d.ts +15 -0
  42. package/dist/temporal/consommation/contrat.js +13 -0
  43. package/dist/temporal/consommation/contrat.js.map +1 -0
  44. package/dist/temporal/consommation/deroule.d.ts +2 -0
  45. package/dist/temporal/consommation/deroule.js +14 -0
  46. package/dist/temporal/consommation/deroule.js.map +1 -0
  47. package/dist/temporal/deroules.d.ts +2 -1
  48. package/dist/temporal/deroules.js +3 -2
  49. package/dist/temporal/deroules.js.map +1 -1
  50. package/dist/temporal/file/contrat.d.ts +2 -0
  51. package/dist/temporal/file/deroule.js +14 -4
  52. package/dist/temporal/file/deroule.js.map +1 -1
  53. package/dist/temporal/installation.d.ts +6 -0
  54. package/dist/temporal/installation.js +15 -0
  55. package/dist/temporal/installation.js.map +1 -1
  56. package/dist/temporal/nuits/activites.d.ts +2 -1
  57. package/dist/temporal/nuits/activites.js +127 -3
  58. package/dist/temporal/nuits/activites.js.map +1 -1
  59. package/dist/temporal/nuits/client.d.ts +19 -5
  60. package/dist/temporal/nuits/client.js +33 -23
  61. package/dist/temporal/nuits/client.js.map +1 -1
  62. package/dist/temporal/nuits/commande.js +16 -11
  63. package/dist/temporal/nuits/commande.js.map +1 -1
  64. package/dist/temporal/nuits/contrat.d.ts +29 -0
  65. package/dist/temporal/nuits/contrat.js +10 -0
  66. package/dist/temporal/nuits/contrat.js.map +1 -1
  67. package/dist/temporal/nuits/deroule.d.ts +5 -0
  68. package/dist/temporal/nuits/deroule.js +18 -1
  69. package/dist/temporal/nuits/deroule.js.map +1 -1
  70. package/dist/temporal/nuits/pc2.d.ts +72 -0
  71. package/dist/temporal/nuits/pc2.js +206 -0
  72. package/dist/temporal/nuits/pc2.js.map +1 -0
  73. package/dist/temporal/places/activites.d.ts +23 -1
  74. package/dist/temporal/places/activites.js +38 -2
  75. package/dist/temporal/places/activites.js.map +1 -1
  76. package/dist/temporal/places/client.d.ts +18 -2
  77. package/dist/temporal/places/client.js +28 -3
  78. package/dist/temporal/places/client.js.map +1 -1
  79. package/dist/temporal/places/contrat.d.ts +79 -14
  80. package/dist/temporal/places/contrat.js +7 -0
  81. package/dist/temporal/places/contrat.js.map +1 -1
  82. package/dist/temporal/places/deroule.js +159 -23
  83. package/dist/temporal/places/deroule.js.map +1 -1
  84. package/dist/temporal/places/reservation.d.ts +54 -0
  85. package/dist/temporal/places/reservation.js +69 -0
  86. package/dist/temporal/places/reservation.js.map +1 -0
  87. package/dist/temporal/planification.d.ts +6 -0
  88. package/dist/temporal/planification.js +26 -0
  89. package/dist/temporal/planification.js.map +1 -0
  90. package/dist/temporal/tickets/activites.d.ts +0 -2
  91. package/dist/temporal/tickets/activites.js +2 -52
  92. package/dist/temporal/tickets/activites.js.map +1 -1
  93. package/dist/temporal/tickets/contrat.d.ts +7 -26
  94. package/dist/temporal/tickets/deroule.js +35 -23
  95. package/dist/temporal/tickets/deroule.js.map +1 -1
  96. package/dist/temporal/travailleur.js +2 -0
  97. package/dist/temporal/travailleur.js.map +1 -1
  98. package/docs/ARCHITECTURE.md +2 -2
  99. package/docs/CADRE.md +1 -1
  100. package/docs/INTERFACE.md +16 -11
  101. package/docs/architecture/circuit.md +62 -58
  102. package/docs/architecture/entree.md +87 -63
  103. package/docs/architecture/greffon.md +24 -21
  104. package/docs/architecture/installation.md +35 -30
  105. package/docs/architecture/machine.md +48 -40
  106. package/docs/architecture/tests.md +37 -33
  107. package/docs/lexique.md +4 -3
  108. package/package.json +1 -1
  109. package/scripts/activites.mjs +351 -180
  110. package/scripts/aiguillage.mjs +1 -0
  111. package/scripts/attente-de-la-machine.mjs +3 -22
  112. package/scripts/avancement.mjs +21 -30
  113. package/scripts/bilan.mjs +22 -2
  114. package/scripts/branche-de-nuit.mjs +1 -1
  115. package/scripts/circuit.mjs +75 -39
  116. package/scripts/codes-de-sortie.mjs +0 -6
  117. package/scripts/coeurs-dedies.mjs +19 -2
  118. package/scripts/consommation-des-passes.mjs +67 -35
  119. package/scripts/consommation.mjs +152 -24
  120. package/scripts/copies-finies.mjs +15 -35
  121. package/scripts/dernier-vert.mjs +4 -5
  122. package/scripts/dette.mjs +5 -3
  123. package/scripts/droits.mjs +2 -2
  124. package/scripts/echantillonneur-de-la-passe.mjs +7 -31
  125. package/scripts/engendres.mjs +5 -61
  126. package/scripts/enveloppe/enveloppe.mjs +30 -34
  127. package/scripts/enveloppe/travail-de-la-copie.mjs +5 -0
  128. package/scripts/etapes.mjs +21 -7
  129. package/scripts/etat-du-depot.mjs +61 -0
  130. package/scripts/faits-du-circuit.mjs +7 -4
  131. package/scripts/fermeture-de-la-machine.d.mts +6 -4
  132. package/scripts/fermeture-de-la-machine.mjs +12 -16
  133. package/scripts/fichier-du-poste.d.mts +9 -0
  134. package/scripts/file-des-tickets.d.mts +0 -18
  135. package/scripts/file-des-tickets.mjs +0 -42
  136. package/scripts/fusion-du-changelog.mjs +1 -1
  137. package/scripts/grillhouse-maj.mjs +1 -1
  138. package/scripts/index-des-rouges.d.mts +40 -0
  139. package/scripts/index-des-rouges.mjs +104 -0
  140. package/scripts/integration/file.mjs +13 -63
  141. package/scripts/integration/integrer.mjs +157 -424
  142. package/scripts/integration/jugement.mjs +109 -0
  143. package/scripts/integration/rejeu.mjs +94 -71
  144. package/scripts/jointure.d.ts +34 -27
  145. package/scripts/journal-des-etats.d.mts +1 -1
  146. package/scripts/langages/c/commandes.mjs +27 -12
  147. package/scripts/langages/cargo/commandes.mjs +148 -94
  148. package/scripts/langages/cargo/index.mjs +2 -1
  149. package/scripts/langages/cargo/lectures-des-tests.mjs +132 -0
  150. package/scripts/langages/cargo/migrations/lectures-des-tests.mjs +31 -0
  151. package/scripts/langages/python/commandes.mjs +31 -15
  152. package/scripts/langages/python/index.mjs +2 -1
  153. package/scripts/langages/python/lectures-des-tests.mjs +148 -0
  154. package/scripts/langages/python/migrations/lectures-des-tests.mjs +31 -0
  155. package/scripts/langages/typescript/consommateurs-arbitres.mjs +2 -2
  156. package/scripts/langages/typescript/index.mjs +4 -0
  157. package/scripts/langages/typescript/lectures-des-tests.mjs +95 -0
  158. package/scripts/langages/typescript/migrations/lectures-des-tests.mjs +31 -0
  159. package/scripts/langages/typescript/tests-de-nuit.mjs +9 -15
  160. package/scripts/langages/typescript/tests.mjs +11 -37
  161. package/scripts/langages/typescript/titres-de-tests.mjs +5 -4
  162. package/scripts/langages/typescript/verifier.mjs +74 -44
  163. package/scripts/langages/typescript/vitest-config/base.mjs +3 -3
  164. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +6 -25
  165. package/scripts/lectures-communes.mjs +234 -0
  166. package/scripts/machine.mjs +11 -18
  167. package/scripts/mesure/base-de-passe.mjs +1 -2
  168. package/scripts/mesure-de-la-machine.d.mts +43 -3
  169. package/scripts/mesure-de-la-machine.mjs +209 -11
  170. package/scripts/migrations/0.33.0-ci-du-cadre.mjs +3 -3
  171. package/scripts/migrations/nuit-yml-retire.mjs +25 -0
  172. package/scripts/migrations/part-retiree.mjs +31 -0
  173. package/scripts/migrations/table-des-consommations.mjs +36 -0
  174. package/scripts/migrations.mjs +6 -0
  175. package/scripts/montee.mjs +9 -0
  176. package/scripts/nuit-de-pc2.mjs +628 -0
  177. package/scripts/nuit.sh +8 -131
  178. package/scripts/paquets.mjs +1 -1
  179. package/scripts/passe-de-la-machine.mjs +365 -105
  180. package/scripts/place-du-circuit.d.mts +15 -0
  181. package/scripts/place-du-circuit.mjs +32 -0
  182. package/scripts/places-de-la-machine.mjs +148 -627
  183. package/scripts/places-du-serveur.mjs +43 -16
  184. package/scripts/plafond-de-la-machine.d.mts +8 -13
  185. package/scripts/plafond-de-la-machine.mjs +37 -69
  186. package/scripts/registre-des-entrees.mjs +57 -0
  187. package/scripts/regles-des-places.d.mts +84 -50
  188. package/scripts/regles-des-places.mjs +200 -156
  189. package/scripts/retirer-copie.sh +2 -2
  190. package/scripts/seances.mjs +181 -63
  191. package/scripts/secours.mjs +95 -0
  192. package/scripts/services-du-noyau.mjs +11 -19
  193. package/scripts/sous-commandes.mjs +1 -0
  194. package/scripts/sous-modules.sh +1 -1
  195. package/scripts/superviseur.mjs +16 -7
  196. package/scripts/table-des-consommations.d.mts +9 -0
  197. package/scripts/table-des-consommations.mjs +35 -0
  198. package/scripts/tableau.mjs +33 -19
  199. package/scripts/taches-du-graphe.mjs +124 -2
  200. package/scripts/transitions.d.mts +27 -5
  201. package/scripts/transitions.mjs +125 -104
  202. package/scripts/verdict-de-la-nuit.d.mts +13 -0
  203. package/scripts/verdict-de-la-nuit.mjs +34 -7
  204. package/scripts/verrou-de-fichier.mjs +1 -2
  205. package/scripts/workflows-du-cadre.mjs +2 -2
  206. package/skills/developpeur/SKILL.md +8 -2
  207. package/skills/direct/SKILL.md +5 -0
  208. package/skills/explorateur/SKILL.md +10 -1
  209. package/skills/grill/SKILL.md +2 -4
  210. package/skills/pitmaster/SKILL.md +7 -5
  211. package/skills/pitmaster/references/consigne-agent.md +1 -1
  212. package/skills/relecteur/SKILL.md +4 -1
  213. package/skills/testwriter/SKILL.md +15 -2
  214. package/cadre/templates/projet/.env.example +0 -57
  215. package/cadre/templates/projet/.github/workflows/nuit.yml +0 -139
  216. package/cadre/templates/projet/deployment/README.md +0 -98
  217. package/cadre/templates/projet/deployment/docs/01-INSTALL.md +0 -145
  218. package/cadre/templates/projet/deployment/docs/02-CONFIGURATION.md +0 -117
  219. package/cadre/templates/projet/deployment/docs/03-API.md +0 -264
  220. package/cadre/templates/projet/deployment/docs/04-TROUBLESHOOTING.md +0 -262
  221. package/cadre/templates/projet/deployment/scripts/install.ps1 +0 -100
  222. package/cadre/templates/projet/deployment/scripts/start.ps1 +0 -61
  223. package/cadre/templates/projet/deployment/scripts/stop.ps1 +0 -37
  224. package/cadre/templates/projet/deployment/scripts/test.ps1 +0 -118
  225. package/cadre/templates/projet/ecosystem.config.cjs +0 -73
  226. package/cadre/templates/projet/src/config.ts +0 -68
  227. package/cadre/templates/projet/src/errors.ts +0 -102
  228. package/cadre/templates/projet/src/index.ts +0 -46
  229. package/cadre/templates/projet/src/services/.gitkeep +0 -8
  230. package/cadre/templates/projet/src/types/index.ts +0 -24
  231. package/cadre/templates/projet/src/utils/logger.ts +0 -106
  232. package/cadre/templates/projet/tests/unit/config.spec.ts +0 -68
  233. package/cadre/templates/projet/tests/unit/errors.spec.ts +0 -132
  234. package/cadre/templates/projet/tests/unit/types.spec.ts +0 -73
  235. package/cadre/templates/projet/tsconfig.build.json +0 -14
  236. package/scripts/flux-de-la-nuit.mjs +0 -39
  237. package/scripts/garde-de-la-memoire.mjs +0 -231
  238. package/scripts/repli-de-la-nuit.mjs +0 -184
@@ -26,27 +26,30 @@ import {
26
26
  } from 'node:fs';
27
27
  import path from 'node:path';
28
28
  import { avecLAvancementDuTravail } from './avancement.mjs';
29
- import { A_REPASSER, MEMOIRE_COUPEE } from './codes-de-sortie.mjs';
29
+ import { A_REPASSER } from './codes-de-sortie.mjs';
30
+ import { baseDuLot, commitDuLot, marquerLeLot, rendreEnTravail } from './etat-du-depot.mjs';
30
31
  import { BASE_DU_LOT, DEPUIS_LE_VERT } from './dernier-vert.mjs';
31
32
  import { empreinteDEtape } from './empreinte-d-etape.mjs';
32
33
  import { BASE as GARDES_DE_LA_BASE, FICHIER as DETTE } from './dette.mjs';
33
34
  import { optionsDuRole } from './droits.mjs';
34
35
  import { cheminsLus } from './composants-affectes.mjs';
35
- import { couvertPar } from './engendres.mjs';
36
+ import { aRejouer, couvertPar, installerEtRegenerer, touchesPar } from './engendres.mjs';
36
37
  import {
37
38
  differencesDesReferences,
38
39
  ligneDesReferences,
39
40
  texteDesDifferences,
40
41
  } from './references-changees.mjs';
41
42
  import { ecrireLaListe, VARIABLE as VARIABLE_ENVELOPPE } from './enveloppe/paquets-du-plan.mjs';
43
+ import { jugerLArbre } from './integration/jugement.mjs';
42
44
  import { inscrireLeLot, rendreLIndex } from './enveloppe/travail-de-la-copie.mjs';
43
- import { auteurDuCode, etapeDuCircuit, EXPLORATEUR, SUITE } from './etapes.mjs';
45
+ import { auteurDuCode, etapeDuCircuit, EXPLORATEUR, phaseDeLaPasse, SUITE } from './etapes.mjs';
44
46
  import { gardesDuCadre, nomsDesGardes } from './gardes-du-cadre.mjs';
45
47
  import { INTEGRE } from './integration/file.mjs';
46
- import { lotSurMain, refusLotAbsent } from './integration/integrer.mjs';
47
- import { RETIRER_COPIE } from './integration/rejeu.mjs';
48
+ import { lotSurMain, refusDuLot, refusLotAbsent } from './integration/integrer.mjs';
49
+ import { accorderLesDependances, monterDans, RETIRER_COPIE } from './integration/rejeu.mjs';
48
50
  import { AUTEUR_DU_VERDICT } from './integration/verdict.mjs';
49
51
  import { langageDe } from './langages.mjs';
52
+ import { guideDeLIndex, indexerLesRouges } from './index-des-rouges.mjs';
50
53
  import { lireLeRegistre, vertsDuRegistre } from './registre-des-resultats.mjs';
51
54
  import { AVANCEMENT } from './mesure/avancement.mjs';
52
55
  import { avecLesOutils } from './outils-cles.mjs';
@@ -67,7 +70,12 @@ import {
67
70
  VERDICTS_DU_TRI,
68
71
  VERDICTS_ROUVERTS,
69
72
  } from './resultats.mjs';
70
- import { consigne, consigneDuRelecteurDUnLotDirect, idDeSeance, jusquALaFiche } from './seances.mjs';
73
+ import {
74
+ consigne,
75
+ consigneDuRelecteurDUnLotDirect,
76
+ idDeSeance,
77
+ jusquALaFiche,
78
+ } from './seances.mjs';
71
79
  import {
72
80
  Arret,
73
81
  AUTEUR_DU_CIRCUIT,
@@ -92,7 +100,6 @@ import {
92
100
  import { emettre } from './effets.mjs';
93
101
  import { PREUVE, TRI } from './transitions.mjs';
94
102
  import { AttenteDeLaMachine } from './attente-de-la-machine.mjs';
95
- import { nommerLAvancement } from './places-de-la-machine.mjs';
96
103
 
97
104
  const ici = import.meta.dirname;
98
105
  // The sessions out of the envelope (the reviewer, the explorateur and the questionneur, all on
@@ -467,8 +474,9 @@ export function gardesDeLaBase(ctx) {
467
474
  const dehors = rel.startsWith('..') || path.isAbsolute(rel);
468
475
  const dansHead =
469
476
  !dehors &&
470
- spawnSync('git', ['-C', copie, 'cat-file', '-e', `HEAD:${rel}`], { encoding: 'utf8' })
471
- .status === 0;
477
+ spawnSync('git', ['-C', copie, 'cat-file', '-e', `${baseDuLot(copie)}:${rel}`], {
478
+ encoding: 'utf8',
479
+ }).status === 0;
472
480
  if (dehors || dansHead) {
473
481
  noms.push(path.basename(script, path.extname(script)));
474
482
  let source = '';
@@ -487,11 +495,9 @@ export function gardesDeLaBase(ctx) {
487
495
  return JSON.stringify([...new Set(noms)]);
488
496
  }
489
497
 
490
- // The copy's HEAD, the base of the lot as it stands (the tip of main of its time), or null.
491
- function laBase(ctx) {
492
- const r = spawnSync('git', ['-C', ctx.copie, 'rev-parse', 'HEAD'], { encoding: 'utf8' });
493
- return r.status === 0 ? r.stdout.trim() : null;
494
- }
498
+ // The base of the lot as it stands (the tip of main of its time): the copy's HEAD, or the parent of
499
+ // the commit of the lot (`baseDuLot`, scripts/etat-du-depot.mjs), or null.
500
+ const laBase = ctx => baseDuLot(ctx.copie);
495
501
 
496
502
  // The tree <arbre> kept as a commit on <parent> in the copy, under the circuit's author, with the
497
503
  // message <message>: its id, or null when git fails.
@@ -510,8 +516,8 @@ function unCommit(ctx, arbre, parent, message) {
510
516
  return r.status === 0 ? r.stdout.trim() : null;
511
517
  }
512
518
 
513
- // The lot of the copy kept as a commit on <parent> (a lot kept before, or HEAD), as Gerrit keeps
514
- // each patch set of a change: `{ commit, arbre, base }`, its base the copy's HEAD, or null when git
519
+ // The lot of the copy kept as a commit on <parent> (a lot kept before, or its base), as Gerrit keeps
520
+ // each patch set of a change: `{ commit, arbre, base }`, its base the base of the lot, or null when git
515
521
  // fails. Turborepo compares two of them (`--filter=...[<avant>...<après>]`, the merge base of the
516
522
  // range being the first), and the reviewer reads their difference.
517
523
  function garderLeLot(ctx, parent) {
@@ -593,19 +599,118 @@ function differenceDesLots(ctx, avant, apres) {
593
599
  return r.status === 0 ? r.stdout.split('\0').filter(Boolean).sort() : [];
594
600
  }
595
601
 
596
- // The final pass the lot calls for: `{ arbre, restreinte }`, the tree of the copy and the band
597
- // Turborepo plays (`{ avant, apres }`: the copy's HEAD, the base of the lot, and the copy kept as a
598
- // commit on it), as Bazel and Nx `affected` play the reverse-dependency closure of a change: always
599
- // the band of the lot, before any review, after one, on an accepted lot, main advanced or not,
600
- // never the whole repository, which the night and the integration play. It throws, naming git,
601
- // when git cannot keep the lot: a null band would be the whole repository.
602
+ // The final pass the lot calls for: `{ arbre, restreinte }`, the tree it judges (the commit of the
603
+ // lot's, else the copy's) and the band Turborepo plays (`{ avant, apres }`: the base of the lot, the
604
+ // tip of main, and that commit, else the copy kept as a commit on the base), as Bazel and Nx
605
+ // `affected` play the reverse-dependency closure of a change: always the band of the lot, before any
606
+ // review, after one, on an accepted lot, main advanced or not, never the whole repository, which the
607
+ // night and the queue play. It throws, naming git, when git cannot keep the lot: a null band would
608
+ // be the whole repository.
602
609
  export function laPasseFinale(ctx) {
603
- const arbre = arbreDeLaCopie(ctx);
604
- const lot = arbre ? garderLeLot(ctx, null) : null;
605
- if (!arbre || !lot) {
610
+ const commit = commitDuLot(ctx.copie);
611
+ const arbre = commit ? arbreDuCommit(ctx, commit) : arbreDeLaCopie(ctx);
612
+ const base = laBase(ctx);
613
+ const apres = commit ?? (arbre ? garderLeLot(ctx, null)?.commit : null);
614
+ if (!arbre || !base || !apres) {
606
615
  throw new Error(`la passe finale ne peut borner le lot de ${ctx.ticket} : git ne le garde pas`);
607
616
  }
608
- return { arbre, restreinte: { avant: lot.base, apres: lot.commit } };
617
+ return { arbre, restreinte: { avant: base, apres } };
618
+ }
619
+
620
+ /**
621
+ * The commit of the lot, posed on its base in the copy of the ticket before the final pass judges it
622
+ * (4.1), as bors tests the commit that will enter main: the one the circuit posed before goes back
623
+ * to local work; the references written in full that the lot touches (the project's generated files
624
+ * it still declares, `aRejouer`, then the frame's) play in the copy, the one that writes
625
+ * `package-lock.json` before `npm ci`, which installs a lot that changes the lock file or a
626
+ * manifest (`installerEtRegenerer`), and what they write enters the commit; then the commit, with
627
+ * the message of the lot built from the sheets present, its hooks included under
628
+ * GRILLHOUSE_INTEGRATION=1. Null, the commit marked (or no file to commit); else the refusal of the
629
+ * lot `{ motif, piece }`, nothing committed, the work held.
630
+ */
631
+ export function commiterLeLot(ctx) {
632
+ rendreEnTravail(ctx.copie);
633
+ const fichiers = changements(ctx).map(c => c.fichier);
634
+ if (!fichiers.length) {
635
+ return null;
636
+ }
637
+ const dans = (...a) =>
638
+ spawnSync('git', ['-C', ctx.copie, ...a], { encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 });
639
+ const refuser = motif => ({ motif, piece: fin(motif, 30) });
640
+ const branche = `agent/${ctx.ticket}`;
641
+ if (dans('symbolic-ref', '--short', '-q', 'HEAD').stdout.trim() !== branche) {
642
+ return refuser(`La copie du ticket ${ctx.copie} n'est pas sur la branche ${branche}.`);
643
+ }
644
+ const avant = garderLeLot(ctx, null);
645
+ if (!avant) {
646
+ return refuser(`git ne garde pas le lot de ${ctx.ticket} avant son commit.`);
647
+ }
648
+ entete(ctx, 'commit');
649
+ const ecrire = texte => appendFileSync(ctx.journal, texte);
650
+ const montee = monterDans(ctx.copie, ecrire);
651
+ if (montee.refus) {
652
+ return refuser(montee.refus);
653
+ }
654
+ // A refusal leaves the work as it was before the references played, unstaged.
655
+ const rendre = motif => {
656
+ restaurerLaCopie(ctx, avant.commit);
657
+ dans('reset', '-q');
658
+ ecrire(`${motif}\n`);
659
+ return refuser(motif);
660
+ };
661
+ if (dans('add', '-A').status !== 0) {
662
+ return rendre('Le lot ne se met pas à l’index de la copie.');
663
+ }
664
+ const env = environnementDeLaPasse(ctx, process.env);
665
+ const duCadre = lesReferences(ctx).filter(r => r.cadre && r.entiers.length);
666
+ const { installation, refus } = installerEtRegenerer({
667
+ refs: [
668
+ ...aRejouer(ctx.engendres ?? [], ctx.copie, fichiers).map(e => ({ ...e, cadre: false })),
669
+ ...touchesPar(duCadre, fichiers),
670
+ ],
671
+ installer: () => {
672
+ const ecrits = dans('diff', '--cached', '--name-only', '--no-renames', '-z', avant.base);
673
+ const dependances = ecrits.stdout
674
+ .split('\0')
675
+ .some(f => ['package.json', 'package-lock.json'].includes(path.posix.basename(f)));
676
+ return dependances ? accorderLesDependances(ctx.copie, montee.lancer, env) : null;
677
+ },
678
+ dansCopie: dans,
679
+ lancer: commande =>
680
+ spawnSync('bash', montee.monter('sh', '-c', commande), {
681
+ cwd: ctx.copie,
682
+ encoding: 'utf8',
683
+ maxBuffer: 256 * 1024 * 1024,
684
+ env,
685
+ }),
686
+ ecrire,
687
+ });
688
+ if (installation || refus) {
689
+ return rendre(installation ?? refus);
690
+ }
691
+ if (dans('add', '-A').status !== 0) {
692
+ return rendre('Le lot ne se met pas à l’index de la copie.');
693
+ }
694
+ if (dans('diff', '--cached', '--quiet').status === 0) {
695
+ return null;
696
+ }
697
+ const message = path.join(ctx.tmp, 'message');
698
+ writeFileSync(message, messageDeCommit(ctx));
699
+ const c = spawnSync(
700
+ 'bash',
701
+ montee.monter('git', '-C', ctx.copie, 'commit', '-q', '-F', message),
702
+ {
703
+ encoding: 'utf8',
704
+ env: { ...env, GRILLHOUSE_INTEGRATION: '1' },
705
+ }
706
+ );
707
+ if (c.status !== 0) {
708
+ dans('reset', '-q');
709
+ const motif = `Le commit du lot est refusé :\n${c.stdout}${c.stderr}`;
710
+ ecrire(`${motif}\n`);
711
+ return refuser(motif);
712
+ }
713
+ return marquerLeLot(ctx.copie) ? null : refuser('git ne marque pas le commit du lot.');
609
714
  }
610
715
 
611
716
  // The filters of Turborepo the band <restreinte> (`{ avant, apres }`, two lots kept) plays at the
@@ -688,14 +793,13 @@ export function referencesDesRouges(ctx, lieux, aElaguer = false) {
688
793
 
689
794
  // The regeneration of the references named <noms> (4.2), as make remakes a target and then the
690
795
  // targets that depend on its outputs: the copy kept as a lot on the one the last review read (or
691
- // HEAD), each command run on the whole copy, in their order; a reference that reads (`lit`) a file
796
+ // its base), each command run on the whole copy, in their order; a reference that reads (`lit`) a file
692
797
  // another one has just written runs after it, once for each reference whose writing calls for it;
693
- // then the copy kept again on that lot. `{ texte, regenerees, fichiers, restreinte }`: the report,
694
- // the names of the references changed, the files changed, and the range of the final pass that
695
- // follows (null when nothing changed: no pass plays again, and the reds stand); <suite>, the
798
+ // then the copy kept again on that lot. `{ texte, regenerees, fichiers }`: the report,
799
+ // the names of the references changed and the files changed; <suite>, the
696
800
  // regeneration the checks of the plan call for: `controles`, beside other reds, the checks of the
697
801
  // plan follow, on the regenerated tree; `passe`, without, the final pass that is due follows,
698
- // on the band of the lot; null after a final pass. A file a reference writes follows from the lot, as
802
+ // on the band of the lot; null after a final pass, which plays that whole band again. A file a reference writes follows from the lot, as
699
803
  // the output of a genrule, without a word of the plan, and the reviewer reads its difference; a
700
804
  // file changed that none of the references run declares, or a command that fails (a reference of
701
805
  // the project at another code than 0, one of the frame on a real failure alone) restores the copy
@@ -745,9 +849,11 @@ export function regenerer(
745
849
  const refus = [];
746
850
  const appelees = new Set();
747
851
  let arbre = avant.arbre;
852
+ // One execution of the step in the register: its commands are one measure.
853
+ const execution = randomUUID();
748
854
  while (aJouer.length) {
749
855
  const r = aJouer.shift();
750
- const x = commandeDeReference(ctx, r.commande);
856
+ const x = commandeDeReference(ctx, r.commande, execution);
751
857
  if (!refs.includes(r)) {
752
858
  refs.push(r);
753
859
  }
@@ -813,25 +919,18 @@ export function regenerer(
813
919
  if (!fichiers.length) {
814
920
  return {
815
921
  texte: `La régénération (${refs.map(r => `${r.nom}, \`${r.commande}\``).join(' ; ')}) ne change aucun fichier : ${
816
- suite === 'passe'
817
- ? 'la passe finale juge le lot tel quel'
818
- : suite === 'controles'
819
- ? 'les contrôles ne rejouent pas, et leurs rouges restent, chacun à son propriétaire'
820
- : 'aucune passe ne rejoue, et les rouges de la passe finale restent, chacun à son propriétaire'
922
+ suite === 'controles'
923
+ ? 'les contrôles ne rejouent pas, et leurs rouges restent, chacun à son propriétaire'
924
+ : 'la passe finale juge le lot tel quel'
821
925
  }.`,
822
926
  regenerees: [],
823
927
  fichiers,
824
- restreinte: null,
825
928
  };
826
929
  }
827
930
  return {
828
931
  texte: [
829
932
  `Les références régénérées sur la copie entière : ${regenerees.map(r => r.nom).join(', ')} ; le lot porte leurs fichiers, puis ${
830
- suite === 'controles'
831
- ? "les contrôles du plan, sur l'arbre régénéré"
832
- : suite === 'passe'
833
- ? 'la passe finale'
834
- : "la passe finale restreinte à ce qu'elles changent"
933
+ suite === 'controles' ? "les contrôles du plan, sur l'arbre régénéré" : 'la passe finale'
835
934
  }.`,
836
935
  '',
837
936
  ...regenerees.map(r => `- ${r.nom} (\`${r.commande}\`) : ${siens(r).join(', ')}`),
@@ -847,7 +946,6 @@ export function regenerer(
847
946
  ].join('\n'),
848
947
  regenerees: regenerees.map(r => r.nom),
849
948
  fichiers,
850
- restreinte: { avant: avant.commit, apres: apres.commit },
851
949
  };
852
950
  }
853
951
 
@@ -885,8 +983,9 @@ export const environnementDeLaPasse = (ctx, base, env = {}) => ({
885
983
  ...env,
886
984
  });
887
985
 
888
- // What a pass of the circuit launches: its command under its part (`lancementSousPart`: in its
889
- // control group, the workers of its tools the cores of its part), as it is where no part is held.
986
+ // What a pass of the circuit launches: its command under its reservation (`lancementSousPart`: in
987
+ // its control group, the workers of its tools the cores of its reservation), as it is where none is
988
+ // held.
890
989
  const lancerSousSaPart = ({ part, groupe, unite, fils, affinite }, cmd, args, env) =>
891
990
  part
892
991
  ? lancementSousPart({ part, cmd, args, env, groupe, unite, fils, affinite })
@@ -898,7 +997,7 @@ const lancerSousSaPart = ({ part, groupe, unite, fils, affinite }, cmd, args, en
898
997
  // 126, 127, as the shell says it; killed by a signal, the shell's 128 + its number; or the part
899
998
  // of the machine not taken), and what it wrote to the log. It runs in the environment of a pass
900
999
  // (`environnementDeLaPasse`).
901
- function commandeDeReference(ctx, commande) {
1000
+ function commandeDeReference(ctx, commande, execution) {
902
1001
  entete(ctx, 'references');
903
1002
  appendFileSync(ctx.journal, `$ ${commande}\n`);
904
1003
  const debut = statSync(ctx.journal).size;
@@ -922,6 +1021,8 @@ function commandeDeReference(ctx, commande) {
922
1021
  dire: l => appendFileSync(ctx.journal, `${l}\n`),
923
1022
  ticket: ctx.ticket,
924
1023
  sorte: etapeDuCircuit({ etape: 'references' }).titre,
1024
+ phase: phaseDeLaPasse({ etape: 'references' }),
1025
+ execution,
925
1026
  }
926
1027
  );
927
1028
  const code = r.status ?? 1;
@@ -1070,10 +1171,10 @@ export const sectionMisDeCote = fichiers =>
1070
1171
  ]
1071
1172
  : [];
1072
1173
 
1073
- // The integration of the lot: its two patches, its message and the references that write files in
1074
- // full (`--references`, from `lesReferences`, the one list), written from the copy, then
1075
- // scripts/integration/integrer.mjs from the main tree, its output added to the log. `{ code,
1076
- // sortie, args }`.
1174
+ // The integration of the lot (5.1): its final message written from the sheets, then
1175
+ // scripts/integration/integrer.mjs from the main tree on the commit the final pass judged, its output
1176
+ // added to the log. `{ code, sortie, args }`, `rejuger` (why) with no script played when the copy
1177
+ // does not hold that commit as judged (`refusDuLot`): the lot goes back to the final pass.
1077
1178
  export function integrer(ctx) {
1078
1179
  const branche = `agent/${ctx.ticket}`;
1079
1180
  const commande = `node ${INTEGRER}`;
@@ -1142,48 +1243,13 @@ export function integrer(ctx) {
1142
1243
  // is stale: the lot of the copy is committed below, the branch set on it, as a new push to a
1143
1244
  // pull request replaces the commit its merge queue holds.
1144
1245
  }
1145
- const dansCopie = (...a) =>
1146
- spawnSync('git', ['-C', ctx.copie, ...a], { encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 });
1147
- // Each file against HEAD, a new one against nothing: the index of the copy is not written.
1148
- const patch = fichiers =>
1149
- fichiers
1150
- .map(f =>
1151
- dansCopie('cat-file', '-e', `HEAD:${f}`).status === 0
1152
- ? dansCopie('diff', '--binary', 'HEAD', '--', f).stdout
1153
- : dansCopie('diff', '--no-index', '--binary', '/dev/null', f).stdout
1154
- )
1155
- .join('');
1156
- const args = ['--ticket', ctx.ticket];
1157
- for (const [option, fichiers] of [
1158
- ['--tests', tests],
1159
- ['--code', code],
1160
- ]) {
1161
- if (!fichiers.length) {
1162
- continue;
1163
- }
1164
- const f = path.join(ctx.tmp, `${option.slice(2)}.patch`);
1165
- writeFileSync(f, patch(fichiers));
1166
- args.push(option, f);
1167
- }
1168
1246
  const message = path.join(ctx.tmp, 'message');
1169
1247
  writeFileSync(message, messageDeCommit(ctx));
1170
- args.push('--message', message);
1171
- // The project's generated files, the integration reads from the main tree itself.
1172
- const entieres = lesReferences(ctx)
1173
- .filter(r => r.cadre && r.entiers.length)
1174
- .map(({ nom, commande, fichiers, lit, entiers, cadre }) => ({
1175
- nom,
1176
- commande,
1177
- fichiers,
1178
- lit,
1179
- entiers,
1180
- cadre,
1181
- }));
1182
- if (entieres.length) {
1183
- const f = path.join(ctx.tmp, 'references.json');
1184
- writeFileSync(f, `${JSON.stringify(entieres)}\n`);
1185
- args.push('--references', f);
1248
+ const rejuger = existsSync(ctx.copie) ? refusDuLot(ctx.racine, ctx.copie) : null;
1249
+ if (rejuger) {
1250
+ return finir(`${rejuger} : le lot repart à la passe finale.\n`, { code: 0, rejuger });
1186
1251
  }
1252
+ const args = ['--ticket', ctx.ticket, '--message', message];
1187
1253
  entete(ctx, 'integration');
1188
1254
  appendFileSync(ctx.journal, `$ node ${INTEGRER} ${args.join(' ')}\n`);
1189
1255
  const x = spawnSync(process.execPath, [INTEGRER, ...args], {
@@ -1402,13 +1468,16 @@ export function messageDuLot({ entete, description, fiches, references = [] }) {
1402
1468
  .concat('\n');
1403
1469
  }
1404
1470
 
1405
- // The files the copy changes against its HEAD: [{ fichier, supprime }], relative to the copy.
1406
- export function changements(ctx) {
1407
- const r = spawnSync(
1408
- 'git',
1409
- ['-C', ctx.copie, 'status', '--porcelain', '-z', '--untracked-files=all'],
1410
- { encoding: 'utf8' }
1411
- );
1471
+ // The files the lot changes against its base (`baseDuLot`: the copy's HEAD, or the parent of the
1472
+ // commit of the lot, whose files it then holds besides the local ones), those of <chemins> when
1473
+ // given: [{ fichier, supprime }], relative to the copy.
1474
+ export function changements(ctx, chemins = []) {
1475
+ const lire = (...a) =>
1476
+ spawnSync('git', ['-C', ctx.copie, ...a, ...(chemins.length ? ['--', ...chemins] : [])], {
1477
+ encoding: 'utf8',
1478
+ maxBuffer: 256 * 1024 * 1024,
1479
+ });
1480
+ const r = lire('status', '--porcelain', '-z', '--untracked-files=all');
1412
1481
  if (r.status !== 0) {
1413
1482
  return [];
1414
1483
  }
@@ -1426,7 +1495,19 @@ export function changements(ctx) {
1426
1495
  i++;
1427
1496
  }
1428
1497
  }
1429
- return out;
1498
+ if (!commitDuLot(ctx.copie)) {
1499
+ return out;
1500
+ }
1501
+ // The tracked files against the base, then the untracked ones.
1502
+ const suivis = lire('diff', '--name-status', '--no-renames', '-z', 'HEAD^').stdout.split('\0');
1503
+ const lot = new Map();
1504
+ for (let i = 0; i + 1 < suivis.length; i += 2) {
1505
+ lot.set(suivis[i + 1], suivis[i] === 'D');
1506
+ }
1507
+ for (const e of entrees.filter(e => e.startsWith('?? '))) {
1508
+ lot.set(e.slice(3), false);
1509
+ }
1510
+ return [...lot].sort().map(([fichier, supprime]) => ({ fichier, supprime }));
1430
1511
  }
1431
1512
 
1432
1513
  // Whether the testwriter writes <fichier> of the copy: the rule of a test file of the module of its
@@ -1526,17 +1607,18 @@ function paquetDe(liste, fichier) {
1526
1607
  // to a directory of its own (RESULTATS, scripts/resultats.mjs: the summaries of Turborepo, the
1527
1608
  // JSON reports of Vitest, the SARIF of the guards), its output added to the log for the human:
1528
1609
  // `{ code, dossier }`. The circuit reads its results by the verdict of the language, never its
1529
- // output; a runner without a report test by test is read there, from the log of its task. Every pass (the proof of
1530
- // the red, the checks, the final pass `npm run verifier`) takes its part of the budget of the
1531
- // machine (`avecLaPasse` of scripts/passe-de-la-machine.mjs) and plays held to it, in a control
1532
- // group of its own, its command launched by the circuit (`lancementSousPart`); it passes the mark
1533
- // of its part to the `npm run verifier` it runs, which takes none of its own; its wait is written
1534
- // to the log. A wait that stops (its bound, 75; a faulty key or reserve, 1) is the command's
1535
- // code, its message in the log and in `raison`; `attente`, a 75 that is a wait for a part or for
1536
- // room at its bound (the pass's own, or that of the `npm run verifier` it runs). Once it holds its part, the
1537
- // pass plays under a progress directory of its own (`avancement`), of the kind `genreDeLaPasse`
1538
- // names. It plays in the environment of a pass (`environnementDeLaPasse`).
1539
- function npm(ctx, etape, args, env = {}, cwd = ctx.copie) {
1610
+ // output; a runner without a report test by test is read there, from the log of its task. Every
1611
+ // pass (the proof of the red, the checks, the final pass `npm run verifier`) asks the arbiter of the
1612
+ // machine for its reservation (`avecLaPasse` of scripts/passe-de-la-machine.mjs) and plays held to
1613
+ // it, in a control group of its own, its command launched by the circuit (`lancementSousPart`); it
1614
+ // passes the mark of its reservation to the `npm run verifier` it runs, which asks none of its
1615
+ // own; its wait is written to the log. A wait that stops (its bound, 75; a faulty reserve or an
1616
+ // arbiter that does not answer, 1) is the command's code, its message in the log and in
1617
+ // `raison`; `attente`, a 75 that is a wait for a reservation or for room at its bound (the pass's
1618
+ // own, or that of the `npm run verifier` it runs). The pass plays under a progress directory of
1619
+ // its own (`avancement`), of the kind `genreDeLaPasse` names. It plays in the environment of a
1620
+ // pass (`environnementDeLaPasse`).
1621
+ function npm(ctx, etape, args, execution, env = {}, cwd = ctx.copie) {
1540
1622
  entete(ctx, etape);
1541
1623
  const dossier = mkdtempSync(path.join(ctx.base.dossier, 'resultats-'));
1542
1624
  const prefixe = Object.entries(env).map(([k, v]) => `${k}=${v} `);
@@ -1551,16 +1633,19 @@ function npm(ctx, etape, args, env = {}, cwd = ctx.copie) {
1551
1633
  ctx.tmp,
1552
1634
  { racine: ctx.copie, genre: genreDeLaPasse(ctx, etape, args) },
1553
1635
  avancement => {
1554
- const oublier = nommerLAvancement({ env: envMachine, dossier: avancement });
1555
- try {
1556
- // The pass plays on its part: in its control group, its tools on the cores of its
1557
- // part.
1636
+ // The pass plays on its part: in its control group, its tools on the cores of its
1637
+ // part.
1638
+ // `npm run verifier` is the act of judgement the queue calls too
1639
+ // (scripts/integration/jugement.mjs): 4.1 gives it its own envelope around the
1640
+ // call (its part, its control group, its progress).
1641
+ const jouer = juge => {
1558
1642
  const lancement = lancerSousSaPart(
1559
1643
  contexte,
1560
1644
  'npm',
1561
1645
  args,
1562
1646
  environnementDeLaPasse(ctx, envMachine, {
1563
1647
  ...env,
1648
+ ...juge,
1564
1649
  [RESULTATS]: dossier,
1565
1650
  [AVANCEMENT]: avancement,
1566
1651
  [GARDES_DE_LA_BASE]: gardesDeLaBase(ctx),
@@ -1582,9 +1667,17 @@ function npm(ctx, etape, args, env = {}, cwd = ctx.copie) {
1582
1667
  } finally {
1583
1668
  rendreLIndex(ctx.copie);
1584
1669
  }
1585
- } finally {
1586
- oublier();
1670
+ };
1671
+ if (args[1] !== 'verifier') {
1672
+ return jouer({});
1587
1673
  }
1674
+ return jugerLArbre({
1675
+ lancer: jouer,
1676
+ copie: ctx.copie,
1677
+ dossier,
1678
+ base: laBase(ctx),
1679
+ phase: phaseDeLaPasse({ etape, finale }),
1680
+ }).resultat;
1588
1681
  }
1589
1682
  ),
1590
1683
  {
@@ -1595,14 +1688,14 @@ function npm(ctx, etape, args, env = {}, cwd = ctx.copie) {
1595
1688
  dire: l => appendFileSync(ctx.journal, `${l}\n`),
1596
1689
  ticket: ctx.ticket,
1597
1690
  sorte: etapeDuCircuit({ etape, finale })?.titre ?? etape,
1691
+ phase: phaseDeLaPasse({ etape, finale }),
1692
+ execution,
1598
1693
  }
1599
1694
  );
1600
1695
  const code = r.status ?? 1;
1601
1696
  // The 75 of `npm run verifier` is its wait for room under /tmp at its bound,
1602
- // which waits again without counting; cut by the watch of its memory (MEMOIRE_COUPEE in its
1603
- // results), it is a replay that counts.
1604
- const coupee = existsSync(path.join(dossier, MEMOIRE_COUPEE));
1605
- return { code, dossier, attente: finale && code === A_REPASSER && !coupee };
1697
+ // which waits again without counting.
1698
+ return { code, dossier, attente: finale && code === A_REPASSER };
1606
1699
  } catch (e) {
1607
1700
  if (!(e instanceof AttenteDeLaMachine)) {
1608
1701
  throw e;
@@ -1671,15 +1764,17 @@ function mesureDeLaPreuve(ctx, liste, fichiers, derniere = null) {
1671
1764
  groupes.set(p, [...(groupes.get(p) ?? []), f]);
1672
1765
  }
1673
1766
  const runs = [];
1767
+ const execution = randomUUID();
1674
1768
  for (const [dossier, groupe] of groupes) {
1675
1769
  const entier = entiers.includes(dossier);
1676
1770
  // The files of the lot play for real (`--force`): a run replayed from Turborepo's cache, the
1677
1771
  // checks' same command on the same inputs, writes no report of Vitest.
1678
- const pass = npm(ctx, 'preuve', [
1679
- 'test',
1680
- '--',
1681
- ...(entier ? [dossier] : ['--force', ...groupe]),
1682
- ]);
1772
+ const pass = npm(
1773
+ ctx,
1774
+ 'preuve',
1775
+ ['test', '--', ...(entier ? [dossier] : ['--force', ...groupe])],
1776
+ execution
1777
+ );
1683
1778
  runs.push({
1684
1779
  groupe,
1685
1780
  entier,
@@ -2107,6 +2202,9 @@ export function rougesDe(ctx, liste, c) {
2107
2202
  if (res.tests.length === 0 && res.etat === 'failed') {
2108
2203
  out.push({
2109
2204
  texte: `test ${f} — ne se charge pas : ${premiereLigne(res.message)}`,
2205
+ message: res.message,
2206
+ cause: premiereLigne(res.message),
2207
+ estTest: true,
2110
2208
  fichier: f,
2111
2209
  ...lieu,
2112
2210
  joue: lieu.paquet,
@@ -2130,6 +2228,9 @@ export function rougesDe(ctx, liste, c) {
2130
2228
  const tus = nommes.filter(n => !premiere.includes(n));
2131
2229
  out.push({
2132
2230
  texte: `test ${f} › ${a.nom} — ${premiere}${tus.length ? ` (il nomme ${tus.join(', ')})` : ''}`,
2231
+ message: a.message,
2232
+ cause: premiere,
2233
+ estTest: true,
2133
2234
  fichier: f,
2134
2235
  nommes,
2135
2236
  ...lieu,
@@ -2215,17 +2316,49 @@ export function rougesDUnePasse({ copie, dossier, code, ticket, journal }) {
2215
2316
  .map(r => (r.detail ? `${r.texte}\n\n${r.detail}` : r.texte));
2216
2317
  }
2217
2318
 
2319
+ // The fingerprint of the whole text of the reds <textes>: two passes that read the same reds, whole,
2320
+ // give the same one; a message changed or a red gone gives another.
2321
+ const empreinteDuTexte = textes =>
2322
+ createHash('sha256').update(JSON.stringify(textes)).digest('hex');
2323
+
2324
+ // Every red of <tous> written whole into one file of the work folder of the ticket
2325
+ // (`<copie>.travail/`, which the preuve's report also sits beside): its name is the hash of its
2326
+ // content, so that a replayed act rewrites the same file and no red is written twice. Its address,
2327
+ // '' without a red. Only the agents open it; the circuit decides without it.
2328
+ function ecrireLeDetailDesRouges(ctx, tous, nomDuPaquet) {
2329
+ if (!tous.length) {
2330
+ return '';
2331
+ }
2332
+ const contenu = tous
2333
+ .map(r =>
2334
+ [
2335
+ `## ${nomDuPaquet(r)} : ${r.texte}${(r.compte ?? 1) > 1 ? ` (${r.compte} rouges)` : ''}`,
2336
+ '',
2337
+ ...(r.message && r.message !== r.texte ? [r.message, ''] : []),
2338
+ ...(r.detail ? [r.detail, ''] : []),
2339
+ ].join('\n')
2340
+ )
2341
+ .join('\n');
2342
+ const nom = `rouges-${createHash('sha256').update(contenu).digest('hex').slice(0, 16)}.md`;
2343
+ const dossier = `${ctx.copie}.travail`;
2344
+ const chemin = path.join(dossier, nom);
2345
+ mkdirSync(dossier, { recursive: true });
2346
+ if (!existsSync(chemin) || readFileSync(chemin, 'utf8') !== contenu) {
2347
+ writeFileSync(chemin, contenu);
2348
+ }
2349
+ return chemin;
2350
+ }
2351
+
2218
2352
  const ligneDeCommande = c =>
2219
2353
  `${Object.entries(c.env ?? {})
2220
2354
  .map(([k, v]) => `${k}=${v} `)
2221
2355
  .join('')}npm ${c.args.join(' ')}`;
2222
2356
 
2223
2357
  // The checks after the developpeur: those of the plan (3.1), or, when <finale>, `npm run
2224
- // verifier`, what the integration plays (4.1), restricted by <restreinte> (`{ avant, apres }`, two
2358
+ // verifier`, the final pass (4.1), restricted by <restreinte> (`{ avant, apres }`, two
2225
2359
  // lots kept) to the packages that changed from one to the other and their dependents, the readers
2226
- // of a path it changes, with the root's tasks, the guards (`filtresDeLaBande`). After a regeneration,
2227
- // <reportes> (`{ rouges, rejouee }`) carries the reds of the pass before it, the final pass or the
2228
- // checks of the plan: each one in a package the pass after the regeneration does not play again
2360
+ // of a path it changes, with the root's tasks, the guards (`filtresDeLaBande`). After a regeneration
2361
+ // for the checks of the plan, <reportes> (`{ rouges, rejouee }`) carries the reds of those checks: each one in a package the pass after the regeneration does not play again
2229
2362
  // stands, as a CI keeps the verdict of a job it does not run again; when the regeneration changes
2230
2363
  // nothing (`rejouee` false), no command plays, and they all stand. `{ rouge, aRepasser, arbitrer, auDeveloppeur,
2231
2364
  // attente, texte, complet, resume, horsTitre, lieux, tous, notes, avertissements }`: `attente` every
@@ -2246,33 +2379,24 @@ export function controles(ctx, finale, restreinte = null, reportes = null, fichi
2246
2379
  // as staged there (a file moved is a rename, its source no longer a change).
2247
2380
  rendreLIndex(ctx.copie);
2248
2381
  const liste = composantsDe(ctx.copie).filter(p => !p.hors);
2249
- // Resumed at a red in the test files <fichiers>: the final pass plays their packages alone (the
2250
- // graph of packages of Turborepo, the root's tasks beside), the checks of the plan their tests
2251
- // alone (Vitest plays what the files import) and the guards.
2252
- const duReprise = fichiers
2253
- ? [...new Set(fichiers.map(f => liste.find(p => f.startsWith(`${p.dossier}/`))?.pkg.name))]
2254
- .filter(Boolean)
2255
- .sort()
2256
- : null;
2257
- const filtres = duReprise
2258
- ? ['--', ...duReprise.map(n => `--filter=${n}`), '--filter=//']
2259
- : restreinte
2260
- ? filtresDeLaBande(ctx, liste, restreinte)
2261
- : [];
2382
+ // Resumed at a red in the test files <fichiers>: the checks of the plan play their tests alone
2383
+ // (Vitest plays what the files import) and the guards; the final pass, always the whole band.
2384
+ const filtres = restreinte ? filtresDeLaBande(ctx, liste, restreinte) : [];
2262
2385
  const commandes =
2263
2386
  reportes && !reportes.rejouee
2264
2387
  ? []
2265
2388
  : finale
2266
2389
  ? [{ args: ['run', 'verifier', ...filtres] }]
2267
2390
  : commandesDuPlan(ctx, liste, fichiers);
2391
+ const execution = randomUUID();
2268
2392
  const resultats = commandes.map(({ args, env }) => {
2269
- let r = npm(ctx, 'controles', args, env);
2393
+ let r = npm(ctx, 'controles', args, execution, env);
2270
2394
  // The 75 of verifier is final (its wait for the lock reached its bound, or the watch of its
2271
2395
  // memory cut it); a command of the
2272
2396
  // checks plays once more, the gesture `rejeu`.
2273
2397
  if (r.code === A_REPASSER && !finale) {
2274
2398
  geste(ctx, 'rejeu');
2275
- r = npm(ctx, 'controles', args, env);
2399
+ r = npm(ctx, 'controles', args, execution, env);
2276
2400
  }
2277
2401
  const c = { args, env, ...r };
2278
2402
  return { ...c, ...rougesDe(ctx, liste, c) };
@@ -2332,8 +2456,10 @@ export function controles(ctx, finale, restreinte = null, reportes = null, fichi
2332
2456
  const enEchec = resultats.filter(r => r.code !== 0 && r.code !== A_REPASSER);
2333
2457
  const a = rouges.filter(r => r.dansLePlan);
2334
2458
  const autres = rouges.filter(r => !r.dansLePlan);
2459
+ const nb = r => r.compte ?? 1;
2460
+ const somme = l => l.reduce((n, r) => n + nb(r), 0);
2335
2461
  const resume = rouges.length
2336
- ? `rouge : ${rouges.length} rouge(s) — ${
2462
+ ? `rouge : ${somme(rouges)} rouge(s) — ${
2337
2463
  commandes.length
2338
2464
  ? enEchec.map(nommer).join(' ; ')
2339
2465
  : `ceux ${finale ? "de la passe finale d'avant" : "des contrôles d'avant"}, que la régénération ne change pas`
@@ -2342,7 +2468,7 @@ export function controles(ctx, finale, restreinte = null, reportes = null, fichi
2342
2468
  ? `à repasser : ${aRepasser.map(nommer).join(' ; ')}`
2343
2469
  : `verts : ${commandes.length ? resultats.map(ligneDeCommande).join(' ; ') : finale ? "la passe finale d'avant" : "les contrôles d'avant"}${
2344
2470
  laisses.length
2345
- ? ` ; laissés à la passe finale, ${laisses.length} rouge(s) hors du plan`
2471
+ ? ` ; laissés à la passe finale, ${somme(laisses)} rouge(s) hors du plan`
2346
2472
  : ''
2347
2473
  }`;
2348
2474
  // Where the checks played: the final pass out of the envelope, on the band of the lot (its base
@@ -2351,7 +2477,6 @@ export function controles(ctx, finale, restreinte = null, reportes = null, fichi
2351
2477
  const ou = !finale
2352
2478
  ? 'Contrôles du plan, ses tests et ses paquets, ses gardes dans son enveloppe'
2353
2479
  : 'Contrôles de la passe finale, hors enveloppe, sur la bande du lot (sa base et ses dépendants)';
2354
- const ligne = r => [`- ${r.texte}`, ...(r.detail ? ['', r.detail, ''] : [])];
2355
2480
  const nomDuPaquet = r => r.paquet ?? 'hors des paquets';
2356
2481
  const journal = `Le journal du ticket, pour le détail des commandes : ${ctx.journal} (il se cite en pièce, \`${ctx.ticket}.log:<ligne>\`)`;
2357
2482
  // The warnings and notes of the guards, apart from the reds: shown, given to no one to correct.
@@ -2363,18 +2488,45 @@ export function controles(ctx, finale, restreinte = null, reportes = null, fichi
2363
2488
  '',
2364
2489
  ]
2365
2490
  : [];
2491
+ // The reds as an index (scripts/index-des-rouges.mjs): the circuit carries it, the detail of each
2492
+ // red, whole, lies in a file of the work folder of the ticket, which the agents alone open.
2493
+ const proprietaire = r => (r.dansLePlan ? 'developpeur' : 'superviseur');
2494
+ const pourLIndex = l =>
2495
+ l.map(r => ({
2496
+ paquet: nomDuPaquet(r),
2497
+ fichier: r.fichier ?? null,
2498
+ message: r.cause ?? r.texte,
2499
+ proprietaire: proprietaire(r),
2500
+ dansLePlan: Boolean(r.dansLePlan),
2501
+ test: Boolean(r.estTest),
2502
+ compte: nb(r),
2503
+ }));
2504
+ const detail = ecrireLeDetailDesRouges(ctx, tous, nomDuPaquet);
2505
+ const index = indexerLesRouges(pourLIndex(rouges), { detail });
2506
+ const empreinte = empreinteDuTexte(
2507
+ rouges.map(r => [nomDuPaquet(r), r.texte, r.message ?? '', r.detail ?? '', nb(r)])
2508
+ );
2509
+ const guide = guideDeLIndex(index, detail);
2510
+ const entreesDuPlan = index.entrees.filter(e => e.dansLePlan);
2511
+ const indexDesLaisses = indexerLesRouges(pourLIndex(laisses), { detail });
2366
2512
  const texte = [
2367
2513
  `${ou} : ${resume}.`,
2368
2514
  '',
2369
- ...(a.length ? [`Tes rouges (${a.length}) :`, ...a.flatMap(ligne), ''] : []),
2515
+ ...(a.length
2516
+ ? [`Tes rouges (${somme(a)}) :`, guide, ...entreesDuPlan.map(e => e.texte), '']
2517
+ : []),
2370
2518
  ...(aRepasser.length && !rouges.length
2371
2519
  ? [`À repasser (${aRepasser.length}) : ${aRepasser.map(nommer).join(' ; ')}`, '']
2372
2520
  : []),
2373
2521
  ...(autres.length
2374
- ? [`Les autres rouges (${autres.length}), hors du plan, montent au superviseur.`, '']
2522
+ ? [`Les autres rouges (${somme(autres)}), hors du plan, montent au superviseur.`, '']
2375
2523
  : []),
2376
2524
  ...(laisses.length && !finale
2377
- ? [`Laissés à la passe finale (${laisses.length}) :`, ...laisses.map(r => `- ${r.texte}`), '']
2525
+ ? [
2526
+ `Laissés à la passe finale (${somme(laisses)}) :`,
2527
+ ...indexDesLaisses.entrees.map(e => e.texte),
2528
+ '',
2529
+ ]
2378
2530
  : []),
2379
2531
  journal,
2380
2532
  ].join('\n');
@@ -2383,15 +2535,44 @@ export function controles(ctx, finale, restreinte = null, reportes = null, fichi
2383
2535
  `${ou} : ${resume}.`,
2384
2536
  '',
2385
2537
  ...(rouges.length
2386
- ? [
2387
- `Les rouges (${rouges.length}) :`,
2388
- ...rouges.flatMap(r => ligne({ ...r, texte: `${nomDuPaquet(r)} : ${r.texte}` })),
2389
- '',
2390
- ]
2538
+ ? [`Les rouges (${somme(rouges)}) :`, guide, ...index.entrees.map(e => e.texte), '']
2391
2539
  : []),
2392
2540
  ...avertissements,
2393
2541
  journal,
2394
2542
  ].join('\n');
2543
+ // The places of the reds, each once: the decisions read the file, the guards and the owner.
2544
+ const lieux = [...new Map(rouges.map(r => [JSON.stringify(lieu(r)), lieu(r)])).values()];
2545
+ // Every red as it was read, one per place, with its count: the reports of a regeneration keep
2546
+ // them, and the decisions that extend the plan read their place.
2547
+ const cleDeLieu = r =>
2548
+ JSON.stringify([
2549
+ r.joue,
2550
+ r.paquet ?? null,
2551
+ r.fichier ?? null,
2552
+ r.lecteur ?? null,
2553
+ r.ecarte ?? null,
2554
+ r.horsTitre ?? null,
2555
+ Boolean(r.dansLePlan),
2556
+ Boolean(r.arbitrer),
2557
+ Boolean(r.estTest),
2558
+ Boolean(r.sansResultat),
2559
+ r.gardes ?? [],
2560
+ r.nommes ?? [],
2561
+ ]);
2562
+ const groupes = new Map();
2563
+ for (const r of tous) {
2564
+ const g = groupes.get(cleDeLieu(r));
2565
+ if (g) {
2566
+ g.compte += nb(r);
2567
+ } else {
2568
+ const reste = { ...r, compte: nb(r) };
2569
+ delete reste.message;
2570
+ delete reste.cause;
2571
+ delete reste.detail;
2572
+ groupes.set(cleDeLieu(r), reste);
2573
+ }
2574
+ }
2575
+ const tousBornes = [...groupes.values()];
2395
2576
  return {
2396
2577
  rouge: rouges.length > 0,
2397
2578
  aRepasser: aRepasser.length > 0,
@@ -2405,7 +2586,10 @@ export function controles(ctx, finale, restreinte = null, reportes = null, fichi
2405
2586
  avertissements: avertissements.length ? `\n\n${avertissements.join('\n').trimEnd()}` : '',
2406
2587
  // The reds of the stop, each with where it lies: the plan's, or at the final pass all of them;
2407
2588
  // never those left to the final pass.
2408
- rouges: rouges.map(r => ({ paquet: nomDuPaquet(r), texte: r.texte, detail: r.detail })),
2589
+ rouges: index.entrees.map(e => ({ paquet: e.paquet, texte: e.texte })),
2590
+ index,
2591
+ empreinte: rouges.length ? empreinte : '',
2592
+ detail,
2409
2593
  resume,
2410
2594
  horsTitre: [...new Set(rouges.map(r => r.horsTitre).filter(Boolean))].sort(),
2411
2595
  // The directories of the components the plan set apart that hold a red: the plan extends to them.
@@ -2413,9 +2597,9 @@ export function controles(ctx, finale, restreinte = null, reportes = null, fichi
2413
2597
  // The directories of the reader packages whose reds all lie in test files: the plan extends to
2414
2598
  // those tests, and not to the packages.
2415
2599
  testsLecteurs,
2416
- lieux: rouges.map(lieu),
2600
+ lieux,
2417
2601
  references,
2418
- tous,
2602
+ tous: tousBornes,
2419
2603
  notes: resultats.flatMap(r =>
2420
2604
  lireSarif(r.dossier)
2421
2605
  .constats.filter(estNoteDeDette)
@@ -2522,42 +2706,29 @@ export function sansTests(ctx) {
2522
2706
  return !liste.some(p => ctx.paquets.some(c => touche(c, p.dossier)) && joueDesTests(racine, p));
2523
2707
  }
2524
2708
 
2525
- // Whether the copy holds a change of the plan against its HEAD.
2709
+ // Whether the lot holds a change of the plan against its base.
2526
2710
  export function livre(ctx) {
2527
- const r = spawnSync(
2528
- 'git',
2529
- ['-C', ctx.copie, 'status', '--porcelain', '--untracked-files=all', '--', ...ctx.paquets],
2530
- { encoding: 'utf8' }
2531
- );
2532
- return String(r.stdout ?? '').trim() !== '';
2711
+ return changements(ctx, ctx.paquets).length > 0;
2533
2712
  }
2534
2713
 
2535
- // The fingerprint of the files of <chemins> in the copy (the plan by default): `git status
2536
- // --porcelain` of them and the content of each file it lists.
2537
2714
  // The key of a measure of the proof: the copy's fingerprint and the files it measures, in their
2538
2715
  // order; the same tree measured on other files (a version that sets other files aside) is another
2539
2716
  // measure.
2540
2717
  export const cleDeLaMesure = (ctx, fichiers) => [empreinte(ctx, ['.']), ...fichiers].join('\n');
2541
2718
 
2719
+ // The fingerprint of the files of <chemins> the lot changes (the plan by default): each file of
2720
+ // `changements`, deleted or not, and its content, the same whether the lot is committed or not.
2542
2721
  export function empreinte(ctx, chemins = ctx.paquets) {
2543
- const r = spawnSync(
2544
- 'git',
2545
- ['-C', ctx.copie, 'status', '--porcelain', '-z', '--untracked-files=all', '--', ...chemins],
2546
- { encoding: 'utf8' }
2547
- );
2548
- const statut = String(r.stdout ?? '');
2549
- const h = createHash('sha256').update(statut);
2550
- for (const e of statut.split('\0')) {
2551
- if (e.length < 4) {
2552
- continue;
2553
- }
2554
- const f = path.join(ctx.copie, e.slice(3));
2722
+ const h = createHash('sha256');
2723
+ for (const { fichier, supprime } of changements(ctx, chemins)) {
2724
+ h.update(`${supprime ? 'D' : 'M'} ${fichier}\0`);
2725
+ const f = path.join(ctx.copie, fichier);
2555
2726
  try {
2556
2727
  if (statSync(f).isFile()) {
2557
- h.update(e).update(readFileSync(f));
2728
+ h.update(readFileSync(f));
2558
2729
  }
2559
2730
  } catch {
2560
- // A file removed: its line in the status is its trace.
2731
+ // A file removed: its line is its trace.
2561
2732
  }
2562
2733
  }
2563
2734
  return h.digest('hex');