@roomi-fields/grillhouse 0.33.1 → 0.34.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 (124) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +63 -0
  3. package/cadre/templates/projet/CLAUDE.md +9 -3
  4. package/charte.md +23 -6
  5. package/dist/temporal/circuit/activites.d.ts +3 -1
  6. package/dist/temporal/circuit/activites.js +25 -1
  7. package/dist/temporal/circuit/activites.js.map +1 -1
  8. package/dist/temporal/circuit/appel.d.ts +19 -0
  9. package/dist/temporal/circuit/appel.js +93 -0
  10. package/dist/temporal/circuit/appel.js.map +1 -0
  11. package/dist/temporal/circuit/client.d.ts +7 -0
  12. package/dist/temporal/circuit/client.js +20 -0
  13. package/dist/temporal/circuit/client.js.map +1 -1
  14. package/dist/temporal/circuit/commande.js +27 -87
  15. package/dist/temporal/circuit/commande.js.map +1 -1
  16. package/dist/temporal/circuit/contrat.d.ts +19 -0
  17. package/dist/temporal/circuit/contrat.js +2 -0
  18. package/dist/temporal/circuit/contrat.js.map +1 -1
  19. package/dist/temporal/circuit/deroule.js +86 -11
  20. package/dist/temporal/circuit/deroule.js.map +1 -1
  21. package/dist/temporal/file/activites.d.ts +3 -0
  22. package/dist/temporal/file/activites.js +9 -0
  23. package/dist/temporal/file/activites.js.map +1 -1
  24. package/dist/temporal/file/contrat.d.ts +58 -0
  25. package/dist/temporal/file/deroule.d.ts +8 -1
  26. package/dist/temporal/file/deroule.js +100 -2
  27. package/dist/temporal/file/deroule.js.map +1 -1
  28. package/dist/temporal/nuits/contrat.d.ts +2 -0
  29. package/dist/temporal/nuits/deroule.js +3 -0
  30. package/dist/temporal/nuits/deroule.js.map +1 -1
  31. package/dist/temporal/places/activites.d.ts +8 -0
  32. package/dist/temporal/places/activites.js +12 -1
  33. package/dist/temporal/places/activites.js.map +1 -1
  34. package/dist/temporal/places/client.d.ts +8 -1
  35. package/dist/temporal/places/client.js +25 -2
  36. package/dist/temporal/places/client.js.map +1 -1
  37. package/dist/temporal/places/contrat.d.ts +35 -3
  38. package/dist/temporal/places/contrat.js +5 -4
  39. package/dist/temporal/places/contrat.js.map +1 -1
  40. package/dist/temporal/places/deroule.js +55 -9
  41. package/dist/temporal/places/deroule.js.map +1 -1
  42. package/dist/temporal/tickets/activites.d.ts +3 -0
  43. package/dist/temporal/tickets/activites.js +73 -4
  44. package/dist/temporal/tickets/activites.js.map +1 -1
  45. package/dist/temporal/tickets/contrat.d.ts +31 -0
  46. package/dist/temporal/tickets/deroule.js +61 -10
  47. package/dist/temporal/tickets/deroule.js.map +1 -1
  48. package/docs/ARCHITECTURE.md +213 -57
  49. package/docs/CADRE.md +6 -1
  50. package/docs/INTERFACE.md +24 -8
  51. package/hooks/crochet.mjs +17 -2
  52. package/hooks/hooks.json +24 -0
  53. package/package.json +1 -1
  54. package/scripts/activites.mjs +77 -14
  55. package/scripts/aiguillage.mjs +2 -0
  56. package/scripts/attente-a-l-arret.mjs +141 -0
  57. package/scripts/attente-au-tour.mjs +32 -16
  58. package/scripts/avancement.mjs +5 -3
  59. package/scripts/branche-de-nuit.mjs +63 -3
  60. package/scripts/circuit.mjs +57 -4
  61. package/scripts/circuits-du-serveur.mjs +34 -1
  62. package/scripts/commandes-composees.mjs +11 -4
  63. package/scripts/copies-finies.mjs +43 -29
  64. package/scripts/crochets.mjs +1 -1
  65. package/scripts/dette.mjs +55 -4
  66. package/scripts/disque-des-copies.d.mts +28 -0
  67. package/scripts/disque-des-copies.mjs +155 -0
  68. package/scripts/droits.mjs +2 -0
  69. package/scripts/faits-du-circuit.mjs +24 -0
  70. package/scripts/file-des-tickets.d.mts +16 -0
  71. package/scripts/file-des-tickets.mjs +65 -7
  72. package/scripts/gardes-du-cadre.mjs +4 -2
  73. package/scripts/integration/file.mjs +302 -5
  74. package/scripts/jointure.d.ts +33 -1
  75. package/scripts/langages/cargo/commandes.mjs +71 -10
  76. package/scripts/langages/cargo/composants.mjs +12 -4
  77. package/scripts/langages/cargo/executables-de-tests.mjs +118 -0
  78. package/scripts/langages/cargo/exemples.mjs +17 -3
  79. package/scripts/langages/cargo/index.mjs +8 -3
  80. package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +2 -2
  81. package/scripts/langages/cargo/migrations/0.34.0-executables-de-tests.mjs +35 -0
  82. package/scripts/langages/cargo/squelette.mjs +8 -3
  83. package/scripts/langages/cargo/tailles-des-tests.mjs +68 -6
  84. package/scripts/langages/cargo/tests-de-head.mjs +12 -9
  85. package/scripts/langages/cargo/verdict.mjs +40 -14
  86. package/scripts/langages/python/commandes.mjs +11 -2
  87. package/scripts/langages/python/index.mjs +12 -4
  88. package/scripts/langages/python/verdict.mjs +8 -1
  89. package/scripts/langages/typescript/index.mjs +9 -2
  90. package/scripts/langages/typescript/resume-du-lanceur.mjs +86 -0
  91. package/scripts/langages/typescript/tests.mjs +1 -1
  92. package/scripts/langages/typescript/verdict.mjs +4 -60
  93. package/scripts/langages/typescript/verifier.mjs +1 -1
  94. package/scripts/langages/typescript/vitest-config/changements.mjs +12 -7
  95. package/scripts/langages/typescript/vitest-config/lances.mjs +45 -0
  96. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +1 -0
  97. package/scripts/messages-non-lus.mjs +166 -0
  98. package/scripts/mesure-de-la-machine.mjs +7 -4
  99. package/scripts/migrations-des-gardes.mjs +168 -0
  100. package/scripts/places-de-la-machine.mjs +44 -40
  101. package/scripts/places-du-serveur.mjs +82 -14
  102. package/scripts/plafond-de-la-machine.d.mts +18 -0
  103. package/scripts/plafond-de-la-machine.mjs +45 -0
  104. package/scripts/recommencer.d.mts +4 -0
  105. package/scripts/recommencer.mjs +29 -0
  106. package/scripts/regles-des-places.d.mts +35 -0
  107. package/scripts/regles-des-places.mjs +82 -1
  108. package/scripts/resultats.mjs +38 -4
  109. package/scripts/retirer-les-copies-finies.mjs +11 -7
  110. package/scripts/seances.mjs +1 -1
  111. package/scripts/services-du-noyau.mjs +1 -0
  112. package/scripts/sous-commandes.mjs +2 -0
  113. package/scripts/superviseur.mjs +235 -56
  114. package/scripts/tableau.mjs +385 -247
  115. package/scripts/taches-du-graphe.mjs +32 -5
  116. package/scripts/ticket-du-circuit.mjs +25 -0
  117. package/scripts/transitions.d.mts +27 -1
  118. package/scripts/transitions.mjs +96 -4
  119. package/scripts/verrou-de-machine.mjs +41 -17
  120. package/skills/explorateur/SKILL.md +8 -2
  121. package/skills/pitmaster/SKILL.md +18 -15
  122. package/skills/pitmaster/references/tour.md +3 -1
  123. package/skills/questionneur/SKILL.md +5 -1
  124. package/skills/testwriter/SKILL.md +32 -6
