@roomi-fields/grillhouse 0.24.2 → 0.24.3

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.
@@ -5,5 +5,5 @@
5
5
  "author": {
6
6
  "name": "Romain Peyrichou"
7
7
  },
8
- "version": "0.24.2"
8
+ "version": "0.24.3"
9
9
  }
package/charte.md CHANGED
@@ -56,6 +56,12 @@ mécaniques que la liste des étapes écrit (rejouer, régénérer, juger un lot
56
56
  tout autre arrêt monte au superviseur avec sa pièce, et il monte au responsable ce qui lui
57
57
  revient. Ainsi aucune séance ne juge ce qu'une règle tranche.
58
58
 
59
+ **Un agent qui a la réponse l'applique** : une décision qu'il sait trancher et qu'il recommande
60
+ (un nom, une signature, un paquet à retirer de son plan), il la prend et l'écrit dans sa fiche,
61
+ sans s'arrêter ; seule monte une question qui revient au responsable (le langage, l'architecture,
62
+ un écart à la référence) ou dont il n'a pas la réponse. Ainsi le circuit n'attend que les vraies
63
+ décisions.
64
+
59
65
  **Tous les agents jugent sur le plan** : une décision du responsable entre dans la description du
60
66
  ticket, comme une RFC amendée ; les commentaires restent l'historique. Ainsi chaque agent lit la
61
67
  même décision.
@@ -77,11 +77,16 @@ références, dont 163 d'attente).
77
77
  avoir relevé l'existant, qu'une revue la lit une fois, que l'auteur répond une fois et que ce qui
78
78
  reste ouvert va à qui décide, l'étape 1 du circuit (1 Plan) lance l'explorateur hors de
79
79
  l'enveloppe ; il relève les composants (`npx grillhouse composants-affectes <ticket>`) et finit sur
80
- sa fiche : les critères, les paquets à toucher, ses questions ouvertes avec leur pièce. Le circuit
80
+ sa fiche : les critères, les paquets à toucher, les composants du relevé qu'il écarte avec leur
81
+ raison, ses questions ouvertes avec leur pièce. Le circuit rejoue le relevé sur le plan, sans
82
+ séance, comme il contrôle les paquets : un composant du relevé ni touché ni écarté rend la fiche
83
+ non conforme, comme la section des composants touchés d'un document de conception dit pour
84
+ chacun s'il change, ou pourquoi il reste. Le circuit
81
85
  écrit le plan au ticket : les paquets finissent son titre, la seule liste que lit l'enveloppe de
82
86
  chaque séance d'après. Le questionneur le lit une fois ; l'explorateur, sa séance
83
87
  reprise, répond une fois, CHANGE ou GARDE par question ; ce qui reste ouvert monte au superviseur
84
- (« questionnement »), sinon le circuit passe aux tests. Ainsi les questions utiles se posent avant
88
+ (« questionnement »), sinon le circuit passe aux tests. Un plan passé ne se rejoue que si son
89
+ titre ou ses critères changent. Ainsi les questions utiles se posent avant
85
90
  le plan, et le plan ne tourne pas en rond (BP 320.9 : 132 tours de questions, 29 critères dont 2
86
91
  utiles).
87
92
 
@@ -110,7 +115,7 @@ passe finale et le relecteur sur l'ensemble ; aucun composant n'est une unité d
110
115
  3 Code · 3.1 Contrôles · 4 Passe finale et relecture (4.1 Passe finale, 4.2 Régénération des
111
116
  références, 4.3 Relecture) · 5 Intégration. `--depuis <testwriter|developpeur>` rejoue le
112
117
  ticket entier depuis cette étape ; `--etendre <paquet>` ajoute un paquet au plan, puis reprend
113
- l'étape en cours. Un constat bloquant du relecteur va droit à l'agent qu'il nomme et reste ouvert
118
+ l'étape en cours, celle du testwriter après un arrêt sur un renvoi du développeur vers lui. Un constat bloquant du relecteur va droit à l'agent qu'il nomme et reste ouvert
114
119
  d'une relance à l'autre, comme un fil de revue non résolu, jusqu'à ce que le relecteur le dise
115
120
  levé ou accepte le lot. Le bilan compte par étape et par rôle. Ainsi un type change avec ses
116
121
  lecteurs en une seule séance, et un constat n'est jamais perdu (BP 320.9 : seize composants
@@ -120,10 +125,21 @@ fois).
120
125
  **Le bilan sépare les attentes** : comme le « lead time » de DORA sépare l'attente de revue du
121
126
  temps de travail, chaque montée dit qui doit répondre, et le bilan répartit l'attente entre celle
122
127
  du superviseur, celle du responsable et la nuit, la plage horaire que le projet déclare
