@roomi-fields/grillhouse 0.25.4 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/agents/testwriter.md +1 -1
  3. package/bin/grillhouse.mjs +20 -3
  4. package/cadre/templates/cargo/package.json +3 -0
  5. package/cadre/templates/projet/.gitattributes +1 -0
  6. package/cadre/templates/projet/CLAUDE.md +6 -0
  7. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  8. package/charte.md +10 -1
  9. package/docs/ARCHITECTURE.md +107 -19
  10. package/docs/INTERFACE.md +19 -5
  11. package/hooks/register.tsx +57 -16
  12. package/package.json +9 -3
  13. package/scripts/circuit.mjs +244 -66
  14. package/scripts/copies-finies.mjs +345 -0
  15. package/scripts/crochets.mjs +9 -3
  16. package/scripts/enveloppe/enveloppe.mjs +59 -17
  17. package/scripts/enveloppe/lancer.sh +15 -22
  18. package/scripts/enveloppe/travail-de-la-copie.mjs +188 -0
  19. package/scripts/etapes.mjs +1 -1
  20. package/scripts/fusion-du-changelog.mjs +120 -0
  21. package/scripts/grillhouse-maj.mjs +19 -0
  22. package/scripts/integration/file.mjs +196 -104
  23. package/scripts/jointure.d.ts +26 -1
  24. package/scripts/langages/cargo/binaires.json +2 -1
  25. package/scripts/langages/cargo/clippy.mjs +10 -2
  26. package/scripts/langages/cargo/commandes.mjs +77 -22
  27. package/scripts/langages/cargo/composants.mjs +236 -9
  28. package/scripts/langages/cargo/index.mjs +17 -8
  29. package/scripts/langages/cargo/sccache.mjs +143 -0
  30. package/scripts/langages/cargo/verdict.mjs +52 -11
  31. package/scripts/langages/typescript/consommateurs.mjs +10 -2
  32. package/scripts/langages/typescript/index.mjs +4 -2
  33. package/scripts/langages/typescript/lecteurs.mjs +13 -4
  34. package/scripts/langages/typescript/references-par-les-types.mjs +5 -1
  35. package/scripts/langages/typescript/regle-des-tests.mjs +37 -0
  36. package/scripts/nuit.sh +25 -0
  37. package/scripts/outils-cles.mjs +188 -0
  38. package/scripts/resultats.mjs +26 -7
  39. package/scripts/retirer-copie.sh +2 -1
  40. package/scripts/sous-commandes.mjs +16 -0
  41. package/scripts/verrou-de-machine.mjs +14 -13
  42. package/scripts/verrous/verrou.mjs +50 -14
  43. package/skills/developpeur/SKILL.md +14 -2
  44. package/skills/explorateur/SKILL.md +3 -1
  45. package/skills/pitmaster/SKILL.md +10 -3
  46. package/skills/pitmaster/references/consigne-agent.md +11 -10
  47. package/skills/relecteur/SKILL.md +13 -2
  48. package/skills/testwriter/SKILL.md +23 -6
@@ -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,12 +380,19 @@
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
387
390
  // question (`critere_en_cause`), stops at « relecture-arret »; so does the third RENDU since the
388
- // ticket's last ACCEPTÉ.
391
+ // ticket's last ACCEPTÉ, and a RENDU whose finding goes to the testwriter when the plan skips
392
+ // him (`sansTests`), at that verdict, as a CI fails fast on a step it cannot run
393
+ // (`arretDuTestwriterSaute`; OSC Bridge SH-13y.1: three RENDU « Agent : testwriter » on a
394
+ // package whose tests no command of the frame plays, the developpeur relaunched on an empty
395
+ // diff each time); its question, declare the tests of the package or settle the finding.
389
396
  // - ACCEPTÉ: the integration, once the whole final pass has played on the lot accepted (its tree
390
397
  // is `verifie`); else that pass first, once, its red going to the developpeur and the lot then
391
398
  // to the reviewer again. The circuit builds the lot from the copy: the files the copy changes
@@ -409,6 +416,9 @@
409
416
  // sorts the discoveries (below), then ends at « integre », exit 0 (the queue's last word at the
410
417
  // ticket named with it, a CI it could not read); reopened (out of the queue, or a red CI), it stops at « integration », the queue's
411
418
  // last word as its reason; still in the queue, it stops at « a-repasser », the queue's reason.
419
+ // The branch out of the queue and its ticket open, as `--reprendre` finds it after a red CI, the
420
+ // queue reads the CI of the ticket's commit on main again (`file.mjs --ci <ticket>`): a rerun
421
+ // green (`gh run rerun <id> --failed`) closes the ticket, as an entry does.
412
422
  // - Then the tri of the discoveries (step 5.3, `trier`), as Chromium and Mozilla give each new
413
423
  // report a verdict before it is filed: each discovery a sheet filed is kept with the circuit's
