@roomi-fields/grillhouse 0.31.0 → 0.33.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 (149) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +40 -0
  3. package/bin/grillhouse.mjs +6 -4
  4. package/cadre/templates/projet/.github/workflows/ci.yml +136 -16
  5. package/cadre/templates/projet/.github/workflows/nuit.yml +111 -0
  6. package/cadre/templates/projet/deployment/docs/01-INSTALL.md +4 -4
  7. package/cadre/templates/projet/package.json +2 -2
  8. package/charte.md +8 -5
  9. package/dist/temporal/circuit/contrat.d.ts +15 -0
  10. package/dist/temporal/circuit/deroule.js +37 -14
  11. package/dist/temporal/circuit/deroule.js.map +1 -1
  12. package/dist/temporal/deroules.d.ts +1 -0
  13. package/dist/temporal/deroules.js +3 -1
  14. package/dist/temporal/deroules.js.map +1 -1
  15. package/dist/temporal/file/activites.d.ts +1 -0
  16. package/dist/temporal/file/activites.js +5 -2
  17. package/dist/temporal/file/activites.js.map +1 -1
  18. package/dist/temporal/file/contrat.d.ts +50 -33
  19. package/dist/temporal/file/contrat.js +2 -2
  20. package/dist/temporal/file/contrat.js.map +1 -1
  21. package/dist/temporal/file/deroule.d.ts +3 -1
  22. package/dist/temporal/file/deroule.js +128 -26
  23. package/dist/temporal/file/deroule.js.map +1 -1
  24. package/dist/temporal/installation.d.ts +3 -2
  25. package/dist/temporal/installation.js +7 -4
  26. package/dist/temporal/installation.js.map +1 -1
  27. package/dist/temporal/nuits/activites.d.ts +10 -0
  28. package/dist/temporal/nuits/activites.js +114 -0
  29. package/dist/temporal/nuits/activites.js.map +1 -0
  30. package/dist/temporal/nuits/appel.d.ts +23 -0
  31. package/dist/temporal/nuits/appel.js +40 -0
  32. package/dist/temporal/nuits/appel.js.map +1 -0
  33. package/dist/temporal/nuits/choix.d.ts +14 -0
  34. package/dist/temporal/nuits/choix.js +119 -0
  35. package/dist/temporal/nuits/choix.js.map +1 -0
  36. package/dist/temporal/nuits/client.d.ts +28 -0
  37. package/dist/temporal/nuits/client.js +83 -0
  38. package/dist/temporal/nuits/client.js.map +1 -0
  39. package/dist/temporal/nuits/commande.d.ts +2 -0
  40. package/dist/temporal/nuits/commande.js +107 -0
  41. package/dist/temporal/nuits/commande.js.map +1 -0
  42. package/dist/temporal/nuits/contrat.d.ts +98 -0
  43. package/dist/temporal/nuits/contrat.js +30 -0
  44. package/dist/temporal/nuits/contrat.js.map +1 -0
  45. package/dist/temporal/nuits/deroule.d.ts +5 -0
  46. package/dist/temporal/nuits/deroule.js +100 -0
  47. package/dist/temporal/nuits/deroule.js.map +1 -0
  48. package/dist/temporal/tickets/activites.d.ts +1 -0
  49. package/dist/temporal/tickets/activites.js +5 -0
  50. package/dist/temporal/tickets/activites.js.map +1 -1
  51. package/dist/temporal/tickets/contrat.d.ts +10 -0
  52. package/dist/temporal/tickets/deroule.js +8 -1
  53. package/dist/temporal/tickets/deroule.js.map +1 -1
  54. package/dist/temporal/travailleur.js +4 -1
  55. package/dist/temporal/travailleur.js.map +1 -1
  56. package/docs/ARCHITECTURE.md +257 -54
  57. package/docs/CADRE.md +41 -1
  58. package/docs/INTERFACE.md +54 -7
  59. package/hooks/hooks.json +4 -0
  60. package/hooks/register.tsx +11 -3
  61. package/package.json +4 -1
  62. package/scripts/abi-des-dependances.mjs +105 -0
  63. package/scripts/activites.mjs +99 -48
  64. package/scripts/aiguillage.mjs +3 -0
  65. package/scripts/attente-au-tour.mjs +99 -0
  66. package/scripts/avancement.mjs +8 -18
  67. package/scripts/base-des-workflows.mjs +57 -0
  68. package/scripts/ci-des-branches.mjs +91 -0
  69. package/scripts/circuit.mjs +99 -5
  70. package/scripts/composants-affectes.mjs +24 -7
  71. package/scripts/composition-des-langages.mjs +3 -0
  72. package/scripts/copies-finies.mjs +8 -1
  73. package/scripts/crochets.mjs +4 -0
  74. package/scripts/dernier-vert.mjs +30 -4
  75. package/scripts/effets.mjs +9 -0
  76. package/scripts/enveloppe/enveloppe.mjs +3 -1
  77. package/scripts/enveloppe/lancer.sh +1 -1
  78. package/scripts/enveloppe/travail-de-la-copie.mjs +219 -59
  79. package/scripts/etapes.mjs +19 -2
  80. package/scripts/faits-du-circuit.mjs +43 -20
  81. package/scripts/fichier-du-poste.mjs +87 -0
  82. package/scripts/grillhouse-maj.mjs +15 -1
  83. package/scripts/integration/file.mjs +215 -275
  84. package/scripts/integration/integrer.mjs +82 -41
  85. package/scripts/integration/rejeu.mjs +13 -64
  86. package/scripts/jointure.d.ts +30 -2
  87. package/scripts/journal-des-etats.d.mts +41 -0
  88. package/scripts/journal-des-etats.mjs +273 -0
  89. package/scripts/journal.mjs +119 -0
  90. package/scripts/langages/cargo/commandes.mjs +81 -19
  91. package/scripts/langages/cargo/exemples.mjs +2 -2
  92. package/scripts/langages/cargo/index.mjs +14 -5
  93. package/scripts/langages/cargo/tailles-des-tests.mjs +19 -11
  94. package/scripts/langages/python/commandes.mjs +11 -7
  95. package/scripts/langages/python/exemples.mjs +1 -1
  96. package/scripts/langages/python/index.mjs +11 -2
  97. package/scripts/langages/python/tailles-des-tests.mjs +19 -11
  98. package/scripts/langages/typescript/code-mort.mjs +41 -24
  99. package/scripts/langages/typescript/consommateurs.mjs +28 -17
  100. package/scripts/langages/typescript/exemples.mjs +2 -0
  101. package/scripts/langages/typescript/frontieres.mjs +46 -0
  102. package/scripts/langages/typescript/index.mjs +24 -3
  103. package/scripts/langages/typescript/migrations/0.33.0-binaire-de-jour.mjs +34 -0
  104. package/scripts/langages/typescript/migrations/0.33.0-tests-du-poste.mjs +31 -0
  105. package/scripts/langages/typescript/resumes.mjs +17 -7
  106. package/scripts/langages/typescript/tailles-des-tests.mjs +251 -22
  107. package/scripts/langages/typescript/tests-de-nuit.mjs +101 -9
  108. package/scripts/langages/typescript/tests-du-poste.mjs +172 -0
  109. package/scripts/langages/typescript/tranches.mjs +273 -0
  110. package/scripts/langages/typescript/verifier.mjs +154 -23
  111. package/scripts/langages/typescript/vitest-config/base.mjs +3 -0
  112. package/scripts/langages/typescript/vitest-config/cibles.mjs +78 -7
  113. package/scripts/langages/typescript/vitest-config/lances.mjs +4 -4
  114. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +9 -0
  115. package/scripts/langages/typescript/vitest.nuit.config.mjs +3 -2
  116. package/scripts/langages.d.mts +20 -0
  117. package/scripts/lint-des-scripts.mjs +23 -6
  118. package/scripts/matiere-de-test.d.ts +11 -0
  119. package/scripts/migrations/0.33.0-cache-distant.mjs +36 -0
  120. package/scripts/migrations/0.33.0-ci-des-branches-de-ticket.mjs +31 -0
  121. package/scripts/migrations/0.33.0-ci-du-cadre.mjs +31 -0
  122. package/scripts/migrations/0.33.0-node-26.mjs +58 -0
  123. package/scripts/migrations.mjs +8 -0
  124. package/scripts/newday.mjs +18 -0
  125. package/scripts/nuit.sh +40 -13
  126. package/scripts/places-de-la-machine.mjs +6 -0
  127. package/scripts/registre.d.mts +90 -0
  128. package/scripts/registre.mjs +28 -3
  129. package/scripts/reprise.mjs +12 -8
  130. package/scripts/services-du-noyau.mjs +4 -0
  131. package/scripts/session-start.sh +28 -32
  132. package/scripts/sous-commandes.mjs +31 -10
  133. package/scripts/superviseur.mjs +127 -75
  134. package/scripts/tableau.mjs +222 -17
  135. package/scripts/taches-du-graphe.mjs +39 -6
  136. package/scripts/ticket-du-circuit.mjs +37 -7
  137. package/scripts/transitions.mjs +60 -8
  138. package/scripts/verrou-de-machine.mjs +1 -2
  139. package/scripts/workflows-du-cadre.mjs +75 -0
  140. package/skills/developpeur/SKILL.md +1 -1
  141. package/skills/explorateur/SKILL.md +1 -1
  142. package/skills/grill/SKILL.md +10 -62
  143. package/skills/grill/references/paquets.md +60 -0
  144. package/skills/pitmaster/SKILL.md +21 -31
  145. package/skills/questionneur/SKILL.md +1 -1
  146. package/skills/relecteur/SKILL.md +1 -1
  147. package/skills/testwriter/SKILL.md +7 -1
  148. package/skills/release/SKILL.md +0 -134
  149. package/skills/release/scripts/update-version.cjs +0 -92