@@ -48,7 +48,7 @@ import path from 'node:path';
48
48
  import { fileURLToPath } from 'node:url';
49
49
  import { composants as lesComposants, matieres } from './consommateurs.mjs';
50
50
  import { elementsDuLot } from './elements-du-lot.mjs';
51
- import { A_ELAGUER, lireSarif, RESULTATS } from '../../resultats.mjs';
51
+ import { estNoteDeDette, lireSarif, RESULTATS } from '../../resultats.mjs';
52
52
  import { lecteurs } from './lecteurs.mjs';
53
53
  import { estUnTest, manifestes, soeurDAvant } from './regle-des-tests.mjs';
54
54
  import {
@@ -57,6 +57,7 @@ import {
57
57
  SCRIPT_DES_TESTS,
58
58
  } from '../../services-du-noyau.mjs';
59
59
  import { verdict } from './verdict.mjs';
60
+ import { garderLesResumes, lireLesResumes, resumesDuLancement } from './resume-du-lanceur.mjs';
60
61
  import { miseAJour } from './mise-a-jour.mjs';
61
62
  import { squelette } from './squelette.mjs';
62
63
  import { estHorsDuJour } from './vitest-config/cibles.mjs';
@@ -133,7 +134,7 @@ function constatsDe(racine, script, args) {
133
134
  env: { ...process.env, [RESULTATS]: dossier },
134
135
  encoding: 'utf8',
135
136
  });
136
- const constats = lireSarif(dossier).constats.filter(k => k.genre !== A_ELAGUER);
137
+ const constats = lireSarif(dossier).constats.filter(k => !estNoteDeDette(k));
137
138
  if (r.status !== 0 && constats.length === 0) {
138
139
  return [{ message: `${path.basename(script)} rouge (code ${r.status ?? r.signal}).` }];
139
140
  }
@@ -155,6 +156,8 @@ const joueDesTests = (_racine, composant) =>
155
156
 
