@roomi-fields/grillhouse 0.54.0 → 0.55.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +75 -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 +16 -0
  77. package/dist/temporal/places/client.js +25 -1
  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 +32 -27
  104. package/docs/architecture/installation.md +43 -32
  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/consommation-des-passes.mjs +67 -31
  118. package/scripts/consommation.mjs +152 -24
  119. package/scripts/copies-finies.mjs +15 -35
  120. package/scripts/dernier-vert.mjs +4 -5
  121. package/scripts/dette.mjs +5 -3
  122. package/scripts/droits.mjs +2 -2
  123. package/scripts/echantillonneur-de-la-passe.mjs +7 -31
  124. package/scripts/engendres.mjs +5 -61
  125. package/scripts/enveloppe/enveloppe.mjs +30 -34
  126. package/scripts/enveloppe/travail-de-la-copie.mjs +5 -0
  127. package/scripts/etapes.mjs +21 -7
  128. package/scripts/etat-du-depot.mjs +61 -0
  129. package/scripts/faits-du-circuit.mjs +7 -4
  130. package/scripts/fermeture-de-la-machine.d.mts +6 -4
  131. package/scripts/fermeture-de-la-machine.mjs +12 -16
  132. package/scripts/fichier-du-poste.d.mts +9 -0
  133. package/scripts/file-des-tickets.d.mts +0 -18
  134. package/scripts/file-des-tickets.mjs +0 -42
  135. package/scripts/fusion-du-changelog.mjs +1 -1
  136. package/scripts/greffons.mjs +282 -17
  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 +40 -3
  169. package/scripts/mesure-de-la-machine.mjs +201 -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.mjs +4 -0
  174. package/scripts/montee.mjs +22 -1
  175. package/scripts/nuit-de-pc2.mjs +628 -0
  176. package/scripts/nuit.sh +8 -131
  177. package/scripts/paquets.mjs +1 -1
  178. package/scripts/passe-de-la-machine.mjs +340 -103
  179. package/scripts/place-du-circuit.d.mts +15 -0
  180. package/scripts/place-du-circuit.mjs +32 -0
  181. package/scripts/places-de-la-machine.mjs +148 -626
  182. package/scripts/places-du-serveur.mjs +26 -13
  183. package/scripts/plafond-de-la-machine.d.mts +8 -13
  184. package/scripts/plafond-de-la-machine.mjs +26 -56
  185. package/scripts/registre-des-entrees.mjs +57 -0
  186. package/scripts/regles-des-places.d.mts +82 -50
  187. package/scripts/regles-des-places.mjs +192 -156
  188. package/scripts/retirer-copie.sh +9 -2
  189. package/scripts/seances.mjs +181 -63
  190. package/scripts/secours.mjs +95 -0
  191. package/scripts/services-du-noyau.mjs +11 -19
  192. package/scripts/sous-commandes.mjs +1 -0
  193. package/scripts/sous-modules.sh +1 -1
  194. package/scripts/superviseur.mjs +98 -20
  195. package/scripts/table-des-consommations.d.mts +9 -0
  196. package/scripts/table-des-consommations.mjs +35 -0
  197. package/scripts/tableau.mjs +33 -19
  198. package/scripts/taches-du-graphe.mjs +124 -2
  199. package/scripts/transitions.d.mts +27 -5
  200. package/scripts/transitions.mjs +122 -104
  201. package/scripts/verdict-de-la-nuit.d.mts +13 -0
  202. package/scripts/verdict-de-la-nuit.mjs +34 -7
  203. package/scripts/verrou-de-fichier.mjs +1 -2
  204. package/scripts/workflows-du-cadre.mjs +2 -2
  205. package/skills/developpeur/SKILL.md +8 -2
  206. package/skills/direct/SKILL.md +5 -0
  207. package/skills/explorateur/SKILL.md +10 -1
  208. package/skills/grill/SKILL.md +2 -4
  209. package/skills/pitmaster/SKILL.md +14 -7
  210. package/skills/pitmaster/references/consigne-agent.md +1 -1
  211. package/skills/relecteur/SKILL.md +4 -1
  212. package/skills/testwriter/SKILL.md +15 -2
  213. package/cadre/templates/projet/.env.example +0 -57
  214. package/cadre/templates/projet/.github/workflows/nuit.yml +0 -139
  215. package/cadre/templates/projet/deployment/README.md +0 -98
  216. package/cadre/templates/projet/deployment/docs/01-INSTALL.md +0 -145
  217. package/cadre/templates/projet/deployment/docs/02-CONFIGURATION.md +0 -117
  218. package/cadre/templates/projet/deployment/docs/03-API.md +0 -264
  219. package/cadre/templates/projet/deployment/docs/04-TROUBLESHOOTING.md +0 -262
  220. package/cadre/templates/projet/deployment/scripts/install.ps1 +0 -100
  221. package/cadre/templates/projet/deployment/scripts/start.ps1 +0 -61
  222. package/cadre/templates/projet/deployment/scripts/stop.ps1 +0 -37
  223. package/cadre/templates/projet/deployment/scripts/test.ps1 +0 -118
  224. package/cadre/templates/projet/ecosystem.config.cjs +0 -73
  225. package/cadre/templates/projet/src/config.ts +0 -68
  226. package/cadre/templates/projet/src/errors.ts +0 -102
  227. package/cadre/templates/projet/src/index.ts +0 -46
  228. package/cadre/templates/projet/src/services/.gitkeep +0 -8
  229. package/cadre/templates/projet/src/types/index.ts +0 -24
  230. package/cadre/templates/projet/src/utils/logger.ts +0 -106
  231. package/cadre/templates/projet/tests/unit/config.spec.ts +0 -68
  232. package/cadre/templates/projet/tests/unit/errors.spec.ts +0 -132
  233. package/cadre/templates/projet/tests/unit/types.spec.ts +0 -73
  234. package/cadre/templates/projet/tsconfig.build.json +0 -14
  235. package/scripts/flux-de-la-nuit.mjs +0 -39
  236. package/scripts/garde-de-la-memoire.mjs +0 -231
  237. package/scripts/repli-de-la-nuit.mjs +0 -184
