@roomi-fields/grillhouse 0.50.3 → 0.52.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 (150) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +68 -0
  3. package/agents/developpeur.md +1 -1
  4. package/agents/direct.md +1 -1
  5. package/agents/explorateur.md +1 -1
  6. package/agents/questionneur.md +1 -1
  7. package/agents/relecteur.md +1 -1
  8. package/agents/testwriter.md +1 -1
  9. package/cadre/templates/c/package.json +1 -0
  10. package/cadre/templates/cargo/package.json +1 -0
  11. package/cadre/templates/python/package.json +1 -0
  12. package/charte/plan.md +47 -0
  13. package/charte/preuve.md +39 -0
  14. package/charte/superviseur.md +61 -0
  15. package/charte/tests.md +38 -0
  16. package/charte.md +39 -189
  17. package/dist/machine/part-par-sorte.d.ts +16 -0
  18. package/dist/machine/part-par-sorte.js +36 -0
  19. package/dist/machine/part-par-sorte.js.map +1 -0
  20. package/dist/temporal/circuit/appel.js +1 -1
  21. package/dist/temporal/circuit/appel.js.map +1 -1
  22. package/dist/temporal/circuit/client.d.ts +4 -4
  23. package/dist/temporal/circuit/client.js +38 -16
  24. package/dist/temporal/circuit/client.js.map +1 -1
  25. package/dist/temporal/circuit/contrat.d.ts +11 -7
  26. package/dist/temporal/circuit/contrat.js +5 -9
  27. package/dist/temporal/circuit/contrat.js.map +1 -1
  28. package/dist/temporal/circuit/deroule.js +18 -6
  29. package/dist/temporal/circuit/deroule.js.map +1 -1
  30. package/dist/temporal/commande.js +12 -3
  31. package/dist/temporal/commande.js.map +1 -1
  32. package/dist/temporal/installation.d.ts +54 -3
  33. package/dist/temporal/installation.js +187 -17
  34. package/dist/temporal/installation.js.map +1 -1
  35. package/dist/temporal/places/client.d.ts +5 -1
  36. package/dist/temporal/places/client.js +23 -11
  37. package/dist/temporal/places/client.js.map +1 -1
  38. package/docs/ARCHITECTURE.md +23 -2700
  39. package/docs/INTERFACE.md +26 -10
  40. package/docs/architecture/circuit.md +61 -14
  41. package/docs/architecture/entree.md +21 -8
  42. package/docs/architecture/greffon.md +49 -20
  43. package/docs/architecture/installation.md +46 -17
  44. package/docs/architecture/machine.md +79 -39
  45. package/docs/architecture/tests.md +59 -16
  46. package/docs/lexique.md +163 -0
  47. package/hooks/hooks.json +0 -10
  48. package/hooks/register.tsx +92 -4
  49. package/package.json +2 -1
  50. package/scripts/activites.mjs +105 -65
  51. package/scripts/aiguillage.mjs +15 -8
  52. package/scripts/attente-au-tour.mjs +2 -3
  53. package/scripts/attente-de-la-machine.mjs +4 -8
  54. package/scripts/avancement.mjs +12 -8
  55. package/scripts/bilan.mjs +126 -63
  56. package/scripts/bilans-gardes.mjs +37 -0
  57. package/scripts/branche-de-nuit.mjs +2 -2
  58. package/scripts/ci-de-main.mjs +18 -21
  59. package/scripts/circuit.mjs +89 -44
  60. package/scripts/circuits-du-serveur.mjs +5 -5
  61. package/scripts/composants-affectes.mjs +30 -12
  62. package/scripts/composition-des-langages.mjs +5 -3
  63. package/scripts/conformite.mjs +1 -1
  64. package/scripts/consommation-des-passes.mjs +8 -6
  65. package/scripts/copies-finies.mjs +3 -14
  66. package/scripts/depart-du-ticket.d.mts +8 -2
  67. package/scripts/depart-du-ticket.mjs +26 -8
  68. package/scripts/direct.mjs +158 -72
  69. package/scripts/droits.mjs +165 -208
  70. package/scripts/engendres.mjs +3 -14
  71. package/scripts/entree-de-seance.mjs +35 -0
  72. package/scripts/enveloppe/enveloppe.mjs +98 -46
  73. package/scripts/enveloppe/lancer.sh +90 -66
  74. package/scripts/enveloppe/paquets-du-plan.mjs +38 -11
  75. package/scripts/enveloppe/travail-de-la-copie.mjs +192 -3
  76. package/scripts/etapes.mjs +84 -22
  77. package/scripts/faits-du-circuit.mjs +8 -2
  78. package/scripts/grillhouse-maj.mjs +43 -18
  79. package/scripts/groupe-cles.d.mts +15 -0
  80. package/scripts/groupe-cles.mjs +77 -2
  81. package/scripts/init.mjs +9 -2
  82. package/scripts/integration/rejeu.mjs +8 -1
  83. package/scripts/jointure.d.ts +24 -4
  84. package/scripts/langages/c/index.mjs +5 -2
  85. package/scripts/langages/cargo/commandes.mjs +35 -15
  86. package/scripts/langages/cargo/composants.mjs +45 -3
  87. package/scripts/langages/cargo/index.mjs +6 -3
  88. package/scripts/langages/python/commandes.mjs +50 -7
  89. package/scripts/langages/python/index.mjs +5 -2
  90. package/scripts/langages/python/squelette.mjs +2 -1
  91. package/scripts/langages/typescript/chemins-des-tests.mjs +1 -1
  92. package/scripts/langages/typescript/index.mjs +16 -14
  93. package/scripts/langages/typescript/mise-a-jour.mjs +1 -1
  94. package/scripts/langages/typescript/rapports-aux-lignes.mjs +74 -0
  95. package/scripts/langages/typescript/turbo-des-paquets.mjs +151 -38
  96. package/scripts/langages/typescript/verdict.mjs +29 -3
  97. package/scripts/langages/typescript/verifier.mjs +28 -3
  98. package/scripts/langages/typescript/vitest-config/changements.mjs +8 -6
  99. package/scripts/langages/typescript/vitest-config/lances.mjs +15 -32
  100. package/scripts/langages.mjs +54 -4
  101. package/scripts/matieres-lues.mjs +1 -1
  102. package/scripts/mesure/base-de-passe.mjs +32 -90
  103. package/scripts/migrations/serveurs-de-l-index.mjs +79 -0
  104. package/scripts/migrations/suivi-du-superviseur-retire.mjs +56 -0
  105. package/scripts/migrations.mjs +23 -7
  106. package/scripts/nuit.sh +3 -2
  107. package/scripts/paquet.mjs +1 -1
  108. package/scripts/paquets.d.ts +3 -0
  109. package/scripts/paquets.mjs +88 -1
  110. package/scripts/passe-de-la-machine.mjs +109 -36
  111. package/scripts/places-de-la-machine.mjs +81 -29
  112. package/scripts/plafond-de-la-machine.d.mts +2 -5
  113. package/scripts/plafond-de-la-machine.mjs +9 -9
  114. package/scripts/reprise.mjs +42 -13
  115. package/scripts/resultats.mjs +78 -56
  116. package/scripts/retirer-les-copies-finies.mjs +1 -1
  117. package/scripts/seances.mjs +471 -133
  118. package/scripts/services-du-noyau.mjs +9 -1
  119. package/scripts/session-start.sh +22 -7
  120. package/scripts/sortie-de-seance.mjs +70 -0
  121. package/scripts/sortie.mjs +37 -6
  122. package/scripts/sous-commandes.mjs +0 -3
  123. package/scripts/superviseur.mjs +400 -162
  124. package/scripts/tableau.mjs +188 -65
  125. package/scripts/transitions.d.mts +25 -2
  126. package/scripts/transitions.mjs +137 -29
  127. package/scripts/verrous/ecriture-hors-enveloppe.mjs +31 -9
  128. package/skills/codebase-design/DESIGN-IT-TWICE.md +1 -1
  129. package/skills/developpeur/SKILL.md +38 -15
  130. package/skills/direct/SKILL.md +29 -9
  131. package/skills/domain-modeling/GLOSSARY-FORMAT.md +9 -9
  132. package/skills/domain-modeling/SKILL.md +14 -12
  133. package/skills/explorateur/SKILL.md +32 -8
  134. package/skills/grill/SKILL.md +3 -2
  135. package/skills/pitmaster/SKILL.md +80 -50
  136. package/skills/pitmaster/references/cadre.md +1 -1
  137. package/skills/pitmaster/references/consigne-agent.md +12 -11
  138. package/skills/pitmaster/references/tour.md +6 -5
  139. package/skills/relecteur/SKILL.md +13 -6
  140. package/skills/systematic-debugging/SKILL.md +281 -0
  141. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  142. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  143. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  144. package/skills/systematic-debugging/find-polluter.sh +72 -0
  145. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  146. package/skills/testwriter/SKILL.md +37 -31
  147. package/cadre/templates/projet/pitmaster/SUIVI.md +0 -22
  148. package/scripts/attente-a-l-arret.mjs +0 -114
  149. package/scripts/verrous/commande.mjs +0 -214
  150. package/scripts/verrous/verrou.mjs +0 -311