@@ -16,6 +16,8 @@
16
16
  // - `decouverte` `{ role, sujet, corps, composants }`: a discovery filed closed under the ticket
17
17
  // (scripts/ticket.sh, label `decouverte`), then its line among the sheets (`{ id, sujet }`);
18
18
  // - `registre` `{ ligne }`: a line of the register of the steps (scripts/registre.mjs);
19
+ // - `trace` `{ ligne }`: a line of the journal of states (scripts/journal-des-etats.mjs), whose
20
+ // failure is said once and never stops the circuit;
19
21
  // - `etat` `{ etat }`: the circuit's state, which the workflow of a ticket holds and no player writes
20
22
  // (src/temporal/circuit/deroule.ts);
21
23
  // - `plan` `{ titre, description }`: the plan written at the ticket (its title, its description);
@@ -39,6 +41,7 @@ import { appendFileSync, existsSync, readFileSync } from 'node:fs';
39
41
  import path from 'node:path';
40
42
  import { stripVTControlCharacters } from 'node:util';
41
43
  import { ecrireLeBilan } from './bilan.mjs';
44
+ import { ecrireLaTrace } from './journal-des-etats.mjs';
42
45
  import { ecrire as ecrireAuRegistre } from './registre.mjs';
43
46
 
44
47
  /** The line of HTML comment that carries the key <cle> in a text at a ticket. */
@@ -215,6 +218,12 @@ const JOUEURS = {
215
218
  return echec(e.message);
216
219
  }
217
220
  },