@@ -1,141 +1,62 @@
1
1
  #!/usr/bin/env node
2
- // The commit of a lot on its ticket's branch (packages/grillhouse/docs/architecture/entree.md §3.1
3
- // « Actes de la file », §5.1): the mechanical steps of one integration, run by the circuit of the ticket (scripts/circuit.mjs)
4
- // once the reviewer has accepted the lot, which the circuit builds from the ticket's copy. It
5
- // commits the lot on the branch of the ticket, or refuses it with the full output of the step that
6
- // refused. The circuit of the ticket then sends the branch to the queue of the project (the
7
- // workflow `file:<racine>`, src/temporal/file/deroule.ts), which brings it onto main. Run from any
8
- // working tree of the repository, it works on the main tree, found from git's common directory.
2
+ // The entry of a lot into the queue (packages/grillhouse/docs/architecture/entree.md §3.1
3
+ // « Actes de la file », §5.1), run by the circuit of the ticket (scripts/circuit.mjs) at 5.1, once
4
+ // the reviewer has accepted the lot the final pass committed in the ticket's copy and judged. It
5
+ // gives that commit its final message, without changing its tree, or refuses it with the full output
6
+ // of the step that refused. The circuit of the ticket then sends the branch to the queue of the
7
+ // project (the workflow `file:<racine>`, src/temporal/file/deroule.ts), which brings it onto main.
8
+ // Run from any working tree of the repository, it works on the main tree, found from git's common
9
+ // directory.
9
10
  //
10
- // npx grillhouse integrer --ticket <id>
11
- // [--tests <patch>] [--code <patch>] --message <file> [--references <file>]
11
+ // npx grillhouse integrer --ticket <id> [--message <file>]
12
12
  //
13
13
  // One delivery is one ticket: the ticket gives its branch `agent/<ticket>` and its copy
14
- // (`.claude/worktrees/<ticket>`, the one the lot was written in, when it exists); a second
15
- // --ticket is a usage error, named. In order, each step refusing stops the run:
14
+ // (`.claude/worktrees/<ticket>`, which holds the commit of the lot); a second --ticket is a usage
15
+ // error, named. In order, each step refusing stops the run:
16
16
  // 0. the keys of the project, read from the package.json of the main tree: its generated files
17
- // (`grillhouse.engendres`, scripts/engendres.mjs) and its tools (`grillhouse.outils`,
18
- // scripts/outils-cles.mjs), a faulty key refused by its name before any work;
17
+ // (`grillhouse.engendres`, scripts/engendres.mjs), its tools (`grillhouse.outils`,
18
+ // scripts/outils-cles.mjs) and its data, a faulty key refused by its name before any work;
19
19
  // 1. the verdict: the ticket has `ACCEPTÉ` as its last reviewer verdict (`ACCEPTÉ` or
20
20
  // `RENDU` at the start of a comment of the author `relecteur`; another author's is none) and, when labelled `arbitrage`, each arbitrage
21
21
  // (`estArbitrage`: a « ## Arbitrage » comment, the supervisor's) is settled
22
22
  // (`arbitrageTranche`: `### Verdict — tranché`, or a « ## Réponse du
23
23
  // responsable » comment after it): `refusArbitrage`, the one rule of the label, which the
24
24
  // circuit plays too at its launch and at each resumption (scripts/circuit.mjs);
