@roomi-fields/grillhouse 0.24.13 → 0.24.14

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.
@@ -217,12 +217,23 @@
217
217
  // of its paths and the content of each file it lists, taken before and after the session; the
218
218
  // sheet and the handover do not count) has nothing to deliver, the gesture `rien-a-livrer`, as a
219
219
  // CI skips a job without object: the checks judge the lot; green, the run goes on; red, the
220
- // circuit stops at « sans-livraison », its report sending to the developpeur's handover.
220
+ // circuit stops at « sans-livraison », its report sending to the developpeur's handover. A
221
+ // developpeur that `--depuis developpeur` launches on the lot the integration refused (`refus`,
222
+ // the fingerprint of its plan), as a merge queue lets a lot it sends back pass again only with a
223
+ // change, a session that changes nothing does not go to the checks of the copy, which do not see
224
+ // that red: the developpeur is relaunched once with the refusal, then the
225
+ // circuit stops at « sans-livraison », the refusal as its piece (BP 320.37: three times FAIT
226
+ // without a file changed, the checks of the copy green, the integration red on the same lot).
221
227
  // - A sheet of the developpeur whose `renvoi` names the testwriter says the red that remains lies
222
228
  // in the tests of the lot: the gesture `renvoi-au-testwriter`, whether or not the session
223
- // changed a file: the testwriter, the sending and the handover as his report, then the proof
224
- // and the developpeur. The same sending twice in a row, with no green checks between them, stops
225
- // at « sans-livraison ».
229
+ // changed a file: the testwriter, the sending and the handover as his report, with the red
230
+ // output of the last checks when checks ran since his session, as a CI hands back the log of
231
+ // the check that fails, then the proof and the developpeur. The same sending twice in a row on
232
+ // the same red output of the checks (none, or the same), with no green checks between them,
233
+ // stops at « sans-livraison »: a round trip without a new fact; a sending on another red output
234
+ // relaunches the testwriter (BP 320.37: a first sending before any check, a second after checks
235
+ // that named the guard's line). That output is kept in the state (`controlesRouges`), so that a
236
+ // `--reprendre` or a `--depuis` keeps it.
226
237
  // - The checks after the developpeur judge the plan, as Bazel plays the targets of a change: `npm
227
238
  // test -- <package>` for each package of the plan, touched by the lot or not (a package without a
228
239
  // script `test:vitest` plays only when the lot touches it), `npm test -- <test files of the lot>`
@@ -379,7 +390,9 @@
379
390
  // `<type>(<paquets>): <sujet> (<ticket>)`, the type read from the ticket's type (bug fix,
380
391
  // chore, docs, else feat), its body written once from the final state: the criteria of the plan,
381
392
  // then each deviation the sheets of the developpeur and of the reviewer name (`ecarts`), once by
382
- // its subject, from the last sheet that carries it, with the trailer Co-Authored-By. It runs
393
+ // its subject, from the last sheet that carries it, with the trailer Co-Authored-By; and the
394
+ // references that write files in full (`--references`), which the integration regenerates on
395
+ // main of the moment instead of applying their files from the lot. It runs
383
396
  // scripts/integration/integrer.mjs from the main tree, its output added to the log: 0 is the
384
397
  // commit on agent/<ticket> (which the circuit names from git), the copy removed, the branch in
385
398
  // the queue; 75 (« à repasser ») plays it once more (`rejeu`), then stops at « a-repasser »; any
@@ -413,7 +426,7 @@
413
426
  // - The state is `.claude/worktrees/<ticket>.circuit.json`, written again at each step and at the
414
427
  // start and end of each session: `{ etape, tentative, code, raison, rapport, finale, boucles,
415
428
  // seance, question, questionnement, processus, depart, paquets, constats, verifie, mene, reprise,
416
- // journal }`; `processus` the process of the circuit that writes it, `depart` its start (field
429
+ // refus, journal }`; `processus` the process of the circuit that writes it, `depart` its start (field
417
430
  // 22 of /proc/<pid>/stat), which together name it, a number alone being reused; `questionnement` the work
418
431
  // on the plan under way (`{ objet, role, seance }`: the plan, the explorateur or the
419
432
  // questionneur, its session), null otherwise; `etape` is the state's name of a numbered step of
@@ -430,14 +443,23 @@
430
443
  // the session that runs, null between two; `verifie` the tree of the lot the last whole final
431
444
  // pass green played, null before; `mene` the start (an ISO date) of the step the circuit leads
432
445
  // itself while it runs, null otherwise; `reprise` the session of the testwriter or developpeur
433
- // its relaunches resume, `{ agent, seance }`, null before any.
446
+ // its relaunches resume, `{ agent, seance }`, null before any; `refus` the integration's refusal
447
+ // of the lot (`{ rapport, piece, empreinte, lance, relance }`: its output, its piece, the
448
+ // fingerprint of the plan refused, whether `--depuis developpeur` launched the developpeur on it,
449
+ // whether a session so launched left it unchanged once), null before any, once the integration
450
+ // accepts the lot, and on a run from the testwriter.
434
451
  // - `--reprendre` starts again at the step of the state, its report given to the next session,
435
452
  // after any stop, the death of the circuit included. A session the state names
436
453
  // that still runs is waited for first, and stopped when it stands still as long as a motionless