414
424
  // results (`decouverte`: its id, its subject); without one, no session. Else one session of the
@@ -461,7 +471,8 @@
461
471
  // a stop « questionnement », it lets the plan pass as it is then (the supervisor
462
472
  // changed it or kept it), from the testwriter.
463
473
  // - `--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
474
+ // that step, the text of `--contexte` the task at the head of each agent's instruction in the
475
+ // run, the reviewer's line CONTEXTE (after a stop
465
476
  // « integration », from the developpeur, the refusal as his report, the red to lift, as a merge
466
477
  // queue sends the lot back to its author with the log of its check; from the testwriter, the
467
478
  // refusal dropped), as a retry
@@ -471,7 +482,10 @@
471
482
  // no `--reprendre`, and names no component: a second name is a second ticket, exit 2.
472
483
  // - `--etendre <paquet>[,<paquet>…]` (each a path or a package name of the repository) extends the
473
484
  // 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
485
+ // package of the plan that reads it, as the module of the language says (`lecteurs` of the
486
+ // join: the imports of a package of TypeScript, its tests' included, the dependencies of a
487
+ // crate, of development included), else at its end,
488
+ // said at the ticket
475
489
  // (`Circuit · plan : le superviseur étend le plan à …`); then the step under way resumes as
476
490
  // after `--reprendre`, on the plan extended, the question as its context with the text of
477
491
  // `--contexte`; a stop « sans-livraison » on the developpeur's sending to the testwriter
@@ -506,7 +520,8 @@
506
520
  // ticket in one short comment, `Circuit · bilan : …`, compared with the bilan before it in the
507
521
  // project.
508
522
  // - Exit codes: 0 at « integre »; 2 a malformed call; a stop, by its name (ARRETS):
509
- // 10 lancement (lancer.sh stopped before the session), 11 bloqué (a motionless transcript),
523
+ // 10 lancement (lancer.sh stopped before the session, or the tools of the project,
524
+ // `grillhouse.outils`, refused at the launch or a resumption, before any session), 11 bloqué (a motionless transcript),
510
525
  // 12 sans-fiche (twice no sheet that conforms), 13 preuve (the third proof fails), 14 controles
511
526
  // (the third developpeur of the checks or of the final pass leaves a red check, a red of the
512
527
  // final pass out of the plan or that no package of the plan holds, or reds to settle),
@@ -515,8 +530,8 @@
515
530
  // second developpeur session that `--depuis developpeur` launched on the lot the integration
516
531
  // refused and that changes nothing; or
517
532
  // the developpeur's same sending to the testwriter twice in a row, on the same red output of the
518
- // checks, no green checks between them), 16 relecture-arret (a finding without a valid agent, one on a criterion, the third
519
- // RENDU), 17 integration (the integration script refuses the lot, or the queue reopens the
533
+ // checks, no green checks between them), 16 relecture-arret (a finding without a valid agent, one to the testwriter the plan skips,
534
+ // one on a criterion, the third RENDU), 17 integration (the integration script refuses the lot, or the queue reopens the
520
535
  // ticket), 19 hors-portee (a testwriter or developpeur whose sheet says BLOQUÉ, without a
521
536
  // sending to the testwriter, or a developpeur's FAIT with criteria out of the plan), 20 besoin (a testwriter or developpeur whose sheet says BESOIN, a
522
537
  // reviewer whose sheet carries a `question`, or a ticket labelled `arbitrage` whose arbitrage
@@ -550,6 +565,7 @@ import { pathToFileURL } from 'node:url';
550
565
  import { stripVTControlCharacters } from 'node:util';
551
566
  import { ecrireLeBilan } from './bilan.mjs';
552
567
  import { DEPUIS_LE_VERT } from './dernier-vert.mjs';
568
+ import { avecLesOutils, outilsDe } from './outils-cles.mjs';
553
569
  import { commandesPermises, optionsDuRole } from './droits.mjs';