25
- // 2. the lots: the tests lot touches only what the testwriter writes (`estUnTest` of the module
26
- // of the language: test files and the shared test material), the code lot none of it; each
27
- // file judged on the tree where it exists, the ticket's copy for a file present after the
28
- // lot, the main tree for one the lot deletes or renames away;
29
- // 3. the main tree: every file of the lots is unmodified there; the ticket's copy is on its
30
- // branch and carries the lot and nothing else: a modified or untracked file outside the lot
31
- // refuses, named (what an ignored folder such as node_modules holds is not work);
32
- // 4. a clean integration copy (`.claude/worktrees/integration`) on HEAD, made ready by the
33
- // replay (scripts/integration/rejeu.mjs: submodules by scripts/sous-modules.sh, dependencies
34
- // in agreement with the lock file and the manifests, mounts);
35
- // 5. the lots, applied in three ways in the copy, tests first, without the files a reference
36
- // writes in full; the files of the lot in the
37
- // ticket's copy are compared with the copy's own base plus the lot, not with the integration
38
- // copy. Once the lots are in the copy, the references that write package-lock.json regenerate
39
- // (below), then the replay makes the dependencies agree with the lock file and the manifests
40
- // of the copy (`npm ci`, as the continuous integration runs it); an install that fails refuses
41
- // the lot, « Les dépendances de la copie ne s'installent pas. »; then the other references
42
- // regenerate (`installerEtRegenerer` of scripts/engendres.mjs);
43
- // 6. the commit in the copy, its hooks included, under GRILLHOUSE_INTEGRATION=1: a pre-commit
44
- // hook that plays the guards skips them, as the final pass plays them; nothing is verified
45
- // here: the queue lays the branch on the tip of main, and its final pass judges the lot before
46
- // main moves (scripts/integration/file.mjs); the commit committed is the commit that pass
47
- // judges;
48
- // 7. the branch `agent/<ticket>` is set on that commit, the ticket's copy follows it and is
49
- // removed by `scripts/retirer-copie.sh` (no `--jetable`; `--garder-travail`: the working
50
- // directory of the ticket's circuit, `<copie>.travail`, stays for the circuit that still runs,
51
- // and the queue removes it at the ticket's closure): a refusal, a locked copy for
52
- // example, is written to the ticket, the commit stands. The ticket is labelled
53
- // `en-file`, which the queue removes. main does not move here.
25
+ // 2. the commit of the lot (`refusDuLot`): the copy is on its branch, its HEAD is the commit the
26
+ // circuit posed, it holds no change since, and the tree of that commit is in the registry of the
27
+ // trees judged (scripts/arbres-juges.mjs), as bors enters only the tree it tested;
28
+ // 3. the main tree: every file of the lot is unmodified there;
29
+ // 4. the commit takes the message, its hooks included, under GRILLHOUSE_INTEGRATION=1 (a
30
+ // pre-commit hook that plays the guards skips them, as the final pass plays them; commit-msg
31
+ // judges the message), its tree unchanged: a commit a hook refuses, or whose tree it changes,
32
+ // is left as it was;
33
+ // 5. the ticket is labelled `en-file`, which the queue removes, and the copy is removed by
34
+ // `scripts/retirer-copie.sh` (no `--jetable`; `--garder-travail`: the working directory of the
35
+ // ticket's circuit, `<copie>.travail`, stays for the circuit that still runs, and the queue
36
+ // removes it at the ticket's closure): a refusal, a locked copy for example, is written to the
37
+ // ticket, the commit stands. main does not move here, and main advanced since the judgement
38
+ // sends nothing back: the queue lays the branch on the tip of main and judges it again.
54
39
  //
55
- // The references written in full are the generated files the project declares
56
- // (`grillhouse.engendres`), then the frame's the circuit hands over (`--references`, a JSON file the
57
- // circuit writes from its one list, `lesReferences` of scripts/circuit.mjs): each `{ nom, commande,
58
- // fichiers, lit, entiers, cadre }`, `entiers` the files of `fichiers` its command writes in full,
59
- // `lit` the files it reads (paths, directories or glob patterns, as `couvertPar` of
60
- // scripts/engendres.mjs reads them). As a genrule of Bazel writes its output again on the merged
61
- // tree, and npm install writes package-lock.json again after a merge, a file of the lot a reference
62
- // writes in full is not applied: main's version stays, and each reference whose files or reads the
63
- // lot touches plays in the copy, on main of the moment, before the commit, through the mounts, with
64
- // the tools of the project, and what it writes enters the commit (`regenerer` of
65
- // scripts/engendres.mjs): one that writes package-lock.json before the install, the others after it
66
- // (`installerEtRegenerer`). A command of the project at another code than 0, one of
67
- // the frame on a real failure (126, 127, a signal), or a file it changes that its `fichiers` do not
68
- // cover, refuses the lot, the command, its code and its output named. A conflict on any other file
69
- // refuses it, as the three-way application says. A generated file of the project the lot removes
70
- // from the key (`encoreDeclares` of scripts/engendres.mjs, read in the copy once the lots are
71
- // applied) follows the lot: its deletion is done, any other change applied, its command not played.
72
- //
73
- // What steps 2, 3 and 5 read of a lot is its files: each file added, modified or deleted, a
74
- // rename counting its source and its destination (named as the file is, not as git quotes it in
75
- // the patch), a copy its destination only. Step 2 judges them against the testwriter's files, step 3
76
- // against the main tree and the ticket's copy, and step 5 compares them with the copy's own base
77
- // plus the lot.
78
- //
79
- // The main tree is not touched. The duration is written at the end.
80
- // One integration runs at a time (`.git/integration.lock`): another waits for the end of the
81
- // running one; a lock whose process is gone is taken over. Exit code: 0 committed, 1 refused,
82
- // 2 usage, 3 refused because a lot does not apply on main (`LOT_NE_S_APPLIQUE_PAS` of
83
- // scripts/etapes.mjs).
84
- // Called without a lot to apply (neither `--tests` nor `--code`), it does not commit: the lot is
85
- // already on main (`lotSurMain`, exit 0, nothing done) or it is refused by the name `lot-absent`
86
- // (exit 1), the same rule the circuit's resumption reads (scripts/activites.mjs).
40
+ // The main tree is not touched. The duration is written at the end. Exit code: 0 done, 1 refused,
41
+ // 2 usage.
42
+ // Called without a message, it does not commit: the lot is already on main (`lotSurMain`, exit 0,
43
+ // nothing done) or it is refused by the name `lot-absent` (exit 1), the same rule the circuit's
44
+ // resumption reads (scripts/activites.mjs).
87
45
  import { spawnSync } from 'node:child_process';
88
- import { existsSync, readFileSync } from 'node:fs';
46
+ import { existsSync } from 'node:fs';
89
47
  import path from 'node:path';
90
48
  import { pathToFileURL } from 'node:url';
91
49
  import { arbitrageTranche, estArbitrage } from '../arbitrages.mjs';