@@ -4,14 +4,15 @@
4
4
  // the same way (scripts/circuit.mjs `contexte`).
5
5
  //
6
6
  // - The ticket is read by `bd show <id> --json` in the main tree; one Beads cannot show is refused.
7
- // - Its description holds a « ## Architecture » section, by the rule of the developer's lock
8
- // (`sansArchitecture` of ./verrous/verrou.mjs): the code waits for the architecture. The
7
+ // - Its description holds a « ## Architecture » section (`sansArchitecture`, the one reading of
8
+ // the rule): the code waits for the architecture. The
9
9
  // supervisor's stop (`--arreter`) reads neither it nor the title: it does not depend on the
10
10
  // ticket's content, as GitLab cancels a pipeline whatever its configuration; its plan is empty.
11
11
  // - Its title names its plan after its last « — », separated by commas: each one a path
12
12
  // (`packages/<nom>`, or `.`), or the name of a package, which becomes its directory, read in the
13
13
  // ticket's copy when it exists, else in the main tree (`composantsLisibles`). A title without it, and
14
- // a component that names neither, are refused by their name. An act after the opening is given
14
+ // a component that names neither, are refused by their name, but a new path of the repository
15
+ // on a ticket labelled `direct`, kept as it is written. An act after the opening is given
15
16
  // the plan its workflow holds (<plan>) and reads only the subject of the title: the integration
