@roomi-fields/grillhouse 0.29.0 → 0.31.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 (263) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +769 -0
  3. package/agents/developpeur.md +0 -1
  4. package/agents/explorateur.md +0 -1
  5. package/agents/questionneur.md +0 -1
  6. package/agents/testwriter.md +0 -1
  7. package/bin/grillhouse.mjs +79 -18
  8. package/cadre/templates/projet/.github/workflows/ci.yml +2 -13
  9. package/cadre/templates/projet/CLAUDE.md +5 -1
  10. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  11. package/cadre/templates/projet/package.json +2 -2
  12. package/charte.md +24 -0
  13. package/dist/temporal/acte.d.ts +24 -0
  14. package/dist/temporal/acte.js +139 -0
  15. package/dist/temporal/acte.js.map +1 -0
  16. package/dist/temporal/attributs.d.ts +6 -0
  17. package/dist/temporal/attributs.js +15 -0
  18. package/dist/temporal/attributs.js.map +1 -0
  19. package/dist/temporal/circuit/activites.d.ts +13 -0
  20. package/dist/temporal/circuit/activites.js +33 -0
  21. package/dist/temporal/circuit/activites.js.map +1 -0
  22. package/dist/temporal/circuit/client.d.ts +72 -0
  23. package/dist/temporal/circuit/client.js +247 -0
  24. package/dist/temporal/circuit/client.js.map +1 -0
  25. package/dist/temporal/circuit/commande.d.ts +2 -0
  26. package/dist/temporal/circuit/commande.js +238 -0
  27. package/dist/temporal/circuit/commande.js.map +1 -0
  28. package/dist/temporal/circuit/contrat.d.ts +305 -0
  29. package/dist/temporal/circuit/contrat.js +30 -0
  30. package/dist/temporal/circuit/contrat.js.map +1 -0
  31. package/dist/temporal/circuit/deroule.d.ts +3 -0
  32. package/dist/temporal/circuit/deroule.js +540 -0
  33. package/dist/temporal/circuit/deroule.js.map +1 -0
  34. package/dist/temporal/client.d.ts +47 -0
  35. package/dist/temporal/client.js +69 -0
  36. package/dist/temporal/client.js.map +1 -0
  37. package/dist/temporal/commande.d.ts +2 -0
  38. package/dist/temporal/commande.js +94 -0
  39. package/dist/temporal/commande.js.map +1 -0
  40. package/dist/temporal/deroules.d.ts +5 -0
  41. package/dist/temporal/deroules.js +10 -0
  42. package/dist/temporal/deroules.js.map +1 -0
  43. package/dist/temporal/etat.d.ts +33 -0
  44. package/dist/temporal/etat.js +59 -0
  45. package/dist/temporal/etat.js.map +1 -0
  46. package/dist/temporal/file/activites.d.ts +10 -0
  47. package/dist/temporal/file/activites.js +25 -0
  48. package/dist/temporal/file/activites.js.map +1 -0
  49. package/dist/temporal/file/client.d.ts +4 -0
  50. package/dist/temporal/file/client.js +6 -0
  51. package/dist/temporal/file/client.js.map +1 -0
  52. package/dist/temporal/file/contrat.d.ts +158 -0
  53. package/dist/temporal/file/contrat.js +14 -0
  54. package/dist/temporal/file/contrat.js.map +1 -0
  55. package/dist/temporal/file/deroule.d.ts +15 -0
  56. package/dist/temporal/file/deroule.js +235 -0
  57. package/dist/temporal/file/deroule.js.map +1 -0
  58. package/dist/temporal/installation.d.ts +120 -0
  59. package/dist/temporal/installation.js +386 -0
  60. package/dist/temporal/installation.js.map +1 -0
  61. package/dist/temporal/places/activites.d.ts +8 -0
  62. package/dist/temporal/places/activites.js +13 -0
  63. package/dist/temporal/places/activites.js.map +1 -0
  64. package/dist/temporal/places/client.d.ts +28 -0
  65. package/dist/temporal/places/client.js +64 -0
  66. package/dist/temporal/places/client.js.map +1 -0
  67. package/dist/temporal/places/contrat.d.ts +106 -0
  68. package/dist/temporal/places/contrat.js +21 -0
  69. package/dist/temporal/places/contrat.js.map +1 -0
  70. package/dist/temporal/places/deroule.d.ts +3 -0
  71. package/dist/temporal/places/deroule.js +198 -0
  72. package/dist/temporal/places/deroule.js.map +1 -0
  73. package/dist/temporal/sonde/activites.d.ts +6 -0
  74. package/dist/temporal/sonde/activites.js +52 -0
  75. package/dist/temporal/sonde/activites.js.map +1 -0
  76. package/dist/temporal/sonde/contrat.d.ts +35 -0
  77. package/dist/temporal/sonde/contrat.js +10 -0
  78. package/dist/temporal/sonde/contrat.js.map +1 -0
  79. package/dist/temporal/sonde/deroule.d.ts +3 -0
  80. package/dist/temporal/sonde/deroule.js +39 -0
  81. package/dist/temporal/sonde/deroule.js.map +1 -0
  82. package/dist/temporal/tickets/activites.d.ts +7 -0
  83. package/dist/temporal/tickets/activites.js +81 -0
  84. package/dist/temporal/tickets/activites.js.map +1 -0
  85. package/dist/temporal/tickets/client.d.ts +10 -0
  86. package/dist/temporal/tickets/client.js +31 -0
  87. package/dist/temporal/tickets/client.js.map +1 -0
  88. package/dist/temporal/tickets/contrat.d.ts +56 -0
  89. package/dist/temporal/tickets/contrat.js +13 -0
  90. package/dist/temporal/tickets/contrat.js.map +1 -0
  91. package/dist/temporal/tickets/deroule.d.ts +3 -0
  92. package/dist/temporal/tickets/deroule.js +94 -0
  93. package/dist/temporal/tickets/deroule.js.map +1 -0
  94. package/dist/temporal/travailleur.d.ts +2 -0
  95. package/dist/temporal/travailleur.js +69 -0
  96. package/dist/temporal/travailleur.js.map +1 -0
  97. package/docs/ARCHITECTURE.md +646 -87
  98. package/docs/CADRE.md +27 -0
  99. package/docs/INTERFACE.md +139 -42
  100. package/hooks/crochet.mjs +19 -2
  101. package/hooks/hooks.json +11 -0
  102. package/package.json +16 -4
  103. package/scripts/activites.mjs +2255 -0
  104. package/scripts/aiguillage.d.mts +37 -0
  105. package/scripts/aiguillage.mjs +40 -14
  106. package/scripts/avancement.mjs +155 -26
  107. package/scripts/bilan.mjs +137 -43
  108. package/scripts/cadre.mjs +16 -4
  109. package/scripts/circuit.mjs +993 -4075
  110. package/scripts/circuits-cles.d.mts +4 -0
  111. package/scripts/circuits-cles.mjs +21 -0
  112. package/scripts/circuits-du-serveur.mjs +105 -0
  113. package/scripts/codes-de-sortie.mjs +9 -0
  114. package/scripts/commandes-composees.mjs +45 -41
  115. package/scripts/commandes-du-path.d.mts +7 -0
  116. package/scripts/commandes-du-path.mjs +25 -0
  117. package/scripts/composants-affectes.mjs +64 -21
  118. package/scripts/composition-des-langages.mjs +18 -12
  119. package/scripts/conformite.mjs +56 -28
  120. package/scripts/copies-finies.mjs +52 -47
  121. package/scripts/depart-du-ticket.d.mts +53 -0
  122. package/scripts/depart-du-ticket.mjs +124 -0
  123. package/scripts/dependances-internes.mjs +121 -0
  124. package/scripts/dernier-vert.mjs +61 -34
  125. package/scripts/dette.mjs +32 -11
  126. package/scripts/donnees-cles.mjs +244 -0
  127. package/scripts/droits.mjs +51 -16
  128. package/scripts/effets.mjs +352 -0
  129. package/scripts/empreinte-d-etape.mjs +17 -0
  130. package/scripts/engendres.mjs +15 -5
  131. package/scripts/enveloppe/enveloppe.mjs +259 -55
  132. package/scripts/enveloppe/lancer.sh +14 -18
  133. package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
  134. package/scripts/enveloppe/travail-de-la-copie.mjs +41 -13
  135. package/scripts/etapes.mjs +5 -2
  136. package/scripts/faits-du-circuit.mjs +493 -0
  137. package/scripts/file-des-tickets.d.mts +21 -0
  138. package/scripts/file-des-tickets.mjs +58 -0
  139. package/scripts/flux-des-paquets.mjs +201 -0
  140. package/scripts/gardes-du-cadre.mjs +21 -5
  141. package/scripts/init.mjs +11 -4
  142. package/scripts/integration/file.mjs +544 -434
  143. package/scripts/integration/integrer.mjs +87 -43
  144. package/scripts/integration/rejeu.mjs +45 -13
  145. package/scripts/jointure.d.ts +151 -28
  146. package/scripts/langages/cargo/commandes.mjs +383 -124
  147. package/scripts/langages/cargo/composants.mjs +154 -42
  148. package/scripts/langages/cargo/exemples.mjs +12 -21
  149. package/scripts/langages/cargo/index.mjs +22 -8
  150. package/scripts/langages/cargo/sccache.mjs +8 -14
  151. package/scripts/langages/cargo/tests-de-head.mjs +25 -9
  152. package/scripts/langages/python/commandes.mjs +218 -100
  153. package/scripts/langages/python/composants.mjs +53 -21
  154. package/scripts/langages/python/exemples.mjs +6 -16
  155. package/scripts/langages/python/index.mjs +28 -8
  156. package/scripts/langages/python/lot.mjs +1 -36
  157. package/scripts/langages/typescript/chemins-des-tests.mjs +6 -2
  158. package/scripts/langages/typescript/composants.mjs +9 -3
  159. package/scripts/langages/typescript/consommateurs-arbitres.mjs +40 -14
  160. package/scripts/langages/typescript/consommateurs.mjs +39 -14
  161. package/scripts/langages/typescript/construire.mjs +6 -163
  162. package/scripts/langages/typescript/elements-du-lot.mjs +36 -12
  163. package/scripts/langages/typescript/exemples.mjs +3 -11
  164. package/scripts/langages/typescript/frontieres.mjs +66 -22
  165. package/scripts/langages/typescript/index-interfaces.mjs +36 -13
  166. package/scripts/langages/typescript/index.mjs +50 -61
  167. package/scripts/langages/typescript/interfaces-contre-code.mjs +113 -45
  168. package/scripts/langages/typescript/lecteurs.mjs +36 -11
  169. package/scripts/langages/typescript/migrations/0.23.0-config-vitest.mjs +15 -5
  170. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +6 -2
  171. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +6 -2
  172. package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
  173. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +33 -0
  174. package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
  175. package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
  176. package/scripts/langages/typescript/parcours.mjs +12 -4
  177. package/scripts/langages/typescript/regle-des-tests.mjs +9 -3
  178. package/scripts/langages/typescript/resumes.mjs +9 -3
  179. package/scripts/langages/typescript/tailles-des-tests.mjs +93 -20
  180. package/scripts/langages/typescript/tests-de-nuit.mjs +15 -10
  181. package/scripts/langages/typescript/tests.mjs +40 -15
  182. package/scripts/langages/typescript/titres-de-tests.mjs +320 -0
  183. package/scripts/langages/typescript/turbo-des-paquets.mjs +327 -81
  184. package/scripts/langages/typescript/verdict.mjs +4 -2
  185. package/scripts/langages/typescript/verifier.mjs +58 -20
  186. package/scripts/langages/typescript/vitest-config/avancement.reporter.mjs +15 -5
  187. package/scripts/langages/typescript/vitest-config/base.mjs +29 -3
  188. package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
  189. package/scripts/langages/typescript/vitest-config/changements.mjs +21 -8
  190. package/scripts/langages/typescript/vitest-config/cibles.mjs +36 -14
  191. package/scripts/langages/typescript/vitest-config/delais.mjs +60 -0
  192. package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
  193. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +108 -0
  194. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +56 -59
  195. package/scripts/langages/typescript/vitest-config/lances.mjs +83 -27
  196. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +10 -0
  197. package/scripts/langages/typescript/vitest-config/resultats.mjs +3 -1
  198. package/scripts/langages/typescript/vitest.nuit.config.mjs +4 -0
  199. package/scripts/lint-des-scripts.mjs +58 -0
  200. package/scripts/mesure/base-de-passe.mjs +117 -25
  201. package/scripts/mesure/pression.mjs +12 -6
  202. package/scripts/mesure-de-la-machine.d.mts +21 -0
  203. package/scripts/mesure-de-la-machine.mjs +76 -0
  204. package/scripts/migrations/0.23.0-charte-importee.mjs +6 -2
  205. package/scripts/migrations/0.23.0-crochets-de-seance.mjs +25 -8
  206. package/scripts/migrations/0.23.0-marche-du-projet.mjs +18 -6
  207. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +56 -18
  208. package/scripts/migrations/0.24.12-tri-des-decouvertes.mjs +6 -2
  209. package/scripts/migrations/0.25.0-script-des-tests.mjs +15 -5
  210. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +124 -0
  211. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
  212. package/scripts/migrations.mjs +5 -0
  213. package/scripts/nuit.sh +25 -3
  214. package/scripts/outil.mjs +3 -1
  215. package/scripts/outils-cles.d.mts +24 -0
  216. package/scripts/outils-cles.mjs +18 -8
  217. package/scripts/paquet-npm.mjs +157 -0
  218. package/scripts/paquet.mjs +73 -4
  219. package/scripts/paquets.mjs +46 -10
  220. package/scripts/passe-de-la-machine.mjs +71 -0
  221. package/scripts/places-de-la-machine.mjs +414 -0
  222. package/scripts/places-du-serveur.mjs +170 -0
  223. package/scripts/prefixe-des-tickets.mjs +68 -0
  224. package/scripts/preparation.mjs +25 -8
  225. package/scripts/registre.mjs +9 -4
  226. package/scripts/regles-des-places.d.mts +36 -0
  227. package/scripts/regles-des-places.mjs +70 -0
  228. package/scripts/reponses-du-circuit.d.mts +6 -0
  229. package/scripts/reponses-du-circuit.mjs +28 -0
  230. package/scripts/reprise.mjs +66 -0
  231. package/scripts/resultats.mjs +112 -46
  232. package/scripts/retirer-les-copies-finies.mjs +25 -0
  233. package/scripts/sans-reponse.d.mts +4 -0
  234. package/scripts/sans-reponse.mjs +13 -0
  235. package/scripts/seances.mjs +936 -0
  236. package/scripts/services-du-noyau.mjs +27 -8
  237. package/scripts/session-start.sh +2 -2
  238. package/scripts/sortie.mjs +3 -3
  239. package/scripts/sous-commandes.mjs +41 -10
  240. package/scripts/style-a-l-ecriture.mjs +260 -0
  241. package/scripts/superviseur.mjs +122 -111
  242. package/scripts/tableau.mjs +180 -117
  243. package/scripts/taches-du-graphe.mjs +348 -0
  244. package/scripts/ticket-du-circuit.mjs +216 -0
  245. package/scripts/transitions.d.mts +148 -0
  246. package/scripts/transitions.mjs +1018 -0
  247. package/scripts/verrou-de-fichier.mjs +8 -4
  248. package/scripts/verrou-de-machine.mjs +150 -51
  249. package/scripts/verrous/commande.mjs +50 -17
  250. package/scripts/verrous/ticket-du-sous-agent.mjs +9 -3
  251. package/scripts/verrous/verrou.mjs +42 -14
  252. package/skills/explorateur/SKILL.md +9 -2
  253. package/skills/grill/SKILL.md +1 -1
  254. package/skills/mesure/SKILL.md +3 -0
  255. package/skills/pitmaster/SKILL.md +17 -18
  256. package/skills/pitmaster/references/consigne-agent.md +5 -1
  257. package/skills/release/SKILL.md +3 -3
  258. package/skills/relecteur/SKILL.md +5 -3
  259. package/skills/testwriter/SKILL.md +49 -31
  260. package/scripts/demon.mjs +0 -251
  261. package/scripts/integration/file-attente.mjs +0 -61
  262. package/scripts/langages/cargo/touches.mjs +0 -93
  263. package/scripts/langages/typescript/script-des-tests.mjs +0 -6
