@roomi-fields/grillhouse 0.50.3 → 0.52.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 (150) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +68 -0
  3. package/agents/developpeur.md +1 -1
  4. package/agents/direct.md +1 -1
  5. package/agents/explorateur.md +1 -1
  6. package/agents/questionneur.md +1 -1
  7. package/agents/relecteur.md +1 -1
  8. package/agents/testwriter.md +1 -1
  9. package/cadre/templates/c/package.json +1 -0
  10. package/cadre/templates/cargo/package.json +1 -0
  11. package/cadre/templates/python/package.json +1 -0
  12. package/charte/plan.md +47 -0
  13. package/charte/preuve.md +39 -0
  14. package/charte/superviseur.md +61 -0
  15. package/charte/tests.md +38 -0
  16. package/charte.md +39 -189
  17. package/dist/machine/part-par-sorte.d.ts +16 -0
  18. package/dist/machine/part-par-sorte.js +36 -0
  19. package/dist/machine/part-par-sorte.js.map +1 -0
  20. package/dist/temporal/circuit/appel.js +1 -1
  21. package/dist/temporal/circuit/appel.js.map +1 -1
  22. package/dist/temporal/circuit/client.d.ts +4 -4
  23. package/dist/temporal/circuit/client.js +38 -16
  24. package/dist/temporal/circuit/client.js.map +1 -1
  25. package/dist/temporal/circuit/contrat.d.ts +11 -7
  26. package/dist/temporal/circuit/contrat.js +5 -9
  27. package/dist/temporal/circuit/contrat.js.map +1 -1
  28. package/dist/temporal/circuit/deroule.js +18 -6
  29. package/dist/temporal/circuit/deroule.js.map +1 -1
  30. package/dist/temporal/commande.js +12 -3
  31. package/dist/temporal/commande.js.map +1 -1
  32. package/dist/temporal/installation.d.ts +54 -3
  33. package/dist/temporal/installation.js +187 -17
  34. package/dist/temporal/installation.js.map +1 -1
  35. package/dist/temporal/places/client.d.ts +5 -1
  36. package/dist/temporal/places/client.js +23 -11
  37. package/dist/temporal/places/client.js.map +1 -1
  38. package/docs/ARCHITECTURE.md +23 -2700
  39. package/docs/INTERFACE.md +26 -10
  40. package/docs/architecture/circuit.md +61 -14
  41. package/docs/architecture/entree.md +21 -8
  42. package/docs/architecture/greffon.md +49 -20
  43. package/docs/architecture/installation.md +46 -17
  44. package/docs/architecture/machine.md +79 -39
  45. package/docs/architecture/tests.md +59 -16
  46. package/docs/lexique.md +163 -0
  47. package/hooks/hooks.json +0 -10
  48. package/hooks/register.tsx +92 -4
  49. package/package.json +2 -1
  50. package/scripts/activites.mjs +105 -65
  51. package/scripts/aiguillage.mjs +15 -8
  52. package/scripts/attente-au-tour.mjs +2 -3
  53. package/scripts/attente-de-la-machine.mjs +4 -8
  54. package/scripts/avancement.mjs +12 -8
  55. package/scripts/bilan.mjs +126 -63
  56. package/scripts/bilans-gardes.mjs +37 -0
  57. package/scripts/branche-de-nuit.mjs +2 -2
  58. package/scripts/ci-de-main.mjs +18 -21
  59. package/scripts/circuit.mjs +89 -44
  60. package/scripts/circuits-du-serveur.mjs +5 -5
  61. package/scripts/composants-affectes.mjs +30 -12
  62. package/scripts/composition-des-langages.mjs +5 -3
  63. package/scripts/conformite.mjs +1 -1
  64. package/scripts/consommation-des-passes.mjs +8 -6
  65. package/scripts/copies-finies.mjs +3 -14
  66. package/scripts/depart-du-ticket.d.mts +8 -2
  67. package/scripts/depart-du-ticket.mjs +26 -8
  68. package/scripts/direct.mjs +158 -72
  69. package/scripts/droits.mjs +165 -208
  70. package/scripts/engendres.mjs +3 -14
  71. package/scripts/entree-de-seance.mjs +35 -0
  72. package/scripts/enveloppe/enveloppe.mjs +98 -46
  73. package/scripts/enveloppe/lancer.sh +90 -66
  74. package/scripts/enveloppe/paquets-du-plan.mjs +38 -11
  75. package/scripts/enveloppe/travail-de-la-copie.mjs +192 -3
  76. package/scripts/etapes.mjs +84 -22
  77. package/scripts/faits-du-circuit.mjs +8 -2
  78. package/scripts/grillhouse-maj.mjs +43 -18
  79. package/scripts/groupe-cles.d.mts +15 -0
  80. package/scripts/groupe-cles.mjs +77 -2
  81. package/scripts/init.mjs +9 -2
  82. package/scripts/integration/rejeu.mjs +8 -1
  83. package/scripts/jointure.d.ts +24 -4
  84. package/scripts/langages/c/index.mjs +5 -2
  85. package/scripts/langages/cargo/commandes.mjs +35 -15
  86. package/scripts/langages/cargo/composants.mjs +45 -3
  87. package/scripts/langages/cargo/index.mjs +6 -3
  88. package/scripts/langages/python/commandes.mjs +50 -7
  89. package/scripts/langages/python/index.mjs +5 -2
  90. package/scripts/langages/python/squelette.mjs +2 -1
  91. package/scripts/langages/typescript/chemins-des-tests.mjs +1 -1
  92. package/scripts/langages/typescript/index.mjs +16 -14
  93. package/scripts/langages/typescript/mise-a-jour.mjs +1 -1
  94. package/scripts/langages/typescript/rapports-aux-lignes.mjs +74 -0
  95. package/scripts/langages/typescript/turbo-des-paquets.mjs +151 -38
  96. package/scripts/langages/typescript/verdict.mjs +29 -3
  97. package/scripts/langages/typescript/verifier.mjs +28 -3
  98. package/scripts/langages/typescript/vitest-config/changements.mjs +8 -6
  99. package/scripts/langages/typescript/vitest-config/lances.mjs +15 -32
  100. package/scripts/langages.mjs +54 -4
  101. package/scripts/matieres-lues.mjs +1 -1
  102. package/scripts/mesure/base-de-passe.mjs +32 -90
  103. package/scripts/migrations/serveurs-de-l-index.mjs +79 -0
  104. package/scripts/migrations/suivi-du-superviseur-retire.mjs +56 -0
  105. package/scripts/migrations.mjs +23 -7
  106. package/scripts/nuit.sh +3 -2
  107. package/scripts/paquet.mjs +1 -1
  108. package/scripts/paquets.d.ts +3 -0
  109. package/scripts/paquets.mjs +88 -1
  110. package/scripts/passe-de-la-machine.mjs +109 -36
  111. package/scripts/places-de-la-machine.mjs +81 -29
  112. package/scripts/plafond-de-la-machine.d.mts +2 -5
  113. package/scripts/plafond-de-la-machine.mjs +9 -9
  114. package/scripts/reprise.mjs +42 -13
  115. package/scripts/resultats.mjs +78 -56
  116. package/scripts/retirer-les-copies-finies.mjs +1 -1
  117. package/scripts/seances.mjs +471 -133
  118. package/scripts/services-du-noyau.mjs +9 -1
  119. package/scripts/session-start.sh +22 -7
  120. package/scripts/sortie-de-seance.mjs +70 -0
  121. package/scripts/sortie.mjs +37 -6
  122. package/scripts/sous-commandes.mjs +0 -3
  123. package/scripts/superviseur.mjs +400 -162
  124. package/scripts/tableau.mjs +188 -65
  125. package/scripts/transitions.d.mts +25 -2
  126. package/scripts/transitions.mjs +137 -29
  127. package/scripts/verrous/ecriture-hors-enveloppe.mjs +31 -9
  128. package/skills/codebase-design/DESIGN-IT-TWICE.md +1 -1
  129. package/skills/developpeur/SKILL.md +38 -15
  130. package/skills/direct/SKILL.md +29 -9
  131. package/skills/domain-modeling/GLOSSARY-FORMAT.md +9 -9
  132. package/skills/domain-modeling/SKILL.md +14 -12
  133. package/skills/explorateur/SKILL.md +32 -8
  134. package/skills/grill/SKILL.md +3 -2
  135. package/skills/pitmaster/SKILL.md +80 -50
  136. package/skills/pitmaster/references/cadre.md +1 -1
  137. package/skills/pitmaster/references/consigne-agent.md +12 -11
  138. package/skills/pitmaster/references/tour.md +6 -5
  139. package/skills/relecteur/SKILL.md +13 -6
  140. package/skills/systematic-debugging/SKILL.md +281 -0
  141. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  142. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  143. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  144. package/skills/systematic-debugging/find-polluter.sh +72 -0
  145. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  146. package/skills/testwriter/SKILL.md +37 -31
  147. package/cadre/templates/projet/pitmaster/SUIVI.md +0 -22
  148. package/scripts/attente-a-l-arret.mjs +0 -114
  149. package/scripts/verrous/commande.mjs +0 -214
  150. package/scripts/verrous/verrou.mjs +0 -311
