@roomi-fields/grillhouse 0.24.5 → 0.24.7

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.
@@ -111,9 +111,11 @@
111
111
  // sheet read is kept with the ticket's sheets, `.claude/worktrees/<ticket>.fiches.jsonl` (`{
112
112
  // date, role, fiche }`, the lot a review read joined to its sheet, `lot`), beside the circuit's
113
113
  // own results: the report of each proof and check, which the reviewer receives, with its outcome
114
- // (`resultat`), each stop (`arret`), each developpeur resumed who changed nothing (`inchange`),
115
- // each session launched (`lancement`, its role and its session id), each end of a run on a
116
- // question (`montee`: its code, its stop and who must answer it), which the bilan reads; and each
114
+ // (`resultat`), each stop (`arret`), each developpeur session that changed no file of the plan
115
+ // and goes to the checks or stops at « sans-livraison » (`inchange`), each session launched
116
+ // (`lancement`, its role and its session id), each end of a run on a question (`montee`: its
117
+ // code, its stop and the supervisor's session that ran it, `superviseur`, the
118
+ // `CLAUDE_CODE_SESSION_ID` Claude Code gives the run), which the bilan reads; and each
117
119
  // of its discoveries (`decouvertes`) filed closed under the ticket (scripts/ticket.sh, label
118
120
  // `decouverte`). A session that ends without a sheet that conforms (none, one out of its schema,
119
121
  // a code other than 0) is resumed once, the same session, with the third template, which names
@@ -261,7 +263,12 @@
261
263
  // their test files, a finding of one of their guards, whatever file it aims at, or a failed test
262
264
  // or a finding on a file a reference of the project covers), mixed with other reds or not, or a
263
265
  // guard's note of a key of the debt inscribed above what it finds (`a-elaguer`, the pass green
264
- // or not), sends no developpeur: the gesture `regeneration`, once for that pass. The circuit
266
+ // or not), sends no developpeur: the gesture `regeneration`, once for that pass. Checks of the
267
+ // plan green but for reds of references call for it too, before the final pass, as make
268
+ // remakes a generated file before what reads it: the final pass that is due then plays once, on
269
+ // the regenerated tree, and does not regenerate again a reference regenerated on that same tree
270
+ // (BPScript 320.3.9: the ceiling of the words, red at the checks, left to the final pass, which
271
+ // played the same tests again on the same tree for 6.1 min before regenerating). The circuit
265
272
  // keeps the copy as a lot, runs the command of each reference concerned on the whole copy (the
266
273
  // debt lowered from the notes of the pass, its guards not played again), out of the envelope,
267
274
  // under the lock of the machine, its output added to the log, then, as make remakes the targets
@@ -493,7 +500,6 @@ import {
493
500
  QUESTIONNEUR,
494
501
  RESPONSABLE,
495
502
  SUITE,
496
- SUPERVISEUR,
497
503
  } from './etapes.mjs';
498
504
  import { paquets } from './paquets.mjs';
499
505
  import { releve } from './composants-affectes.mjs';
@@ -1185,9 +1191,11 @@ function consigne(valeurs, rang = 0) {
1185
1191
 
1186
1192
  // One session of <role> on the whole ticket: its sheet. A relaunch on its step (<tentative> past
1187
1193
  // 1) that is not the last (<derniere>) resumes the agent's session the circuit keeps
1188
- // (`ctx.reprise`, its author and id) with the short instruction (the fourth template); a
1189
- // resumption that fails (a code other than 0, or no sheet that conforms) falls back on a fresh and
1190
- // whole session, under a new id, which the circuit keeps. A fresh session's instruction (the first
1194
+ // (`ctx.reprise`, its author and id) with the short instruction (the fourth template); its sheet
1195
+ // refused is asked again once of that same session, as of a fresh one (`jusquALaFiche`), so the
1196
+ // question it carries goes up (BP 320.3.9); a resumption that ends in error (a code other than 0:
1197
+ // the session not found) falls back on a fresh and whole session, under a new id, which the
1198
+ // circuit keeps. A fresh session's instruction (the first
1191
1199
  // template) carries the ticket's description and notes as they are at its launch, the packages of
1192
1200
  // the plan, and the last handover of its author at the ticket. Every instruction, fresh or resumed,
1193
1201
  // carries the findings of the reviewer still open for its role (`ctx.constats`), all of them,
@@ -1213,14 +1221,17 @@ async function seance(ctx, role, { tentative, rapport, fort, derniere }) {
1213
1221
  rapport: rapport ?? 'aucun',
1214
1222
  constats,
1215
1223
  };
1216
- const r = await lancer(ctx, role, consigne(courte, 3), { fort, reprend: reprise.seance });
1217
- seanceLancee(ctx, role, r);
1218
- const lu = r.seance === 0 ? lireSaFiche(ctx, role, r.sortie) : { erreur: `code ${r.seance}` };
1219
- if (lu.fiche) return garder(ctx, role, lu.fiche);
1224
+ const fiche = await jusquALaFiche(ctx, role, consigne(courte, 3), {
1225
+ fort,
1226
+ premiere: 'reprend',
1227
+ id: reprise.seance,
1228
+ repli: true,
1229
+ });
1230
+ if (fiche) return fiche;
1220
1231
  commenter(
1221
1232
  ctx,
1222
1233
  role,
1223
- `reprise de la séance ${reprise.seance} sans fiche conforme (${lu.erreur}) : séance neuve et entière.`
1234
+ `reprise de la séance ${reprise.seance} finie en erreur : séance neuve et entière.`
1224
1235
  );
1225
1236
  }