123
- (`grillhouse.plageDeNuit` de son `package.json`, 23 h – 8 h par défaut). Son texte donne le mur,
124
- le mur hors nuit d'attente (une nuit de travail y reste) et le perdu hors attentes. Ainsi le temps perdu se lit sans la nuit ni l'attente
125
- d'une réponse (BP 320.9 : 500 min de nuit mêlées à l'attente du responsable et à celle du
126
- superviseur).
128
+ (`grillhouse.plageDeNuit` de son `package.json`, 23 h – 8 h par défaut). Une question que le
129
+ superviseur porte au responsable est l'attente du responsable : sa réponse s'écrit au ticket
130
+ pendant l'attente, sous « ## Réponse du responsable — … », seul texte d'un commentaire que le
131
+ bilan lit. Son texte donne le mur, le mur hors nuit d'attente (une nuit de travail y reste) et le
132
+ perdu hors attentes. Ainsi le temps perdu se lit sans la nuit ni l'attente d'une réponse (BP
133
+ 320.9 : 500 min de nuit mêlées à l'attente du responsable et à celle du superviseur ; BP 320.8 :
134
+ les 78 min de la réponse du responsable comptées au superviseur).
135
+
136
+ **Le bilan compte chaque séance à son coût** : le registre écrit chaque rôle tel que Claude Code
137
+ nomme l'agent d'un greffon (`grillhouse:developpeur`), et le bilan le lit comme le panneau, d'une
138
+ seule façon (`roleDeLAgent` de `etapes.mjs`). Le registre garde le total qu'une séance écrit,
139
+ comme ccusage ; sans total, ou à total nul pour des jetons dépensés (un sous-agent n'en écrit
140
+ pas), il calcule le coût sur ses jetons, au tarif de son modèle (`TARIFS` de `registre.mjs`). Ainsi
141
+ le bilan compte toutes les séances, et un sous-agent du superviseur coûte ce qu'il a dépensé (BP 320.8 : « 0 séances ; 0,00 $ » pour 25
142
+ séances et 20,36 $, et 0 $ pour un questionneur du superviseur).
127
143
 
128
144
  **Un fait porte sa pièce** : comme une revue de code cite la ligne qu'elle juge, chaque constat,
129
145
  question ou montée d'une fiche porte sa `piece`, un seul format (`lirePiece` de `resultats.mjs`) :
@@ -148,6 +164,18 @@ que le ticket, comme l'espace de travail d'un pipeline ; aucun balayage n'y touc
148
164
  l'efface à la clôture, `npx grillhouse retirer-copie` avec la copie d'un ticket fermé sans
149
165
  intégration. Ainsi une séance qui survit à son circuit garde ce qu'il lui a remis.
150
166
 
167
+ **Le circuit est un démon** (`packages/grillhouse/scripts/demon.mjs`) : comme daemon(3) et
168
+ `setsid --fork`, `npx grillhouse circuit` lance
169
+ un relais, qui lance le circuit dans une session à lui puis finit aussitôt ; le circuit n'est ni
170
+ dans le groupe de son appelant ni sous lui dans l'arbre des processus. L'appelant relaie sa sortie
171
+ jusqu'à sa dernière ligne et rend son code de fin ; mort, il laisse le circuit aller à sa fin.
172
+ L'état du circuit le nomme par son numéro et son heure de départ (`processus`, `depart`, le champ
173
+ 22 de `/proc/<pid>/stat`), comme un gestionnaire de services vérifie qu'un numéro réutilisé ne
174
+ désigne pas un autre processus : le panneau tient un circuit pour vivant sur ce seul processus,
175
+ jamais sur la ligne de commande de l'appelant, une seconde course du ticket est refusée tant
176
+ qu'il vit, et `--arreter` ne vise que lui. Ainsi un circuit survit à la séance qui le lance (BP 320.8 : un circuit mort avec
177
+ la séance du superviseur, repris à la main).
178
+
151
179
  **Main reste vert** : l'intégration exige un `npm run verifier` vert, sans rouge admis, mesuré
152
180
  contre le dernier vert ; la nuit rejoue la passe complète. Un test connu
153
181
  rouge se met en quarantaine dans le test lui-même (`it.skip` ou `it.fails`), avec le ticket qui
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roomi-fields/grillhouse",
3
- "version": "0.24.2",
3
+ "version": "0.24.3",
4
4
  "description": "Roomi's Grillhouse: the frame's scripts, called by one command, grillhouse <sous-commande>",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/scripts/bilan.mjs CHANGED
@@ -24,9 +24,13 @@
24
24
  // AUCUNE, QUESTIONS or DÉSACCORD, and the questions left open, `ouvertes`), each end of a run on
25
25
  // a stop (`montee`: its code, its stop and who must answer its question, `qui`); the circuit's
26
26
  // state, `.claude/worktrees/<ticket>.circuit.json`, for where the circuit ended; the night the
27
- // project declares in its package.json (`grillhouse.plageDeNuit`). Every agent declares
28
- // nothing: the bilan measures.
29
- // - The steps and the roles are those of scripts/etapes.mjs. Only the circuit's roles count, the
27
+ // project declares in its package.json (`grillhouse.plageDeNuit`); the comments of the ticket
28
+ // (`bd comments <ticket> --json`, run from the main tree), their times and, of their text, the
29
+ // title of the owner's answer alone (« ## Réponse du responsable — <la question> », which the
30
+ // skill pitmaster fixes). Every agent declares nothing: the bilan measures.
31
+ // - The steps and the roles are those of scripts/etapes.mjs; a register line's role is read as the
32
+ // board reads it (`roleDeLAgent`: bare, or scoped by the frame's plugin, `grillhouse:<rôle>`, as
33
+ // the register writes it). Only the circuit's roles count, the
30
34
  // explorateur of the plan among them. Only the sessions the circuit launched count in
31
35
  // the window, the categories, the tokens and the cost; a session of a circuit's role on the
32
36
  // ticket the circuit did not launch, the supervisor's, counts apart (`seances.horsCircuit`: its
@@ -51,9 +55,10 @@
51
55
  // - attente du superviseur, attente du responsable, nuit: as the lead time of DORA separates the