@@ -42,11 +42,12 @@
42
42
  // "traces": { "trace:grammaires": { "lit": ["…/paires-v1"], "ecrit": "packages/060-encoder/trace/grammaires-du-corpus" } }
43
43
  // }
44
44
  //
45
- // - `lit`: the paths its tests read, directories or files, data or code. Its `test:unit` hashes
46
- // them (`inputs`: the root's, `$TURBO_EXTENDS$`, or `$TURBO_DEFAULT$` when the root's task sets
47
- // none; then `$TURBO_ROOT$/<dir>/**` each) and waits, beside the root's `dependsOn`, for each
45
+ // - `lit`: the paths its tests read, directories, files or glob patterns, data or code. Its
46
+ // `test:unit` hashes them (`inputs`: the root's, `$TURBO_EXTENDS$`, or `$TURBO_DEFAULT$` when
47
+ // the root's task sets none; then `$TURBO_ROOT$/<dir>/**` per directory, a file or a pattern as
48
+ // is, a path strictly inside a trace's output both ways) and waits, beside the root's `dependsOn`, for each
48
49
  // trace whose output one of them overlaps (`<producer>#trace:<name>`). The patterns its test
49
- // files declare they read (`// @lit <motif>` at their head, ./vitest-config/lances.mjs) are
50
+ // files declare they read (`// @lit <motif>` at their head, read by the module of its language) are
50
51
  // hashed with them (`$TURBO_ROOT$/<motif>` each, those `lit` already covers left out), a
51
52
  // package without `lit` included.
52
53
  // - `traces`: each trace the package produces, its command the package's script of the same name,
@@ -57,11 +58,13 @@
57
58
  // a package's tests wait for are read in Turborepo's plan of its tests (`tracesDuPlan` of
58
59
  // scripts/taches-du-graphe.mjs).
59
60
  // - The package holding a declared path of data alone (the shared test material) has its `build`
60
- // leave it out (`inputs`: the root's, then `!<dir>/**` each). A declared path holding code
61
+ // leave it out (`inputs`: the root's, then `!<dir>/**` per directory, a file or a pattern as is,
62
+ // `!` before it; a pattern that covers a file the build reads by name stays). A declared path holding code
61
63
  // (`.ts`, `.tsx`, `.mts`, `.cts`, `.d.ts`, `.js`, `.jsx`, `.mjs`, `.cjs`) stays an input of its
62
64
  // package's build; what a trace writes is no code of it.
63
65
  //
64
- // The check refuses a declared path absent that no trace writes; a trace written out of its
66
+ // The check refuses a declared path absent, or a pattern that covers no file, that no trace
67
+ // writes; a trace written out of its
65
68
  // package, followed by git, or not ignored; a `trace:*` script without declaration, a declaration
66
69
  // without script or not named `trace:<name>`. In the root's turbo.json, which is the project's, it
67
70
  // refuses what the generator owns: a task of one package (`<package>#<task>`, the root's own
@@ -89,7 +92,9 @@
89
92
  // project's guards; a root without it plays none): each waits for the build of each package of
90
93
  // the frame that has a `build` script, sorted (`//#grillhouse:gardes`, `//#gardes` in a
91
94
  // repository of packages), or for the root's build in a repository without packages; the task