1226
1237
  const lots = testsDuLot(ctx);
@@ -1293,7 +1304,8 @@ function seanceLancee(ctx, role, r) {
1293
1304
  // 0) is resumed once, the same session, with the short instruction that names what lacks (the
1294
1305
  // third template). The session opens under the id <id> (a new one by default), or resumes it with
1295
1306
  // <premiere> « reprend »; with <neuve> (the testwriter or the developpeur), the circuit keeps that
1296
- // id for that author (`ctx.reprise`). Throws an Arret for a launch that stops before its session,
1307
+ // id for that author (`ctx.reprise`); with <repli> (a resumption), a session that ends in error
1308
+ // returns null, for a fresh session in its place. Throws an Arret for a launch that stops before its session,
1297
1309
  // a motionless session, or twice no sheet that conforms (« sans-fiche »). <avec> joins its fields
1298
1310
  // to the sheet's entry (the lot a review read); <valider> names what makes a sheet out of
1299
1311
  // conformity beyond its schema (an unknown package of a plan), or null.
@@ -1304,6 +1316,7 @@ async function jusquALaFiche(ctx, role, texte, options = {}) {
1304
1316
  id = randomUUID(),
1305
1317
  avec = {},
1306
1318
  valider = () => null,
1319
+ repli = false,
1307
1320
  ...reste
1308
1321
  } = options;
1309
1322
  if (neuve) ctx.reprise = { agent: neuve, seance: id };
@@ -1319,6 +1332,7 @@ async function jusquALaFiche(ctx, role, texte, options = {}) {
1319
1332
  ...ouvrir(essai === 1 ? premiere : 'reprend'),
1320
1333
  });
1321
1334
  seanceLancee(ctx, role, r);
1335
+ if (repli && r.seance !== 0) return null;
1322
1336
  lu =
1323
1337
  r.seance === 0
1324
1338
  ? lireSaFiche(ctx, role, r.sortie)