437
- // session. On a stop « questionnement », it lets the plan pass as it is then (the supervisor
454
+ // session. On a stop « integration », it plays the integration (or the queue) again on the same
455
+ // lot, as bors retries: a refusal can come from the load or from main (BP 320.16, 320.16.2). On
456
+ // a stop « questionnement », it lets the plan pass as it is then (the supervisor
438
457
  // changed it or kept it), from the testwriter.
439
458
  // - `--depuis <testwriter|developpeur>` has the lot corrected: it plays the whole ticket from
440
- // that step, the text of `--contexte` on the line CONTEXTE of each agent of the run, as a retry
459
+ // that step, the text of `--contexte` on the line CONTEXTE of each agent of the run (after a stop
460
+ // « integration », from the developpeur, the refusal as his report, the red to lift, as a merge
461
+ // queue sends the lot back to its author with the log of its check; from the testwriter, the
462
+ // refusal dropped), as a retry
441
463
  // of GitLab CI plays the jobs after it with the same variables: from the testwriter, his proof,
442
464
  // then the developpeur launched by a red of the proof as without `--depuis`; from the
443
465
  // developpeur, his checks; then the final pass, the reviewer and the integration. It goes with
@@ -484,9 +506,11 @@
484
506
  // (the third developpeur of the checks or of the final pass leaves a red check, a red of the
485
507
  // final pass out of the plan or that no package of the plan holds, or reds to settle),
486
508
  // 15 sans-livraison (a developpeur session that changes no file of the plan, its checks red; the
487
- // first session of a `--reprendre` whose plan already holds changes goes on to the checks; or
488
- // the developpeur's same sending to the testwriter twice in a row, no green checks between
489
- // them), 16 relecture-arret (a finding without a valid agent, one on a criterion, the third
509
+ // first session of a `--reprendre` whose plan already holds changes goes on to the checks; a
510
+ // second developpeur session that `--depuis developpeur` launched on the lot the integration
511
+ // refused and that changes nothing; or
512
+ // the developpeur's same sending to the testwriter twice in a row, on the same red output of the
513
+ // checks, no green checks between them), 16 relecture-arret (a finding without a valid agent, one on a criterion, the third
490
514
  // RENDU), 17 integration (the integration script refuses the lot, or the queue reopens the
491
515
  // ticket), 19 hors-portee (a testwriter or developpeur whose sheet says BLOQUÉ, without a
492
516
  // 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
@@ -564,7 +588,7 @@ import {
564
588
  } from './resultats.mjs';
565
589
  import { AUTEUR_DE_LA_FILE, INTEGRE } from './integration/file.mjs';
566
590
  import { dossierCommun, lireEntrees } from './integration/file-attente.mjs';
567
- import { refusArbitrage } from './integration/integrer.mjs';
591
+ import { couvertPar, refusArbitrage } from './integration/integrer.mjs';
568
592
  import { AUTEUR_DU_VERDICT } from './integration/verdict.mjs';
569
593
  import { attendreUnPeu } from './verrou-de-fichier.mjs';
570
594
  import { AttenteDeLaMachine, avecLaMachine } from './verrou-de-machine.mjs';
@@ -646,7 +670,11 @@ const generateur = (script, ...args) =>
646
670
  // gardes }`, `lit` the files of the copy it reads that another reference writes (as the
647
671
  // prerequisites of a rule of make: the index reads the interfaces, whose generated part the API
648
672
  // reports write), `gardes` the names the findings its regeneration lifts carry (their guard or