156
157
  export default {
157
158
  nom: 'typescript',
159
+ // The expected size of a copy before any is measured: its node_modules, about 0.5 to 1 GB (2026-11-11).
160
+ tailleDUneCopie: 1024 ** 3,
158
161
  manifeste: 'package.json',
159
162
  // The name a package.json gives its package; its internal dependencies are the package.json's
160
163
  // own, so no other manifest holds any.
@@ -265,6 +268,10 @@ export default {
265
268
  // A night test, a bench or a time witness (./vitest-config/cibles.mjs, `estHorsDuJour`).
266
269
  horsDuJour: (chemin, racine) => estHorsDuJour(path.resolve(racine, chemin)),
267
270
  soeurDAvant,
271
+ // The summary of a run of Turborepo, which the core serves to the other modules.
272
+ resumesDuLancement,
273
+ garderLesResumes,
274
+ lireLesResumes,
268
275
  // Its tool plays HEAD's version of each test file beside it (`soeurDAvant`): no tree, no name
269
276
  // to read.
270
277
  arbreDAvant: () => false,
@@ -0,0 +1,86 @@
1
+ // The summary of a run of Turborepo (`turbo run … --summarize`, `.turbo/runs/<id>.json`), read and
2
+ // kept once, here: the module typescript drives Turborepo, and the join serves these members to the
3
+ // modules cargo and python through the services of the core (`tachesDuVerdict`,
4
+ // scripts/taches-du-graphe.mjs).
5
+ //
6
+ // - `resumesDuLancement` names the summaries present in a project before a run.
7
+ // - `garderLesResumes` moves the summaries a run wrote into `<dossier>/turbo/`, the results
8
+ // directory (`GRILLHOUSE_RESULTATS`, scripts/resultats.mjs) its environment names, or removes
9
+ // them without one.
10
+ // - `lireLesResumes` gives each task of those summaries, its package and directory, its script,
11
+ // its exit code, its cache status and its log file (from the root), and whether it plays the
12
+ // tests of its package (`test:unit`).
13
+ import {
14
+ copyFileSync,
15
+ existsSync,
16
+ mkdirSync,
17
+ readdirSync,
18
+ readFileSync,
19
+ rmdirSync,
20
+ rmSync,
21
+ } from 'node:fs';
22
+ import path from 'node:path';
23
+ import { RESULTATS } from '../../resultats.mjs';
24
+ import { SCRIPT_DES_TESTS } from '../../services-du-noyau.mjs';
25
+
26
+ const TURBO = 'turbo';
27
+
28
+ const lireJson = f => {
29
+ try {
30
+ return JSON.parse(readFileSync(f, 'utf8'));
31
+ } catch {
32
+ return null;
33
+ }
34
+ };
35
+
36
+ // The names of the summaries of <racine> before a run; none without `.turbo/runs`.
37
+ export function resumesDuLancement(racine) {
38
+ const runs = path.join(racine, '.turbo', 'runs');
39
+ return new Set(existsSync(runs) ? readdirSync(runs) : []);
40
+ }
41
+
42
+ // Moves the summaries that a run in <racine> wrote (`.turbo/runs/*.json` absent from <avant>, the
43
+ // names there before it) into the results directory <env> names; removes them without it.
44
+ // `.turbo/runs` goes too when the run created it (<avant> empty) and it is left empty.
45
+ export function garderLesResumes(racine, avant, env = process.env) {
46
+ const runs = path.join(racine, '.turbo', 'runs');
47
+ const neufs = (existsSync(runs) ? readdirSync(runs) : []).filter(
48
+ f => !avant.has(f) && f.endsWith('.json')
49
+ );
50
+ const dossier = env[RESULTATS];
51
+ for (const f of neufs) {
52
+ if (dossier) {
53
+ mkdirSync(path.join(dossier, TURBO), { recursive: true });
54
+ // The results directory may lie on another file system: a copy, then the removal.
55
+ copyFileSync(path.join(runs, f), path.join(dossier, TURBO, f));
56
+ }
57
+ rmSync(path.join(runs, f), { force: true });
58
+ }
59
+ if (neufs.length && !avant.size && existsSync(runs) && readdirSync(runs).length === 0) {
60
+ rmdirSync(runs);
61
+ }
62
+ }
63
+
64
+ // The tasks of the summaries under the results directory <dossier>, in their order:
65
+ // `{ tache, paquet, dossier, script, tests, code, cache, journal }`, `dossier` « . » for the root,
66
+ // `code` null for a task that did not run.
67
+ export function lireLesResumes(dossier) {
68
+ const d = path.join(dossier, TURBO);
69
+ const fichiers = existsSync(d)
70
+ ? readdirSync(d)
71
+ .filter(f => f.endsWith('.json'))
72
+ .sort()
73
+ : [];
74
+ return fichiers.flatMap(f =>
75
+ (lireJson(path.join(d, f))?.tasks ?? []).map(t => ({
76
+ tache: t.taskId,
77
+ paquet: t.package,
78
+ dossier: t.directory || '.',
79
+ script: t.task,
80
+ tests: t.task === SCRIPT_DES_TESTS,
81
+ code: t.execution?.exitCode ?? null,
82
+ cache: t.cache?.status ?? null,
83
+ journal: t.logFile ?? null,
84
+ }))
85
+ );
86
+ }
@@ -99,8 +99,8 @@ import {
99
99
  tracesDuPlan,
100
100
  } from '../../services-du-noyau.mjs';
101
101
  import { paquets } from '../../paquets.mjs';
102
- import { garderLesResumes } from './verdict.mjs';
103
102
  import { RESULTATS } from '../../resultats.mjs';
103
+ import { garderLesResumes } from './resume-du-lanceur.mjs';
104
104
  import { horsTypescript, planifier } from './turbo-des-paquets.mjs';
105
105
 
106
106
  const racine = process.cwd();
@@ -2,30 +2,16 @@
2
2
  // (scripts/jointure.d.ts, `verdict`): what a run of Turborepo and of Vitest left in the results
3
3
  // directory of a pass (`GRILLHOUSE_RESULTATS`, scripts/resultats.mjs).
4
4
  //
5
- // - The summary of a run of Turborepo (`turbo run … --summarize`, `.turbo/runs/<id>.json`):
6
- // `garderLesResumes` moves the summaries a run wrote into `<dossier>/turbo/`, and `lireResumes`
7
- // gives each task, its package and directory, its script, its exit code, its cache status and
8
- // its log file (from the root), and whether it plays the tests of its package (`test:unit`).
5
+ // - The summary of a run of Turborepo (./resume-du-lanceur.mjs): `lireLesResumes` gives each task.
9
6
  // - The JSON report of Vitest, which the frame's base configuration writes under
10
7
  // `<dossier>/vitest/` while the variable is set (scripts/langages/typescript/vitest-config/resultats.mjs):
11
8
  // `lireRapportsVitest` gives each test file, its status, the message of a file that does not
12
9
  // load, and each test, its title, its full name, its status and its first message.
13
- import {
14
- copyFileSync,
15
- existsSync,
16
- mkdirSync,
17
- readdirSync,
18
- readFileSync,
19
- rmdirSync,
20
- rmSync,
21
- } from 'node:fs';
10
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
22
11
  import path from 'node:path';
23
- import { RESULTATS } from '../../resultats.mjs';
24
- import { SCRIPT_DES_TESTS } from '../../services-du-noyau.mjs';
12
+ import { lireLesResumes } from './resume-du-lanceur.mjs';
25
13
  import { VITEST } from './vitest-config/resultats.mjs';
26
14
 
27
- const TURBO = 'turbo';
28
-
29
15
  const fichiers = (dossier, extension) =>
30
16
  existsSync(dossier)
31
17
  ? readdirSync(dossier)
@@ -41,48 +27,6 @@ const lireJson = f => {
41
27
  }
42
28
  };
43
29
 
44
- // Moves the summaries of Turborepo that a run in <racine> wrote (`.turbo/runs/*.json` absent from
45
- // <avant>, the names there before it) into the results directory <env> names; removes them
46
- // without it. `.turbo/runs` goes too when the run created it (<avant> empty) and it is left empty.
47
- export function garderLesResumes(racine, avant, env = process.env) {
48
- const runs = path.join(racine, '.turbo', 'runs');
49
- const neufs = (existsSync(runs) ? readdirSync(runs) : []).filter(
50
- f => !avant.has(f) && f.endsWith('.json')
51
- );
52
- const dossier = env[RESULTATS];
53
- for (const f of neufs) {
54
- if (dossier) {
55
- mkdirSync(path.join(dossier, TURBO), { recursive: true });
56
- // The results directory may lie on another file system: a copy, then the removal.
57
- copyFileSync(path.join(runs, f), path.join(dossier, TURBO, f));
58
- rmSync(path.join(runs, f), { force: true });
59
- } else {
60
- rmSync(path.join(runs, f), { force: true });
61
- }
62
- }
63
- if (neufs.length && !avant.size && existsSync(runs) && readdirSync(runs).length === 0) {
64
- rmdirSync(runs);
65
- }
66
- }
67
-
68
- // The tasks of the summaries of Turborepo under the results directory <dossier>, in their order:
69
- // `{ tache, paquet, dossier, script, tests, code, cache, journal }`, `dossier` « . » for the root,
70
- // `code` null for a task that did not run.
71
- export function lireResumes(dossier) {
72
- return fichiers(path.join(dossier, TURBO), '.json').flatMap(f =>
73
- (lireJson(f)?.tasks ?? []).map(t => ({
74
- tache: t.taskId,
75
- paquet: t.package,
76
- dossier: t.directory || '.',
77
- script: t.task,
78
- tests: t.task === SCRIPT_DES_TESTS,
79
- code: t.execution?.exitCode ?? null,
80
- cache: t.cache?.status ?? null,
81
- journal: t.logFile ?? null,
82
- }))
83
- );
84
- }
85
-
86
30
  // The test files of the reports of Vitest under the results directory <dossier>: `{ fichier,
87
31
  // etat, message, tests }`, `fichier` its absolute path, each test `{ titre, nom, etat, message }`.
88
32
  export function lireRapportsVitest(dossier) {
@@ -103,5 +47,5 @@ export function lireRapportsVitest(dossier) {
103
47
 
104
48
  // The verdict the results directory <dossier> holds: `{ rapports, taches }`.
105
49
  export function verdict(dossier) {
106
- return { rapports: lireRapportsVitest(dossier), taches: lireResumes(dossier) };
50
+ return { rapports: lireRapportsVitest(dossier), taches: lireLesResumes(dossier) };
107
51
  }
@@ -127,8 +127,8 @@ import {
127
127
  } from '../../services-du-noyau.mjs';
128
128
  import { paquets, TYPAGE } from '../../paquets.mjs';
129
129
  import { fichiersDeLaTranche, RAPPORTS } from './tranches.mjs';
130
+ import { garderLesResumes } from './resume-du-lanceur.mjs';
130
131
  import { controlesDuDepot, planifier } from './turbo-des-paquets.mjs';
131
- import { garderLesResumes } from './verdict.mjs';
132
132
 
133
133
  const GARDES = ['grillhouse:gardes', 'gardes'];
134
134
  const TACHES = [...GARDES, TYPAGE, SCRIPT_DES_TESTS];
@@ -48,16 +48,20 @@
48
48
  // script of the shell, a document, which a test reads without importing it.
49
49
  // Vitest's own `forceRerunTriggers` (a configuration's, or its default) still apply, as with
50
50
  // `--changed`. Under the mark `cible`, 5 and 7 do not play the package whole, and no test is
51
- // related by the paths it reads (`testsQuiLancent`): the tests Vitest relates alone, and the
52
- // files named, as `vitest --changed` leaves a file out of its graph to the complete pass, the
51
+ // related by the paths it reads (`testsQuiLancent`): the tests Vitest relates alone, the tests
52
+ // that declare their reads, and the files named, as `vitest --changed` leaves a file out of its graph to the complete pass, the
53
53
  // CI's of the ticket's branch and the night's. Witness: grillhouse-4nr.21, whose
54
54
  // `scripts/session-start.sh` the reads of 276 of the 282 test files of packages/grillhouse hold
55
55
  // (a test that starts the command reads every script of its table).
56
56
  // - Otherwise the tests played are those Vitest relates to the files changed or added (`related`,
57
57
  // absolute), the tests that read one of them by its path, a script they launch or a file they
58
58
  // read, with what it imports and names (`testsQuiLancent`, ./lances.mjs, as Bazel's `data`),
59
- // and the files a targeted run names themselves (./cibles.mjs): a file named plays, changed or
60
- // not. A package where none relates plays none and passes
59
+ // the tests that declare they read a file changed, added or removed (`// @lit <motif>` at
60
+ // their head, `testsQuiDeclarent`, ./lances.mjs), targeted or not, and the files a targeted run
61
+ // names themselves (./cibles.mjs): a file named plays, changed or not. Witness: the tests that
62
+ // judge a list of the repository complete (the share of `scripts/` and `bin/`, the callers of
63
+ // each subcommand), which the targeted passes of grillhouse-44b.15 left red to the CI of the
64
+ // branch five times in one night (grillhouse-44b.17). A package where none relates plays none and passes
61
65
  // (`passWithNoTests`), as Vitest's `--changed` has it.
62
66
  //
63
67
  // This module's top level uses Node alone (./cibles.mjs, scripts/langages/typescript/tests.mjs import it); a
@@ -66,7 +70,7 @@ import { existsSync, readFileSync, realpathSync } from 'node:fs';
66
70
  import { createRequire } from 'node:module';
67
71
  import path from 'node:path';
68
72
  import { fileURLToPath } from 'node:url';
69
- import { testsQuiLancent } from './lances.mjs';
73
+ import { testsQuiDeclarent, testsQuiLancent } from './lances.mjs';
70
74
 
71
75
  // This directory, the frame's base configuration.
72
76
  const BASE = path.dirname(fileURLToPath(import.meta.url));
@@ -251,9 +255,10 @@ export function restreindre(test, dossier, ch, nommes, dire) {
251
255
  }
252
256
  const changes = ch.fichiers.map(f => path.join(ch.racine, f));
253
257
  const lanceurs = ch.cible ? [] : testsQuiLancent(dossier, ch.racine, changes);
254
- test.related = [...new Set([...changes, ...nommes, ...lanceurs])];
258
+ const declarants = testsQuiDeclarent(dossier, [...ch.fichiers, ...ch.supprimes]);
259
+ test.related = [...new Set([...changes, ...nommes, ...lanceurs, ...declarants])];
255
260
  test.passWithNoTests = true;
256
261
  dire(
257
- `↳ ${nom} : les tests que Vitest relie aux ${ch.fichiers.length} fichier(s) changé(s) depuis ${ch.cible ? 'la base du lot' : 'le dernier vert'}${lanceurs.length ? `, et ${lanceurs.length} test(s) qui en lisent un par son chemin` : ''}.`
262
+ `↳ ${nom} : les tests que Vitest relie aux ${ch.fichiers.length} fichier(s) changé(s) depuis ${ch.cible ? 'la base du lot' : 'le dernier vert'}${lanceurs.length ? `, et ${lanceurs.length} test(s) qui en lisent un par son chemin` : ''}${declarants.length ? `, et ${declarants.length} test(s) qui déclarent en lire un (@lit)` : ''}.`
258
263
  );
259
264
  }
@@ -32,6 +32,14 @@
32
32
  // one of the files changed. ./changements.mjs adds them to the tests Vitest relates to the
33
33
  // changes, so that a test plays when the script it launches changes, as it plays when a module it
34
34
  // imports changes.
35
+ // - The tests that declare what they read (`testsQuiDeclarent`): a test that judges a list of the
36
+ // repository complete (every script has its share, every caller names its subcommand) reads files
37
+ // it neither imports nor names, and the reads of a test that launches the command hold every
38
+ // script, too many to follow under a targeted measure (./changements.mjs). It declares them, as a
39
+ // target of Bazel declares its `data`: a line `// @lit <motif> …` of the comment at its head,
40
+ // each pattern a glob from the top of the repository (`// @lit packages/grillhouse/scripts/**`).
41
+ // ./changements.mjs adds it to the tests of every pass, targeted or not, whose changes, files
42
+ // changed, added or removed, one of its patterns covers.
35
43
  // - What a test names without the frame reading it (`nonDeclares`): a string of the test's code or
36
44
  // of its material that ends the path of a module of its package (`'verrou.mjs'`,
37
45
  // `'verrous/verrou.mjs'`), out of a directory of tests, the module out of what the test reads and
@@ -457,6 +465,43 @@ export function testsQuiLancent(dossier, racine, changes) {
457
465
  });
458
466
  }