@@ -1717,13 +1731,14 @@ function referencesDesRouges(ctx, lieux, aElaguer = false) {
1717
1731
  // another one has just written runs after it, once for each reference whose writing calls for it;
1718
1732
  // then the copy kept again on that lot. `{ texte, regenerees, fichiers, restreinte }`: the report,
1719
1733
  // the names of the references changed, the files changed, and the range of the final pass that
1720
- // follows (null when nothing changed: no pass plays again, and the reds stand). A file a reference
1721
- // writes follows from the lot, as the output of a genrule, without a word of the plan, and the
1722
- // reviewer reads its difference; a file changed that none of the references run declares, or a
1723
- // command that fails (a reference of the project at another code than 0, one of the frame on a
1724
- // real failure alone) restores the copy as it was and stops at « references », each deviation in
1725
- // its question.
1726
- function regenerer(ctx, noms, notes = []) {
1734
+ // follows (null when nothing changed: no pass plays again, and the reds stand); with
1735
+ // <avantLaPasse>, the regeneration the checks of the plan call for, the final pass that is due
1736
+ // follows, whole or since the last review. A file a reference writes follows from the lot, as
1737
+ // the output of a genrule, without a word of the plan, and the reviewer reads its difference; a
1738
+ // file changed that none of the references run declares, or a command that fails (a reference of
1739
+ // the project at another code than 0, one of the frame on a real failure alone) restores the copy
1740
+ // as it was and stops at « references », each deviation in its question.
1741
+ function regenerer(ctx, noms, notes = [], avantLaPasse = false) {
1727
1742
  // The notes of the debt, in a file of the run, which the command that lowers it reads.
1728
1743
  const fichierDesNotes = path.join(ctx.base.dossier, 'dette-a-abaisser.json');
1729
1744
  const toutes = lesReferences(ctx).map(r =>
@@ -1803,7 +1818,7 @@ function regenerer(ctx, noms, notes = []) {
1803
1818
  }
1804
1819
  if (!fichiers.length) {
1805
1820
  return {
1806
- texte: `La régénération (${refs.map(r => `${r.nom}, \`${r.commande}\``).join(' ; ')}) ne change aucun fichier : aucune passe ne rejoue, et les rouges de la passe finale restent, chacun à son propriétaire.`,
1821
+ texte: `La régénération (${refs.map(r => `${r.nom}, \`${r.commande}\``).join(' ; ')}) ne change aucun fichier : ${avantLaPasse ? 'la passe finale juge le lot tel quel' : 'aucune passe ne rejoue, et les rouges de la passe finale restent, chacun à son propriétaire'}.`,
1807
1822
  regenerees: [],
1808
1823
  fichiers,
1809
1824
  restreinte: null,
@@ -1811,7 +1826,7 @@ function regenerer(ctx, noms, notes = []) {
1811
1826
  }
1812
1827
  return {
1813
1828
  texte: [
1814
- `Les références régénérées sur la copie entière : ${regenerees.map(r => r.nom).join(', ')} ; le lot porte leurs fichiers, puis la passe finale restreinte à ce qu'elles changent.`,
1829
+ `Les références régénérées sur la copie entière : ${regenerees.map(r => r.nom).join(', ')} ; le lot porte leurs fichiers, puis la passe finale${avantLaPasse ? '' : " restreinte à ce qu'elles changent"}.`,
1815
1830
  '',
1816
1831
  ...regenerees.map(r => `- ${r.nom} (\`${r.commande}\`) : ${siens(r).join(', ')}`),
1817
1832
  '',
@@ -2552,8 +2567,10 @@ const ligneDeCommande = c =>
2552
2567
  // in a package of the plan; `horsTitre` the packages out of the plan that hold a red; `arbitrer`
2553
2568
  // when every red of the plan is a finding to settle; `lieux` the place of each red, `{ fichier,
2554
2569
  // gardes }`, its file (null for a red without one) and the names its finding carries (none for a
2555
- // test or a task); `tous` every red as it was read; `notes`, at the final pass, each key of the debt
2556
- // a guard wrote inscribed above what it finds, `{ garde, fichier, regle, trouve }`.
2570
+ // test or a task); `references`, out of the final pass, the references whose reds the checks saw,
2571
+ // which their regeneration lifts before the final pass; `tous` every red as it was read; `notes`,
2572
+ // at the final pass, each key of the debt a guard wrote inscribed above what it finds, `{ garde,
2573
+ // fichier, regle, trouve }`.
2557
2574
  function controles(ctx, finale, restreinte = null, reportes = null) {
2558
2575
  const liste = paquets(ctx.copie).filter(p => !p.hors);
2559
2576
  const filtres = restreinte
@@ -2584,14 +2601,17 @@ function controles(ctx, finale, restreinte = null, reportes = null) {
2584
2601
  r => !reportes.rejouee || (Boolean(r.joue) && !joues.has(r.joue))
2585
2602
  ),
2586
2603
  ];
2587
- // Out of the final pass, the reds of the plan are the developpeur's; the others (the root, a red
2588
- // no file situates, a package out of the plan, a red of a reference, which its regeneration
2589
- // lifts, 4.2) wait for it.
2590
- const deReference = r =>
2591
- referencesDesRouges(ctx, [{ fichier: r.fichier ?? null, gardes: r.gardes ?? [] }]).length > 0;
2604
+ // Out of the final pass, the reds of the plan are the developpeur's; a red of a reference goes to
2605
+ // its regeneration (4.2), before the final pass; the others (the root, a red no file situates, a
2606
+ // package out of the plan) wait for the final pass.
2607
+ const lieu = r => ({ fichier: r.fichier ?? null, gardes: r.gardes ?? [] });
2608
+ const deReference = r => referencesDesRouges(ctx, [lieu(r)]).length > 0;
2592
2609
  const siens = r => finale || (r.dansLePlan && !deReference(r));
2593
2610
  const rouges = tous.filter(siens);
2594
- const laisses = tous.filter(r => !siens(r));
2611
+ const references = finale
2612
+ ? []
2613
+ : referencesDesRouges(ctx, tous.filter(r => !siens(r) && deReference(r)).map(lieu));
2614
+ const laisses = tous.filter(r => !siens(r) && (finale || !deReference(r)));
2595
2615
  const aRepasser = resultats.filter(r => r.code === A_REPASSER);
2596
2616
  const nommer = r => `${ligneDeCommande(r)} (code ${r.code})`;
2597
2617
  const enEchec = resultats.filter(r => r.code !== 0 && r.code !== A_REPASSER);
@@ -2609,6 +2629,10 @@ function controles(ctx, finale, restreinte = null, reportes = null) {
2609
2629
  laisses.length
2610
2630
  ? ` ; laissés à la passe finale, ${laisses.length} rouge(s) hors du plan`
2611
2631
  : ''
2632
+ }${
2633
+ references.length
2634
+ ? ` ; des rouges sont ceux de références, à leur régénération avant la passe finale (${references.map(r => r.nom).join(', ')})`
2635
+ : ''
2612
2636
  }`;
2613
2637
  // Where the checks played: the final pass out of the envelope, on the whole copy or restricted
2614
2638
  // to what changed since the last review; the checks of the plan, its tests and packages, its
@@ -2662,7 +2686,8 @@ function controles(ctx, finale, restreinte = null, reportes = null) {
2662
2686
  rouges: rouges.map(r => ({ paquet: nomDuPaquet(r), texte: r.texte, detail: r.detail })),
2663
2687
  resume,
2664
2688
  horsTitre: [...new Set(rouges.map(r => r.horsTitre).filter(Boolean))].sort(),
2665
- lieux: rouges.map(r => ({ fichier: r.fichier ?? null, gardes: r.gardes ?? [] })),
2689
+ lieux: rouges.map(lieu),
2690
+ references,
2666
2691
  tous,
2667
2692
  notes: finale
2668
2693
  ? resultats.flatMap(r =>
@@ -2881,6 +2906,9 @@ async function derouler(ctx, debut) {
2881
2906
  // the testwriter, the sending and the handover as its report, then the proof and the
2882
2907
  // developpeur.
2883
2908
  if (ctx.renvoiAuTestwriter) {
2909
+ if (empreinte(ctx) === avant) {
2910
+ inscrire(ctx, { role: AUTEUR_DU_CIRCUIT, etape: CODE, inchange: true });
2911
+ }
2884
2912
  throw new Arret(
2885
2913
  'sans-livraison',
2886
2914
  `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}`
@@ -2961,11 +2989,16 @@ async function derouler(ctx, debut) {
2961
2989
  };
2962
2990
  const suivante = tentative + 1;
2963
2991
  // A final pass with a red of a reference, mixed with others or not, or a debt the lot
2964
- // lowers: their regeneration, once for this pass; the reds that remain then go each to
2965
- // its owner.
2992
+ // lowers: their regeneration, once for this pass, but for a reference the checks had
2993
+ // regenerated on this same tree, whose inputs have not changed since; the reds that remain
2994
+ // then go each to its owner.
2995
+ const dejaRegenerees =
2996
+ ctx.regenereSur && ctx.regenereSur.arbre === passe.arbre ? ctx.regenereSur.noms : [];
2966
2997
  const aRegenerer =
2967
2998
  passeFinale && !regeneration && (k.rouge || k.notes.length > 0)
2968
- ? referencesDesRouges(ctx, k.lieux, k.notes.length > 0)
2999
+ ? referencesDesRouges(ctx, k.lieux, k.notes.length > 0).filter(
3000
+ r => !dejaRegenerees.includes(r.nom)
3001
+ )
2969
3002
  : [];
2970
3003
  if (aRegenerer.length) {
2971
3004
  const noms = aRegenerer.map(r => r.nom);
@@ -3012,6 +3045,21 @@ async function derouler(ctx, debut) {
3012
3045
  arreter('controles', null);
3013
3046
  } else if (k.aRepasser) {
3014
3047
  arreter('a-repasser', null);
3048
+ } else if (!passeFinale && k.references.length) {
3049
+ // The checks green but for reds of references: their regeneration, then the final pass,
3050
+ // which plays once, on the regenerated tree, as make remakes a generated file before
3051
+ // what reads it.
3052
+ geste(ctx, 'regeneration');
3053
+ ecrireRapport(ctx, 'controles', `${k.resume}.`, resultat('vert'));
3054
+ ctx.renvoiAuTestwriter = false;
3055
+ ctx.aRegenerer = {
3056
+ noms: k.references.map(r => r.nom),
3057
+ notes: [],
3058
+ avantLaPasse: true,
3059
+ };
3060
+ etape = REFERENCES;
3061
+ tentative = 0;
3062
+ finale = true;
3015
3063
  } else {
3016
3064
  ecrireRapport(ctx, 'controles', `${k.resume}.`, resultat('vert'));
3017
3065
  // Green checks: a sending of the developpeur to the testwriter may come again.
@@ -3045,16 +3093,22 @@ async function derouler(ctx, debut) {
3045
3093
  "L'état du circuit ne garde pas les références à régénérer : la passe finale les redonne (`--depuis developpeur`)."
3046
3094
  );
3047
3095
  }
3048
- const g = regenerer(ctx, a.noms, a.notes);
3096
+ const g = regenerer(ctx, a.noms, a.notes, Boolean(a.avantLaPasse));
3049
3097
  ecrireRapport(ctx, 'references', g.texte, {
3050
3098
  regenerees: g.regenerees,
3051
3099
  fichiers: g.fichiers,
3052
3100
  });
3053
- ctx.regeneration = {
3054
- restreinte: g.restreinte,
3055
- entiere: a.entiere,
3056
- reportes: { rouges: a.rouges, rejouee: g.fichiers.length > 0 },
3057
- };
3101
+ // After the checks, the final pass that is due, on the regenerated tree, which does not
3102
+ // regenerate again the references just regenerated on it; after a final pass, the pass
3103
+ // restricted to what the regeneration changed, with the reds of the pass before.
3104
+ ctx.regenereSur = a.avantLaPasse ? { arbre: arbreDeLaCopie(ctx), noms: a.noms } : null;
3105
+ ctx.regeneration = a.avantLaPasse
3106
+ ? null
3107
+ : {
3108
+ restreinte: g.restreinte,
3109
+ entiere: a.entiere,
3110
+ reportes: { rouges: a.rouges, rejouee: g.fichiers.length > 0 },
3111
+ };
3058
3112
  ctx.aRegenerer = null;
3059
3113
  etape = CONTROLES;
3060
3114
  finale = true;
@@ -3270,19 +3324,20 @@ function depart(ctx, e) {
3270
3324
  }
3271
3325
 
3272
3326
  // The end of the run, its exit code <code>: an end on a stop kept with the circuit's results
3273
- // (`montee`: its code, its stop and who must answer its question, the supervisor for a stop
3274
- // without one, as an end at 75 he replays), from which the
3275
- // bilan measures the wait to the run that answers it, then the ticket's bilan at the ticket
3327
+ // (`montee`: its code, its stop and the supervisor's session that ran it, `superviseur`, when
3328
+ // Claude Code names it), from which the bilan measures the wait to the run that answers it, the
3329
+ // owner's when he writes in that session meanwhile, then the ticket's bilan at the ticket
3276
3330
  // (scripts/bilan.mjs); a bilan it cannot write leaves the code as it is.
3277
3331
  function aLaFin(ctx, code) {
3278
3332
  try {
3279
3333
  if (code !== 0) {
3334
+ const superviseur = process.env.CLAUDE_CODE_SESSION_ID;
3280
3335
  inscrire(ctx, {
3281
3336
  role: AUTEUR_DU_CIRCUIT,
3282
3337
  montee: {
3283
3338
  code,
3284
3339
  raison: ctx.courant?.raison ?? null,
3285
- qui: ctx.courant?.question?.qui ?? SUPERVISEUR,
3340
+ ...(superviseur ? { superviseur } : {}),
3286
3341
  },
3287
3342
  });
3288
3343
  }
@@ -29,7 +29,8 @@
29
29
  // dependencies (the `deps` and `data` of Bazel, the `implicitDependencies` of Nx).
30
30
  // - The readers of an element are the other components that: its provider's `## Consommateurs`
31
31
  // declares for it, or for `*` (`consommateurs`); import it, or the whole provider, in their
32
- // production code (`import`, the uses of scripts/consommateurs.mjs); hold a test file that names
32
+ // production code, or in their tests for a package of the shared test material (`import`, the
33
+ // uses of scripts/consommateurs.mjs); hold a test file that names
33
34
  // it, as a whole word, and imports the provider (the test file's path).
34
35
  // - By the types (scripts/references-par-les-types.mjs): each element, a member of a type
35
36
  // included, resolved by TypeScript's language service over the components' `tsconfig.json`;
@@ -36,6 +36,7 @@ import { spawnSync } from 'node:child_process';
36
36
  import { existsSync, readFileSync } from 'node:fs';
37
37
  import path from 'node:path';
38
38
  import { pathToFileURL } from 'node:url';
39
+ import { lireLigne } from './consommateurs.mjs';
39
40
  import { trancher } from './dette.mjs';
40
41
  import { aVerifier, marques } from './interfaces-contre-code.mjs';
41
42
 
@@ -90,18 +91,6 @@ function section(description, titre) {
90
91
  return out.join('\n');
91
92
  }
92
93
 
93
- // The consumer and the names of the `## Consommateurs` line <ligne>
94
- // (``- `<consommateur>` : <nom>, <nom>``), or null for a line of another form.
95
- function lireLigne(ligne) {
96
- const m = /^[-*]\s+`?([^`:\s]+)`?\s*:\s*(.+)$/.exec(ligne);
97
- if (!m) return null;
98
- const noms = m[2]
99
- .split(',')
100
- .map(s => s.replace(/`/g, '').trim())
101
- .filter(Boolean);
102
- return { consommateur: m[1], noms };
103
- }
104
-
105
94
  // The names of <noms> the text <texte> does not name word for word: each one whole, with no