92
- // added is `{ dependsOn, outputs: [] }`;
95
+ // added is `{ dependsOn, outputs: [] }`; in a repository of packages, the `env` of each `//#…`
96
+ // names `GRILLHOUSE_INDEX_DU_DEPOT`, the fingerprint of the list of the files of the index, the
97
+ // project's entries kept;
93
98
  // - `typecheck`, cached per package: it waits for `build` and, in a repository of packages, for
94
99
  // `^build`; a package without a `typecheck` script plays none; the task added is
95
100
  // `{ dependsOn: ["build", "^build"], outputs: [] }` (`["build"]` without packages), and a
@@ -111,14 +116,22 @@ import {
111
116
  AVANCEMENT,
112
117
  CHANGEMENTS,
113
118
  inscrireLePlan,
119
+ langage,
114
120
  paquetsSansPackageJson,
115
121
  TRACE,
116
122
  VARIABLE_TRAVAILLEURS as TRAVAILLEURS,
117
123
  } from '../../services-du-noyau.mjs';
118
124
  import { matieres } from './consommateurs.mjs';
119
- import { lecturesDeclarees, testsDuPaquet } from './vitest-config/lances.mjs';
125
+ import { lecturesDesTests } from './vitest-config/lances.mjs';
120
126
  import { parcourir } from './parcours.mjs';
121
- import { paquets, TYPAGE } from '../../paquets.mjs';
127
+ import {
128
+ estUnMotif,
129
+ fichiersDuMotif,
130
+ lectureNette,
131
+ paquets,
132
+ recouvreLaLecture,
133
+ TYPAGE,
134
+ } from '../../paquets.mjs';
122
135
  import { ecrireSarif, RESULTATS } from '../../resultats.mjs';