459
467
 
468
+ // The tag of a test that declares the files it reads: a line `// @lit <motif> …` of the comment at
469
+ // the head of the file, before its first line of code, as the tag `@poste` (./cibles.mjs).
470
+ const ETIQUETTE_DE_LECTURE = /^\/\/\s*@lit\b(.*)$/;
471
+
472
+ /**
473
+ * The patterns the text <texte> of a test file declares it reads: the words of each line
474
+ * `// @lit` of the comment at its head, each a glob from the top of the repository.
475
+ * @param {string} texte the text of the file
476
+ */
477
+ export function lecturesDeclarees(texte) {
478
+ const out = [];
479
+ for (const ligne of texte.split('\n')) {
480
+ const l = ligne.trim();
481
+ const m = ETIQUETTE_DE_LECTURE.exec(l);
482
+ if (m) {
483
+ out.push(...m[1].split(/\s+/).filter(Boolean));
484
+ } else if (l !== '' && !l.startsWith('//') && !l.startsWith('#!')) {
485
+ break;
486
+ }
487
+ }
488
+ return out;
489
+ }
490
+
491
+ /**
492
+ * The test files of the package at <dossier> that declare they read one of the files <chemins>
493
+ * (each from the top of the repository): those whose `@lit` patterns cover one; absolute, sorted.
494
+ */
495
+ export function testsQuiDeclarent(dossier, chemins) {
496
+ if (chemins.length === 0) {
497
+ return [];
498
+ }
499
+ return testsDuPaquet(dossier).filter(t => {
500
+ const motifs = lecturesDeclarees(lire(t));
501
+ return motifs.some(m => chemins.some(c => path.matchesGlob(c, m)));
502
+ });
503
+ }
504
+
460
505
  // Whether the path <rel> (from the top) lies under one of the paths <lit> (from the top).
