@roomi-fields/grillhouse 0.30.0 → 0.31.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 (129) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +30 -0
  3. package/agents/developpeur.md +0 -1
  4. package/agents/explorateur.md +0 -1
  5. package/agents/questionneur.md +0 -1
  6. package/agents/testwriter.md +0 -1
  7. package/dist/temporal/circuit/client.d.ts +2 -2
  8. package/dist/temporal/circuit/client.js.map +1 -1
  9. package/dist/temporal/circuit/commande.js +4 -4
  10. package/dist/temporal/circuit/commande.js.map +1 -1
  11. package/dist/temporal/circuit/contrat.d.ts +3 -3
  12. package/dist/temporal/circuit/contrat.js +8 -2
  13. package/dist/temporal/circuit/contrat.js.map +1 -1
  14. package/dist/temporal/circuit/deroule.js +3 -3
  15. package/dist/temporal/circuit/deroule.js.map +1 -1
  16. package/dist/temporal/commande.js +5 -6
  17. package/dist/temporal/commande.js.map +1 -1
  18. package/dist/temporal/installation.d.ts +0 -4
  19. package/dist/temporal/installation.js +12 -34
  20. package/dist/temporal/installation.js.map +1 -1
  21. package/docs/ARCHITECTURE.md +49 -19
  22. package/docs/CADRE.md +10 -0
  23. package/docs/INTERFACE.md +8 -3
  24. package/package.json +2 -2
  25. package/scripts/activites.mjs +150 -77
  26. package/scripts/aiguillage.mjs +33 -11
  27. package/scripts/avancement.mjs +27 -10
  28. package/scripts/bilan.mjs +101 -25
  29. package/scripts/cadre.mjs +5 -2
  30. package/scripts/circuit.mjs +153 -57
  31. package/scripts/composants-affectes.mjs +64 -21
  32. package/scripts/composition-des-langages.mjs +5 -3
  33. package/scripts/conformite.mjs +54 -19
  34. package/scripts/dependances-internes.mjs +9 -3
  35. package/scripts/dernier-vert.mjs +54 -19
  36. package/scripts/dette.mjs +32 -11
  37. package/scripts/donnees-cles.mjs +24 -8
  38. package/scripts/droits.mjs +40 -15
  39. package/scripts/empreinte-d-etape.mjs +17 -0
  40. package/scripts/engendres.mjs +15 -5
  41. package/scripts/enveloppe/enveloppe.mjs +141 -48
  42. package/scripts/enveloppe/travail-de-la-copie.mjs +36 -12
  43. package/scripts/faits-du-circuit.mjs +1 -1
  44. package/scripts/flux-des-paquets.mjs +21 -7
  45. package/scripts/gardes-du-cadre.mjs +9 -3
  46. package/scripts/init.mjs +11 -4
  47. package/scripts/integration/file.mjs +84 -29
  48. package/scripts/integration/integrer.mjs +70 -24
  49. package/scripts/integration/rejeu.mjs +26 -9
  50. package/scripts/jointure.d.ts +6 -1
  51. package/scripts/langages/cargo/commandes.mjs +97 -18
  52. package/scripts/langages/cargo/composants.mjs +24 -8
  53. package/scripts/langages/cargo/index.mjs +4 -0
  54. package/scripts/langages/cargo/tests-de-head.mjs +25 -9
  55. package/scripts/langages/python/commandes.mjs +3 -1
  56. package/scripts/langages/python/index.mjs +4 -0
  57. package/scripts/langages/typescript/chemins-des-tests.mjs +6 -2
  58. package/scripts/langages/typescript/composants.mjs +9 -3
  59. package/scripts/langages/typescript/consommateurs-arbitres.mjs +40 -14
  60. package/scripts/langages/typescript/consommateurs.mjs +39 -14
  61. package/scripts/langages/typescript/elements-du-lot.mjs +36 -12
  62. package/scripts/langages/typescript/frontieres.mjs +66 -22
  63. package/scripts/langages/typescript/index-interfaces.mjs +36 -13
  64. package/scripts/langages/typescript/index.mjs +10 -3
  65. package/scripts/langages/typescript/interfaces-contre-code.mjs +109 -41
  66. package/scripts/langages/typescript/lecteurs.mjs +36 -11
  67. package/scripts/langages/typescript/migrations/0.23.0-config-vitest.mjs +15 -5
  68. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +6 -2
  69. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +6 -2
  70. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +3 -1
  71. package/scripts/langages/typescript/parcours.mjs +12 -4
  72. package/scripts/langages/typescript/regle-des-tests.mjs +9 -3
  73. package/scripts/langages/typescript/resumes.mjs +9 -3
  74. package/scripts/langages/typescript/tailles-des-tests.mjs +58 -16
  75. package/scripts/langages/typescript/tests-de-nuit.mjs +3 -1
  76. package/scripts/langages/typescript/tests.mjs +24 -8
  77. package/scripts/langages/typescript/titres-de-tests.mjs +35 -12
  78. package/scripts/langages/typescript/turbo-des-paquets.mjs +152 -51
  79. package/scripts/langages/typescript/verdict.mjs +3 -1
  80. package/scripts/langages/typescript/verifier.mjs +28 -10
  81. package/scripts/langages/typescript/vitest-config/avancement.reporter.mjs +15 -5
  82. package/scripts/langages/typescript/vitest-config/base.mjs +7 -2
  83. package/scripts/langages/typescript/vitest-config/changements.mjs +21 -8
  84. package/scripts/langages/typescript/vitest-config/delais.mjs +9 -3
  85. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +12 -4
  86. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +17 -6
  87. package/scripts/langages/typescript/vitest-config/lances.mjs +83 -27
  88. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +7 -0
  89. package/scripts/langages/typescript/vitest-config/resultats.mjs +3 -1
  90. package/scripts/lint-des-scripts.mjs +58 -0
  91. package/scripts/mesure/base-de-passe.mjs +117 -25
  92. package/scripts/mesure/pression.mjs +9 -3
  93. package/scripts/migrations/0.23.0-charte-importee.mjs +6 -2
  94. package/scripts/migrations/0.23.0-crochets-de-seance.mjs +25 -8
  95. package/scripts/migrations/0.23.0-marche-du-projet.mjs +18 -6
  96. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +48 -16
  97. package/scripts/migrations/0.24.12-tri-des-decouvertes.mjs +6 -2
  98. package/scripts/migrations/0.25.0-script-des-tests.mjs +15 -5
  99. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +6 -2
  100. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +7 -7
  101. package/scripts/nuit.sh +15 -0
  102. package/scripts/outil.mjs +3 -1
  103. package/scripts/outils-cles.mjs +18 -7
  104. package/scripts/paquet-npm.mjs +15 -5
  105. package/scripts/paquets.mjs +12 -4
  106. package/scripts/passe-de-la-machine.mjs +7 -2
  107. package/scripts/places-de-la-machine.mjs +66 -12
  108. package/scripts/preparation.mjs +15 -5
  109. package/scripts/registre.mjs +6 -2
  110. package/scripts/reprise.mjs +66 -0
  111. package/scripts/resultats.mjs +105 -37
  112. package/scripts/seances.mjs +22 -4
  113. package/scripts/services-du-noyau.mjs +1 -0
  114. package/scripts/sous-commandes.mjs +3 -1
  115. package/scripts/style-a-l-ecriture.mjs +48 -17
  116. package/scripts/tableau.mjs +34 -9
  117. package/scripts/taches-du-graphe.mjs +33 -13
  118. package/scripts/ticket-du-circuit.mjs +10 -0
  119. package/scripts/transitions.mjs +141 -24
  120. package/scripts/verrou-de-fichier.mjs +6 -2
  121. package/scripts/verrou-de-machine.mjs +123 -39
  122. package/scripts/verrous/commande.mjs +50 -17
  123. package/scripts/verrous/ticket-du-sous-agent.mjs +9 -3
  124. package/scripts/verrous/verrou.mjs +42 -14
  125. package/skills/explorateur/SKILL.md +7 -1
  126. package/skills/grill/SKILL.md +1 -1
  127. package/skills/mesure/SKILL.md +3 -0
  128. package/skills/relecteur/SKILL.md +1 -1
  129. package/skills/testwriter/SKILL.md +12 -6