123
136
  import {
124
137
  SCRIPT_DES_TESTS as TESTS,
@@ -136,6 +149,10 @@ const TOPOLOGIE = ['dependencies', 'devDependencies', 'optionalDependencies'];
136
149
  const RACINES = ['turbo.json', 'turbo.jsonc'];
137
150
  // The guard tasks of the root: the frame's controls, and the project's own guards.
138
151
  export const GARDES = SCRIPTS_DE_GARDES;
152
+ // The variable that carries the fingerprint of the list of the files of the index, which the
153
+ // verification pass gives (verifier.mjs) and the guard tasks of the root hash: a guard reads the
154
+ // index.
155
+ export const INDEX_DU_DEPOT = 'GRILLHOUSE_INDEX_DU_DEPOT';
139
156
  // The controls of the root that the CI plays beside the verification: the format check and the
140
157
  // lint. A root plays those its package.json holds a script for, none demanded.
141
158
  export const CONTROLES = ['format:check', 'lint'];
@@ -416,13 +433,11 @@ const net = d => String(d ?? '').replace(/\/+$/, '');
416
433
  // and whether it has such a segment: { fixe, glob }.
417
434
  function partieFixe(motif) {
418
435
  const segments = String(motif).replace(/^\.\//, '').split('/');
419
- const i = segments.findIndex(s => /[*?[\]{}]/.test(s));
436
+ const i = segments.findIndex(estUnMotif);
420
437
  return { fixe: net((i < 0 ? segments : segments.slice(0, i)).join('/')), glob: i >= 0 };
421
438
  }
422
439
  // Whether <f> is <d> or under it.
423
440
  const sous = (f, d) => f === d || f.startsWith(`${d}/`);
424
- // Whether one of <a> and <b> holds the other.
425
- const recouvre = (a, b) => sous(a, b) || sous(b, a);
426
441
 
427
442
  // The paths of the submodules the .gitmodules of <racine> declares, sorted; none without one.
428
443
  function sousModules(racine) {
@@ -443,12 +458,33 @@ function sousModules(racine) {
443
458
  .sort();
444
459
  }
445
460
 
446
- // The exclusion of the `.git` of each submodule of <sm> one of the <chemins> (from the root)
447
- // holds, each `!<prefixe><path from <depuis>>/.git`: the `.git` of a submodule set in a copy is
461
+ // Whether an input of Turborepo, the path or pattern <lu>, can reach the `.git` of the submodule
462
+ // <m>: a path that holds it; a pattern whose fixed part is the submodule or holds it, then a glob.
463
+ function atteintLeGit(lu, m) {
464
+ const { fixe, glob } = partieFixe(lu);
465
+ return glob ? fixe === '' || sous(m, fixe) : sous(m, fixe);
466
+ }
467
+
468
+ // The inputs, from the root, that the path read <lu> (`grillhouse.lit`) of <racine> gives: a
469
+ // pattern or a file as is, a directory with `/**`. A path strictly inside the output of a trace of
470
+ // <ecrits>, which may not be written yet, gives both, so that the text does not follow the disk.
471
+ function entreesDeLecture(racine, lu, ecrits) {
472
+ if (estUnMotif(lu)) {
473
+ return [lu];
474
+ }
475
+ if (ecrits.some(e => lu !== e && sous(lu, e))) {
476
+ return [lu, `${lu}/**`];
477
+ }
478
+ const f = statSync(path.join(racine, lu), { throwIfNoEntry: false });
479
+ return [f?.isFile() ? lu : `${lu}/**`];
480
+ }
481
+
482
+ // The exclusion of the `.git` of each submodule of <sm> one of the <chemins> (from the root, paths
483
+ // or patterns) reaches, each `!<prefixe><path from <depuis>>/.git`: the `.git` of a submodule set in a copy is
448
484
  // a file naming that copy.
449
485
  const gitsExclus = (chemins, sm, prefixe = '$TURBO_ROOT$/', depuis = '') =>
450
486
  sm
451
- .filter(m => chemins.some(c => sous(m, c)))
487
+ .filter(m => chemins.some(c => atteintLeGit(c, m)))
452
488
  .map(m => `!${prefixe}${depuis ? path.posix.relative(depuis, m) : m}/.git`);
453
489
 
454
490
  // The file of the base <base> that a configuration of TypeScript in <dir> extends, as tsc finds
@@ -659,7 +695,7 @@ function declarations(liste) {
659
695
  .filter(p => !p.hors)
660
696
  .map(({ dossier, pkg }) => {
661
697
  const g = pkg.grillhouse ?? {};
662
- const chemins = l => [...new Set((Array.isArray(l) ? l : []).map(net))].sort();
698
+ const chemins = l => [...new Set((Array.isArray(l) ? l : []).map(lectureNette))].sort();
663
699
  return {
664
700
  dossier,
665
701
  pkg,
@@ -677,14 +713,16 @@ function declarations(liste) {
677
713
  }
678
714
 
679
715
  // The patterns the test files of the package at <dossier> (absolute) declare they read (`// @lit`
680
- // at their head, ./vitest-config/lances.mjs), each a glob from the root, those the paths <lit> of
681
- // the package already cover left out; sorted.
682
- function lecturesDesTests(dossier, lit) {
683
- return [
684
- ...new Set(testsDuPaquet(dossier).flatMap(t => lecturesDeclarees(readFileSync(t, 'utf8')))),
685
- ]
686
- .filter(m => !lit.some(l => m === l || m.startsWith(`${l}/`)))
687
- .sort();
716
+ // at their head), as the module of its language <langageNom> reads them (null: a package of
717
+ // TypeScript, ./vitest-config/lances.mjs), each a glob from the root, those the paths <lit> of the
718
+ // package already cover left out; sorted.
719
+ function lecturesHorsDeLit(dossier, langageNom, lit) {
720
+ const lectures = langageNom
721
+ ? langage(langageNom).lecturesDesTests(dossier)
722
+ : lecturesDesTests(dossier);
723
+ return lectures.filter(
724
+ m => !lit.some(l => m === l || m.startsWith(`${l.replace(/\/\*\*$/, '')}/`))
725
+ );
688
726
  }
689
727
 
690
728
  // The text of a package's turbo.json, whose tasks are <taches>.
@@ -719,7 +757,7 @@ export function attendus(racine) {
719
757
  // The trace tasks whose output one of <lit> overlaps, <soi> left out, sorted.
720
758
  const jointes = (lit, soi) =>
721
759
  traces
722
- .filter(t => t.id !== soi && lit.some(l => recouvre(l, t.ecrit)))
760
+ .filter(t => t.id !== soi && lit.some(l => recouvreLaLecture(l, t.ecrit)))
723
761
  .map(t => t.id)
724
762
  .sort();
725
763
  // The paths of data alone declared: the ones a trace writes left out, which git ignores, and the
@@ -727,7 +765,9 @@ export function attendus(racine) {
727
765
  const ecrits = traces.map(t => t.ecrit);
728
766
  const donnees = [
729
767
  ...new Set([...decls.values()].flatMap(d => [...d.lit, ...d.traces.flatMap(t => t.lit)])),
730
- ].filter(l => !ecrits.some(e => recouvre(l, e)) && !contientCode(racine, l, ecrits));
768
+ ].filter(
769
+ l => !ecrits.some(e => recouvreLaLecture(l, e)) && !contientCode(racine, l, ecrits)
770
+ );
731
771
  // The inputs of the root's <tache> a package's own extend: the root's, or Turborepo's default
732
772
  // when the root sets none (`$TURBO_EXTENDS$` then extends an empty list).
733
773
  const base = tache => (deRacine.get(tache)?.inputs ? '$TURBO_EXTENDS$' : '$TURBO_DEFAULT$');
@@ -756,12 +796,19 @@ export function attendus(racine) {
756
796
  const lusParBuild = propres
757
797
  ? f => propres.includes(f)
758
798
  : f => f === 'package.json' || /^tsconfig[^/]*\.json$/.test(f);
799
+ const relatif = f => path.posix.relative(dossier, f);
800
+ // A pattern that covers a file the build reads by name is left in its inputs.
759
801
  const dedans = donnees
760
802
  .filter(d => d !== dossier && sous(d, dossier))
761
- .map(d => path.posix.relative(dossier, d))
762
- .filter(d => !lusParBuild(d))
803
+ .filter(d =>
804
+ estUnMotif(d)
805
+ ? !fichiersDuMotif(racine, d).some(f => lusParBuild(relatif(f)))
806
+ : !lusParBuild(relatif(d))
807
+ )
763
808
  .sort();
764
- const sansDonnees = dedans.map(d => `!${d}/**`);
809
+ const sansDonnees = dedans
810
+ .flatMap(d => entreesDeLecture(racine, d, ecrits))
811
+ .map(e => `!${relatif(e)}`);
765
812
  if (langageDuPaquet) {
766
813
  taches.build.inputs = [...propres, ...sansDonnees];
767
814
  } else if (propres) {
@@ -791,13 +838,19 @@ export function attendus(racine) {
791
838
  }
792
839
  }
793
840
  const decl = decls.get(dossier);
794
- const declares = lecturesDesTests(path.join(racine, dossier), decl.lit);
841
+ const declares = lecturesHorsDeLit(
842
+ path.join(racine, dossier),
843
+ langageDuPaquet ?? null,
844
+ decl.lit
845
+ );
795
846
  if (decl.lit.length || declares.length) {
796
847
  taches[TESTS] = {
797
848
  dependsOn: [...deplier(deRacine.get(TESTS)?.dependsOn ?? []), ...jointes(decl.lit)],
798
849
  inputs: [
799
850
  base(TESTS),
800
- ...decl.lit.map(l => `$TURBO_ROOT$/${l}/**`),
851
+ ...decl.lit
852
+ .flatMap(l => entreesDeLecture(racine, l, ecrits))
853
+ .map(l => `$TURBO_ROOT$/${l}`),
801
854
  ...declares.map(m => `$TURBO_ROOT$/${m}`),
802
855
  ...gitsExclus(decl.lit, sm),
803
856
  ],
@@ -809,7 +862,9 @@ export function attendus(racine) {
809
862
  dependsOn: [...deplier(['build', '^build']), ...jointes(t.lit, t.id)],
810
863
  inputs: [
811
864
  '$TURBO_DEFAULT$',
812
- ...t.lit.map(l => `$TURBO_ROOT$/${l}/**`),
865
+ ...t.lit
866
+ .flatMap(l => entreesDeLecture(racine, l, ecrits))
867
+ .map(l => `$TURBO_ROOT$/${l}`),
813
868
  ...gitsExclus(t.lit, sm),
814
869
  `!${ecrit}/**`,
815
870
  ],
@@ -859,6 +914,36 @@ function gardesEcartees(racine) {
859
914
  return { f, texte, ecarts };
860
915
  }
861
916
 
917
+ // Whether the task <cle> is written as one of the root package, in a repository of packages.
918
+ const estDeLaRacine = cle => cle.startsWith('//#');
919
+
920
+ // The guard task <cle> the generator adds to a root that lacks it.
921
+ const gardeNeuve = (cle, dependsOn) => ({
922
+ dependsOn,
923
+ ...(estDeLaRacine(cle) ? { env: [INDEX_DU_DEPOT] } : {}),
924
+ outputs: [],
925
+ });
926
+
927
+ // The guard tasks of the root's turbo.json at <racine>, in a repository of packages (`//#…`), whose
928
+ // `env` lacks INDEX_DU_DEPOT, added to the project's: [{ f, cle, attendu }]; a task absent aside,
929
+ // which `gardesEcartees` adds whole.
930
+ function gardesSansIndex(racine) {
931
+ const r = confRacine(racine);
932
+ if (!r) {
933
+ return [];
934
+ }
935
+ return [...gardesAttendues(racine).keys()].filter(estDeLaRacine).flatMap(cle => {
936
+ const tache = r.conf.tasks?.[cle];
937
+ if (!tache || typeof tache !== 'object') {
938
+ return [];
939
+ }
940
+ const actuel = Array.isArray(tache.env) ? tache.env : [];
941
+ return actuel.includes(INDEX_DU_DEPOT)
942
+ ? []
943
+ : [{ f: r.f, cle, attendu: [...actuel, INDEX_DU_DEPOT] }];
944
+ });
945
+ }
946
+
862
947
  // The typing task of the root's turbo.json at <racine> when it lacks it, or when its `dependsOn`
863
948
  // lacks one of the builds it waits for (`attenteDuTypage`): { f, chemin, valeur, manques }, the
864
949
  // path of the edit and the value it sets (the task, `{ dependsOn, outputs: [] }`; or its
@@ -981,12 +1066,21 @@ export function ecrire(racine) {
981
1066
  for (const { cle, attendu, present } of racineEcartee.ecarts) {
982
1067
  const [chemin, valeur] = present
983
1068
  ? [['tasks', cle, 'dependsOn'], attendu]
984
- : [['tasks', cle], { dependsOn: attendu, outputs: [] }];
1069
+ : [['tasks', cle], gardeNeuve(cle, attendu)];
985
1070
  texte = applyEdits(texte, modify(texte, chemin, valeur, MISE_EN_FORME));
986
1071
  }
987
1072
  writeFileSync(path.join(racine, racineEcartee.f), texte);
988
1073
  ecrits.push(racineEcartee.f);
989
1074
  }
1075
+ for (const { f, cle, attendu } of gardesSansIndex(racine)) {
1076
+ const abs = path.join(racine, f);
1077
+ const texte = readFileSync(abs, 'utf8');
1078
+ const chemin = ['tasks', cle, 'env'];
1079
+ writeFileSync(abs, applyEdits(texte, modify(texte, chemin, attendu, MISE_EN_FORME)));
1080
+ if (!ecrits.includes(f)) {
1081
+ ecrits.push(f);
1082
+ }
1083
+ }
990
1084
  const typage = typageEcarte(racine);
991
1085
  if (typage) {
992
1086
  const abs = path.join(racine, typage.f);
@@ -1069,12 +1163,17 @@ export function ecrire(racine) {
1069
1163
  return ecrits;
1070
1164
  }
1071
1165
 
1072
- // Whether <chemin> of <racine> (a directory, or a file, from the root) holds a file of code; what
1073
- // lies under one of <exclus> left out, as `parcourir` walks it.
1166
+ // Whether <chemin> of <racine> (a directory, a file or a pattern, from the root) holds a file of
1167
+ // code; what lies under one of <exclus> left out, as `parcourir` walks it.
1074
1168
  function contientCode(racine, chemin, exclus) {
1075
1169
  if (exclus.some(e => sous(chemin, e))) {
1076
1170
  return false;
1077
1171
  }
1172
+ if (estUnMotif(chemin)) {
1173
+ return fichiersDuMotif(racine, chemin).some(
1174
+ f => CODE.test(f) && !exclus.some(e => sous(f, e))
1175
+ );
1176
+ }
1078
1177
  const rel = p => path.relative(racine, p).split(path.sep).join('/');
1079
1178
  return parcourir(path.join(racine, chemin), p => exclus.some(e => sous(rel(p), e))).some(f =>
1080
1179
  CODE.test(f)
@@ -1084,7 +1183,7 @@ function contientCode(racine, chemin, exclus) {
1084
1183
  const gitSort = (racine, args) => spawnSync('git', args, { cwd: racine, encoding: 'utf8' });
1085
1184
 
1086
1185
  // The refusals of the data and traces the packages of <racine> declare: one line per declared
1087
- // path absent that no trace writes, per trace written out of its producer,
1186
+ // path absent or pattern covering no file that no trace writes, per trace written out of its producer,
1088
1187
  // followed by git or not ignored, per trace script without declaration and declaration without
1089
1188
  // script.
1090
1189
  function declarationsRefusees(racine) {
@@ -1124,8 +1223,17 @@ function declarationsRefusees(racine) {
1124
1223
  }
1125
1224
  }
1126
1225
  for (const l of [...new Set([...lit, ...traces.flatMap(t => t.lit)])].sort()) {
1127
- const sortie = ecrits.some(e => recouvre(l, e));
1128
- if (!sortie && !existsSync(path.join(racine, l))) {
1226
+ const sortie = ecrits.some(e => recouvreLaLecture(l, e));
1227
+ if (sortie) {
1228
+ continue;
1229
+ }
1230
+ if (estUnMotif(l)) {
1231
+ if (fichiersDuMotif(racine, l).length === 0) {
1232
+ refus.push(
1233
+ `⛔ ${ici} : le motif lu \`${l}\` ne recouvre aucun fichier, et aucune trace n'écrit sous lui (\`grillhouse.traces\`).`
1234
+ );
1235
+ }
1236
+ } else if (!existsSync(path.join(racine, l))) {
1129
1237
  refus.push(
1130
1238
  `⛔ ${ici} : le chemin lu \`${l}\` n'existe pas, et aucune trace ne l'écrit (\`grillhouse.traces\`).`
1131
1239
  );
@@ -1261,6 +1369,11 @@ export function verifier(racine) {
1261
1369
  : `⛔ ${f} : la tâche \`${cle}\` manque ; \`${COMMANDE}\` l'ajoute, après la construction de chaque paquet du cadre.`
1262
1370
  );
1263
1371
  }
1372
+ for (const { f, cle } of gardesSansIndex(racine)) {
1373
+ refus.push(
1374
+ `⛔ ${f} : l'\`env\` de \`${cle}\` doit nommer ${INDEX_DU_DEPOT}, l'empreinte de la liste des fichiers de l'index, qu'une garde lit ; \`${COMMANDE}\` l'ajoute.`
1375
+ );
1376
+ }
1264
1377
  for (const [f, t] of attendus(racine)) {
1265
1378
  const abs = path.join(racine, f);
1266
1379
  if (!existsSync(abs)) {
@@ -8,8 +8,13 @@
8
8
  // `<dossier>/vitest/` while the variable is set (scripts/langages/typescript/vitest-config/resultats.mjs):
9
9
  // `lireRapportsVitest` gives each test file, its status, the message of a file that does not
10
10
  // load, and each test, its title, its full name, its status and its first message.
11
+ // - The log of a task of tests whose package has no report (./rapports-aux-lignes.mjs, a runner
12
+ // without a report test by test), read from the root of the run.
11
13
  import { existsSync, readdirSync, readFileSync } from 'node:fs';
12
14
  import path from 'node:path';
15
+ import { stripVTControlCharacters } from 'node:util';
16
+ import { A_REPASSER } from '../../services-du-noyau.mjs';
17
+ import { rapportsAuxLignes } from './rapports-aux-lignes.mjs';
13
18
  import { lireLesResumes } from './resume-du-lanceur.mjs';
14
19
  import { VITEST } from './vitest-config/resultats.mjs';
15
20
 
@@ -46,7 +51,28 @@ export function lireRapportsVitest(dossier) {
46
51
  );
47
52
  }
48
53
 
49
- // The verdict the results directory <dossier> holds: `{ rapports, taches }`.
50
- export function verdict(dossier) {
51
- return { rapports: lireRapportsVitest(dossier), taches: lireLesResumes(dossier) };
54
+ // The reports the logs of the tasks <taches> give, from the root <racine> of their run: those of
55
+ // each task of tests that ran, not « à repasser », whose package has none among <rapports>.
56
+ function rapportsDesJournaux(racine, taches, rapports) {
57
+ return taches
58
+ .filter(t => t.tests && t.journal && t.code !== null && t.code !== A_REPASSER)
59
+ .flatMap(t => {
60
+ const paquet = path.join(racine, t.dossier, path.sep);
61
+ const journal = path.join(racine, t.journal);
62
+ return !existsSync(journal) || rapports.some(r => r.fichier.startsWith(paquet))
63
+ ? []
64
+ : rapportsAuxLignes(stripVTControlCharacters(readFileSync(journal, 'utf8')), {
65
+ dossier: paquet,
66
+ code: t.code,
67
+ });
68
+ });
69
+ }
70
+
71
+ // The verdict the results directory <dossier> holds: `{ rapports, taches }`; with the root
72
+ // <racine> of the run, the reports its logs give too.
73
+ export function verdict(dossier, racine) {
74
+ const rapports = lireRapportsVitest(dossier);
75
+ const taches = lireLesResumes(dossier);
76
+ const auxLignes = racine ? rapportsDesJournaux(racine, taches, rapports) : [];
77
+ return { rapports: [...rapports, ...auxLignes], taches };
52
78
  }
@@ -19,6 +19,8 @@
19
19
  // keeps its tree as the last green; a red one leaves it. The pass alone keeps it, for every
20
20
  // language: it plays the tasks of every package of the graph, a crate's and a Python
21
21
  // project's beside a TypeScript package's (their `test:unit` and `typecheck`).
22
+ // - Every pass gives its tasks the fingerprint of the list of the files of the index
23
+ // (`GRILLHOUSE_INDEX_DU_DEPOT`), which the guard tasks hash (./turbo-des-paquets.mjs).
22
24
  // - `--tout`, and `--force` (the night, scripts/nuit.sh), play the complete pass: each task of
23
25
  // tests for real (`GRILLHOUSE_TESTS` carries only `rejouer`, the moment of the pass, no path).
24
26
  // - The part of the budget of the machine (scripts/places-de-la-machine.mjs, `avecLaPasse`): a
@@ -73,6 +75,7 @@
73
75
  // TMPDIR, TMP and TEMP (`globalPassThroughEnv`, ./turbo-des-paquets.mjs); removed at the end,
74
76
  // green, red or interrupted (SIGINT, SIGTERM, SIGHUP).
75
77
  import { spawnSync } from 'node:child_process';
78
+ import { createHash } from 'node:crypto';
76
79
  import { existsSync, readdirSync, readFileSync, rmdirSync, rmSync, writeFileSync } from 'node:fs';
77
80
  import { availableParallelism, tmpdir } from 'node:os';
78
81
  import path from 'node:path';
@@ -112,7 +115,7 @@ import { paquets, TYPAGE } from '../../paquets.mjs';
112
115
  import { RESULTATS } from '../../resultats.mjs';
113
116
  import { fichiersDeLaTranche, RAPPORTS } from './tranches.mjs';
114
117
  import { garderLesResumes } from './resume-du-lanceur.mjs';
115
- import { controlesDuDepot, planifier } from './turbo-des-paquets.mjs';
118
+ import { controlesDuDepot, INDEX_DU_DEPOT, planifier } from './turbo-des-paquets.mjs';
116
119
 
117
120
  const TACHES = [...GARDES, TYPAGE, SCRIPT_DES_TESTS];
118
121
  const CONCURRENCE = /^--concurrency(?:=|$)/;
@@ -125,6 +128,17 @@ const rejeu = id => {
125
128
  return `npx turbo run ${id.slice(i + 1)} --filter=${id.slice(0, i)}`;
126
129
  };
127
130
 
131
+ // The fingerprint of the list of the files of the index of the repository at <racine>, under
132
+ // <env>: it moves when a file enters or leaves the index, whatever the contents. null when git
133
+ // gives no list.
134
+ function empreinteDeLIndex(racine, env) {
135
+ const r = spawnSync('git', ['-C', racine, 'ls-files', '-z'], {
136
+ env,
137
+ maxBuffer: 1024 * 1024 * 1024,
138
+ });
139
+ return r.status === 0 ? createHash('sha256').update(r.stdout).digest('hex') : null;
140
+ }
141
+
128
142
  const lister = dossier => (existsSync(dossier) ? readdirSync(dossier) : []);
129
143
 
130
144
  // The tasks side by side <args> ask for (`--concurrency=<n>`, `--concurrency <n>`), null without
@@ -390,7 +404,7 @@ function passe({ racine, demandes, env, dire, coeurs }) {
390
404
  // green that turned red, with the moment they did. A red pass on a ticket's branch records none:
391
405
  // its reds are the ticket's work.
392
406
  if (complet && env[RESULTATS] && m?.etat) {
393
- const rapports = langageDe(racine).verdict(env[RESULTATS]).rapports;
407
+ const rapports = langageDe(racine).verdict(env[RESULTATS], racine).rapports;
394
408
  if (code === 0) {
395
409
  garderLeRegistre(m.etat, rapports);
396
410
  } else if (!m.etat.branche || m.etat.branche === m.etat.main) {
@@ -411,7 +425,18 @@ function passe({ racine, demandes, env, dire, coeurs }) {
411
425
 
412
426
  function jouerLaPasse({ racine, demandes, args, tout, ajouts, env, dire, coeurs, taches }) {
413
427
  const { gardesSeules, sansTests, tranche } = demandes;
414
- const { [TESTS_CIBLES]: _, [CHANGEMENTS]: __, [BASE_DU_LOT]: ___, ...propre } = env;
428
+ const {
429
+ [TESTS_CIBLES]: _,
430
+ [CHANGEMENTS]: __,
431
+ [BASE_DU_LOT]: ___,
432
+ [INDEX_DU_DEPOT]: ____,
433
+ ...herite
434
+ } = env;
435
+ // The fingerprint of this repository's index, never the caller's: a guard reads the index, and
436
+ // Turborepo, which hashes an untracked file as a tracked one, plays the guards again when the
437
+ // list moves.
438
+ const index = empreinteDeLIndex(racine, herite);
439
+ const propre = index === null ? herite : { ...herite, [INDEX_DU_DEPOT]: index };
415
440
  // The environment of the run: measured against the last green; the moment of a complete pass,
416
441
  // which moves the hash of every task of tests, so that each plays for real; a tranche, with it.
417
442
  const cibles = tranche
@@ -26,7 +26,8 @@
26
26
  // 4. the configuration of the package at its top: `package.json`, `vitest.config.*`,
27
27
  // `vite.config.*`, `vitest.workspace.*`, `tsconfig*.json`; its `setupFiles` and its
28
28
  // `globalSetup`, which Vitest runs beside the graph;
29
- // 5. a path its tests declare they read (`grillhouse.lit` of its package.json, from the top):
29
+ // 5. a path its tests declare they read (`grillhouse.lit` of its package.json, from the top,
30
+ // a path or a glob pattern, as `couvertPar` of ../../../paquets.mjs reads it):
30
31
  // a directory or a file out of the package that its tests read as a whole (the templates,
31
32
  // the plugin, the configuration of the repository), as Bazel's `data`, named file by file
32
33
  // where the frame rewrites their neighbours (the hooks and configuration of `.beads`, never
@@ -71,6 +72,7 @@ import { existsSync, readFileSync, realpathSync } from 'node:fs';
71
72
  import { createRequire } from 'node:module';
72
73
  import path from 'node:path';
73
74
  import { fileURLToPath } from 'node:url';
75
+ import { couvertPar } from '../../../paquets.mjs';
74
76
  import { testsQuiDeclarent, testsQuiLancent, testsQuiNomment } from './lances.mjs';
75
77
 
76
78
  // This directory, the frame's base configuration.
@@ -208,9 +210,9 @@ function paquetEntier(ch, dossier, test = {}) {
208
210
  const racine = ch.racine;
209
211
  const abs = f => path.join(racine, f);
210
212
  const deps = dependances(racine, dossier);
211
- const lit = (lireJson(path.join(dossier, 'package.json'))?.grillhouse?.lit ?? [])
212
- .filter(l => typeof l === 'string')
213
- .map(l => l.replace(/^\.\//, '').replace(/\/+$/, ''));
213
+ const lit = (lireJson(path.join(dossier, 'package.json'))?.grillhouse?.lit ?? []).filter(
214
+ l => typeof l === 'string'
215
+ );
214
216
  const preparation = [test.setupFiles, test.globalSetup]
215
217
  .flat()
216
218
  .filter(f => typeof f === 'string')
@@ -231,7 +233,7 @@ function paquetEntier(ch, dossier, test = {}) {
231
233
  ? 'la configuration du paquet'
232
234
  : preparation.includes(a)
233
235
  ? 'un fichier de préparation des tests'
234
- : !ch.cible && lit.some(l => f === l || f.startsWith(`${l}/`))
236
+ : !ch.cible && couvertPar(lit, f)
235
237
  ? 'un chemin que ses tests déclarent lire (grillhouse.lit)'
236
238
  : deps.some(d => sous(a, d) && construit(racine, d, a))
237
239
  ? 'le code d’un paquet dont il dépend, que ses tests lisent construit'
@@ -246,7 +248,7 @@ function paquetEntier(ch, dossier, test = {}) {
246
248
  // path reads its text, not its output.
247
249
  if (!ch.cible) {
248
250
  for (const f of ch.sansEffet ?? []) {
249
- if (lit.some(l => f === l || f.startsWith(`${l}/`))) {
251
+ if (couvertPar(lit, f)) {
250
252
  return { raison: 'un chemin que ses tests déclarent lire (grillhouse.lit)', fichier: f };
251
253
  }
252
254
  }
@@ -5,7 +5,7 @@
5
5
  // Mechanism: packages/grillhouse/docs/architecture/tests.md, §5.3 (the tests of a package replayed).
6
6
  //
7
7
  // - What a test names (`nommesPar`): each path that a string of its code writes whole
8
- // (`'../../scripts/verrous/verrou.mjs'`), or that the strings of one call of `join` or
8
+ // (`'../../scripts/verrous/ecriture-hors-enveloppe.mjs'`), or that the strings of one call of `join` or
9
9
  // `resolve` write together (`path.join(DEPOT, 'packages/a', 'scripts/x.mjs')`), resolved from
10
10
  // the directory of the file that writes it, then from the test's package, then from the top of
11
11
  // the repository, the first that exists: the constant `SCRIPT` of a test that launches a script,
@@ -23,7 +23,7 @@
23
23
  // - What a test reads (`lusPar`): the test and the files it names, then, from file to file, the
24
24
  // modules each one imports (a relative specifier, or a package of the workspace, resolved as Node
25
25
  // resolves it, out of node_modules once its links are followed) and the paths each module's code
26
- // writes from its own directory (`path.join(ICI, 'verrous/verrou.mjs')`), a command's link
26
+ // writes from its own directory (`path.join(ICI, 'verrous/ticket-du-sous-agent.mjs')`), a command's link
27
27
  // included (the hook of the plugin that runs `node_modules/.bin/grillhouse <sous-commande>`), and
28
28
  // the paths a script of the shell writes from its own directory (`"$ici/superviseur.mjs"`): a
29
29
  // script that launches another names it. A subcommand leads to every script of the command's
@@ -44,8 +44,8 @@
44
44
  // turbo.json (../turbo-des-paquets.mjs) writes each pattern in the inputs of the package's test
45
45
  // task, so that Turborepo's cache follows the same declaration.
46
46
  // - What a test names without the frame reading it (`nonDeclares`): a string of the test's code or
47
- // of its material that ends the path of a module of its package (`'verrou.mjs'`,
48
- // `'verrous/verrou.mjs'`), out of a directory of tests, the module out of what the test reads and
47
+ // of its material that ends the path of a module of its package (`'registre.mjs'`,
48
+ // `'enveloppe/lancer.sh'`), out of a directory of tests, the module out of what the test reads and
49
49
  // out of the package's `grillhouse.lit`: a script it launches by a path built at run time
50
50
  // (`path.join(SCRIPTS, nom)`), whose change would not play it; or a pattern that names a
51
51
  // directory of the package without a fixed start (`'**/scripts/*.mjs'`), for each module it
@@ -62,7 +62,7 @@ import { existsSync, globSync, readFileSync, realpathSync, statSync } from 'node
62
62
  import { createRequire } from 'node:module';
63
63
  import path from 'node:path';
64
64
  import { matieres } from '../composants.mjs';
65
- import { paquets } from '../../../paquets.mjs';
65
+ import { couvertPar, lecturesDeclarees, paquets } from '../../../paquets.mjs';
66
66
  import { parcourir } from '../parcours.mjs';
67
67
 
68
68
  /** A test file, as Vitest's default `include` names one. */
@@ -484,29 +484,6 @@ export function testsQuiNomment(dossier, racine, changes) {
484
484
  );
485
485
  }
486
486
 
487
- // The tag of a test that declares the files it reads: a line `// @lit <motif> …` of the comment at
488
- // the head of the file, before its first line of code, as the tag `@poste` (./cibles.mjs).
489
- const ETIQUETTE_DE_LECTURE = /^\/\/\s*@lit\b(.*)$/;
490
-
491
- /**
492
- * The patterns the text <texte> of a test file declares it reads: the words of each line
493
- * `// @lit` of the comment at its head, each a glob from the top of the repository.
494
- * @param {string} texte the text of the file
495
- */
496
- export function lecturesDeclarees(texte) {
497
- const out = [];
498
- for (const ligne of texte.split('\n')) {
499
- const l = ligne.trim();
500
- const m = ETIQUETTE_DE_LECTURE.exec(l);
501
- if (m) {
502
- out.push(...m[1].split(/\s+/).filter(Boolean));
503
- } else if (l !== '' && !l.startsWith('//') && !l.startsWith('#!')) {
504
- break;
505
- }
506
- }
507
- return out;
508
- }
509
-
510
487
  /**
511
488
  * The test files of the package at <dossier> that declare they read one of the files <chemins>
512
489
  * (each from the top of the repository): those whose `@lit` patterns cover one; absolute, sorted.
@@ -521,12 +498,18 @@ export function testsQuiDeclarent(dossier, chemins) {
521
498
  });
522
499
  }
523
500
 
524
- // Whether the path <rel> (from the top) lies under one of the paths <lit> (from the top).
525
- const dansLit = (rel, lit) => lit.some(l => rel === l || rel.startsWith(`${l}/`));
501
+ /**
502
+ * The patterns the test files of the package at <dossier> declare they read (`lecturesDeclarees`),
503
+ * each once, sorted.
504
+ * @param {string} dossier the directory of the package, absolute
505
+ */
506
+ export function lecturesDesTests(dossier) {
507
+ return [...new Set(testsDuPaquet(dossier).flatMap(t => lecturesDeclarees(lire(t))))].sort();
508
+ }
526
509
 
527
510
  /**
528
511
  * What the test files of the package at <dossier>, in the repository at <racine>, name without
529
- * the frame reading it, <lit> the package's `grillhouse.lit` (paths from the top):
512
+ * the frame reading it, <lit> the package's `grillhouse.lit` (paths or patterns from the top):
530
513
  * `[{ test, fichier, chaine }]`, `test` and `fichier` from the top, `fichier` a module of the
531
514
  * package out of a directory of tests whose path the string <chaine> of the test's code (or of its
532
515
  * material) ends, out of what the test reads (`lusPar`) and out of lit; in the order of the tests.
@@ -538,7 +521,7 @@ export function nonDeclares(dossier, racine, lit = [], memo = new Map()) {
538
521
  const modules = [];
539
522
  for (const f of fichiersSous(dossier)) {
540
523
  const r = du(racine, f);
541
- if (!MODULE.test(f) || TEST.test(f) || MATIERE.test(r) || dansLit(r, lit)) {
524
+ if (!MODULE.test(f) || TEST.test(f) || MATIERE.test(r) || couvertPar(lit, r)) {
542
525
  continue;
543
526
  }
544
527
  modules.push(f);