52
56
  // wait for review from the work, each wait runs from an end of a run on a stop (`montee`) to
53
57
  // the first turn of a session or step after it, or the next result of the circuit, the first
54
- // of the two; it is the wait of who must answer its question (`qui`, the owner or the
55
- // supervisor, as the circuit writes it), but its part in the night: the hours of `grillhouse.plageDeNuit` in the
56
- // project's package.json (`{ debut, fin }`, in local time), from 23 h to 8 h without it;
58
+ // of the two; it is the wait of who must answer its question: the owner's when the circuit
59
+ // names him (`qui`), or when the supervisor carried the question to him, his answer written at
60
+ // the ticket during the wait; else the supervisor's; but its part in the night: the hours of
61
+ // `grillhouse.plageDeNuit` in the project's package.json (`{ debut, fin }`, in local time), from 23 h to 8 h without it;
57
62
  // - étapes automatiques: the other steps the circuit leads, but the final passes;
58
63
  // - passes finales: the final passes, but those without effect or replayed;
59
64
  // - rejeu d'étapes déjà vertes: the same, on a lot unchanged since green: checks green again,
@@ -75,12 +80,14 @@ import { existsSync, readdirSync, readFileSync, renameSync, writeFileSync } from
75
80
  import os from 'node:os';
76
81
  import path from 'node:path';
77
82
  import { pathToFileURL } from 'node:url';
83
+ import { estReponseDuResponsable } from './consommateurs-arbitres.mjs';
78
84
  import {
79
85
  AGENTS_DU_LOT,
80
86
  etapeDuCircuit,
81
87
  nomDuRole,
82
88
  QUESTIONNEUR,
83
89
  RESPONSABLE,
90
+ roleDeLAgent,
84
91
  SUITE,
85
92
  SUPERVISEUR,
86
93
  } from './etapes.mjs';
@@ -185,14 +192,15 @@ const commun = ([d, f], l) =>
185
192
  longueur(l.map(([a, b]) => [Math.max(a, d), Math.min(b, f)]).filter(([a, b]) => b > a));
186
193
 
187
194
  // The bilan of <ticket> from the register's lines <lignes> (of its project), the results the