649
- // their rule).
673
+ // their rule), `entiers` the files of `fichiers` its command writes in full, which the integration
674
+ // does not apply from the lot but regenerates on main of the moment
675
+ // (scripts/integration/integrer.mjs): the index, the turbo.json of the packages (the root's is
676
+ // written in part); not the API reports, which read the build, nor the debt, which reads the notes
677
+ // of a pass.
650
678
  const REFERENCES_DU_CADRE = [
651
679
  {
652
680
  nom: "l'index des interfaces",
@@ -654,6 +682,7 @@ const REFERENCES_DU_CADRE = [
654
682
  fichiers: ['docs/agents/index-des-interfaces.md'],
655
683
  lit: ['docs/INTERFACE.md', '**/docs/INTERFACE.md'],
656
684
  gardes: ['index-interfaces'],
685
+ entiers: ['docs/agents/index-des-interfaces.md'],
657
686
  },
658
687
  {
659
688
  nom: 'les turbo.json des paquets',
@@ -661,6 +690,7 @@ const REFERENCES_DU_CADRE = [
661
690
  fichiers: ['turbo.json', 'turbo.jsonc', '**/turbo.json'],
662
691
  lit: [],
663
692
  gardes: ['turbo-des-paquets'],
693
+ entiers: ['*/**/turbo.json'],
664
694
  },
665
695
  {
666
696
  nom: "les rapports d'API",
@@ -673,6 +703,7 @@ const REFERENCES_DU_CADRE = [
673
703
  ],
674
704
  lit: [],
675
705
  gardes: ['rapport-api', 'partie-generee'],
706
+ entiers: [],
676
707
  },
677
708
  {
678
709
  nom: 'la dette des gardes',
@@ -680,6 +711,7 @@ const REFERENCES_DU_CADRE = [
680
711
  fichiers: [DETTE],
681
712
  lit: [],
682
713
  gardes: [],
714
+ entiers: [],
683
715
  abaisser: true,
684
716
  },
685
717
  ];
@@ -980,8 +1012,8 @@ function ecrireRapport(ctx, etape, texte, resultat, rapport = texte) {
980
1012
  }
981
1013
 
982
1014
  // The state of the run, written whole (`seance` and `question` null and `finale` false unless <etat>
983
- // sets them, `processus`, `paquets`, `constats`, `verifie`, `reprise` and `aRegenerer` the
984
- // run's), kept as the run's current state.
1015
+ // sets them, `processus`, `paquets`, `constats`, `verifie`, `reprise`, `aRegenerer`, `refus` and
1016
+ // `controlesRouges` the run's), kept as the run's current state.
985
1017
  function ecrireEtat(ctx, etat) {
986
1018
  ctx.courant = {
987
1019
  finale: false,
@@ -998,6 +1030,8 @@ function ecrireEtat(ctx, etat) {
998
1030
  verifie: ctx.verifie ?? null,
999
1031
  reprise: ctx.reprise ?? null,
1000
1032
  aRegenerer: ctx.aRegenerer ?? null,
1033
+ refus: ctx.refus ?? null,
1034
+ controlesRouges: ctx.controlesRouges ?? null,
1001
1035
  };
1002
1036
  const provisoire = `${ctx.etat}.${process.pid}`;
1003
1037
  writeFileSync(
@@ -1257,11 +1291,12 @@ function consigne(valeurs, rang = 0) {
1257
1291
  // the plan, and the last handover of its author at the ticket. Every instruction, fresh or resumed,
1258
1292
  // carries the findings of the reviewer still open for its role (`ctx.constats`), all of them,
1259
1293
  // whatever the relaunch: a proof refused, red checks, a sending, a RENDU, a resumption of the
1260
- // supervisor; a developpeur's sheet FAIT answers each of his by its title (`reponsesAuxConstats`),
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`),
1261
1296
  // refused without one, and the circuit keeps each answer with its finding (`avecLesReponses`).
1262
1297
  // Throws an Arret for a launch that stops before its session, a motionless session, or
1263
1298
  // a session that ends twice without a sheet that conforms.
1264
- async function seance(ctx, role, { tentative, rapport, fort, derniere }) {
1299
+ async function seance(ctx, role, { tentative, rapport, fort, derniere, change }) {
1265
1300
  const nom = nomDuRole(role);
1266
1301
  const reprise = tentative > 1 && !derniere && ctx.reprise?.agent === role ? ctx.reprise : null;
1267
1302
  const constats = texteDesOuverts(ouverts(ctx, role));
@@ -1281,9 +1316,10 @@ async function seance(ctx, role, { tentative, rapport, fort, derniere }) {
1281
1316
  paquets: plan,
1282
1317
  tentative,
1283
1318
  change:
1284
- role === 'testwriter'
1319
+ change ??
1320
+ (role === 'testwriter'
1285
1321
  ? 'la preuve du rouge, jouée après ta séance, refuse ton lot'
1286
- : 'les contrôles, joués après ta séance, sont rouges',
1322
+ : 'les contrôles, joués après ta séance, sont rouges'),
1287
1323
  rapport: rapport ?? 'aucun',
1288
1324
  constats,
1289
1325
  };
@@ -1771,9 +1807,9 @@ function laPasseFinale(ctx) {
1771
1807
 
1772
1808
  // The references of the circuit: those the project declares in the package.json of the copy
1773
1809
  // (`grillhouse.references`), each `{ nom, commande, fichiers, tests, lit, gardes }` with a name, a
1774
- // command and files, `tests`, `lit` and `gardes` arrays when given, empty when not; then the frame's
1775
- // (REFERENCES_DU_CADRE, `cadre`), each but one whose first file a reference of the project covers,
1776
- // which replaces it.
1810
+ // command and files, `tests`, `lit` and `gardes` arrays when given, empty when not, `entiers` empty;
1811
+ // then the frame's (REFERENCES_DU_CADRE, `cadre`), each but one whose first file a reference of the
1812
+ // project covers, which replaces it.
1777
1813
  function lesReferences(ctx) {
1778
1814
  const l = lireJson(path.join(existsSync(ctx.copie) ? ctx.copie : ctx.racine, 'package.json'))
1779
1815
  ?.grillhouse?.references;
@@ -1793,6 +1829,7 @@ function lesReferences(ctx) {
1793
1829
  tests: r.tests ?? [],
1794
1830
  lit: r.lit ?? [],
1795
1831
  gardes: r.gardes ?? [],
1832
+ entiers: [],
1796
1833
  cadre: false,
1797
1834
  }));
1798
1835
  const duCadre = REFERENCES_DU_CADRE.filter(
@@ -1801,16 +1838,6 @@ function lesReferences(ctx) {
1801
1838
  return [...duProjet, ...duCadre];
1802
1839
  }
1803
1840
 
1804
- // Whether one of <motifs> covers the file <fichier>, both from the root of the copy, as the
1805
- // inputs of Turborepo read them: a path names that file, a directory every file under it, a glob
1806
- // pattern (`*`, `**`) the files it matches (`path.matchesGlob` of Node).
1807
- export function couvertPar(motifs, fichier) {
1808
- return motifs.some(m => {
1809
- const dossier = m.replace(/\/+$/, '');
1810
- return fichier === dossier || fichier.startsWith(`${dossier}/`) || path.matchesGlob(fichier, m);
1811
- });
1812
- }
1813
-
1814
1841
  // The references a red of <lieux> is one of (each `{ fichier, gardes, dansLePlan }`, its file, the
1815
1842
  // names its finding carries, and whether a path of the plan holds it), however many other reds
1816
1843
  // stand beside it, as `--update-snapshots` updates the snapshots that fail and leaves the other
@@ -2035,12 +2062,17 @@ function arretHorsDuPlan(ctx, tentative, fiche) {
2035
2062
  }
2036
2063
 
2037
2064
  // The sending to the testwriter in the developpeur's sheet <fiche> (its `renvoi`): what the
2038
- // testwriter receives, the sending, then the developpeur's handover; null without a sending.
2065
+ // testwriter receives, the sending, the developpeur's handover, then the red output of the last
2066
+ // checks when checks ran since the testwriter's session (`ctx.controlesRouges`); null without a
2067
+ // sending.
2039
2068
  function renvoiDe(ctx, fiche) {
2040
2069
  if (!fiche.renvoi) return null;
2041
2070
  const passation = derniereDe(ctx, 'developpeur')?.text ?? 'aucune';
2042
2071
  const raison = fiche.raison ? ` : ${fiche.raison}` : '';
2043
- return `Le développeur renvoie le rouge qui reste aux tests du lot${raison}.\n\nSa passation :\n\n${passation}`;
2072
+ const controles = ctx.controlesRouges
2073
+ ? `\n\nLa sortie rouge des derniers contrôles :\n\n${ctx.controlesRouges}`
2074
+ : '';
2075
+ return `Le développeur renvoie le rouge qui reste aux tests du lot${raison}.\n\nSa passation :\n\n${passation}${controles}`;
2044
2076
  }
2045
2077
 
2046
2078
  // The findings of the reviewer still open for <role> (`ctx.constats`), in their order.
@@ -2086,7 +2118,8 @@ function constatsOuverts(ctx, fiche, texte) {
2086
2118
  return [...restes, ...neufs];
2087
2119
  }
2088
2120
 
2089
- // The integration of the lot: its two patches and its message, written from the copy, then
2121
+ // The integration of the lot: its two patches, its message and the references that write files in
2122
+ // full (`--references`, from `lesReferences`, the one list), written from the copy, then
2090
2123
  // scripts/integration/integrer.mjs from the main tree, its output added to the log. A run « à
2091
2124
  // repasser » (75) plays once more, the gesture `rejeu`. `{ code, sortie, args }`.
2092
2125
  function integrer(ctx) {
@@ -2115,6 +2148,20 @@ function integrer(ctx) {
2115
2148
  const message = path.join(ctx.tmp, 'message');
2116
2149
  writeFileSync(message, messageDeCommit(ctx));
2117
2150
  args.push('--message', message);
2151
+ const entieres = lesReferences(ctx)
2152
+ .filter(r => r.entiers.length)
2153
+ .map(({ nom, commande, fichiers, entiers, cadre }) => ({
2154
+ nom,
2155
+ commande,
2156
+ fichiers,
2157
+ entiers,
2158
+ cadre,
2159
+ }));
2160
+ if (entieres.length) {
2161
+ const f = path.join(ctx.tmp, 'references.json');
2162
+ writeFileSync(f, `${JSON.stringify(entieres)}\n`);
2163
+ args.push('--references', f);
2164
+ }
2118
2165
  let r;
2119
2166
  for (let essai = 1; essai <= 2; essai++) {
2120
2167
  entete(ctx, 'integration');
@@ -3121,6 +3168,8 @@ async function derouler(ctx, debut) {
3121
3168
  let { etape, tentative, rapport, finale } = debut;
3122
3169
  // The step a `--reprendre` starts at, the first of the loop.
3123
3170
  let reprise = Boolean(ctx.reprendre);
3171
+ // A developpeur relaunched on the integration's refusal of the lot he left unchanged.
3172
+ let relanceSurLeRefus = false;
3124
3173
  for (;;) {
3125
3174
  const reprend = reprise;
3126
3175
  reprise = false;
@@ -3160,6 +3209,8 @@ async function derouler(ctx, debut) {
3160
3209
  });
3161
3210
  // A testwriter who declares himself blocked or in need of an answer goes up to the supervisor.
3162
3211
  if (fiche.statut !== 'FAIT') throw arretDuStatut(ctx, 'testwriter', tentative, fiche);
3212
+ // No checks have run since this session.
3213
+ ctx.controlesRouges = null;
3163
3214
  commenter(ctx, 'testwriter', `séance ${tentative} finie, sa fiche lue.`);
3164
3215
  etape = PREUVE;
3165
3216
  } else if (etape === PREUVE) {
@@ -3197,7 +3248,9 @@ async function derouler(ctx, debut) {
3197
3248
  rapport,
3198
3249
  fort,
3199
3250
  derniere: fort,
3251
+ change: relanceSurLeRefus ? CHANGE_DU_REFUS : undefined,
3200
3252
  });
3253
+ relanceSurLeRefus = false;
3201
3254
  // A question goes up to the supervisor; a red out of reach, to the testwriter its sheet sends
3202
3255
  // it to, else up to the supervisor.
3203
3256
  if (fiche.statut === 'BESOIN') {
@@ -3207,17 +3260,20 @@ async function derouler(ctx, debut) {
3207
3260
  if (renvoi) {
3208
3261
  // The red that remains lies in the tests of the lot: the gesture `renvoi-au-testwriter`,
3209
3262
  // the testwriter, the sending and the handover as its report, then the proof and the
3210
- // developpeur.
3211
- if (ctx.renvoiAuTestwriter) {
3263
+ // developpeur. `renvoiAuTestwriter` keeps the red output of the checks the sending before
3264
+ // carried ('' for none), null after green checks: the same output twice in a row is a
3265
+ // round trip without a new fact.
3266
+ const sortie = ctx.controlesRouges ?? '';
3267
+ if (ctx.renvoiAuTestwriter === sortie) {
3212
3268
  if (empreinte(ctx) === avant) {
3213
3269
  inscrire(ctx, { role: AUTEUR_DU_CIRCUIT, etape: CODE, inchange: true });
3214
3270
  }
3215
3271
  throw new Arret(
3216
3272
  'sans-livraison',
3217
- `La fiche de la séance ${tentative} du développeur renvoie une deuxième fois de suite au testwriter, sans contrôles verts depuis le premier renvoi : le testwriter n'a pas levé ce rouge.\n\n${renvoi}`
3273
+ `La fiche de la séance ${tentative} du développeur renvoie une deuxième fois de suite au testwriter, sur la même sortie rouge des contrôles que le premier renvoi (aucune, ou la même), sans contrôles verts entre eux : le testwriter n'a pas levé ce rouge.\n\n${renvoi}`
3218
3274
  );
3219
3275
  }
3220
- ctx.renvoiAuTestwriter = true;
3276
+ ctx.renvoiAuTestwriter = sortie;
3221
3277
  commenter(
3222
3278
  ctx,
3223
3279
  'developpeur',
@@ -3235,6 +3291,30 @@ async function derouler(ctx, debut) {
3235
3291
  }
3236
3292
  if (fiche.hors_plan?.length) throw arretHorsDuPlan(ctx, tentative, fiche);
3237
3293
  const inchangee = empreinte(ctx) === avant;
3294
+ if (inchangee && ctx.refus?.lance && ctx.refus.empreinte === avant) {
3295
+ // The lot the integration refused, unchanged: as a merge queue lets a lot pass again only
3296
+ // with a change, neither the gesture `rien-a-livrer` nor the checks of the copy, which
3297
+ // the refusal does not see; the developpeur relaunched once with the refusal, then the
3298
+ // stop goes up.
3299
+ inscrire(ctx, { role: AUTEUR_DU_CIRCUIT, etape: CODE, inchange: true });
3300
+ if (ctx.refus.relance) {
3301
+ throw new Arret(
3302
+ 'sans-livraison',
3303
+ `La séance ${tentative} du développeur ne change aucun fichier du plan (${ctx.paquets.join(', ')}), une seconde fois sur le lot que l'intégration refuse.\n\n${ctx.refus.rapport}`,
3304
+ { piece: ctx.refus.piece }
3305
+ );
3306
+ }
3307
+ ctx.refus = { ...ctx.refus, relance: true };
3308
+ commenter(
3309
+ ctx,
3310
+ 'developpeur',
3311
+ `séance ${tentative}${fort ? ' (opus, effort high)' : ''} finie sans changement, sur le lot que l'intégration refuse : le circuit le relance une fois, le refus comme rapport.`
3312
+ );
3313
+ tentative++;
3314
+ rapport = rapportDuRefus(ctx.refus);
3315
+ relanceSurLeRefus = true;
3316
+ continue;
3317
+ }
3238
3318
  if (inchangee && reprend && livre(ctx)) {
3239
3319
  // A resumed developpeur that finds the lot delivered: the checks judge it.
3240
3320
  commenter(
@@ -3269,6 +3349,8 @@ async function derouler(ctx, debut) {
3269
3349
  ? { arbre: arbreDeLaCopie(ctx), restreinte: regeneration.restreinte }
3270
3350
  : laPasseFinale(ctx);
3271
3351
  const k = controles(ctx, passeFinale, passe.restreinte, regeneration?.reportes ?? null);
3352
+ // The output of these checks, red, which a sending to the testwriter carries.
3353
+ ctx.controlesRouges = k.rouge ? k.texte : null;
3272
3354
  // The outcome the bilan reads (scripts/bilan.mjs): with the reds, each its place and its
3273
3355
  // text, by which it knows two checks that measured the same thing.
3274
3356
  const resultat = issue => ({
@@ -3369,7 +3451,7 @@ async function derouler(ctx, debut) {
3369
3451
  resultat('vert'),
3370
3452
  `${k.resume}.${k.avertissements}`
3371
3453
  );
3372
- ctx.renvoiAuTestwriter = false;
3454
+ ctx.renvoiAuTestwriter = null;
3373
3455
  ctx.aRegenerer = {
3374
3456
  noms: k.references.map(r => r.nom),
3375
3457
  notes: [],
@@ -3387,7 +3469,7 @@ async function derouler(ctx, debut) {
3387
3469
  `${k.resume}.${k.avertissements}`
3388
3470
  );
3389
3471
  // Green checks: a sending of the developpeur to the testwriter may come again.
3390
- ctx.renvoiAuTestwriter = false;
3472
+ ctx.renvoiAuTestwriter = null;
3391
3473
  if (!passeFinale) {
3392
3474
  // The checks green: the final pass, its sessions counted apart.
3393
3475
  etape = CONTROLES;
@@ -3511,12 +3593,13 @@ async function derouler(ctx, debut) {
3511
3593
  const r = integrer(ctx);
3512
3594
  if (r.code === A_REPASSER) throw new Arret('a-repasser', fin(r.sortie, 40));
3513
3595
  if (r.code !== 0) {
3514
- throw new Arret(
3515
- 'integration',
3596
+ throw refuser(
3597
+ ctx,
3516
3598
  `Le script d'intégration refuse le lot (code ${r.code}).\n\n${fin(r.sortie, 60)}`,
3517
- { piece: `$ node ${INTEGRER} ${r.args.join(' ')}\n${fin(r.sortie, 30)}` }
3599
+ `$ node ${INTEGRER} ${r.args.join(' ')}\n${fin(r.sortie, 30)}`
3518
3600
  );
3519
3601
  }
3602
+ ctx.refus = null;
3520
3603
  const branche = `agent/${ctx.ticket}`;
3521
3604
  const commit = spawnSync('git', ['-C', ctx.racine, 'rev-parse', '--short', branche], {
3522
3605
  encoding: 'utf8',
@@ -3535,9 +3618,7 @@ async function derouler(ctx, debut) {
3535
3618
  continue;
3536
3619
  }
3537
3620
  if (f.etat === 'en-file') throw new Arret('a-repasser', f.raison);
3538
- throw new Arret('integration', `La file rouvre le ticket.\n\n${f.raison}`, {
3539
- piece: f.raison,
3540
- });
3621
+ throw refuser(ctx, `La file rouvre le ticket.\n\n${f.raison}`, f.raison);
3541
3622
  } else if (etape === TRI) {
3542
3623
  // The lot is on main: the tri of its discoveries, which neither stops nor undoes it.
3543
3624
  await trier(ctx);
@@ -3584,6 +3665,25 @@ async function derouler(ctx, debut) {
3584
3665
  }
3585
3666
  }
3586
3667
 
3668
+ // What changed for a developpeur relaunched on the integration's refusal of the lot he left as it was.
3669
+ const CHANGE_DU_REFUS =
3670
+ 'l’intégration refuse ton lot, et ta séance n’a changé aucun fichier du plan : son refus, dans le rapport ci-dessous, est le rouge à lever';
3671
+
3672
+ // The stop « integration » of the motive <rapport> and the piece <piece>, the refusal of the lot
3673
+ // kept in the state (`refus`: `{ rapport, piece, empreinte, lance, relance }`, the fingerprint of
3674
+ // the plan refused, whether a --depuis developpeur launched the developpeur on it, and whether a
3675
+ // session so launched already left it unchanged once), which --depuis developpeur gives the
3676
+ // developpeur.
3677
+ function refuser(ctx, rapport, piece) {
3678
+ ctx.refus = { rapport, piece, empreinte: empreinte(ctx), lance: false, relance: false };
3679
+ return new Arret('integration', rapport, { piece });
3680
+ }
3681
+
3682
+ // The developpeur's report on the integration's refusal <refus>: the red to lift, which the checks
3683
+ // of the copy, green, do not see.
3684
+ const rapportDuRefus = refus =>
3685
+ `L’intégration refuse ce lot : son refus, ci-dessous, est le rouge à lever ; les contrôles de ta copie, verts, ne le voient pas, et le lot ne repasse à l’intégration qu’avec un changement.\n\n${refus.rapport}`;
3686
+
3587
3687
  // The gesture <genre> of the circuit (scripts/etapes.mjs, GESTES), with no session: its line at
3588
3688
  // the ticket and in the log, with its rule.
3589
3689
  function geste(ctx, genre) {
@@ -3641,10 +3741,18 @@ async function conduire(ctx, d) {
3641
3741
  return monter(ctx, a);
3642
3742
  }
3643
3743
 
3644
- // Where the run starts: the step a --depuis names (the testwriter's or the developpeur's), the
3645
- // step of the state <e> (null without one) on --reprendre, else the testwriter, the run starting
3646
- // over.
3744
+ // Where the run starts: after a stop « integration », on --depuis developpeur, the developpeur,
3745
+ // the refusal (`refus`) as his report, the session so launched marked (`lance`), as a merge queue
3746
+ // sends the lot back to its author with the log of its check; else the step a --depuis names (the
3747
+ // testwriter's, which makes the lot again, the refusal dropped, or the developpeur's), the step of
3748
+ // the state <e> (null without one) on --reprendre, the integration or the queue played again on
3749
+ // the same lot after their stop, as bors retries, else the testwriter, the run starting over.
3647
3750
  function depart(ctx, e) {
3751
+ if (ctx.depuis === 'developpeur' && e?.raison === 'integration' && ctx.refus) {
3752
+ ctx.refus = { ...ctx.refus, lance: true, relance: false };
3753
+ return { etape: CODE, tentative: 1, rapport: rapportDuRefus(ctx.refus), finale: false };
3754
+ }
3755
+ if (ctx.depuis === 'testwriter') ctx.refus = null;
3648
3756
  if (ctx.depuis) {
3649
3757
  return {
3650
3758
  etape: ctx.depuis === 'testwriter' ? TESTS : CODE,
@@ -3654,9 +3762,11 @@ function depart(ctx, e) {
3654
3762
  };
3655
3763
  }
3656
3764
  if (!ctx.reprendre) {
3657
- // The run starts over: no lot verified, no finding of a review open.
3765
+ // The run starts over: no lot verified, no finding of a review open, no refusal, no checks played.
3658
3766
  ctx.verifie = null;
3659
3767
  ctx.constats = [];
3768
+ ctx.refus = null;
3769
+ ctx.controlesRouges = null;
3660
3770
  return { etape: TESTS, tentative: 1, rapport: null, finale: false };
3661
3771
  }
3662
3772
  if (!e) throw new Usage(`rien à reprendre : ${ctx.etat} n'existe pas.`);
@@ -4107,6 +4217,7 @@ async function arreter(ctx, e) {
4107
4217
  ctx.constats = [...(lu.constats ?? [])];
4108
4218
  ctx.verifie = lu.verifie ?? null;
4109
4219
  ctx.reprise = lu.reprise ?? null;
4220
+ ctx.refus = lu.refus ?? null;
4110
4221
  ecrireEtat(ctx, {
4111
4222
  etape: lu.etape,
4112
4223
  tentative: lu.tentative,
@@ -4178,11 +4289,14 @@ export async function main(argv) {
4178
4289
  mkdirSync(path.dirname(ctx.copie), { recursive: true });
4179
4290
  let e = existsSync(ctx.etat) ? JSON.parse(readFileSync(ctx.etat, 'utf8')) : null;
4180
4291
  // The findings of the reviewer still open, the lot the whole final pass verified, the session a
4181
- // relaunch resumes, and the references a regeneration has to run, kept from one run to the next.
4292
+ // relaunch resumes, the references a regeneration has to run, the integration's refusal of
4293
+ // the lot, and the red output of the last checks, kept from one run to the next.
4182
4294
  ctx.constats = [...(e?.constats ?? [])];
4183
4295
  ctx.verifie = e?.verifie ?? null;
4184
4296
  ctx.reprise = e?.reprise ?? null;
4185
4297
  ctx.aRegenerer = e?.aRegenerer ?? null;
4298
+ ctx.refus = e?.refus ?? null;
4299
+ ctx.controlesRouges = e?.controlesRouges ?? null;
4186
4300
  // The supervisor's answers to a question: stop the circuit, or extend its plan and resume.
4187
4301
  if (ctx.arreter) return await arreter(ctx, e);
4188
4302
  // A circuit that outlives its caller is still the ticket's: no second run beside it.
@@ -212,7 +212,7 @@ export const GESTES = [
212
212
  genre: 'rien-a-livrer',
213
213
  geste: 'aux contrôles, qui jugent le lot',
214
214
  regle:
215
- 'un développeur qui ne change aucun fichier du plan n’a rien à livrer quand les contrôles sont verts ; rouges, l’arrêt monte (sans-livraison)',
215
+ 'un développeur qui ne change aucun fichier du plan n’a rien à livrer quand les contrôles sont verts ; rouges, l’arrêt monte (sans-livraison) ; sur le lot que l’intégration refuse, pour un développeur que --depuis developpeur lance, le geste ne joue pas : il est relancé une fois avec le refus',
216
216
  cas: 'BP 320.9 : 995-tools n’a rien à livrer, 4 montées et 49 min (B5)',
217
217
  },
218
218
  ];
@@ -55,16 +55,26 @@
55
55
  // `node scripts/integration/gardes.mjs`); what remains is the project's own guards, which move to
56
56
  // `gardes` when the project has none (the report says so), else stay where nothing plays them
57
57
  // (the report names both); nothing remaining, the script goes.
58
+ // - The typing: each package of TypeScript (a `tsconfig.json`) that has no `typecheck` script
59
+ // receives the template's, `tsc -p tsconfig.json --noEmit` (its tsconfig.json types its sources
60
+ // and its tests, nothing emitted, as the template's does; its tsconfig.build.json builds), as a
61
+ // package of the examples of create-turbo types itself (`check-types`): each package of the frame
62
+ // in a project with `workspaces` (a package out of the frame is not touched, the root's
63
+ // `typecheck` stays the project's), the root in a project without. `npm run verifier` plays it,
64
+ // the task `typecheck` of Turborepo, which the generator keeps in the root's turbo.json
65
+ // (scripts/turbo-des-paquets.mjs). The report names the packages that received it. Witness:
66
+ // BPScript 320.21.4, whose type errors in test/ showed only at night.
58
67
  // - `turbo.json` is the project's own file, as every repository run by Turborepo writes its own. A
59
68
  // project with a `package.json` and no `turbo.json` receives the frame's template of its form:
60
69
  // `templates/turbo/paquets.json` when its `package.json` declares
61
70
  // `workspaces` (the tasks of each package, and the root's guards, `//#grillhouse:gardes` and
62
- // `//#gardes`; the tests live in the packages, the root has no `test:vitest`; the `build` of each
63
- // package is set by its own generated `turbo.json`, below), else
64
- // `templates/turbo/sans-paquets.json` (`build`, then the guards and the tests beside each other).
71
+ // `//#gardes`, and `typecheck`, after the build of each package and of its dependencies; the
72
+ // tests live in the packages, the root has no `test:vitest`; the `build` of each package is set by its own
73
+ // generated `turbo.json`, below), else `templates/turbo/sans-paquets.json` (`build`, then the
74
+ // guards, the tests and `typecheck` beside each other).
65
75
  // A `turbo.json` present is never written again by the update; only the generator of the
66
76
  // packages' turbo.json (below) writes in it the `dependsOn` of the guard tasks, and adds one it
67
- // lacks.
77
+ // lacks, and the typing task.
68
78
  // - The tools the frame's checks run as commands (dependency-cruiser, knip, Turborepo) are added
69
79
  // to the project's `devDependencies` at the version the template's `devDependencies` give; a
70
80
  // tool the project already declares in `dependencies`, `devDependencies` or
@@ -89,7 +99,7 @@
89
99
  // the range the template's package.json declares for `vitest`. Where the root resolves no Vitest or
90
100
  // another version, the project's scripts stay (the frame's included) and the report names the
91
101
  // version found and the range required. A `test` that runs anything else stays. The scripts of
92
- // the packages of a monorepo are not written.
102
+ // the packages of a monorepo are not written, but their `typecheck` (above).
93
103
  // - The frame's base configuration of Vitest is the package's (`@roomi-fields/grillhouse/vitest-config`,
94
104
  // scripts/vitest-config/), which each Vitest configuration imports by its name
95
105
  // (`import base from '@roomi-fields/grillhouse/vitest-config'`), as the examples of Turborepo
@@ -156,6 +166,7 @@ import { migrer, restesAuProjet } from './migrations.mjs';
156
166
  import { CODE, TESTS } from './frontieres.mjs';
157
167
  import { paquets } from './paquets.mjs';
158
168
  import { sources } from './sources.mjs';
169
+ import { TYPAGE } from './turbo-des-paquets.mjs';
159
170
 
160
171
  const SCRIPTS = {
161
172
  tableau: 'grillhouse tableau --texte',
@@ -328,6 +339,38 @@ function poserConfigVitest(projet, p) {
328
339
  return declarants.length > 0 ? { nom: PAQUET_DU_CADRE, paquets: declarants } : null;
329
340
  }
330
341
 
342
+ // Gives the typing script of the template, <script> (`tsc -p tsconfig.json --noEmit`: its
343
+ // tsconfig.json types its sources and its tests, nothing emitted), to each package of TypeScript
344
+ // (a `tsconfig.json`) of the project at <projet> (root package.json <p>) that has no `typecheck`:
345
+ // each package of the frame in a project of packages, written in its package.json (a package out
346
+ // of the frame is not touched, and the root's `typecheck` stays the project's); the root itself in
347
+ // a project without packages, set in <p>, which the caller writes. `npm run verifier` plays it, a
348
+ // task of Turborepo (scripts/turbo-des-paquets.mjs). Returns { script, paquets } (paquets: each
349
+ // package's directory, `.` for the root), or null when nothing changes.
350
+ function poserTypage(projet, p, script) {
351
+ if (typeof script !== 'string') return null;
352
+ const types = dossier => existsSync(path.join(projet, dossier, 'tsconfig.json'));
353
+ const sans = pkg => typeof pkg.scripts?.[TYPAGE] !== 'string';
354
+ const declarants = [];
355
+ if (p.workspaces === undefined) {
356
+ if (types('.') && sans(p)) {
357
+ p.scripts = { ...(p.scripts ?? {}), [TYPAGE]: script };
358
+ declarants.push('.');
359
+ }
360
+ } else {
361
+ for (const { dossier, pkg, hors } of paquets(projet)) {
362
+ if (hors || !types(dossier) || !sans(pkg)) continue;
363
+ pkg.scripts = { ...(pkg.scripts ?? {}), [TYPAGE]: script };
364
+ writeFileSync(
365
+ path.join(projet, dossier, 'package.json'),
366
+ `${JSON.stringify(pkg, null, 2)}\n`
367
+ );
368
+ declarants.push(dossier);
369
+ }
370
+ }
371
+ return declarants.length > 0 ? { script, paquets: declarants } : null;
372
+ }
373
+
331
374
  // Writes the frame's status line in the settings of the project at <projet>, when they exist and
332
375
  // hold none or the frame's (see the header); their other keys keep their order. Returns whether
333
376
  // they changed.
@@ -386,6 +429,7 @@ export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
386
429
  turbo: null,
387
430
  configVitest: null,
388
431
  dependanceDuCadre: null,
432
+ typage: null,
389
433
  gardes: null,
390
434
  ligneEtat: false,
391
435
  greffon: false,
@@ -486,6 +530,7 @@ export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
486
530
  }
487
531
  bilan.dependanceDuCadre = declarerDependanceDuCadre(projet, p);
488
532
  bilan.configVitest = poserConfigVitest(projet, p);
533
+ bilan.typage = poserTypage(projet, p, pkgSource.scripts?.[TYPAGE]);
489
534
  writeFileSync(pkg, `${JSON.stringify(p, null, 2)}\n`);
490
535
  }
491
536
  bilan.turbo = poserTurbo(projet, source);
@@ -550,6 +595,11 @@ export function rapport(b) {
550
595
  `Dépendance d'exécution : ${nom} déclaré dans les dependencies de ${declarants.join(', ')}, dont le code hors des tests importe une entrée du paquet. \`npm install\` relie le paquet.`
551
596
  );
552
597
  }
598
+ if (b.typage) {
599
+ lignes.push(
600
+ `Typage : \`${b.typage.script}\` écrit dans ${b.typage.paquets.join(', ')} (le script typecheck, ses sources et ses tests, que son tsconfig.json inclut) ; \`npm run verifier\` le joue à côté des gardes et des tests.`
601
+ );
602
+ }
553
603
  if (b.turbo) {
554
604
  lignes.push(
555
605
  `turbo.json écrit depuis le gabarit du cadre ${b.turbo} ; il est au projet, la mise à jour n'y touche plus.`