106
95
  // character of a name (a letter, a digit, `_`, `$`, `-`) beside it; `*`, a namespace, between
107
96
  // backquotes.
@@ -135,14 +124,16 @@ export function verifier(racine, env = process.env) {
135
124
  const head = git(racine, 'show', `HEAD:${rel}`);
136
125
  const lignesAvant = head.status === 0 ? lignesConsommateurs(head.stdout) : [];
137
126
  const avant = new Set(lignesAvant);
138
- // The names each consumer of HEAD's section reads.
127
+ // The names each consumer of HEAD's section reads (`lireLigne` of scripts/consommateurs.mjs,
128
+ // the one reading of such a line: a line that is no list of names gives none).
139
129
  const nomsAvant = new Map();
140
- for (const l of lignesAvant.map(lireLigne).filter(Boolean)) {
130
+ for (const l of lignesAvant.map(lireLigne).filter(l => l?.noms)) {
141
131
  nomsAvant.set(l.consommateur, new Set([...(nomsAvant.get(l.consommateur) ?? []), ...l.noms]));
142
132
  }
143
133
  for (const ligne of lignesConsommateurs(readFileSync(iface, 'utf8'))) {
144
134
  if (avant.has(ligne)) continue;
145
- const lue = lireLigne(ligne);
135
+ const l = lireLigne(ligne);
136
+ const lue = l?.noms ? l : null;
146
137
  const deja = lue && nomsAvant.get(lue.consommateur);
147
138
  const ajoutes = lue ? lue.noms.filter(n => !deja?.has(n)) : null;
148
139
  changees.push({ rel, ligne, lue, ajoutes });
@@ -7,16 +7,23 @@
7
7
  // - `a` : duree, tempo
8
8
  // - `c` : *
9
9
  //
10
- // This check reads what the production code of every component imports from every other, and
11
- // refuses (exit 1) a use that the provider's interface does not declare, and a declared name that
10
+ // This check reads what the production code of every component imports from every other, and what
11
+ // its tests import from a package of the shared test material (`matieres`), whose only readers are
12
+ // tests, as knip counts test files as entries out of its `--production` mode; it refuses (exit 1) a use that the provider's interface does not declare, and a declared name that
12
13
  // no code of its consumer uses, as ESLint's `no-unused-vars` refuses a name nothing uses (BP
13
14
  // 320.3.2.1: « LEVEL_TYPES » declared for 020-loader, only reported, caught by its second review).
14
- // `*` stands for a namespace, default, re-export-all or side-effect import. A refusal inscribed in
15
- // the project's debt (`grillhouse-dette.json`, see `dette.mjs`) passes, keyed by the provider's
16
- // interface and `usage-non-declare` or `declare-non-utilise` (`homonyme` for two components of one
17
- // name, keyed by the first path). The debt of the new rule is inscribed once, when a project
18
- // updates to it (scripts/migrations/0.24.4-noms-declares-inutilises.mjs); in a ticket, the name
19
- // leaves its line.
15
+ // `*` stands for a namespace, default, re-export-all or side-effect import, and for a dynamic
16
+ // import not destructured; a literal dynamic import destructured gives its names, as knip reads
17
+ // it. A bullet of the section is a list of names, each a JavaScript identifier or `*`: a bullet of
18
+ // another form, with or without « : », is refused, and gives no name; a paragraph is no consumer
19
+ // and passes. A refusal inscribed in the project's debt
20
+ // (`grillhouse-dette.json`, see `dette.mjs`) passes, keyed by the provider's interface and
21
+ // `usage-non-declare`, `declare-non-utilise` or `ligne-mal-formee` (`homonyme` for two components
22
+ // of one name, keyed by the first path). The debt of a new rule is inscribed once, when a project
23
+ // updates to it (scripts/migrations/0.24.4-noms-declares-inutilises.mjs,
24
+ // scripts/migrations/0.24.6-lignes-mal-formees.mjs,
25
+ // scripts/migrations/0.24.7-matiere-dans-les-tests.mjs); in a ticket, the name leaves its line, and a
26
+ // line of prose is written as a list of names.
20
27
  //
21
28
  // npx grillhouse consommateurs run from the repository root
22
29
  //
@@ -25,8 +32,9 @@
25
32
  // `docs/agents/hors-cadre.txt`: neither read nor checked, as provider or as consumer. Every check
26
33
  // of the frame enumerates the components through `composants`. In a repository of packages, such a
27
34
  // package stays a workspace, and Turborepo plays none of its tasks (scripts/turbo-des-paquets.mjs
28
- // writes its configuration). For the check of the uses, test files,
29
- // `dist/`, `docs/` and `node_modules/` are not production code and are not read; nor are Vite's
35
+ // writes its configuration). For the check of the uses, test files (under a folder `test/`,
36
+ // `tests/` or `__tests__/`, or named `*.test.*`, `*.spec.*`) count only for their imports of a
37
+ // package of the material; `dist/`, `docs/` and `node_modules/` are never read, nor are Vite's
30
38
  // temporary files, and a file gone between the walk and its read is passed over (`parcourir`).
31
39
  // The identity of a component is its name: two directories of the same name, one under `packages/`
32
40
  // and one under `src/`, are refused, both paths named (the way npm workspaces, Nx and Cargo refuse
@@ -111,36 +119,80 @@ export function matieres(racine) {
111
119
  return found;
112
120
  }
113
121
 
114
- // The declared consumers of an interface text: Map consumer → Set of element names.
115
- export function declares(texte) {
116
- const out = new Map();
122
+ // A name of a `## Consommateurs` line: a JavaScript identifier, or `*`.
123
+ const NOM = /^(?:\*|[\p{ID_Start}$_][\p{ID_Continue}$‌‍]*)$/u;
124
+
125
+ // The consumer and the names of the bullet <ligne> of a `## Consommateurs` section, trimmed, in
126
+ // its one form ``- `<consommateur>` : <nom>, <nom>``: `{ consommateur, noms }`; `{ consommateur:
127
+ // null, noms: null }` for a bullet of another form, with or without « : », or whose piece after
128
+ // « : » is not a name (`NOM`), a bullet of prose; null for a line that is no bullet (a paragraph).
129
+ // The one reading of such a line, for this guard and for scripts/consommateurs-arbitres.mjs.
130
+ export function lireLigne(ligne) {
131
+ if (!/^[-*]\s+\S/.test(ligne)) return null;
132
+ const m = /^[-*]\s+`?([^`:\s]+)`?\s*:\s*(.+)$/.exec(ligne);
133
+ const noms = m
134
+ ? m[2]
135
+ .split(',')
136
+ .map(s => s.replace(/`/g, '').trim())
137
+ .filter(Boolean)
138
+ : [];
139
+ return noms.length && noms.every(n => NOM.test(n))
140
+ ? { consommateur: m[1], noms }
141
+ : { consommateur: null, noms: null };
142
+ }
143
+
144
+ // The bullets of the section `## Consommateurs` of an interface text, each read by `lireLigne`:
145
+ // [{ texte, consommateur, noms }]; a paragraph is none. The section ends at the next heading of any
146
+ // level: the generated part (scripts/interfaces-contre-code.mjs) opens on the heading of its first
147
+ // element, so its bullets are never read.
148
+ function lignesDeConsommateurs(texte) {
149
+ const out = [];
117
150
  let dedans = false;
118
151
  for (const l of texte.split('\n')) {
119
152
  if (/^#{1,6} /.test(l)) {
120
153
  dedans = /^## Consommateurs\s*$/.test(l);
121
154
  continue;
122
155
  }
123
- const m = dedans && /^[-*]\s+`?([^`:\s]+)`?\s*:\s*(.+)$/.exec(l.trim());
124
- if (!m) continue;
125
- const noms = m[2]
126
- .split(',')
127
- .map(s => s.replace(/`/g, '').trim())
128
- .filter(Boolean);
129
- out.set(m[1], new Set(noms));
156
+ const lue = dedans ? lireLigne(l.trim()) : null;
157
+ if (lue) out.push({ texte: l.trim(), ...lue });
130
158
  }
