@roomi-fields/grillhouse 0.25.4 → 0.25.5

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.25.4"
8
+ "version": "0.25.5"
9
9
  }
@@ -218,7 +218,14 @@ d'une relance à l'autre, comme un fil de revue non résolu, jusqu'à ce que le
218
218
  levé ou accepte le lot. Comme l'auteur répond dans chaque fil d'une revue GitHub ou Gerrit, la
219
219
  fiche FAIT du développeur répond à chaque constat ouvert pour lui, par son titre (`reponses` :
220
220
  `levé` avec sa pièce, ou `contesté` avec sa raison et sa pièce) ; le circuit refuse une fiche à
221
- laquelle il en manque une (`reponsesAuxConstats`), garde chaque réponse avec son constat, et la
221
+ laquelle il en manque une (`reponsesAuxConstats`). Quand le superviseur relance avec son
222
+ contexte (`--contexte`, ou la question que `--etendre` y verse), comme une revue que son auteur
223
+ relance sur un changement qu'il cadre, la consigne porte ce contexte en tête, comme la tâche,
224
+ avant le ticket, le rapport et les constats ; les constats ouverts au lancement de la passe
225
+ (`enContexte`, `auLancement`) sont donnés en contexte, sans réponse exigée, et ceux qu'un
226
+ `RENDU` pose dans la passe restent la tâche, leur réponse exigée (`constatsDeLaSeance`,
227
+ BP 320.14.2.3 : le contexte après la règle des réponses, une séance qui ne travaille qu'un
228
+ constat ancien, sa fiche refusée, deux fois `sans-livraison`). Le circuit garde chaque réponse avec son constat, et la
222
229
  relecture suivante la lit sous lui (BP 320.21 : la cause de son choix dans une passation que le
223
230
  circuit ne lit pas, « la relecture n'a reçu aucune fiche du développeur », trois `RENDU`, puis
224
231
  l'arrêt). Le bilan compte par étape et par rôle. Ainsi un type change avec ses
@@ -318,6 +325,19 @@ que le ticket, comme l'espace de travail d'un pipeline ; aucun balayage n'y touc
318
325
  l'efface à la clôture, `npx grillhouse retirer-copie` avec la copie d'un ticket fermé sans
319
326
  intégration. Ainsi une séance qui survit à son circuit garde ce qu'il lui a remis.
320
327
 
328
+ **La nuit retire les copies finies** (`packages/grillhouse/scripts/copies-finies.mjs`) : après ses
329
+ étapes, quel que soit son verdict, la nuit passe chaque copie que `git worktree list` nomme, hors
330
+ l'arbre principal et sa propre copie, par `retirer-copie.sh` sans `--jetable`, comme une CI
331
+ nettoie ses espaces de travail à la fin d'un pipeline et comme `git worktree prune`, qu'elle joue
332
+ d'abord. Une copie dont les commits et le travail local sont tous entrés sur main, jugés par le
333
+ contenu comme le retrait juge le travail, part avec sa branche (main et une branche qu'une autre
334
+ copie tient restent) ; une copie refusée (commits ou travail non entrés, verrou) reste, et le
335
+ journal la nomme avec sa raison, le premier chemin non entré compris. Une copie qu'un circuit tient reste sans passer : son ticket en
336
+ cours, son dossier `.travail`, ou, pour la copie de l'intégration et celle de la file, leur
337
+ verrou ; des tickets en cours illisibles, ou lus au-delà d'une minute, gardent toutes les
338
+ copies. Le retrait ne change pas le verdict de la nuit. Ainsi aucune copie ne survit à l'entrée de
339
+ son contenu sur main (Grillhouse, 79 copies d'agents, 5,7 Go ; OSC Bridge, 4,4 Go).
340
+
321
341
  **Le circuit est un démon** (`packages/grillhouse/scripts/demon.mjs`) : comme daemon(3) et
322
342
  `setsid --fork`, `npx grillhouse circuit` lance
323
343
  un relais, qui lance le circuit dans une session à lui puis finit aussitôt ; le circuit n'est ni
@@ -516,7 +536,10 @@ demandent au projet, ses générateurs ; ses binaires (`binaires`), que `maj` in
516
536
  les fichiers sources laissent de côté et que `maj` écrit dans le `.gitignore`. Le module typescript vit sous
517
537
  `scripts/langages/typescript/` (`tests/temoins/repartition.json` range chaque fichier), ses tests
518
538
  sous `tests/unit/langages/typescript/` ; le module cargo sous `scripts/langages/cargo/` (les crates
519
- de `cargo metadata`, les tests par nextest puis les doctests, la vérification par cargo-deny,
539
+ de `cargo metadata`, les tests par nextest puis les doctests, après la construction des cibles de
540
+ test de chaque crate (`cargo test --no-run`), une tâche `build` du verdict avec son journal, comme
541
+ la tâche `test` de Turborepo dépend de `build` : des tests qui ne compilent pas sont le rouge
542
+ « construction de <crate> » de la preuve du rouge, et se jouent aux contrôles ; la vérification par cargo-deny,
520
543
  sous le verrou de la machine ; le refus, avant tout lancement de cargo, d'un espace dont git ne
521
544
  suit pas le Cargo.lock, comme `npm ci` refuse un projet sans package-lock.json : les tests, la
522
545
  vérification et la préparation le nomment en une ligne avec son geste (`git add Cargo.lock`), et
package/docs/INTERFACE.md CHANGED
@@ -90,7 +90,9 @@ noyau, et chaque réponse décrit sans agir, sauf `verifier` d'un fichier engend
90
90
  `typescript`, un script `test:unit` dans son `package.json` ; `cargo`, un dossier `tests/`. Le circuit en tire les paquets du
91
91
  plan qui portent des tests, comme Bazel lit les cibles de test d'un paquet à leur genre.
92
92
  - `lecteurs` : les fournisseurs et les lecteurs, par le code, des éléments qu'un ticket nomme : son
93
- interface, ses imports, ses tests, ses types. Le relevé des composants touchés
93
+ interface, ses imports, ses tests, ses types ; ce que lit chaque composant (`lit`) et ce que
94
+ lisent ses tests (`parLesTests` : leurs imports ; `cargo`, ses dépendances de développement),
95
+ d'où `--etendre` tire l'ordre du plan. Le relevé des composants touchés
94
96
  (`composants-affectes`) y ajoute les chemins lus et l'architecture.
95
97
  - `touches` : les composants touchés depuis un commit, leurs dépendants, transitivement, et les
96
98
  fichiers hors de tout composant (`{ touches, dependants, horsGraphe }`), comme le
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roomi-fields/grillhouse",
3
- "version": "0.25.4",
3
+ "version": "0.25.5",
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",
@@ -102,8 +102,8 @@
102
102
  // section absent without notes), both read with `bd show` at the session's launch, the report of
103
103
  // the step before (the proof, the reds of a check), the findings of the reviewer still open, the
104
104
  // last handover of the session's author at the ticket, for a developpeur without one yet the last
105
- // of the testwriter, else « aucune » (no verdict), the line `CONTEXTE :`: the text of
106
- // `--contexte`, for each agent of the run, and the references 4.2 regenerates, each with its
105
+ // of the testwriter, else « aucune » (no verdict), the text of `--contexte` at its head, as its
106
+ // task (`tache`), for each agent of the run, and the references 4.2 regenerates, each with its
107
107
  // files (`lesReferences`), so that no session stops on what the circuit writes itself (BP
108
108
  // 320.8: a developpeur, code and tests green, stopped on a ceiling, the debt and the index).
109
109
  // The session's own exit code is the one lancer.sh
@@ -380,7 +380,10 @@
380
380
  // in each thread of a review on GitHub or Gerrit, a sheet FAIT of the developpeur answers each
381
381
  // finding open for him, by its title, levé or contesté with its reason, with its piece
382
382
  // (`reponses`); a sheet without the answer to one is refused (`reponsesAuxConstats` of
383
- // scripts/resultats.mjs) and asked again once of the same session, and the answer is kept with
383
+ // scripts/resultats.mjs) and asked again once of the same session, except in a run whose
384
+ // supervisor gives the task (`--contexte`), where the findings open at its launch are the
385
+ // session's context and need no answer, a finding a RENDU states within the run still its task
386
+ // (`auLancement`, `constatsDeLaSeance`, BP 320.14.2.3), and the answer is kept with
384
387
  // its finding in the state until the next review (BP 320.21: the cause of his choice in a
385
388
  // handover the circuit does not read, three RENDU, then the stop); the rest of the lot it does not read again (its skill, « La relecture
386
389
  // bornée »). A blocking finding without a valid agent, or one that puts its criterion in
@@ -461,7 +464,8 @@
461
464
  // a stop « questionnement », it lets the plan pass as it is then (the supervisor
462
465
  // changed it or kept it), from the testwriter.
463
466
  // - `--depuis <testwriter|developpeur>` has the lot corrected: it plays the whole ticket from
464
- // that step, the text of `--contexte` on the line CONTEXTE of each agent of the run (after a stop
467
+ // that step, the text of `--contexte` the task at the head of each agent's instruction in the
468
+ // run, the reviewer's line CONTEXTE (after a stop
465
469
  // « integration », from the developpeur, the refusal as his report, the red to lift, as a merge
466
470
  // queue sends the lot back to its author with the log of its check; from the testwriter, the
467
471
  // refusal dropped), as a retry
@@ -471,7 +475,10 @@
471
475
  // no `--reprendre`, and names no component: a second name is a second ticket, exit 2.
472
476
  // - `--etendre <paquet>[,<paquet>…]` (each a path or a package name of the repository) extends the
473
477
  // plan: the circuit writes the title (`bd update --title`), each package gained before the first
474
- // package of the plan that depends on it (its package.json), else at its end, said at the ticket
478
+ // package of the plan that reads it, as the module of the language says (`lecteurs` of the
479
+ // join: the imports of a package of TypeScript, its tests' included, the dependencies of a
480
+ // crate, of development included), else at its end,
481
+ // said at the ticket
475
482
  // (`Circuit · plan : le superviseur étend le plan à …`); then the step under way resumes as
476
483
  // after `--reprendre`, on the plan extended, the question as its context with the text of
477
484
  // `--contexte`; a stop « sans-livraison » on the developpeur's sending to the testwriter
@@ -1273,7 +1280,7 @@ async function attendreLaSeance(ctx, groupe) {
1273
1280
  // developpeur's on a resumption, 4 the questionneur's on the plan, 5 the explorateur's on the plan,
1274
1281
  // 6 the explorateur's on the questions of the plan, 7 the explorateur's on the tri of the
1275
1282
  // discoveries), filled with <valeurs>.
1276
- function consigne(valeurs, rang = 0) {
1283
+ export function consigne(valeurs, rang = 0) {
1277
1284
  const texte = readFileSync(GABARIT, 'utf8');
1278
1285
  const bloc = [...texte.matchAll(/```text\n([\s\S]*?)\n```/g)][rang];
1279
1286
  if (!bloc) throw new Error(`gabarit sans bloc de consigne n° ${rang + 1} : ${GABARIT}`);
@@ -1289,23 +1296,24 @@ function consigne(valeurs, rang = 0) {
1289
1296
  // circuit keeps. A fresh session's instruction (the first
1290
1297
  // template) carries the ticket's description and notes as they are at its launch, the packages of
1291
1298
  // the plan, and the last handover of its author at the ticket. Every instruction, fresh or resumed,
1292
- // carries the findings of the reviewer still open for its role (`ctx.constats`), all of them,
1293
- // whatever the relaunch: a proof refused, red checks, a sending, a RENDU, a resumption of the
1294
- // supervisor; <change> says what changed on a resumption, when it is not the proof or the checks
1295
- // (the integration's refusal of the lot, `refus`); a developpeur's sheet FAIT answers each of his by its title (`reponsesAuxConstats`),
1296
- // refused without one, and the circuit keeps each answer with its finding (`avecLesReponses`).
1299
+ // carries the supervisor's context of the run at its head, as its task, and the findings of the
1300
+ // reviewer still open for its role (`ctx.constats`), all of them, whatever the relaunch: a proof
1301
+ // refused, red checks, a sending, a RENDU, a resumption of the supervisor (`constatsDeLaSeance`);
1302
+ // <change> says what changed on a resumption, when it is not the proof or the checks (the
1303
+ // integration's refusal of the lot, `refus`).
1297
1304
  // Throws an Arret for a launch that stops before its session, a motionless session, or
1298
1305
  // a session that ends twice without a sheet that conforms.
1299
1306
  async function seance(ctx, role, { tentative, rapport, fort, derniere, change }) {
1300
1307
  const nom = nomDuRole(role);
1301
1308
  const reprise = tentative > 1 && !derniere && ctx.reprise?.agent === role ? ctx.reprise : null;
1302
- const constats = texteDesOuverts(ouverts(ctx, role));
1309
+ const { tache, ouverts, constats, valider, repondre } = constatsDeLaSeance(
1310
+ ctx.contexte,
1311
+ ctx.constats,
1312
+ role
1313
+ );
1303
1314
  const plan = ctx.paquets.join(', ');
1304
- // A developpeur's sheet answers each finding open for him, kept with its finding.
1305
- const titres = role === 'developpeur' ? ouverts(ctx, role).map(c => c.titre) : [];
1306
- const valider = f => reponsesAuxConstats(f, titres);
1307
1315
  const repondu = fiche => {
1308
- if (fiche && titres.length) ctx.constats = avecLesReponses(ctx.constats, fiche);
1316
+ if (fiche) ctx.constats = repondre(ctx.constats, fiche);
1309
1317
  return fiche;
1310
1318
  };
1311
1319
  if (reprise) {
@@ -1321,6 +1329,8 @@ async function seance(ctx, role, { tentative, rapport, fort, derniere, change })
1321
1329
  ? 'la preuve du rouge, jouée après ta séance, refuse ton lot'
1322
1330
  : 'les contrôles, joués après ta séance, sont rouges'),
1323
1331
  rapport: rapport ?? 'aucun',
1332
+ tache,
1333
+ ouverts,
1324
1334
  constats,
1325
1335
  };
1326
1336
  const fiche = await jusquALaFiche(ctx, role, consigne(courte, 3), {
@@ -1355,13 +1365,14 @@ async function seance(ctx, role, { tentative, rapport, fort, derniere, change })
1355
1365
  lots: lots.length
1356
1366
  ? `${role === 'developpeur' ? 'le lot de tests' : 'tes tests'}, déjà dans la copie : ${lots.join(', ')}`
1357
1367
  : 'aucun',
1358
- contexte: contexteDe(ctx),
1368
+ tache,
1359
1369
  description: description.trim() || 'aucune',
1360
1370
  // The section of the ticket's notes, absent without notes.
1361
1371
  notes: notes.trim()
1362
1372
  ? `\nLES NOTES DU TICKET, l'état qu'un agent d'avant y a écrit :\n\n${notes.trim()}\n`
1363
1373
  : '',
1364
1374
  rapport: rapport ?? 'aucun',
1375
+ ouverts,
1365
1376
  constats,
1366
1377
  passation: passation?.text ?? 'aucune',
1367
1378
  references: lesReferences(ctx)
@@ -1371,6 +1382,53 @@ async function seance(ctx, role, { tentative, rapport, fort, derniere, change })
1371
1382
  return repondu(await jusquALaFiche(ctx, role, consigne(valeurs), { fort, neuve: role, valider }));
1372
1383
  }
1373
1384
 
1385
+ // The findings of the reviewer open for <role> among <constats>, as a session of the run whose
1386
+ // supervisor's context is <contexte> (`--contexte`, with `--depuis`, `--reprendre` or
1387
+ // `--etendre`) receives them, as a review its author relaunches on a change he frames keeps its
1388
+ // open threads in sight without blocking on them (BP 320.14.2.3: the context after the rule of
1389
+ // the answers, a session that worked an old finding only, its sheet refused, « sans-livraison »
1390
+ // twice). With a context, the context heads the instruction as its task (`tache`); the findings
1391
+ // open at the launch of the run (`enContexte`, `auLancement`) are its context, after the others
1392
+ // under their own heading, and a developpeur's sheet FAIT is not refused for want of an answer to
1393
+ // one of them; every other finding, without a context or stated by a RENDU within the run, is its
1394
+ // task, and his sheet FAIT answers each by its title, refused without one (`valider`,
1395
+ // `reponsesAuxConstats`). Either way, each answer a developpeur's sheet gives is kept with its
1396
+ // finding (`repondre`, `avecLesReponses`).
1397
+ export function constatsDeLaSeance(contexte, constats, role) {
1398
+ const siens = (constats ?? []).filter(c => c.role === role);
1399
+ const anciens = siens.filter(c => c.enContexte);
1400
+ const neufs = siens.filter(c => !c.enContexte);
1401
+ const titres = role === 'developpeur' ? neufs.map(c => c.titre) : [];
1402
+ const enContexte = `les constats ouverts au lancement de la passe du superviseur, donnés en contexte : ta tâche est celle du superviseur, ci-dessus ; chacun reste ouvert jusqu'à la relecture qui le juge levé, et ta fiche n'a pas à répondre à chacun`;
1403
+ const titre =
1404
+ 'LES CONSTATS DU RELECTEUR QUI RESTENT OUVERTS pour ton rôle, ' +
1405
+ (anciens.length && !neufs.length ? enContexte : "chacun jusqu'à la relecture qui le juge levé");
1406
+ const texte =
1407
+ anciens.length && neufs.length
1408
+ ? `${texteDesOuverts(neufs)}\n\nPUIS ${enContexte} :\n\n${texteDesOuverts(anciens, neufs.length)}`
1409
+ : texteDesOuverts(siens);
1410
+ return {
1411
+ tache: contexte
1412
+ ? `TA TÂCHE, que le superviseur te donne ; elle passe avant le ticket, le rapport${anciens.length ? ' et les constats donnés en contexte' : ''} ci-dessous :\n\n${contexte}\n\n`
1413
+ : '',
1414
+ ouverts: titre,
1415
+ constats: texte,
1416
+ valider: f => reponsesAuxConstats(f, titres),
1417
+ repondre: (tous, fiche) =>
1418
+ role === 'developpeur' && siens.length ? avecLesReponses(tous, fiche) : tous,
1419
+ };
1420
+ }
1421
+
1422
+ // The findings <constats> as a run launched with the supervisor's context <contexte> holds them:
1423
+ // each one open at its launch marked `enContexte`, as the threads already open when the author
1424
+ // relaunches a review on a change he frames; without a context, none. A finding a RENDU states
1425
+ // within the run comes without the mark (`constatsOuverts`), and is the session's task again.
1426
+ export const auLancement = (contexte, constats) =>
1427
+ (constats ?? []).map(c => {
1428
+ const { enContexte, ...reste } = c;
1429
+ return contexte ? { ...reste, enContexte: true } : reste;
1430
+ });
1431
+
1374
1432
  // The findings <constats>, each finding of the developpeur that his sheet <fiche> answers (by its
1375
1433
  // title) with its answer `{ etat, raison, piece }`, as a thread of a review keeps the author's
1376
1434
  // reply under its comment.
@@ -1386,8 +1444,8 @@ function avecLesReponses(constats, fiche) {
1386
1444
  });
1387
1445
  }
1388
1446
 
1389
- // The line CONTEXTE of a session: the text of `--contexte` of the run, which every session of the
1390
- // run receives; « aucun » without it.
1447
+ // The line CONTEXTE of a reviewer's session: the text of `--contexte` of the run; « aucun »
1448
+ // without it.
1391
1449
  const contexteDe = ctx => ctx.contexte || 'aucun';
1392
1450
 
1393
1451
  // The launch <r> of a session of <role>, or the Arret it is: a session its lock stopped on a
@@ -2081,13 +2139,13 @@ function renvoiDe(ctx, fiche) {
2081
2139
  const ouverts = (ctx, role) => (ctx.constats ?? []).filter(c => c.role === role);
2082
2140
 
2083
2141
  // The findings <constats> as an agent's instruction carries them, each under its heading, with
2084
- // what it holds, its body and its piece; « aucun » without one.
2085
- const texteDesOuverts = constats =>
2142
+ // what it holds, its body and its piece, numbered after <avant>; « aucun » without one.
2143
+ const texteDesOuverts = (constats, avant = 0) =>
2086
2144
  constats.length
2087
2145
  ? constats
2088
2146
  .map(
2089
2147
  (c, i) =>
2090
- `### Constat ${i + 1} — ${c.titre}\nBloquant : ${c.regle}\n${c.corps}${c.piece ? `\nPièce : ${c.piece}` : ''}`
2148
+ `### Constat ${avant + i + 1} — ${c.titre}\nBloquant : ${c.regle}\n${c.corps}${c.piece ? `\nPièce : ${c.piece}` : ''}`
2091
2149
  )
2092
2150
  .join('\n\n')
2093
2151
  : 'aucun';
@@ -2096,11 +2154,12 @@ const texteDesOuverts = constats =>
2096
2154
  // review stay open until the review that resolves them: each blocking finding of the sheet (a
2097
2155
  // remark reaches the ticket, no agent; the sheet's schema gives a RENDU at least one), after each
2098
2156
  // finding open before it that the sheet neither marks lifted (`suivi`, by its title) nor states
2099
- // again. Each one `{ titre, regle, role, corps, piece }`, its recipient the agent it names, testwriter or
2157
+ // again, which keeps its mark `enContexte` (`auLancement`), a finding the sheet states coming
2158
+ // without it. Each one `{ titre, regle, role, corps, piece }`, its recipient the agent it names, testwriter or
2100
2159
  // developpeur, without the developpeur's answer to the review before (`reponse`): his next sheet
2101
2160
  // answers it again. Throws an Arret `relecture-arret` for a finding without a valid recipient or one
2102
2161
  // that puts a criterion in question.
2103
- function constatsOuverts(ctx, fiche, texte) {
2162
+ export function constatsOuverts(ctx, fiche, texte) {
2104
2163
  const arret = raison =>
2105
2164
  new Arret('relecture-arret', `${raison}\n\nLe verdict :\n\n${texte}`, { piece: raison });
2106
2165
  const neufs = bloquants(fiche).map(c => {
@@ -4255,33 +4314,47 @@ async function arreter(ctx, e) {
4255
4314
  return 0;
4256
4315
  }
4257
4316
 
4258
- // The plan extended by the supervisor to the packages of `--etendre` (each a path or a package
4259
- // name of the repository, else a Usage): each one enters the title before the first package of
4260
- // the plan whose package.json depends on it, else at its end, written by bd and said at the
4261
- // ticket. With the state <e>, the run then resumes the step under way, as `--reprendre` does, the
4262
- // question of the stop and the text of `--contexte` as the context of its sessions; a stop
4263
- // « sans-livraison » whose developpeur's last sheet sends the red to the testwriter (`renvoi`,
4264
- // twice in a row) resumes at the step of the role it names, the testwriter's, as a retry plays the
4265
- // job that failed. Without a state, it starts on the plan extended. The state the run resumes
4266
- // from.
4267
- function etendre(ctx, e) {
4268
- const gagnes = [...new Set(ctx.etendre.map(ctx.resoudre))].filter(c => !ctx.paquets.includes(c));
4269
- const base = existsSync(ctx.copie) ? ctx.copie : ctx.racine;
4270
- const liste = composantsDe(base);
4271
- const pkg = c =>
4272
- liste.some(p => p.dossier === c) ? lireJson(path.join(base, c, 'package.json')) : null;
4273
- const lit = (lecteur, fournisseur) => {
4274
- const nom = pkg(fournisseur)?.name;
4275
- const p = pkg(lecteur);
4276
- return Boolean(
4277
- nom && p && [p.dependencies, p.devDependencies, p.peerDependencies].some(d => d && nom in d)
4278
- );
4317
+ // The plan <paquets> of the repository at <base>, each a directory relative to it, extended by
4318
+ // <gagnes>: each one enters before the first package of the plan that reads it, as the module of
4319
+ // the language reads its components (`lecteurs` of the join, its `lit` and its `parLesTests`: the
4320
+ // imports of a package of TypeScript, its tests' included, the dependencies of a crate of cargo,
4321
+ // of development included), else at its end, as Pants asks the order of the targets of its
4322
+ // backends.
4323
+ export function ordonnerLePlan(base, paquets, gagnes) {
4324
+ const langage = langageDe(base);
4325
+ const composants = langage.composants(base);
4326
+ const { lit, parLesTests } = langage.lecteurs(base, {
4327
+ composants,
4328
+ noms: [],
4329
+ texte: '',
4330
+ nommes: [],
4331
+ });
4332
+ const de = d => composants.find(c => (path.relative(base, c.dossier) || '.') === d);
4333
+ const litLe = (lecteur, fournisseur) => {
4334
+ const l = de(lecteur);
4335
+ const f = de(fournisseur);
4336
+ return Boolean(l && f && (lit.get(l)?.has(f) || parLesTests.get(l)?.has(f)));
4279
4337
  };
4280
- const plan = [...ctx.paquets];
4338
+ const plan = [...paquets];
4281
4339
  for (const c of gagnes) {
4282
- const i = plan.findIndex(x => lit(x, c));
4340
+ const i = plan.findIndex(x => litLe(x, c));
4283
4341
  plan.splice(i < 0 ? plan.length : i, 0, c);
4284
4342
  }
4343
+ return plan;
4344
+ }
4345
+
4346
+ // The plan extended by the supervisor to the packages of `--etendre` (each a path or a package
4347
+ // name of the repository, else a Usage): each one enters the title in the order of
4348
+ // `ordonnerLePlan`, written by bd and said at the ticket. With the state <e>, the run then resumes
4349
+ // the step under way, as `--reprendre` does, the question of the stop and the text of
4350
+ // `--contexte` as the context of its sessions; a stop « sans-livraison » whose developpeur's last
4351
+ // sheet sends the red to the testwriter (`renvoi`, twice in a row) resumes at the step of the role
4352
+ // it names, the testwriter's, as a retry plays the job that failed. Without a state, it starts on
4353
+ // the plan extended. The state the run resumes from.
4354
+ function etendre(ctx, e) {
4355
+ const gagnes = [...new Set(ctx.etendre.map(ctx.resoudre))].filter(c => !ctx.paquets.includes(c));
4356
+ const base = existsSync(ctx.copie) ? ctx.copie : ctx.racine;
4357
+ const plan = ordonnerLePlan(base, ctx.paquets, gagnes);
4285
4358
  const titre = ecrireLePlan(ctx, plan);
4286
4359
  // The plan the supervisor extends has passed: it is written, questioned no more.
4287
4360
  inscrire(ctx, {
@@ -4334,6 +4407,9 @@ export async function main(argv) {
4334
4407
  throw new Usage(`--etendre : le lot de ${ctx.ticket} est intégré.`);
4335
4408
  e = etendre(ctx, e);
4336
4409
  }
4410
+ // The findings open at the launch of a run with the supervisor's context (`--contexte`, or the
4411
+ // question `--etendre` gives it) are its sessions' context; without one, their task.
4412
+ ctx.constats = auLancement(ctx.contexte, ctx.constats);
4337
4413
  // The supervisor's resumption of the questioning lets the plan pass as it is now.
4338
4414
  if (ctx.reprendre && e?.raison === 'questionnement') {
4339
4415
  commenter(
@@ -0,0 +1,206 @@
1
+ #!/usr/bin/env node
2
+ // The removal of the working copies whose content is on main, run by the night once its steps
3
+ // are played (scripts/nuit.sh), as `git worktree prune` and the workspace cleanup at the end of a
4
+ // CI pipeline (Jenkins « Workspace Cleanup »): no copy outlives the entry of its content on main.
5
+ //
6
+ // node scripts/copies-finies.mjs [<copie à garder>…] from the main tree of the repository
7
+ //
8
+ // - First `git worktree prune`: a copy whose folder is gone leaves the list. Then each copy
9
+ // `git worktree list` names, the main tree and the copies named on the command line (the
10
+ // night's) left out, passes through scripts/retirer-copie.sh, without `--jetable`: a copy whose
11
+ // local work has all entered main by its content goes, with its `<copie>.travail`; a refused
12
+ // copy (work that has not entered, a lock) stays, intact, its line naming the refusal.
13
+ // - A copy a running circuit holds stays without passing, even without work: its ticket in
14
+ // progress (the copy's folder bears the ticket's id, `.claude/worktrees/<ticket>`, as the
15
+ // circuit and the launcher name it; read by `bd list --status in_progress`), the working
16
+ // directory of its circuit (`<copie>.travail`, which lives as long as the ticket,
17
+ // scripts/circuit.mjs), or, for the integration copy and the queue copy
18
+ // (`.claude/worktrees/integration`, `.claude/worktrees/file`), their lock in git's common
19
+ // directory (`integration.lock`, `file-integration.lock`, scripts/integration/). Tickets in
20
+ // progress that do not read, or not within a minute, hold every copy: none is removed.
21
+ // - A copy whose commits are not on main stays, its line naming the first path that has not
22
+ // entered: retirer-copie.sh judges the local work alone, so the copy's HEAD is judged first, as
23
+ // the removal judges local work: each path HEAD changed since its base with main holds the
24
+ // content and the mode a commit of main after that base gave it (a cherry-pick or a rebase
25
+ // counts, not the commit's identity). A detached HEAD's commits thus never become unreachable.
26
+ // - The branch of a copy removed goes (`git branch -D`), its content being HEAD's, on main; main
27
+ // and a branch another copy holds stay.
28
+ // - One line per copy removed or kept, on the output, which the night adds to its log. The exit is
29
+ // 0 whatever is removed or kept: the removal never changes the night's verdict.
30
+ import { spawnSync } from 'node:child_process';
31
+ import { existsSync, realpathSync } from 'node:fs';
32
+ import path from 'node:path';
33
+ import { pathToFileURL } from 'node:url';
34
+
35
+ const RETIRER = path.join(import.meta.dirname, 'retirer-copie.sh');
36
+ const PRINCIPALE = 'main';
37
+ // The copies of the integration and of the queue, each held while its lock stands.
38
+ const VERROUS = { integration: 'integration.lock', file: 'file-integration.lock' };
39
+
40
+ const lancer = (dossier, cmd, args) =>
41
+ spawnSync(cmd, args, { cwd: dossier, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
42
+ const git = (dossier, ...args) => lancer(dossier, 'git', args);
43
+ const reel = p => {
44
+ try {
45
+ return realpathSync(p);
46
+ } catch {
47
+ return path.resolve(p);
48
+ }
49
+ };
50
+
51
+ // The copies `git worktree list` names: `{ chemin, tete, branche }`, the main tree first.
52
+ function lesCopies(racine) {
53
+ return git(racine, 'worktree', 'list', '--porcelain')
54
+ .stdout.split('\n\n')
55
+ .map(bloc => bloc.split('\n'))
56
+ .filter(l => l[0]?.startsWith('worktree '))
57
+ .map(l => ({
58
+ chemin: l[0].slice('worktree '.length),
59
+ tete: l.find(x => x.startsWith('HEAD '))?.slice('HEAD '.length),
60
+ branche: l.find(x => x.startsWith('branch refs/heads/'))?.slice('branch refs/heads/'.length),
61
+ }));
62
+ }
63
+
64
+ // What holds <chemin> for a running circuit, or null.
65
+ function tenue(chemin, enCours, commun) {
66
+ const nom = path.basename(chemin);
67
+ if (existsSync(`${chemin}.travail`)) {
68
+ return `son circuit a son dossier ${nom}.travail`;
69
+ }
70
+ if (enCours.has(nom)) {
71
+ return `le ticket ${nom} est en cours`;
72
+ }
73
+ const verrou = VERROUS[nom];
74
+ if (verrou && path.dirname(chemin).endsWith(path.join('.claude', 'worktrees'))) {
75
+ if (existsSync(path.join(commun, verrou))) {
76
+ return `le verrou ${verrou} est posé`;
77
+ }
78
+ }
79
+ return null;
80
+ }
81
+
82
+ // The first path the commit or branch <b> changed since its base with main whose content no commit of main
83
+ // after that base gave, or null when all its content is on main.
84
+ function pasEntre(racine, b) {
85
+ const base = git(racine, 'merge-base', b, PRINCIPALE);
86
+ if (base.status !== 0) {
87
+ return `ses commits n'ont pas de base commune avec ${PRINCIPALE}`;
88
+ }
89
+ const chemins = git(racine, 'diff', '--name-only', '-z', '--no-renames', base.stdout.trim(), b)
90
+ .stdout.split('\0')
91
+ .filter(Boolean);
92
+ for (const p of chemins) {
93
+ const tenu = git(racine, 'ls-tree', b, '--', p).stdout.trim();
94
+ const [mode, , id] = tenu ? tenu.split(/\s+/) : ['000000', '', '0'];
95
+ const donnes = git(
96
+ racine,
97
+ 'log',
98
+ `${b}..${PRINCIPALE}`,
99
+ '--no-renames',
100
+ '--format=',
101
+ '--raw',
102
+ '--no-abbrev',
103
+ '--',
104
+ p
105
+ ).stdout.split('\n');
106
+ const entre = donnes.some(l => {
107
+ const [, m, , i] = l.split(/\s+/);
108
+ return m === mode && (i === id || (id === '0' && /^0+$/.test(i ?? '')));
109
+ });
110
+ if (!entre) {
111
+ return `${p} n'est pas sur ${PRINCIPALE}`;
112
+ }
113
+ }
114
+ return null;
115
+ }
116
+
117
+ /**
118
+ * Removes the copies of the repository at <racine> whose content is on main; returns one line per
119
+ * copy removed or kept. <garder> names the copies left out (the night's); <enCours> the ids of the
120
+ * tickets in progress, null when they do not read.
121
+ */
122
+ export function retirerLesCopiesFinies(racine, { garder = [], enCours }) {
123
+ if (enCours === null) {
124
+ return ['✗ les tickets en cours ne se lisent pas (bd list) : aucune copie n’est retirée.'];
125
+ }
126
+ git(racine, 'worktree', 'prune');
127
+ const commun = git(
128
+ racine,
129
+ 'rev-parse',
130
+ '--path-format=absolute',
131
+ '--git-common-dir'
132
+ ).stdout.trim();
133
+ const [principale, ...copies] = lesCopies(racine);
134
+ const ecartees = new Set([principale?.chemin, ...garder].filter(Boolean).map(reel));
135
+ const ici = reel(racine);
136
+ const vu = c => (path.relative(ici, reel(c)).startsWith('..') ? c : path.relative(ici, reel(c)));
137
+ const lignes = [];
138
+ for (const { chemin, tete, branche } of copies) {
139
+ if (ecartees.has(reel(chemin))) {
140
+ continue;
141
+ }
142
+ const raison = tenue(chemin, enCours, commun);
143
+ if (raison) {
144
+ lignes.push(`· copie gardée : ${vu(chemin)} : ${raison}.`);
145
+ continue;
146
+ }
147
+ const commits = tete ? pasEntre(racine, tete) : null;
148
+ if (commits) {
149
+ lignes.push(`· copie gardée : ${vu(chemin)} : ses commits ne sont pas entrés, ${commits}.`);
150
+ continue;
151
+ }
152
+ const r = lancer(racine, 'bash', [RETIRER, chemin]);
153
+ if (r.status !== 0) {
154
+ const refus = String(r.stderr || r.stdout)
155
+ .trim()
156
+ .split('\n');
157
+ lignes.push(`· copie gardée : ${vu(chemin)} : ${refus.join('\n ')}`);
158
+ continue;
159
+ }
160
+ let ligne = `✓ copie retirée : ${vu(chemin)}`;
161
+ if (branche && branche !== PRINCIPALE) {
162
+ const tenante = lesCopies(racine).find(c => c.branche === branche);
163
+ if (tenante) {
164
+ ligne += ` ; sa branche ${branche} reste : la copie ${vu(tenante.chemin)} la tient`;
165
+ } else {
166
+ const d = git(racine, 'branch', '-D', branche);
167
+ ligne +=
168
+ d.status === 0
169
+ ? ` ; sa branche ${branche} supprimée`
170
+ : ` ; sa branche ${branche} reste : ${d.stderr.trim()}`;
171
+ }
172
+ }
173
+ lignes.push(`${ligne}.`);
174
+ }
175
+ return lignes;
176
+ }
177
+
178
+ // The ids of the tickets in progress, null when they do not read within LECTURE_MS.
179
+ const LECTURE_MS = 60_000;
180
+ function ticketsEnCours(racine) {
181
+ const r = spawnSync('bd', ['list', '--status', 'in_progress', '--limit', '0', '--json'], {
182
+ cwd: racine,
183
+ encoding: 'utf8',
184
+ maxBuffer: 256 * 1024 * 1024,
185
+ timeout: LECTURE_MS,
186
+ });
187
+ if (r.status !== 0) {
188
+ return null;
189
+ }
190
+ try {
191
+ return new Set((JSON.parse(r.stdout || '[]') ?? []).map(t => String(t.id)));
192
+ } catch {
193
+ return null;
194
+ }
195
+ }
196
+
197
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
198
+ const racine = process.cwd();
199
+ const lignes = retirerLesCopiesFinies(racine, {
200
+ garder: process.argv.slice(2),
201
+ enCours: ticketsEnCours(racine),
202
+ });
203
+ if (lignes.length) {
204
+ process.stdout.write(`${lignes.join('\n')}\n`);
205
+ }
206
+ }
@@ -85,7 +85,11 @@ export interface Lecteurs {
85
85
  lecteurs: Map<Composant, Set<string>>;
86
86
  }[];
87
87
  };
88
+ /** What each component reads: its production code, and its dependencies of every kind. */
88
89
  lit: Map<Composant, Set<Composant>>;
90
+ /** What each component's tests read: the components they import, its dependencies of
91
+ * development. */
92
+ parLesTests: Map<Composant, Set<Composant>>;
89
93
  }
90
94
 
91
95
  /** The elements a lot adds, changes or removes between two commits, each with its place. */
@@ -12,12 +12,18 @@
12
12
  // - Each guard of structure of the module (./clippy.mjs, ./frontieres.mjs, ./index-interfaces.mjs)
13
13
  // is a command by its name too, its own script, as the module typescript's: the line of a red
14
14
  // guard (`grillhouse <garde>`, scripts/gardes-du-cadre.mjs) names a command that exists.
15
- // - `tester` plays the tests of each crate chosen, one crate after the other: `cargo nextest run
16
- // -p <crate> --no-fail-fast` for a crate that plays tests (./composants.mjs, `joueDesTests`),
17
- // then `cargo test --doc -p <crate>` for a crate whose library has doctests, which nextest does
18
- // not play. A path, written from the root, chooses the crate that holds it; the source of a test
19
- // target (`<crate>/tests/<nom>.rs`) plays that target alone (`--test <nom>`), without the
20
- // doctests. A path out of every crate, or in a crate without tests, is refused, named, and
15
+ // - `tester` plays the tests of each crate chosen, one crate after the other. For a crate that
16
+ // plays tests (./composants.mjs, `joueDesTests`): the build of its test targets, `cargo test
17
+ // --no-run -p <crate>`, a task `build` of its own, as Turborepo's `test` depends on `build`
18
+ // (grillhouse-egm); then `cargo nextest run -p <crate> --no-fail-fast`, which finds them built.
19
+ // Then `cargo test --doc -p <crate>` for a crate whose library has doctests, which nextest does
20
+ // not play. A failed build leaves the crate's other tasks not played (`code` null): a test that
21
+ // does not compile is a red of the build, which the proof of the red reads as one (« construction
22
+ // de <crate> », scripts/circuit.mjs), and the tests play at the checks. The output of the build
23
+ // goes to its log, `<target>/grillhouse/<crate>-build.log`, the task's `journal` from the root,
24
+ // then to the error stream. A path, written from the root, chooses the crate that holds it; the
25
+ // source of a test target (`<crate>/tests/<nom>.rs`) builds and plays that target alone
26
+ // (`--test <nom>`), without the doctests. A path out of every crate, or in a crate without tests, is refused, named, and
21
27
  // nothing plays (code 2). Without a path, every crate plays, or, under the circuit's mark
22
28
  // (`GRILLHOUSE_DEPUIS_LE_VERT`), the crates the changes since the last green touch and their
23
29
  // dependents (./touches.mjs), every crate when no last green counts. `--force` changes nothing:
@@ -55,7 +61,16 @@
55
61
  // - The exit code: 0 when every task is green, 75 when the only reds are « à repasser », 1
56
62
  // otherwise; 2 for a path refused, a Cargo.lock not tracked or a command unknown.
57
63
  import { spawnSync } from 'node:child_process';
58
- import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
64
+ import {
65
+ closeSync,
66
+ copyFileSync,
67
+ existsSync,
68
+ mkdirSync,
69
+ openSync,
70
+ readFileSync,
71
+ rmSync,
72
+ writeFileSync,
73
+ } from 'node:fs';
59
74
  import { constants, tmpdir } from 'node:os';
60
75
  import path from 'node:path';
61
76
  import { fileURLToPath, pathToFileURL } from 'node:url';
@@ -152,12 +167,27 @@ function passe(racine, env) {
152
167
  ecrire();
153
168
  return { t, args };
154
169
  },
155
- jouer({ t, args }, junit = null) {
170
+ jouer({ t, args }, { junit = null, journal = null } = {}) {
156
171
  // A report of an earlier run is no report of this one, which may write none.
157
172
  if (junit) {
158
173
  rmSync(junit, { force: true });
159
174
  }
160
- const r = spawnSync('cargo', args, { cwd: racine, env, stdio: 'inherit' });
175
+ let r;
176
+ if (journal) {
177
+ // The output of cargo, both streams in their order, goes to the task's log, then to the
178
+ // command's error stream, where cargo writes it.
179
+ mkdirSync(path.dirname(journal), { recursive: true });
180
+ const fd = openSync(journal, 'w');
181
+ try {
182
+ r = spawnSync('cargo', args, { cwd: racine, env, stdio: ['inherit', fd, fd] });
183
+ } finally {
184
+ closeSync(fd);
185
+ }
186
+ process.stderr.write(readFileSync(journal, 'utf8'));
187
+ t.journal = path.relative(racine, journal);
188
+ } else {
189
+ r = spawnSync('cargo', args, { cwd: racine, env, stdio: 'inherit' });
190
+ }
161
191
  t.code = r.error ? 127 : (r.status ?? 128 + (constants.signals[r.signal] ?? 0));
162
192
  if (junit && dossier && existsSync(junit)) {
163
193
  mkdirSync(path.join(dossier, JUNIT), { recursive: true });
@@ -192,30 +222,40 @@ function depuisLeVert(racine, tous, tout, env) {
192
222
  }
193
223
 
194
224
  // Plans and plays the tests of the crates <choix> (each `{ c, cibles }`, `cibles` the test targets
195
- // named, empty for the whole crate) in the run <p>.
225
+ // named, empty for the whole crate) in the run <p>: for a crate that plays tests, the build of its
226
+ // test targets first, then nextest, then its doctests; a failed build leaves the crate's other
227
+ // tasks not played.
196
228
  function jouerLesTests(racine, p, choix, options) {
197
229
  const m = metadonnees(racine);
198
230
  const junit = path.join(m.target_directory, 'nextest', PROFIL, 'junit.xml');
199
- const prevues = [];
231
+ const parCrate = [];
200
232
  for (const { c, cibles } of choix) {
201
233
  Object.assign(p.cibles, binaires(c));
202
234
  const d = c.composant.dossier;
235
+ const nom = c.composant.nom;
236
+ const prevues = [];
203
237
  if (joueDesTests(racine, c.composant)) {
238
+ const selection = ['-p', nom, ...cibles.flatMap(n => ['--test', n])];
239
+ const journal = path.join(m.target_directory, 'grillhouse', `${nom}-build.log`);
240
+ const construction = ['test', '--no-run', ...selection];
241
+ prevues.push([p.prevoir(nom, d, 'build', false, construction), { journal }]);
204
242
  const args = ['nextest', 'run', '--tool-config-file', `${PROFIL}:${NEXTEST}`];
205
- args.push('--profile', PROFIL, '--no-fail-fast', '-p', c.composant.nom);
206
- for (const n of cibles) {
207
- args.push('--test', n);
208
- }
209
- prevues.push([p.prevoir(c.composant.nom, d, 'nextest', true, [...args, ...options]), junit]);
243
+ args.push('--profile', PROFIL, '--no-fail-fast', ...selection);
244
+ prevues.push([p.prevoir(nom, d, 'nextest', true, [...args, ...options]), { junit }]);
210
245
  }
211
246
  const doctests = c.cibles.some(t => t.kind.includes('lib') && t.doctest !== false);
212
247
  if (cibles.length === 0 && doctests) {
213
- const args = ['test', '--doc', '-p', c.composant.nom];
214
- prevues.push([p.prevoir(c.composant.nom, d, 'doctest', true, args), null]);
248
+ const args = ['test', '--doc', '-p', nom];
249
+ prevues.push([p.prevoir(nom, d, 'doctest', true, args), {}]);
215
250
  }
251
+ parCrate.push(prevues);
216
252
  }
217
- for (const [t, j] of prevues) {
218
- p.jouer(t, j);
253
+ for (const prevues of parCrate) {
254
+ for (const [t, o] of prevues) {
255
+ if (p.jouer(t, o) !== 0 && t.t.script === 'build') {
256
+ break;
257
+ }
258
+ }
219
259
  }
220
260
  }
221
261
 
@@ -108,12 +108,14 @@ export function joueDesTests(_racine, composant) {
108
108
 
109
109
  /**
110
110
  * The readers, by their manifests, of the crates <noms> among <composants> of <racine>: each a
111
- * reader `{ composant, par }`, `par` the kinds of its dependencies on it.
111
+ * reader `{ composant, par }`, `par` the kinds of its dependencies on it; what each crate reads
112
+ * (`lit`), every kind; what its tests read (`parLesTests`), its dependencies of development.
112
113
  */
113
114
  export function lecteurs(racine, { composants: liste, noms }) {
114
115
  const tous = crates(racine);
115
116
  const parDossier = new Map(liste.map(c => [c.dossier, c]));
116
117
  const lit = new Map(liste.map(c => [c, new Set()]));
118
+ const parLesTests = new Map(liste.map(c => [c, new Set()]));
117
119
  const genres = new Map(liste.map(c => [c, new Map()]));
118
120
  for (const c of tous) {
119
121
  const lecteur = parDossier.get(c.composant.dossier);
@@ -126,6 +128,9 @@ export function lecteurs(racine, { composants: liste, noms }) {
126
128
  continue;
127
129
  }
128
130
  lit.get(lecteur).add(lu);
131
+ if (d.genre === 'dev') {
132
+ parLesTests.get(lecteur).add(lu);
133
+ }
129
134
  const g = genres.get(lu);
130
135
  if (!g.has(lecteur)) {
131
136
  g.set(lecteur, new Set());
@@ -151,6 +156,7 @@ export function lecteurs(racine, { composants: liste, noms }) {
151
156
  sansFournisseur,
152
157
  types: { etat: 'fait', raison: null, elements: [] },
153
158
  lit,
159
+ parLesTests,
154
160
  };
155
161
  }
156
162
 
@@ -4,7 +4,8 @@
4
4
  //
5
5
  // - `<dossier>/cargo/<run>.json`, one per run: `{ taches, cibles }`, each task as the join types
6
6
  // it (`code` null for a task planned that did not run; `tests` true for the runs of nextest and
7
- // of the doctests), and the file of each test binary of nextest by its id (`ws-core`,
7
+ // of the doctests; `journal`, from the root, the log of the task `build`, the build of a crate's
8
+ // test targets, which the circuit reads for a failed build), and the file of each test binary of nextest by its id (`ws-core`,
8
9
  // `ws-core::integ`, `ws-core::bin/outil`), its target's source.
9
10
  // - `<dossier>/nextest/<run>-<crate>.xml`, the JUnit report of each run of nextest: each
10
11
  // `testsuite`, a test binary, gives a test file, each `testcase` a test, failed when it holds a
@@ -230,14 +230,22 @@ function fournisseur(spec, fichier, tous, soi) {
230
230
  }
231
231
 
232
232
  // What each component really uses of the others: Map provider → Map consumer → Set of names. Its
233
- // production code counts for every provider, its tests for a package of the material only.
234
- export function utilise(racine, tous = composants(racine)) {
233
+ // production code counts for every provider, its tests for a package of the material only; the
234
+ // providers its tests import, the material's included, go in <parLesTests>, when given (Map
235
+ // consumer → Set of providers, each of <tous>).
236
+ export function utilise(racine, tous = composants(racine), parLesTests = null) {
235
237
  const out = new Map();
236
238
  const matiere = new Set(matieres(racine).map(m => m.nom));
237
239
  for (const c of tous) {
238
240
  for (const { f, test } of fichiers(c.dir)) {
239
241
  for (const { spec, noms } of imports(lireSiPresent(f) ?? '')) {
240
242
  const p = fournisseur(spec, f, tous, c);
243
+ if (p && test && parLesTests) {
244
+ if (!parLesTests.has(c)) {
245
+ parLesTests.set(c, new Set());
246
+ }
247
+ parLesTests.get(c).add(p);
248
+ }
241
249
  if (!p || (test && !matiere.has(p.nom))) continue;
242
250
  if (!out.has(p.nom)) out.set(p.nom, new Map());
243
251
  const parConsommateur = out.get(p.nom);
@@ -15,7 +15,8 @@
15
15
  // imports the provider (the test file's path).
16
16
  // - By the types (scripts/langages/typescript/references-par-les-types.mjs): each element the text writes, resolved by
17
17
  // TypeScript's language service over the components' `tsconfig.json`.
18
- // - What each component reads (`lit`): its imports, and the providers of the elements it reads.
18
+ // - What each component reads (`lit`): its imports, and the providers of the elements it reads;
19
+ // what its tests read (`parLesTests`): the components its tests import.
19
20
  import { existsSync, readFileSync } from 'node:fs';
20
21
  import path from 'node:path';
21
22
  import {
@@ -97,12 +98,13 @@ function importe(texte, fichier, p) {
97
98
  // components <composants> of <racine> (`composants` of the module), the components the text
98
99
  // names <nommes>: `{ elements: [{ nom, fournisseur, lecteurs: [{ composant, par }] }],
99
100
  // sansFournisseur, types: { etat, raison, elements: [{ nom, declarations: [{ composant, publie }],
100
- // lecteurs: Map composant → Set of « par » }] }, lit: Map composant → Set of composants }`, each
101
- // component one of <composants>.
101
+ // lecteurs: Map composant → Set of « par » }] }, lit: Map composant → Set of composants,
102
+ // parLesTests: Map composant → Set of composants }`, each component one of <composants>.
102
103
  export function lecteurs(racine, { composants, noms, texte, nommes }) {
103
104
  const tous = composants.map(c => ({ nom: c.nom, dir: c.dossier, paquet: c.paquet, c }));
104
105
  const exterieur = i => i.c;
105
- const reel = utilise(racine, tous);
106
+ const testsLisent = new Map();
107
+ const reel = utilise(racine, tous, testsLisent);
106
108
  const ifaces = interfacesDe(racine, tous);
107
109
  const tests = new Map();
108
110
  const testsDuComposant = c => {
@@ -157,6 +159,12 @@ export function lecteurs(racine, { composants, noms, texte, nommes }) {
157
159
  }
158
160
  }
159
161
  for (const e of elements) for (const l of e.lecteurs) lit.get(l.composant).add(e.fournisseur);
162
+ const parLesTests = new Map(composants.map(c => [c, new Set()]));
163
+ for (const [c, lus] of testsLisent) {
164
+ for (const p of lus) {
165
+ parLesTests.get(c.c).add(p.c);
166
+ }
167
+ }
160
168
  return {
161
169
  elements,
162
170
  sansFournisseur: sansFournisseur.filter(
@@ -175,5 +183,6 @@ export function lecteurs(racine, { composants, noms, texte, nommes }) {
175
183
  })),
176
184
  },
177
185
  lit,
186
+ parLesTests,
178
187
  };
179
188
  }
@@ -261,8 +261,12 @@ export function leService(racine, tous) {
261
261
  // components the ticket names (<contexte>: `{ fichiers, composants }`, Sets of file names and of
262
262
  // components), when it has some: `{ etat: 'fait', raison: null, elements: [{ nom, ecrit,
263
263
  // declarations: [{ c, publie }], lecteurs: Map component → Set of « par » }] }`, or
264
- // `{ etat: 'impossible', raison, elements: [] }` when it cannot run.
264
+ // `{ etat: 'impossible', raison, elements: [] }` when it cannot run. Without any element, the
265
+ // survey is done at once: no language service is built.
265
266
  export function parLesTypes(racine, tous, ecrits, contexte = {}) {
267
+ if (ecrits.length === 0) {
268
+ return { etat: 'fait', raison: null, elements: [] };
269
+ }
266
270
  try {
267
271
  return releveParLesTypes(racine, tous, ecrits, contexte);
268
272
  } catch (e) {
package/scripts/nuit.sh CHANGED
@@ -63,6 +63,14 @@
63
63
  # the night ticket « La poussée de la nuit est refusée sur <commit> vers « origin/<branch> » »
64
64
  # (or comments the open one that names « origin/<branch> »), and exits 1; a remote already at
65
65
  # the commit accepts the push.
66
+ # - The copies whose content is on main: once its steps are played, whatever their verdict, the
67
+ # night passes each copy `git worktree list` names, the main tree and its own left out, through
68
+ # scripts/retirer-copie.sh without `--jetable` (scripts/copies-finies.mjs), as a CI cleans its
69
+ # workspaces at the end of a pipeline: a copy whose commits and local work have all entered
70
+ # main by their content goes, and its branch (main and a branch another copy holds stay); a copy
71
+ # refused (commits or work not entered, a lock) or held by a running circuit (its ticket in progress, its
72
+ # `<copie>.travail`, the lock of the integration or of the queue) stays, its log line naming
73
+ # why. The removal never changes the night's verdict.
66
74
  # - It takes no lock of the integration or of the queue (scripts/integration/file.mjs): an
67
75
  # integration and the queue run during the night, each in its own copy.
68
76
  # - Its log is <git common dir>/nuit/<date>.log. Green: HEAD becomes the last green commit
@@ -265,6 +273,9 @@ fin() {
265
273
  }
266
274
  jouer >> "$journal" 2>&1
267
275
  verdict=$?
276
+ # The copies whose content is on main go once the steps are played, the night's own kept; their
277
+ # removal never changes the verdict.
278
+ (cd "$racine" && node "$ici/copies-finies.mjs" "$copie") >> "$journal" 2>&1 || true
268
279
 
269
280
  if [ "$verdict" -eq 75 ]; then
270
281
  echo "⏱ à repasser : ${tete:0:7} n'est ni vert ni rouge, la machine est restée chargée ; le dernier vert reste, aucun ticket, la nuit suivante rejoue." >> "$journal"
@@ -24,7 +24,10 @@
24
24
  // - `reponses` (`titre` of the finding, `etat` levé or contesté, `raison` for a contesté,
25
25
  // `piece`): as the author answers in each thread of a review on GitHub or Gerrit, a FAIT
26
26
  // answers each finding of the reviewer open for him, by its title, and the circuit refuses a
27
- // sheet without the answer to one (`reponsesAuxConstats`) and gives the next review each answer
27
+ // sheet without the answer to one (`reponsesAuxConstats`), save in a run where the supervisor
28
+ // gives the task (`--contexte`, the findings open at the run's launch then its context, the
29
+ // ones a RENDU states within it still its task: `constatsDeLaSeance` of
30
+ // scripts/circuit.mjs), and gives the next review each answer
28
31
  // under its finding (BP 320.21: the cause of his choice in a handover the circuit does not
29
32
  // read, three RENDU, then the stop) (developpeur);
30
33
  // - `ecarts` (`sujet`, `texte`): the body of the commit message, written by the circuit, each
@@ -2,7 +2,8 @@
2
2
  # The removal of a working copy, called by the three places that end one: the agent copy (by
3
3
  # scripts/integration/integrer.mjs once its lot is committed, and by the supervisor for a ticket
4
4
  # closed without integration), the integration copy (by the same script) and the night copy
5
- # (scripts/nuit.sh), the last two when their existing copy does not get ready.
5
+ # (scripts/nuit.sh), the last two when their existing copy does not get ready; and by the night
6
+ # for every other copy once its steps are played (scripts/copies-finies.mjs), without `--jetable`.
6
7
  #
7
8
  # npx grillhouse retirer-copie [--jetable] [--garder-travail] <copie>
8
9
  #
@@ -168,7 +168,11 @@ son adresse) : le circuit la consigne fermée sous ton ticket, et tu continues.
168
168
  `titre` tel que ta consigne l'écrit : `levé`, avec sa `piece`, ou `contesté`, avec sa `raison`
169
169
  et sa `piece` ; le circuit refuse une fiche à laquelle il en manque une, et le relecteur lit
170
170
  chaque réponse sous son constat, comme l'auteur répond dans chaque fil d'une revue. Une
171
- passation qui dit pourquoi tu gardes ton choix ne suffit pas : le relecteur ne la reçoit pas ;
171
+ passation qui dit pourquoi tu gardes ton choix ne suffit pas : le relecteur ne la reçoit pas.
172
+ Quand le superviseur te donne ta tâche, en tête de ta consigne, les constats ouverts au
173
+ lancement de sa passe sont ton contexte : aucune réponse ne leur est exigée, et une réponse
174
+ donnée reste lue sous son constat ; un constat qu'un `RENDU` pose dans la passe exige la
175
+ sienne ;
172
176
  - `ecarts` : ce que le message de commit nomme, chacun sous son `sujet` (ce qui s'écarte :
173
177
  une référence, un test, un plafond), avec son `texte` ;
174
178
  - `decouvertes` : ce que le circuit consigne fermé sous le ticket.
@@ -183,7 +187,11 @@ son adresse) : le circuit la consigne fermée sous ton ticket, et tu continues.
183
187
  valables. La dernière tentative, sur le modèle fort, est une séance neuve et entière. Ainsi tu
184
188
  repars de ce que tu sais. Toute relance (des contrôles rouges, un `RENDU`, une reprise du
185
189
  superviseur) porte les constats du relecteur qui restent ouverts pour toi, tous, jusqu'à la
186
- relecture qui les juge levés. Ainsi aucun constat ne se perd d'une relance à l'autre.
190
+ relecture qui les juge levés. Ainsi aucun constat ne se perd d'une relance à l'autre. Une
191
+ relance du superviseur avec son contexte (`--contexte`) te donne ce contexte en tête de ta
192
+ consigne : c'est ta tâche, qui passe avant le ticket, le rapport et les constats ; ceux
193
+ ouverts au lancement de sa passe te sont donnés en contexte, ceux qu'un `RENDU` pose dans la
194
+ passe restent ta tâche. Ainsi la demande du superviseur prime.
187
195
  - **Les tests ciblés** : les tests touchés et voisins, plus ceux des composants en aval quand une
188
196
  interface change (`npm test -- <fichiers>`).
189
197
  - **Une suite se juge sur tous ses échecs** : leur liste se compare nom par nom aux échecs connus.
@@ -138,7 +138,10 @@ nomme le responsable, ce qui décide, les documents qu'il valide et les commande
138
138
  le même lot (la charge, main), et `--depuis developpeur` repart du développeur, le refus comme
139
139
  son rapport, quand le lot est en cause ; `--arreter`, son motif en
140
140
  `--contexte`, quand le ticket
141
- doit changer avant tout travail. Une décision du responsable qui change le plan entre dans la
141
+ doit changer avant tout travail. Mon `--contexte` est la tâche du testwriter et du
142
+ développeur : il vient en tête de leur consigne, et les constats du relecteur ouverts au
143
+ lancement de la passe leur sont donnés en contexte, sans réponse exigée ; un constat qu'un
144
+ `RENDU` pose dans la passe reste leur tâche. Une décision du responsable qui change le plan entre dans la
142
145
  description du ticket (`bd update <ticket> -d`), que tous les agents lisent, avant que je
143
146
  reprenne. 22 (`questionnement`) : des questions du plan restent ouvertes après la réponse de
144
147
  l'explorateur, au ticket avec leur pièce ; je change le plan (`bd update <ticket>`) ou je le
@@ -3,7 +3,10 @@
3
3
  Huit gabarits, que le circuit du ticket (`packages/grillhouse/scripts/circuit.mjs`) remplit, chaque `{{champ}}` reçu
4
4
  de lui : le premier pour chaque séance neuve du testwriter et du développeur, une par rôle pour
5
5
  tout le ticket, dans l'enveloppe du plan du ticket, le lanceur ajoutant ses sections, chaque
6
- consigne portant les constats du relecteur qui restent ouverts pour son rôle ; le second pour chaque séance du relecteur, hors
6
+ consigne portant les constats du relecteur qui restent ouverts pour son rôle, et, quand le
7
+ superviseur relance le circuit avec `--contexte`, ce contexte en tête, comme sa tâche
8
+ (`{{tache}}`), les constats ouverts au lancement de la passe devenant son contexte, après
9
+ ceux qu'un `RENDU` pose dans la passe (`{{ouverts}}`, leur titre, et `{{constats}}`) ; le second pour chaque séance du relecteur, hors
7
10
  enveloppe, après la passe finale verte, qui porte la liste des éléments du lot, et après un `RENDU` la relecture d'avant (la
8
11
  commande de la différence entre le lot qu'elle a lu et celui d'aujourd'hui, ses fichiers, les
9
12
  constats qui restent ouverts, chacun avec la réponse du développeur sous lui) et ne nomme que les fichiers que le lot change depuis elle ; le troisième pour la reprise
@@ -34,7 +37,7 @@ Tu es le {{role}} du dépôt {{depot}}. Contexte neuf, une seule tâche.
34
37
 
35
38
  Premier geste : charge ta compétence (outil Skill), puis suis-la. Ainsi tu travailles dans le cadre écrit.
36
39
 
37
- TON TICKET : {{ticket}} — {{sujet}}
40
+ {{tache}}TON TICKET : {{ticket}} — {{sujet}}
38
41
 
39
42
  TON PLAN : {{paquets}}, les paquets du ticket, le fournisseur d'abord ; ta séance porte tout le ticket, dans tous ces paquets.
40
43
 
@@ -42,8 +45,6 @@ REPRISE : {{reprise}}
42
45
 
43
46
  LOTS À LIRE : {{lots}}
44
47
 
45
- CONTEXTE : {{contexte}}
46
-
47
48
  LE TICKET, sa description et ses critères, lus au lancement de ta séance :
48
49
 
49
50
  {{description}}
@@ -52,7 +53,7 @@ LE RAPPORT DE L'ÉTAPE D'AVANT, mesuré par le circuit :
52
53
 
53
54
  {{rapport}}
54
55
 
55
- LES CONSTATS DU RELECTEUR QUI RESTENT OUVERTS pour ton rôle, chacun jusqu'à la relecture qui le juge levé :
56
+ {{ouverts}} :
56
57
 
57
58
  {{constats}}
58
59
 
@@ -68,7 +69,7 @@ LES RÉFÉRENCES QUE LE CIRCUIT RÉGÉNÈRE à l'étape 4.2, sur la copie entiè
68
69
 
69
70
  Ta séance finit sur ta fiche, que ton schéma décrit et que le circuit lit seule ; ta passation au ticket (`bd comments add`) reste, pour l'humain et la séance suivante de ton rôle : ce qui est fait, ce qui ne l'est pas et pourquoi.
70
71
 
71
- Testwriter : chaque test vert avant le code entre dans `verts_attendus` (son fichier depuis la racine, son nom complet tel que le rapport de la preuve l'écrit, sa raison) ; pour un fichier de tests que HEAD tient, adapté, dont tous les verts ont une même raison, le fichier et la raison seuls, qui n'excusent aucun rouge et ne valent rien sur un fichier neuf ; quand le ticket change un type ou un nom d'un paquet du plan, tu migres aussi, dans la même séance, la matière de test partagée et les tests du plan qui le lisent ; tu inscris, dans le même lot, chaque nom de la matière de test partagée que tes tests se mettent à importer, sur la ligne de leur paquet dans la section « Consommateurs » de l'interface du fournisseur. Développeur : quand le rouge qui reste est dans les tests du lot, ta fiche porte `renvoi` (testwriter), et le circuit relance le testwriter, puis la preuve et ta séance, sa consigne portant ta fiche, ta passation et la sortie rouge des derniers contrôles ; un critère que tu ne tiens pas parce qu'il demande un paquet hors du plan va dans `hors_plan` (son numéro, ce paquet, sa pièce), même quand ta fiche dit FAIT, et le circuit monte au superviseur à 3 Code ; sur FAIT, ta fiche répond à chaque constat du relecteur ouvert pour toi, par son titre, dans `reponses` (`levé` avec sa `piece`, ou `contesté` avec sa `raison` et sa `piece`), que le relecteur lit sous son constat, et le circuit refuse une fiche à laquelle il en manque une ; un écart que le commit doit nommer va dans `ecarts`, sous son sujet. Ainsi chaque rouge va à l'agent qui le lève.
72
+ Testwriter : chaque test vert avant le code entre dans `verts_attendus` (son fichier depuis la racine, son nom complet tel que le rapport de la preuve l'écrit, sa raison) ; pour un fichier de tests que HEAD tient, adapté, dont tous les verts ont une même raison, le fichier et la raison seuls, qui n'excusent aucun rouge et ne valent rien sur un fichier neuf ; quand le ticket change un type ou un nom d'un paquet du plan, tu migres aussi, dans la même séance, la matière de test partagée et les tests du plan qui le lisent ; tu inscris, dans le même lot, chaque nom de la matière de test partagée que tes tests se mettent à importer, sur la ligne de leur paquet dans la section « Consommateurs » de l'interface du fournisseur. Développeur : quand le rouge qui reste est dans les tests du lot, ta fiche porte `renvoi` (testwriter), et le circuit relance le testwriter, puis la preuve et ta séance, sa consigne portant ta fiche, ta passation et la sortie rouge des derniers contrôles ; un critère que tu ne tiens pas parce qu'il demande un paquet hors du plan va dans `hors_plan` (son numéro, ce paquet, sa pièce), même quand ta fiche dit FAIT, et le circuit monte au superviseur à 3 Code ; sur FAIT, ta fiche répond à chaque constat du relecteur ouvert pour toi, par son titre, dans `reponses` (`levé` avec sa `piece`, ou `contesté` avec sa `raison` et sa `piece`), que le relecteur lit sous son constat, et le circuit refuse une fiche à laquelle il en manque une ; quand le superviseur te donne ta tâche, en tête de cette consigne, les constats ouverts au lancement de sa passe te sont donnés en contexte : une réponse que tu leur donnes reste lue sous son constat, aucune n'est exigée ; un constat qu'un `RENDU` pose dans la passe exige la sienne ; un écart que le commit doit nommer va dans `ecarts`, sous son sujet. Ainsi chaque rouge va à l'agent qui le lève.
72
73
 
73
74
  Le `statut` de ta fiche : FAIT quand ta part est faite ; BLOQUÉ, avec sa `raison`, quand ce qui reste est hors de ta portée (dans les tests, dans la matière de test partagée, dans un fichier hors du plan, ou une décision hors de ton rôle) ; BESOIN, avec sa `question`, quand une réponse te manque pour avancer. Sur BESOIN, ou BLOQUÉ sans `renvoi`, le circuit s'arrête sans te relancer, et ta question monte au superviseur ; une découverte hors des critères va dans `decouvertes`, que le circuit consigne. Ainsi aucune séance ne tourne sur ce que son agent a dit hors de sa portée.
74
75
 
@@ -130,7 +131,7 @@ Ta séance a fini sans fiche conforme : {{erreur}}. Le circuit ne lit rien d'aut
130
131
  ## Testwriter et développeur, sur une reprise (rempli par le circuit)
131
132
 
132
133
  ```text
133
- TON TICKET : {{ticket}} — {{sujet}}
134
+ {{tache}}TON TICKET : {{ticket}} — {{sujet}}
134
135
 
135
136
  TON PLAN : {{paquets}}
136
137
 
@@ -142,11 +143,11 @@ LE RAPPORT NEUF, mesuré par le circuit :
142
143
 
143
144
  {{rapport}}
144
145
 
145
- LES CONSTATS DU RELECTEUR QUI RESTENT OUVERTS pour ton rôle :
146
+ {{ouverts}} :
146
147
 
147
148
  {{constats}}
148
149
 
149
- Lève ce que disent ce rapport et ces constats, dans le cadre de ta consigne. Ta séance finit sur ta fiche, que le circuit lit : `statut` FAIT, BLOQUÉ avec sa `raison`, ou BESOIN avec sa `question` ; développeur, sur FAIT, ta réponse à chacun de ces constats, par son titre (`reponses`). Ainsi le circuit lit ta fin.
150
+ Fais ta tâche quand le superviseur t'en donne une, en tête de cette consigne, et lève ce que disent ce rapport et les constats qui ne sont pas donnés en contexte ; sans tâche, lève ce que disent ce rapport et ces constats ; toujours dans le cadre de ta consigne. Ta séance finit sur ta fiche, que le circuit lit : `statut` FAIT, BLOQUÉ avec sa `raison`, ou BESOIN avec sa `question` ; développeur, sur FAIT, ta réponse à ces constats, par son titre (`reponses`), exigée pour chacun qui n'est pas donné en contexte. Ainsi le circuit lit ta fin.
150
151
  ```
151
152
 
152
153
  ## Questionneur, sur le plan (rempli par le circuit)
@@ -140,6 +140,13 @@ circuit cherche chaque pièce fichier:ligne dans la copie et refuse une fiche do
140
140
  introuvable. Le circuit l'écrit au ticket, sur plusieurs lignes, son premier mot le verdict, que le
141
141
  script d'intégration et le tableau lisent, puis tes remarques. Tu n'écris rien au ticket toi-même.
142
142
 
143
+ **Une pièce que le ticket exige se lit avant ton verdict** : une pièce qu'un critère ou une section
144
+ du ticket exige (une passation, une sortie, une décision) et que tu ne peux pas lire rend le lot
145
+ (`RENDU`), par un constat bloquant que son `role` adresse à l'agent qui la doit ; une décision qui
146
+ revient au responsable et que le lot n'a pas reçue monte par ta `question`, jamais sous un
147
+ `ACCEPTÉ`. Ainsi le lot n'entre sur main que sur des pièces lues, comme une revue mûre n'approuve
148
+ aucune preuve qu'elle n'a pas vue.
149
+
143
150
  **Un constat bloquant tient un critère du plan ou une règle du cadre**, que son champ `regle`
144
151
  nomme (« critère 2 », ou le document et sa règle) ; tout autre constat est une remarque (`genre`
145
152
  `remarque`), que le circuit écrit au ticket sans relancer personne. Seuls les constats bloquants