188
- // circuit kept <entrees> (`<ticket>.fiches.jsonl`), the circuit's state <etat> (or null) and the
189
- // project's night <nuit>.
195
+ // circuit kept <entrees> (`<ticket>.fiches.jsonl`), the circuit's state <etat> (or null), the
196
+ // project's night <nuit> and the comments of the ticket <commentaires> (Beads' JSON).
190
197
  export function bilan({
191
198
  ticket,
192
199
  lignes,
193
200
  entrees = [],
194
201
  etat = null,
195
202
  nuit = NUIT,
203
+ commentaires = [],
196
204
  maintenant = Date.now(),
197
205
  }) {
198
206
  // The sessions the circuit launched, by their id.
@@ -201,7 +209,8 @@ export function bilan({
201
209
  );
202
210
  // Each agent's latest line on the ticket: it holds all its turns.
203
211
  const derniere = new Map();
204
- for (const l of lignes) {
212
+ for (const x of lignes) {
213
+ const l = { ...x, role: roleDeLAgent(x.role) };
205
214
  if (l.ticket !== ticket || (l.role !== CIRCUIT && !ROLES.has(l.role))) continue;
206
215
  const avant = derniere.get(l.agent);
207
216
  if (!avant || Date.parse(l.fin) > Date.parse(avant.fin)) derniere.set(l.agent, l);
@@ -307,13 +316,20 @@ export function bilan({
307
316
  }
308
317
 
309
318
  // The waits: from each end of a run on a stop to the answer, the run after, each for who must
310
- // answer its question (`qui`, the owner or the supervisor).
319
+ // answer its question: the owner when the circuit names him, or when his answer is written at
320
+ // the ticket during the wait; else the supervisor.
321
+ const reponses = commentaires
322
+ .filter(c => estReponseDuResponsable(c.text))
323
+ .map(c => Date.parse(c.created_at ?? ''))
324
+ .filter(t => !Number.isNaN(t));
311
325
  const lesAttentes = [];
312
326
  for (const e of duCircuit.filter(x => x.montee)) {
313
327
  const tour = segments.find(s => s.d > e.t)?.d ?? Infinity;
314
328
  const suivant = gardes.find(x => x.t > e.t)?.t ?? Infinity;
315
329
  const f = Math.min(tour, suivant, fin);
316
- const { qui } = e.montee;
330
+ // A comment's time is to the second: the answer is in the wait up to the gap around it.
331
+ const repondu = reponses.some(t => t >= e.t - JEU && t <= f + JEU);
332
+ const qui = e.montee.qui === RESPONSABLE || repondu ? RESPONSABLE : SUPERVISEUR;
317
333
  if (f > e.t) lesAttentes.push({ i: [e.t, f], qui, nuit: nuits([e.t, f], nuit) });
318
334
  }
319
335
  const attentes = lesAttentes.map(a => a.i);
@@ -516,8 +532,24 @@ export function lignesDuProjet(texte, racine) {
516
532
  });
517
533
  }
518
534
 
535
+ // The comments of <ticket> (Beads' JSON), read from the main tree <racine>; none when bd does not
536
+ // read them.
537
+ function commentairesDu(racine, ticket) {
538
+ const r = spawnSync('bd', ['comments', ticket, '--json'], {
539
+ cwd: racine,
540
+ encoding: 'utf8',
541
+ maxBuffer: 256 * 1024 * 1024,
542
+ });
543
+ try {
544
+ const c = r.status === 0 ? JSON.parse(r.stdout) : [];
545
+ return Array.isArray(c) ? c : [];
546
+ } catch {
547
+ return [];
548
+ }
549
+ }
550
+
519
551
  // The bilan of <ticket> computed from the main tree <racine>: its register, the results its
520
- // circuit kept, its circuit's state.
552
+ // circuit kept, its circuit's state, the comments of the ticket.
521
553
  function calculer(racine, ticket) {
522
554
  const registre =
523
555
  process.env.GRILLHOUSE_REGISTRE ??
@@ -540,7 +572,14 @@ function calculer(racine, ticket) {
540
572
  } catch {
541
573
  etat = null;
542
574
  }
543
- return bilan({ ticket, lignes, entrees, etat, nuit: plageDeNuit(racine) });
575
+ return bilan({
576
+ ticket,
577
+ lignes,
578
+ entrees,
579
+ etat,
580
+ nuit: plageDeNuit(racine),
581
+ commentaires: commentairesDu(racine, ticket),
582
+ });
544
583
  }
545
584
 
546
585
  // The bilan of <ticket> computed, kept in the main tree <racine>, and its text, compared with the
@@ -25,6 +25,16 @@
25
25
  // npx grillhouse circuit <ticket> --etendre <paquet>[,<paquet>…] [--contexte <texte>]
26
26
  // npx grillhouse circuit <ticket> --arreter [--contexte <motif>]
27
27
  //
28
+ // The run is a daemon (scripts/demon.mjs), as daemon(3) and `setsid --fork` make one: the command
29
+ // launches a relay,
30
+ // which launches the run in a session of its own and ends at once, so that the run is neither in
31
+ // the caller's process group nor under it in the tree of processes, and goes on to its end when
32
+ // its caller dies (BP 320.8: the circuit, a background command of the supervisor's session, died
33
+ // with it). The caller relays the run's output to its own streams while it lives, and ends on the
34
+ // run's exit code; the state names the run (`processus` and its start `depart`), which the board
35
+ // reads, and a second run of the ticket while it lives is refused (exit 2), `--arreter` stopping
36
+ // it.
37
+ //
28
38
  // The circuit decides on structured results only (scripts/resultats.mjs, the one module of their
29
39
  // formats), as Bazel's Build Event Protocol and the JUnit reports carry the outcome of a build:
30
40
  // the sheet that ends each session, the summaries of Turborepo, the JSON reports of Vitest and the
@@ -43,12 +53,14 @@
43
53
  // description and notes, the context), writes the plan in its sheet: its criteria, the packages
44
54
  // to touch, and its open questions, each with its piece; it surveys the components the ticket
45
55
  // reaches by `npx grillhouse composants-affectes <ticket>` (scripts/composants-affectes.mjs),
46
- // which the circuit plays no more. A package the repository does not hold, or one named twice,
47
- // makes the sheet out of conformity. The circuit writes the plan at the ticket (`bd update
48
- // --title -d`): the packages end its title, the list the envelope of every later session
49
- // writes; the criteria already written stay as they are, the owner's decision, and the criteria
50
- // of the sheet, those the plan adds, follow them, numbered after them (a change or a removal of
51
- // a criterion written is an open question of the sheet); the open questions a section
56
+ // which the circuit plays no more as a step. A package the repository does not hold, one named
57
+ // twice, or a component of the survey of the plan (`releve`, which the circuit plays with no
58
+ // session to check the sheet) that the sheet neither puts in its packages nor sets apart with
59
+ // its reason (`ecartes`, written at the ticket) makes the sheet out of conformity. The circuit
60
+ // writes the plan at the ticket (`bd update --title -d`): the packages end its title, the list the envelope of every later
61
+ // session writes; the criteria already written stay as they are, the owner's decision, and the
62
+ // criteria of the sheet, those the plan adds, follow them, numbered after them (a change or a
63
+ // removal of a criterion written is an open question of the sheet); the open questions a section
52
64
  // « Questions ouvertes » after them. Each writing starts again from the description before the
53
65
  // plan. Then one session of the questionneur out of the envelope, read-only (no tool of
54
66
  // writing, every write of bd refused, scripts/droits.mjs), as Amazon's bar raiser, a cockpit's
@@ -66,12 +78,12 @@
66
78
  // question the explorateur leaves without an answer) stops at « questionnement », the open questions as its piece, a
67
79
  // question for the supervisor: he changes the plan (`bd update`) or keeps it, then
68
80
  // `--reprendre` lets the plan pass as it is then, from the testwriter. Nothing open, the plan
69
- // passes (`plan`, its fingerprint); a plan that passed, its title and description unchanged
70
- // since, passes with no session.
81
+ // passes (`plan`, its fingerprint: its title and its criteria); a plan that passed, its title
82
+ // and criteria unchanged since, passes with no session, whatever else of its description
83
+ // changed.
71
84
  // - Each session is a launch of scripts/enveloppe/lancer.sh, a child process the circuit waits
72
85
  // for, in its own process group, its errors written to a file: a session outlives the death of
73
- // its circuit (its caller dead, the circuit with it), and the state names its group while it
74
- // runs. Its plan, the packages it writes (`--paquets`, the envelope's list), is the plan of the
86
+ // its circuit, and the state names its group while it runs. Its plan, the packages it writes (`--paquets`, the envelope's list), is the plan of the
75
87
  // ticket, the whole copy in sight, the session at the root (`.`); lancer.sh builds the packages
76
88
  // of the plan and what they read before it opens. A session its lock stops on a write out of
77
89
  // the plan ends the circuit at « hors-plan », a question for the supervisor, the write as its
@@ -81,8 +93,11 @@
81
93
  // section absent without notes), both read with `bd show` at the session's launch, the report of
82
94
  // the step before (the proof, the reds of a check), the findings of the reviewer still open, the
83
95
  // last handover of the session's author at the ticket, for a developpeur without one yet the last
84
- // of the testwriter, else « aucune » (no verdict), and the line `CONTEXTE :`: the text of
85
- // `--contexte`, for each agent of the run. The session's own exit code is the one lancer.sh
96
+ // of the testwriter, else « aucune » (no verdict), the line `CONTEXTE :`: the text of
97
+ // `--contexte`, for each agent of the run, and the references 4.2 regenerates, each with its
98
+ // files (`lesReferences`), so that no session stops on what the circuit writes itself (BP
99
+ // 320.8: a developpeur, code and tests green, stopped on a ceiling, the debt and the index).
100
+ // The session's own exit code is the one lancer.sh
86
101
  // writes to `.claude/worktrees/<ticket>.fin`; a launch that leaves none stopped before its
87
102
  // session.
88
103
  // - Each session of the explorateur, the questionneur, the testwriter, the developpeur and the
@@ -347,8 +362,9 @@
347
362
  // live in the base of the run (scripts/vitest-config/base-de-passe.mjs), removed at its end.
348
363
  // - The state is `.claude/worktrees/<ticket>.circuit.json`, written again at each step and at the
349
364
  // start and end of each session: `{ etape, tentative, code, raison, rapport, finale, boucles,
350
- // seance, question, questionnement, processus, paquets, constats, verifie, mene, reprise,
351
- // journal }`; `processus` the process of the circuit that writes it; `questionnement` the work
365
+ // seance, question, questionnement, processus, depart, paquets, constats, verifie, mene, reprise,
366
+ // journal }`; `processus` the process of the circuit that writes it, `depart` its start (field
367
+ // 22 of /proc/<pid>/stat), which together name it, a number alone being reused; `questionnement` the work
352
368
  // on the plan under way (`{ objet, role, seance }`: the plan, the explorateur or the
353
369
  // questionneur, its session), null otherwise; `etape` is the state's name of a numbered step of
354
370
  // the process (scripts/etapes.mjs: testwriter 2, preuve 2.1, developpeur 3, controles 3.1, or 4.1
@@ -365,7 +381,7 @@
365
381
  // itself while it runs, null otherwise; `reprise` the session of the testwriter or developpeur
366
382
  // its relaunches resume, `{ agent, seance }`, null before any.
367
383
  // - `--reprendre` starts again at the step of the state, its report given to the next session,
368
- // after any stop, the death of the circuit with its caller included. A session the state names
384
+ // after any stop, the death of the circuit included. A session the state names
369
385
  // that still runs is waited for first, and stopped when it stands still as long as a motionless
370
386
  // session. On a stop « questionnement », it lets the plan pass as it is then (the supervisor
371
387
  // changed it or kept it), from the testwriter.
@@ -380,9 +396,10 @@
380
396
  // package of the plan that depends on it (its package.json), else at its end, said at the ticket
381
397
  // (`Circuit · plan : le superviseur étend le plan à …`); then the step under way resumes as
382
398
  // after `--reprendre`, on the plan extended, the question as its context with the text of
383
- // `--contexte`. The plan so extended has passed (`plan`, its fingerprint): neither the
384
- // explorateur nor the questionneur works on it again. A package the repository does not hold is
385
- // refused, exit 2.
399
+ // `--contexte`; a stop « sans-livraison » on the developpeur's sending to the testwriter
400
+ // resumes at the testwriter, the role it names. The plan so extended has passed (`plan`, its
401
+ // fingerprint): neither the explorateur nor the questionneur works on it again. A package the
402
+ // repository does not hold is refused, exit 2.
386
403
  // - `--arreter` stops the circuit on the supervisor's word, as a pipeline cancelled: a circuit
387
404
  // running on the ticket (the state's `processus`, alive) stops, SIGTERM then SIGKILL, and so does
388
405
  // the session it led (`seance`); the state keeps its step, its stop « arrete », its question
@@ -473,6 +490,7 @@ import {
473
490
  SUPERVISEUR,
474
491
  } from './etapes.mjs';
475
492
  import { paquets } from './paquets.mjs';
493
+ import { releve } from './composants-affectes.mjs';
476
494
  import { ecrire as ecrireAuRegistre, ligneDEtape, transcriptionsDeLaCopie } from './registre.mjs';
477
495
  import { FICHIER as DETTE } from './dette.mjs';
478
496
  import {
@@ -497,14 +515,18 @@ import { AVANCEMENT } from './vitest-config/avancement.mjs';
497
515
  import { NOMS_DES_GARDES } from './gardes-du-cadre.mjs';
498
516
  import { isTesterFile } from './verrous/verrou.mjs';
499
517
  import { A_REPASSER } from './vitest-config/pression.mjs';
500
- import { ouvrirBase, vivant } from './vitest-config/base-de-passe.mjs';
518
+ import { departDe, leMemeVivant, ouvrirBase, vivant } from './vitest-config/base-de-passe.mjs';
501
519
  import { GREFFON } from './cadre.mjs';
520
+ import { executerEnDemon } from './demon.mjs';
502
521
 
503
522
  // The time a session's transcripts may stand still before the circuit stops it.
504
523
  export const IMMOBILE_MS = 20 * 60 * 1000;
505
524
  // The exit code of each stop, from the list of the steps and stops.
506
525
  export { ARRETS };
507
526
  const CODE_USAGE = 2;
527
+ // The start of this process (departDe), which the state writes beside its number: a number alone
528
+ // may name another process once reused.
529
+ const DEPART = departDe(process.pid);
508
530
  // The bounded loops, each declared with its step (scripts/etapes.mjs, `boucles`): the testwriter is
509
531
  // relaunched twice at most after a failed proof (three sessions); the developpeur has three
510
532
  // sessions, the last on the strong model; the third RENDU of one ticket stops the circuit.
@@ -903,6 +925,7 @@ function ecrireEtat(ctx, etat) {
903
925
  avancement: null,
904
926
  ...etat,
905
927
  processus: process.pid,
928
+ depart: DEPART,
906
929
  paquets: ctx.paquets,
907
930
  constats: ctx.constats ?? [],
908
931
  verifie: ctx.verifie ?? null,
@@ -1202,6 +1225,9 @@ async function seance(ctx, role, { tentative, rapport, fort, derniere }) {
1202
1225
  rapport: rapport ?? 'aucun',
1203
1226
  constats,
1204
1227
  passation: passation?.text ?? 'aucune',
1228
+ references: lesReferences(ctx)
1229
+ .map(r => `- ${r.nom} : ${r.fichiers.map(f => `\`${f}\``).join(', ')}`)
1230
+ .join('\n'),
1205
1231
  };
1206
1232
  return await jusquALaFiche(ctx, role, consigne(valeurs), { fort, neuve: role });
1207
1233
  }
@@ -1609,7 +1635,8 @@ function laPasseFinale(ctx) {
1609
1635
  // (REFERENCES_DU_CADRE, `cadre`), each but one whose first file a reference of the project covers,
1610
1636
  // which replaces it.
1611
1637
  function lesReferences(ctx) {
1612
- const l = lireJson(path.join(ctx.copie, 'package.json'))?.grillhouse?.references;
1638
+ const l = lireJson(path.join(existsSync(ctx.copie) ? ctx.copie : ctx.racine, 'package.json'))
1639
+ ?.grillhouse?.references;
1613
1640
  const duProjet = (Array.isArray(l) ? l : [])
1614
1641
  .filter(
1615
1642
  r =>
@@ -3224,9 +3251,19 @@ function rubrique(ctx, titre) {
3224
3251
  // The meta-frame, the frame's plugin's, read at the plugin's root (scripts/cadre.mjs).
3225
3252
  const METACADRE = path.join(GREFFON, 'METACADRE.md');
3226
3253
 
3227
- // The fingerprint of a plan, its title and its description.
3228
- const empreinteDuPlan = ({ titre, description }) =>
3229
- createHash('sha256').update(`${titre}\n${description}`).digest('hex');
3254
+ // The fingerprint of a plan, its title and its section of criteria, each line without its blank
3255
+ // lines: the rest of the description (an answer of the supervisor, the open questions, its notes)
3256
+ // is not the plan, as a CI replays a job only when its inputs move.
3257
+ const empreinteDuPlan = ({ titre, description }) => {
3258
+ const criteres = sectionsDe(description)
3259
+ .filter(deCriteres)
3260
+ .flatMap(s => [s.tete, ...s.lignes])
3261
+ .map(l => l.trim())
3262
+ .filter(Boolean);
3263
+ return createHash('sha256')
3264
+ .update([titre, ...criteres].join('\n'))
3265
+ .digest('hex');
3266
+ };
3230
3267
 
3231
3268
  // Whether the plan of fingerprint <empreinte> has passed: a plan whose questioning left no
3232
3269
  // question open, or the supervisor's resumption of its stop.
@@ -3315,26 +3352,47 @@ function ecrireLePlan(ctx, plan, description = null) {
3315
3352
  }
3316
3353
 
3317
3354
  // What makes the packages of the sheet <fiche> of the explorateur out of conformity, or null: a
3318
- // package that names neither a package nor a path of the repository, or one package named twice
3319
- // (by its name and by its path). A session that writes one is resumed once (`jusquALaFiche`).
3320
- function fautesDesPaquets(ctx, fiche) {
3321
- const dossiers = fiche.paquets.map(p => {
3355
+ // package that names neither a package nor a path of the repository, one package named twice
3356
+ // (by its name and by its path), or a component of the survey of the plan's description
3357
+ // <description> (scripts/composants-affectes.mjs, `releve`, played by the circuit with no
3358
+ // session, as it checks the packages) that the sheet neither puts in its packages nor sets apart
3359
+ // with its reason (`ecartes`). A session that writes one is resumed once (`jusquALaFiche`).
3360
+ function fautesDesPaquets(ctx, fiche, description) {
3361
+ const dossier = p => {
3322
3362
  try {
3323
3363
  return ctx.resoudre(p);
3324
3364
  } catch {
3325
3365
  return null;
3326
3366
  }
3327
- });
3367
+ };
3368
+ const dossiers = fiche.paquets.map(dossier);
3328
3369
  const inconnus = fiche.paquets.filter((p, i) => dossiers[i] === null);
3329
3370
  if (inconnus.length) {
3330
3371
  return `paquets : ${inconnus.join(', ')} ne nomme ni un paquet ni un chemin du dépôt`;
3331
3372
  }
3332
3373
  const doubles = fiche.paquets.filter((p, i) => dossiers.indexOf(dossiers[i]) !== i);
3333
- return doubles.length
3334
- ? `paquets : ${doubles.join(', ')} nomme un paquet déjà nommé dans le plan`
3374
+ if (doubles.length) {
3375
+ return `paquets : ${doubles.join(', ')} nomme un paquet déjà nommé dans le plan`;
3376
+ }
3377
+ const tenus = [...dossiers, ...(fiche.ecartes ?? []).map(e => dossier(e.composant))];
3378
+ const couvre = (d, c) => d === '.' || c === d || c.startsWith(`${d}/`);
3379
+ const racine = existsSync(ctx.copie) ? ctx.copie : ctx.racine;
3380
+ const absents = releve(racine, description).composants.filter(c => {
3381
+ const d = dossier(c);
3382
+ return d !== null && !tenus.some(t => t !== null && couvre(t, d));
3383
+ });
3384
+ return absents.length
3385
+ ? `paquets : ${absents.join(', ')}, que le relevé nomme, n'est ni dans les paquets ni dans les écartés (ecartes, avec sa raison)`
3335
3386
  : null;
3336
3387
  }
3337
3388
 
3389
+ // The components the sheet <fiche> of the explorateur sets apart, each with its reason, as the
3390
+ // circuit writes them at the ticket; empty without one.
3391
+ const ecartsDe = fiche =>
3392
+ (fiche.ecartes ?? []).length
3393
+ ? ` ; écartés : ${fiche.ecartes.map(e => `${e.composant} (${e.raison})`).join(' ; ')}`
3394
+ : '';
3395
+
3338
3396
  // The plan of the ticket (step 1 of scripts/etapes.mjs) before its testwriter, as an RFC: its
3339
3397
  // author writes it after surveying what exists, a review reads it once,
3340
3398
  // the author answers once, and what stays open goes to who decides. One session of the
@@ -3345,8 +3403,8 @@ function fautesDesPaquets(ctx, fiche) {
3345
3403
  // question it leaves without an answer stays open with its own. Each session's work is named in
3346
3404
  // the state while it runs (`questionnement`); the exchange is written at the ticket and its end
3347
3405
  // kept with the circuit's results (`questionnement`, which the bilan counts). A plan that has
3348
- // passed, its title and description unchanged since, passes. Null when nothing stays open (the
3349
- // plan passes, kept as `plan`); else the exit code of the question it goes up with,
3406
+ // passed, its title and criteria unchanged since (`empreinteDuPlan`), passes. Null when nothing
3407
+ // stays open (the plan passes, kept as `plan`); else the exit code of the question it goes up with,
3350
3408
  // « questionnement », the open questions as its piece, or the stop of a session that cannot end.
3351
3409
  async function lePlan(ctx) {
3352
3410
  if (planPasse(ctx, empreinteDuPlan(leTicket(ctx)))) return null;
@@ -3368,10 +3426,12 @@ async function lePlan(ctx) {
3368
3426
  ecrireEtat(ctx, etat());
3369
3427
  return fiche;
3370
3428
  };
3429
+ // The description before the plan, from which each sheet's plan is written.
3430
+ const avant = leTicket(ctx).description;
3371
3431
  const explorateur = {
3372
3432
  droits: horsDeLEnveloppe(ctx, EXPLORATEUR, 'sonnet'),
3373
3433
  id: randomUUID(),
3374
- valider: f => fautesDesPaquets(ctx, f),
3434
+ valider: f => fautesDesPaquets(ctx, f, decrireLePlan(avant, f.criteres, f.questions)),
3375
3435
  };
3376
3436
  try {
3377
3437
  const t = leTicket(ctx);
@@ -3399,7 +3459,7 @@ async function lePlan(ctx) {
3399
3459
  const ouvertesDuPlan = plan.questions.length ? `\n${lignesOuvertes(plan.questions)}` : 'aucune';
3400
3460
  dire(
3401
3461
  'plan',
3402
- `l'explorateur écrit le plan — paquets : ${plan.paquets.join(', ')} ; ${plan.criteres.length} critère(s) ajouté(s) ; questions ouvertes : ${ouvertesDuPlan}`
3462
+ `l'explorateur écrit le plan — paquets : ${plan.paquets.join(', ')}${ecartsDe(plan)} ; ${plan.criteres.length} critère(s) ajouté(s) ; questions ouvertes : ${ouvertesDuPlan}`
3403
3463
  );
3404
3464
  const ecrit = leTicket(ctx);
3405
3465
  const lu = await session(
@@ -3451,7 +3511,10 @@ async function lePlan(ctx) {
3451
3511
  );
3452
3512
  reponses = plan.reponses ?? [];
3453
3513
  const lignes = reponses.map(r => `${r.numero}. ${r.reponse} — ${r.texte}`).join('\n');
3454
- dire('questionnement', `la réponse de l'explorateur :\n${lignes || 'aucune'}`);
3514
+ dire(
3515
+ 'questionnement',
3516
+ `la réponse de l'explorateur${ecartsDe(plan)} :\n${lignes || 'aucune'}`
3517
+ );
3455
3518
  }
3456
3519
  // What stays open: the plan's own questions, then each question left without an answer.
3457
3520
  const ouvertes = [
@@ -3537,7 +3600,7 @@ async function terminer(cible) {
3537
3600
  // it, its session gone.
3538
3601
  async function arreterLeCircuit(ctx, e) {
3539
3602
  const pid = e.processus;
3540
- if (Number.isInteger(pid) && pid !== process.pid && vivant(pid)) {
3603
+ if (pid !== process.pid && leMemeVivant(pid, e.depart)) {
3541
3604
  commenter(
3542
3605
  ctx,
3543
3606
  'arret',
@@ -3581,8 +3644,11 @@ async function arreter(ctx, e) {
3581
3644
  // name of the repository, else a Usage): each one enters the title before the first package of
3582
3645
  // the plan whose package.json depends on it, else at its end, written by bd and said at the
3583
3646
  // ticket. With the state <e>, the run then resumes the step under way, as `--reprendre` does, the
3584
- // question of the stop and the text of `--contexte` as the context of its sessions; without one,
3585
- // it starts on the plan extended.
3647
+ // question of the stop and the text of `--contexte` as the context of its sessions; a stop
3648
+ // « sans-livraison » whose developpeur's last sheet sends the red to the testwriter (`renvoi`,
3649
+ // twice in a row) resumes at the step of the role it names, the testwriter's, as a retry plays the
3650
+ // job that failed. Without a state, it starts on the plan extended. The state the run resumes
3651
+ // from.
3586
3652
  function etendre(ctx, e) {
3587
3653
  const gagnes = [...new Set(ctx.etendre.map(ctx.resoudre))].filter(c => !ctx.paquets.includes(c));
3588
3654
  const liste = paquets(existsSync(ctx.copie) ? ctx.copie : ctx.racine);
@@ -3610,12 +3676,17 @@ function etendre(ctx, e) {
3610
3676
  'plan',
3611
3677
  `le superviseur étend le plan à ${ctx.etendre.join(', ')} : ${titre.split(' — ').at(-1)}.`
3612
3678
  );
3613
- if (!e) return;
3679
+ if (!e) return e;
3614
3680
  ctx.contexte =
3615
3681
  [e.question ? `${e.question.fait}\n\n${e.question.piece}` : null, ctx.contexte]
3616
3682
  .filter(Boolean)
3617
3683
  .join('\n\n') || null;
3618
3684
  ctx.reprendre = true;
3685
+ const renvoi =
3686
+ e.etape === CODE && e.raison === 'sans-livraison'
3687
+ ? fichesDe(ctx, 'developpeur').at(-1)?.renvoi
3688
+ : null;
3689
+ return renvoi?.role === 'testwriter' ? { ...e, etape: TESTS } : e;
3619
3690
  }
3620
3691
 
3621
3692
  export async function main(argv) {
@@ -3623,7 +3694,7 @@ export async function main(argv) {
3623
3694
  try {
3624
3695
  ctx = contexte(lireArguments(argv));
3625
3696
  mkdirSync(path.dirname(ctx.copie), { recursive: true });
3626
- const e = existsSync(ctx.etat) ? JSON.parse(readFileSync(ctx.etat, 'utf8')) : null;
3697
+ let e = existsSync(ctx.etat) ? JSON.parse(readFileSync(ctx.etat, 'utf8')) : null;
3627
3698
  // The findings of the reviewer still open, the lot the whole final pass verified, the session a
3628
3699
  // relaunch resumes, and the references a regeneration has to run, kept from one run to the next.
3629
3700
  ctx.constats = [...(e?.constats ?? [])];
@@ -3632,10 +3703,16 @@ export async function main(argv) {
3632
3703
  ctx.aRegenerer = e?.aRegenerer ?? null;
3633
3704
  // The supervisor's answers to a question: stop the circuit, or extend its plan and resume.
3634
3705
  if (ctx.arreter) return await arreter(ctx, e);
3706
+ // A circuit that outlives its caller is still the ticket's: no second run beside it.
3707
+ if (e && e.processus !== process.pid && leMemeVivant(e.processus, e.depart)) {
3708
+ throw new Usage(
3709
+ `un circuit tourne déjà sur ${ctx.ticket} (processus ${e.processus}) : il mène le ticket à sa fin, \`--arreter\` l'arrête.`
3710
+ );
3711
+ }
3635
3712
  if (ctx.etendre) {
3636
3713
  if (e?.etape === 'integre')
3637
3714
  throw new Usage(`--etendre : le lot de ${ctx.ticket} est intégré.`);
3638
- etendre(ctx, e);
3715
+ e = etendre(ctx, e);
3639
3716
  }
3640
3717
  // The supervisor's resumption of the questioning lets the plan pass as it is now.
3641
3718
  if (ctx.reprendre && e?.raison === 'questionnement') {
@@ -3669,6 +3746,7 @@ export async function main(argv) {
3669
3746
  }
3670
3747
  }
3671
3748
 
3749
+ // The entry: the run as a daemon (scripts/demon.mjs), apart from its caller.
3672
3750
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
3673
- process.exitCode = await main(process.argv.slice(2));
3751
+ process.exitCode = await executerEnDemon(import.meta.filename, process.argv.slice(2), main);
3674
3752
  }