@@ -14,7 +14,6 @@ import { createHash, randomUUID } from 'node:crypto';
14
14
  import {
15
15
  appendFileSync,
16
16
  closeSync,
17
- copyFileSync,
18
17
  cpSync,
19
18
  existsSync,
20
19
  mkdirSync,
@@ -31,6 +30,7 @@ import path from 'node:path';
31
30
  import { avecLAvancementDuTravail } from './avancement.mjs';
32
31
  import { A_REPASSER } from './codes-de-sortie.mjs';
33
32
  import { DEPUIS_LE_VERT } from './dernier-vert.mjs';
33
+ import { empreinteDEtape } from './empreinte-d-etape.mjs';
34
34
  import { FICHIER as DETTE } from './dette.mjs';
35
35
  import { commandesPermises, optionsDuRole } from './droits.mjs';
36
36
  import { couvertPar } from './engendres.mjs';
@@ -62,6 +62,7 @@ import { consigne, idDeSeance, jusquALaFiche } from './seances.mjs';
62
62
  import {
63
63
  Arret,
64
64
  AUTEUR_DU_CIRCUIT,
65
+ codeDejaPresent,
65
66
  commenter,
66
67
  composantsDe,
67
68
  entete,
@@ -83,7 +84,7 @@ import { AttenteDeLaMachine, nommerLAvancement } from './verrou-de-machine.mjs';
83
84
  import { avecLaMachineEtUnePlace } from './places-de-la-machine.mjs';
84
85
 
85
86
  const ici = import.meta.dirname;
86
- // The sessions out of the envelope (the reviewer on Opus, the explorateur and the questionneur on
87
+ // The sessions out of the envelope (the reviewer, the explorateur and the questionneur, all on
87
88
  // Sonnet), each in the
88
89
  // ticket's copy, the main tree once the integration removed it, under the rights and the context
89
90
  // of its role (scripts/droits.mjs: the commands its skill names, the refusal of a change of its
@@ -308,7 +309,7 @@ export async function relire(ctx, { constats = [] } = {}) {
308
309
  id: idDeSeance(ctx, 'relecture'),
309
310
  evenement: 'relecture',
310
311
  horsEnveloppe: true,
311
- droits: horsDeLEnveloppe(ctx, 'relecteur', 'opus'),
312
+ droits: horsDeLEnveloppe(ctx, 'relecteur', 'sonnet'),
312
313
  avec: lot ? { lot: { ...lot, fichiers: [...tests, ...code] } } : {},
313
314
  // Every review judges the findings still open, bounded or whole (`suiviDesConstats`).
314
315
  valider: f =>
@@ -392,22 +393,16 @@ function relectureDAvant(ctx) {
392
393
  return tient(e.lot.commit) && tient(e.lot.base) ? e : null;
393
394
  }
394
395
 
395
- // The tree of the copy as it stands, the copy's HEAD and index untouched: its index copied to a
396
- // file of the circuit's, every file of the copy added to that one (`git add -A`, the ignored files
397
- // left out), written as a tree. Its id, or null when git fails.
396
+ // The tree of the copy as it stands, the copy's HEAD and index untouched: a fresh index of the
397
+ // circuit's, read from HEAD (no stat cache, so git hashes every file's content and a file changed
398
+ // within the second of the index, the racy case, is never missed), every file of the copy added to
399
+ // it (`git add -A`, the ignored files left out), written as a tree. Its id, or null when git fails.
398
400
  export function arbreDeLaCopie(ctx) {
399
401
  const index = path.join(ctx.tmp, `index-${randomUUID().replaceAll('-', '')}`);
400
- const reel = spawnSync(
401
- 'git',
402
- ['-C', ctx.copie, 'rev-parse', '--path-format=absolute', '--git-path', 'index'],
403
- { encoding: 'utf8' }
404
- ).stdout?.trim();
405
402
  const env = { ...process.env, GIT_INDEX_FILE: index };
406
403
  const git = (...a) => spawnSync('git', ['-C', ctx.copie, ...a], { encoding: 'utf8', env });
407
404
  try {
408
- if (reel && existsSync(reel)) {
409
- copyFileSync(reel, index);
410
- } else if (git('read-tree', 'HEAD').status !== 0) {
405
+ if (git('read-tree', 'HEAD').status !== 0) {
411
406
  return null;
412
407
  }
413
408
  if (git('add', '-A').status !== 0) {
@@ -486,8 +481,8 @@ function leLotSurLaBase(ctx, lot) {
486
481
  // The lot of the copy kept against the review before: `{ avant, depuis, lot }`, that review
487
482
  // (`relectureDAvant`, null before any), the lot it read set on the copy's HEAD (`leLotSurLaBase`,
488
483
  // null when nothing bounds), and the copy kept as a lot on it (on HEAD without it). The bounded
489
- // review, its elements to judge again and the restricted final pass read the difference from
490
- // `depuis` to `lot`.
484
+ // review and its elements to judge again read the difference from `depuis` to `lot`; the final
485
+ // pass does not read it, it plays the band of the lot (`laPasseFinale`).
491
486
  export function leLotGarde(ctx) {
492
487
  const avant = relectureDAvant(ctx);
493
488
  const depuis = avant ? leLotSurLaBase(ctx, avant.lot) : null;
@@ -526,21 +521,19 @@ function differenceDesLots(ctx, avant, apres) {
526
521
  return r.status === 0 ? r.stdout.split('\0').filter(Boolean).sort() : [];
527
522
  }
528
523
 
529
- // The final pass the lot calls for: `{ arbre, restreinte }`, the tree of the copy, and, after a
530
- // review whose lot it no longer is the accepted one, the range Turborepo plays (`{ avant, apres }`:
531
- // the lot that review read set on the copy's HEAD, and the copy kept on it, `leLotGarde`), null
532
- // for the whole pass: before any review, on the lot the last review accepted (`leLotAccepte`, an
533
- // advance of the copy included), or when that lot does not replay on HEAD.
524
+ // The final pass the lot calls for: `{ arbre, restreinte }`, the tree of the copy and the band
525
+ // Turborepo plays (`{ avant, apres }`: the copy's HEAD, the base of the lot, and the copy kept as a
526
+ // commit on it), as Bazel and Nx `affected` play the reverse-dependency closure of a change: always
527
+ // the band of the lot, before any review, after one, on an accepted lot, main advanced or not,
528
+ // never the whole repository, which the night and the integration play. It throws, naming git,
529
+ // when git cannot keep the lot: a null band would be the whole repository.
534
530
  export function laPasseFinale(ctx) {
535
531
  const arbre = arbreDeLaCopie(ctx);
536
- if (!arbre || leLotAccepte(ctx, arbre)) {
537
- return { arbre, restreinte: null };
532
+ const lot = arbre ? garderLeLot(ctx, null) : null;
533
+ if (!arbre || !lot) {
534
+ throw new Error(`la passe finale ne peut borner le lot de ${ctx.ticket} : git ne le garde pas`);
538
535
  }
539
- const { depuis, lot } = leLotGarde(ctx);
540
- return {
541
- arbre,
542
- restreinte: depuis && lot ? { avant: depuis, apres: lot.commit } : null,
543
- };
536
+ return { arbre, restreinte: { avant: lot.base, apres: lot.commit } };
544
537
  }
545
538
 
546
539
  // The references of the circuit: those the project declares in the package.json of the copy
@@ -607,7 +600,7 @@ export function referencesDesRouges(ctx, lieux, aElaguer = false) {
607
600
  // follows (null when nothing changed: no pass plays again, and the reds stand); <suite>, the
608
601
  // regeneration the checks of the plan call for: `controles`, beside other reds, the checks of the
609
602
  // plan follow, on the regenerated tree; `passe`, without, the final pass that is due follows,
610
- // whole or since the last review; null after a final pass. A file a reference writes follows from the lot, as
603
+ // on the band of the lot; null after a final pass. A file a reference writes follows from the lot, as
611
604
  // the output of a genrule, without a word of the plan, and the reviewer reads its difference; a
612
605
  // file changed that none of the references run declares, or a command that fails (a reference of
613
606
  // the project at another code than 0, one of the frame on a real failure alone) restores the copy
@@ -839,11 +832,16 @@ function restaurer(ctx, commit, fichiers) {
839
832
  // The files of the lot that only the night plays (<misDeCote>, `separerLesFichiersDuJour`) are no
840
833
  // part of the proof: the red proves the behaviour the ticket develops, and a bench or a night test
841
834
  // is neither required red nor a cause of refusal. A lot whose only test files are those passes.
842
- export function preuveReussie({ fichiers, rouges, casses, nommes, misDeCote = 0 }, { inchange }) {
835
+ // With the code of the behaviour already in the copy (<codePresent>, `codeDejaPresent`), no test
836
+ // can turn red: the proof abstains the same way, a lot that holds a red keeps its verdict.
837
+ export function preuveReussie(
838
+ { fichiers, rouges, casses, nommes, misDeCote = 0 },
839
+ { inchange, codePresent = false }
840
+ ) {
843
841
  if (casses > 0) {
844
842
  return false;
845
843
  }
846
- if (inchange) {
844
+ if (inchange || codePresent) {
847
845
  return true;
848
846
  }
849
847
  if (nommes > 0) {
@@ -1623,9 +1621,11 @@ export const portentLeTravail = fiches =>
1623
1621
  // separator between its group and its title, a blank, or « > » as Vitest prints it, or « › » as
1624
1622
  // Jest and the report of the proof print it (`sansSeparateur`); the measure plays again only when
1625
1623
  // the copy changed (`mesureDeLaPreuve`).
1626
- export function preuve(ctx, { mesure: derniere = null } = {}) {
1624
+ export function preuve(ctx, { mesure: derniere = null, fichiers: seuls = null } = {}) {
1627
1625
  // Only the files of the day are proved; the ones only the night plays are put aside, named.
1628
- const { jour: fichiers, misDeCote } = separerLesFichiersDuJour(ctx, testsDuLot(ctx));
1626
+ // Resumed at a red (<seuls>, the files it names), the proof plays these files alone and passes
1627
+ // when they load: a test fixed is green, not red.
1628
+ const { jour: fichiers, misDeCote } = separerLesFichiersDuJour(ctx, seuls ?? testsDuLot(ctx));
1629
1629
  const portent = portentLeTravail(fichesDe(ctx, 'testwriter'));
1630
1630
  // Whether the sheet names the test <a> of the file <f>, by its full name or by its whole file.
1631
1631
  const nomme = (f, a) =>
@@ -1654,6 +1654,8 @@ export function preuve(ctx, { mesure: derniere = null } = {}) {
1654
1654
  }));
1655
1655
  // A plan « comportement inchangé »: every green of the lot is expected.
1656
1656
  const inchange = Boolean(ctx.sorte?.inchange);
1657
+ // The developpeur already ran after the last testwriter: the code is there, no test can turn red.
1658
+ const codePresent = codeDejaPresent(ctx);
1657
1659
  for (const { groupe, entier, avant, lus, arbres, code, resultats, constructions } of mesure) {
1658
1660
  for (const { nom, erreur } of constructions) {
1659
1661
  if (reportes.includes(nom)) {
@@ -1704,18 +1706,20 @@ export function preuve(ctx, { mesure: derniere = null } = {}) {
1704
1706
  }
1705
1707
  const section = (titre, l) =>
1706
1708
  l.length ? [`${titre} (${l.length}) :`, ...l.map(x => `- ${x}`), ''] : [];
1707
- const ok = preuveReussie(
1708
- {
1709
- fichiers: fichiers.length,
1710
- rouges: rouges.length,
1711
- casses: casses.length,
1712
- nommes: nommes.length,
1713
- nonNommes: nonNommes.length,
1714
- anciens,
1715
- misDeCote: misDeCote.length,
1716
- },
1717
- { inchange }
1718
- );
1709
+ const ok = seuls
1710
+ ? casses.length === 0
1711
+ : preuveReussie(
1712
+ {
1713
+ fichiers: fichiers.length,
1714
+ rouges: rouges.length,
1715
+ casses: casses.length,
1716
+ nommes: nommes.length,
1717
+ nonNommes: nonNommes.length,
1718
+ anciens,
1719
+ misDeCote: misDeCote.length,
1720
+ },
1721
+ { inchange, codePresent }
1722
+ );
1719
1723
  const resume = `${rouges.length} rouge(s), ${nommes.length} vert(s) nommé(s) qui portent le travail, ${nonNommes.length} vert(s) non nommé(s), ${casses.length} fichier(s) qui ne se charge(nt) pas, ${anciens} test(s) vert(s) que HEAD tient déjà, laissé(s) de côté`;
1720
1724
  const ecrit = (...sections) =>
1721
1725
  [
@@ -1724,14 +1728,16 @@ export function preuve(ctx, { mesure: derniere = null } = {}) {
1724
1728
  nom => `Les tests de ${nom} se jouent aux contrôles, après le développeur.`
1725
1729
  ),
1726
1730
  '',
1727
- ...(fichiers.length || rouges.length || misDeCote.length
1728
- ? []
1729
- : inchange
1730
- ? [
1731
- 'Aucun fichier de test du lot : le plan dit « comportement inchangé », rien à prouver.',
1732
- '',
1733
- ]
1734
- : ['Aucun fichier de test du lot dans le plan : rien ne prouve le rouge.', '']),
1731
+ ...(codePresent && !inchange && ok && rouges.length === 0
1732
+ ? ['Le code du développeur est déjà dans la copie : le rouge n’a rien à prouver.', '']
1733
+ : fichiers.length || rouges.length || misDeCote.length
1734
+ ? []
1735
+ : inchange
1736
+ ? [
1737
+ 'Aucun fichier de test du lot : le plan dit « comportement inchangé », rien à prouver.',
1738
+ '',
1739
+ ]
1740
+ : ['Aucun fichier de test du lot dans le plan : rien ne prouve le rouge.', '']),
1735
1741
  ...section('Rouges', rouges),
1736
1742
  ...sections,
1737
1743
  ...(nommes.length
@@ -1799,9 +1805,10 @@ const STYLE = new Set(['lint', 'format:check']);
1799
1805
 
1800
1806
  // Where <chemin> (from the root of the copy) lies: `{ dansLePlan, paquet, horsTitre }`, whether
1801
1807
  // a path of the plan holds it, the name of the package of <liste> that holds it, and that name
1802
- // again when the plan does not hold it.
1808
+ // again when the plan does not hold it. A red with no path (null) is in the plan when the plan
1809
+ // names « . », which holds the whole copy.
1803
1810
  function situer(ctx, liste, chemin) {
1804
- const dedans = Boolean(chemin) && dansLePlan(ctx, chemin);
1811
+ const dedans = chemin ? dansLePlan(ctx, chemin) : nommeLaRacine(ctx);
1805
1812
  const p = chemin ? liste.find(x => chemin.startsWith(`${x.dossier}/`)) : null;
1806
1813
  const paquet = p ? p.pkg.name : null;
1807
1814
  return { dansLePlan: dedans, paquet, horsTitre: dedans ? null : paquet };
@@ -1887,9 +1894,7 @@ function rougesDe(ctx, liste, c) {
1887
1894
  continue;
1888
1895
  }
1889
1896
  const p = liste.find(x => x.pkg.name === t.paquet);
1890
- const lieu = p
1891
- ? situer(ctx, liste, `${p.dossier}/`)
1892
- : { dansLePlan: false, paquet: null, horsTitre: null };
1897
+ const lieu = p ? situer(ctx, liste, `${p.dossier}/`) : situer(ctx, liste, null);
1893
1898
  const j = journalDeTache(ctx, t);
1894
1899
  out.push({
1895
1900
  texte:
@@ -1907,9 +1912,7 @@ function rougesDe(ctx, liste, c) {
1907
1912
  if (out.length === 0) {
1908
1913
  out.push({
1909
1914
  texte: `${ligneDeCommande(c)} rouge (code ${c.code}), sans résultat qui situe son rouge — le journal du ticket : ${ctx.journal}`,
1910
- dansLePlan: false,
1911
- paquet: null,
1912
- horsTitre: null,
1915
+ ...situer(ctx, liste, null),
1913
1916
  });
1914
1917
  }
1915
1918
  return { rouges: out, avertissements };
@@ -1939,17 +1942,27 @@ const ligneDeCommande = c =>
1939
1942
  // which their regeneration lifts before the checks judge the lot again, or before the final pass; `tous` every red as it was read; `notes`,
1940
1943
  // at the final pass, each key of the debt a guard wrote inscribed above what it finds, `{ garde,
1941
1944
  // fichier, regle, trouve }`.
1942
- export function controles(ctx, finale, restreinte = null, reportes = null) {
1945
+ export function controles(ctx, finale, restreinte = null, reportes = null, fichiers = null) {
1943
1946
  const liste = composantsDe(ctx.copie).filter(p => !p.hors);
1944
- const filtres = restreinte
1945
- ? ['--', `--filter=...[${restreinte.avant}...${restreinte.apres}]`, '--filter=//']
1946
- : [];
1947
+ // Resumed at a red in the test files <fichiers>: the final pass plays their packages alone (the
1948
+ // graph of packages of Turborepo, the root's tasks beside), the checks of the plan their tests
1949
+ // alone (Vitest plays what the files import) and the guards.
1950
+ const duReprise = fichiers
1951
+ ? [...new Set(fichiers.map(f => liste.find(p => f.startsWith(`${p.dossier}/`))?.pkg.name))]
1952
+ .filter(Boolean)
1953
+ .sort()
1954
+ : null;
1955
+ const filtres = duReprise
1956
+ ? ['--', ...duReprise.map(n => `--filter=${n}`), '--filter=//']
1957
+ : restreinte
1958
+ ? ['--', `--filter=...[${restreinte.avant}...${restreinte.apres}]`, '--filter=//']
1959
+ : [];
1947
1960
  const commandes =
1948
1961
  reportes && !reportes.rejouee
1949
1962
  ? []
1950
1963
  : finale
1951
1964
  ? [{ args: ['run', 'verifier', ...filtres] }]
1952
- : commandesDuPlan(ctx, liste);
1965
+ : commandesDuPlan(ctx, liste, fichiers);
1953
1966
  const resultats = commandes.map(({ args, env }) => {
1954
1967
  let r = npm(ctx, 'controles', args, env);
1955
1968
  // The 75 of verifier is final (its wait for the lock reached its bound); a command of the
@@ -2008,14 +2021,12 @@ export function controles(ctx, finale, restreinte = null, reportes = null) {
2008
2021
  ? ` ; laissés à la passe finale, ${laisses.length} rouge(s) hors du plan`
2009
2022
  : ''
2010
2023
  }`;
2011
- // Where the checks played: the final pass out of the envelope, on the whole copy or restricted
2012
- // to what changed since the last review; the checks of the plan, its tests and packages, its
2013
- // guards in its envelope.
2024
+ // Where the checks played: the final pass out of the envelope, on the band of the lot (its base
2025
+ // and its dependents); the checks of the plan, its tests and packages, its guards in its
2026
+ // envelope.
2014
2027
  const ou = !finale
2015
2028
  ? 'Contrôles du plan, ses tests et ses paquets, ses gardes dans son enveloppe'
2016
- : restreinte
2017
- ? "Contrôles de la passe finale, hors enveloppe, restreinte à ce que le lot change depuis la relecture d'avant et à ses dépendants"
2018
- : 'Contrôles de la passe finale, hors enveloppe, sur la copie entière';
2029
+ : 'Contrôles de la passe finale, hors enveloppe, sur la bande du lot (sa base et ses dépendants)';
2019
2030
  const ligne = r => [`- ${r.texte}`, ...(r.detail ? ['', r.detail, ''] : [])];
2020
2031
  const nomDuPaquet = r => r.paquet ?? 'hors des paquets';
2021
2032
  const journal = `Le journal du ticket, pour le détail des commandes : ${ctx.journal}`;
@@ -2088,15 +2099,20 @@ export function controles(ctx, finale, restreinte = null, reportes = null) {
2088
2099
  // plan and each the lot touches in it, `npm test -- <test files of the lot>` that none of them
2089
2100
  // holds (the shared test material's out of the plan), each test played once, then the guards in
2090
2101
  // the envelope of the plan, whose findings on its files alone count.
2091
- function commandesDuPlan(ctx, liste) {
2102
+ function commandesDuPlan(ctx, liste, seuls = null) {
2092
2103
  const lot = changements(ctx);
2093
2104
  const touches = liste.length
2094
2105
  ? [...new Set(lot.map(c => paquetDe(liste, c.fichier)).filter(d => d !== '.'))].sort()
2095
2106
  : ['.'];
2096
- const entiers = [
2097
- ...new Set([...touches.filter(d => dansLePlan(ctx, d)), ...paquetsDuPlan(ctx, liste)]),
2098
- ].sort();
2099
- const tests = testsDuLot(ctx).filter(f => !entiers.some(d => d === '.' || f.startsWith(`${d}/`)));
2107
+ // Resumed at a red (<seuls>, the test files it names): these tests alone, no package whole.
2108
+ const entiers = seuls
2109
+ ? []
2110
+ : [
2111
+ ...new Set([...touches.filter(d => dansLePlan(ctx, d)), ...paquetsDuPlan(ctx, liste)]),
2112
+ ].sort();
2113
+ const tests = (seuls ?? testsDuLot(ctx)).filter(
2114
+ f => !entiers.some(d => d === '.' || f.startsWith(`${d}/`))
2115
+ );
2100
2116
  const scripts = lireJson(path.join(ctx.copie, 'package.json'))?.scripts ?? {};
2101
2117
  const enveloppe = { [VARIABLE_ENVELOPPE]: ecrireLaListe(ctx.paquets) };
2102
2118
  return [
@@ -2176,6 +2192,63 @@ export function empreinte(ctx, chemins = ctx.paquets) {
2176
2192
  return h.digest('hex');
2177
2193
  }
2178
2194
 
2195
+ // The fingerprint of the step <etape> (`preuve`, `controles`, `passe-finale`) on the copy
2196
+ // (scripts/reprise.mjs `empreinteDEtape`): its command and the hashes of what it reads, each
2197
+ // package of the plan and its dependents by the hash of its test task in the plan of Turborepo
2198
+ // (`turbo run test:unit --filter=...<package> --dry=json`: the hash of the inputs of a task), the
2199
+ // files of the plan in the copy (`empreinte`), and the configuration at the root of the copy by
2200
+ // its content. Null when Turborepo does not give its plan: nothing is then read back.
2201
+ export function empreinteDeLEtape(ctx, etape) {
2202
+ const liste = composantsDe(ctx.copie).filter(p => !p.hors);
2203
+ const commande =
2204
+ etape === 'preuve'
2205
+ ? `preuve ${testsDuLot(ctx).join(' ')}`
2206
+ : etape === 'controles'
2207
+ ? JSON.stringify(commandesDuPlan(ctx, liste))
2208
+ : 'npm run verifier';
2209
+ const noms = liste
2210
+ .filter(p => dansLePlan(ctx, p.dossier))
2211
+ .map(p => p.pkg.name)
2212
+ .filter(Boolean)
2213
+ .sort();
2214
+ const empreintes = langageDe(ctx.copie).empreintes(ctx.copie, noms);
2215
+ if (!empreintes) {
2216
+ return null;
2217
+ }
2218
+ const hashes = { plan: empreinte(ctx), ...empreintes };
2219
+ const racine = createHash('sha256');
2220
+ for (const f of readdirSync(ctx.copie).sort()) {
2221
+ const chemin = path.join(ctx.copie, f);
2222
+ if (statSync(chemin, { throwIfNoEntry: false })?.isFile()) {
2223
+ racine.update(f).update(readFileSync(chemin));
2224
+ }
2225
+ }
2226
+ hashes['//'] = racine.digest('hex');
2227
+ return empreinteDEtape({ commande, hashes });
2228
+ }
2229
+
2230
+ // The test files and the files of code a red lies in (<lieux>, the places of the red as the
2231
+ // checks name them) that the testwriter and the developpeur carry (scripts/reprise.mjs
2232
+ // `attribuerLeRouge`): `{ tests, code }`. The testwriter carries the test files of the lot; the
2233
+ // developpeur, every other file of a path of the plan.
2234
+ export function portesDuRouge(ctx, lieux) {
2235
+ const dulot = new Set(
2236
+ changements(ctx)
2237
+ .filter(c => !c.supprime && duTestwriter(ctx, c.fichier))
2238
+ .map(c => c.fichier)
2239
+ );
2240
+ const nommes = [...new Set((lieux ?? []).map(l => l.fichier).filter(Boolean))];
2241
+ return {
2242
+ tests: nommes.filter(f => dulot.has(f)),
2243
+ code: nommes.filter(f => !dulot.has(f) && dansLePlan(ctx, f)),
2244
+ };
2245
+ }
2246
+
2247
+ // Whether the plan names `.`, which holds the whole copy.
2248
+ function nommeLaRacine(ctx) {
2249
+ return ctx.paquets.includes('.');
2250
+ }
2251
+
2179
2252
  // Whether a path of the plan holds <chemin> (relative to the copy), `.` holding every path.
2180
2253
  function dansLePlan(ctx, chemin) {
2181
2254
  return ctx.paquets.some(c => c === '.' || chemin === c || chemin.startsWith(`${c}/`));
@@ -148,7 +148,9 @@ export function versionDeLOutil(racine = process.cwd()) {
148
148
  return null;
149
149
  }
150
150
  const v = pkg?.grillhouse?.outil;
151
- if (v === undefined || v === null) return null;
151
+ if (v === undefined || v === null) {
152
+ return null;
153
+ }
152
154
  if (typeof v !== 'string' || !X_Y_Z.test(v)) {
153
155
  throw new Error(`la clé ${CLE} vaut ${JSON.stringify(v)}, pas une version x.y.z.`);
154
156
  }
@@ -167,12 +169,18 @@ export function aiguillage(
167
169
  nom,
168
170
  { racine = process.cwd(), cache = cacheDesOutils(), paquet = PAQUET_QUI_TOURNE } = {}
169
171
  ) {
170
- if (!REDIRIGEES.has(nom)) return null;
172
+ if (!REDIRIGEES.has(nom)) {
173
+ return null;
174
+ }
171
175
  const version = versionDeLOutil(racine);
172
- if (version === null) return null;
176
+ if (version === null) {
177
+ return null;
178
+ }
173
179
  const dossier = dossierDeLOutil(version, cache);
174
180
  const commande = commandeDans(dossier);
175
- if (realpath(paquet) === realpath(path.resolve(path.dirname(commande), '..'))) return null;
181
+ if (realpath(paquet) === realpath(path.resolve(path.dirname(commande), '..'))) {
182
+ return null;
183
+ }
176
184
  return { version, dossier, commande };
177
185
  }
178
186
 
@@ -206,7 +214,9 @@ export function echecDeLOutil(racine = process.cwd(), { cache = cacheDesOutils()
206
214
  } catch {
207
215
  return null;
208
216
  }
209
- if (version === null) return null;
217
+ if (version === null) {
218
+ return null;
219
+ }
210
220
  const f = fichierDEchec(version, cache);
211
221
  // A failure written after another launch installed the version: the version stands.
212
222
  if (existsSync(commandeDans(dossierDeLOutil(version, cache)))) {
@@ -228,7 +238,9 @@ function balayer(cache) {
228
238
  }
229
239
  for (const e of entrees) {
230
240
  const pid = Number(/\.installation-(\d+)$/.exec(e)?.[1]);
231
- if (pid && !vivant(pid)) rmSync(path.join(cache, e), { recursive: true, force: true });
241
+ if (pid && !vivant(pid)) {
242
+ rmSync(path.join(cache, e), { recursive: true, force: true });
243
+ }
232
244
  }
233
245
  }
234
246
 
@@ -250,7 +262,9 @@ function npmInstall(npm, prefixe, specs) {
250
262
  { stdio: ['ignore', 2, 'pipe'], encoding: 'utf8' }
251
263
  );
252
264
  process.stderr.write(r.stderr ?? '');
253
- if (r.status === 0) return;
265
+ if (r.status === 0) {
266
+ return;
267
+ }
254
268
  const ligne = String(r.stderr ?? '')
255
269
  .trim()
256
270
  .split('\n')
@@ -275,10 +289,14 @@ export function installer(
275
289
  { cache = cacheDesOutils(), npm = 'npm', retenue = RETENUE_MS } = {}
276
290
  ) {
277
291
  const dossier = dossierDeLOutil(version, cache);
278
- if (existsSync(commandeDans(dossier))) return { dossier, installe: false };
292
+ if (existsSync(commandeDans(dossier))) {
293
+ return { dossier, installe: false };
294
+ }
279
295
  const echec = fichierDEchec(version, cache);
280
296
  const garde = lireLEchec(echec);
281
- if (garde && Date.now() - Date.parse(garde.date) < retenue) throw new Error(garde.raison);
297
+ if (garde && Date.now() - Date.parse(garde.date) < retenue) {
298
+ throw new Error(garde.raison);
299
+ }
282
300
  mkdirSync(cache, { recursive: true });
283
301
  balayer(cache);
284
302
  const chantier = `${dossier}.installation-${process.pid}`;
@@ -291,7 +309,9 @@ export function installer(
291
309
  readFileSync(path.join(chantier, 'node_modules', NOM_DU_PAQUET, 'package.json'), 'utf8')
292
310
  );
293
311
  const pairs = Object.entries(pkg.peerDependencies ?? {}).map(([n, r]) => `${n}@${r}`);
294
- if (pairs.length) npmInstall(npm, chantier, pairs);
312
+ if (pairs.length) {
313
+ npmInstall(npm, chantier, pairs);
314
+ }
295
315
  if (!existsSync(commandeDans(chantier))) {
296
316
  throw new Error(`npm n'a pas posé la commande de ${NOM_DU_PAQUET}@${version}`);
297
317
  }
@@ -305,7 +325,9 @@ export function installer(
305
325
  renameSync(chantier, dossier);
306
326
  } catch (e) {
307
327
  // Another launch installed it meanwhile: its folder stands.
308
- if (!existsSync(commandeDans(dossier))) throw e;
328
+ if (!existsSync(commandeDans(dossier))) {
329
+ throw e;
330
+ }
309
331
  }
310
332
  return { dossier, installe: true };
311
333
  } finally {
@@ -105,7 +105,9 @@ export function ouvrirAvancement({ racine, genre = null, dans = tmpdir(), debut
105
105
  * @param {{ racine: string, taches: { hash: string, cache: boolean }[] }} o
106
106
  */
107
107
  export function inscrireLePlan(dossier, { racine, taches }) {
108
- if (!dossier || !taches.length) return;
108
+ if (!dossier || !taches.length) {
109
+ return;
110
+ }
109
111
  const { taches: connues } = lireLesTotaux(racine);
110
112
  try {
111
113
  for (const t of taches.filter(x => x.cache)) {
@@ -133,11 +135,16 @@ function enregistrements(dossier) {
133
135
  const sans = [];
134
136
  for (const f of lister(path.join(dossier, TACHES))) {
135
137
  const e = lireJson(path.join(dossier, TACHES, f));
136
- if (!e || !Number.isFinite(e.faits) || !Number.isFinite(e.prevus)) continue;
137
- if (!e.hash) sans.push(e);
138
- else {
138
+ if (!e || !Number.isFinite(e.faits) || !Number.isFinite(e.prevus)) {
139
+ continue;
140
+ }
141
+ if (!e.hash) {
142
+ sans.push(e);
143
+ } else {
139
144
  const avant = parHash.get(e.hash);
140
- if (!avant || (!e.cache && (avant.cache || e.a > avant.a))) parHash.set(e.hash, e);
145
+ if (!avant || (!e.cache && (avant.cache || e.a > avant.a))) {
146
+ parHash.set(e.hash, e);
147
+ }
141
148
  }
142
149
  }
143
150
  return [...parHash.values(), ...sans];
@@ -151,7 +158,9 @@ function enregistrements(dossier) {
151
158
  */
152
159
  export function lireAvancement(dossier) {
153
160
  const passe = lireJson(path.join(dossier, PASSE));
154
- if (!passe) return null;
161
+ if (!passe) {
162
+ return null;
163
+ }
155
164
  const liste = enregistrements(dossier);
156
165
  const faits = liste.reduce((s, e) => s + e.faits, 0);
157
166
  const demarres = liste.reduce((s, e) => s + e.prevus, 0);
@@ -274,17 +283,25 @@ export function avecLAvancementDuTravail(travail, { racine, genre, garder = () =
274
283
  */
275
284
  export function garderLeTotal(dossier) {
276
285
  const passe = lireJson(path.join(dossier, PASSE));
277
- if (!passe) return;
286
+ if (!passe) {
287
+ return;
288
+ }
278
289
  const t = totauxDe(passe.totaux ?? null);
279
- if (!t.fichier) return;
290
+ if (!t.fichier) {
291
+ return;
292
+ }
280
293
  const liste = enregistrements(dossier);
281
- if (passe.genre && liste.length) t.passes[passe.genre] = liste.reduce((s, e) => s + e.prevus, 0);
294
+ if (passe.genre && liste.length) {
295
+ t.passes[passe.genre] = liste.reduce((s, e) => s + e.prevus, 0);
296
+ }
282
297
  for (const e of liste.filter(x => x.hash && !x.cache)) {
283
298
  delete t.taches[e.hash];
284
299
  t.taches[e.hash] = e.prevus;
285
300
  }
286
301
  const cles = Object.keys(t.taches);
287
- for (const c of cles.slice(0, Math.max(0, cles.length - TACHES_GARDEES))) delete t.taches[c];
302
+ for (const c of cles.slice(0, Math.max(0, cles.length - TACHES_GARDEES))) {
303
+ delete t.taches[c];
304
+ }
288
305
  try {
289
306
  ecrireAtomique(t.fichier, { passes: t.passes, taches: t.taches });
290
307
  } catch {