16
17
  // removes the ticket's copy while the circuit still runs, and a component the lot creates is in
17
18
  // neither tree then.
@@ -19,8 +20,20 @@
19
20
  import { spawnSync } from 'node:child_process';
20
21
  import { existsSync } from 'node:fs';
21
22
  import path from 'node:path';
23
+ import { estUnCheminNeuf } from './enveloppe/paquets-du-plan.mjs';
22
24
  import { composantsLisibles } from './ticket-du-circuit.mjs';
23
- import { sansArchitecture } from './verrous/verrou.mjs';
25
+
26
+ /**
27
+ * The refusal of the ticket <id> whose <description> holds no "## Architecture" section, or null.
28
+ * @param {string} id
29
+ * @param {unknown} description
30
+ * @returns {string | null}
31
+ */
32
+ export function sansArchitecture(id, description) {
33
+ return /^##\s+Architecture\b/m.test(String(description ?? ''))
34
+ ? null
35
+ : `Le ticket ${id} n'a pas sa section « ## Architecture » : le code attend l'architecture. Rends la question au superviseur.`;
36
+ }
24
37
 
25
38
  /** A ticket a circuit cannot start on, by its reason. */
26
39
  export class DepartRefuse extends Error {
@@ -32,10 +45,11 @@ export class DepartRefuse extends Error {
32
45
 
33
46
  /**
34
47
  * The directory of the component <nom> of a title among <liste> (`composantsLisibles` of the repository
35
- * at <base>): `.` itself; a component by its path or its name; else a path of the repository; or a
36
- * refusal.
48
+ * at <base>): `.` itself; a component by its path or its name; else a path of the repository; else,
49
+ * for a direct ticket (<neuf>), a path the repository does not hold yet, as it is written
50
+ * (`estUnCheminNeuf`): a package is born of a direct ticket; or a refusal.
37
51
  */
38
- export function resoudreComposant(liste, base, nom) {
52
+ export function resoudreComposant(liste, base, nom, { neuf = false } = {}) {
39
53
  const brut = path.normalize(nom);
40
54
  const norme = brut.endsWith('/') ? brut.slice(0, -1) : brut;
41
55
  if (norme === '.') {
@@ -51,6 +65,9 @@ export function resoudreComposant(liste, base, nom) {
51
65
  if (!norme.startsWith('..') && existsSync(path.join(base, norme))) {
52
66
  return norme;
53
67
  }
68
+ if (neuf && estUnCheminNeuf(nom)) {
69
+ return norme;
70
+ }
54
71
  throw new DepartRefuse(
55
72
  `le composant « ${nom} » du titre ne nomme ni un paquet ni un chemin du dépôt.`
56
73
  );
@@ -115,7 +132,8 @@ export function ticketAuLancement(racine, id, { arreter = false, bd = null, plan
115
132
  const copie = path.join(racine, '.claude', 'worktrees', id);
116
133
  const base = existsSync(copie) ? copie : racine;
117
134
  const liste = composantsLisibles(base);
118
- const resoudre = nom => resoudreComposant(liste, base, nom);
135
+ const neuf = Boolean(ticket?.labels?.includes('direct'));
136
+ const resoudre = nom => resoudreComposant(liste, base, nom, { neuf });
119
137
  // The supervisor's stop reads neither the ticket's « ## Architecture » section nor its title.
120
138
  const titre = arreter
121
139
  ? { sujet: String(ticket?.title ?? id), plan: [] }
@@ -7,9 +7,19 @@
7
7
  // supervisor never writes it: it reads the lot, plays the full verification, commits, advances main
8
8
  // and pushes.
9
9
  //
10
- // npx grillhouse direct <ticket> [--paquet <chemin>]… [--contexte <texte>]
10
+ // npx grillhouse direct <ticket> --panne <texte> [--paquet <chemin>]… [--contexte <texte>]
11
11
  // npx grillhouse direct <ticket> --deverrouiller
12
12
  //
13
+ // - It exists for a failure of the engine alone, which `--panne` names: without it, or with a
14
+ // blank text, the command refuses before any work.
15
+ // - It refuses a closed ticket, and a ticket whose workflow runs on the server, a question
16
+ // included; a server that does not read (silent, or its client not built) does not stop it, the
17
+ // failure of the engine being its case, and the ticket says the check was not made.
18
+ // - Once nothing refuses it, it takes the ticket (`in_progress`), so that the queue of the tickets
19
+ // starts no circuit on it, and writes there the failure, once; each review writes its verdict.
20
+ // - It asks nothing of the arbiter of the machine: no place, and its sessions run under the mark of
21
+ // a place held, so that a closed machine does not hold them back.
22
+ //
13
23
  // - The ticket carries the label `direct`. Its packages are the components of its title, as the
14
24
  // circuit writes them (« numéro — sujet — composant, composant »), completed by each `--paquet`;
15
25
  // without any, the command refuses, naming the title. A path no package holds (the skeleton of a
@@ -34,27 +44,33 @@ import { existsSync, realpathSync } from 'node:fs';
34
44
  import path from 'node:path';
35
45
  import { pathToFileURL } from 'node:url';
36
46
  import { ecritPar, preparer } from './enveloppe/travail-de-la-copie.mjs';
37
- import { prendreUnePlace, VARIABLE_TENUE } from './places-de-la-machine.mjs';
47
+ import { circuitsDuServeur, ClientNonConstruit, ServeurMuet } from './circuits-du-serveur.mjs';
48
+ import { VARIABLE_TENUE } from './places-de-la-machine.mjs';
38
49
  import { bloquantsDeLaFiche } from './resultats.mjs';
39
- import { consigne } from './seances.mjs';
50
+ import { consigneDuRelecteurDUnLotDirect } from './seances.mjs';
40
51
 
41
52
  // The RENDU verdicts in a row that stop the command, as the circuit stops its third.
42
53
  const RENDUS_MAX = 3;
43
54
 
44
- // The requirement of the reviewer of a direct, after the instruction of the circuit's.
45
- const EXIGENCE_DU_DIRECT = [
46
- 'CE LOT EST UN DIRECT, mené hors du circuit par `npx grillhouse direct` : un seul agent, le rôle `direct`, a écrit les tests et le code ensemble. Tout constat bloquant lui est adressé : son destinataire est `developpeur`.',
47
- "La preuve du rouge n'est pas jouée : tu la tiens. Un défaut corrigé porte un test qui le reproduit, et ce test échoue sans le code du lot ; sans lui, le constat est bloquant. Un ticket de données ou le squelette d'un paquet, qui ne change aucun comportement, n'a pas de test à exiger.",
48
- ].join('\n\n');
55
+ // What the rescue command alone says of its lot to the reviewer.
56
+ const PROPRE_A_LA_VOIE_DE_SECOURS =
57
+ 'Ce lot est mené par la voie de secours `npx grillhouse direct`, réservée aux pannes du moteur.';
58
+
59
+ // The mark of a place held under which the command plays: its sessions and their commands ask the
60
+ // arbiter of the machine for no place and read no closure; each still takes its part of the poste.
61
+ const SANS_ARBITRE = 'voie-de-secours';
62
+
63
+ // What the ticket says of a launch that could not read the circuits.
64
+ const NON_VERIFIE = "La commande n'a pas pu vérifier qu'aucun circuit ne vit sur ce ticket";
49
65
 
50
66
  /**
51
- * The instruction of the reviewer of a direct: that of the circuit's reviewer (the second template
52
- * of the supervisor's skill), then what a direct asks of its lot.
67
+ * The instruction of the reviewer of a lot of the rescue command: that of a direct lot
68
+ * (`consigneDuRelecteurDUnLotDirect`), with what the command alone says of it.
53
69
  * @param {Record<string, string>} valeurs
54
70
  * @returns {string}
55
71
  */
56
72
  export function consigneDuRelecteurDuDirect(valeurs) {
57
- return `${consigne(valeurs, 1).trim()}\n\n${EXIGENCE_DU_DIRECT}\n`;
73
+ return consigneDuRelecteurDUnLotDirect(valeurs, PROPRE_A_LA_VOIE_DE_SECOURS);
58
74
  }
59
75
 
60
76
  /**
@@ -161,25 +177,59 @@ export function deverrouillerLaCopie(copie, git) {
161
177
  }
162
178
  }
163
179
 
164
- /**
165
- * The command: the agent, then the reviewer, and it stops. <ports> are what it launches
166
- * (`copie`, `verrouiller`, `avancer`, `fiches`, `lot`, `resoudre`, `seance`, `relecture`); <options> the paths
167
- * `--paquet` adds to the plan.
168
- * @param {{ id: string, ticket: { title?: string, labels?: string[] }, options?: string[], ports: any }} o
169
- * @returns {Promise<{ verdict?: string, copie?: string, constats?: object[], arret?: boolean, statut?: string, rendus?: number, fiche?: object }>}
170
- */
171
- export async function lancerLeDirect({ id, ticket, options = [], ports }) {
172
- if (!(ticket.labels ?? []).includes('direct')) {
180
+ // Refuses the ticket <id> while a workflow of its circuit runs on the server, a question included;
181
+ // returns null, or what the ticket says when the server does not read.
182
+ async function refuserUnCircuitVivant(id, ports) {
183
+ let circuits;
184
+ try {
185
+ circuits = await ports.circuits();
186
+ } catch (e) {
187
+ if (e instanceof ServeurMuet || e instanceof ClientNonConstruit) {
188
+ return `${NON_VERIFIE} : ${e.message}.`;
189
+ }
190
+ throw e;
191
+ }
192
+ if (circuits.some(c => c.ticket === id && c.fin === null)) {
173
193
  throw new Error(
174
- `Le ticket ${id} n'est pas étiqueté direct : la commande ne mène que les tickets de la voie directe (charte, « Un ticket prend l'une de trois voies »).`
194
+ `Le ticket ${id} a un circuit qui vit sur le serveur : finis-le par \`npx grillhouse circuit ${id} --arreter\` ; si son déroulé en panne ne finit pas sur ce mot, termine-le au serveur par \`temporal workflow terminate --workflow-id '${await ports.deroule()}'\`, puis relance la commande.`
175
195
  );
176
196
  }
177
- const { plan } = planDuDirect({
178
- id,
179
- titre: ticket.title ?? '',
180
- options,
181
- resoudre: ports.resoudre,
182
- });
197
+ return null;
198
+ }
199
+
200
+ // Writes at the ticket the use of the rescue way: the failure <panne>, once for each failure, and
201
+ // <nonVerifie>, when the circuits were not read, once too unless the failure is new.
202
+ async function ecrireLUsage(panne, nonVerifie, ports) {
203
+ const dits = (await ports.commentaires()).map(c => c.text);
204
+ const entree = `Voie de secours (\`npx grillhouse direct\`), panne du moteur : ${panne}`;
205
+ const neuve = !dits.some(t => t === entree || t.startsWith(`${entree}\n`));
206
+ const lignes = [
207
+ neuve ? entree : null,
208
+ nonVerifie && (neuve || !dits.some(t => t.includes(NON_VERIFIE))) ? nonVerifie : null,
209
+ ].filter(Boolean);
210
+ if (lignes.length) {
211
+ await ports.commenter(lignes.join('\n\n'));
212
+ }
213
+ }
214
+
215
+ // Plays <f> under the mark of a place held, the environment given back at its end.
216
+ async function sansArbitre(f) {
217
+ const avant = process.env[VARIABLE_TENUE];
218
+ process.env[VARIABLE_TENUE] = avant || SANS_ARBITRE;
219
+ try {
220
+ return await f();
221
+ } finally {
222
+ if (avant === undefined) {
223
+ delete process.env[VARIABLE_TENUE];
224
+ } else {
225
+ process.env[VARIABLE_TENUE] = avant;
226
+ }
227
+ }
228
+ }
229
+
230
+ // The lot of the direct <id> on the paths <plan>: the copy, then what the sheets of the reviewer
231
+ // decide.
232
+ async function menerLeLot(plan, ports) {
183
233
  const copie = ports.copie();
184
234
  ports.verrouiller(copie);
185
235
  const decision = decisionDuDirect(ports.fiches(), ports.lot());
@@ -196,24 +246,54 @@ export async function lancerLeDirect({ id, ticket, options = [], ports }) {
196
246
  };
197
247
  }
198
248
  const constats = decision.constats ?? [];
199
- // A direct holds a place of circuit of the machine, counted with the circuits, from its agent to
200
- // its review; given back at the end, whatever the end.
201
- const rendre = ports.place();
202
- try {
203
- // The copy moves onto main before the session: the files its work meets in conflict go to the
204
- // agent, who writes them all, as the author of a lot resolves his own rebase.
205
- const { fichiers = [] } = (await ports.avancer(copie)) ?? {};
206
- const fiche = await ports.seance('direct', { constats, paquets: plan, conflits: fichiers });
207
- if (fiche?.statut && fiche.statut !== 'FAIT') {
208
- return { arret: true, statut: fiche.statut, fiche, copie };
209
- }
210
- const relue = await ports.relecture({ constats });
211
- return { verdict: relue.verdict, constats: relue.constats ?? [], fiche: relue.fiche, copie };
212
- } finally {
213
- rendre();
249
+ // The copy moves onto main before the session: the files its work meets in conflict go to the
250
+ // agent, who writes them all, as the author of a lot resolves his own rebase.
251
+ const { fichiers = [] } = (await ports.avancer(copie)) ?? {};
252
+ const fiche = await ports.seance('direct', { constats, paquets: plan, conflits: fichiers });
253
+ if (fiche?.statut && fiche.statut !== 'FAIT') {
254
+ return { arret: true, statut: fiche.statut, fiche, copie };
255
+ }
256
+ const relue = await ports.relecture({ constats });
257
+ return { verdict: relue.verdict, constats: relue.constats ?? [], fiche: relue.fiche, copie };
258
+ }
259
+
260
+ /**
261
+ * The command: its refusals, which leave the ticket as it was, then the ticket taken and the use
262
+ * of the rescue way written there, then the agent, the reviewer, and it stops. <ports> are what it
263
+ * reads, writes and launches (`circuits`, `deroule`, `prendre`, `commentaires`, `commenter`,
264
+ * `copie`, `verrouiller`, `avancer`, `fiches`, `lot`, `resoudre`, `seance`, `relecture`); <panne>
265
+ * the failure of the engine that justifies it; <options> the paths `--paquet` adds to the plan.
266
+ * @param {{ id: string, ticket: { title?: string, labels?: string[], status?: string }, panne?: string | null, options?: string[], ports: any }} o
267
+ * @returns {Promise<{ verdict?: string, copie?: string, constats?: object[], arret?: boolean, statut?: string, rendus?: number, fiche?: object }>}
268
+ */
269
+ export async function lancerLeDirect({ id, ticket, panne, options = [], ports }) {
270
+ const motif = String(panne ?? '').trim();
271
+ if (!motif) {
272
+ throw new Error(SANS_PANNE);
214
273
  }
274
+ if (!(ticket.labels ?? []).includes('direct')) {
275
+ throw new Error(
276
+ `Le ticket ${id} n'est pas étiqueté direct : la commande ne mène que les tickets de la voie directe (charte, module superviseur, « Un ticket prend l'une de trois voies »).`
277
+ );
278
+ }
279
+ if (ticket.status === 'closed') {
280
+ throw new Error(`Le ticket ${id} est fermé : la commande ne le rouvre pas.`);
281
+ }
282
+ const { plan } = planDuDirect({
283
+ id,
284
+ titre: ticket.title ?? '',
285
+ options,
286
+ resoudre: ports.resoudre,
287
+ });
288
+ const nonVerifie = await refuserUnCircuitVivant(id, ports);
289
+ await ports.prendre();
290
+ await ecrireLUsage(motif, nonVerifie, ports);
291
+ return sansArbitre(() => menerLeLot(plan, ports));
215
292
  }
216
293
 
294
+ const SANS_PANNE =
295
+ "La commande est la voie de secours, réservée aux pannes du moteur : nomme celle qui la justifie par `--panne <texte>`.";
296
+
217
297
  /**
218
298
  * What the agent of a direct reads of the files its work meets in conflict with main (« aucun »
219
299
  * without any).
@@ -228,14 +308,23 @@ export function rapportDuConflit(fichiers) {
228
308
 
229
309
  // The task the agent of a direct reads at the head of its instruction.
230
310
  const TACHE_DU_DIRECT =
231
- "Ce ticket est mené en direct, hors du circuit : tu écris ses tests et son code ensemble, dans les paquets de ton plan. Un défaut corrigé porte un test qui le reproduit. Aucune preuve du rouge ni aucun contrôle du circuit ne suit ta séance : un relecteur juge ton lot, puis le superviseur le vérifie. Les constats ci-dessous, s'il y en a, viennent de ce relecteur.";
311
+ "Ce ticket est mené en direct, par la voie de secours : tu écris ses tests et son code ensemble, dans les paquets de ton plan. Un défaut corrigé porte un test qui le reproduit. Aucune preuve du rouge ni aucun contrôle du circuit ne suit ta séance : un relecteur juge ton lot, puis le superviseur le vérifie. Les constats ci-dessous, s'il y en a, viennent de ce relecteur.";
312
+
313
+ // bd writing at the ticket of <ctx> under the supervisor, who launches the command; a failed write
314
+ // throws.
315
+ function ecrireAuTicket(ctx, ...args) {
316
+ const r = ctx.bdSous('superviseur', ...args);
317
+ if (r.status !== 0) {
318
+ throw new Error(`bd ${args[0]} échoue : ${r.error?.message ?? r.stderr ?? ''}`.trim());
319
+ }
320
+ }
232
321
 
233
322
  // The ports of the command on the project at the working directory, the circuit's own sessions.
234
323
  async function portsDuProjet(id, { contexteDuSuperviseur }) {
235
324
  const { contexte } = await import('./circuit.mjs');
236
325
  const { seance, idDeSeance } = await import('./seances.mjs');
237
326
  const { arbreDeLaCopie, relire } = await import('./activites.mjs');
238
- const { lesFiches } = await import('./ticket-du-circuit.mjs');
327
+ const { lesCommentaires, lesFiches } = await import('./ticket-du-circuit.mjs');
239
328
  const ctx = contexte({ ticket: id, arreter: true, contexte: contexteDuSuperviseur });
240
329
  const git = (...a) => spawnSync('git', ['-C', ctx.racine, ...a], { encoding: 'utf8' });
241
330
  const ouverts = constats =>
@@ -259,27 +348,16 @@ async function portsDuProjet(id, { contexteDuSuperviseur }) {
259
348
  }
260
349
  return ctx.copie;
261
350
  },
262
- // The place of circuit the direct holds for its whole run: the sessions it launches then
263
- // hold nothing more (GRILLHOUSE_PLACE_TENUE), as under any place already held.
264
- place: () => {
265
- const p = prendreUnePlace({
266
- ticket: id,
267
- racine: ctx.racine,
268
- dire: l => process.stdout.write(`${l}\n`),
269
- });
270
- const avant = process.env[VARIABLE_TENUE];
271
- if (p.id) {
272
- process.env[VARIABLE_TENUE] = p.id;
273
- }
274
- return () => {
275
- if (avant === undefined) {
276
- delete process.env[VARIABLE_TENUE];
277
- } else {
278
- process.env[VARIABLE_TENUE] = avant;
279
- }
280
- p.rendre();
281
- };
351
+ // The circuits of the repository, the integrated ones included: a workflow still at its
352
+ // triage runs.
353
+ circuits: () => circuitsDuServeur(ctx.racine, { integres: true }),
354
+ deroule: async () => {
355
+ const { idDuCircuit } = await import('../dist/temporal/circuit/contrat.js');
356
+ return idDuCircuit(ctx.racine, id);
282
357
  },
358
+ prendre: () => ecrireAuTicket(ctx, 'update', id, '--status', 'in_progress'),
359
+ commentaires: () => lesCommentaires(ctx),
360
+ commenter: texte => ecrireAuTicket(ctx, 'comments', 'add', id, texte),
283
361
  verrouiller: copie => verrouillerLaCopie(copie, git),
284
362
  fiches: () =>
285
363
  lesFiches(ctx).map(e => (e.role === 'relecteur' ? { ...e, lot: e.lot?.arbre } : e)),
@@ -305,7 +383,6 @@ async function portsDuProjet(id, { contexteDuSuperviseur }) {
305
383
  derniere: true,
306
384
  seanceId: idDeSeance(ctx, 'direct'),
307
385
  evenement: 'neuve',
308
- fiche: 'developpeur',
309
386
  constats: ouverts(constats),
310
387
  rapport: conflits.length ? rapportDuConflit(conflits) : undefined,
311
388
  lectures: { lots: () => [], references: () => [] },
@@ -324,20 +401,23 @@ async function portsDuProjet(id, { contexteDuSuperviseur }) {
324
401
  };
325
402
  }
326
403
 
327
- // The command's options for <argv>: the ticket, the paths added to the plan, the context, and the
328
- // unlocking; or a usage fault.
329
- function lireLesOptions(argv) {
330
- const o = { id: null, paquets: [], contexte: null, deverrouiller: false };
404
+ /**
405
+ * The command's options for <argv>: the ticket, the failure of the engine, the paths added to the
406
+ * plan, the context, and the unlocking; or null, a usage fault.
407
+ * @param {string[]} argv
408
+ */
409
+ export function lireLesOptions(argv) {
410
+ const o = { id: null, panne: null, paquets: [], contexte: null, deverrouiller: false };
331
411
  for (let i = 0; i < argv.length; i++) {
332
412
  const a = argv[i];
333
- if (a === '--paquet' || a === '--contexte') {
413
+ if (a === '--paquet' || a === '--contexte' || a === '--panne') {
334
414
  if (i + 1 >= argv.length) {
335
415
  return null;
336
416
  }
337
417
  if (a === '--paquet') {
338
418
  o.paquets.push(argv[++i]);
339
419
  } else {
340
- o.contexte = argv[++i];
420
+ o[a.slice(2)] = argv[++i];
341
421
  }
342
422
  } else if (a === '--deverrouiller') {
343
423
  o.deverrouiller = true;
@@ -351,7 +431,7 @@ function lireLesOptions(argv) {
351
431
  }
352
432
 
353
433
  const USAGE =
354
- 'usage : npx grillhouse direct <ticket> [--paquet <chemin>]… [--contexte <texte>] | npx grillhouse direct <ticket> --deverrouiller\n';
434
+ 'usage : npx grillhouse direct <ticket> --panne <texte> [--paquet <chemin>]… [--contexte <texte>] | npx grillhouse direct <ticket> --deverrouiller\n';
355
435
 
356
436
  // The command on <argv>: its exit code.
357
437
  async function commande(argv) {
@@ -360,6 +440,11 @@ async function commande(argv) {
360
440
  process.stderr.write(USAGE);
361
441
  return 2;
362
442
  }
443
+ // Refused before any work: the context of the ticket already writes beside its copy.
444
+ if (!o.deverrouiller && !o.panne?.trim()) {
445
+ process.stderr.write(`⛔ ${SANS_PANNE}\n${USAGE}`);
446
+ return 2;
447
+ }
363
448
  const { ctx, ports, git } = await portsDuProjet(o.id, { contexteDuSuperviseur: '' });
364
449
  ctx.contexteDuDirect = o.contexte ? `${TACHE_DU_DIRECT}\n\n${o.contexte}` : TACHE_DU_DIRECT;
365
450
  if (o.deverrouiller) {
@@ -375,6 +460,7 @@ async function commande(argv) {
375
460
  const r = await lancerLeDirect({
376
461
  id: o.id,
377
462
  ticket: JSON.parse(show.stdout || '[]')[0] ?? {},
463
+ panne: o.panne,
378
464
  options: o.paquets,
379
465
  ports,
380
466
  });