554
570
  import {
555
571
  ecrireLaListe,
@@ -578,6 +594,7 @@ import { FICHIER as DETTE } from './dette.mjs';
578
594
  import {
579
595
  A_ELAGUER,
580
596
  bloquantsDeLaFiche,
597
+ cleDuConstat,
581
598
  conformiteDuLot,
582
599
  conformiteDuTri,
583
600
  lireFiche,
@@ -605,6 +622,7 @@ import { A_REPASSER } from './mesure/pression.mjs';
605
622
  import { departDe, leMemeVivant, ouvrirBase, vivant } from './mesure/base-de-passe.mjs';
606
623
  import { GREFFON } from './cadre.mjs';
607
624
  import { executerEnDemon } from './demon.mjs';
625
+ import { retirerLesCopiesDuDepot } from './copies-finies.mjs';
608
626
 
609
627
  // The time a session's transcripts may stand still before the circuit stops it.
610
628
  export const IMMOBILE_MS = 20 * 60 * 1000;
@@ -1273,7 +1291,7 @@ async function attendreLaSeance(ctx, groupe) {
1273
1291
  // developpeur's on a resumption, 4 the questionneur's on the plan, 5 the explorateur's on the plan,
1274
1292
  // 6 the explorateur's on the questions of the plan, 7 the explorateur's on the tri of the
1275
1293
  // discoveries), filled with <valeurs>.
1276
- function consigne(valeurs, rang = 0) {
1294
+ export function consigne(valeurs, rang = 0) {
1277
1295
  const texte = readFileSync(GABARIT, 'utf8');
1278
1296
  const bloc = [...texte.matchAll(/```text\n([\s\S]*?)\n```/g)][rang];
1279
1297
  if (!bloc) throw new Error(`gabarit sans bloc de consigne n° ${rang + 1} : ${GABARIT}`);
@@ -1289,23 +1307,24 @@ function consigne(valeurs, rang = 0) {
1289
1307
  // circuit keeps. A fresh session's instruction (the first
1290
1308
  // template) carries the ticket's description and notes as they are at its launch, the packages of
1291
1309
  // 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`).
1310
+ // carries the supervisor's context of the run at its head, as its task, and the findings of the
1311
+ // reviewer still open for its role (`ctx.constats`), all of them, whatever the relaunch: a proof
1312
+ // refused, red checks, a sending, a RENDU, a resumption of the supervisor (`constatsDeLaSeance`);
1313
+ // <change> says what changed on a resumption, when it is not the proof or the checks (the
1314
+ // integration's refusal of the lot, `refus`).
1297
1315
  // Throws an Arret for a launch that stops before its session, a motionless session, or
1298
1316
  // a session that ends twice without a sheet that conforms.
1299
1317
  async function seance(ctx, role, { tentative, rapport, fort, derniere, change }) {
1300
1318
  const nom = nomDuRole(role);
1301
1319
  const reprise = tentative > 1 && !derniere && ctx.reprise?.agent === role ? ctx.reprise : null;
1302
- const constats = texteDesOuverts(ouverts(ctx, role));
1320
+ const { tache, ouverts, constats, valider, repondre } = constatsDeLaSeance(
1321
+ ctx.contexte,
1322
+ ctx.constats,
1323
+ role
1324
+ );
1303
1325
  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
1326
  const repondu = fiche => {
1308
- if (fiche && titres.length) ctx.constats = avecLesReponses(ctx.constats, fiche);
1327
+ if (fiche) ctx.constats = repondre(ctx.constats, fiche);
1309
1328
  return fiche;
1310
1329
  };
1311
1330
  if (reprise) {
@@ -1321,6 +1340,8 @@ async function seance(ctx, role, { tentative, rapport, fort, derniere, change })
1321
1340
  ? 'la preuve du rouge, jouée après ta séance, refuse ton lot'
1322
1341
  : 'les contrôles, joués après ta séance, sont rouges'),
1323
1342
  rapport: rapport ?? 'aucun',
1343
+ tache,
1344
+ ouverts,
1324
1345
  constats,
1325
1346
  };
1326
1347
  const fiche = await jusquALaFiche(ctx, role, consigne(courte, 3), {
@@ -1355,13 +1376,14 @@ async function seance(ctx, role, { tentative, rapport, fort, derniere, change })
1355
1376
  lots: lots.length
1356
1377
  ? `${role === 'developpeur' ? 'le lot de tests' : 'tes tests'}, déjà dans la copie : ${lots.join(', ')}`
1357
1378
  : 'aucun',
1358
- contexte: contexteDe(ctx),
1379
+ tache,
1359
1380
  description: description.trim() || 'aucune',
1360
1381
  // The section of the ticket's notes, absent without notes.
1361
1382
  notes: notes.trim()
1362
1383
  ? `\nLES NOTES DU TICKET, l'état qu'un agent d'avant y a écrit :\n\n${notes.trim()}\n`
1363
1384
  : '',
1364
1385
  rapport: rapport ?? 'aucun',
1386
+ ouverts,
1365
1387
  constats,
1366
1388
  passation: passation?.text ?? 'aucune',
1367
1389
  references: lesReferences(ctx)
@@ -1371,11 +1393,58 @@ async function seance(ctx, role, { tentative, rapport, fort, derniere, change })
1371
1393
  return repondu(await jusquALaFiche(ctx, role, consigne(valeurs), { fort, neuve: role, valider }));
1372
1394
  }
1373
1395
 
1396
+ // The findings of the reviewer open for <role> among <constats>, as a session of the run whose
1397
+ // supervisor's context is <contexte> (`--contexte`, with `--depuis`, `--reprendre` or
1398
+ // `--etendre`) receives them, as a review its author relaunches on a change he frames keeps its
1399
+ // open threads in sight without blocking on them (BP 320.14.2.3: the context after the rule of
1400
+ // the answers, a session that worked an old finding only, its sheet refused, « sans-livraison »
1401
+ // twice). With a context, the context heads the instruction as its task (`tache`); the findings
1402
+ // open at the launch of the run (`enContexte`, `auLancement`) are its context, after the others
1403
+ // under their own heading, and a developpeur's sheet FAIT is not refused for want of an answer to
1404
+ // one of them; every other finding, without a context or stated by a RENDU within the run, is its
1405
+ // task, and his sheet FAIT answers each by its title, refused without one (`valider`,
1406
+ // `reponsesAuxConstats`). Either way, each answer a developpeur's sheet gives is kept with its
1407
+ // finding (`repondre`, `avecLesReponses`).
1408
+ export function constatsDeLaSeance(contexte, constats, role) {
1409
+ const siens = (constats ?? []).filter(c => c.role === role);
1410
+ const anciens = siens.filter(c => c.enContexte);
1411
+ const neufs = siens.filter(c => !c.enContexte);
1412
+ const titres = role === 'developpeur' ? neufs.map(c => c.titre) : [];
1413
+ 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`;
1414
+ const titre =
1415
+ 'LES CONSTATS DU RELECTEUR QUI RESTENT OUVERTS pour ton rôle, ' +
1416
+ (anciens.length && !neufs.length ? enContexte : "chacun jusqu'à la relecture qui le juge levé");
1417
+ const texte =
1418
+ anciens.length && neufs.length
1419
+ ? `${texteDesOuverts(neufs)}\n\nPUIS ${enContexte} :\n\n${texteDesOuverts(anciens, neufs.length)}`
1420
+ : texteDesOuverts(siens);
1421
+ return {
1422
+ tache: contexte
1423
+ ? `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`
1424
+ : '',
1425
+ ouverts: titre,
1426
+ constats: texte,
1427
+ valider: f => reponsesAuxConstats(f, titres),
1428
+ repondre: (tous, fiche) =>
1429
+ role === 'developpeur' && siens.length ? avecLesReponses(tous, fiche) : tous,
1430
+ };
1431
+ }
1432
+
1433
+ // The findings <constats> as a run launched with the supervisor's context <contexte> holds them:
1434
+ // each one open at its launch marked `enContexte`, as the threads already open when the author
1435
+ // relaunches a review on a change he frames; without a context, none. A finding a RENDU states
1436
+ // within the run comes without the mark (`constatsOuverts`), and is the session's task again.
1437
+ export const auLancement = (contexte, constats) =>
1438
+ (constats ?? []).map(c => {
1439
+ const { enContexte, ...reste } = c;
1440
+ return contexte ? { ...reste, enContexte: true } : reste;
1441
+ });
1442
+
1374
1443
  // The findings <constats>, each finding of the developpeur that his sheet <fiche> answers (by its
1375
- // title) with its answer `{ etat, raison, piece }`, as a thread of a review keeps the author's
1376
- // reply under its comment.
1444
+ // title, numbered or not: `cleDuConstat`) with its answer `{ etat, raison, piece }`, as a thread
1445
+ // of a review keeps the author's reply under its comment.
1377
1446
  function avecLesReponses(constats, fiche) {
1378
- const parTitre = new Map((fiche.reponses ?? []).map(r => [r.titre, r]));
1447
+ const parTitre = new Map((fiche.reponses ?? []).map(r => [cleDuConstat(r.titre), r]));
1379
1448
  return (constats ?? []).map(c => {
1380
1449
  const r = c.role === 'developpeur' ? parTitre.get(c.titre) : undefined;
1381
1450
  if (!r) return c;
@@ -1386,8 +1455,8 @@ function avecLesReponses(constats, fiche) {
1386
1455
  });
1387
1456
  }
1388
1457
 
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.
1458
+ // The line CONTEXTE of a reviewer's session: the text of `--contexte` of the run; « aucun »
1459
+ // without it.
1391
1460
  const contexteDe = ctx => ctx.contexte || 'aucun';
1392
1461
 
1393
1462
  // The launch <r> of a session of <role>, or the Arret it is: a session its lock stopped on a
@@ -1979,11 +2048,40 @@ function regenerer(ctx, noms, notes = [], avantLaPasse = false, refusAuLot = fal
1979
2048
  };
1980
2049
  }
1981
2050
 
2051
+ // The environment of a pass of the circuit (the proof, the checks, the final pass, a command of a
2052
+ // reference): <base>, the launcher's under the lock of the machine, with the tools of the project
2053
+ // (`ctx.outils`, `grillhouse.outils`, read at the launch) whatever <base> holds, then <env>.
2054
+ export const environnementDeLaPasse = (ctx, base, env = {}) => ({
2055
+ ...avecLesOutils(ctx.outils ?? {}, base),
2056
+ ...env,
2057
+ });
2058
+
2059
+ // The tools of the project whose main tree is <racine>, read at the launch of a run:
2060
+ // `{ outils }`, or `{ arret }`, the stop « lancement » that goes up to the supervisor before any
2061
+ // session (its code, name, report, piece and question), the faults of the key named.
2062
+ export function outilsAuLancement(racine) {
2063
+ try {
2064
+ return { outils: outilsDe(racine) };
2065
+ } catch (err) {
2066
+ const rapport = `La clé grillhouse.outils du package.json est refusée :\n${err.message}`;
2067
+ return {
2068
+ arret: {
2069
+ code: ARRETS.lancement,
2070
+ nom: 'lancement',
2071
+ rapport,
2072
+ piece: `$ npm pkg get grillhouse.outils\n${rapport}`,
2073
+ question: `${rapport}\nLa clé se corrige au package.json du projet, puis \`--reprendre\`.`,
2074
+ },
2075
+ };
2076
+ }
2077
+ }
2078
+
1982
2079
  // One command of a reference, run by the shell at the root of the copy, out of the envelope,
1983
2080
  // under the lock of the machine, its output added to the log: `{ code, panne, sortie }`, its exit
1984
2081
  // code, whether it failed for real, whatever it judges (the command not found or not executable,
1985
2082
  // 126, 127, as the shell says it; killed by a signal, the shell's 128 + its number; or the lock of
1986
- // the machine not taken), and what it wrote to the log.
2083
+ // the machine not taken), and what it wrote to the log. It runs in the environment of a pass
2084
+ // (`environnementDeLaPasse`).
1987
2085
  function commandeDeReference(ctx, commande) {
1988
2086
  entete(ctx, 'references');
1989
2087
  appendFileSync(ctx.journal, `$ ${commande}\n`);
@@ -1992,7 +2090,12 @@ function commandeDeReference(ctx, commande) {
1992
2090
  const fd = openSync(ctx.journal, 'a');
1993
2091
  try {
1994
2092
  const r = avecLaMachine(
1995
- env => spawnSync('sh', ['-c', commande], { cwd: ctx.copie, stdio: ['ignore', fd, fd], env }),
2093
+ env =>
2094
+ spawnSync('sh', ['-c', commande], {
2095
+ cwd: ctx.copie,
2096
+ stdio: ['ignore', fd, fd],
2097
+ env: environnementDeLaPasse(ctx, env),
2098
+ }),
1996
2099
  { racine: ctx.copie, dire: l => appendFileSync(ctx.journal, `${l}\n`) }
1997
2100
  );
1998
2101
  const code = r.status ?? 1;
@@ -2081,13 +2184,13 @@ function renvoiDe(ctx, fiche) {
2081
2184
  const ouverts = (ctx, role) => (ctx.constats ?? []).filter(c => c.role === role);
2082
2185
 
2083
2186
  // 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 =>
2187
+ // what it holds, its body and its piece, numbered after <avant>; « aucun » without one.
2188
+ const texteDesOuverts = (constats, avant = 0) =>
2086
2189
  constats.length
2087
2190
  ? constats
2088
2191
  .map(
2089
2192
  (c, i) =>
2090
- `### Constat ${i + 1} — ${c.titre}\nBloquant : ${c.regle}\n${c.corps}${c.piece ? `\nPièce : ${c.piece}` : ''}`
2193
+ `### Constat ${avant + i + 1} — ${c.titre}\nBloquant : ${c.regle}\n${c.corps}${c.piece ? `\nPièce : ${c.piece}` : ''}`
2091
2194
  )
2092
2195
  .join('\n\n')
2093
2196
  : 'aucun';
@@ -2096,11 +2199,12 @@ const texteDesOuverts = constats =>
2096
2199
  // review stay open until the review that resolves them: each blocking finding of the sheet (a
2097
2200
  // remark reaches the ticket, no agent; the sheet's schema gives a RENDU at least one), after each
2098
2201
  // 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
2202
+ // again, which keeps its mark `enContexte` (`auLancement`), a finding the sheet states coming
2203
+ // without it. Each one `{ titre, regle, role, corps, piece }`, its recipient the agent it names, testwriter or
2100
2204
  // developpeur, without the developpeur's answer to the review before (`reponse`): his next sheet
2101
2205
  // answers it again. Throws an Arret `relecture-arret` for a finding without a valid recipient or one
2102
2206
  // that puts a criterion in question.
2103
- function constatsOuverts(ctx, fiche, texte) {
2207
+ export function constatsOuverts(ctx, fiche, texte) {
2104
2208
  const arret = raison =>
2105
2209
  new Arret('relecture-arret', `${raison}\n\nLe verdict :\n\n${texte}`, { piece: raison });
2106
2210
  const neufs = bloquants(fiche).map(c => {
@@ -2113,13 +2217,35 @@ function constatsOuverts(ctx, fiche, texte) {
2113
2217
  }
2114
2218
  return { titre: c.titre, regle: c.regle, role: c.role, corps: c.corps, piece: c.piece };
2115
2219
  });
2116
- const leves = new Set((fiche.suivi ?? []).filter(s => s.etat === 'levé').map(s => s.titre));
2220
+ const leves = new Set(
2221
+ (fiche.suivi ?? []).filter(s => s.etat === 'levé').map(s => cleDuConstat(s.titre))
2222
+ );
2117
2223
  const restes = (ctx.constats ?? [])
2118
2224
  .filter(c => !leves.has(c.titre) && !neufs.some(n => n.titre === c.titre))
2119
2225
  .map(c => Object.fromEntries(Object.entries(c).filter(([k]) => k !== 'reponse')));
2120
2226
  return [...restes, ...neufs];
2121
2227
  }
2122
2228
 
2229
+ // The stop for the findings open in <ctx> that go to the testwriter when the plan skips him
2230
+ // (`sansTests`), or null: no new pass treats them, as a CI fails fast on a step it cannot run
2231
+ // (grillhouse-26x). An Arret `relecture-arret` whose report names each finding, the role skipped
2232
+ // and why, then the verdict <texte>; its piece, the findings' pieces; its question, declare the
2233
+ // tests of the package or settle the finding.
2234
+ export function arretDuTestwriterSaute(ctx, texte) {
2235
+ const auTestwriter = ouverts(ctx, 'testwriter');
2236
+ if (!auTestwriter.length || !sansTests(ctx)) return null;
2237
+ const titres = auTestwriter.map(c => `« ${c.titre} »`).join(', ');
2238
+ const plan = ctx.paquets.join(', ');
2239
+ return new Arret(
2240
+ 'relecture-arret',
2241
+ `Le relecteur adresse au testwriter ${titres}, quand le plan saute le testwriter : aucun paquet du plan ne joue de tests (${plan}).\n\nLe verdict :\n\n${texte}`,
2242
+ {
2243
+ piece: auTestwriter.map(c => c.piece ?? c.titre).join('\n'),
2244
+ question: `Le constat ${titres} va au testwriter, que le plan (${plan}) saute : déclarer les tests du paquet au cadre, puis \`--reprendre\`, ou trancher le constat (\`--depuis developpeur --contexte\`, ou \`--arreter\`).`,
2245
+ }
2246
+ );
2247
+ }
2248
+
2123
2249
  // The integration of the lot: its two patches, its message and the references that write files in
2124
2250
  // full (`--references`, from `lesReferences`, the one list), written from the copy, then
2125
2251
  // scripts/integration/integrer.mjs from the main tree, its output added to the log. A run « à
@@ -2184,18 +2310,35 @@ function integrer(ctx) {
2184
2310
  return r;
2185
2311
  }
2186
2312
 
2313
+ // The arguments of the queue at 5.2 for the ticket <ticket>, whether its branch is in the queue
2314
+ // (<enFile>) and its status in Beads (<statut>): none, the queue as it is, while the branch waits
2315
+ // in it or once the ticket is closed; `--ci <ticket>` for a branch out of the queue and a ticket
2316
+ // open, a red CI reopened it, which the queue reads again (`relireCI` of
2317
+ // scripts/integration/file.mjs), as a merge queue judges the last attempt of the checks.
2318
+ export const argumentsDeLaFile = ({ ticket, enFile, statut }) =>
2319
+ enFile || statut === 'closed' ? [] : ['--ci', ticket];
2320
+
2187
2321
  // The queue (scripts/integration/file.mjs), launched from the main tree and waited for, its output
2188
2322
  // added to the log; then the state it leaves to the ticket: `{ etat, raison }`, `etat` ferme (the
2189
2323
  // ticket closed, its branch on main and its CI read), en-file (the branch still in the queue, the
2190
2324
  // queue's reason) or rouvert (out of the queue, or a red CI, the queue's last comment). A queue
2191
- // already running exits 0 at once: it takes the branch, and the state is read at its end too.
2325
+ // already running exits 0 at once: it takes the branch, and the state is read at its end too. A
2326
+ // branch out of the queue with its ticket open (a red CI reopened it, then `--reprendre`) runs the
2327
+ // queue's reading of the CI again instead (`argumentsDeLaFile`).
2192
2328
  function file(ctx) {
2193
2329
  const motsDeLaFile = () => passations(ctx).filter(c => c.author === AUTEUR_DE_LA_FILE);
2194
2330
  const avant = motsDeLaFile().length;
2331
+ const branche = `agent/${ctx.ticket}`;
2332
+ const avantLaFile = ctx.bd('show', ctx.ticket, '--json');
2333
+ const args = argumentsDeLaFile({
2334
+ ticket: ctx.ticket,
2335
+ enFile: lireEntrees(ctx.racine).some(e => e.branche === branche),
2336
+ statut: avantLaFile.status === 0 ? (JSON.parse(avantLaFile.stdout)[0]?.status ?? null) : null,
2337
+ });
2195
2338
  entete(ctx, 'file');
2196
- appendFileSync(ctx.journal, `$ node ${FILE}\n`);
2339
+ appendFileSync(ctx.journal, `$ node ${[FILE, ...args].join(' ')}\n`);
2197
2340
  const x = avecAvancement(ctx, null, avancement =>
2198
- spawnSync(process.execPath, [FILE], {
2341
+ spawnSync(process.execPath, [FILE, ...args], {
2199
2342
  cwd: ctx.racine,
2200
2343
  encoding: 'utf8',
2201
2344
  maxBuffer: 256 * 1024 * 1024,
@@ -2203,7 +2346,6 @@ function file(ctx) {
2203
2346
  })
2204
2347
  );
2205
2348
  appendFileSync(ctx.journal, `${x.stdout ?? ''}${x.stderr ?? ''}`);
2206
- const branche = `agent/${ctx.ticket}`;
2207
2349
  // Another queue that runs takes the branch: the circuit waits for its end.
2208
2350
  while (lireEntrees(ctx.racine).some(e => e.branche === branche) && fileEnCours(ctx)) {
2209
2351
  attendreUnPeu(5_000);
@@ -2475,7 +2617,8 @@ function paquetDe(liste, fichier) {
2475
2617
  // (scripts/verrou-de-machine.mjs), its wait written to the log, and passes it to the
2476
2618
  // `npm run verifier` it runs. A wait that stops (its bound, 75; a lock held by an ancestor, 1) is
2477
2619
  // the command's code, its message in the log. Once it holds the lock, the pass plays under a
2478
- // progress directory of its own (`avancement`), of the kind `genreDeLaPasse` names.
2620
+ // progress directory of its own (`avancement`), of the kind `genreDeLaPasse` names. It plays in
2621
+ // the environment of a pass (`environnementDeLaPasse`).
2479
2622
  function npm(ctx, etape, args, env = {}) {
2480
2623
  entete(ctx, etape);
2481
2624
  const dossier = mkdtempSync(path.join(ctx.base.dossier, 'resultats-'));
@@ -2489,13 +2632,12 @@ function npm(ctx, etape, args, env = {}) {
2489
2632
  spawnSync('npm', args, {
2490
2633
  cwd: ctx.copie,
2491
2634
  stdio: ['ignore', fd, fd],
2492
- env: {
2493
- ...envMachine,
2635
+ env: environnementDeLaPasse(ctx, envMachine, {
2494
2636
  ...env,
2495
2637
  [RESULTATS]: dossier,
2496
2638
  [AVANCEMENT]: avancement,
2497
2639
  ...(args[0] === 'test' ? { [DEPUIS_LE_VERT]: '1' } : {}),
2498
- },
2640
+ }),
2499
2641
  })
2500
2642
  ),
2501
2643
  { racine: ctx.copie, dire: l => appendFileSync(ctx.journal, `${l}\n`) }
@@ -3600,6 +3742,8 @@ async function derouler(ctx, debut) {
3600
3742
  );
3601
3743
  }
3602
3744
  ctx.constats = constatsOuverts(ctx, v.fiche, v.texte);
3745
+ const saute = arretDuTestwriterSaute(ctx, v.texte);
3746
+ if (saute) throw saute;
3603
3747
  const auTestwriter = ouverts(ctx, 'testwriter').length > 0;
3604
3748
  etape = auTestwriter ? TESTS : CODE;
3605
3749
  tentative = 1;
@@ -3806,7 +3950,10 @@ function depart(ctx, e) {
3806
3950
  // (`montee`: its code, its stop and the supervisor's session that ran it, `superviseur`, when
3807
3951
  // Claude Code names it), from which the bilan measures the wait to the run that answers it, the
3808
3952
  // owner's when he writes in that session meanwhile, then the ticket's bilan at the ticket
3809
- // (scripts/bilan.mjs); a bilan it cannot write leaves the code as it is.
3953
+ // (scripts/bilan.mjs); a bilan it cannot write leaves the code as it is. Then the removal of the
3954
+ // finished copies of the repository (scripts/copies-finies.mjs), as a CI cleans its workspaces at
3955
+ // the end of each pipeline, not only the night's: its lines added to the log and written on the
3956
+ // error stream, each kept copy with the place it holds; it never changes the code.
3810
3957
  function aLaFin(ctx, code) {
3811
3958
  try {
3812
3959
  if (code !== 0) {
@@ -3825,6 +3972,15 @@ function aLaFin(ctx, code) {
3825
3972
  } catch (e) {
3826
3973
  process.stderr.write(`⚠️ bilan non écrit au ticket : ${e.message}\n`);
3827
3974
  }
3975
+ try {
3976
+ const lignes = retirerLesCopiesDuDepot(ctx.racine);
3977
+ if (lignes.length) {
3978
+ appendFileSync(ctx.journal, `${lignes.join('\n')}\n`);
3979
+ process.stderr.write(`${lignes.join('\n')}\n`);
3980
+ }
3981
+ } catch (e) {
3982
+ process.stderr.write(`⚠️ copies finies non retirées : ${e.message}\n`);
3983
+ }
3828
3984
  return code;
3829
3985
  }
3830
3986
 
@@ -4255,33 +4411,47 @@ async function arreter(ctx, e) {
4255
4411
  return 0;
4256
4412
  }
4257
4413
 
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
- );
4414
+ // The plan <paquets> of the repository at <base>, each a directory relative to it, extended by
4415
+ // <gagnes>: each one enters before the first package of the plan that reads it, as the module of
4416
+ // the language reads its components (`lecteurs` of the join, its `lit` and its `parLesTests`: the
4417
+ // imports of a package of TypeScript, its tests' included, the dependencies of a crate of cargo,
4418
+ // of development included), else at its end, as Pants asks the order of the targets of its
4419
+ // backends.
4420
+ export function ordonnerLePlan(base, paquets, gagnes) {
4421
+ const langage = langageDe(base);
4422
+ const composants = langage.composants(base);
4423
+ const { lit, parLesTests } = langage.lecteurs(base, {
4424
+ composants,
4425
+ noms: [],
4426
+ texte: '',
4427
+ nommes: [],
4428
+ });
4429
+ const de = d => composants.find(c => (path.relative(base, c.dossier) || '.') === d);
4430
+ const litLe = (lecteur, fournisseur) => {
4431
+ const l = de(lecteur);
4432
+ const f = de(fournisseur);
4433
+ return Boolean(l && f && (lit.get(l)?.has(f) || parLesTests.get(l)?.has(f)));
4279
4434
  };
4280
- const plan = [...ctx.paquets];
4435
+ const plan = [...paquets];
4281
4436
  for (const c of gagnes) {
4282
- const i = plan.findIndex(x => lit(x, c));
4437
+ const i = plan.findIndex(x => litLe(x, c));
4283
4438
  plan.splice(i < 0 ? plan.length : i, 0, c);
4284
4439
  }
4440
+ return plan;
4441
+ }
4442
+
4443
+ // The plan extended by the supervisor to the packages of `--etendre` (each a path or a package
4444
+ // name of the repository, else a Usage): each one enters the title in the order of
4445
+ // `ordonnerLePlan`, written by bd and said at the ticket. With the state <e>, the run then resumes
4446
+ // the step under way, as `--reprendre` does, the question of the stop and the text of
4447
+ // `--contexte` as the context of its sessions; a stop « sans-livraison » whose developpeur's last
4448
+ // sheet sends the red to the testwriter (`renvoi`, twice in a row) resumes at the step of the role
4449
+ // it names, the testwriter's, as a retry plays the job that failed. Without a state, it starts on
4450
+ // the plan extended. The state the run resumes from.
4451
+ function etendre(ctx, e) {
4452
+ const gagnes = [...new Set(ctx.etendre.map(ctx.resoudre))].filter(c => !ctx.paquets.includes(c));
4453
+ const base = existsSync(ctx.copie) ? ctx.copie : ctx.racine;
4454
+ const plan = ordonnerLePlan(base, ctx.paquets, gagnes);
4285
4455
  const titre = ecrireLePlan(ctx, plan);
4286
4456
  // The plan the supervisor extends has passed: it is written, questioned no more.
4287
4457
  inscrire(ctx, {
@@ -4334,6 +4504,9 @@ export async function main(argv) {
4334
4504
  throw new Usage(`--etendre : le lot de ${ctx.ticket} est intégré.`);
4335
4505
  e = etendre(ctx, e);
4336
4506
  }
4507
+ // The findings open at the launch of a run with the supervisor's context (`--contexte`, or the
4508
+ // question `--etendre` gives it) are its sessions' context; without one, their task.
4509
+ ctx.constats = auLancement(ctx.contexte, ctx.constats);
4337
4510
  // The supervisor's resumption of the questioning lets the plan pass as it is now.
4338
4511
  if (ctx.reprendre && e?.raison === 'questionnement') {
4339
4512
  commenter(
@@ -4366,6 +4539,11 @@ export async function main(argv) {
4366
4539
  })
4367
4540
  );
4368
4541
  }
4542
+ // The tools of the project, which every pass of the circuit plays with: a faulty key stops the
4543
+ // run before any session, by its name.
4544
+ const lancement = outilsAuLancement(ctx.racine);
4545
+ if (lancement.arret) return aLaFin(ctx, monter(ctx, { ...lancement.arret, etat: d }));
4546
+ ctx.outils = lancement.outils;
4369
4547
  // From the testwriter: the plan, which the explorateur writes and the questionneur reads once.
4370
4548
  if (d.etape === TESTS) {
4371
4549
  const arret = await lePlan(ctx);