@roomi-fields/grillhouse 0.25.5 → 0.26.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 (44) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/agents/testwriter.md +1 -1
  3. package/bin/grillhouse.mjs +20 -3
  4. package/cadre/templates/cargo/package.json +3 -0
  5. package/cadre/templates/projet/.gitattributes +1 -0
  6. package/cadre/templates/projet/CLAUDE.md +6 -0
  7. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  8. package/charte.md +10 -1
  9. package/docs/ARCHITECTURE.md +91 -26
  10. package/docs/INTERFACE.md +16 -4
  11. package/hooks/register.tsx +57 -16
  12. package/package.json +9 -3
  13. package/scripts/circuit.mjs +121 -19
  14. package/scripts/copies-finies.mjs +167 -28
  15. package/scripts/crochets.mjs +9 -3
  16. package/scripts/enveloppe/enveloppe.mjs +59 -17
  17. package/scripts/enveloppe/lancer.sh +15 -22
  18. package/scripts/enveloppe/travail-de-la-copie.mjs +188 -0
  19. package/scripts/etapes.mjs +1 -1
  20. package/scripts/fusion-du-changelog.mjs +120 -0
  21. package/scripts/grillhouse-maj.mjs +19 -0
  22. package/scripts/integration/file.mjs +196 -104
  23. package/scripts/jointure.d.ts +22 -1
  24. package/scripts/langages/cargo/binaires.json +2 -1
  25. package/scripts/langages/cargo/clippy.mjs +10 -2
  26. package/scripts/langages/cargo/commandes.mjs +19 -4
  27. package/scripts/langages/cargo/composants.mjs +229 -8
  28. package/scripts/langages/cargo/index.mjs +17 -8
  29. package/scripts/langages/cargo/sccache.mjs +143 -0
  30. package/scripts/langages/cargo/verdict.mjs +50 -10
  31. package/scripts/langages/typescript/index.mjs +4 -2
  32. package/scripts/langages/typescript/regle-des-tests.mjs +37 -0
  33. package/scripts/nuit.sh +15 -1
  34. package/scripts/outils-cles.mjs +188 -0
  35. package/scripts/resultats.mjs +22 -6
  36. package/scripts/sous-commandes.mjs +16 -0
  37. package/scripts/verrou-de-machine.mjs +14 -13
  38. package/scripts/verrous/verrou.mjs +50 -14
  39. package/skills/developpeur/SKILL.md +4 -0
  40. package/skills/explorateur/SKILL.md +3 -1
  41. package/skills/pitmaster/SKILL.md +6 -2
  42. package/skills/pitmaster/references/consigne-agent.md +3 -3
  43. package/skills/relecteur/SKILL.md +6 -2
  44. package/skills/testwriter/SKILL.md +23 -6
package/scripts/nuit.sh CHANGED
@@ -34,6 +34,10 @@
34
34
  # read-only, its working tree and its git repository (the list the preparation's pose printed,
35
35
  # whatever a command rewrites afterwards): a write into it fails. With a shared submodule and no possible mount (bwrap absent
36
36
  # or refused), the night turns red, the log saying so, before any command runs.
37
+ # - The tools of the project: `grillhouse.outils` in the package.json of the main tree
38
+ # (scripts/outils-cles.mjs) gives each command of the project its variables, each set to its
39
+ # path, whatever the environment of the night's launcher; a faulty key turns the night red, the
40
+ # log naming it, and nothing runs.
37
41
  # - The night tests: after the full pass, the night tests and the time budget benches, which
38
42
  # `npm test` and the integration leave out, played by the command `tests-de-nuit` of the module
39
43
  # of the copy's language (the module typescript's: the files `*.nuit.test.*`, `*.nuit.spec.*`,
@@ -70,7 +74,9 @@
70
74
  # main by their content goes, and its branch (main and a branch another copy holds stay); a copy
71
75
  # refused (commits or work not entered, a lock) or held by a running circuit (its ticket in progress, its
72
76
  # `<copie>.travail`, the lock of the integration or of the queue) stays, its log line naming
73
- # why. The removal never changes the night's verdict.
77
+ # why and the place it holds, a kept copy whose ticket is closed losing what the tools of its
78
+ # languages wrote there. The removal never changes the night's verdict; the end of each
79
+ # circuit runs it too (scripts/circuit.mjs).
74
80
  # - It takes no lock of the integration or of the queue (scripts/integration/file.mjs): an
75
81
  # integration and the queue run during the night, each in its own copy.
76
82
  # - Its log is <git common dir>/nuit/<date>.log. Green: HEAD becomes the last green commit
@@ -205,6 +211,14 @@ jouer() {
205
211
  esac
206
212
  done <<< "$lecture"
207
213
  [ "$faute" -eq 0 ] || return 1
214
+ # The tools of the project, one `export VARIABLE='chemin'` each (exportsDesOutils of
215
+ # outils-cles.mjs), evaluated for every command.
216
+ local outils
217
+ if ! outils=$(node "$ici/outils-cles.mjs" "$copie"); then
218
+ echo "✗ la clé grillhouse.outils est refusée : rien n'est joué."
219
+ return 1
220
+ fi
221
+ eval "$outils"
208
222
  if [ -f "$copie/package-lock.json" ] && ! cmp -s "$copie/package-lock.json" "$copie/node_modules/.nuit-lock"; then
209
223
  monter npm --prefix "$copie" ci --no-audit --no-fund --silent || return 1
210
224
  cp "$copie/package-lock.json" "$copie/node_modules/.nuit-lock"
@@ -0,0 +1,188 @@
1
+ #!/usr/bin/env node
2
+ // The reading of the `grillhouse.outils` key of a package.json, the tools of the project, as Bazel
3
+ // declares what an action sees out of its sandbox (--sandbox_add_mount_pair) and the environment
4
+ // it gets (--action_env): `{ "<VARIABLE>": "<chemin>" }`, each path absolute or under `~`. The
5
+ // envelope (scripts/enveloppe/enveloppe.mjs) mounts each path read-only and passes each variable to
6
+ // the session; the circuit's passes (scripts/circuit.mjs), `npm run verifier`
7
+ // (bin/grillhouse.mjs) and the night (scripts/nuit.sh) play with the same variables, so that every
8
+ // one of them sees the same tool, whatever its launcher's environment.
9
+ //
10
+ // - The key is absent, null or an object; each name is a variable's (`[A-Za-z_][A-Za-z0-9_]*`),
11
+ // each value a string, a path absolute or under `~` (the home), that exists. Every fault is named
12
+ // with its key; a faulty key gives no variable.
13
+ // - A tool never undoes the envelope: a path is refused, its variable and its path named, when it
14
+ // is `/`, the home or a path that holds it, a path that holds a mount of the envelope (the main
15
+ // tree and its copies, `/tmp` and the temporary directories, and the mounts the envelope names:
16
+ // `~/.claude`, the scratchpads, the npm cache, the session directories), or a path under a hidden
17
+ // directory of the first level of the home (`~/.ssh`, `~/.gnupg`, `~/.aws`, `~/.config`…), where
18
+ // the machine keeps its credentials, but `~/.local` and `~/.cache`; nor under or holding
19
+ // `~/.local/share/keyrings`, the keyrings of the machine's credentials. A path that is a link is
20
+ // judged by its target too, which the envelope mounts with it.
21
+ // - The key is read from the package.json of the main tree of the repository (`outilsDe`), never of
22
+ // a copy: an agent never opens a path for its next session.
23
+ // - `node outils-cles.mjs <dir>` writes one line `export VARIABLE='chemin'` per tool of the project
24
+ // that holds <dir>, the path resolved and quoted for the shell (`exportsDesOutils`), which the
25
+ // night evaluates, exit 0; a faulty key writes its faults on stderr, exit 1.
26
+ import { spawnSync } from 'node:child_process';
27
+ import { existsSync, readFileSync, realpathSync } from 'node:fs';
28
+ import os from 'node:os';
29
+ import path from 'node:path';
30
+ import { pathToFileURL } from 'node:url';
31
+
32
+ const NOM = /^[A-Za-z_][A-Za-z0-9_]*$/;
33
+ // The hidden directories of the first level of the home that a tool may lie under.
34
+ const CACHES_PERMIS = ['.local', '.cache'];
35
+ // The keyrings of credentials inside them, as paths relative to the home.
36
+ const TROUSSEAUX = ['.local/share/keyrings'];
37
+
38
+ // Whether <enfant> is <parent> or lies under it.
39
+ const sous = (enfant, parent) => {
40
+ const rel = path.relative(parent, enfant);
41
+ return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
42
+ };
43
+
44
+ // The refusal of the path <chemin> of the tool <cle>, or null, the home <maison> and the mounts
45
+ // <montages> of the envelope (see the header).
46
+ function refusDuChemin(cle, chemin, maison, montages) {
47
+ if (chemin === path.parse(chemin).root) {
48
+ return `la clé ${cle} nomme ${chemin}, la racine : un outil ne montre pas toute la machine.`;
49
+ }
50
+ if (sous(maison, chemin)) {
51
+ return `la clé ${cle} nomme ${chemin}, qui contient la maison ${maison} : un outil ne montre pas ses identifiants.`;
52
+ }
53
+ const couvert = montages.find(m => sous(path.resolve(m), chemin));
54
+ if (couvert) {
55
+ return `la clé ${cle} nomme ${chemin}, qui contient ${path.resolve(couvert)}, un montage de l'enveloppe.`;
56
+ }
57
+ const premier = sous(chemin, maison) ? path.relative(maison, chemin).split(path.sep)[0] : '';
58
+ if (premier.startsWith('.') && !CACHES_PERMIS.includes(premier)) {
59
+ return `la clé ${cle} nomme ${chemin}, sous ~/${premier}, un dossier caché de la maison où la machine garde ses identifiants (seuls ~/.local et ~/.cache portent un outil).`;
60
+ }
61
+ const trousseau = TROUSSEAUX.map(t => path.join(maison, t)).find(
62
+ t => sous(chemin, t) || sous(t, chemin)
63
+ );
64
+ if (trousseau) {
65
+ return `la clé ${cle} nomme ${chemin}, qui touche ${trousseau}, le trousseau où la machine garde ses identifiants.`;
66
+ }
67
+ return null;
68
+ }
69
+
70
+ // The real path of <p>, its links followed; <p> itself when it does not resolve.
71
+ const realpath = p => {
72
+ try {
73
+ return realpathSync(p);
74
+ } catch {
75
+ return p;
76
+ }
77
+ };
78
+
79
+ /**
80
+ * The tools that the package.json <pkg> declares: `outils`, each variable and its path resolved
81
+ * (`~` from <maison>), none when a fault is found; `fautes`, one sentence per fault, naming its key.
82
+ * <montages> are the paths a tool must not hold (see the header); a path that exists is judged
83
+ * again by its real path, `reel` (its links followed), which the envelope mounts with it.
84
+ * @param {any} pkg the parsed package.json
85
+ * @param {{ maison?: string, existe?: (p: string) => boolean, reel?: (p: string) => string, montages?: string[] }} [o]
86
+ * @returns {{ outils: Record<string, string>, fautes: string[] }}
87
+ */
88
+ export function lireOutils(
89
+ pkg,
90
+ { maison = os.homedir(), existe = existsSync, reel = realpath, montages = [] } = {}
91
+ ) {
92
+ const o = pkg?.grillhouse?.outils;
93
+ if (o === undefined || o === null) return { outils: {}, fautes: [] };
94
+ if (typeof o !== 'object' || Array.isArray(o)) {
95
+ return {
96
+ outils: {},
97
+ fautes: [
98
+ `la clé grillhouse.outils vaut ${JSON.stringify(o)}, pas un objet { VARIABLE: chemin }.`,
99
+ ],
100
+ };
101
+ }
102
+ /** @type {string[]} */
103
+ const fautes = [];
104
+ /** @type {Record<string, string>} */
105
+ const outils = {};
106
+ for (const [nom, v] of Object.entries(o)) {
107
+ const cle = `grillhouse.outils.${nom}`;
108
+ if (!NOM.test(nom)) {
109
+ fautes.push(`la clé grillhouse.outils nomme « ${nom} », pas un nom de variable.`);
110
+ } else if (typeof v !== 'string') {
111
+ fautes.push(`la clé ${cle} vaut ${JSON.stringify(v)}, pas un chemin.`);
112
+ } else if (!path.isAbsolute(v) && v !== '~' && !v.startsWith('~/')) {
113
+ fautes.push(`la clé ${cle} vaut « ${v} », ni un chemin absolu ni un chemin sous ~.`);
114
+ } else {
115
+ const chemin = path.resolve(v.startsWith('~') ? path.join(maison, v.slice(1)) : v);
116
+ const refus = refusDuChemin(cle, chemin, path.resolve(maison), montages);
117
+ // The envelope mounts what a link leads to: its target is judged as the path.
118
+ const cible = !refus && existe(chemin) ? reel(chemin) : chemin;
119
+ const refusDeLaCible =
120
+ cible !== chemin ? refusDuChemin(cle, cible, path.resolve(maison), montages) : null;
121
+ if (refus) fautes.push(refus);
122
+ else if (refusDeLaCible) fautes.push(`${refusDeLaCible} (la cible du lien ${chemin})`);
123
+ else if (existe(chemin)) outils[nom] = chemin;
124
+ else fautes.push(`la clé ${cle} nomme ${chemin}, qui n'existe pas.`);
125
+ }
126
+ }
127
+ return { outils: fautes.length ? {} : outils, fautes };
128
+ }
129
+
130
+ // The main tree of the repository that holds <dir>, from git's common directory; <dir> itself out
131
+ // of a repository.
132
+ function arbrePrincipal(dir) {
133
+ const r = spawnSync(
134
+ 'git',
135
+ ['-C', dir, 'rev-parse', '--path-format=absolute', '--git-common-dir'],
136
+ {
137
+ encoding: 'utf8',
138
+ }
139
+ );
140
+ return r.status === 0 ? path.dirname(r.stdout.trim()) : path.resolve(dir);
141
+ }
142
+
143
+ /**
144
+ * The tools of the project that holds <dir>, from the package.json of its main tree, never of a
145
+ * copy, so that an agent never opens a path for its next session (none without one); no path
146
+ * holding the main tree, `/tmp`, the temporary directories, nor one of <montages>.
147
+ * @param {string} dir a directory of the project: its main tree or a copy
148
+ * @param {{ montages?: string[] }} [o]
149
+ * @returns {Record<string, string>}
150
+ * @throws {Error} the faults of the key, one per line
151
+ */
152
+ export function outilsDe(dir, { montages = [] } = {}) {
153
+ const racine = arbrePrincipal(dir);
154
+ const f = path.join(racine, 'package.json');
155
+ if (!existsSync(f)) return {};
156
+ const temporaires = [process.env.CLAUDE_CODE_TMPDIR, os.tmpdir(), '/tmp'].filter(Boolean);
157
+ const { outils, fautes } = lireOutils(JSON.parse(readFileSync(f, 'utf8')), {
158
+ montages: [racine, ...temporaires, ...montages],
159
+ });
160
+ if (fautes.length) throw new Error(fautes.join('\n'));
161
+ return outils;
162
+ }
163
+
164
+ /**
165
+ * The environment <env> of a pass with the tools <outils> (`outilsDe`), the tools winning.
166
+ * @param {Record<string, string>} outils
167
+ * @param {Record<string, string | undefined>} env
168
+ */
169
+ export function avecLesOutils(outils, env) {
170
+ return { ...env, ...outils };
171
+ }
172
+
173
+ // The shell's text that exports the tools <outils> (`outilsDe`), one `export VARIABLE='chemin'`
174
+ // per line, each path quoted for the shell: what the night evaluates before its commands.
175
+ export const exportsDesOutils = outils =>
176
+ Object.entries(outils)
177
+ .map(([n, c]) => `export ${n}='${c.replaceAll("'", "'\\''")}'\n`)
178
+ .join('');
179
+
180
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
181
+ try {
182
+ const outils = outilsDe(path.resolve(process.argv[2] ?? '.'));
183
+ process.stdout.write(exportsDesOutils(outils));
184
+ } catch (e) {
185
+ process.stderr.write(`${/** @type {Error} */ (e).message}\n`);
186
+ process.exitCode = 1;
187
+ }
188
+ }
@@ -23,7 +23,8 @@
23
23
  // the circuit does not read, fell at the review) (developpeur);
24
24
  // - `reponses` (`titre` of the finding, `etat` levé or contesté, `raison` for a contesté,
25
25
  // `piece`): as the author answers in each thread of a review on GitHub or Gerrit, a FAIT
26
- // answers each finding of the reviewer open for him, by its title, and the circuit refuses a
26
+ // answers each finding of the reviewer open for him, by its title (the number « Constat N — »
27
+ // its instruction heads it with recognised, `cleDuConstat`), and the circuit refuses a
27
28
  // sheet without the answer to one (`reponsesAuxConstats`), save in a run where the supervisor
28
29
  // gives the task (`--contexte`, the findings open at the run's launch then its context, the
29
30
  // ones a RENDU states within it still its task: `constatsDeLaSeance` of
@@ -50,8 +51,9 @@
50
51
  // element out of the list, a file the lot changes named alone or as `<fichier>#<nom>`
51
52
  // (`conformiteDuLot`) (reviewer);
52
53
  // - `suivi` (`titre`, `etat` levé or non levé, `preuve`): after a review sent back, each finding
53
- // before it judged on the difference of the lot, which the circuit writes at the ticket with
54
- // the verdict, for the human (reviewer);
54
+ // before it judged on the difference of the lot, by its title (its number « Constat N — »
55
+ // recognised, `cleDuConstat`), which the circuit writes at the ticket with the verdict, for
56
+ // the human (reviewer);
55
57
  // - `question`, with its `piece` (reviewer): what goes up to the owner, a real word of the
56
58
  // language written in the code; the circuit stops at « besoin » before it commits or
57
59
  // relaunches anyone;
@@ -280,7 +282,9 @@ const FICHES = {
280
282
  reponses: liste(
281
283
  objet(
282
284
  {
283
- titre: texte('Le titre du constat, tel que ta consigne l’écrit.'),
285
+ titre: texte(
286
+ 'Le titre du constat, tel que ta consigne l’écrit, sans son numéro « Constat N — ».'
287
+ ),
284
288
  etat: {
285
289
  type: 'string',
286
290
  enum: ['levé', 'contesté'],
@@ -356,7 +360,7 @@ const FICHES = {
356
360
  suivi: liste(
357
361
  objet(
358
362
  {
359
- titre: texte('Le titre du constat d’avant.'),
363
+ titre: texte('Le titre du constat d’avant, sans son numéro « Constat N — ».'),
360
364
  etat: { type: 'string', enum: ['levé', 'non levé'] },
361
365
  preuve: texte('Ce que la différence du lot en montre.'),
362
366
  },
@@ -516,12 +520,24 @@ export function reponsesAuxQuestions(fiche, posees) {
516
520
  return sans.length ? `reponses : sans ligne pour les questions ${sans.join(', ')}` : null;
517
521
  }
518
522
 
523
+ // The finding an answer's title <titre> names: the title itself, or the title as the instruction
524
+ // heads it, numbered, « Constat N — <titre> » (`texteDesOuverts` of scripts/circuit.mjs), as a review
525
+ // attaches a reply to its thread by its identifier, never by a copy of its display.
526
+ export function cleDuConstat(titre) {
527
+ const tiret = ' — ';
528
+ const fin = titre.indexOf(tiret);
529
+ const numero = titre.slice('Constat '.length, fin);
530
+ return titre.startsWith('Constat ') && fin > 0 && String(Number.parseInt(numero, 10)) === numero
531
+ ? titre.slice(fin + tiret.length)
532
+ : titre;
533
+ }
534
+
519
535
  // What makes the developpeur's sheet <fiche> out of conformity with the findings open for him
520
536
  // (<titres>), as the author answers in each thread of a review: a FAIT without the answer to one,
521
537
  // by its title (a BLOQUÉ or a BESOIN stops the circuit before any review). The fault, or null.
522
538
  export function reponsesAuxConstats(fiche, titres) {
523
539
  if (fiche.statut !== 'FAIT') return null;
524
- const repondus = new Set((fiche.reponses ?? []).map(r => r.titre));
540
+ const repondus = new Set((fiche.reponses ?? []).map(r => cleDuConstat(r.titre)));
525
541
  const sans = titres.filter(t => !repondus.has(t)).map(t => `« ${t} »`);
526
542
  if (!sans.length) return null;
527
543
  return `reponses : sans réponse ${sans.length > 1 ? 'aux constats' : 'au constat'} ${sans.join(', ')}`;
@@ -14,6 +14,7 @@
14
14
  import path from 'node:path';
15
15
  import { fileURLToPath } from 'node:url';
16
16
  import { langageDe } from './langages.mjs';
17
+ import { avecLesOutils, outilsDe } from './outils-cles.mjs';
17
18
 
18
19
  const SCRIPTS = path.dirname(fileURLToPath(import.meta.url));
19
20
 
@@ -27,6 +28,7 @@ export const SOUS_COMMANDES = {
27
28
  droits: 'droits.mjs',
28
29
  enveloppe: 'enveloppe/enveloppe.mjs',
29
30
  file: 'integration/file.mjs',
31
+ 'fusion-du-changelog': 'fusion-du-changelog.mjs',
30
32
  'gardes-du-cadre': 'gardes-du-cadre.mjs',
31
33
  greffons: 'greffons.mjs',
32
34
  hook: 'crochet.mjs',
@@ -88,6 +90,20 @@ export function commandeDe(nom, racine = process.cwd()) {
88
90
  return n !== null && Object.hasOwn(commandes, n) ? commandes[n] : null;
89
91
  }
90
92
 
93
+ /**
94
+ * The environment the subcommand <nom> runs under, in the project at <racine>, from <env>:
95
+ * `verifier` gets the tools of the project (`grillhouse.outils`, scripts/outils-cles.mjs), each
96
+ * variable set to its path, whatever <env> holds; every other subcommand gets <env>.
97
+ * @param {string} nom the subcommand
98
+ * @param {string} [racine] the root of the project, the working directory by default
99
+ * @param {Record<string, string | undefined>} [env]
100
+ * @returns {Record<string, string | undefined>}
101
+ * @throws {Error} the faults of the key, for `verifier`
102
+ */
103
+ export function environnementDe(nom, racine = process.cwd(), env = process.env) {
104
+ return nom === 'verifier' ? avecLesOutils(outilsDe(racine), env) : env;
105
+ }
106
+
91
107
  // The script of each subcommand in the project at <racine>, where a former copy of the frame lay
92
108
  // (`scripts/<script>`): what the migrations name, a former copy becoming its subcommand. A script
93
109
  // of the core is named from `scripts/`, one of a module of language by its file's name, where the
@@ -38,12 +38,13 @@
38
38
  // `--experimental_local_test_priority` orders the tests that wait for the machine. A measure
39
39
  // played in the frame's own repository (one whose workspaces hold the package
40
40
  // @roomi-fields/grillhouse in development, its agent copies included: `rangDeLaMesure`) is of
41
- // the second rank; a project's (a circuit, a `npm run verifier`) is of the first. A measure of
42
- // the first rank that waits names itself in the directory `<lock>.premier-rang/` (one file per
43
- // waiting process, named by its number, removed once it holds the lock or stops); a measure of
44
- // the second rank does not take the lock, even free, while a live process waits there, so a
45
- // project's circuit never waits behind the frame's own checks (BPScript 320.9: 208 min of its
46
- // wait went to the checks of the frame's agent copies). A waiting file whose process is gone
41
+ // the first rank, « mesure du cadre »; a project's (a circuit, a `npm run verifier`) is of the
42
+ // second, « mesure d'un projet ». A measure of the first rank that waits names itself in the
43
+ // directory `<lock>.premier-rang/` (one file per waiting process, named by its number, removed
44
+ // once it holds the lock or stops); a measure of the second rank does not take the lock, even
45
+ // free, while a live process waits there, so a check of the frame, whose next version every
46
+ // project waits for, never waits behind the projects' measures (the verification of 0.26.0
47
+ // waited 61 min behind five measures of two projects). A waiting file whose process is gone
47
48
  // names no one and goes. Between measures of one rank, the first to find the lock free takes
48
49
  // it. The bound of the wait is the same for both ranks, and the wait says its rank.
49
50
  // - The lock is let go at the end of the measure, whether it succeeds or throws.
@@ -69,20 +70,20 @@ const VARIABLE_VERROU = 'GRILLHOUSE_VERROU_MACHINE';
69
70
  const VARIABLE_TENUE = 'GRILLHOUSE_MESURE_TENUE';
70
71
  const VARIABLE_ATTENTE = 'GRILLHOUSE_ATTENTE_MACHINE_MS';
71
72
 
72
- // The name of the frame's package, which a repository of the second rank develops.
73
+ // The name of the frame's package, which a repository of the first rank develops.
73
74
  const CADRE = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).name;
74
75
 
75
76
  /**
76
- * The rank of a measure played at <racine>: 2 in the frame's own repository (its workspaces hold
77
- * the package @roomi-fields/grillhouse in development), 1 elsewhere.
77
+ * The rank of a measure played at <racine>: 1 in the frame's own repository (its workspaces hold
78
+ * the package @roomi-fields/grillhouse in development), 2 elsewhere.
78
79
  * @param {string} racine the root of the repository the measure plays in
79
80
  * @returns {1 | 2}
80
81
  */
81
82
  export function rangDeLaMesure(racine) {
82
- return paquets(racine).some(p => p.pkg.name === CADRE) ? 2 : 1;
83
+ return paquets(racine).some(p => p.pkg.name === CADRE) ? 1 : 2;
83
84
  }
84
85
 
85
- const RANGS = { 1: 'mesure de premier rang', 2: 'mesure de second rang (le dépôt du cadre)' };
86
+ const RANGS = { 1: 'mesure du cadre', 2: "mesure d'un projet" };
86
87
 
87
88
  /** The longest wait for the lock of the machine, in ms, unless GRILLHOUSE_ATTENTE_MACHINE_MS names another. */
88
89
  export const ATTENTE_MACHINE_MS = 60 * 60_000;
@@ -203,8 +204,8 @@ function attendus(verrou, rang) {
203
204
  const avant = !premiers.length
204
205
  ? ''
205
206
  : premiers.length === 1
206
- ? ` ; une mesure de premier rang attend aussi et passe d'abord : ${processus(premiers[0])}`
207
- : ` ; ${premiers.length} mesures de premier rang attendent aussi et passent d'abord : ${premiers.map(processus).join(' ; ')}`;
207
+ ? ` ; une mesure du cadre attend aussi et passe d'abord : ${processus(premiers[0])}`
208
+ : ` ; ${premiers.length} mesures du cadre attendent aussi et passent d'abord : ${premiers.map(processus).join(' ; ')}`;
208
209
  return `le verrou de la mesure lourde (${verrou}) est ${tenu}${avant}`;
209
210
  }
210
211
 
@@ -7,7 +7,12 @@
7
7
  // - testwriter writes the files it owns, those the rule of a test file of the module of the
8
8
  // project's language classes (`estUnTest`, scripts/jointure.d.ts, scripts/langages.mjs): its test
9
9
  // files, the helpers of its folders of tests, and every file of a package of the shared test
10
- // material.
10
+ // material. Of the manifests, it writes what the module declares its (`manifestes`): a write of
11
+ // a component's manifest whose only change from the file on disk lies in the part of its tests
12
+ // (`horsDesTests` empty; the text after an Edit or a MultiEdit is the file's with its
13
+ // replacements), and the lock files of the versions; any other change of a manifest is refused,
14
+ // the path and each part named. A file of code is judged the same way when the module declares
15
+ // a part of it the tests' (cargo: the test module of a file of `src/`).
11
16
  // - The repository root is that of the git repository holding the written file, whatever the
12
17
  // agent's working directory; a file outside any repository is read against the working directory.
13
18
  // A project that declares no language (`grillhouse.langages`) is refused, exit code 2, the
@@ -19,7 +24,8 @@
19
24
  // - In an envelope (`GRILLHOUSE_ENVELOPPE`, the packages of the plan, scripts/enveloppe/
20
25
  // paquets-du-plan.mjs), a write in the copy out of the packages the plan writes (`ecritsDuPlan`
21
26
  // on the components of the module of the language, `paquetsDuLangage`, as the envelope reads them)
22
- // and out of the shared test material, whose rule is the one above, stops the session, as the
27
+ // and out of the shared test material, whose rule is the one above, and for the testwriter out
28
+ // of the lock files of the versions (`manifestes.verrous`), stops the session, as the
23
29
  // visibility of Bazel refuses a target the rule does not open: the hook answers Claude Code's
24
30
  // `continue: false`, the tool refused (`permissionDecision: deny`), its reason naming the file's
25
31
  // package and the plan, and leaves that reason in the session's working directory
@@ -76,10 +82,13 @@ function racineDe(file) {
76
82
  }
77
83
  }
78
84
 
79
- // The stop of a write out of the plan of the envelope <env>, `{ paquet, raison }`, or null: a
80
- // write in the repository holding the file, out of the packages the plan writes and out of the
81
- // shared test material.
82
- function horsDuPlan(input, { tmp = tmpdir(), env = process.env } = {}) {
85
+ // The role that writes the tests, the shared test material and the lock files of the versions.
86
+ const TESTWRITER = 'testwriter';
87
+
88
+ // The stop of a write of <role> out of the plan of the envelope <env>, `{ paquet, raison }`, or
89
+ // null: a write in the repository holding the file, out of the packages the plan writes, out of
90
+ // the shared test material and, for the testwriter, out of the lock files of the versions.
91
+ export function horsDuPlan(input, { tmp = tmpdir(), env = process.env, role = null } = {}) {
83
92
  const plan = paquetsDeLEnveloppe(env);
84
93
  if (!plan || !WRITE_TOOLS.has(input.tool_name)) return null;
85
94
  const raw = input.tool_input?.file_path ?? input.tool_input?.notebook_path;
@@ -88,11 +97,13 @@ function horsDuPlan(input, { tmp = tmpdir(), env = process.env } = {}) {
88
97
  if (isScratch(file, tmp)) return null;
89
98
  const copie = racineDe(file);
90
99
  if (!copie) return null;
91
- const liste = paquetsDuLangage(langageDe(copie), copie);
100
+ const langage = langageDe(copie);
101
+ const liste = paquetsDuLangage(langage, copie);
92
102
  const ecrits = ecritsDuPlan(plan, liste);
93
103
  const rel = path.relative(copie, file);
94
104
  if (ecrits.includes('.') || ecrits.some(d => rel.startsWith(`${d}/`))) return null;
95
- if (langageDe(copie).estUnTest(file, copie)?.matiere) return null;
105
+ if (langage.estUnTest(file, copie)?.matiere) return null;
106
+ if (role === TESTWRITER && langage.manifestes.verrous.includes(rel)) return null;
96
107
  const tenant = paquetQuiTient(rel, liste);
97
108
  const paquet = tenant === '.' ? 'la racine du dépôt' : tenant;
98
109
  return {
@@ -101,6 +112,23 @@ function horsDuPlan(input, { tmp = tmpdir(), env = process.env } = {}) {
101
112
  };
102
113
  }
103
114
 
115
+ // The text of the file at <file>, null when there is none.
116
+ const lu = file => (existsSync(file) ? readFileSync(file, 'utf8') : null);
117
+
118
+ // The text the write <input> leaves at <file>: a Write's content, the file's text with each
119
+ // replacement of an Edit or a MultiEdit, as Claude Code applies them; null for another tool.
120
+ function texteApres(input, file) {
121
+ const t = input.tool_input ?? {};
122
+ const remplacer = (texte, e) =>
123
+ e.replace_all
124
+ ? texte.split(e.old_string ?? '').join(e.new_string ?? '')
125
+ : texte.replace(e.old_string ?? '', () => e.new_string ?? '');
126
+ if (input.tool_name === 'Write') return t.content ?? '';
127
+ if (input.tool_name === 'Edit') return remplacer(lu(file) ?? '', t);
128
+ if (input.tool_name === 'MultiEdit') return (t.edits ?? []).reduce(remplacer, lu(file) ?? '');
129
+ return null;
130
+ }
131
+
104
132
  // The ticket id of the launch prompt. A sub-agent's prompt opens its own transcript, next to the
105
133
  // session's; an agent launched as its own session (`claude --agent`) has it in the session's.
106
134
  function ticketOf(input) {
@@ -159,13 +187,21 @@ export function refusal(role, input, { tmp = tmpdir(), describe = ticketDescript
159
187
  return null;
160
188
  }
161
189
  const racine = racineDe(file) ?? cwd;
162
- const classe = langageDe(racine).estUnTest(file, racine);
190
+ const langage = langageDe(racine);
191
+ const classe = langage.estUnTest(file, racine);
163
192
  const testwriter = classe !== null;
164
193
 
165
- if (role === 'testwriter') {
166
- return testwriter
167
- ? null
168
- : `Le testwriter écrit seulement des fichiers de test et la matière de test partagée ; ${raw} n'est ni l'un ni l'autre. Le code revient au développeur.`;
194
+ if (role === TESTWRITER) {
195
+ if (testwriter || langage.manifestes.verrous.includes(path.relative(racine, file))) return null;
196
+ const apres = texteApres(input, file);
197
+ const hors =
198
+ apres === null ? null : langage.manifestes.horsDesTests(file, racine, lu(file), apres);
199
+ if (hors?.length === 0) return null;
200
+ const regle =
201
+ "Le testwriter écrit seulement des fichiers de test, la matière de test partagée et, d'un manifeste ou d'un fichier de code, la part de ses tests";
202
+ return hors
203
+ ? `${regle} ; ce changement de ${raw} touche aussi ${hors.join(', ')}. Le reste du fichier revient au développeur.`
204
+ : `${regle} ; ${raw} n'est rien de cela. Le code revient au développeur.`;
169
205
  }
170
206
  if (role === 'developpeur') {
171
207
  if (testwriter) {
@@ -193,7 +229,7 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
193
229
  let stop = null;
194
230
  let reason = null;
195
231
  try {
196
- stop = horsDuPlan(input);
232
+ stop = horsDuPlan(input, { role: process.argv[2] });
197
233
  if (!stop) reason = refusal(process.argv[2], input);
198
234
  } catch (e) {
199
235
  reason = e.message;
@@ -117,6 +117,10 @@ avec ta fiche. Ainsi le circuit reprend dès ta fiche rendue.
117
117
  travail.
118
118
  - **Un test que tu crois faux** part au superviseur, avec la règle qu'il contredit. Les tests et la
119
119
  matière de test partagée sont au testwriter.
120
+ - **Le module de test d'un fichier de code est au testwriter** : dans un projet cargo, la ligne
121
+ `#[cfg(test)] mod tests;` déclare le `tests.rs` (ou le dossier `tests/`) que le testwriter
122
+ écrit près du module ; il l'écrit avec son test, et tu ne la touches pas, ni un module de test
123
+ en ligne. Ainsi chaque test arrive compilé, avant ton code.
120
124
 
121
125
  Une découverte qui ne bloque pas entre dans `decouvertes` de ta fiche (son sujet, son exemple et
122
126
  son adresse) : le circuit la consigne fermée sous ton ticket, et tu continues.
@@ -58,7 +58,9 @@ change, et ceux qu'il peut casser.
58
58
  répond à un besoin réel de l'usage actuel, et se confronte à la spécification. Ma fiche ne
59
59
  porte que les critères que j'ajoute : les critères déjà écrits au ticket sont la décision du
60
60
  responsable, que le circuit garde tels quels, les miens après eux. Pour changer ou retirer un
61
- critère écrit, je pose une question ouverte ;
61
+ critère écrit, je pose une question ouverte. Un critère sur le changelog s'écrit
62
+ « le CHANGELOG le dit », sans le lier à un titre de section, que chaque sortie déplace : le
63
+ relecteur juge l'entrée sur le lot, et aucun test ne la lit ;
62
64
  - `paquets` : les paquets à toucher, le fournisseur d'abord, puis ses lecteurs, chacun comme le
63
65
  titre le nomme (le nom de son paquet, ou son chemin) ; le circuit les écrit au titre, et
64
66
  chaque séance du ticket n'écrit qu'eux ;
@@ -93,7 +93,9 @@ nomme le responsable, ce qui décide, les documents qu'il valide et les commande
93
93
  les lui envoie avec sa sortie ; toute autre commande en échec ou un fichier qu'aucune référence
94
94
  n'écrit arrête à `references`, code 23, une question pour moi qui porte chaque écart : je fais
95
95
  corriger la référence ou le lot, 4.3 le relecteur), 5 Intégration (5.1
96
- le commit, 5.2 la file et la lecture de la CI, 5.3 le tri des découvertes par l'explorateur, sur
96
+ le commit, 5.2 la file et la lecture de la CI : une CI rouge rouvre le ticket ; un rejeu vert
97
+ des jobs rouges, `gh run rerun <id> --failed`, puis `--reprendre`, le ferme ; un test instable
98
+ se met en quarantaine dans le test, avec son ticket ; 5.3 le tri des découvertes par l'explorateur, sur
97
99
  le lot entré sur main, qui ne retarde pas la file et ne défait pas l'intégration) ; aucun composant n'est une unité du circuit, chaque
98
100
  étape joue une fois pour tout le ticket, dans l'enveloppe de tous les paquets du plan ; je dis
99
101
  où en est un ticket par son étape, « 3 Code » ; son en-tête dit ses arrêts et leurs codes. Ainsi
@@ -309,7 +311,9 @@ Le circuit du ticket fait chaque commit après le verdict `ACCEPTÉ` du relecteu
309
311
  la raison du verrou du développeur. Un mécanisme manquant devient le travail, jamais une compensation
310
312
  locale.
311
313
  - **Les critères naissent avec le ticket** : je crée chaque ticket de réalisation avec ses
312
- critères d'acceptation numérotés (`docs/agents/issue-tracker.md`, « Conventions »). Un cas
314
+ critères d'acceptation numérotés (`docs/agents/issue-tracker.md`, « Conventions ») ; un critère
315
+ sur le changelog dit « le CHANGELOG le dit », sans le lier à un titre de section, et le
316
+ relecteur le juge sur le lot. Un cas
313
317
  qu'un agent me rend en cours de travail s'y ajoute s'il est un besoin réel de l'usage actuel ;
314
318
  une remarque du relecteur hors des critères devient une découverte (`relecteur`, « Le
315
319
  verdict »). Ainsi chaque comportement attendu devient un test, et aucun agent ne le tranche
@@ -69,11 +69,11 @@ LES RÉFÉRENCES QUE LE CIRCUIT RÉGÉNÈRE à l'étape 4.2, sur la copie entiè
69
69
 
70
70
  Ta séance finit sur ta fiche, que ton schéma décrit et que le circuit lit seule ; ta passation au ticket (`bd comments add`) reste, pour l'humain et la séance suivante de ton rôle : ce qui est fait, ce qui ne l'est pas et pourquoi.
71
71
 
72
- Testwriter : chaque test vert avant le code entre dans `verts_attendus` (son fichier depuis la racine, son nom complet tel que le rapport de la preuve l'écrit, sa raison) ; pour un fichier de tests que HEAD tient, adapté, dont tous les verts ont une même raison, le fichier et la raison seuls, qui n'excusent aucun rouge et ne valent rien sur un fichier neuf ; quand le ticket change un type ou un nom d'un paquet du plan, tu migres aussi, dans la même séance, la matière de test partagée et les tests du plan qui le lisent ; tu inscris, dans le même lot, chaque nom de la matière de test partagée que tes tests se mettent à importer, sur la ligne de leur paquet dans la section « Consommateurs » de l'interface du fournisseur. Développeur : quand le rouge qui reste est dans les tests du lot, ta fiche porte `renvoi` (testwriter), et le circuit relance le testwriter, puis la preuve et ta séance, sa consigne portant ta fiche, ta passation et la sortie rouge des derniers contrôles ; un critère que tu ne tiens pas parce qu'il demande un paquet hors du plan va dans `hors_plan` (son numéro, ce paquet, sa pièce), même quand ta fiche dit FAIT, et le circuit monte au superviseur à 3 Code ; sur FAIT, ta fiche répond à chaque constat du relecteur ouvert pour toi, par son titre, dans `reponses` (`levé` avec sa `piece`, ou `contesté` avec sa `raison` et sa `piece`), que le relecteur lit sous son constat, et le circuit refuse une fiche à laquelle il en manque une ; quand le superviseur te donne ta tâche, en tête de cette consigne, les constats ouverts au lancement de sa passe te sont donnés en contexte : une réponse que tu leur donnes reste lue sous son constat, aucune n'est exigée ; un constat qu'un `RENDU` pose dans la passe exige la sienne ; un écart que le commit doit nommer va dans `ecarts`, sous son sujet. Ainsi chaque rouge va à l'agent qui le lève.
72
+ Testwriter : chaque test vert avant le code entre dans `verts_attendus` (son fichier depuis la racine, son nom complet tel que le rapport de la preuve l'écrit, sa raison) ; pour un fichier de tests que HEAD tient, adapté, dont tous les verts ont une même raison, le fichier et la raison seuls, qui n'excusent aucun rouge et ne valent rien sur un fichier neuf ; quand le ticket change un type ou un nom d'un paquet du plan, tu migres aussi, dans la même séance, la matière de test partagée et les tests du plan qui le lisent ; tu inscris, dans le même lot, chaque nom de la matière de test partagée que tes tests se mettent à importer, sur la ligne de leur paquet dans la section « Consommateurs » de l'interface du fournisseur ; une dépendance que tes tests demandent, tu la déclares toi-même, par Write ou Edit, dans la partie des tests du manifeste d'un paquet du plan (`devDependencies` d'un `package.json`, `[dev-dependencies]` d'un `Cargo.toml`) et dans le fichier de verrouillage des versions, et ton verrou refuse tout autre changement du manifeste, chaque partie nommée. Développeur : quand le rouge qui reste est dans les tests du lot, ta fiche porte `renvoi` (testwriter), et le circuit relance le testwriter, puis la preuve et ta séance, sa consigne portant ta fiche, ta passation et la sortie rouge des derniers contrôles ; un critère que tu ne tiens pas parce qu'il demande un paquet hors du plan va dans `hors_plan` (son numéro, ce paquet, sa pièce), même quand ta fiche dit FAIT, et le circuit monte au superviseur à 3 Code ; sur FAIT, ta fiche répond à chaque constat du relecteur ouvert pour toi, par son titre, dans `reponses` (son titre sans le numéro « Constat N — » de cette consigne ; `levé` avec sa `piece`, ou `contesté` avec sa `raison` et sa `piece`), que le relecteur lit sous son constat, et le circuit refuse une fiche à laquelle il en manque une ; quand le superviseur te donne ta tâche, en tête de cette consigne, les constats ouverts au lancement de sa passe te sont donnés en contexte : une réponse que tu leur donnes reste lue sous son constat, aucune n'est exigée ; un constat qu'un `RENDU` pose dans la passe exige la sienne ; un écart que le commit doit nommer va dans `ecarts`, sous son sujet. Ainsi chaque rouge va à l'agent qui le lève.
73
73
 
74
74
  Le `statut` de ta fiche : FAIT quand ta part est faite ; BLOQUÉ, avec sa `raison`, quand ce qui reste est hors de ta portée (dans les tests, dans la matière de test partagée, dans un fichier hors du plan, ou une décision hors de ton rôle) ; BESOIN, avec sa `question`, quand une réponse te manque pour avancer. Sur BESOIN, ou BLOQUÉ sans `renvoi`, le circuit s'arrête sans te relancer, et ta question monte au superviseur ; une découverte hors des critères va dans `decouvertes`, que le circuit consigne. Ainsi aucune séance ne tourne sur ce que son agent a dit hors de sa portée.
75
75
 
76
- Tu travailles dans ta copie (`.claude/worktrees/{{ticket}}`), dans l'enveloppe du plan du ticket : tu lis toute la copie, par l'index d'abord (rtfm, codegraph), et tu n'écris que les paquets du plan, les composants du titre ; le paquet de la matière de test partagée, seul le testwriter l'écrit. Une écriture hors du plan échoue, et ton verrou arrête ta séance : le superviseur étend le plan ou refuse. Ainsi tu lis tout, et tu changes le seul plan.
76
+ Tu travailles dans ta copie (`.claude/worktrees/{{ticket}}`), dans l'enveloppe du plan du ticket : tu lis toute la copie, par l'index d'abord (rtfm, codegraph), et tu n'écris que les paquets du plan, les composants du titre ; le paquet de la matière de test partagée et le fichier de verrouillage des versions à la racine, seul le testwriter les écrit. Une écriture hors du plan échoue, et ton verrou arrête ta séance : le superviseur étend le plan ou refuse. Ainsi tu lis tout, et tu changes le seul plan.
77
77
 
78
78
  Le lanceur a avancé ta copie sur main avant d'ouvrir ta séance : tu pars du dernier commit. Ainsi ton lot s'applique sur l'état présent du dépôt.
79
79
 
@@ -147,7 +147,7 @@ LE RAPPORT NEUF, mesuré par le circuit :
147
147
 
148
148
  {{constats}}
149
149
 
150
- Fais ta tâche quand le superviseur t'en donne une, en tête de cette consigne, et lève ce que disent ce rapport et les constats qui ne sont pas donnés en contexte ; sans tâche, lève ce que disent ce rapport et ces constats ; toujours dans le cadre de ta consigne. Ta séance finit sur ta fiche, que le circuit lit : `statut` FAIT, BLOQUÉ avec sa `raison`, ou BESOIN avec sa `question` ; développeur, sur FAIT, ta réponse à ces constats, par son titre (`reponses`), exigée pour chacun qui n'est pas donné en contexte. Ainsi le circuit lit ta fin.
150
+ Fais ta tâche quand le superviseur t'en donne une, en tête de cette consigne, et lève ce que disent ce rapport et les constats qui ne sont pas donnés en contexte ; sans tâche, lève ce que disent ce rapport et ces constats ; toujours dans le cadre de ta consigne. Ta séance finit sur ta fiche, que le circuit lit : `statut` FAIT, BLOQUÉ avec sa `raison`, ou BESOIN avec sa `question` ; développeur, sur FAIT, ta réponse à ces constats, par son titre sans son numéro « Constat N — » (`reponses`), exigée pour chacun qui n'est pas donné en contexte. Ainsi le circuit lit ta fin.
151
151
  ```
152
152
 
153
153
  ## Questionneur, sur le plan (rempli par le circuit)
@@ -77,7 +77,7 @@ les constats d'avant, chacun avec la réponse du développeur sous lui (« Répo
77
77
  `levé` ou `contesté` avec sa raison, et sa pièce).
78
78
 
79
79
  1. Chaque constat d'avant se juge levé ou non, sa preuve tirée de la différence, dans `suivi`
80
- (son titre, `levé` ou `non levé`, la preuve). Une réponse `contesté` se juge sur sa raison et
80
+ (son titre sans son numéro « Constat N — », `levé` ou `non levé`, la preuve). Une réponse `contesté` se juge sur sa raison et
81
81
  sa pièce, relues, et ta preuve dit pourquoi elle tient ou non. Un constat non levé revient dans `constats`, bloquant, au même destinataire.
82
82
  2. Les six passes portent sur la différence : un constat bloquant neuf que le correctif crée,
83
83
  dans les lignes qu'il change, rend le lot.
@@ -113,7 +113,11 @@ cet ordre.
113
113
  5. **L'existant** : cette notion existe-t-elle déjà ailleurs dans le projet, dans ce composant ou un
114
114
  autre ? Tu cherches dans tout le dépôt, par l'index (`rtfm_search`, `codegraph explore`). Ainsi le produit garde un seul calcul par notion.
115
115
  6. **Les critères** : chaque critère d'acceptation du ticket a son test, qui échoue sans le code ;
116
- le code ne fait rien que les critères ne disent. Tu lances les tests par `npm test --
116
+ le code ne fait rien que les critères ne disent. L'entrée du CHANGELOG se juge sur le lot,
117
+ comme une revue mûre relit les notes de version : un critère qui la nomme n'a pas de test, et
118
+ tu lis l'entrée que le lot ajoute, ce qu'elle dit du changement et de son pourquoi ; un test du
119
+ lot qui lit le CHANGELOG, ou un autre document de suivi des versions, se rend au testwriter
120
+ (`testwriter`, « Aucun test ne lit le CHANGELOG »). Tu lances les tests par `npm test --
117
121
  <fichiers>` (chemins depuis la racine du dépôt) ; une sortie relue du cache de Turborepo (« cache hit, replaying logs ») vaut un
118
122
  lancement, tu ne la rejoues pas pour la croire. Un test mis en quarantaine (`it.skip`,
119
123
  `it.fails`) nomme le ticket qui le corrige, sinon le lot est rendu. Un banc de temps ou un test