131
159
  return out;
132
160
  }
133
161
 
134
- // The imports of a source text: [{ spec, noms }].
162
+ // The declared consumers of an interface text: Map consumer → Set of element names. A line that
163
+ // is no list of names gives none.
164
+ export function declares(texte) {
165
+ return new Map(
166
+ lignesDeConsommateurs(texte)
167
+ .filter(l => l.noms)
168
+ .map(l => [l.consommateur, new Set(l.noms)])
169
+ );
170
+ }
171
+
172
+ // The imports of a source text: [{ spec, noms }]. A dynamic `import` or a `require` of a literal
173
+ // specifier, destructured in a declaration (`const { a, b: c } = await import(…)`), gives the
174
+ // names it destructures, as a static import, a rest element or `default` `*`; one not
175
+ // destructured gives `*`,
176
+ // as knip reads them. A specifier computed at run time is not read.
135
177
  export function imports(source) {
136
178
  const out = [];
137
179
  // A static clause holds only names, braces, commas, `*`, `as` and `type`: it never crosses a
138
180
  // `;`, a quote, a parenthesis or an `=`, so it never runs from one statement into the next.
139
181
  const re =
140
- /^\s*(?:import|export)\s+(?:type\s+)?([^;'"()=]*?)\s*from\s*['"]([^'"]+)['"]|^\s*import\s*['"]([^'"]+)['"]|\b(?:require|import)\(\s*['"]([^'"]+)['"]\s*\)/gm;
182
+ /^\s*(?:import|export)\s+(?:type\s+)?([^;'"()=]*?)\s*from\s*['"]([^'"]+)['"]|^\s*import\s*['"]([^'"]+)['"]|\b(?:const|let|var)\s*\{([^{}]*)\}\s*=\s*(?:await\s+)?(?:require|import)\(\s*['"]([^'"]+)['"]\s*\)|\b(?:require|import)\(\s*['"]([^'"]+)['"]\s*\)/gm;
141
183
  for (const m of source.matchAll(re)) {
142
- if (m[3] || m[4]) {
143
- out.push({ spec: m[3] ?? m[4], noms: ['*'] });
184
+ if (m[5]) {
185
+ const noms = m[4]
186
+ .split(',')
187
+ .map(p => p.trim())
188
+ .filter(Boolean)
189
+ .map(p => (p.startsWith('...') ? '*' : p.split(/[:=]/)[0].trim()))
190
+ .map(n => (n === 'default' ? '*' : n));
191
+ out.push({ spec: m[5], noms });
192
+ continue;
193
+ }
194
+ if (m[3] || m[6]) {
195
+ out.push({ spec: m[3] ?? m[6], noms: ['*'] });
144
196
  continue;
145
197
  }
146
198
  const clause = m[1];
@@ -206,13 +258,18 @@ export function parcourir(chemin, sauter = () => false) {
206
258
  // The text of the file <f> a walk listed, or null when it is gone since.
207
259
  export const lireSiPresent = f => siPresent(x => readFileSync(x, 'utf8'), f, null);
208
260
 
209
- // The production source files under <dir>: test folders and test files left out.
261
+ // The source files under <dir>: [{ f, test }], `test` for a file under a test folder or of a test
262
+ // name.
210
263
  function fichiers(dir) {
211
264
  const nom = p => path.basename(p);
212
- return parcourir(
213
- dir,
214
- p => SKIP.has(nom(p)) || nom(p).startsWith('.') || TEST_DIR.has(nom(p))
215
- ).filter(p => SOURCE.test(nom(p)) && !isTest(nom(p)));
265
+ const sousTest = p =>
266
+ path
267
+ .relative(dir, path.dirname(p))
268
+ .split(path.sep)
269
+ .some(s => TEST_DIR.has(s));
270
+ return parcourir(dir, p => SKIP.has(nom(p)) || nom(p).startsWith('.'))
271
+ .filter(p => SOURCE.test(nom(p)))
272
+ .map(f => ({ f, test: isTest(nom(f)) || sousTest(f) }));
216
273
  }
217
274
 
218
275
  // The component an import specifier reaches from <fichier>, other than <soi>, or null.
@@ -230,14 +287,16 @@ function fournisseur(spec, fichier, tous, soi) {
230
287
  );
231
288
  }
232
289
 
233
- // What each component really uses of the others: Map provider → Map consumer → Set of names.
290
+ // What each component really uses of the others: Map provider → Map consumer → Set of names. Its
291
+ // production code counts for every provider, its tests for a package of the material only.
234
292
  export function utilise(racine, tous = composants(racine)) {
235
293
  const out = new Map();
294
+ const matiere = new Set(matieres(racine).map(m => m.nom));
236
295
  for (const c of tous) {
237
- for (const f of fichiers(c.dir)) {
296
+ for (const { f, test } of fichiers(c.dir)) {
238
297
  for (const { spec, noms } of imports(lireSiPresent(f) ?? '')) {
239
298
  const p = fournisseur(spec, f, tous, c);
240
- if (!p) continue;
299
+ if (!p || (test && !matiere.has(p.nom))) continue;
241
300
  if (!out.has(p.nom)) out.set(p.nom, new Map());
242
301
  const parConsommateur = out.get(p.nom);
243
302
  if (!parConsommateur.has(c.nom)) parConsommateur.set(c.nom, new Set());
@@ -252,6 +311,10 @@ export function utilise(racine, tous = composants(racine)) {
252
311
  // and the name, which the migration of 0.24.4 reports line by line.
253
312
  export const DECLARE_NON_UTILISE = 'declare-non-utilise';
254
313
 
314
+ // The rule of a bullet of a `## Consommateurs` section that is no list of names; its finding
315
+ // names the line (`texte`), which the migration of 0.24.6 reports.
316
+ export const LIGNE_MAL_FORMEE = 'ligne-mal-formee';
317
+
255
318
  // The refusals of the components that share a name: one finding per name, both paths.
256
319
  function homonymes(racine) {
257
320
  const parNom = new Map();
@@ -268,9 +331,10 @@ function homonymes(racine) {
268
331
  }
269
332
 
270
333
  // The refusals, as findings `{ fichier, regle, message }` the debt (`dette.mjs`) judges: the uses
271
- // no interface declares (`usage-non-declare`), and the declared names no code of their consumer
272
- // uses (`declare-non-utilise`). A declared consumer out of the frame is passed over: its code is
273
- // not read.
334
+ // no interface declares (`usage-non-declare`), the declared names no code of their consumer uses
335
+ // (`declare-non-utilise`), and the lines of a section `## Consommateurs` that are no list of names
336
+ // (`ligne-mal-formee`), which give no name. A declared consumer out of the frame is passed over:
337
+ // its code is not read.
274
338
  export function verifier(racine) {
275
339
  const tous = composants(racine);
276
340
  const hors = horsCadre(racine);
@@ -279,7 +343,16 @@ export function verifier(racine) {
279
343
  for (const p of tous) {
280
344
  const iface = path.join(p.dir, 'docs', 'INTERFACE.md');
281
345
  const rel = path.relative(racine, iface);
282
- const declare = existsSync(iface) ? declares(readFileSync(iface, 'utf8')) : new Map();
346
+ const contenu = existsSync(iface) ? readFileSync(iface, 'utf8') : '';
347
+ const declare = declares(contenu);
348
+ for (const { texte } of lignesDeConsommateurs(contenu).filter(l => !l.noms)) {
349
+ refus.push({
350
+ fichier: rel,
351
+ regle: LIGNE_MAL_FORMEE,
352
+ texte,
353
+ message: `${rel} § Consommateurs : la ligne « ${texte} » n'est pas une liste de noms ; écrire la ligne en liste de noms : - \`consommateur\` : nom, nom.`,
354
+ });
355
+ }
283
356
  const utilises = reel.get(p.nom) ?? new Map();
284
357
  for (const [consommateur, noms] of utilises) {
285
358
  const permis = declare.get(consommateur) ?? new Set();
@@ -316,7 +389,7 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
316
389
  const { refus, lignes } = trancher(racine, 'consommateurs', verdict.refus);
317
390
  for (const r of refus) process.stderr.write(`⛔ ${r.message}\n`);
318
391
  for (const l of lignes) process.stderr.write(`${l}\n`);
319
- if (refus.some(r => r.regle !== DECLARE_NON_UTILISE)) {
392
+ if (refus.some(r => r.regle !== DECLARE_NON_UTILISE && r.regle !== LIGNE_MAL_FORMEE)) {
320
393
  process.stderr.write(
321
394
  "Une consommation nouvelle se décide (le titre du ticket, sa section « Architecture » ou sa section « Noms publiés » qui la nomment, sinon l'arbitrage du superviseur), puis entre dans la section « Consommateurs » de l'interface du fournisseur.\n"
322
395
  );
@@ -92,6 +92,9 @@ const LIRE_GIT = [
92
92
  'Bash(git -C * ls-files*)',
93
93
  'Bash(git -C * grep*)',
94
94
  ];
95
+ // The test tool run directly, Vitest or Turborepo that plays it (charter, « Aucun agent ne lance
96
+ // l'outil de test directement »): `npm test` and `npm run verifier` play it with what it depends on.
97
+ // `turbo *` ends on a word, so `npx grillhouse turbo-des-paquets` stays open.
95
98
  const TEST_DIRECT = [
96
99
  'Bash(vitest*)',
97
100
  'Bash(npx vitest*)',
@@ -99,6 +102,12 @@ const TEST_DIRECT = [
99
102
  'Bash(npm exec vitest*)',
100
103
  'Bash(npm exec * vitest*)',
101
104
  'Bash(node_modules/.bin/vitest*)',
105
+ 'Bash(turbo *)',
106
+ 'Bash(npx turbo *)',
107
+ 'Bash(npx * turbo *)',
108
+ 'Bash(npm exec turbo *)',
109
+ 'Bash(npm exec * turbo *)',
110
+ 'Bash(node_modules/.bin/turbo *)',
102
111
  ];
103
112
  // The skills Claude Code keeps listed when its own are off (`disableBundledSkills`), measured on
104
113
  // Claude Code 2.1.305.