92
- import {
93
- couvertPar,
94
- engendresDe,
95
- installerEtRegenerer,
96
- partDesLots,
97
- poserLesRetires,
98
- touchesPar,
99
- } from '../engendres.mjs';
100
- import { LOT_NE_S_APPLIQUE_PAS } from '../etapes.mjs';
101
- import { langageDe } from '../langages.mjs';
50
+ import { arbreEstJuge } from '../arbres-juges.mjs';
51
+ import { commitDuLot, marquerLeLot } from '../etat-du-depot.mjs';
52
+ import { engendresDe } from '../engendres.mjs';
102
53
  import { prefixe } from '../prefixe-des-tickets.mjs';
103
54
  import { commitsDelivering, gitLog } from '../un-commit-par-ticket.mjs';
104
55
  import { avecLesDonnees, donneesDe } from '../donnees-cles.mjs';
105
56
  import { matieresDeclareesDe } from '../matieres-cles.mjs';
106
57
  import { avecLesOutils, empreintesDe, outilsDe } from '../outils-cles.mjs';
107
- import { lacherVerrou, prendreVerrou } from '../verrou-de-fichier.mjs';
108
- import { ouvrirCopie, RETIRER_COPIE } from './rejeu.mjs';
58
+ import { monterDans, RETIRER_COPIE } from './rejeu.mjs';
109
59
  import { verdictDe } from './verdict.mjs';
110
- import { ouvrirBase } from '../mesure/base-de-passe.mjs';
111
-
112
- // A file name as git writes it in a patch: a name with a character outside ASCII, a quote, a
113
- // backslash or a control character comes between quotes with C escapes (`\303\251` for `é`).
114
- // Returns the name itself.
115
- function nomDeGit(ecrit) {
116
- if (!ecrit.startsWith('"')) {
117
- return ecrit;
118
- }
119
- const octets = [];
120
- const echappes = { n: 10, t: 9, r: 13, a: 7, b: 8, f: 12, v: 11 };
121
- const corps = Buffer.from(ecrit.slice(1, -1), 'utf8');
122
- for (let i = 0; i < corps.length; i++) {
123
- if (corps[i] !== 0x5c) {
124
- octets.push(corps[i]);
125
- continue;
126
- }
127
- const suite = String.fromCharCode(corps[i + 1]);
128
- const octal = /^[0-7]{3}/.exec(corps.subarray(i + 1, i + 4).toString('latin1'));
129
- if (octal) {
130
- octets.push(Number.parseInt(octal[0], 8));
131
- i += 3;
132
- } else {
133
- octets.push(echappes[suite] ?? corps[i + 1]);
134
- i += 1;
135
- }
136
- }
137
- return Buffer.from(octets).toString('utf8');
138
- }
139
60
 
140
61
  // The refusal for the verdicts of one ticket, or null. `ticket` and `comments` are Beads' JSON.