221
+ // A line of the journal of states: never an arrest, never a wait (ecrireLaTrace says a failure
222
+ // once and goes on).
223
+ trace(ctx, { ligne }) {
224
+ ecrireLaTrace(ctx.racine, ligne);
225
+ return ok;
226
+ },
218
227
  plan(ctx, { titre, description }) {
219
228
  const options = [
220
229
  ...(titre === null ? [] : ['--title', titre]),
@@ -32,7 +32,9 @@
32
32
  // the envelope declares: each starts empty and sealed read-only, and the home gets back
33
33
  // `~/.claude`, `~/.claude.json`, the npm cache, the paths of `MAISON_EN_LECTURE` (claude, node,
34
34
  // git and the session's tools) and the repository. No socket of the session comes back. Of
35
- // the machine's credentials, only claude's own are in sight.
35
+ // the machine's credentials, only claude's own are in sight: the file of the remote cache of
36
+ // the poste (`~/.config/grillhouse/`, scripts/fichier-du-poste.mjs) stays out, and the
37
+ // session's runs keep to the local cache of the main tree that every copy shares.
36
38
  // - A project that names its published version (`grillhouse.outil`) gets `~/.cache/grillhouse/outil`
37
39
  // read-only, the version installed by the envelope before the session starts: the write lock
38
40
  // runs on that version, never on the code of the copy it guards.
@@ -227,7 +227,7 @@ echec=$(mktemp)
227
227
  # its advance to main, its work kept in the copy, a conflict stopping the launch, marked in the
228
228
  # files, the log naming each one; then the pose of the submodules, their mount, the installation.
229
229
  # The list the pose fixes is the one every mount gets, whatever the installation rewrites.
230
- partages=$(node "$ici/travail-de-la-copie.mjs" preparer "$copie" ${cible:+"$cible"}) || exit 1
230
+ partages=$(node "$ici/travail-de-la-copie.mjs" preparer "$copie" ${cible:+"$cible"} --role "$role") || exit 1
231
231
  monter() { bash "$ici/../sous-modules.sh" monter "$copie" --partages "$partages" "$@"; }
232
232
  if [ -f "$copie/package.json" ]; then
233
233
  # The build of the copy for the session's plan, by the module of its language (`construire`),
@@ -29,12 +29,26 @@
29
29
  // copy brought back to HEAD, moved forward, the lot applied three ways. The lot waits in the
30
30
  // copy's own git directory (`git rev-parse --git-dir`, `grillhouse-travail.patch`) while the
31
31
  // copy moves, and goes once it is applied.
32
+ // - The lot applies file by file (one `git apply --3way` per file, its patch alone): a file that
33
+ // fails touches none of the others. A file in conflict keeps its marks; a file git refuses
34
+ // without marks (a deletion of a file main changed) stays alone in the lot kept in the git
35
+ // directory, named in the message; the untracked files stay in place.
32
36
  // - Applied without conflict: the index is left as HEAD has it; exit 0.
33
37
  // - In conflict: the copy stays as `git merge` leaves it, the conflicts marked in the files and
34
38
  // unmerged in the index; the output names the copy and each file in conflict; exit 1.
35
- // - A copy whose lot still waits in its git directory (git refused it whole, as a deletion of
36
- // a file main changed) is not touched: the output names the file and how to take it back;
37
- // exit 1. So no relaunch loses it.
39
+ // - A copy whose lot still waits in its git directory is not touched: the output names the files
40
+ // and how to take them back; exit 1. So no relaunch loses it.
41
+ // - With `--role <role>` (`ecrit`), the launch of a session of the role that writes at least one
42
+ // of the files in conflict or of the lot kept is accepted (exit 0): its session receives its
43
+ // files alone, the marks in the copy or the lot as it waits, the other role's files staying
44
+ // marked or in the lot until its own session. A role that writes none gets the refusal. The
45
+ // circuit plays the same rule before a pass (scripts/circuit.mjs `avantLaPasse`, the gesture
46
+ // `conflit-de-l-avance`): the testwriter first for a test or the shared test material
47
+ // (`estUnTest`), then the developpeur, the session of each coming back to the pass, which
48
+ // prepares the copy again (`suspects`, the files of the conflict whose marks are looked for
49
+ // even when the index no longer says them in conflict); a conflict the session of the role
50
+ // does not lift goes up to the supervisor, the stop « lancement », each file named. A file
51
+ // without marker left in the copy counts as resolved (put in the index by the circuit).
38
52
  // - A copy still in conflict (unmerged entries in its index) or whose branch has left main
39
53
  // (commits on both sides, no fast-forward) is not touched; the output says why; exit 1. A
40
54
  // fast-forward that fails after the work is set aside (an untracked file in the way) gives
@@ -53,7 +67,7 @@
53
67
  // and open-synth-descriptors, each copy moved by hand). A lot in conflict on another file is not
54
68
  // regenerated: its conflicts come first.
55
69
  import { spawnSync } from 'node:child_process';
56
- import { existsSync, rmSync, statSync, writeFileSync, writeSync } from 'node:fs';
70
+ import { existsSync, readFileSync, rmSync, statSync, writeFileSync, writeSync } from 'node:fs';
57
71
  import path from 'node:path';
58
72
  import { pathToFileURL } from 'node:url';
59
73
  import { couvertPar, engendresDe, regenerer, touchesPar } from '../engendres.mjs';
@@ -102,31 +116,46 @@ function lesCles(copie) {
102
116
  }
103
117
 
104
118
  /**
105
- * Applies the lot <lot> (a Buffer of `git diff --binary`) three ways to <copie>: `conflits`, the
106
- * files in conflict, null when git refuses the lot outright. With <cles> (`lesCles`), the generated
107
- * files the lot (or one of <autres>, the copy's untracked files) touches are left out, then written
108
- * again by their command once the lot applies without conflict; `refus`, a command that fails.
119
+ * Applies the lot <lot> (a Buffer of `git diff --binary`) three ways to <copie>, file by file:
120
+ * `conflits`, the files that keep their marks; `enAttente`, the files git refuses without marks (a
121
+ * deletion of a file main changed), whose patches are `restant`. With <cles> (`lesCles`), the
122
+ * generated files the lot (or one of <autres>, the copy's untracked files) touches are left out,
123
+ * then written again by their command once the lot applies without conflict; `refus`, a command
124
+ * that fails.
109
125
  * @param {string} copie
110
126
  * @param {Buffer} lot
111
127
  * @param {{ engendres: any[], env: NodeJS.ProcessEnv } | null} [cles]
112
128
  * @param {string[]} [autres]
113
- * @returns {{ conflits: string[] | null, refus?: string | null }}
129
+ * @returns {{ conflits: string[], enAttente: string[], restant: Buffer, refus?: string | null }}
114
130
  */
115
131
  function appliquer(copie, lot, cles = null, autres = []) {
116
132
  const fichiers = cles ? [...fichiersDuLot(copie, lot), ...autres] : [];
117
133
  const touches = cles ? touchesPar(cles.engendres, fichiers) : [];
118
134
  const exclus = fichiers.filter(f => touches.some(e => couvertPar(e.entiers, f)));
119
- const r = git(
120
- copie,
121
- ['apply', '--3way', '--allow-empty', ...exclus.map(f => `--exclude=${f}`), '-'],
122
- lot
123
- );
124
- const conflits = enConflit(copie);
125
- if (r.status !== 0 && !conflits.length) {
126
- return { conflits: null };
135
+ // One call of `git apply --3way` per file: a file that fails touches none of the others.
136
+ const conflits = [];
137
+ const enAttente = [];
138
+ const gardes = [];
139
+ for (const morceau of morceauxDuLot(lot)) {
140
+ const noms = fichiersDuLot(copie, morceau);
141
+ if (noms.length && noms.every(f => exclus.includes(f))) {
142
+ continue;
143
+ }
144
+ const r = git(copie, ['apply', '--3way', '--allow-empty', '-'], morceau);
145
+ if (r.status === 0) {
146
+ continue;
147
+ }
148
+ const marques = enConflit(copie).filter(f => noms.includes(f));
149
+ if (marques.length) {
150
+ conflits.push(...marques);
151
+ } else {
152
+ enAttente.push(...noms.slice(-1));
153
+ gardes.push(morceau);
154
+ }
127
155
  }
128
- if (conflits.length || !touches.length || !cles) {
129
- return { conflits };
156
+ const restant = Buffer.concat(gardes);
157
+ if (conflits.length || enAttente.length || !touches.length || !cles) {
158
+ return { conflits, enAttente, restant };
130
159
  }
131
160
  const refus = regenerer({
132
161
  refs: touches.map(e => ({ ...e, cadre: false })),
@@ -139,7 +168,73 @@ function appliquer(copie, lot, cles = null, autres = []) {
139
168
  }),
140
169
  dansCopie: (...args) => spawnSync('git', ['-C', copie, ...args], { encoding: 'utf8' }),
141
170
  });
142
- return { conflits, refus };
171
+ return { conflits, enAttente, restant, refus };
172
+ }
173
+
174
+ /**
175
+ * The lot <lot> cut into the patch of each file (`diff --git` to the next), as Buffers.
176
+ * @param {Buffer} lot
177
+ * @returns {Buffer[]}
178
+ */
179
+ function morceauxDuLot(lot) {
180
+ return String(lot.toString('latin1'))
181
+ .split(/(?=^diff --git )/m)
182
+ .filter(m => m.startsWith('diff --git '))
183
+ .map(m => Buffer.from(m, 'latin1'));
184
+ }
185
+
186
+ // Whether the file <f> of <copie> carries a conflict marker (`<<<<<<< ` or `>>>>>>> ` at the head
187
+ // of a line), as git writes them.
188
+ function porteDesMarques(copie, f) {
189
+ const chemin = path.join(copie, f);
190
+ return existsSync(chemin) && /^(<{7}|>{7}) /m.test(readFileSync(chemin, 'latin1'));
191
+ }
192
+
193
+ // The files of <copie> that carry no conflict marker any more, among those unmerged: the work of a
194
+ // session that resolved them. Each goes to the index as resolved; the index is then left as HEAD has
195
+ // it once no conflict remains.
196
+ function releverLesResolus(copie) {
197
+ const a = enConflit(copie);
198
+ const resolus = a.filter(f => existsSync(path.join(copie, f)) && !porteDesMarques(copie, f));
199
+ for (const f of resolus) {
200
+ git(copie, ['add', '--', f]);
201
+ }
202
+ if (resolus.length && resolus.length === a.length) {
203
+ git(copie, ['reset', '-q']);
204
+ }
205
+ }
206
+
207
+ /**
208
+ * The files of <fichiers> by role: `{ testwriter, developpeur, roles }`, the testwriter's those
209
+ * <estUnTest> (the rule of a test file of the module of the language) judges, the developpeur's the
210
+ * others; `roles`, the order of the sessions, the testwriter first, a role without file absent.
211
+ * @param {string[]} fichiers
212
+ * @param {(fichier: string) => unknown} estUnTest
213
+ */
214
+ export function rolesDuConflit(fichiers, estUnTest) {
215
+ const testwriter = fichiers.filter(f => Boolean(estUnTest(f)));
216
+ const developpeur = fichiers.filter(f => !estUnTest(f));
217
+ const roles = [
218
+ testwriter.length ? 'testwriter' : null,
219
+ developpeur.length ? 'developpeur' : null,
220
+ ];
221
+ return { testwriter, developpeur, roles: roles.filter(r => r !== null) };
222
+ }
223
+
224
+ /**
225
+ * Whether the role <role> writes a file, as a function of the file: the testwriter those
226
+ * <estUnTest> judges, the developpeur the others, any other role none (undefined).
227
+ * @param {string} role
228
+ * @param {(fichier: string) => unknown} estUnTest
229
+ */
230
+ export function ecritPar(role, estUnTest) {
231
+ if (role === 'testwriter') {
232
+ return f => Boolean(estUnTest(f));
233
+ }
234
+ if (role === 'developpeur') {
235
+ return f => !estUnTest(f);
236
+ }
237
+ return undefined;
143
238
  }
144
239
 
145
240
  /**
@@ -157,8 +252,11 @@ export function reporter(copie, { base, pointe }) {
157
252
  return { ok: false, message: cles.refus };
158
253
  }
159
254
  const a = appliquer(copie, d.stdout, cles);
160
- if (a.conflits === null) {
161
- return { ok: false, message: `⛔ Le lot ne s'applique pas à la copie ${copie}.` };
255
+ if (a.enAttente.length) {
256
+ return {
257
+ ok: false,
258
+ message: `⛔ Le lot ne s'applique pas à la copie ${copie} pour : ${a.enAttente.join(', ')}.`,
259
+ };
162
260
  }
163
261
  const r = git(copie, ['reset', '-q']);
164
262
  if (a.refus) {
@@ -167,34 +265,68 @@ export function reporter(copie, { base, pointe }) {
167
265
  return r.status === 0 ? { ok: true, message: '' } : { ok: false, message: texte(r) };
168
266
  }
169
267
 
268
+ const lotEnAttente = (copie, garde, fichiers) =>
269
+ `⛔ Le travail de la copie ${copie} attend dans ${garde}, que git n'a pas pu remettre en place pour :\n${fichiers.map(f => ` ${f}`).join('\n')}\nIl se reprend à la main (git apply --3way ${garde}, ou il se jette), puis le fichier se retire, avant une relance ; le circuit relance le rôle qui écrit ces fichiers.`;
270
+
170
271
  const conflit = (copie, conflits, entete) =>
171
272
  [entete, 'Fichiers en conflit :', ...conflits.map(f => ` ${f}`)].join('\n');
172
273
 
173
274
  /**
174
- * Moves <copie> forward to <cible>, its local work kept in the copy; returns `{ ok, message }`.
275
+ * Moves <copie> forward to <cible>, its local work kept in the copy; returns `{ ok, message,
276
+ * conflits, enAttente }`, the files that keep their marks and those that wait alone in the kept
277
+ * lot. With <ecrit> (whether the role relaunched writes a file), a copy that keeps conflicts or a
278
+ * lot waiting is accepted (`ok`) when that role writes one of their files. <suspects>, the files
279
+ * an earlier advance left in conflict: one that still carries its marks counts as in conflict,
280
+ * even when the index no longer says so (a session wrote it, or put it in the index, unresolved).
175
281
  * @param {string} copie
176
282
  * @param {string} cible
283
+ * @param {{ ecrit?: (fichier: string) => boolean, suspects?: string[] }} [o]
177
284
  */
178
- export function avancer(copie, cible) {
179
- const restants = enConflit(copie);
180
- if (restants.length) {
181
- return {
182
- ok: false,
183
- message: conflit(
184
- copie,
185
- restants,
186
- `⛔ La copie ${copie} garde des conflits non résolus ; ils se résolvent dans la copie avant une relance.`
187
- ),
188
- };
189
- }
285
+ export function avancer(copie, cible, { ecrit, suspects = [] } = {}) {
286
+ releverLesResolus(copie);
287
+ const restants = [
288
+ ...new Set([...enConflit(copie), ...suspects.filter(f => porteDesMarques(copie, f))]),
289
+ ];
190
290
  const garde = path.join(
191
291
  path.resolve(copie, String(git(copie, ['rev-parse', '--git-dir']).stdout).trim()),
192
292
  LOT
193
293
  );
294
+ // The deletions a session has done in the copy leave the kept lot.
194
295
  if (existsSync(garde)) {
296
+ const morceaux = morceauxDuLot(readFileSync(garde));
297
+ const reste = morceaux.filter(m =>
298
+ fichiersDuLot(copie, m).some(f => existsSync(path.join(copie, f)))
299
+ );
300
+ if (morceaux.length && reste.length < morceaux.length) {
301
+ if (reste.length) {
302
+ writeFileSync(garde, Buffer.concat(reste));
303
+ } else {
304
+ rmSync(garde, { force: true });
305
+ }
306
+ }
307
+ }
308
+ const attendus = existsSync(garde) ? fichiersDuLot(copie, readFileSync(garde)) : [];
309
+ if (restants.length || existsSync(garde)) {
310
+ const voulu = ecrit ? [...restants, ...attendus].some(f => ecrit(f)) : false;
311
+ // The role relaunched receives its files alone.
312
+ const siens = liste => (voulu ? liste.filter(f => ecrit(f)) : liste);
313
+ const message = [
314
+ restants.length
315
+ ? conflit(
316
+ copie,
317
+ restants,
318
+ `⛔ La copie ${copie} garde des conflits non résolus ; ils se résolvent dans la copie avant une relance.`
319
+ )
320
+ : null,
321
+ existsSync(garde) ? lotEnAttente(copie, garde, attendus) : null,
322
+ ]
323
+ .filter(Boolean)
324
+ .join('\n');
195
325
  return {
196
- ok: false,
197
- message: `⛔ Le travail de la copie ${copie} attend dans ${garde}, que git n'a pas pu remettre en place ; il se reprend à la main (git apply --3way ${garde}, ou il se jette), puis le fichier se retire, avant une relance.`,
326
+ ok: voulu,
327
+ message: voulu ? '' : message,
328
+ conflits: siens(restants),
329
+ enAttente: siens(attendus),
198
330
  };
199
331
  }
200
332
  const cles = lesCles(copie);
@@ -234,8 +366,12 @@ export function avancer(copie, cible) {
234
366
  const remis = git(copie, ['reset', '-q', '--hard']);
235
367
  const ff = remis.status === 0 ? git(copie, ['merge', '-q', '--ff-only', cible]) : remis;
236
368
  if (ff.status !== 0) {
237
- const rendu = appliquer(copie, d.stdout).conflits;
238
- if (rendu !== null && rendu.length === 0 && git(copie, ['reset', '-q']).status === 0) {
369
+ const rendu = appliquer(copie, d.stdout);
370
+ if (
371
+ rendu.conflits.length === 0 &&
372
+ rendu.enAttente.length === 0 &&
373
+ git(copie, ['reset', '-q']).status === 0
374
+ ) {
239
375
  rmSync(garde, { force: true });
240
376
  return {
241
377
  ok: false,
@@ -248,22 +384,35 @@ export function avancer(copie, cible) {
248
384
  };
249
385
  }
250
386
  const libres = lignes(git(copie, ['ls-files', '--others', '--exclude-standard']));
251
- const { conflits, refus } = appliquer(copie, d.stdout, cles, libres);
252
- if (conflits === null) {
253
- return {
254
- ok: false,
255
- message: `⛔ Le travail de la copie ${copie} ne s'applique pas sur main ; il reste dans ${garde}.`,
256
- };
387
+ const { conflits, enAttente, restant, refus } = appliquer(copie, d.stdout, cles, libres);
388
+ if (enAttente.length) {
389
+ writeFileSync(garde, restant);
390
+ } else {
391
+ rmSync(garde, { force: true });
257
392
  }
258
- rmSync(garde, { force: true });
259
- if (conflits.length) {
393
+ if (conflits.length || enAttente.length) {
394
+ if (!conflits.length) {
395
+ git(copie, ['reset', '-q']);
396
+ }
397
+ const message = [
398
+ conflits.length
399
+ ? conflit(
400
+ copie,
401
+ conflits,
402
+ `⛔ Le travail en cours de la copie entre en conflit avec main ; il reste dans la copie ${copie}, ses conflits marqués dans ses fichiers.`
403
+ )
404
+ : null,
405
+ enAttente.length ? lotEnAttente(copie, garde, enAttente) : null,
406
+ ]
407
+ .filter(Boolean)
408
+ .join('\n');
409
+ const voulu = ecrit ? [...conflits, ...enAttente].some(f => ecrit(f)) : false;
410
+ const siens = liste => (voulu ? liste.filter(f => ecrit(f)) : liste);
260
411
  return {
261
- ok: false,
262
- message: conflit(
263
- copie,
264
- conflits,
265
- `⛔ Le travail en cours de la copie entre en conflit avec main ; il reste dans la copie ${copie}, ses conflits marqués dans ses fichiers.`
266
- ),
412
+ ok: voulu,
413
+ message: voulu ? '' : message,
414
+ conflits: siens(conflits),
415
+ enAttente: siens(enAttente),
267
416
  };
268
417
  }
269
418
  const r = git(copie, ['reset', '-q']);
@@ -285,9 +434,10 @@ const SOUS_MODULES = path.join(import.meta.dirname, '..', 'sous-modules.sh');
285
434
  * command goes to the file descriptor <sortie>; returns `{ ok, message, partages }`.
286
435
  * @param {string} copie
287
436
  * @param {string | null} cible
288
- * @param {{ env?: NodeJS.ProcessEnv, sortie?: number }} [o]
437
+ * @param {{ env?: NodeJS.ProcessEnv, sortie?: number, ecrit?: (fichier: string) => boolean,
438
+ * suspects?: string[] }} [o]
289
439
  */
290
- export function preparer(copie, cible, { env = process.env, sortie = 2 } = {}) {
440
+ export function preparer(copie, cible, { env = process.env, sortie = 2, ecrit, suspects } = {}) {
291
441
  // A command of the submodules whose error output is read: kept on <sortie> as well when it
292
442
  // succeeds, as the launcher's log kept it.
293
443
  const bash = (args, stdio) => {
@@ -311,7 +461,7 @@ export function preparer(copie, cible, { env = process.env, sortie = 2 } = {}) {
311
461
  if (g.status !== 0) {
312
462
  return echec(g, 'La garde des sous-modules');
313
463
  }
314
- const a = avancer(copie, cible);
464
+ const a = avancer(copie, cible, { ecrit, suspects });
315
465
  if (!a.ok) {
316
466
  return { ...a, partages: '' };
317
467
  }
@@ -356,16 +506,26 @@ export function preparer(copie, cible, { env = process.env, sortie = 2 } = {}) {
356
506
  }
357
507
 
358
508
  if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
359
- const [geste, copie, ...reste] = process.argv.slice(2);
509
+ const [geste, copie, ...tout] = process.argv.slice(2);
510
+ // `--role <role>` (preparer): the role the session launched is, whose files a conflict or a lot
511
+ // kept may be.
512
+ const iRole = tout.indexOf('--role');
513
+ const role = iRole >= 0 ? tout[iRole + 1] : null;
514
+ const reste = iRole >= 0 ? tout.filter((_, i) => i !== iRole && i !== iRole + 1) : tout;
515
+ let ecrit;
516
+ if (geste === 'preparer' && role) {
517
+ const { langageDe } = await import('../langages.mjs');
518
+ ecrit = ecritPar(role, f => langageDe(copie).estUnTest(f, copie));
519
+ }
360
520
  const r =
361
521
  geste === 'reporter' && reste.length === 2
362
522
  ? reporter(copie, { base: reste[0], pointe: reste[1] })
363
523
  : geste === 'preparer' && reste.length <= 1
364
- ? preparer(copie, reste[0] ?? null)
524
+ ? preparer(copie, reste[0] ?? null, { ecrit })
365
525
  : {
366
526
  ok: false,
367
527
  message:
368
- 'usage: travail-de-la-copie.mjs reporter <copie> <base> <pointe> | preparer <copie> [<cible>]',
528
+ 'usage: travail-de-la-copie.mjs reporter <copie> <base> <pointe> | preparer <copie> [<cible>] [--role <role>]',
369
529
  };
370
530
  // `preparer` prints the list its pose fixes on stdout, its messages on stderr.
371
531
  if (geste === 'preparer') {
@@ -131,6 +131,11 @@ export const ARRETS = {
131
131
  'sans-livraison': 15,
132
132
  'relecture-arret': 16,
133
133
  integration: 17,
134
+ // The resumption of the integration of a lot already on main: a lot neither on main nor in the
135
+ // copy (`lot-absent`), or a copy that does not get removed (`copie-gardee`); both at the code of
136
+ // the integration stop (grillhouse-bf5.2).
137
+ 'lot-absent': 17,
138
+ 'copie-gardee': 17,
134
139
  'hors-portee': 19,
135
140
  besoin: 20,
136
141
  questionnement: 22,
@@ -197,7 +202,7 @@ export const GESTES = [
197
202
  genre: 'rejeu',
198
203
  geste: 'la commande joue une seconde fois',
199
204
  regle:
200
- 'une commande des contrôles hors de la passe finale, ou l’intégration, à 75 rejoue une fois avant l’arrêt',
205
+ 'une commande des contrôles hors de la passe finale à 75 rejoue une fois avant l’arrêt',
201
206
  cas: 'A12 : un contrôle à 75, rejoué avant de conclure à la charge',
202
207
  },
203
208
  {
@@ -218,7 +223,7 @@ export const GESTES = [
218
223
  genre: 'rien-a-livrer',
219
224
  geste: 'aux contrôles, qui jugent le lot',
220
225
  regle:
221
- 'un développeur qui ne change aucun fichier du plan n’a rien à livrer quand les contrôles sont verts ; rouges, l’arrêt monte (sans-livraison) ; sur le lot que l’intégration refuse, pour un développeur que --depuis developpeur lance, le geste ne joue pas : il est relancé une fois avec le refus',
226
+ 'un développeur qui ne change aucun fichier du plan n’a rien à livrer quand les contrôles sont verts ; rouges, l’arrêt monte (sans-livraison), sauf le rouge d’une référence que le lot fait baisser, la dette des gardes, qui se régénère au lieu d’arrêter ; sur le lot que l’intégration refuse, pour un développeur que --depuis developpeur lance, le geste ne joue pas : il est relancé une fois avec le refus',
222
227
  cas: 'BP 320.9 : 995-tools n’a rien à livrer, 4 montées et 49 min (B5)',
223
228
  },
224
229
  {
@@ -229,6 +234,14 @@ export const GESTES = [
229
234
  'le plan dit le ticket mécanique, avec sa raison et sa commande (`sorte` de la fiche de l’explorateur) : un geste sans comportement neuf ; tant qu’aucun testwriter ni développeur n’a travaillé le lot, un rouge des contrôles ou un RENDU monte, sans relancer personne',
230
235
  cas: 'BP 320.16 : 38 outils déplacés par mv, 117 commentaires ; BP 320.40.1 : une variable inutilisée, 4 séances ; BP 322.11.1 : l’outil de test monté sur 31 paquets',
231
236
  },
237
+ {
238
+ genre: 'conflit-de-l-avance',
239
+ geste:
240
+ 'au rôle qui écrit les fichiers en conflit ou au lot gardé, les marques posées dans la copie : le testwriter pour un test ou la matière de test partagée, le développeur pour le code, le testwriter d’abord puis le développeur sur les fichiers des deux',
241
+ regle:
242
+ 'l’avance d’une copie sur main laisse des fichiers en conflit ou un lot gardé : le rôle que `estUnTest` du module du langage désigne pour chacun les écrit ; un conflit que la seconde séance du rôle ne lève pas monte (lancement)',
243
+ cas: 'SH-b52.2 : marques dans 2 fichiers de test, résolues à la main par le superviseur ; SH-br0.3 : 8 fichiers de test dans le lot gardé, la copie sur main sans eux',
244
+ },
232
245
  ];
233
246
 
234
247
  // The gesture of name <genre>, or null.
@@ -268,6 +281,10 @@ export const MONTEES = Object.fromEntries(
268
281
  'La relecture ne rend pas le lot à un agent (un constat sans destinataire valide, un constat au testwriter que le plan saute, un lot mécanique rendu, un critère en cause, ou la troisième relecture rendue) : que devient le plan, et qui reprend ?',
269
282
  integration:
270
283
  'L’intégration refuse le lot, ou la file rouvre le ticket : que corrige le lot, et qui le reprend ?',
284
+ 'lot-absent':
285
+ 'La reprise de l’intégration ne trouve le lot ni sur main ni dans la copie : que devient le lot, et qui le reprend ?',
286
+ 'copie-gardee':
287
+ 'Le lot est sur main, mais la copie ou son dossier de travail ne se retire pas : qu’est-ce qui la retient, et se lève-t-il pour reprendre ?',
271
288
  'hors-portee':
272
289
  'L’agent se dit bloqué hors de sa portée : le plan s’étend-il au paquet qu’il nomme, ou un autre agent lève-t-il le reste ?',
273
290
  besoin: 'Une réponse manque pour avancer : laquelle ?',
@@ -50,12 +50,13 @@
50
50
  // an effect not written has its outcome, said on the error output or the failure of its
51
51
  // activity;
52
52
  // - the acts of the queue of a project (scripts/integration/file.mjs, grillhouse-4nr.8): `situer`,
53
- // where the lot of a ticket stands (`situerLeLot`); `avancer`, main moved onto its branch
54
- // (`avancerMain`), the ticket told of a branch out of the queue or kept (`direLIssue`);
55
- // `fermer`, the ticket closed and main pushed (`fermerLEntree`); `ci`, one reading of the CI of
56
- // a commit (`lireUneFoisLaCI`); `conclure`, the CI concluded at the ticket (`conclureLaCI`);
57
- // `effet-de-la-file`, one effect they gave back, under the key of its activity. Their lines go
58
- // to the error output.
53
+ // where the lot of a ticket stands (`situerLeLot`); `brancher`, the branch made the candidate its
54
+ // CI judges and pushed (`preparerLaBranche`); `ci`, one reading of the CI of a commit
55
+ // (`lireUneFoisLaCI`); `conclure`, the CI concluded at the ticket (`conclureLaCI`); `avancer`,
56
+ // main moved onto the candidate (`avancerMain`); each of `brancher` and `avancer` telling the
57
+ // ticket of a branch out of the queue or kept (`direLIssue`); `fermer`, the ticket closed and main
58
+ // pushed (`fermerLEntree`); `effet-de-la-file`, one effect they gave back, under the key of its
59
+ // activity. Their lines go to the error output.
59
60
  import { appendFileSync, readFileSync } from 'node:fs';
60
61
  import path from 'node:path';
61
62
  import { pathToFileURL } from 'node:url';
@@ -75,6 +76,9 @@ import {
75
76
  monter,
76
77
  ouvrirJusquAuPlan,
77
78
  publierLArret,
79
+ SANS_CONFLIT,
80
+ SUR_LA_POINTE,
81
+ suiteDuConflit,
78
82
  unPasDuPlan,
79
83
  } from './circuit.mjs';
80
84
  import {
@@ -84,9 +88,10 @@ import {
84
88
  fermerLEntree,
85
89
  lireUneFoisLaCI,
86
90
  outilsDeLaFile,
91
+ preparerLaBranche,
87
92
  situerLeLot,
88
93
  } from './integration/file.mjs';
89
- import { avancementDeLaCI, avecLAvancementDuTravail } from './avancement.mjs';
94
+ import { avancementDeLaCI } from './avancement.mjs';
90
95
  import { ecrireLEffet } from './effets.mjs';
91
96
  import { Arret, geste } from './ticket-du-circuit.mjs';
92
97
 
@@ -232,10 +237,29 @@ const ACTES = {
232
237
  const { nom, rapport, piece, question } = pointe.arret;
233
238
  return { arret: { leve: { nom, rapport, piece, question } }, etat, menee };
234
239
  }
240
+ if (pointe.conflit) {
241
+ // The copy's advance left files in conflict, or a lot kept: the role that writes the first
242
+ // of them is relaunched (the decision of the workflow), then the pass prepares again.
243
+ geste(ctx, 'conflit-de-l-avance');
244
+ const { role, memoire } = suiteDuConflit(ctx, etape, pointe.conflit);
245
+ return {
246
+ conflit: { role, fichiers: pointe.conflit.fichiers, rapport: pointe.conflit.rapport },
247
+ memoire: { regeneration: pointe.regeneration ?? null, ...memoire },
248
+ etat,
249
+ menee,
250
+ };
251
+ }
235
252
  if (pointe.avancee) {
236
253
  appendFileSync(ctx.journal, 'la copie avance sur la pointe de main avant la passe.\n');
237
254
  }
238
- return { memoire: { regeneration: pointe.regeneration ?? null }, etat, menee };
255
+ return {
256
+ memoire: {
257
+ regeneration: pointe.regeneration ?? null,
258
+ ...(SUR_LA_POINTE.has(etape.etape) ? SANS_CONFLIT : {}),
259
+ },
260
+ etat,
261
+ menee,
262
+ };
239
263
  });
240
264
  },
241
265
  async fait(
@@ -394,20 +418,19 @@ Object.assign(ACTES, {
394
418
  async situer({ racine, ticket }) {
395
419
  return situerLeLot(laFile(racine), ticket);
396
420
  },
397
- // The replay of the ticket's branch on main writes the progress of its `npm run verifier` in
398
- // the working directory of the ticket, where the board reads it while the circuit waits for the
399
- // queue (`avecLAvancementDuTravail`, the kind `file`); a lot entered keeps it until the queue is done
400
- // with the ticket closed, which removes the working directory (`retirerLeTravail`).
401
- async avancer({ racine, ticket, branche }) {
421
+ async brancher({ racine, ticket, branche }) {
402
422
  const o = laFile(racine);
403
423
  const entree = { ticket, branche };
404
- const travail = path.join(racine, '.claude', 'worktrees', `${ticket}.travail`);
405
- const r = avecLAvancementDuTravail(
406
- travail,
407
- { racine, genre: 'file', garder: lu => Boolean(lu.entre) },
408
- () => avancerMain(o, entree)
409
- );
410
- return { ...(r.entre ? r : { issue: direLIssue(o, entree, r) }), effets: o.rendus };
424
+ const r = preparerLaBranche(o, entree);
425
+ return { ...(r.entre || r.candidat ? r : { issue: direLIssue(o, entree, r) }), effets: o.rendus };
426
+ },
427
+ async avancer({ racine, ticket, branche, commit }) {
428
+ const o = laFile(racine);
429
+ const r = avancerMain(o, { ticket, branche, commit });
430
+ return {
431
+ ...(r.entre || r.bouge ? r : { issue: direLIssue(o, { ticket, branche }, r) }),
432
+ effets: o.rendus,
433
+ };
411
434
  },
412
435
  async fermer({ racine, ticket, branche, commit }) {
413
436
  const o = laFile(racine);