461
506
  const dansLit = (rel, lit) => lit.some(l => rel === l || rel.startsWith(`${l}/`));
462
507
 
@@ -24,6 +24,7 @@ process.env.GRILLHOUSE_MESURE_D_ESSAI ||= JSON.stringify({
24
24
  coeurs: 12,
25
25
  charge: 1,
26
26
  memoireLibre: 16 * 1024 ** 3,
27
+ memoireTotale: 32 * 1024 ** 3,
27
28
  });
28
29
  process.env.GRILLHOUSE_TEMPORAIRE_LIBRE ||= '0';
29
30
  process.env.GRILLHOUSE_COPIE_LIBRE ||= '0';
@@ -0,0 +1,166 @@
1
+ // The stop of an agent of a team with an unread message: the hooks SubagentStop and TeammateIdle
2
+ // of the frame's plugin run it (`grillhouse messages-non-lus`), as a consumer of a queue (SQS,
3
+ // Kafka) does not stop with messages it has not acknowledged. A message SendMessage leaves in the
4
+ // box of an agent while the agent writes its last answer is otherwise read by no one: the agent
5
+ // ends its turn and waits, and the instruction waits with it.
6
+ //
7
+ // - The box of an agent is `~/.claude/teams/<équipe>/inboxes/<nom>.json`, an array of entries
8
+ // `{ from, text, summary, timestamp, msg_id, read }`, which Claude Code writes and marks read
9
+ // (https://code.claude.com/docs/en/agent-teams.md, « Mailbox »). An unread message has
10
+ // `read: false`.
11
+ // - The agent's name: `teammate_name` (TeammateIdle); else the meta file of its transcript
12
+ // (`agent-<agent_id>.meta.json` beside `agent_transcript_path`, under the session's
13
+ // `subagents/`), whose `name` and `teamName` Claude Code writes for a named agent; else an
14
+ // `agent_id` of the form `<nom>@<équipe>`; else `agent_type`, which is a named agent's name. A
15
+ // sub-agent launched without a name has none of them, and no box.
16
+ // - The team: the meta file's `teamName`, else the one of the `agent_id`, else the team whose
17
+ // `config.json` names the hook's session as its lead's (`leadSessionId`): an agent of a team
18
+ // runs in its lead's session. The box is the file of that name in that team, when it exists: the
19
+ // list of the members (`members` of `config.json`) is not read, since Claude Code removes an
20
+ // agent from it when the agent leaves, while a message may still wait in its box.
21
+ // - Each unread message blocks the stop once: its `msg_id` is noted in
22
+ // `~/.claude/grillhouse/messages-signales/<équipe>/<nom>.json`, and a message already noted
23
+ // lets the stop pass, so that a message Claude Code leaves unread never holds the agent in a
24
+ // loop (`stop_hook_active` is not read: a message that comes during the continuation blocks in
25
+ // its turn). The file keeps the noted ids still in the box alone.
26
+ // - The block: the reason on the error stream, exit code 2, which both events read as the next
27
+ // instruction of the agent (hooks.md, « Exit code 2 behavior per event »; TeammateIdle has no
28
+ // `decision` in JSON). The reason gives each unread message, its sender and its text.
29
+ // - The box is never written: Claude Code keeps it. A box absent or unreadable, a team not found,
30
+ // a note that cannot be written, an input that is no JSON: the stop passes, exit 0.
31
+ import {
32
+ existsSync,
33
+ mkdirSync,
34
+ readFileSync,
35
+ readdirSync,
36
+ renameSync,
37
+ writeFileSync,
38
+ } from 'node:fs';
39
+ import os from 'node:os';
40
+ import path from 'node:path';
41
+ import { pathToFileURL } from 'node:url';
42
+
43
+ const lireJson = f => {
44
+ try {
45
+ return JSON.parse(readFileSync(f, 'utf8'));
46
+ } catch {
47
+ return null;
48
+ }
49
+ };
50
+
51
+ // The meta file of the sub-agent the input names, or null.
52
+ function metaDe(entree) {
53
+ const transcription =
54
+ entree.agent_transcript_path ??
55
+ (entree.agent_id && entree.transcript_path
56
+ ? path.join(
57
+ entree.transcript_path.replace(/\.jsonl$/, ''),
58
+ 'subagents',
59
+ `agent-${entree.agent_id}.jsonl`
60
+ )
61
+ : null);
62
+ return transcription ? lireJson(transcription.replace(/\.jsonl$/, '.meta.json')) : null;
63
+ }
64
+
65
+ // The team whose lead runs the session <session>, under <equipes>; null when none does.
66
+ function equipeDeLaSeance(equipes, session) {
67
+ if (!session) {
68
+ return null;
69
+ }
70
+ let noms;
71
+ try {
72
+ noms = readdirSync(equipes);
73
+ } catch {
74
+ return null;
75
+ }
76
+ return (
77
+ noms.find(n => lireJson(path.join(equipes, n, 'config.json'))?.leadSessionId === session) ??
78
+ null
79
+ );
80
+ }
81
+
82
+ /**
83
+ * The box of the agent the hook's input <entree> names: `{ equipe, nom, fichier }`, or null for an
84
+ * agent of no team (see the header).
85
+ * @param {Record<string, any>} entree the hook's input
86
+ * @param {{ maison?: string }} [options] the home whose `.claude/teams` holds the teams
87
+ * @returns {{ equipe: string, nom: string, fichier: string } | null}
88
+ */
89
+ export function boiteDe(entree, { maison = os.homedir() } = {}) {
90
+ const equipes = path.join(maison, '.claude', 'teams');
91
+ const meta = entree.teammate_name ? null : metaDe(entree);
92
+ const id = /^([^@]+)@([^@]+)$/.exec(entree.agent_id ?? '');
93
+ const nom = entree.teammate_name ?? meta?.name ?? id?.[1] ?? entree.agent_type ?? null;
94
+ const equipe = meta?.teamName ?? id?.[2] ?? equipeDeLaSeance(equipes, entree.session_id);
95
+ if (!nom || !equipe || /[/\\]/.test(`${nom}${equipe}`)) {
96
+ return null;
97
+ }
98
+ const fichier = path.join(equipes, equipe, 'inboxes', `${nom}.json`);
99
+ return existsSync(fichier) ? { equipe, nom, fichier } : null;
100
+ }
101
+
102
+ /**
103
+ * What the stop of the agent the hook's input <entree> gets: the reason that blocks it, which
104
+ * gives each unread message not yet signalled, or null when the stop passes. The ids it gives are
105
+ * noted, so that each blocks once; the box is only read.
106
+ * @param {Record<string, any>} entree the hook's input
107
+ * @param {{ maison?: string }} [options] the home of `.claude/teams` and `.claude/grillhouse`
108
+ * @returns {string | null}
109
+ */
110
+ export function messagesNonLus(entree, { maison = os.homedir() } = {}) {
111
+ const boite = boiteDe(entree, { maison });
112
+ if (!boite) {
113
+ return null;
114
+ }
115
+ const messages = lireJson(boite.fichier);
116
+ if (!Array.isArray(messages)) {
117
+ return null;
118
+ }
119
+ const note = path.join(
120
+ maison,
121
+ '.claude',
122
+ 'grillhouse',
123
+ 'messages-signales',
124
+ boite.equipe,
125
+ `${boite.nom}.json`
126
+ );
127
+ const lus = lireJson(note);
128
+ const signales = new Set(Array.isArray(lus) ? lus : []);
129
+ const nonLus = messages.filter(m => m && m.read === false && typeof m.msg_id === 'string');
130
+ const neufs = nonLus.filter(m => !signales.has(m.msg_id));
131
+ if (!neufs.length) {
132
+ return null;
133
+ }
134
+ const presents = new Set(messages.map(m => m?.msg_id));
135
+ const garde = [...signales].filter(i => presents.has(i)).concat(neufs.map(m => m.msg_id));
136
+ try {
137
+ mkdirSync(path.dirname(note), { recursive: true });
138
+ writeFileSync(`${note}.${process.pid}`, `${JSON.stringify(garde)}\n`);
139
+ renameSync(`${note}.${process.pid}`, note);
140
+ } catch {
141
+ // A note that cannot be written would block at each stop: the stop passes.
142
+ return null;
143
+ }
144
+ return [
145
+ neufs.length > 1
146
+ ? `Ne t'arrête pas : ${neufs.length} messages non lus attendent dans ta boîte. Traite-les, puis termine ton tour.`
147
+ : "Ne t'arrête pas : un message non lu attend dans ta boîte. Traite-le, puis termine ton tour.",
148
+ ...neufs.map(
149
+ m =>
150
+ `\n## De ${m.from ?? 'inconnu'}${m.summary ? ` — ${m.summary}` : ''}\n${String(m.text ?? '')}`
151
+ ),
152
+ ].join('\n');
153
+ }
154
+
155
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
156
+ let raison = null;
157
+ try {
158
+ raison = messagesNonLus(JSON.parse(readFileSync(0, 'utf8')));
159
+ } catch {
160
+ // An input that is no JSON lets the stop pass.
161
+ }
162
+ if (raison) {
163
+ process.stderr.write(`${raison}\n`);
164
+ process.exitCode = 2;
165
+ }
166
+ }
@@ -1,11 +1,12 @@
1
1
  // What the machine gives at a moment, which the admission of a start reads