141
62
  export function refusVerdicts(ticket, comments) {
@@ -170,27 +91,6 @@ export function refusArbitrage(ticket, comments) {
170
91
  return null;
171
92
  }
172
93
 
173
- // The refusal for the files of the lots, or null; the tests lot holds only what the testwriter
174
- // writes, the code lot none of it. The files are relative to the repository root; each is judged
175
- // on the tree where it exists, as each side of a diff is read in its own tree: a file present
176
- // after the lot on <apres> (the ticket's copy), one the lot deletes or renames away on <avant>
177
- // (the main tree), so a lot that creates or moves a package is read with its own map.
178
- export function refusLots(tests, code, { avant, apres }) {
179
- const testwriter = f => {
180
- const racine = existsSync(path.join(apres, f)) ? apres : avant;
181
- return langageDe(racine).estUnTest(f, racine) !== null;
182
- };
183
- const horsTests = tests.filter(f => !testwriter(f));
184
- if (horsTests.length) {
185
- return `Le lot de tests touche du code : ${horsTests.join(', ')}.`;
186
- }
187
- const duTestwriter = code.filter(testwriter);
188
- if (duTestwriter.length) {
189
- return `Le lot de code touche des fichiers du testwriter (tests ou matière de test partagée) : ${duTestwriter.join(', ')}.`;
190
- }
191
- return null;
192
- }
193
-
194
94
  /**
195
95
  * The commit of main that holds the lot of <ticket>, or null: the one rule that says a lot is on
196
96
  * main, which the queue (scripts/integration/file.mjs) and the circuit's resumption
@@ -234,16 +134,38 @@ export function lotSurMain(o, ticket) {
234
134
  );
235
135
  }
236
136
 
237
- // The refusal « lot-absent » for <ticket>: no lot to apply (neither --tests nor --code) and no
238
- // commit of the ticket on main. The one text, which the integrator's direct call and the circuit's
239
- // resumption both give, the name `lot-absent` first.
137
+ // The refusal « lot-absent » for <ticket>: no commit to send into the queue and no commit of the
138
+ // ticket on main. The one text, which the integrator's direct call and the circuit's resumption both
139
+ // give, the name `lot-absent` first.
240
140
  export const refusLotAbsent = ticket =>
241
- `lot-absent : ${ticket} n'a aucun lot à appliquer (ni --tests ni --code) et aucun commit de ce ticket n'est sur main.`;
141
+ `lot-absent : ${ticket} n'a aucun lot à mettre en file et aucun commit de ce ticket n'est sur main.`;
142
+
143
+ const git = (dossier, ...args) =>
144
+ spawnSync('git', ['-C', dossier, ...args], { encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 });
242
145
 
243
- // The options, or { faute } for a usage error: a ticket always, a message with a lot to apply;
244
- // without a lot (neither --tests nor --code), the call is judged by `lotSurMain` (see `main`).
146
+ /**
147
+ * Why the commit of the lot of the copy <copie> does not enter the queue of the repository at
148
+ * <racine>, or null: its HEAD is not the commit the circuit posed, the copy changed since, or its
149
+ * tree is not in the registry of the trees judged. The one rule, which the circuit reads before it
150
+ * sends the lot back to the final pass (scripts/activites.mjs).
151
+ */
152
+ export function refusDuLot(racine, copie) {
153
+ if (!commitDuLot(copie)) {
154
+ return `La copie ${copie} ne porte pas le commit du lot`;
155
+ }
156
+ const statut = git(copie, 'status', '--porcelain', '--untracked-files=all');
157
+ if (statut.status !== 0 || statut.stdout.trim()) {
158
+ return `La copie ${copie} a changé depuis le jugement :\n${statut.stdout.trimEnd()}${statut.stderr}`;
159
+ }
160
+ const arbre = git(copie, 'rev-parse', 'HEAD^{tree}').stdout.trim();
161
+ return arbreEstJuge(racine, arbre)
162
+ ? null
163
+ : `L'arbre ${arbre} du commit du lot n'est pas au registre des arbres jugés`;
164
+ }
165
+
166
+ // The options, or { faute } for a usage error.
245
167
  export function lire(argv) {
246
- const o = { ticket: null, tests: null, code: null, message: null, references: null };
168
+ const o = { ticket: null, message: null };
247
169
  for (let i = 0; i < argv.length; i++) {
248
170
  const v = argv[i + 1];
249
171
  switch (argv[i]) {
@@ -256,79 +178,25 @@ export function lire(argv) {
256
178
  o.ticket = v;
257
179
  i++;
258
180
  break;
259
- case '--tests':
260
- o.tests = v;
261
- i++;
262
- break;
263
- case '--code':
264
- o.code = v;
265
- i++;
266
- break;
267
181
  case '--message':
268
182
  o.message = v;
269
183
  i++;
270
184
  break;
271
- case '--references':
272
- o.references = v;
273
- i++;
274
- break;
275
185
  default:
276
186
  return { faute: null };
277
187
  }
278
188
  }
279
- if (!o.ticket || ((o.tests || o.code) && !o.message)) {
189
+ if (!o.ticket) {
280
190
  return { faute: null };
281
191
  }
282
192
  return o;
283
193
  }
284
194
 
285
- // The files of the ticket's copy that are not the lot: every modified, deleted or untracked file
286
- // (ignored ones do not count) the lot does not name.
287
- function horsLot(copieTicket, fichiers) {
288
- const r = spawnSync(
289
- 'git',
290
- ['-C', copieTicket, 'status', '--porcelain=v1', '-z', '-uall', '--no-renames'],
291
- { encoding: 'utf8' }
292
- );
293
- if (r.status !== 0) {
294
- return null;
295
- }
296
- const dans = new Set(fichiers);
297
- return r.stdout
298
- .split('\0')
299
- .filter(Boolean)
300
- .map(l => l.slice(3))
301
- .filter(f => !dans.has(f));
302
- }
303
-
304
- // The files of the lot whose content in the ticket's copy differs from its own base plus the lot:
305
- // the lots are applied to the copy's HEAD in a temporary index, which the copy's files are compared
306
- // to. Every file of the lot differs when the lots do not apply to that base.
307
- function differents(copieTicket, lots, fichiers, tmp) {
308
- const index = path.join(tmp, 'index-copie');
309
- const env = { ...process.env, GIT_INDEX_FILE: index };
310
- const dansCopie = (...args) =>
311
- spawnSync('git', ['-C', copieTicket, ...args], { encoding: 'utf8', env });
312
- if (dansCopie('read-tree', 'HEAD').status !== 0) {
313
- return fichiers;
314
- }
315
- for (const p of lots) {
316
- if (dansCopie('apply', '--cached', p).status !== 0) {
317
- return fichiers;
318
- }
319
- }
320
- const r = dansCopie('diff', '--name-only', '--no-renames', '-z', '--', ...fichiers);
321
- if (r.status !== 0) {
322
- return fichiers;
323
- }
324
- return r.stdout.split('\0').filter(Boolean);
325
- }
326
-
327
195
  export function main(argv, ou = process.cwd()) {
328
196
  const o = lire(argv);
329
197
  if ('faute' in o) {
330
198
  process.stderr.write(
331
- 'usage: integrer.mjs --ticket <id> [--tests <patch>] [--code <patch>] --message <file> [--references <file>]\n' +
199
+ 'usage: integrer.mjs --ticket <id> [--message <file>]\n' +
332
200
  (o.faute ? `⛔ ${o.faute}\n` : '')
333
201
  );
334
202
  return 2;
@@ -339,7 +207,6 @@ export function main(argv, ou = process.cwd()) {
339
207
  encoding: 'utf8',
340
208
  }).stdout.trim();
341
209
  const racine = path.dirname(commun);
342
- const git = (...args) => spawnSync('git', ['-C', racine, ...args], { encoding: 'utf8' });
343
210
  const bd = (...a) =>
344
211
  spawnSync('bd', a, { cwd: racine, encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 });
345
212
  const dire = s => process.stdout.write(`${s}\n`);
@@ -347,13 +214,11 @@ export function main(argv, ou = process.cwd()) {
347
214
  process.stdout.write(`⛔ ${s}\nLe lot retourne à son agent avec cette sortie.\n`);
348
215
  return 1;
349
216
  };
350
- const absolu = p => path.resolve(p);
351
217
 
352
- // Without a lot to apply (neither --tests nor --code): the lot is already on main, nothing to
353
- // commit (exit 0), or it is absent and the call is refused by its name `lot-absent` — the same
354
- // rule `lotSurMain` the circuit's resumption reads, not the usage (exit 2), so a resumption that
355
- // finds no lot and no commit on main gets the one named refusal.
356
- if (!(o.tests || o.code)) {
218
+ // Without a message: the lot is already on main, nothing to commit (exit 0), or it is absent and
219
+ // the call is refused by its name `lot-absent` — the same rule `lotSurMain` the circuit's
220
+ // resumption reads, not the usage (exit 2).
221
+ if (!o.message) {
357
222
  let entre;
358
223
  try {
359
224
  entre = lotSurMain({ racine }, o.ticket);
@@ -367,232 +232,100 @@ export function main(argv, ou = process.cwd()) {
367
232
  return 0;
368
233
  }
369
234
 
370
- // One integration at a time: a second waits for the end of the first; a lock whose process is
371
- // gone is taken over.
372
- const verrou = path.join(commun, 'integration.lock');
373
- prendreVerrou(verrou, { attendre: true });
374
235
  const debut = Date.now();
375
- // The working directory of the integration: a base of its own, removed at its end, swept by the
376
- // next one to open a base when the integration is killed (../mesure/base-de-passe.mjs).
377
- const base = ouvrirBase('integration');
378
- const tmp = base.dossier;
236
+ // 0. The keys of the project, before any work.
237
+ let outils;
238
+ let empreintes;
239
+ let donnees;
379
240
  try {
380
- // 0. The keys of the project, before any work.
381
- let engendres;
382
- let outils;
383
- let empreintes;
384
- let donnees;
385
- try {
386
- engendres = engendresDe(racine);
387
- outils = outilsDe(racine);
388
- empreintes = empreintesDe(racine);
389
- donnees = donneesDe(racine);
390
- matieresDeclareesDe(racine);
391
- } catch (e) {
392
- return refuser(`Une clé grillhouse du package.json est refusée :\n${e.message}`);
393
- }
394
-
395
- // 1. The verdict.
396
- const show = bd('show', o.ticket, '--json');
397
- const comments = bd('comments', o.ticket, '--json');
398
- if (show.status !== 0 || comments.status !== 0) {
399
- return refuser(`Ticket ${o.ticket} illisible : ${show.stderr}${comments.stderr}`);
400
- }
401
- const r1 = refusVerdicts(JSON.parse(show.stdout)[0], JSON.parse(comments.stdout || '[]'));
402
- if (r1) {
403
- return refuser(r1);
404
- }
405
- dire('✓ verdicts');
406
-
407
- // 2. The lots.
408
- const lots = [o.tests, o.code].filter(Boolean).map(absolu);
409
- const fichiersDe = p => {
410
- const r = git('apply', '--numstat', '-z', p);
411
- if (r.status !== 0) {
412
- return null;
413
- }
414
- const destinations = r.stdout
415
- .split('\0')
416
- .map(l => l.split('\t')[2])
417
- .filter(Boolean);
418
- // A rename names its source too (numstat names only the destination); a copy leaves its
419
- // source intact, so only its destination counts.
420
- const sources = [...readFileSync(p, 'utf8').matchAll(/^rename from (.+)$/gm)].map(m =>
421
- nomDeGit(m[1])
422
- );
423
- return [...destinations, ...sources];
424
- };
425
- const tests = o.tests ? fichiersDe(absolu(o.tests)) : [];
426
- const code = o.code ? fichiersDe(absolu(o.code)) : [];
427
- if (!tests || !code) {
428
- return refuser('Un patch du lot est illisible.');
429
- }
430
- // The ticket's copy holds the lot; a ticket without a copy (none was made, or it is gone) has
431
- // its lot judged on the main tree alone, and nothing to check nor to remove.
432
- const copieTicket = path.join(racine, '.claude', 'worktrees', o.ticket);
433
- const avecCopie = existsSync(copieTicket);
434
- const r2 = refusLots(tests, code, { avant: racine, apres: avecCopie ? copieTicket : racine });
435
- if (r2) {
436
- return refuser(r2);
437
- }
438
- const fichiers = [...new Set([...tests, ...code])];
439
- dire(`✓ lots : ${fichiers.length} fichiers`);
440
- let duCircuit = [];
441
- if (o.references) {
442
- try {
443
- duCircuit = JSON.parse(readFileSync(absolu(o.references), 'utf8'));
444
- } catch (e) {
445
- return refuser(`Les références ${o.references} ne se lisent pas : ${e.message}`);
446
- }
447
- }
448
- const duProjet = engendres.map(e => ({ ...e, cadre: false }));
449
- const references = [...duProjet, ...duCircuit.map(r => ({ ...r, lit: r.lit ?? [] }))];
450
- // The files of the lot a reference writes in full, and the references the lot touches.
451
- const entiers = fichiers.filter(f => references.some(r => couvertPar(r.entiers, f)));
452
- const aRegenerer = touchesPar(references, fichiers);
241
+ engendresDe(racine);
242
+ outils = outilsDe(racine);
243
+ empreintes = empreintesDe(racine);
244
+ donnees = donneesDe(racine);
245
+ matieresDeclareesDe(racine);
246
+ } catch (e) {
247
+ return refuser(`Une clé grillhouse du package.json est refusée :\n${e.message}`);
248
+ }
453
249
 
454
- // 3. The main tree: the lots' files are free there, so the queue can bring them. The ticket's
455
- // copy holds the lot and nothing else.
456
- const tenus = git('status', '--porcelain', '--', ...fichiers).stdout.trim();
457
- if (tenus) {
458
- return refuser(`Des fichiers du lot sont modifiés dans l'arbre :\n${tenus}`);
459
- }
460
- dire('✓ arbre principal libre');
461
- const branche = `agent/${o.ticket}`;
462
- if (avecCopie) {
463
- const surBranche = spawnSync(
464
- 'git',
465
- ['-C', copieTicket, 'rev-parse', '--abbrev-ref', 'HEAD'],
466
- { encoding: 'utf8' }
467
- );
468
- if (surBranche.stdout.trim() !== branche) {
469
- return refuser(`La copie du ticket ${copieTicket} n'est pas sur la branche ${branche}.`);
470
- }
471
- const autres = horsLot(copieTicket, fichiers);
472
- if (autres === null) {
473
- return refuser(`L'état de la copie ${copieTicket} ne se lit pas.`);
474
- }
475
- if (autres.length) {
476
- return refuser(
477
- `La copie du ticket porte autre chose que le lot :\n${autres.map(f => ` ${f}`).join('\n')}`
478
- );
479
- }
480
- dire('✓ copie du ticket : le lot seul');
481
- }
250
+ // 1. The verdict.
251
+ const show = bd('show', o.ticket, '--json');
252
+ const comments = bd('comments', o.ticket, '--json');
253
+ if (show.status !== 0 || comments.status !== 0) {
254
+ return refuser(`Ticket ${o.ticket} illisible : ${show.stderr}${comments.stderr}`);
255
+ }
256
+ const r1 = refusVerdicts(JSON.parse(show.stdout)[0], JSON.parse(comments.stdout || '[]'));
257
+ if (r1) {
258
+ return refuser(r1);
259
+ }
260
+ dire('✓ verdicts');
482
261
 
483
- // 4. The integration copy: detached on HEAD, without any untracked file; its dependencies
484
- // are kept only while the lock file and the manifests are the same (a CI cache keyed by them).
485
- const copie = path.join(racine, '.claude', 'worktrees', 'integration');
486
- const ouverte = ouvrirCopie({ racine, copie, ref: 'HEAD', dire });
487
- if (ouverte.refus) {
488
- return refuser(ouverte.refus);
489
- }
490
- const { dansCopie, monter, installer } = ouverte;
262
+ // 2. The commit of the lot.
263
+ const copie = path.join(racine, '.claude', 'worktrees', o.ticket);
264
+ const branche = `agent/${o.ticket}`;
265
+ if (!existsSync(copie)) {
266
+ return refuser(`Le ticket n'a pas de copie ${copie} qui porte le commit de son lot.`);
267
+ }
268
+ if (git(copie, 'rev-parse', '--abbrev-ref', 'HEAD').stdout.trim() !== branche) {
269
+ return refuser(`La copie du ticket ${copie} n'est pas sur la branche ${branche}.`);
270
+ }
271
+ const r2 = refusDuLot(racine, copie);
272
+ if (r2) {
273
+ return refuser(`${r2}.`);
274
+ }
275
+ const juge = commitDuLot(copie);
276
+ dire(`✓ commit du lot jugé : ${juge.slice(0, 7)}`);
491
277
 
492
- // 5. The lots, applied in the copy without the files a reference writes in full; then the
493
- // references that write the lock file (regenerated from the lots' manifests), then the
494
- // installation that follows that lock file, then the other references regenerated.
495
- const sansEntiers = entiers.map(f => `--exclude=${f}`);
496
- for (const p of lots) {
497
- const r = dansCopie('apply', '--3way', '--index', ...sansEntiers, p);
498
- if (r.status !== 0) {
499
- refuser(`Le lot ${p} ne s'applique pas :\n${r.stdout}${r.stderr}`);
500
- return LOT_NE_S_APPLIQUE_PAS;
501
- }
502
- }
503
- // The generated files the lots remove from the key follow the lots: main's version is not kept.
504
- const part = partDesLots({
505
- references,
506
- duProjet,
507
- entiers,
508
- touchees: aRegenerer,
509
- arbre: copie,
510
- });
511
- let neSAppliquePas = false;
512
- const suivis = poserLesRetires({
513
- lots,
514
- fichiers: part.suivis,
515
- dansCopie,
516
- surNonApplique: () => (neSAppliquePas = true),
517
- });
518
- if (suivis) {
519
- const refus = refuser(suivis);
520
- return neSAppliquePas ? LOT_NE_S_APPLIQUE_PAS : refus;
521
- }
522
- const divergents = avecCopie ? differents(copieTicket, lots, fichiers, tmp) : [];
523
- if (divergents.length) {
524
- return refuser(
525
- `Des fichiers du lot diffèrent dans la copie du ticket :\n${divergents.map(f => ` ${f}`).join('\n')}`
526
- );
527
- }
528
- dire('✓ lots appliqués');
529
- const aRejouer = part.rejouees;
530
- const env = avecLesDonnees(donnees, avecLesOutils(outils, process.env, empreintes));
531
- const { installation, refus } = installerEtRegenerer({
532
- refs: aRejouer,
533
- installer,
534
- dansCopie,
535
- lancer: commande =>
536
- spawnSync('bash', monter('sh', '-c', commande), {
537
- cwd: copie,
538
- encoding: 'utf8',
539
- maxBuffer: 256 * 1024 * 1024,
540
- env,
541
- }),
542
- });
543
- if (installation || refus) {
544
- return refuser(installation ?? refus);
545
- }
546
- if (aRejouer.length) {
547
- dire(`✓ références régénérées sur main à jour : ${aRejouer.map(r => r.nom).join(', ')}`);
548
- }
278
+ // 3. The main tree: the lot's files are free there, so the queue can bring them.
279
+ const fichiers = git(copie, 'diff', '--name-only', '--no-renames', '-z', `${juge}^`, juge)
280
+ .stdout.split('\0')
281
+ .filter(Boolean);
282
+ const tenus = fichiers.length
283
+ ? git(racine, 'status', '--porcelain', '--', ...fichiers).stdout.trim()
284
+ : '';
285
+ if (tenus) {
286
+ return refuser(`Des fichiers du lot sont modifiés dans l'arbre :\n${tenus}`);
287
+ }
288
+ dire('✓ arbre principal libre');
549
289
 
550
- // 6. The commit, in the copy: the commit committed is the commit the final pass judges.
551
- // The guards run in that pass: a pre-commit hook that plays them skips them under
552
- // GRILLHOUSE_INTEGRATION=1; commit-msg (a closed ticket refuses a second commit, a reopened one
553
- // takes its corrections) runs as always.
554
- const c = spawnSync(
555
- 'bash',
556
- monter('git', '-C', copie, 'commit', '-q', '-F', absolu(o.message)),
557
- {
558
- encoding: 'utf8',
559
- env: { ...process.env, GRILLHOUSE_INTEGRATION: '1' },
560
- }
290
+ // 4. The final message, on the same tree.
291
+ const montee = monterDans(copie);
292
+ if (montee.refus) {
293
+ return refuser(montee.refus);
294
+ }
295
+ const env = avecLesDonnees(donnees, avecLesOutils(outils, process.env, empreintes));
296
+ const c = spawnSync(
297
+ 'bash',
298
+ montee.monter('git', '-C', copie, 'commit', '-q', '--amend', '-F', path.resolve(o.message)),
299
+ { encoding: 'utf8', env: { ...env, GRILLHOUSE_INTEGRATION: '1' } }
300
+ );
301
+ if (c.status !== 0) {
302
+ return refuser(`Le message final du commit est refusé :\n${c.stdout}${c.stderr}`);
303
+ }
304
+ const arbreDe = rev => git(copie, 'rev-parse', `${rev}^{tree}`).stdout.trim();
305
+ if (arbreDe('HEAD') !== arbreDe(juge)) {
306
+ git(copie, 'reset', '-q', juge);
307
+ return refuser(
308
+ `Un crochet change l'arbre du commit jugé en écrivant son message ; le commit ${juge.slice(0, 7)} est gardé.\n${c.stdout}${c.stderr}`
561
309
  );
562
- if (c.status !== 0) {
563
- return refuser(`Le commit est refusé :\n${c.stdout}${c.stderr}`);
564
- }
565
- const commit = dansCopie('rev-parse', 'HEAD').stdout.trim();
310
+ }
311
+ marquerLeLot(copie);
312
+ const commit = git(copie, 'rev-parse', 'HEAD').stdout.trim();
566
313
 
567
- // 7. The branch of the ticket takes the commit; the ticket's copy follows it (it carried the
568
- // lot, which the commit now holds) and is removed; the ticket is labelled `en-file`.
569
- const pose = git('update-ref', `refs/heads/${branche}`, commit);
570
- if (pose.status !== 0) {
571
- return refuser(`La branche ${branche} ne prend pas ${commit.slice(0, 7)} :\n${pose.stderr}`);
572
- }
573
- if (avecCopie) {
574
- spawnSync('git', ['-C', copieTicket, 'reset', '-q', '--hard', commit], { encoding: 'utf8' });
575
- }
576
- bd('update', o.ticket, '--add-label', 'en-file');
577
- dire(`✓ commit ${commit.slice(0, 7)} sur ${branche}`);
578
- const retrait = avecCopie
579
- ? spawnSync('bash', [RETIRER_COPIE, '--garder-travail', copieTicket], {
580
- cwd: racine,
581
- encoding: 'utf8',
582
- })
583
- : { status: 0, stderr: '' };
584
- if (retrait.status !== 0) {
585
- const raison = `La copie ${copieTicket} n'est pas retirée après le commit de ${branche} : ${retrait.stderr.trim()}`;
586
- bd('comments', 'add', o.ticket, raison);
587
- dire(`⚠ ${raison}`);
588
- }
589
- const duree = Math.round((Date.now() - debut) / 100) / 10;
590
- dire(`⏱ ${duree} s`);
591
- return 0;
592
- } finally {
593
- base.fermer();
594
- lacherVerrou(verrou);
314
+ // 5. The ticket enters the queue and its copy goes.
315
+ bd('update', o.ticket, '--add-label', 'en-file');
316
+ dire(`✓ commit ${commit.slice(0, 7)} sur ${branche}`);
317
+ const retrait = spawnSync('bash', [RETIRER_COPIE, '--garder-travail', copie], {
318
+ cwd: racine,
319
+ encoding: 'utf8',
320
+ });
321
+ if (retrait.status !== 0) {
322
+ const raison = `La copie ${copie} n'est pas retirée après le commit de ${branche} : ${retrait.stderr.trim()}`;
323
+ bd('comments', 'add', o.ticket, raison);
324
+ dire(`⚠ ${raison}`);
595
325
  }
326
+ const duree = Math.round((Date.now() - debut) / 100) / 10;
327
+ dire(`⏱ ${duree} s`);
328
+ return 0;
596
329
  }
597
330
 
598
331
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {