@roomi-fields/grillhouse 0.47.1 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +116 -0
  3. package/agents/direct.md +9 -0
  4. package/cadre/templates/projet/.github/workflows/ci.yml +24 -38
  5. package/cadre/templates/projet/.github/workflows/machine-vierge.yml +5 -0
  6. package/cadre/templates/projet/.github/workflows/nuit.yml +14 -2
  7. package/cadre/templates/projet/CLAUDE.md +31 -10
  8. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  9. package/cadre/templates/turbo/paquets.json +3 -1
  10. package/cadre/templates/turbo/sans-paquets.json +3 -1
  11. package/charte.md +46 -13
  12. package/dist/temporal/circuit/appel.d.ts +4 -1
  13. package/dist/temporal/circuit/appel.js +15 -1
  14. package/dist/temporal/circuit/appel.js.map +1 -1
  15. package/dist/temporal/circuit/client.d.ts +7 -1
  16. package/dist/temporal/circuit/client.js +54 -1
  17. package/dist/temporal/circuit/client.js.map +1 -1
  18. package/dist/temporal/circuit/commande.js +35 -60
  19. package/dist/temporal/circuit/commande.js.map +1 -1
  20. package/dist/temporal/circuit/contrat.d.ts +2 -1
  21. package/dist/temporal/circuit/contrat.js +2 -1
  22. package/dist/temporal/circuit/contrat.js.map +1 -1
  23. package/dist/temporal/circuit/deroule.js +9 -2
  24. package/dist/temporal/circuit/deroule.js.map +1 -1
  25. package/dist/temporal/commande.js +2 -13
  26. package/dist/temporal/commande.js.map +1 -1
  27. package/dist/temporal/deroules.d.ts +1 -1
  28. package/dist/temporal/deroules.js +2 -2
  29. package/dist/temporal/deroules.js.map +1 -1
  30. package/dist/temporal/file/activites.d.ts +1 -4
  31. package/dist/temporal/file/activites.js +13 -14
  32. package/dist/temporal/file/activites.js.map +1 -1
  33. package/dist/temporal/file/contrat.d.ts +34 -91
  34. package/dist/temporal/file/contrat.js +33 -5
  35. package/dist/temporal/file/contrat.js.map +1 -1
  36. package/dist/temporal/file/deroule.d.ts +1 -9
  37. package/dist/temporal/file/deroule.js +57 -166
  38. package/dist/temporal/file/deroule.js.map +1 -1
  39. package/dist/temporal/installation.d.ts +26 -1
  40. package/dist/temporal/installation.js +111 -2
  41. package/dist/temporal/installation.js.map +1 -1
  42. package/dist/temporal/nuits/activites.d.ts +5 -10
  43. package/dist/temporal/nuits/activites.js +9 -57
  44. package/dist/temporal/nuits/activites.js.map +1 -1
  45. package/dist/temporal/nuits/choix.d.ts +15 -0
  46. package/dist/temporal/nuits/choix.js +20 -0
  47. package/dist/temporal/nuits/choix.js.map +1 -1
  48. package/dist/temporal/nuits/contrat.d.ts +11 -16
  49. package/dist/temporal/nuits/deroule.js +38 -67
  50. package/dist/temporal/nuits/deroule.js.map +1 -1
  51. package/dist/temporal/places/client.d.ts +9 -11
  52. package/dist/temporal/places/client.js +11 -19
  53. package/dist/temporal/places/client.js.map +1 -1
  54. package/dist/temporal/places/contrat.d.ts +25 -24
  55. package/dist/temporal/places/contrat.js +5 -7
  56. package/dist/temporal/places/contrat.js.map +1 -1
  57. package/dist/temporal/places/deroule.js +26 -36
  58. package/dist/temporal/places/deroule.js.map +1 -1
  59. package/dist/temporal/tickets/activites.js +4 -2
  60. package/dist/temporal/tickets/activites.js.map +1 -1
  61. package/dist/temporal/tickets/contrat.d.ts +2 -1
  62. package/docs/ARCHITECTURE.md +453 -133
  63. package/docs/CADRE.md +16 -13
  64. package/docs/INTERFACE.md +100 -25
  65. package/hooks/hooks.json +9 -0
  66. package/hooks/register.tsx +59 -5
  67. package/package.json +1 -1
  68. package/scripts/activites.mjs +319 -52
  69. package/scripts/aiguillage.mjs +5 -1
  70. package/scripts/attente-a-l-arret.mjs +2 -5
  71. package/scripts/attente-au-tour.mjs +2 -5
  72. package/scripts/bilan.mjs +125 -2
  73. package/scripts/branche-de-nuit.mjs +32 -44
  74. package/scripts/ci-de-main.mjs +215 -16
  75. package/scripts/circuit.mjs +275 -189
  76. package/scripts/circuits-cles.d.mts +3 -3
  77. package/scripts/circuits-cles.mjs +6 -5
  78. package/scripts/coeurs-dedies.mjs +4 -4
  79. package/scripts/commandes-composees.mjs +12 -5
  80. package/scripts/composition-des-langages.mjs +2 -0
  81. package/scripts/crochets.mjs +2 -2
  82. package/scripts/dette.d.ts +2 -1
  83. package/scripts/dette.mjs +49 -6
  84. package/scripts/direct.mjs +343 -0
  85. package/scripts/droits.mjs +19 -0
  86. package/scripts/effets.mjs +6 -5
  87. package/scripts/engendres.mjs +2 -1
  88. package/scripts/enveloppe/enveloppe.mjs +127 -18
  89. package/scripts/enveloppe/lancer.sh +14 -3
  90. package/scripts/enveloppe/paquets-du-plan.mjs +9 -0
  91. package/scripts/enveloppe/travail-de-la-copie.mjs +121 -21
  92. package/scripts/etapes.mjs +14 -4
  93. package/scripts/etat-du-depot.mjs +23 -0
  94. package/scripts/faits-du-circuit.mjs +24 -34
  95. package/scripts/fermeture-de-la-machine.d.mts +27 -0
  96. package/scripts/fermeture-de-la-machine.mjs +98 -0
  97. package/scripts/fichiers-nommes.mjs +27 -1
  98. package/scripts/file-des-tickets.d.mts +18 -1
  99. package/scripts/file-des-tickets.mjs +63 -15
  100. package/scripts/greffons.mjs +1 -1
  101. package/scripts/grillhouse-maj.mjs +13 -25
  102. package/scripts/groupe-cles.d.mts +6 -0
  103. package/scripts/groupe-cles.mjs +29 -1
  104. package/scripts/integration/file.mjs +162 -48
  105. package/scripts/integration/integrer.mjs +2 -0
  106. package/scripts/jointure.d.ts +22 -3
  107. package/scripts/journal-des-etats.d.mts +16 -0
  108. package/scripts/journal-des-etats.mjs +44 -2
  109. package/scripts/journal.mjs +3 -0
  110. package/scripts/langages/c/commandes.mjs +5 -5
  111. package/scripts/langages/c/composants.mjs +13 -5
  112. package/scripts/langages/c/index.mjs +2 -0
  113. package/scripts/langages/c/squelette.mjs +1 -1
  114. package/scripts/langages/cargo/commandes.mjs +5 -6
  115. package/scripts/langages/cargo/index.mjs +2 -0
  116. package/scripts/langages/python/commandes.mjs +5 -5
  117. package/scripts/langages/python/composants.mjs +10 -2
  118. package/scripts/langages/python/index.mjs +2 -0
  119. package/scripts/langages/typescript/composants.mjs +10 -3
  120. package/scripts/langages/typescript/construire.mjs +2 -0
  121. package/scripts/langages/typescript/exemples.mjs +33 -1
  122. package/scripts/langages/typescript/index.mjs +22 -0
  123. package/scripts/langages/typescript/migrations/0.49.0-tests-equipes.mjs +32 -0
  124. package/scripts/langages/typescript/module-absent.mjs +24 -0
  125. package/scripts/langages/typescript/tests-de-nuit.mjs +152 -32
  126. package/scripts/langages/typescript/tests-du-poste.mjs +65 -23
  127. package/scripts/langages/typescript/titres-de-tests.mjs +11 -7
  128. package/scripts/langages/typescript/turbo-des-paquets.mjs +40 -5
  129. package/scripts/langages/typescript/verifier.mjs +3 -5
  130. package/scripts/langages/typescript/verrou-des-dependances.mjs +161 -0
  131. package/scripts/langages/typescript/vitest-config/cibles.mjs +57 -6
  132. package/scripts/langages/typescript/vitest-config/lances.mjs +3 -1
  133. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +11 -5
  134. package/scripts/langages/typescript/vitest.nuit.config.mjs +53 -5
  135. package/scripts/langages.mjs +25 -3
  136. package/scripts/machine.mjs +103 -0
  137. package/scripts/matieres-cles.mjs +17 -0
  138. package/scripts/matieres-lues.mjs +104 -0
  139. package/scripts/mesure/base-de-passe.mjs +2 -1
  140. package/scripts/migrations/0.48.0-ci-declenchee-par-la-file.mjs +32 -0
  141. package/scripts/migrations/0.48.0-poussee-retiree.mjs +31 -0
  142. package/scripts/migrations/0.49.0-reservation-de-trois-coeurs.mjs +30 -0
  143. package/scripts/migrations.mjs +6 -0
  144. package/scripts/nuit.sh +113 -46
  145. package/scripts/paquet.mjs +16 -5
  146. package/scripts/paquets.d.ts +4 -0
  147. package/scripts/paquets.mjs +57 -0
  148. package/scripts/passe-de-la-machine.mjs +13 -14
  149. package/scripts/places-de-la-machine.mjs +120 -44
  150. package/scripts/places-du-serveur.mjs +29 -8
  151. package/scripts/plafond-de-la-machine.d.mts +7 -13
  152. package/scripts/plafond-de-la-machine.mjs +19 -35
  153. package/scripts/poussee-retiree.mjs +18 -0
  154. package/scripts/prefixe-des-tickets.mjs +1 -1
  155. package/scripts/references-changees.mjs +159 -0
  156. package/scripts/registre.d.mts +2 -2
  157. package/scripts/regles-des-places.d.mts +20 -12
  158. package/scripts/regles-des-places.mjs +27 -30
  159. package/scripts/repli-de-la-nuit.mjs +112 -0
  160. package/scripts/reponses-du-circuit.d.mts +4 -2
  161. package/scripts/reponses-du-circuit.mjs +44 -9
  162. package/scripts/reprise.mjs +27 -8
  163. package/scripts/resultats.mjs +61 -9
  164. package/scripts/seances.mjs +258 -40
  165. package/scripts/services-du-noyau.mjs +3 -0
  166. package/scripts/sous-commandes.mjs +37 -7
  167. package/scripts/superviseur.mjs +241 -88
  168. package/scripts/tableau.mjs +327 -131
  169. package/scripts/taches-du-graphe.mjs +84 -4
  170. package/scripts/ticket.mjs +345 -0
  171. package/scripts/transitions.d.mts +52 -0
  172. package/scripts/transitions.mjs +194 -16
  173. package/scripts/un-commit-par-ticket.mjs +4 -3
  174. package/scripts/verdict-de-la-nuit.mjs +47 -20
  175. package/scripts/verrou-de-fichier.mjs +2 -2
  176. package/scripts/verrous/ecriture-hors-enveloppe.mjs +86 -0
  177. package/scripts/verrous/verrou.mjs +17 -1
  178. package/skills/developpeur/SKILL.md +1 -1
  179. package/skills/direct/SKILL.md +57 -0
  180. package/skills/explorateur/SKILL.md +10 -6
  181. package/skills/pitmaster/SKILL.md +37 -14
  182. package/skills/pitmaster/references/consigne-agent.md +7 -1
  183. package/skills/relecteur/SKILL.md +11 -1
  184. package/skills/testwriter/SKILL.md +10 -0
  185. package/scripts/poussee-cles.mjs +0 -46
  186. package/scripts/ticket.sh +0 -25
@@ -18,9 +18,26 @@ export function aSonArchitecture(t: { description?: string }): boolean;
18
18
  /** The tickets of <tous> that start now, in the order they start. */
19
19
  export function ticketsAPartir<T extends TicketDeBeads>(
20
20
  tous: T[],
21
- o?: { enCours?: Set<string>; externes?: Record<string, TicketDeBeads[]> }
21
+ o?: {
22
+ enCours?: Set<string>;
23
+ externes?: Record<string, TicketDeBeads[]>;
24
+ surMain?: (id: string) => boolean;
25
+ }
22
26
  ): T[];
23
27
 
28
+ /** The tickets of <tous> in the queue that never start because their lot is on main. */
29
+ export function enFileSurMain<T extends TicketDeBeads>(
30
+ tous: T[],
31
+ o?: {
32
+ enCours?: Set<string>;
33
+ externes?: Record<string, TicketDeBeads[]>;
34
+ surMain?: (id: string) => boolean;
35
+ }
36
+ ): T[];
37
+
38
+ /** Whether the lot of a ticket is on the main of the main tree <racine>, as a function of its id. */
39
+ export function lotEstSurMain(racine: string): (id: string) => boolean;
40
+
24
41
  /**
25
42
  * What each ticket of the queue waits for from another project (`external:<project>:<capability>`
26
43
  * not delivered by a closed ticket `provides:<capability>`); `faute` names a project that
@@ -16,6 +16,12 @@
16
16
  // - A circuit alive whose ticket was closed outside it (delivered directly) holds no place: the
17
17
  // queue stops it (`fermesHorsCircuit`).
18
18
  // - A ticket whose dependency is open stays: the board says « attend <ticket> » (scripts/tableau.mjs).
19
+ // - A ticket whose lot is on main never starts again, left open or reopened, as a merge queue
20
+ // drops a merged entry whatever the state of its ticket (bors, GitHub's merge queue): work to
21
+ // do again on an integrated lot is a new ticket, and a lot withdrawn by a revert starts again.
22
+ // `lotEstSurMain` reads it (the one rule `lotSurMain` of ./integration/integrer.mjs), for a
23
+ // ticket that would start alone; `enFileSurMain` names it, for the board and the opening of
24
+ // the supervisor, who closes it.
19
25
  // - A dependency on another project (`external:<project>:<capability>`, Beads' cross-project
20
26
  // dependency) holds the ticket until the provider delivered the capability: a closed ticket of
21
27
  // that project labelled `provides:<capability>` (which `bd ship` sets; `export:` alone does
@@ -25,6 +31,7 @@
25
31
  import { spawnSync } from 'node:child_process';
26
32
  import path from 'node:path';
27
33
  import { ETAPES } from './etapes.mjs';
34
+ import { lotSurMain } from './integration/integrer.mjs';
28
35
 
29
36
  // Whether the description of <t> holds its section « ## Architecture »: the rule the queue and the
30
37
  // board both read.
@@ -89,29 +96,40 @@ export function attendDeLAutreProjet(t, externes) {
89
96
  }));
90
97
  }
91
98
 
99
+ // The tickets of <tous> in the queue that nothing of Beads holds: their section written, every
100
+ // dependency closed, every capability of another project delivered.
101
+ const prets = (tous, enCours, externes) => {
102
+ const fermes = new Set(tous.filter(t => t.status === 'closed').map(t => t.id));
103
+ return enFile(tous, enCours).filter(
104
+ t =>
105
+ aSonArchitecture(t) &&
106
+ (t.dependencies ?? []).every(
107
+ d =>
108
+ d.type !== 'blocks' ||
109
+ (d.depends_on_id.startsWith('external:') ? true : fermes.has(d.depends_on_id))
110
+ ) &&
111
+ dependancesExternes(t).every(d => livree(externes, d.projet, d.capacite))
112
+ );
113
+ };
114
+
92
115
  /**
93
116
  * The tickets of <tous> that start now, in the order they start.
94
117
  * @param {Array<{ id: string, status: string, priority?: number, labels?: string[],
95
118
  * created_at?: string, description?: string,
96
119
  * dependencies?: Array<{ type: string, depends_on_id: string }> }>} tous
97
120
  * every ticket of the project, the closed ones too
98
- * @param {{ enCours?: Set<string>, externes?: Record<string, typeof tous> }} [o] `enCours`, the
99
- * tickets whose circuit already runs; `externes`, the tickets of each other project by its name
121
+ * @param {{ enCours?: Set<string>, externes?: Record<string, typeof tous>,
122
+ * surMain?: (id: string) => boolean }} [o] `enCours`, the tickets whose circuit already runs;
123
+ * `externes`, the tickets of each other project by its name; `surMain`, whether the lot of a
124
+ * ticket is on main (`lotEstSurMain`), asked for a ticket that would start alone
100
125
  * @returns {typeof tous}
101
126
  */
102
- export function ticketsAPartir(tous, { enCours = new Set(), externes } = {}) {
103
- const fermes = new Set(tous.filter(t => t.status === 'closed').map(t => t.id));
104
- return enFile(tous, enCours)
105
- .filter(
106
- t =>
107
- aSonArchitecture(t) &&
108
- (t.dependencies ?? []).every(
109
- d =>
110
- d.type !== 'blocks' ||
111
- (d.depends_on_id.startsWith('external:') ? true : fermes.has(d.depends_on_id))
112
- ) &&
113
- dependancesExternes(t).every(d => livree(externes, d.projet, d.capacite))
114
- )
127
+ export function ticketsAPartir(
128
+ tous,
129
+ { enCours = new Set(), externes, surMain = () => false } = {}
130
+ ) {
131
+ return prets(tous, enCours, externes)
132
+ .filter(t => !surMain(t.id))
115
133
  .sort(
116
134
  (a, b) =>
117
135
  (a.priority ?? 2) - (b.priority ?? 2) ||
@@ -120,6 +138,36 @@ export function ticketsAPartir(tous, { enCours = new Set(), externes } = {}) {
120
138
  );
121
139
  }
122
140
 
141
+ /**
142
+ * The tickets of <tous> in the queue that never start because their lot is on main, sorted by id:
143
+ * those nothing else holds, as `ticketsAPartir` leaves them out.
144
+ * @param {Parameters<typeof ticketsAPartir>[0]} tous every ticket of the project
145
+ * @param {Parameters<typeof ticketsAPartir>[1]} [o]
146
+ * @returns {typeof tous}
147
+ */
148
+ export function enFileSurMain(tous, { enCours = new Set(), externes, surMain = () => false } = {}) {
149
+ return prets(tous, enCours, externes)
150
+ .filter(t => surMain(t.id))
151
+ .sort((a, b) => a.id.localeCompare(b.id, 'en', { numeric: true }));
152
+ }
153
+
154
+ /**
155
+ * Whether the lot of a ticket is on the main of the main tree <racine> (`lotSurMain`), as a
156
+ * function of its id; a prefix of the tickets that does not read holds no ticket, the circuit
157
+ * naming that fault.
158
+ * @param {string} racine
159
+ * @returns {(id: string) => boolean}
160
+ */
161
+ export function lotEstSurMain(racine) {
162
+ return id => {
163
+ try {
164
+ return lotSurMain({ racine }, id) !== null;
165
+ } catch {
166
+ return false;
167
+ }
168
+ };
169
+ }
170
+
123
171
  // The states of the steps of the integration (5.1, 5.2, 5.3): the circuit's own queue closes the
124
172
  // ticket at 5.2, then the circuit sorts its discoveries and ends.
125
173
  const DE_L_INTEGRATION = new Set(
@@ -302,7 +302,7 @@ export function greffonsAbsents(projet) {
302
302
  const GREFFON_DU_CADRE = 'grillhouse';
303
303
  const NOM_DU_PAQUET = '@roomi-fields/grillhouse';
304
304
  const X_Y_Z = /^\d+\.\d+\.\d+$/;
305
- function versionDuPaquet() {
305
+ export function versionDuPaquet() {
306
306
  try {
307
307
  const p = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
308
308
  return p.name === NOM_DU_PAQUET && typeof p.version === 'string' ? p.version : null;
@@ -123,10 +123,11 @@
123
123
  // as `npm install` brings what is installed to what is declared. A plugin that cannot be
124
124
  // installed, or a mod left at another version, has its line naming the command to type; the
125
125
  // update has finished its files, and the exit code is non-zero.
126
- // - The group: when the package.json declares `grillhouse.groupe` (scripts/groupe-cles.mjs), the
127
- // update sets in the Beads of the project each other project of the group as an
128
- // `external_projects.<name>` (its path relative to the project), the ones already set left alone; a group
129
- // badly declared is refused by its key before any work.
126
+ // - The group: when the package.json of the main tree of the project declares `grillhouse.groupe`
127
+ // (`groupeDe` of scripts/groupe-cles.mjs: the update launched in a copy of work reads the same
128
+ // group), the update sets in the Beads of the project each other project of the group as an
129
+ // `external_projects.<name>` (its path relative to the main tree), the ones already set left
130
+ // alone; a group badly declared is refused by its key before any work.
130
131
  // - The generated files: after the package.json, each generator of the declared language
131
132
  // (`miseAJour.generateurs` of its module) is run in the project by the project's command
132
133
  // (`node_modules/.bin/grillhouse`, its installed package) for the file it writes when the project
@@ -161,8 +162,9 @@ import { poserCrochets } from './crochets.mjs';
161
162
  import { ATTRIBUT } from './fusion-du-changelog.mjs';
162
163
  import { fluxSansEntree } from './flux-des-paquets.mjs';
163
164
  import { installerGreffons } from './greffons.mjs';
164
- import { lireGroupe, projetsExternes } from './groupe-cles.mjs';
165
+ import { groupeDe, projetsExternes } from './groupe-cles.mjs';
165
166
  import { migrer, restesAuProjet } from './migrations.mjs';
167
+ import { arbrePrincipal } from './outils-cles.mjs';
166
168
  import { langageDe, langagesDe } from './langages.mjs';
167
169
  import * as langagesDansLArchitecture from './migrations/0.27.0-langages-dans-l-architecture.mjs';
168
170
  import { CONFIG_BEADS, ecrireLePrefixe, prefixe, prefixeDuStore } from './prefixe-des-tickets.mjs';
@@ -343,30 +345,15 @@ export function versionDuProjet(projet) {
343
345
  const jouerBd = (args, cwd) =>
344
346
  spawnSync('bd', args, { cwd, encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 });
345
347
 
346
- // The group the package.json of <projet> declares (null without it); a fault throws, naming its
347
- // key (`grillhouse.groupe`) and its value.
348
- function lireDuGroupe(projet) {
349
- const pkg = path.join(projet, 'package.json');
350
- if (!existsSync(pkg)) {
351
- return null;
352
- }
353
- const { groupe, fautes } = lireGroupe(lireJson(pkg, {}), projet);
354
- if (fautes.length > 0) {
355
- throw new Error(
356
- `⛔ ${fautes.map(f => `${f.cle} vaut ${f.valeur}, pas un chemin de projet existant, une fois`).join(' ; ')}.`
357
- );
358
- }
359
- return groupe;
360
- }
361
-
362
348
  // The `external_projects` of the Beads of <projet>: the other projects of its <groupe>, each by its
363
- // name and its path relative to <projet> (`projetsExternes`); those it sets, by name (none when already set).
349
+ // name and its path relative to the main tree of <projet> (`projetsExternes`), which a copy shares
350
+ // with it; those it sets, by name (none when already set).
364
351
  function poserLesProjetsExternes(projet, groupe, bd) {
365
352
  if (groupe === null) {
366
353
  return [];
367
354
  }
368
355
  const poses = [];
369
- for (const [nom, chemin] of Object.entries(projetsExternes(groupe, projet))) {
356
+ for (const [nom, chemin] of Object.entries(projetsExternes(groupe, arbrePrincipal(projet)))) {
370
357
  const cle = `external_projects.${nom}`;
371
358
  const lu = bd(['config', 'get', cle], projet);
372
359
  if (lu.status === 0 && `${lu.stdout ?? ''}`.trim() === chemin) {
@@ -399,8 +386,9 @@ function cleActive(projet) {
399
386
  * none, the project keeping its own). Returns what changed.
400
387
  */
401
388
  export function mettreAJour(projet, source, { inscrite = VERSION, bd = jouerBd } = {}) {
402
- // The group declared, refused by its key before any work.
403
- const groupe = lireDuGroupe(projet);
389
+ // The group the project declares, read in its main tree (`groupeDe`), refused by its key before
390
+ // any work.
391
+ const groupe = groupeDe(projet);
404
392
  const bilan = {
405
393
  projetsExternes: [],
406
394
  dependances: [],
@@ -18,6 +18,12 @@ export function lireGroupe(
18
18
  racine: string
19
19
  ): { groupe: GroupeDeclare | null; fautes: Array<{ cle: string; valeur: string }> };
20
20
 
21
+ /**
22
+ * The group of the project that holds <dir> (its main tree or a copy), read in the package.json of
23
+ * its main tree; null without the key. Throws the faults of the key.
24
+ */
25
+ export function groupeDe(dir: string): GroupeDeclare | null;
26
+
21
27
  /** The `external_projects` of the Beads of the project at <racine>: the other projects of its group. */
22
28
  export function projetsExternes(
23
29
  groupe: { projets: ProjetDuGroupe[] },
@@ -5,9 +5,13 @@
5
5
  // `grillhouse maj` writes the other projects of the group as the `external_projects` of the Beads
6
6
  // of each (`bd ship` and `external:<project>:<capability>` dependencies resolve through them).
7
7
  // Any other value is a fault, named by its key before any work.
8
+ // The key is the project's: `groupeDe` reads it in the package.json of the main tree of the
9
+ // repository, never of a copy, and resolves its relative paths from that tree, so that a command
10
+ // launched in a copy of work reads the same group as one launched in the main tree.
8
11
  import { createHash } from 'node:crypto';
9
- import { existsSync } from 'node:fs';
12
+ import { existsSync, readFileSync } from 'node:fs';
10
13
  import path from 'node:path';
14
+ import { arbrePrincipal } from './outils-cles.mjs';
11
15
 
12
16
  /**
13
17
  * The group a package.json <pkg> declares, read from the project at <racine>.
@@ -58,6 +62,30 @@ export function lireGroupe(pkg, racine) {
58
62
  return { groupe: { id, projets }, fautes: [] };
59
63
  }
60
64
 
65
+ /**
66
+ * The group of the project that holds <dir>, from the package.json of its main tree, its relative
67
+ * paths resolved from that tree; null without the key, or without a package.json that reads.
68
+ * @param {string} dir a directory of the project: its main tree or a copy
69
+ * @returns {{ id: string, projets: { nom: string, chemin: string }[] } | null}
70
+ * @throws {Error} the faults of the key, each named by its key and its value
71
+ */
72
+ export function groupeDe(dir) {
73
+ const racine = arbrePrincipal(dir);
74
+ let pkg;
75
+ try {
76
+ pkg = JSON.parse(readFileSync(path.join(racine, 'package.json'), 'utf8'));
77
+ } catch {
78
+ return null;
79
+ }
80
+ const { groupe, fautes } = lireGroupe(pkg, racine);
81
+ if (fautes.length > 0) {
82
+ throw new Error(
83
+ `⛔ ${fautes.map(f => `${f.cle} vaut ${f.valeur}, pas un chemin de projet existant, une fois`).join(' ; ')}.`
84
+ );
85
+ }
86
+ return groupe;
87
+ }
88
+
61
89
  /**
62
90
  * The `external_projects` of the Beads of the project at <racine>: the other projects of its
63
91
  * <groupe>, `{ <nom>: <chemin> }`, each path relative to <racine>, the root of its main tree:
@@ -40,22 +40,39 @@
40
40
  // which plays nothing again. Green, the tree is kept judged and main moves forward onto the
41
41
  // candidate (`avancerMain`, `merge --ff-only`), the tree the pass judged; main moved meanwhile, the
42
42
  // workflow replaces the branch again and judges it again. Red, the ticket loses `en-file` and
43
- // reopens, its comment giving the end of the output of the pass; main does not move, and the branch
44
- // stays. To play again (75, the part of the machine awaited), the branch stays in the queue, the
45
- // ticket told, neither reopened nor closed. A flaky test has no path of its own: the red comment
43
+ // reopens; main does not move, and the branch stays. To play again (75, the part of the machine
44
+ // awaited), the branch stays in the queue, the ticket told, neither reopened nor closed. A pass
45
+ // that is not green reports as the checks of the circuit do, and as a merge queue keeps the logs of
46
+ // the job that refuses a lot and lists its failed tests (bors, Zuul): its whole output is added to
47
+ // the journal of the ticket (`.claude/worktrees/<ticket>.log`, the circuit's own), under a header
48
+ // line (a copy that does not open plays no verification, and its header says so), and the comment
49
+ // names that file; the pass names a results directory (`GRILLHOUSE_RESULTATS`,
50
+ // scripts/resultats.mjs) in a base of its own (scripts/mesure/base-de-passe.mjs, genre `file`),
51
+ // removed at its end and swept by the next pass when its act was killed, as the passes of the
52
+ // circuit keep theirs in the base of their run; the comment of a red names each red read there
53
+ // (test, file, message; finding; failed task) by the reading of the checks (`rougesDUnePasse` of
54
+ // scripts/activites.mjs, which the act gives the queue's tools, built with it or refused), in
55
+ // every language, and the journal holds them all; the comment lists them up to a bound
56
+ // (`ROUGES_AU_COMMENTAIRE`), says their count and sends to the journal for the rest; the end of
57
+ // the output comes only when that reading names none. A flaky test has no path of its own: the red comment
46
58
  // gives the charter's rule, a test known red goes into quarantine in the test itself, with the
47
59
  // ticket that fixes it.
48
60
  // At its entry on main (`fermerLEntree`), the branch's ticket closes « intégré : <commit> », loses
49
61
  // `en-file`, and the branch is deleted; a branch git does not delete (its copy still in place) is
50
- // written to the ticket, which closes all the same. Then main is pushed to origin, on the branch
51
- // `grillhouse.poussee.commit` of main's package.json (`main` without the key), which the pre-push
52
- // hook lets go as the tree is judged; a refused push is written to the ticket and does not stop the
62
+ // written to the ticket, which closes all the same. A closure Beads refuses (a ticket an open
63
+ // dependency blocks) is a fault named, `fermeture`: its comment at the ticket says it whole, no
64
+ // capability is delivered, the working directory stays, main is pushed, and the workflow gives the
65
+ // circuit the issue « echec », on which it stops with its question; its resumption, once what
66
+ // holds the closure is lifted, plays the entry again, which closes the ticket; the queue of the
67
+ // tickets never starts again a ticket whose lot is on main (scripts/file-des-tickets.mjs). Then main is pushed to origin, to the branch
68
+ // main, which the pre-push hook lets go as the tree is judged (a main whose package.json carries the
69
+ // retired key `grillhouse.poussee` is refused by its name, nothing pushed); a refused push is written to the ticket and does not stop the
53
70
  // queue. The working directory of its circuit (`.claude/worktrees/<ticket>.travail`,
54
71
  // scripts/circuit.mjs), which lives as long as the ticket, is removed then (`retirerLeTravail`).
55
72
  // Every comment and change of the queue at a ticket is written under the author `file`, which bd
56
73
  // reads in BEADS_ACTOR, as the circuit writes its own lines under `circuit`.
57
74
  import { spawnSync } from 'node:child_process';
58
- import { existsSync, rmSync } from 'node:fs';
75
+ import { appendFileSync, existsSync, mkdirSync, mkdtempSync, rmSync } from 'node:fs';
59
76
  import path from 'node:path';
60
77
  import {
61
78
  aRejouer,
@@ -69,8 +86,11 @@ import { arbreEstJuge, garderLArbreJuge } from '../arbres-juges.mjs';
69
86
  import { A_REPASSER } from '../codes-de-sortie.mjs';
70
87
  import { BASE_DU_LOT } from '../dernier-vert.mjs';
71
88
  import { avecLesDonnees, donneesDe } from '../donnees-cles.mjs';
89
+ import { matieresDeclareesDe } from '../matieres-cles.mjs';
90
+ import { ouvrirBase } from '../mesure/base-de-passe.mjs';
91
+ import { RESULTATS } from '../resultats.mjs';
72
92
  import { avecLesOutils, empreintesDe, outilsDe } from '../outils-cles.mjs';
73
- import { lireCommit } from '../poussee-cles.mjs';
93
+ import { pousseeRetiree } from '../poussee-retiree.mjs';
74
94
  import { ouvrirCopie } from './rejeu.mjs';
75
95
  import { lotSurMain } from './integrer.mjs';
76
96
  import { ACTEUR, emettre } from '../effets.mjs';
@@ -92,33 +112,61 @@ const commenterAu = (o, ticket, texte) =>
92
112
  // circuit reads to name that commit (scripts/circuit.mjs, the tri of the discoveries).
93
113
  export const INTEGRE = 'intégré : ';
94
114
 
95
- // The lines of the end of the output of a pass the comment of a red gives.
115
+ // The lines of the end of the output of a pass, which the comment gives when no red is named.
96
116
  const FIN_DE_LA_SORTIE = 60;
97
117
 
118
+ // The characters of the list of the reds a comment holds, one argument of `bd comments add`: the
119
+ // reds beyond are counted there and read in the journal.
120
+ const ROUGES_AU_COMMENTAIRE = 20000;
121
+
122
+ // The journal of the ticket <ticket> in the main tree <racine>, the one its circuit writes
123
+ // (scripts/circuit.mjs).
124
+ const journalDuTicket = (racine, ticket) =>
125
+ path.join(racine, '.claude', 'worktrees', `${ticket}.log`);
126
+
98
127
  /**
99
- * The final pass played in the queue's own copy (`.claude/worktrees/file`) on the commit <commit>:
100
- * `{ code, sortie }`, the code of `npm run verifier` (0 green, 75 to play again, any other red) and
101
- * its output. The copy is made ready on <commit> (detached, its dependencies in agreement with the
102
- * lock file), the pass measured against the tip of main (`GRILLHOUSE_BASE_DU_LOT`, the commit's base
103
- * as the lot lies on it), as the pass of the circuit measures itself.
128
+ * The final pass played in the queue's own copy (`.claude/worktrees/file`) on the commit <commit>
129
+ * for the ticket <ticket>: `{ code, sortie, rouges }`, the code of `npm run verifier` (0 green, 75
130
+ * to play again, any other red), its output, and the lines of the reds of a red pass. The copy is
131
+ * made ready on <commit> by <ouvrir> (detached, its dependencies in agreement with the lock file),
132
+ * the pass measured against the tip of main (`GRILLHOUSE_BASE_DU_LOT`, the commit's base as the lot
133
+ * lies on it), as the pass of the circuit measures itself. The pass names a results directory
134
+ * (`GRILLHOUSE_RESULTATS`) in a base of its own (`ouvrirBase('file')`), where <rouges> reads the
135
+ * reds of a red pass (`{ copie, dossier, code, ticket, journal }` → their lines); the base is
136
+ * closed at the end of the pass, and swept by the next one when the act was killed. A copy that
137
+ * does not open plays no pass: 75, its refusal as the output, `refus` true.
104
138
  */
105
- function passeDeLaFile(racine, principale, dire) {
106
- return ({ commit }) => {
139
+ function passeDeLaFile(racine, principale, dire, { rouges, ouvrir }) {
140
+ return ({ commit, ticket }) => {
107
141
  const copie = path.join(racine, '.claude', 'worktrees', 'file');
108
- const ouverte = ouvrirCopie({ racine, copie, ref: commit, dire });
142
+ const ouverte = ouvrir({ racine, copie, ref: commit, dire });
109
143
  if (ouverte.refus) {
110
- return { code: A_REPASSER, sortie: ouverte.refus };
144
+ return { code: A_REPASSER, sortie: ouverte.refus, rouges: [], refus: true };
111
145
  }
112
146
  const base = spawnSync('git', ['-C', racine, 'rev-parse', `refs/heads/${principale}`], {
113
147
  encoding: 'utf8',
114
148
  }).stdout.trim();
115
- const r = spawnSync('bash', ouverte.monter('npm', 'run', 'verifier'), {
116
- cwd: copie,
117
- encoding: 'utf8',
118
- maxBuffer: 256 * 1024 * 1024,
119
- env: base ? { ...process.env, [BASE_DU_LOT]: base } : process.env,
120
- });
121
- return { code: r.status ?? 1, sortie: `${r.stdout ?? ''}${r.stderr ?? ''}` };
149
+ const laBase = ouvrirBase('file');
150
+ try {
151
+ const dossier = mkdtempSync(path.join(laBase.dossier, 'resultats-'));
152
+ const r = spawnSync('bash', ouverte.monter('npm', 'run', 'verifier'), {
153
+ cwd: copie,
154
+ encoding: 'utf8',
155
+ maxBuffer: 256 * 1024 * 1024,
156
+ env: { ...process.env, [RESULTATS]: dossier, ...(base ? { [BASE_DU_LOT]: base } : {}) },
157
+ });
158
+ const code = r.status ?? 1;
159
+ const rouge = code !== 0 && code !== A_REPASSER;
160
+ return {
161
+ code,
162
+ sortie: `${r.stdout ?? ''}${r.stderr ?? ''}`,
163
+ rouges: rouge
164
+ ? rouges({ copie, dossier, code, ticket, journal: journalDuTicket(racine, ticket) })
165
+ : [],
166
+ };
167
+ } finally {
168
+ laBase.fermer();
169
+ }
122
170
  };
123
171
  }
124
172
 
@@ -126,9 +174,21 @@ function passeDeLaFile(racine, principale, dire) {
126
174
  * The tools of the queue on the main tree <racine>, its lines said by <dire>: `{ racine,
127
175
  * principale, bd, passe, dire, avancement }`, bd run under the queue's author (BEADS_ACTOR), the
128
176
  * branch of the main tree (null when it is on none), `passe` the final pass played in the queue's
129
- * copy.
177
+ * copy. <ports> gives what the pass plays with: `rouges`, the reading of the reds of a red pass,
178
+ * without which the tools are refused, and `ouvrir`, which makes the queue's copy ready
179
+ * (`ouvrirCopie`).
130
180
  */
131
- export function outilsDeLaFile(racine, dire, avancement = null) {
181
+ export function outilsDeLaFile(
182
+ racine,
183
+ dire,
184
+ avancement = null,
185
+ { rouges, ouvrir = ouvrirCopie } = {}
186
+ ) {
187
+ if (typeof rouges !== 'function') {
188
+ throw new Error(
189
+ "Les outils de la file se bâtissent avec la lecture des rouges d'une passe (rouges)."
190
+ );
191
+ }
132
192
  const bd = (...a) => {
133
193
  const r = spawnSync('bd', a, {
134
194
  cwd: racine,
@@ -149,7 +209,7 @@ export function outilsDeLaFile(racine, dire, avancement = null) {
149
209
  racine,
150
210
  principale,
151
211
  bd,
152
- passe: passeDeLaFile(racine, principale ?? 'main', dire),
212
+ passe: passeDeLaFile(racine, principale ?? 'main', dire, { rouges, ouvrir }),
153
213
  dire,
154
214
  avancement,
155
215
  };
@@ -191,6 +251,7 @@ function remplacer(o, tip, tete) {
191
251
  let env;
192
252
  try {
193
253
  engendres = engendresDe(racine);
254
+ matieresDeclareesDe(racine);
194
255
  env = avecLesDonnees(
195
256
  donneesDe(racine),
196
257
  avecLesOutils(outilsDe(racine), process.env, empreintesDe(racine))
@@ -332,9 +393,10 @@ export function preparerLaBranche(o, entree) {
332
393
  * The candidate <commit> of <entree> (`{ ticket, branche, commit }`) judged by the final pass with
333
394
  * the tools <o>: `{ juge: true }`, green (or its tree already judged: nothing is played again), its
334
395
  * tree kept judged (scripts/arbres-juges.mjs); or `{ issue }`, the issue for the circuit
335
- * (src/temporal/file/deroule.ts): red, `rouvert`, the end of the output of the pass in the comment,
396
+ * (src/temporal/file/deroule.ts): red, `rouvert`, the reds of the pass named in the comment (the end
397
+ * of its output when it names none), its whole output in the journal of the ticket,
336
398
  * the ticket reopened without `en-file`; to play again (75), `en-file`, the ticket told, neither
337
- * reopened nor closed. `o.passe({ commit })` gives `{ code, sortie }`.
399
+ * reopened nor closed. `o.passe({ commit, ticket })` gives `{ code, sortie, rouges }`.
338
400
  */
339
401
  export function jugerLeCandidat(o, entree) {
340
402
  const git = (...args) => spawnSync('git', ['-C', o.racine, ...args], { encoding: 'utf8' });
@@ -344,7 +406,12 @@ export function jugerLeCandidat(o, entree) {
344
406
  o.dire(`✓ arbre de ${court} déjà jugé par une passe finale`);
345
407
  return { juge: true };
346
408
  }
347
- const { code, sortie } = o.passe({ commit: entree.commit });
409
+ const {
410
+ code,
411
+ sortie,
412
+ rouges = [],
413
+ refus = false,
414
+ } = o.passe({ commit: entree.commit, ticket: entree.ticket });
348
415
  if (code === 0) {
349
416
  if (arbre) {
350
417
  garderLArbreJuge(o.racine, arbre);
@@ -352,14 +419,42 @@ export function jugerLeCandidat(o, entree) {
352
419
  o.dire(`✓ passe finale verte sur ${court}`);
353
420
  return { juge: true };
354
421
  }
355
- const fin = `${sortie ?? ''}`.trim().split('\n').slice(-FIN_DE_LA_SORTIE).join('\n');
422
+ const entiere = `${sortie ?? ''}`;
423
+ const fin = entiere.trim().split('\n').slice(-FIN_DE_LA_SORTIE).join('\n');
424
+ // The whole output, added to the journal of the ticket under its header line, then every red
425
+ // the pass read; a copy that did not open played no verification.
426
+ const journal = journalDuTicket(o.racine, entree.ticket);
427
+ mkdirSync(path.dirname(journal), { recursive: true });
428
+ const entete = refus
429
+ ? `La copie de la file ne s'ouvre pas sur ${court} : aucune passe finale jouée (code ${code})`
430
+ : `$ npm run verifier — la passe finale de la file sur ${court} (code ${code})`;
431
+ const lesRouges = rouges.length
432
+ ? `Les rouges de la passe finale de la file sur ${court} (${rouges.length}) :\n${rouges.map(r => `- ${r}`).join('\n')}\n`
433
+ : '';
434
+ appendFileSync(journal, `${entete}\n${entiere}${entiere.endsWith('\n') ? '' : '\n'}${lesRouges}`);
435
+ const saSortie = `Sa sortie entière : ${journal}`;
356
436
  if (code === A_REPASSER) {
357
- const texte = `## ${TITRE_PASSE_FINALE} à repasser\n\nLa passe finale de ${court} sur ${entree.branche} est à repasser (code ${code}) :\n\n${fin}\n\n${o.principale} n'avance pas sans son vert ; la branche reste en file, et la reprise du circuit la renvoie.`;
437
+ const texte = `## ${TITRE_PASSE_FINALE} à repasser\n\nLa passe finale de ${court} sur ${entree.branche} est à repasser (code ${code}) :\n\n${fin}\n\n${saSortie}\n\n${o.principale} n'avance pas sans son vert ; la branche reste en file, et la reprise du circuit la renvoie.`;
358
438
  commenterAu(o, entree.ticket, texte);
359
439
  o.dire(`⚠ passe finale de ${court} à repasser`);
360
440
  return { issue: { etat: 'en-file', raison: texte } };
361
441
  }
362
- const texte = `## ${TITRE_PASSE_FINALE} rouge\n\nLa passe finale de ${court} sur ${entree.branche}, le lot posé sur la pointe de ${o.principale}, est rouge (code ${code}). La fin de sa sortie :\n\n${fin}\n\n${o.principale} n'avance pas et le ticket est rouvert : sa correction entre sous son numéro. Un test connu instable se met en quarantaine dans le test, avec le ticket qui le corrige.`;
442
+ // The reds the pass read in its results, listed up to the bound of a comment, the first always,
443
+ // the others counted and left to the journal; or, when it names none, the end of its output.
444
+ const listes = [];
445
+ let taille = 0;
446
+ for (const r of rouges) {
447
+ taille += r.length;
448
+ if (listes.length && taille > ROUGES_AU_COMMENTAIRE) {
449
+ break;
450
+ }
451
+ listes.push(`- ${r.slice(0, ROUGES_AU_COMMENTAIRE)}`);
452
+ }
453
+ const autres = rouges.length - listes.length;
454
+ const ce = rouges.length
455
+ ? `Ses rouges (${rouges.length}) :\n\n${listes.join('\n')}${autres ? `\n\n… et ${autres} autre(s), au journal.` : ''}`
456
+ : `La fin de sa sortie :\n\n${fin}`;
457
+ const texte = `## ${TITRE_PASSE_FINALE} rouge\n\nLa passe finale de ${court} sur ${entree.branche}, le lot posé sur la pointe de ${o.principale}, est rouge (code ${code}). ${ce}\n\n${saSortie}\n\n${o.principale} n'avance pas et le ticket est rouvert : sa correction entre sous son numéro. Un test connu instable se met en quarantaine dans le test, avec le ticket qui le corrige.`;
363
458
  commenterAu(o, entree.ticket, texte);
364
459
  o.bd('update', entree.ticket, '--status', 'open', '--remove-label', 'en-file');
365
460
  o.dire(`✗ passe finale de ${court} rouge : ${entree.ticket} rouvert`);
@@ -427,12 +522,16 @@ function livrerLesCapacites(o, ticket, labels) {
427
522
  * The ticket of <entree> (`{ ticket, branche, commit }`) entered on main at <commit>, with the
428
523
  * tools <o>: it closes « intégré : <commit> » and loses `en-file` (a ticket already closed is left
429
524
  * as it is), the branch is deleted, then main is pushed to origin on the branch
430
- * `grillhouse.poussee.commit` of main's package.json; the queue is then done with the ticket, and
525
+ * main, unless main's package.json carries the retired key `grillhouse.poussee` (refused by its
526
+ * name, nothing pushed); the queue is then done with the ticket, and
431
527
  * removes the working directory of its circuit (`retirerLeTravail`). Each of its gestures replays
432
528
  * without harm (a ticket closed is left closed, a branch gone stays gone, a commit pushed is pushed
433
529
  * again as it is), and never reopens the ticket; its comments are effects (`commenterAu`), which
434
- * the workflow of the queue writes once each. `{ poussee, raison }`: the branch pushed to, or null
435
- * and why, in one line (`enUneLigne`), its comment at the ticket whole.
530
+ * the workflow of the queue writes once each. `{ poussee, raison, fermeture }`: `main` once
531
+ * pushed, or null and why, in one line (`enUneLigne`), its comment at the ticket whole;
532
+ * `fermeture`, the fault of a `bd close` that fails, in one line (the command and Beads' reason),
533
+ * null without one: the ticket stays open, no capability is delivered and the working directory
534
+ * stays, for the circuit that stops on it, and the entry played again closes the ticket.
436
535
  */
437
536
  export function fermerLEntree(o, entree) {
438
537
  const { racine } = o;
@@ -441,44 +540,59 @@ export function fermerLEntree(o, entree) {
441
540
  const commenter = texte => commenterAu(o, entree.ticket, texte);
442
541
  const show = o.bd('show', entree.ticket, '--json');
443
542
  const lu = show.status === 0 ? (JSON.parse(show.stdout)[0] ?? null) : null;
543
+ let fermeture = null;
444
544
  if ((lu?.status ?? null) !== 'closed') {
445
545
  o.bd('update', entree.ticket, '--remove-label', 'en-file');
446
- o.bd('close', entree.ticket, '--reason', `${INTEGRE}${court}`);
546
+ const r = o.bd('close', entree.ticket, '--reason', `${INTEGRE}${court}`);
547
+ if (r.status !== 0) {
548
+ const raison = `${r.stderr ?? ''}`.trim() || `${r.stdout ?? ''}`.trim() || `code ${r.status}`;
549
+ commenter(
550
+ `Le ticket n'est pas fermé : son lot est sur ${o.principale} en ${court}, mais \`bd close ${entree.ticket}\` échoue :\n${raison}\n\nLève ce qui l'empêche, puis reprends son circuit (\`--reprendre\`) : il repasse par la file, qui ferme le ticket, livre ses capacités et retire son dossier de travail. La file ne relance pas un ticket dont le lot est sur ${o.principale}.`
551
+ );
552
+ o.dire(`⚠ bd close ${entree.ticket} échoue`);
553
+ fermeture = `bd close ${entree.ticket} échoue : ${enUneLigne(raison)}`;
554
+ }
447
555
  }
448
556
  // The capabilities the ticket exports (`export:<capability>`) are delivered once it is closed.
449
- const ferme = livrerLesCapacites(o, entree.ticket, lu?.labels ?? []);
557
+ const ferme = {
558
+ ...(fermeture ? { livraison: null } : livrerLesCapacites(o, entree.ticket, lu?.labels ?? [])),
559
+ fermeture,
560
+ };
450
561
  o.dire(`✓ ${entree.branche} entre sur ${o.principale} : ${court}`);
451
562
  if (git('rev-parse', '--verify', '-q', `refs/heads/${entree.branche}`).status === 0) {
452
563
  const efface = git('branch', '-D', entree.branche);
453
564
  if (efface.status !== 0) {
454
565
  commenter(
455
- `La branche ${entree.branche} reste en place après son entrée sur ${o.principale} (${efface.stderr.trim()}) : sa copie est encore en place. Le ticket est fermé.`
566
+ `La branche ${entree.branche} reste en place après son entrée sur ${o.principale} (${efface.stderr.trim()}) : sa copie est encore en place.${fermeture ? '' : ' Le ticket est fermé.'}`
456
567
  );
457
568
  o.dire(`⚠ ${entree.branche} n'est pas effacée`);
458
569
  }
459
570
  }
460
- retirerLeTravail(o, entree.ticket);
571
+ // The working directory lives as long as the ticket: one left open keeps it, for its circuit.
572
+ if (!fermeture) {
573
+ retirerLeTravail(o, entree.ticket);
574
+ }
461
575
  const paquet = git('show', `refs/heads/${o.principale}:package.json`);
462
- const { commit, faute } = lireCommit(paquet.status === 0 ? JSON.parse(paquet.stdout) : null);
463
- if (faute) {
464
- const raison = `Poussée non faite : grillhouse.poussee.commit vaut ${faute}, pas un nom de branche.`;
576
+ const retiree = pousseeRetiree(paquet.status === 0 ? JSON.parse(paquet.stdout) : null);
577
+ if (retiree) {
578
+ const raison = `Poussée non faite : ${retiree}`;
465
579
  commenter(raison);
466
580
  return { poussee: null, raison: enUneLigne(raison), ...ferme };
467
581
  }
468
582
  const sansInvite = { encoding: 'utf8', env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } };
469
583
  const pousse = spawnSync(
470
584
  'git',
471
- ['-C', racine, 'push', 'origin', `${entree.commit}:refs/heads/${commit}`],
585
+ ['-C', racine, 'push', 'origin', `${entree.commit}:refs/heads/main`],
472
586
  sansInvite
473
587
  );
474
588
  if (pousse.status !== 0) {
475
- const raison = `La poussée de ${court} vers origin/${commit} (grillhouse.poussee.commit) est refusée :\n${pousse.stderr.trim()}`;
589
+ const raison = `La poussée de ${court} vers origin/main est refusée :\n${pousse.stderr.trim()}`;
476
590
  commenter(raison);
477
591
  o.dire(`⚠ poussée de ${court} refusée`);
478
592
  return { poussee: null, raison: enUneLigne(raison), ...ferme };
479
593
  }
480
- o.dire(`✓ poussée : ${court} est sur origin/${commit}`);
481
- return { poussee: commit, raison: null, ...ferme };
594
+ o.dire(`✓ poussée : ${court} est sur origin/main`);
595
+ return { poussee: 'main', raison: null, ...ferme };
482
596
  }
483
597
 
484
598
  /**