2
- // (scripts/regles-des-places.mjs): its cores, its load over one minute, its free memory. The
2
+ // (scripts/regles-des-places.mjs): its cores, its load over one minute, its free memory, and its
3
+ // total memory, which the board shows beside it. The
3
4
  // activity of the workflow of the machine (src/temporal/places/activites.ts) measures it here, and
4
5
  // whether the process of a place still lives; a signal to a process group, and whether the group
5
6
  // a sign of life names still runs, which the sessions (scripts/seances.mjs), the circuit and the
6
7
  // acts under Temporal (src/temporal/acte.ts) share.
7
8
  import { readFileSync } from 'node:fs';
8
- import { availableParallelism, freemem, loadavg } from 'node:os';
9
+ import { availableParallelism, freemem, loadavg, totalmem } from 'node:os';
9
10
  import { departDe, leMemeVivant, vivant } from './mesure/base-de-passe.mjs';
10
11
 
11
12
  export { departDe };
@@ -27,13 +28,15 @@ export function memoireDisponible() {
27
28
  }
28
29
 
29
30
  /**
30
- * The machine now: `{ coeurs, charge, memoireLibre }`, the load over one minute, the memory in bytes.
31
- * @returns {{ coeurs: number, charge: number, memoireLibre: number }}
31
+ * The machine now: `{ coeurs, charge, memoireLibre, memoireTotale }`, the load over one minute,
32
+ * the memories in bytes.
33
+ * @returns {{ coeurs: number, charge: number, memoireLibre: number, memoireTotale: number }}
32
34
  */
33
35
  export const mesureDeLaMachine = () => ({
34
36
  coeurs: availableParallelism(),
35
37
  charge: loadavg()[0],
36
38
  memoireLibre: memoireDisponible(),
39
+ memoireTotale: totalmem(),
37
40
  });
38
41
 
39
42
  /**