@@ -0,0 +1,1018 @@
1
+ // The decisions of the circuit of a ticket (scripts/circuit.mjs), with no input nor output, as a
2
+ // workflow of Temporal decides on the results of its activities and a reducer of Redux on its
3
+ // actions: from the state of the run, the circuit's memory and the facts read so far, the step
4
+ // that follows. The circuit reads the facts and interprets what this module returns; this module
5
+ // reads no file, launches no process and imports no module that does (a guard holds it:
6
+ // tests/unit/transitions.spec.ts).
7
+ //
8
+ // `transition({ etat, memoire, ticket, reprend, faits })`:
9
+ //
10
+ // - `etat`, the run at its step: `{ etape, tentative, rapport, finale, relanceSurLeRefus }`;
11
+ // - `memoire`, what the circuit keeps between steps (`controlesRouges`, `renvoiAuTestwriter`,
12
+ // `refus`, `rienALivrer`, `regeneration`, `regenereSur`, `aRegenerer`, `verifie`, `constats`);
13
+ // - `ticket`, `{ id, paquets, sorte, copie }`;
14
+ // - `reprend`, whether this step is the first of a `--reprendre`;
15
+ // - `faits`, the facts read for this step, by their name.
16
+ //
17
+ // It returns either the next fact to read, `{ besoin: { fait, ...parametres }, effets, memoire }` (a
18
+ // session, a pass, a reading of the copy), which the circuit reads and gives back in `faits` with
19
+ // the same call, `effets` and `memoire` what the step decided before it, so that an engine applies
20
+ // them before the fact and loses none when the fact fails; or the decision: `{ suivant, memoire, effets, arret, fin, usage }`, `suivant` the state of
21
+ // the next step, `memoire` what changes in the circuit's memory, `effets` in their order (a line
22
+ // at the ticket `{ genre: 'commenter', etape, texte }`, a gesture `{ genre: 'geste', nom }`, a
23
+ // report `{ genre: 'rapport', etape, texte, resultat, rapport }`, a result kept
24
+ // `{ genre: 'inscrire', entree, evenement }`, its event named), then a stop `arret` (its name `nom` and its `rapport`, with the
25
+ // options of an Arret of the circuit: `piece`, `question`, `qui`, `rouges`, `motif`, `resultat`,
26
+ // `etape`; or `{ nom, statut: { role, tentative, fiche } }` and `{ nom, horsDuPlan: { tentative,
27
+ // fiche } }`, which the circuit builds with the agent's handover), the end of the run `fin`, or a
28
+ // step the list does not hold `usage`. Each call is played again from the start of its step with
29
+ // the facts read so far, as Temporal replays a workflow on its history: the same facts give the
30
+ // same decision.
31
+ import { A_REPASSER } from './codes-de-sortie.mjs';
32
+ import { ARRETS, boucle, RESPONSABLE, SUITE } from './etapes.mjs';
33
+ import { attribuerLeRouge } from './reprise.mjs';
34
+
35
+ // The steps of the circuit's state, read from the list of the steps.
36
+ const etatDe = n => SUITE.find(e => e.numero === n).etat;
37
+ export const [
38
+ GESTE,
39
+ TESTS,
40
+ PREUVE,
41
+ CODE,
42
+ CONTROLES,
43
+ REFERENCES,
44
+ RELECTURE,
45
+ INTEGRATION,
46
+ EN_FILE,
47
+ TRI,
48
+ ] = ['1.1', '2', '2.1', '3', '3.1', '4.2', '4.3', '5.1', '5.2', '5.3'].map(etatDe);
49
+
50
+ // The bounded loops, each declared with its step (scripts/etapes.mjs, `boucles`): the testwriter is
51
+ // relaunched twice at most after a failed proof (three sessions); the developpeur has three
52
+ // sessions, the last on the strong model; the third RENDU of one ticket stops the circuit.
53
+ export const RELANCES_TESTWRITER = boucle('tests').max - 1;
54
+ export const SEANCES_DEVELOPPEUR = boucle('code').max;
55
+ export const RELECTURES = boucle('relecture').max;
56
+
57
+ // What changed for a developpeur relaunched on the integration's refusal of the lot he left as it was.
58
+ export const CHANGE_DU_REFUS =
59
+ 'l’intégration refuse ton lot, et ta séance n’a changé aucun fichier du plan : son refus, dans le rapport ci-dessous, est le rouge à lever';
60
+
61
+ // The developpeur's report on the integration's refusal <refus>: the red to lift, which the checks
62
+ // of the copy, green, do not see.
63
+ export const rapportDuRefus = refus =>
64
+ `L’intégration refuse ce lot : son refus, ci-dessous, est le rouge à lever ; les contrôles de ta copie, verts, ne le voient pas, et le lot ne repasse à l’intégration qu’avec un changement.\n\n${refus.rapport}`;
65
+
66
+ // The step after the plan of sort <sorte> (null when the path is not mechanical): the gesture of
67
+ // a mechanical ticket (1.1), in place of the testwriter, the proof and the developpeur; the
68
+ // developpeur of a plan without tests (<sansTests>); else the testwriter.
69
+ export const etapeApresLePlan = ({ sorte, sansTests }) =>
70
+ sorte?.genre === 'mécanique' ? GESTE : sansTests ? CODE : TESTS;
71
+
72
+ // The step after a proof that passes: the developpeur on a red (<rouges>), on a finding of the
73
+ // reviewer still open for him (<pourLeDeveloppeur>), or under a plan « comportement inchangé »
74
+ // (<inchange>), whose lot has code to write though nothing turns red, as a reorganisation does
75
+ // (decision 3, amended by the owner on 2026-11-01); else the checks, a lot of tests alone, with
76
+ // no session of the developpeur.
77
+ export const apresLaPreuve = ({ rouges, pourLeDeveloppeur, inchange }) =>
78
+ rouges > 0 || pourLeDeveloppeur || inchange ? CODE : CONTROLES;
79
+
80
+ // What follows a red of the reading of the copy after the session <tentative> of <role>: the agent
81
+ // again, one attempt used as a red build uses it, or, the attempts used up, the stop « controles »
82
+ // as the red checks.
83
+ export function suiteDuRougeDeLecture(role, tentative) {
84
+ const max = boucle(role === 'testwriter' ? 'tests' : 'code').max;
85
+ return tentative < max ? { etape: role, tentative: tentative + 1 } : { arret: 'controles' };
86
+ }
87
+
88
+ // The findings of the reviewer open for <role> among <constats>, in their order.
89
+ export const ouverts = (constats, role) => (constats ?? []).filter(c => c.role === role);
90
+
91
+ // The stop for the findings open (<constats>) that go to the testwriter when the plan skips him
92
+ // (<sansTests>), or null: no new pass treats them, as a CI fails fast on a step it cannot run
93
+ // (grillhouse-26x). A stop `relecture-arret` whose report names each finding, the role skipped
94
+ // and why, then the verdict <texte>; its piece, the findings' pieces; its question, declare the
95
+ // tests of the package or settle the finding.
96
+ export function arretDuTestwriterSaute({ constats, sansTests, paquets }, texte) {
97
+ const auTestwriter = ouverts(constats, 'testwriter');
98
+ if (!auTestwriter.length || !sansTests) {
99
+ return null;
100
+ }
101
+ const titres = auTestwriter.map(c => `« ${c.titre} »`).join(', ');
102
+ const plan = paquets.join(', ');
103
+ return {
104
+ nom: 'relecture-arret',
105
+ rapport: `Le relecteur adresse au testwriter ${titres}, quand le plan saute le testwriter : aucun paquet du plan ne joue de tests (${plan}).\n\nLe verdict :\n\n${texte}`,
106
+ piece: auTestwriter.map(c => c.piece ?? c.titre).join('\n'),
107
+ question: `Le constat ${titres} va au testwriter, que le plan (${plan}) saute : déclarer les tests du paquet au cadre, puis \`--reprendre\`, ou trancher le constat (\`--depuis developpeur --contexte\`, ou \`--arreter\`).`,
108
+ };
109
+ }
110
+
111
+ // The stop for a RENDU of a mechanical lot (<mecanique>), or null: no testwriter nor developpeur
112
+ // wrote it, so no relaunch treats its findings (<constats>). A stop `relecture-arret`, the verdict
113
+ // <texte> in its report, the findings' pieces as its piece; its question, have the lot corrected
114
+ // by the developpeur or stop the circuit.
115
+ export function arretDuGesteMecanique({ constats, mecanique, sorte }, texte) {
116
+ if (!mecanique) {
117
+ return null;
118
+ }
119
+ const pieces = (constats ?? []).map(c => c.piece ?? c.titre).join('\n');
120
+ return {
121
+ nom: 'relecture-arret',
122
+ rapport: `Le relecteur rend un lot mécanique (${sorte.raison}), que la commande du plan a fait sans testwriter ni développeur : le circuit ne relance personne.\n\nLe verdict :\n\n${texte}`,
123
+ piece: pieces || null,
124
+ question: `Le lot mécanique est rendu : le faire corriger par le développeur (\`--depuis developpeur --contexte\`), ou arrêter le circuit (\`--arreter\`) et changer le plan.`,
125
+ };
126
+ }
127
+
128
+ // The last <n> lines of <t>, a text the circuit gives without its colours.
129
+ const fin = (t, n) =>
130
+ String(t ?? '')
131
+ .split('\n')
132
+ .slice(-n)
133
+ .join('\n');
134
+
135
+ // A fact the decision has not read yet: its name and what reads it.
136
+ class Besoin {
137
+ constructor(fait, parametres) {
138
+ this.fait = fait;
139
+ this.parametres = parametres;
140
+ }
141
+ }
142
+
143
+ // The plan of a ticket, its decisions as the circuit and the workflow of a ticket take them
144
+ // (grillhouse-4nr.6.3): the step of the plan that follows its state <e> (`{ plan, lu, posees,
145
+ // reponse }`, the explorateur's sheet, the questionneur's, the questions put, the explorateur's
146
+ // answer): `explorateur`, `questionneur`, `reponse` (questions were put), then `conclure`.
147
+ export const pasDuPlan = e =>
148
+ !e.plan
149
+ ? 'explorateur'
150
+ : !e.lu
151
+ ? 'questionneur'
152
+ : e.posees.length && !e.reponse
153
+ ? 'reponse'
154
+ : 'conclure';
155
+
156
+ // The questions the explorateur answers in the questionneur's sheet <lu>: its questions, or its
157
+ // disagreement as one; none for « AUCUNE ».
158
+ export const questionsPosees = lu =>
159
+ lu.issue === 'AUCUNE'
160
+ ? []
161
+ : lu.issue === 'DÉSACCORD'
162
+ ? [lu.desaccord]
163
+ : lu.questions.map(q => q.question);
164
+
165
+ // What stays open of the plan <plan> once the explorateur answered <reponses> to the questions
166
+ // <posees>: the plan's own questions, then each question put left without its answer.
167
+ export const ouvertesDuPlan = (plan, posees, reponses) => [
168
+ ...plan.questions,
169
+ ...posees
170
+ .filter((_q, i) => !reponses.some(r => Number(r.numero) === i + 1))
171
+ .map(question => ({ question, piece: 'question du questionneur, sans réponse' })),
172
+ ];
173
+
174
+ // The effects <effets> an act gave back as the workflow plays them (scripts/effets.mjs), in their
175
+ // order: a state followed by another state is not played, since the state is written whole and
176
+ // nothing reads it between the two.
177
+ export const effetsAJouer = effets =>
178
+ effets.filter((e, i) => !(e.genre === 'etat' && effets[i + 1]?.genre === 'etat'));
179
+
180
+ // The text <t> without the escape sequences of a terminal (colours, ECMA-48 CSI and OSC), as
181
+ // `stripVTControlCharacters` of node:util removes them; written here, since the workflow of a
182
+ // ticket imports this module and a workflow imports no module of node.
183
+ const SEQUENCES = new RegExp(
184
+ String.raw`\u001b(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007\u001b]*(?:\u0007|\u001b\\)|[@-Z\\-_])`,
185
+ 'g'
186
+ );
187
+ const sansLesCodes = t => String(t ?? '').replace(SEQUENCES, '');
188
+
189
+ // The stop « inattendu » at the step <etat> that no act could write at the ticket (the act of the
190
+ // stop itself failed, its message <message>), as the workflow of a ticket under Temporal publishes
191
+ // it in its memo alone (src/temporal/circuit/deroule.ts): `{ code, nom, question, etat }`. Its
192
+ // question names the cause, the first line of <message>, since it is all the supervisor reads;
193
+ // the codes of colour of a command's output go (`sansLesCodes`).
194
+ export const arretSansActe = (etat, message, ou) => ({
195
+ code: ARRETS.inattendu,
196
+ nom: 'inattendu',
197
+ question: {
198
+ arret: 'inattendu',
199
+ fait: `L'arrêt de l'étape « ${etat.etape} » ne s'écrit pas au ticket : ${sansLesCodes(message)}`,
200
+ piece: ou,
201
+ question: `L'arrêt de l'étape « ${etat.etape} » ne s'écrit pas au ticket : ${
202
+ sansLesCodes(message)
203
+ .split('\n')
204
+ .find(l => l.trim())
205
+ ?.trim() ?? 'sans message'
206
+ }. Lever la cause, puis reprendre le circuit (--reprendre) ou l’arrêter (--arreter).`,
207
+ qui: 'superviseur',
208
+ },
209
+ etat: { ...etat, raison: 'inattendu' },
210
+ });
211
+
212
+ // The decision of the step of <entree> (see the header), or the next fact it needs.
213
+ export function transition(entree) {
214
+ const faits = entree.faits ?? {};
215
+ const lire = (fait, parametres = {}) => {
216
+ if (fait in faits) {
217
+ return faits[fait];
218
+ }
219
+ throw new Besoin(fait, parametres);
220
+ };
221
+ // What the step decided before the fact it needs.
222
+ const partiel = { effets: [], maj: {} };
223
+ try {
224
+ return decider(entree, lire, partiel);
225
+ } catch (e) {
226
+ if (e instanceof Besoin) {
227
+ return {
228
+ besoin: { fait: e.fait, ...e.parametres },
229
+ effets: [...partiel.effets],
230
+ memoire: { ...partiel.maj },
231
+ };
232
+ }
233
+ throw e;
234
+ }
235
+ }
236
+
237
+ function decider({ etat, memoire = {}, ticket, reprend = false }, lire, partiel) {
238
+ let { etape, tentative, rapport, finale } = etat;
239
+ let relanceSurLeRefus = Boolean(etat.relanceSurLeRefus);
240
+ const maj = {};
241
+ // The memory as this decision leaves it so far.
242
+ const m = cle => (cle in maj ? maj[cle] : (memoire[cle] ?? null));
243
+ const effets = [];
244
+ partiel.effets = effets;
245
+ partiel.maj = maj;
246
+ const commenter = (lieu, texte) => effets.push({ genre: 'commenter', etape: lieu, texte });
247
+ const geste = nom => effets.push({ genre: 'geste', nom });
248
+ const ecrireRapport = (lieu, texte, resultat, r = texte) =>
249
+ effets.push({ genre: 'rapport', etape: lieu, texte, resultat, rapport: r });
250
+ const inscrire = (entree, evenement) => effets.push({ genre: 'inscrire', entree, evenement });
251
+ // The last green of a step (`verts`: the fingerprint of its inputs, its duration, what it
252
+ // needs to be read back) kept in the memory, or dropped (<vert> null): only a step green keeps
253
+ // one, as a task of Turborepo caches only its success.
254
+ const garderLeVert = (nom, vert) => {
255
+ const verts = { ...(m('verts') ?? {}) };
256
+ if (vert) {
257
+ verts[nom] = vert;
258
+ } else {
259
+ delete verts[nom];
260
+ }
261
+ maj.verts = verts;
262
+ };
263
+ // A step whose inputs are those of its last green: its result is read back, its duration
264
+ // (<ms>) the one the bilan counts as not replayed (scripts/bilan.mjs).
265
+ const releve = (nom, ms) => {
266
+ const lieu = nom === 'passe-finale' ? 'controles' : nom;
267
+ commenter(
268
+ lieu,
269
+ `${nom} relue sans se rejouer : ses entrées (fichiers, commande) sont celles de son dernier vert.`
270
+ );
271
+ inscrire({ etape: nom, relue: { ms: ms ?? 0 } }, 'relue');
272
+ };
273
+ const decision = (extra = {}) => ({
274
+ suivant: { etape, tentative, rapport, finale, relanceSurLeRefus },
275
+ memoire: maj,
276
+ effets,
277
+ ...extra,
278
+ });
279
+ const arreter = (nom, r, options = {}) => decision({ arret: { nom, rapport: r, ...options } });
280
+ const plan = ticket.paquets.join(', ');
281
+
282
+ // After the plan: the gesture of a mechanical ticket, the developpeur of a plan without tests,
283
+ // else the testwriter.
284
+ const route =
285
+ etape === TESTS
286
+ ? etapeApresLePlan({
287
+ sorte: lire('mecanique') ? ticket.sorte : null,
288
+ sansTests: lire('sansTests'),
289
+ })
290
+ : null;
291
+ if (route === GESTE) {
292
+ geste('mecanique');
293
+ etape = GESTE;
294
+ tentative = 1;
295
+ return decision();
296
+ }
297
+ if (etape === GESTE) {
298
+ if (reprend && lire('livreAvant')) {
299
+ // The copy already carries the gesture (the supervisor played the command himself).
300
+ commenter(
301
+ 'mecanique',
302
+ 'la copie porte déjà un changement du plan : le geste ne rejoue pas, aux contrôles.'
303
+ );
304
+ } else {
305
+ const fiche = lire('seanceDuGeste');
306
+ if (fiche.statut !== 'FAIT') {
307
+ return decision({
308
+ arret: { nom: nomDuStatut(fiche), statut: { role: 'explorateur', tentative, fiche } },
309
+ });
310
+ }
311
+ if (!lire('livre')) {
312
+ return arreter(
313
+ 'sans-livraison',
314
+ `Le geste mécanique ne change aucun fichier du plan (${plan}) : la commande du plan, \`${ticket.sorte.commande}\`, n'a rien changé dans la copie.`,
315
+ { piece: `$ ${ticket.sorte.commande}\naucun fichier du plan changé dans ${ticket.copie}` }
316
+ );
317
+ }
318
+ commenter('mecanique', 'la commande du plan a joué dans la copie : aux contrôles.');
319
+ }
320
+ etape = CONTROLES;
321
+ tentative = 0;
322
+ return decision();
323
+ }
324
+ if (route === CODE) {
325
+ commenter(
326
+ 'testwriter',
327
+ 'aucun test dans le plan (aucun paquet qui joue des tests ne le tient) : ni testwriter ni preuve, le développeur directement.'
328
+ );
329
+ rapport = [
330
+ `Le plan (${plan}) ne porte aucun test (aucun paquet qui joue des tests ne le tient) : le circuit te lance sans testwriter ni preuve. Tu écris le ticket d'après ses critères ; les contrôles suivent ta séance.`,
331
+ rapport,
332
+ ]
333
+ .filter(Boolean)
334
+ .join('\n\n');
335
+ etape = CODE;
336
+ tentative = 1;
337
+ return decision();
338
+ }
339
+ if (etape === TESTS) {
340
+ const reprise = m('reprise');
341
+ const fiche = lire('seance', {
342
+ role: 'testwriter',
343
+ tentative,
344
+ rapport,
345
+ derniere: tentative > RELANCES_TESTWRITER,
346
+ ...(reprise ? { fichiers: reprise.fichiers } : {}),
347
+ });
348
+ // A testwriter who declares himself blocked or in need of an answer goes up to the supervisor.
349
+ if (fiche.statut !== 'FAIT') {
350
+ return decision({
351
+ arret: { nom: nomDuStatut(fiche), statut: { role: 'testwriter', tentative, fiche } },
352
+ });
353
+ }
354
+ // No checks have run since this session.
355
+ maj.controlesRouges = null;
356
+ commenter('testwriter', `séance ${tentative} finie, sa fiche lue.`);
357
+ // A copy the module of the language no longer reads is a red of the testwriter.
358
+ const illisible = lire('lecture');
359
+ if (illisible) {
360
+ const suite = suiteDuRougeDeLecture('testwriter', tentative);
361
+ if (suite.arret) {
362
+ return arreter(suite.arret, illisible.rapport);
363
+ }
364
+ commenter(
365
+ 'testwriter',
366
+ `la copie ne se lit plus ; testwriter relancé (séance ${suite.tentative}).\n\n${illisible.rapport}`
367
+ );
368
+ etape = TESTS;
369
+ tentative = suite.tentative;
370
+ rapport = illisible.rapport;
371
+ return decision();
372
+ }
373
+ etape = PREUVE;
374
+ return decision();
375
+ }
376
+ if (etape === PREUVE) {
377
+ const reprise = m('reprise');
378
+ // A finding of the reviewer still open for the developpeur launches him, red or not.
379
+ const pourLui = ouverts(m('constats'), 'developpeur').length > 0;
380
+ const inchange = Boolean(ticket.sorte?.inchange);
381
+ const vert = m('verts')?.preuve;
382
+ if (vert && !reprise && lire('empreinteEtape', { etape: 'preuve' }) === vert.empreinte) {
383
+ // The proof's inputs are those of its last green: its result is read back, not played.
384
+ releve('preuve', vert.ms);
385
+ rapport = vert.texte ?? null;
386
+ const auDeveloppeur =
387
+ apresLaPreuve({ rouges: vert.rouges, pourLeDeveloppeur: pourLui, inchange }) === CODE;
388
+ etape = auDeveloppeur ? CODE : CONTROLES;
389
+ tentative = auDeveloppeur ? 1 : 0;
390
+ return decision();
391
+ }
392
+ const p = lire('preuve', reprise ? { fichiers: reprise.fichiers } : {});
393
+ rapport = p.texte;
394
+ if (p.ok) {
395
+ // Resumed at a red, a proof restricted to the file the red names goes to the checks.
396
+ const auDeveloppeur = reprise
397
+ ? false
398
+ : apresLaPreuve({ rouges: p.rouges, pourLeDeveloppeur: pourLui, inchange }) === CODE;
399
+ const suite = reprise
400
+ ? 'reprise à un rouge : aux contrôles'
401
+ : p.rouges
402
+ ? 'au développeur'
403
+ : pourLui
404
+ ? 'aucun rouge ; au développeur, que nomme un constat du relecteur'
405
+ : inchange
406
+ ? 'aucun rouge : le plan dit « comportement inchangé », au développeur'
407
+ : 'aucun rouge : un lot de tests seul, aux contrôles';
408
+ ecrireRapport('preuve', `${p.resume} ; ${suite}.\n\n${p.texte}`, p.resultat);
409
+ if (!reprise && p.empreinte) {
410
+ garderLeVert('preuve', {
411
+ empreinte: p.empreinte,
412
+ rouges: p.rouges,
413
+ ms: p.ms,
414
+ texte: p.texte,
415
+ });
416
+ }
417
+ etape = auDeveloppeur ? CODE : CONTROLES;
418
+ tentative = auDeveloppeur ? 1 : 0;
419
+ return decision();
420
+ }
421
+ garderLeVert('preuve', null);
422
+ if (tentative <= RELANCES_TESTWRITER) {
423
+ ecrireRapport(
424
+ 'preuve',
425
+ `${p.resume} ; testwriter relancé (séance ${tentative + 1}).\n\n${p.texte}`,
426
+ p.resultat
427
+ );
428
+ etape = TESTS;
429
+ tentative++;
430
+ return decision();
431
+ }
432
+ return arreter('preuve', p.texte, { resultat: p.resultat });
433
+ }
434
+ if (etape === CODE) {
435
+ return code();
436
+ }
437
+ if (etape === CONTROLES) {
438
+ return controles();
439
+ }
440
+ if (etape === REFERENCES) {
441
+ return references();
442
+ }
443
+ if (etape === RELECTURE) {
444
+ return relecture();
445
+ }
446
+ if (etape === INTEGRATION) {
447
+ const r = lire('integration');
448
+ if (r.code === A_REPASSER) {
449
+ return arreter('a-repasser', fin(r.sortie, 40));
450
+ }
451
+ if (r.code !== 0) {
452
+ return refuser(
453
+ `Le script d'intégration refuse le lot (code ${r.code}).\n\n${fin(r.sortie, 60)}`,
454
+ `$ ${r.commande}\n${fin(r.sortie, 30)}`
455
+ );
456
+ }
457
+ maj.refus = null;
458
+ const branche = `agent/${ticket.id}`;
459
+ const commit = lire('commit');
460
+ commenter(
461
+ 'integration',
462
+ `${commit ? `commit ${commit} sur ${branche}` : 'lot commité'} ; la branche est en file.`
463
+ );
464
+ etape = EN_FILE;
465
+ return decision();
466
+ }
467
+ if (etape === EN_FILE) {
468
+ const f = lire('file');
469
+ if (f.etat === 'ferme') {
470
+ commenter('file', `${f.raison}.`);
471
+ etape = TRI;
472
+ return decision();
473
+ }
474
+ if (f.etat === 'en-file') {
475
+ return arreter('a-repasser', f.raison);
476
+ }
477
+ return refuser(`La file rouvre le ticket.\n\n${f.raison}`, f.raison);
478
+ }
479
+ if (etape === TRI) {
480
+ // The lot is on main: the tri of its discoveries, which neither stops nor undoes it.
481
+ lire('tri');
482
+ return decision({ fin: { code: 0 } });
483
+ }
484
+ return decision({ usage: `étape inconnue dans l'état : ${etape}` });
485
+
486
+ // The stop « integration » of the motive <motif> and the piece <piece>, the refusal of the lot
487
+ // kept in the memory (`refus`: `{ rapport, piece, empreinte, lance, relance }`, the fingerprint
488
+ // of the plan refused, whether a --depuis developpeur launched the developpeur on it, and whether
489
+ // a session so launched already left it unchanged once), which --depuis developpeur gives the
490
+ // developpeur.
491
+ function refuser(motif, piece) {
492
+ maj.refus = {
493
+ rapport: motif,
494
+ piece,
495
+ empreinte: lire('empreinte'),
496
+ lance: false,
497
+ relance: false,
498
+ };
499
+ return arreter('integration', motif, { piece });
500
+ }
501
+
502
+ function code() {
503
+ const fort = tentative >= SEANCES_DEVELOPPEUR;
504
+ const avant = lire('empreinteAvant');
505
+ const fiche = lire('seance', {
506
+ role: 'developpeur',
507
+ tentative,
508
+ rapport,
509
+ fort,
510
+ derniere: fort,
511
+ change: relanceSurLeRefus ? CHANGE_DU_REFUS : undefined,
512
+ });
513
+ relanceSurLeRefus = false;
514
+ const fortement = fort ? ' (opus)' : '';
515
+ // A question goes up to the supervisor; a red out of reach, to the testwriter its sheet sends
516
+ // it to, else up to the supervisor.
517
+ if (fiche.statut === 'BESOIN') {
518
+ return decision({
519
+ arret: { nom: 'besoin', statut: { role: 'developpeur', tentative, fiche } },
520
+ });
521
+ }
522
+ const renvoi = lire('renvoi');
523
+ if (renvoi) {
524
+ // The red that remains lies in the tests of the lot: the gesture `renvoi-au-testwriter`,
525
+ // the testwriter, the sending and the handover as its report, then the proof and the
526
+ // developpeur. `renvoiAuTestwriter` keeps the red output of the checks the sending before
527
+ // carried ('' for none), null after green checks: the same output twice in a row is a
528
+ // round trip without a new fact.
529
+ const sortie = m('controlesRouges') ?? '';
530
+ if (m('renvoiAuTestwriter') === sortie) {
531
+ if (lire('empreinte') === avant) {
532
+ inscrire({ etape: CODE, inchange: true }, 'inchange');
533
+ }
534
+ return arreter(
535
+ 'sans-livraison',
536
+ `La fiche de la séance ${tentative} du développeur renvoie une deuxième fois de suite au testwriter, sur la même sortie rouge des contrôles que le premier renvoi (aucune, ou la même), sans contrôles verts entre eux : le testwriter n'a pas levé ce rouge.\n\n${renvoi}`
537
+ );
538
+ }
539
+ maj.renvoiAuTestwriter = sortie;
540
+ commenter(
541
+ 'developpeur',
542
+ `séance ${tentative}${fortement} finie ; sa fiche renvoie le rouge au testwriter : le circuit relance le testwriter, puis la preuve et le développeur.`
543
+ );
544
+ geste('renvoi-au-testwriter');
545
+ etape = TESTS;
546
+ tentative = 1;
547
+ rapport = renvoi;
548
+ finale = false;
549
+ return decision();
550
+ }
551
+ if (fiche.statut === 'BLOQUÉ') {
552
+ return decision({
553
+ arret: { nom: 'hors-portee', statut: { role: 'developpeur', tentative, fiche } },
554
+ });
555
+ }
556
+ if (fiche.hors_plan?.length) {
557
+ return decision({ arret: { nom: 'hors-portee', horsDuPlan: { tentative, fiche } } });
558
+ }
559
+ // A copy the module of the language no longer reads is a red of the developpeur.
560
+ const illisible = lire('lecture');
561
+ if (illisible) {
562
+ const suite = suiteDuRougeDeLecture('developpeur', tentative);
563
+ if (suite.arret) {
564
+ return arreter(suite.arret, illisible.rapport);
565
+ }
566
+ commenter(
567
+ 'developpeur',
568
+ `séance ${tentative} finie ; la copie ne se lit plus, développeur relancé (séance ${suite.tentative}).\n\n${illisible.rapport}`
569
+ );
570
+ tentative = suite.tentative;
571
+ rapport = illisible.rapport;
572
+ return decision();
573
+ }
574
+ const inchangee = lire('empreinte') === avant;
575
+ const refus = m('refus');
576
+ if (inchangee && refus?.lance && refus.empreinte === avant) {
577
+ // The lot the integration refused, unchanged: as a merge queue lets a lot pass again only
578
+ // with a change, neither the gesture `rien-a-livrer` nor the checks of the copy, which
579
+ // the refusal does not see; the developpeur relaunched once with the refusal, then the
580
+ // stop goes up.
581
+ inscrire({ etape: CODE, inchange: true }, 'inchange');
582
+ if (refus.relance) {
583
+ return arreter(
584
+ 'sans-livraison',
585
+ `La séance ${tentative} du développeur ne change aucun fichier du plan (${plan}), une seconde fois sur le lot que l'intégration refuse.\n\n${refus.rapport}`,
586
+ { piece: refus.piece }
587
+ );
588
+ }
589
+ maj.refus = { ...refus, relance: true };
590
+ commenter(
591
+ 'developpeur',
592
+ `séance ${tentative}${fortement} finie sans changement, sur le lot que l'intégration refuse : le circuit le relance une fois, le refus comme rapport.`
593
+ );
594
+ tentative++;
595
+ rapport = rapportDuRefus(refus);
596
+ relanceSurLeRefus = true;
597
+ return decision();
598
+ }
599
+ if (inchangee && reprend && lire('livre')) {
600
+ // A resumed developpeur that finds the lot delivered: the checks judge it.
601
+ commenter(
602
+ 'developpeur',
603
+ `séance ${tentative} reprise sans changement, le plan garde la livraison d'avant : aux contrôles.`
604
+ );
605
+ inscrire({ etape: CODE, inchange: true }, 'inchange');
606
+ } else if (inchangee) {
607
+ // Nothing to deliver: the gesture `rien-a-livrer`, the checks judge the lot; red, the
608
+ // stop goes up.
609
+ geste('rien-a-livrer');
610
+ inscrire({ etape: CODE, inchange: true }, 'inchange');
611
+ maj.rienALivrer = `La séance ${tentative} du développeur ne change aucun fichier du plan (${plan}), et les contrôles restent rouges. Sa passation au ticket dit pourquoi :\n\n${lire('passation') ?? 'aucune'}`;
612
+ }
613
+ commenter('developpeur', `séance ${tentative}${fortement} finie, sa fiche lue.`);
614
+ etape = CONTROLES;
615
+ return decision();
616
+ }
617
+
618
+ function controles() {
619
+ const passeFinale = finale;
620
+ // The final pass: after a regeneration of the references, restricted to what it changed,
621
+ // the reds of the pass before it carried (none plays when it changed nothing); else the band
622
+ // of the lot, its base and its dependents. The checks of the plan after a
623
+ // regeneration that changed nothing: none plays, the reds of the checks before standing.
624
+ const regeneration = m('regeneration');
625
+ maj.regeneration = null;
626
+ const nomEtape = passeFinale ? 'passe-finale' : 'controles';
627
+ const reprise = m('reprise');
628
+ const vert = m('verts')?.[nomEtape];
629
+ if (
630
+ vert &&
631
+ !reprise &&
632
+ !regeneration &&
633
+ lire('empreinteEtape', { etape: nomEtape }) === vert.empreinte
634
+ ) {
635
+ // The step's inputs are those of its last green: its result is read back, not played.
636
+ releve(nomEtape, vert.ms);
637
+ maj.controlesRouges = null;
638
+ if (!passeFinale) {
639
+ etape = CONTROLES;
640
+ tentative = 0;
641
+ finale = true;
642
+ return decision();
643
+ }
644
+ maj.verifie = vert.arbre;
645
+ etape = lire('lotAccepte', { arbre: vert.arbre }) ? INTEGRATION : RELECTURE;
646
+ return decision();
647
+ }
648
+ const passe = !passeFinale
649
+ ? { arbre: null, restreinte: null }
650
+ : regeneration
651
+ ? { arbre: lire('arbreAvant'), restreinte: regeneration.restreinte }
652
+ : lire('passeFinale');
653
+ const k = lire('controles', {
654
+ finale: passeFinale,
655
+ restreinte: passe.restreinte,
656
+ reportes: regeneration?.reportes ?? null,
657
+ ...(reprise ? { fichiers: reprise.fichiers } : {}),
658
+ });
659
+ if (k.rouge || k.aRepasser) {
660
+ garderLeVert(nomEtape, null);
661
+ }
662
+ // The output of these checks, red, which a sending to the testwriter carries.
663
+ maj.controlesRouges = k.rouge ? k.texte : null;
664
+ // The outcome the bilan reads (scripts/bilan.mjs): with the reds, each its place and its
665
+ // text, by which it knows two checks that measured the same thing.
666
+ const resultat = issue => ({
667
+ issue,
668
+ finale: passeFinale,
669
+ rouges: k.rouges.map(r => `${r.paquet} : ${r.texte}`),
670
+ });
671
+ rapport = k.texte;
672
+ // A developpeur who had nothing to deliver before these checks.
673
+ const rien = m('rienALivrer');
674
+ maj.rienALivrer = null;
675
+ // A stop of the checks: <phrase>, then the report, its reds also kept apart, as its piece;
676
+ // the stop kept at the checks keeps their outcome.
677
+ const arret = (nom, phrase, lieu = null) => {
678
+ const avant = phrase ? `${phrase}\n\n` : '';
679
+ return arreter(nom, `${avant}${k.complet}`, {
680
+ rouges: k.rouges,
681
+ motif: `${avant}${k.sansListe}`,
682
+ etape: lieu,
683
+ resultat: lieu ? null : resultat(nom === 'a-repasser' ? 'a-repasser' : 'rouge'),
684
+ });
685
+ };
686
+ const suivante = tentative + 1;
687
+ const regenereSur = m('regenereSur');
688
+ // A final pass with a red of a reference, mixed with others or not, or a debt the lot
689
+ // lowers: their regeneration, once for this pass, but for a reference the checks had
690
+ // regenerated on this same tree, whose inputs have not changed since; the reds that remain
691
+ // then go each to its owner.
692
+ const dejaRegenerees = regenereSur && regenereSur.arbre === passe.arbre ? regenereSur.noms : [];
693
+ const aRegenerer =
694
+ passeFinale && !regeneration && (k.rouge || k.notes.length > 0)
695
+ ? lire('referencesDesRouges', { lieux: k.lieux, aElaguer: k.notes.length > 0 }).filter(
696
+ r => !dejaRegenerees.includes(r.nom)
697
+ )
698
+ : [];
699
+ // The checks of the plan with a red of a reference, mixed with others or not: its
700
+ // regeneration before any red goes to the developpeur, as Bazel builds a genrule before the
701
+ // tests that read it, but for a reference regenerated on this same tree; mixed with other
702
+ // reds, the checks of the plan play again on the regenerated tree, which judges a test
703
+ // that reads the reference; alone, the final pass that is due (BPScript 320.6.5: a test
704
+ // that reads the turbo.json, red beside their guard, sent to the developpeur, who could not
705
+ // write them).
706
+ const regenereesAuxControles =
707
+ !passeFinale && k.references.length && regenereSur?.arbre === lire('arbreApres')
708
+ ? regenereSur.noms
709
+ : [];
710
+ const avantLesControles = passeFinale
711
+ ? []
712
+ : k.references.filter(r => !regenereesAuxControles.includes(r.nom));
713
+ if (avantLesControles.length) {
714
+ const noms = avantLesControles.map(r => r.nom);
715
+ const meles = k.rouge || k.aRepasser;
716
+ geste('regeneration');
717
+ const phrase = `${k.resume} ; des rouges sont ceux de références (${noms.join(', ')}) : à leur régénération, puis ${meles ? 'les contrôles du plan' : 'la passe finale'}.`;
718
+ ecrireRapport(
719
+ 'controles',
720
+ phrase,
721
+ resultat(meles ? 'rouge' : 'vert'),
722
+ meles ? `${k.texte}${k.avertissements}` : `${phrase}${k.avertissements}`
723
+ );
724
+ // Mixed, the developpeur who had nothing to deliver, for the checks of the plan that
725
+ // follow; green, the final pass, its sessions counted apart, which a developpeur with
726
+ // nothing to deliver before green checks does not concern.
727
+ if (meles) {
728
+ maj.rienALivrer = rien;
729
+ } else {
730
+ maj.renvoiAuTestwriter = null;
731
+ tentative = 0;
732
+ }
733
+ // The report of the reds of the plan, which go to the developpeur when a command of the
734
+ // project refuses the lot, as at the final pass (BPScript 320.10).
735
+ maj.aRegenerer = {
736
+ noms,
737
+ notes: [],
738
+ suite: meles ? 'controles' : 'passe',
739
+ rouges: meles ? k.tous : [],
740
+ auDeveloppeur: meles && k.auDeveloppeur && !k.arbitrer ? k.texte : null,
741
+ };
742
+ etape = REFERENCES;
743
+ finale = true;
744
+ return decision();
745
+ }
746
+ if (aRegenerer.length) {
747
+ const noms = aRegenerer.map(r => r.nom);
748
+ geste('regeneration');
749
+ ecrireRapport(
750
+ 'controles',
751
+ `${k.resume} ; ${k.rouge ? 'des rouges sont ceux de références' : 'la dette des gardes baisse'} (${noms.join(', ')}) : à leur régénération.`,
752
+ resultat(k.rouge ? 'rouge' : 'vert'),
753
+ `${k.texte}${k.avertissements}`
754
+ );
755
+ // The report of the reds of the plan, which go to the developpeur when a command of the
756
+ // project refuses the lot.
757
+ maj.aRegenerer = {
758
+ noms,
759
+ rouges: k.tous,
760
+ notes: k.notes,
761
+ auDeveloppeur: k.auDeveloppeur && !k.arbitrer ? k.texte : null,
762
+ };
763
+ etape = REFERENCES;
764
+ finale = true;
765
+ return decision();
766
+ }
767
+ if (k.rouge && passeFinale && k.horsTitre.length) {
768
+ return arret(
769
+ 'controles',
770
+ `La passe finale est rouge dans ${k.horsTitre.join(', ')}, hors du plan du ticket (${plan}) : le développeur n'est pas relancé. Le superviseur étend le plan à ce paquet (\`--etendre\`), le rouge allant ensuite au développeur, ou fait corriger le lot (\`--depuis developpeur\`, le rouge en \`--contexte\`).`
771
+ );
772
+ }
773
+ if (k.rouge && !k.auDeveloppeur) {
774
+ return arret(
775
+ 'controles',
776
+ `Aucun paquet du plan (${plan}) ne tient ce rouge de la passe finale (un rouge de la racine, ou que rien ne situe).`
777
+ );
778
+ }
779
+ if (k.rouge && k.arbitrer) {
780
+ return arret(
781
+ 'controles',
782
+ 'Les rouges du plan sont des constats à arbitrer : aucun développeur ne les tranche.'
783
+ );
784
+ }
785
+ if (k.rouge && lire('mecanique')) {
786
+ // A mechanical lot: no testwriter nor developpeur lifts the red of its command.
787
+ return arret(
788
+ 'controles',
789
+ `Le ticket est mécanique (${ticket.sorte.raison}) : ni testwriter ni développeur ne lève ce rouge du lot de sa commande. Le superviseur fait corriger le lot (\`--depuis developpeur\`, le rouge en \`--contexte\`), corrige le geste dans la copie puis \`--reprendre\`, ou arrête le circuit (\`--arreter\`).`
790
+ );
791
+ }
792
+ // The stop stands at the developpeur's step, which a resumption plays again.
793
+ if (k.rouge && rien) {
794
+ return arret('sans-livraison', rien, CODE);
795
+ }
796
+ if (k.rouge && suivante <= SEANCES_DEVELOPPEUR) {
797
+ // The red goes back to the step that carries it, by the files it names (scripts/reprise.mjs).
798
+ const portes = lire('portes', { lieux: k.lieux });
799
+ const a = attribuerLeRouge({ lieux: k.lieux, portes });
800
+ if (!a.etape) {
801
+ return arret('controles', `Le rouge n'est attribué à aucune étape : ${a.motif}.`);
802
+ }
803
+ if (a.etape === 'testwriter') {
804
+ const relances = (m('relancesTestwriter') ?? 0) + 1;
805
+ if (relances > RELANCES_TESTWRITER + 1) {
806
+ return arret('controles', null);
807
+ }
808
+ maj.relancesTestwriter = relances;
809
+ // The final pass red in one test file alone: that file is replayed, then the checks and
810
+ // the final pass restricted to what it reaches, with no session for the rest of the lot.
811
+ maj.reprise =
812
+ passeFinale && a.fichiers.length === 1 && portes.tests.includes(a.fichiers[0])
813
+ ? { fichiers: a.fichiers }
814
+ : null;
815
+ ecrireRapport(
816
+ 'controles',
817
+ `${k.resume} ; le rouge nomme ${a.fichiers.join(', ')} : testwriter relancé (séance 1).`,
818
+ resultat('rouge'),
819
+ `${k.texte}${k.avertissements}`
820
+ );
821
+ etape = TESTS;
822
+ tentative = 1;
823
+ finale = false;
824
+ return decision();
825
+ }
826
+ maj.reprise = null;
827
+ ecrireRapport(
828
+ 'controles',
829
+ `${k.resume} ; développeur relancé (séance ${suivante}).`,
830
+ resultat('rouge'),
831
+ `${k.texte}${k.avertissements}`
832
+ );
833
+ etape = CODE;
834
+ tentative = suivante;
835
+ return decision();
836
+ }
837
+ if (k.rouge) {
838
+ return arret('controles', null);
839
+ }
840
+ if (k.aRepasser) {
841
+ return arret('a-repasser', null);
842
+ }
843
+ ecrireRapport('controles', `${k.resume}.`, resultat('vert'), `${k.resume}.${k.avertissements}`);
844
+ // Green checks: a sending of the developpeur to the testwriter may come again.
845
+ maj.renvoiAuTestwriter = null;
846
+ maj.relancesTestwriter = 0;
847
+ const entierement = !reprise && !regeneration;
848
+ if (!passeFinale) {
849
+ if (entierement && k.empreinte) {
850
+ garderLeVert('controles', { empreinte: k.empreinte, ms: k.ms });
851
+ }
852
+ // The checks green: the final pass, its sessions counted apart.
853
+ etape = CONTROLES;
854
+ tentative = 0;
855
+ finale = true;
856
+ return decision();
857
+ }
858
+ // The whole pass green on this lot; the lot the last review accepted goes to the
859
+ // integration, any other to the review.
860
+ // A final pass green on the band of the lot (after a regeneration, on what it changed, or not
861
+ // played when it changed nothing) verifies its tree: the lot accepted on it goes to the
862
+ // integration.
863
+ if (passe.arbre) {
864
+ maj.verifie = passe.arbre;
865
+ }
866
+ if (entierement && k.empreinte) {
867
+ garderLeVert('passe-finale', { empreinte: k.empreinte, arbre: passe.arbre, ms: k.ms });
868
+ }
869
+ if (reprise) {
870
+ // The restricted pass is green: the resumption ends.
871
+ maj.reprise = null;
872
+ }
873
+ etape = lire('lotAccepte', { arbre: passe.arbre }) ? INTEGRATION : RELECTURE;
874
+ return decision();
875
+ }
876
+
877
+ function references() {
878
+ // The references to regenerate and the reds of the pass before, kept in the state from
879
+ // the pass that called for them (the checks of the plan, `suite`, or the final pass), so
880
+ // that a regeneration resumed knows them.
881
+ const a = m('aRegenerer');
882
+ if (!a) {
883
+ return arreter(
884
+ 'references',
885
+ "L'état du circuit ne garde pas les références à régénérer : la passe finale les redonne (`--depuis developpeur`)."
886
+ );
887
+ }
888
+ // A command of the project that refuses beside reds of the plan, within the developpeur's
889
+ // sessions: the copy restored, those reds go to him with its output, then the pass that
890
+ // called for the regeneration, the checks of the plan or the final pass.
891
+ const suivante = tentative + 1;
892
+ const auLot = Boolean(a.auDeveloppeur) && suivante <= SEANCES_DEVELOPPEUR;
893
+ const g = lire('regeneration', {
894
+ noms: a.noms,
895
+ notes: a.notes,
896
+ suite: a.suite ?? null,
897
+ refusAuLot: auLot,
898
+ });
899
+ if (g.refus) {
900
+ const texte = [
901
+ `La régénération des références refuse le lot ; la copie est rendue telle qu'avant elle, et les rouges du plan vont au développeur (séance ${suivante}).`,
902
+ '',
903
+ ...g.refus,
904
+ ].join('\n');
905
+ ecrireRapport('references', texte, { regenerees: [], fichiers: [] });
906
+ rapport = `${texte}\n\n${a.auDeveloppeur}`;
907
+ maj.aRegenerer = null;
908
+ maj.rienALivrer = null;
909
+ etape = CODE;
910
+ tentative = suivante;
911
+ finale = a.suite !== 'controles';
912
+ return decision();
913
+ }
914
+ ecrireRapport('references', g.texte, { regenerees: g.regenerees, fichiers: g.fichiers });
915
+ // After the checks, the pass that judges the regenerated tree, which does not regenerate
916
+ // again the references just regenerated on it: beside other reds, the checks of the plan
917
+ // again (none plays when the regeneration changed nothing, the reds of the checks before
918
+ // standing); without, the final pass that is due. After a final pass, the pass restricted
919
+ // to what the regeneration changed, with the reds of the pass before.
920
+ maj.regenereSur = a.suite ? { arbre: lire('arbreApres'), noms: a.noms } : null;
921
+ maj.regeneration =
922
+ a.suite === 'passe'
923
+ ? null
924
+ : a.suite === 'controles'
925
+ ? g.fichiers.length
926
+ ? null
927
+ : { reportes: { rouges: a.rouges, rejouee: false } }
928
+ : {
929
+ restreinte: g.restreinte,
930
+ reportes: { rouges: a.rouges, rejouee: g.fichiers.length > 0 },
931
+ };
932
+ maj.aRegenerer = null;
933
+ etape = CONTROLES;
934
+ finale = a.suite !== 'controles';
935
+ return decision();
936
+ }
937
+
938
+ function relecture() {
939
+ const v = lire('relecture');
940
+ // A question for the owner: nothing is committed nor relaunched before his answer.
941
+ if (v.fiche.question) {
942
+ return arreter(
943
+ 'besoin',
944
+ `Le relecteur attend une réponse : ${v.fiche.question}\n\nLe verdict :\n\n${v.texte}`,
945
+ {
946
+ piece: v.fiche.piece,
947
+ question: `Le relecteur demande : ${v.fiche.question}`,
948
+ qui: RESPONSABLE,
949
+ }
950
+ );
951
+ }
952
+ if (v.verdict === 'ACCEPTÉ') {
953
+ // The review that accepts the lot closes every finding, each one it judged lifted
954
+ // (`suiviDesConstats`).
955
+ maj.constats = [];
956
+ if (!v.arbre || m('verifie') === v.arbre) {
957
+ commenter('relecture', 'ACCEPTÉ ; le lot va à l’intégration.');
958
+ etape = INTEGRATION;
959
+ return decision();
960
+ }
961
+ // The final pass has not played on the lot accepted: its band plays once, then the
962
+ // integration.
963
+ commenter(
964
+ 'relecture',
965
+ 'ACCEPTÉ ; la passe finale sur la bande du lot (sa base et ses dépendants), qui n’a pas joué sur ce lot, puis l’intégration.'
966
+ );
967
+ etape = CONTROLES;
968
+ tentative = 0;
969
+ finale = true;
970
+ return decision();
971
+ }
972
+ // The reviews since the last ACCEPTÉ: a lot the queue sent back starts a new count.
973
+ const rendus = lire('rendus');
974
+ if (rendus >= RELECTURES) {
975
+ return arreter(
976
+ 'relecture-arret',
977
+ `${rendus} relectures ont rendu le lot : le circuit s'arrête à la troisième.\n\nLe dernier verdict :\n\n${v.texte}`
978
+ );
979
+ }
980
+ // The findings still open once the sheet is read (`constatsOuverts` of scripts/circuit.mjs),
981
+ // or its stop for a finding without a valid recipient.
982
+ const lus = lire('constats');
983
+ if (lus.arret) {
984
+ return decision({ arret: lus.arret });
985
+ }
986
+ maj.constats = lus.constats;
987
+ const saute =
988
+ arretDuTestwriterSaute(
989
+ {
990
+ constats: lus.constats,
991
+ sansTests: ouverts(lus.constats, 'testwriter').length > 0 && lire('sansTests'),
992
+ paquets: ticket.paquets,
993
+ },
994
+ v.texte
995
+ ) ??
996
+ arretDuGesteMecanique(
997
+ { constats: lus.constats, mecanique: lire('mecanique'), sorte: ticket.sorte },
998
+ v.texte
999
+ );
1000
+ if (saute) {
1001
+ return decision({ arret: saute });
1002
+ }
1003
+ const auTestwriter = ouverts(lus.constats, 'testwriter').length > 0;
1004
+ etape = auTestwriter ? TESTS : CODE;
1005
+ tentative = 1;
1006
+ rapport = null;
1007
+ finale = false;
1008
+ commenter(
1009
+ 'relecture',
1010
+ `RENDU (relecture ${rendus}) ; le circuit relance ${auTestwriter ? 'le testwriter' : 'le développeur'}, ses ${lus.constats.length} constat(s) ouvert(s) dans la consigne de chaque séance, puis la passe finale sur la bande du lot (sa base et ses dépendants), et le relecteur sur la différence.`
1011
+ );
1012
+ return decision();
1013
+ }
1014
+ }
1015
+
1016
+ // The name of the stop of an agent's sheet that is not FAIT: « besoin » for a question, else
1017
+ // « hors-portee ».
1018
+ const nomDuStatut = fiche => (fiche.statut === 'BESOIN' ? 'besoin' : 'hors-portee');