@roomi-fields/grillhouse 0.50.3 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +68 -0
  3. package/agents/developpeur.md +1 -1
  4. package/agents/direct.md +1 -1
  5. package/agents/explorateur.md +1 -1
  6. package/agents/questionneur.md +1 -1
  7. package/agents/relecteur.md +1 -1
  8. package/agents/testwriter.md +1 -1
  9. package/cadre/templates/c/package.json +1 -0
  10. package/cadre/templates/cargo/package.json +1 -0
  11. package/cadre/templates/python/package.json +1 -0
  12. package/charte/plan.md +47 -0
  13. package/charte/preuve.md +39 -0
  14. package/charte/superviseur.md +61 -0
  15. package/charte/tests.md +38 -0
  16. package/charte.md +39 -189
  17. package/dist/machine/part-par-sorte.d.ts +16 -0
  18. package/dist/machine/part-par-sorte.js +36 -0
  19. package/dist/machine/part-par-sorte.js.map +1 -0
  20. package/dist/temporal/circuit/appel.js +1 -1
  21. package/dist/temporal/circuit/appel.js.map +1 -1
  22. package/dist/temporal/circuit/client.d.ts +4 -4
  23. package/dist/temporal/circuit/client.js +38 -16
  24. package/dist/temporal/circuit/client.js.map +1 -1
  25. package/dist/temporal/circuit/contrat.d.ts +11 -7
  26. package/dist/temporal/circuit/contrat.js +5 -9
  27. package/dist/temporal/circuit/contrat.js.map +1 -1
  28. package/dist/temporal/circuit/deroule.js +18 -6
  29. package/dist/temporal/circuit/deroule.js.map +1 -1
  30. package/dist/temporal/commande.js +12 -3
  31. package/dist/temporal/commande.js.map +1 -1
  32. package/dist/temporal/installation.d.ts +54 -3
  33. package/dist/temporal/installation.js +187 -17
  34. package/dist/temporal/installation.js.map +1 -1
  35. package/dist/temporal/places/client.d.ts +5 -1
  36. package/dist/temporal/places/client.js +23 -11
  37. package/dist/temporal/places/client.js.map +1 -1
  38. package/docs/ARCHITECTURE.md +23 -2700
  39. package/docs/INTERFACE.md +26 -10
  40. package/docs/architecture/circuit.md +61 -14
  41. package/docs/architecture/entree.md +21 -8
  42. package/docs/architecture/greffon.md +49 -20
  43. package/docs/architecture/installation.md +46 -17
  44. package/docs/architecture/machine.md +79 -39
  45. package/docs/architecture/tests.md +59 -16
  46. package/docs/lexique.md +163 -0
  47. package/hooks/hooks.json +0 -10
  48. package/hooks/register.tsx +92 -4
  49. package/package.json +2 -1
  50. package/scripts/activites.mjs +105 -65
  51. package/scripts/aiguillage.mjs +15 -8
  52. package/scripts/attente-au-tour.mjs +2 -3
  53. package/scripts/attente-de-la-machine.mjs +4 -8
  54. package/scripts/avancement.mjs +12 -8
  55. package/scripts/bilan.mjs +126 -63
  56. package/scripts/bilans-gardes.mjs +37 -0
  57. package/scripts/branche-de-nuit.mjs +2 -2
  58. package/scripts/ci-de-main.mjs +18 -21
  59. package/scripts/circuit.mjs +89 -44
  60. package/scripts/circuits-du-serveur.mjs +5 -5
  61. package/scripts/composants-affectes.mjs +30 -12
  62. package/scripts/composition-des-langages.mjs +5 -3
  63. package/scripts/conformite.mjs +1 -1
  64. package/scripts/consommation-des-passes.mjs +8 -6
  65. package/scripts/copies-finies.mjs +3 -14
  66. package/scripts/depart-du-ticket.d.mts +8 -2
  67. package/scripts/depart-du-ticket.mjs +26 -8
  68. package/scripts/direct.mjs +158 -72
  69. package/scripts/droits.mjs +165 -208
  70. package/scripts/engendres.mjs +3 -14
  71. package/scripts/entree-de-seance.mjs +35 -0
  72. package/scripts/enveloppe/enveloppe.mjs +98 -46
  73. package/scripts/enveloppe/lancer.sh +90 -66
  74. package/scripts/enveloppe/paquets-du-plan.mjs +38 -11
  75. package/scripts/enveloppe/travail-de-la-copie.mjs +192 -3
  76. package/scripts/etapes.mjs +84 -22
  77. package/scripts/faits-du-circuit.mjs +8 -2
  78. package/scripts/grillhouse-maj.mjs +43 -18
  79. package/scripts/groupe-cles.d.mts +15 -0
  80. package/scripts/groupe-cles.mjs +77 -2
  81. package/scripts/init.mjs +9 -2
  82. package/scripts/integration/rejeu.mjs +8 -1
  83. package/scripts/jointure.d.ts +24 -4
  84. package/scripts/langages/c/index.mjs +5 -2
  85. package/scripts/langages/cargo/commandes.mjs +35 -15
  86. package/scripts/langages/cargo/composants.mjs +45 -3
  87. package/scripts/langages/cargo/index.mjs +6 -3
  88. package/scripts/langages/python/commandes.mjs +50 -7
  89. package/scripts/langages/python/index.mjs +5 -2
  90. package/scripts/langages/python/squelette.mjs +2 -1
  91. package/scripts/langages/typescript/chemins-des-tests.mjs +1 -1
  92. package/scripts/langages/typescript/index.mjs +16 -14
  93. package/scripts/langages/typescript/mise-a-jour.mjs +1 -1
  94. package/scripts/langages/typescript/rapports-aux-lignes.mjs +74 -0
  95. package/scripts/langages/typescript/turbo-des-paquets.mjs +151 -38
  96. package/scripts/langages/typescript/verdict.mjs +29 -3
  97. package/scripts/langages/typescript/verifier.mjs +28 -3
  98. package/scripts/langages/typescript/vitest-config/changements.mjs +8 -6
  99. package/scripts/langages/typescript/vitest-config/lances.mjs +15 -32
  100. package/scripts/langages.mjs +54 -4
  101. package/scripts/matieres-lues.mjs +1 -1
  102. package/scripts/mesure/base-de-passe.mjs +32 -90
  103. package/scripts/migrations/serveurs-de-l-index.mjs +79 -0
  104. package/scripts/migrations/suivi-du-superviseur-retire.mjs +56 -0
  105. package/scripts/migrations.mjs +23 -7
  106. package/scripts/nuit.sh +3 -2
  107. package/scripts/paquet.mjs +1 -1
  108. package/scripts/paquets.d.ts +3 -0
  109. package/scripts/paquets.mjs +88 -1
  110. package/scripts/passe-de-la-machine.mjs +109 -36
  111. package/scripts/places-de-la-machine.mjs +81 -29
  112. package/scripts/plafond-de-la-machine.d.mts +2 -5
  113. package/scripts/plafond-de-la-machine.mjs +9 -9
  114. package/scripts/reprise.mjs +42 -13
  115. package/scripts/resultats.mjs +78 -56
  116. package/scripts/retirer-les-copies-finies.mjs +1 -1
  117. package/scripts/seances.mjs +471 -133
  118. package/scripts/services-du-noyau.mjs +9 -1
  119. package/scripts/session-start.sh +22 -7
  120. package/scripts/sortie-de-seance.mjs +70 -0
  121. package/scripts/sortie.mjs +37 -6
  122. package/scripts/sous-commandes.mjs +0 -3
  123. package/scripts/superviseur.mjs +400 -162
  124. package/scripts/tableau.mjs +188 -65
  125. package/scripts/transitions.d.mts +25 -2
  126. package/scripts/transitions.mjs +137 -29
  127. package/scripts/verrous/ecriture-hors-enveloppe.mjs +31 -9
  128. package/skills/codebase-design/DESIGN-IT-TWICE.md +1 -1
  129. package/skills/developpeur/SKILL.md +38 -15
  130. package/skills/direct/SKILL.md +29 -9
  131. package/skills/domain-modeling/GLOSSARY-FORMAT.md +9 -9
  132. package/skills/domain-modeling/SKILL.md +14 -12
  133. package/skills/explorateur/SKILL.md +32 -8
  134. package/skills/grill/SKILL.md +3 -2
  135. package/skills/pitmaster/SKILL.md +80 -50
  136. package/skills/pitmaster/references/cadre.md +1 -1
  137. package/skills/pitmaster/references/consigne-agent.md +12 -11
  138. package/skills/pitmaster/references/tour.md +6 -5
  139. package/skills/relecteur/SKILL.md +13 -6
  140. package/skills/systematic-debugging/SKILL.md +281 -0
  141. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  142. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  143. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  144. package/skills/systematic-debugging/find-polluter.sh +72 -0
  145. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  146. package/skills/testwriter/SKILL.md +37 -31
  147. package/cadre/templates/projet/pitmaster/SUIVI.md +0 -22
  148. package/scripts/attente-a-l-arret.mjs +0 -114
  149. package/scripts/verrous/commande.mjs +0 -214
  150. package/scripts/verrous/verrou.mjs +0 -311
@@ -5,18 +5,11 @@
5
5
  // these packages only: a command of the frame that reads the list builds, judges and writes them
6
6
  // alone. This module uses Node alone, as the modules of scripts/paquets.mjs. Architecture:
7
7
  // docs/architecture/machine.md (§4.1, §5.5).
8
+ import { spawnSync } from 'node:child_process';
8
9
  import path from 'node:path';
9
10
  import { paquets } from '../paquets.mjs';
10
11
 
11
12
  export const VARIABLE = 'GRILLHOUSE_ENVELOPPE';
12
- // The file the lock of a session leaves in its working directory when it stops the session on a
13
- // write out of the plan (scripts/verrous/verrou.mjs); the launcher hands it to the circuit in the
14
- // session's result folder, `<copie>.travail/seances/<id>/hors-plan` (scripts/enveloppe/lancer.sh).
15
- export const MARQUE_HORS_PLAN = 'hors-plan';
16
- // Its structured twin, `{ chemin, paquet, racine }` in JSON: the path written, the package that
17
- // holds it (`.` for the repository root), whether the root holds it. The circuit reads it, not the text.
18
- export const MARQUE_HORS_PLAN_FAIT = 'hors-plan.json';
19
-
20
13
  // The list <paquets> as the variable carries it.
21
14
  export const ecrireLaListe = paquets => paquets.join(path.delimiter);
22
15
 
@@ -78,11 +71,45 @@ export function paquetQuiTient(chemin, paquetsDeLaCopie) {
78
71
  return tenants.sort((a, b) => b.length - a.length)[0] ?? '.';
79
72
  }
80
73
 
74
+ /**
75
+ * Whether the component <chemin> of a plan is written as a path of the repository that may not
76
+ * exist yet: with a `/`, no `@` at its head (the name of a scoped package), within the repository.
77
+ * @param {string} chemin
78
+ */
79
+ export function estUnCheminNeuf(chemin) {
80
+ const n = path.normalize(chemin).replace(/\/+$/, '');
81
+ return (
82
+ chemin.includes('/') &&
83
+ !chemin.startsWith('@') &&
84
+ !path.isAbsolute(n) &&
85
+ !['.', '..'].includes(n) &&
86
+ !n.startsWith('../')
87
+ );
88
+ }
89
+
90
+ // Whether the base commit of the copy <copie> (its HEAD) lacks the path <rel>; false where git
91
+ // reads no commit.
92
+ function absentDeLaBase(copie, rel) {
93
+ const lire = objet => spawnSync('git', ['-C', copie, 'cat-file', '-e', objet]).status === 0;
94
+ return lire('HEAD^{commit}') && !lire(`HEAD:${rel}`);
95
+ }
96
+
81
97
  // The directories, relative to the copy, that the plan <paquets> writes, sorted: for each path of
82
98
  // the plan, the package that holds it (`paquetQuiTient`). A path that no package holds (a folder of
83
99
  // the root, `scripts`; `src/parser` in a one-package project; `.`) writes the package that holds
84
- // it, the root: the plan then writes the whole copy, `['.']`.
85
- export function ecritsDuPlan(paquets, paquetsDeLaCopie) {
86
- const ecrits = [...new Set(paquets.map(p => paquetQuiTient(p, paquetsDeLaCopie)))].sort();
100
+ // it, the root: the plan then writes the whole copy, `['.']`. But a new path of the copy <copie>
101
+ // (`estUnCheminNeuf`), which no package holds and its base commit lacks, writes itself alone: a
102
+ // package to be born.
103
+ export function ecritsDuPlan(paquets, paquetsDeLaCopie, copie = null) {
104
+ const aLaRacine = paquetsDeLaCopie.some(p => path.normalize(p.dossier) === '.');
105
+ const ecrit = p => {
106
+ const tenant = paquetQuiTient(p, paquetsDeLaCopie);
107
+ if (tenant !== '.' || aLaRacine || !copie || !estUnCheminNeuf(p)) {
108
+ return tenant;
109
+ }
110
+ const rel = path.normalize(p).replace(/\/+$/, '');
111
+ return absentDeLaBase(copie, rel) ? rel : tenant;
112
+ };
113
+ const ecrits = [...new Set(paquets.map(ecrit))].sort();
87
114
  return ecrits.includes('.') ? ['.'] : ecrits;
88
115
  }
@@ -9,7 +9,11 @@
9
9
  //
10
10
  // node scripts/enveloppe/travail-de-la-copie.mjs reporter <copie> <base> <pointe>
11
11
  // node scripts/enveloppe/travail-de-la-copie.mjs preparer <copie> [<cible>]
12
+ // node scripts/enveloppe/travail-de-la-copie.mjs photographier <copie>
12
13
  //
14
+ // - `photographier`: the tree <copie> holds, on stdout in JSON, which the launcher takes once the
15
+ // copy is prepared, before the session: the state its lot is read from (scripts/seances.mjs,
16
+ // « le jugement du lot »).
13
17
  // - `preparer`: the one preparation of a copy, which the launcher plays before each session and
14
18
  // the circuit before each pass that judges the lot. With <cible> (an existing copy), the guard
15
19
  // of its submodules (scripts/sous-modules.sh `garde`), then `avancer`; then, for every copy,
@@ -29,6 +33,8 @@
29
33
  // copy brought back to HEAD, moved forward, the lot applied three ways. The lot waits in the
30
34
  // copy's own git directory (`git rev-parse --git-dir`, `grillhouse-travail.patch`) while the
31
35
  // copy moves, and goes once it is applied.
36
+ // - First, an index the circuit saved before a command of its checks, left by a killed
37
+ // process, is put back (`rendreLIndex`).
32
38
  // - The lot applies file by file (one `git apply --3way` per file, its patch alone): a file that
33
39
  // fails touches none of the others. A file in conflict keeps its marks; a file git refuses
34
40
  // without marks (a deletion of a file main changed) stays alone in the lot kept in the git
@@ -80,7 +86,19 @@
80
86
  // declared) is advanced all the same, its references merged as files written by hand, and the
81
87
  // fault is said: on stderr, in the log of the preparation for the circuit.
82
88
  import { spawnSync } from 'node:child_process';
83
- import { existsSync, readFileSync, rmSync, statSync, writeFileSync, writeSync } from 'node:fs';
89
+ import {
90
+ copyFileSync,
91
+ existsSync,
92
+ mkdtempSync,
93
+ readFileSync,
94
+ renameSync,
95
+ rmSync,
96
+ statSync,
97
+ utimesSync,
98
+ writeFileSync,
99
+ writeSync,
100
+ } from 'node:fs';
101
+ import { tmpdir } from 'node:os';
84
102
  import path from 'node:path';
85
103
  import { pathToFileURL } from 'node:url';
86
104
  import { couvertPar, encoreDeclares, engendresDe, regenerer, touchesPar } from '../engendres.mjs';
@@ -100,6 +118,77 @@ const lignes = r =>
100
118
  .map(l => l.trim())
101
119
  .filter(Boolean);
102
120
 
121
+ // The index of a copy as it was before the circuit put the lot there, in the copy's git directory.
122
+ const INDEX_SAUVE = 'grillhouse-index';
123
+
124
+ // The index of <copie> and the file that saves it, absolute; null out of git.
125
+ function indexDeLaCopie(copie) {
126
+ const r = git(copie, [
127
+ 'rev-parse',
128
+ '--path-format=absolute',
129
+ '--git-path',
130
+ 'index',
131
+ '--git-path',
132
+ INDEX_SAUVE,
133
+ ]);
134
+ if (r.status !== 0) {
135
+ return null;
136
+ }
137
+ const [index, sauve] = lignes(r);
138
+ return { index, sauve };
139
+ }
140
+
141
+ /**
142
+ * Puts back the index of <copie> that `inscrireLeLot` saved, in one rename, when one waits in its
143
+ * git directory: after the command, or before the next gesture that reads the index, when the
144
+ * process that ran the command was killed.
145
+ * @param {string} copie
146
+ */
147
+ export function rendreLIndex(copie) {
148
+ const i = indexDeLaCopie(copie);
149
+ if (i && existsSync(i.sauve)) {
150
+ renameSync(i.sauve, i.index);
151
+ }
152
+ }
153
+
154
+ /**
155
+ * Puts the lot of <copie> in its index (`git add -A`, the ignored files left out) for a command
156
+ * that judges it, so that a reader of the index sees a new file as a tracked one and a deleted
157
+ * file no more; the index as it was, unresolved conflicts included, waits in the git directory of
158
+ * the copy until `rendreLIndex`. Throws, naming git, the index unchanged, when git fails.
159
+ * @param {string} copie
160
+ */
161
+ export function inscrireLeLot(copie) {
162
+ rendreLIndex(copie);
163
+ const refus = r =>
164
+ new Error(
165
+ `git ne met pas le lot à l'index de la copie ${copie} (git add -A) : la commande ne joue pas.\n${texte(r)}`
166
+ );
167
+ const rev = git(copie, ['rev-parse', '--git-dir']);
168
+ const i = indexDeLaCopie(copie);
169
+ if (!i) {
170
+ throw refus(rev);
171
+ }
172
+ // A repository without an index file has an empty one, written so that it can be put back.
173
+ if (!existsSync(i.index)) {
174
+ const vide = git(copie, ['read-tree', '--empty']);
175
+ if (vide.status !== 0) {
176
+ throw refus(vide);
177
+ }
178
+ }
179
+ // Saved whole or not at all: copied aside, then renamed. Its time with it: git reads it to
180
+ // judge a file written in the same instant as the index.
181
+ const { atime, mtime } = statSync(i.index);
182
+ copyFileSync(i.index, `${i.sauve}.tmp`);
183
+ utimesSync(`${i.sauve}.tmp`, atime, mtime);
184
+ renameSync(`${i.sauve}.tmp`, i.sauve);
185
+ const r = git(copie, ['add', '-A']);
186
+ if (r.status !== 0) {
187
+ rendreLIndex(copie);
188
+ throw refus(r);
189
+ }
190
+ }
191
+
103
192
  // The files of <copie> unmerged in its index.
104
193
  const enConflit = copie => lignes(git(copie, ['diff', '--name-only', '--diff-filter=U']));
105
194
 
@@ -354,6 +443,101 @@ export function ecritPar(role, estUnTest) {
354
443
  return undefined;
355
444
  }
356
445
 
446
+ // The paths a session's lot leaves out: the tickets' store, and the copies of the tickets the main
447
+ // tree holds, which the circuit brings.
448
+ const HORS_DU_LOT = ['.beads/', '.claude/worktrees/'];
449
+
450
+ // The output of the read `git <args>` in <depot>; a read that fails throws, its error named.
451
+ function lireGit(depot, args, env = process.env) {
452
+ const r = spawnSync('git', ['-C', depot, '--literal-pathspecs', ...args], {
453
+ env,
454
+ maxBuffer: 256 * 1024 * 1024,
455
+ });
456
+ if (r.status !== 0) {
457
+ throw new Error(`git ${args.join(' ')} échoue dans ${depot} : ${String(r.stderr ?? '').trim()}`);
458
+ }
459
+ return String(r.stdout);
460
+ }
461
+
462
+ /**
463
+ * The tree <depot> holds now, `{ arbre, tete }`: the git tree of every file that git does not
464
+ * ignore, as it lies on disk, written through an index of its own (the index of <depot> is left as
465
+ * it is), and the commit of HEAD; null out of git.
466
+ * @param {string} depot
467
+ * @returns {{ arbre: string, tete: string } | null}
468
+ */
469
+ export function photographier(depot) {
470
+ const g = spawnSync('git', ['-C', depot, 'rev-parse', '--absolute-git-dir'], { encoding: 'utf8' });
471
+ if (g.status !== 0) {
472
+ return null;
473
+ }
474
+ const dossier = mkdtempSync(path.join(tmpdir(), 'grillhouse-photo-'));
475
+ try {
476
+ const index = path.join(dossier, 'index');
477
+ const sien = path.join(g.stdout.trim(), 'index');
478
+ if (existsSync(sien)) {
479
+ // Its time with it: git reads it to judge a file written in the same instant as the index.
480
+ const { atime, mtime } = statSync(sien);
481
+ copyFileSync(sien, index);
482
+ utimesSync(index, atime, mtime);
483
+ }
484
+ const env = { ...process.env, GIT_INDEX_FILE: index };
485
+ lireGit(depot, ['add', '-A'], env);
486
+ return {
487
+ arbre: lireGit(depot, ['write-tree'], env).trim(),
488
+ tete: lireGit(depot, ['rev-parse', 'HEAD']).trim(),
489
+ };
490
+ } finally {
491
+ rmSync(dossier, { recursive: true, force: true });
492
+ }
493
+ }
494
+
495
+ /**
496
+ * The files that differ between the trees (or commits) <avant> and <apres> of <depot>, the paths a
497
+ * lot leaves out aside: `{ chemin, avant, apres }`, each state « <mode> <objet> », null without the
498
+ * file.
499
+ * @param {string} depot
500
+ * @param {string} avant
501
+ * @param {string} apres
502
+ * @returns {{ chemin: string, avant: string | null, apres: string | null }[]}
503
+ */
504
+ export function changements(depot, avant, apres) {
505
+ const mots = lireGit(depot, ['diff-tree', '-r', '-z', '--no-renames', avant, apres]).split('\0');
506
+ const out = [];
507
+ for (let i = 0; i + 1 < mots.length; i += 2) {
508
+ const [modeA, modeB, a, b] = mots[i].slice(1).split(' ');
509
+ const etat = (mode, objet) => (/^0+$/.test(mode) ? null : `${mode} ${objet}`);
510
+ out.push({ chemin: mots[i + 1], avant: etat(modeA, a), apres: etat(modeB, b) });
511
+ }
512
+ return out.filter(c => !HORS_DU_LOT.some(d => c.chemin.startsWith(d)));
513
+ }
514
+
515
+ /**
516
+ * The state of the file <chemin> in the tree (or commit) <arbre> of <depot>, as `changements` gives
517
+ * it.
518
+ * @param {string} depot
519
+ * @param {string} arbre
520
+ * @param {string} chemin
521
+ * @returns {string | null}
522
+ */
523
+ export function etatDuFichier(depot, arbre, chemin) {
524
+ const ligne = lireGit(depot, ['ls-tree', '-z', arbre, '--', chemin]).split('\0')[0];
525
+ if (!ligne) {
526
+ return null;
527
+ }
528
+ const [mode, , objet] = ligne.split('\t')[0].split(' ');
529
+ return `${mode} ${objet}`;
530
+ }
531
+
532
+ /**
533
+ * The text of the file of state <etat> in <depot>, null without a file.
534
+ * @param {string} depot
535
+ * @param {string | null} etat
536
+ * @returns {string | null}
537
+ */
538
+ export const texteDeLEtat = (depot, etat) =>
539
+ etat === null ? null : lireGit(depot, ['cat-file', 'blob', etat.split(' ')[1]]);
540
+
357
541
  /**
358
542
  * The lot from <base> to <pointe> as local work of <copie>; returns `{ ok, message }`. <dire>
359
543
  * receives a fault that does not refuse the lot, and the output of the command of a generated file
@@ -404,6 +588,7 @@ const conflit = (copie, conflits, entete) =>
404
588
  * @param {{ ecrit?: (fichier: string) => boolean, suspects?: string[], duCadre?: (copie: string) => any[], dire?: (texte: string) => void }} [o]
405
589
  */
406
590
  export function avancer(copie, cible, { ecrit, suspects = [], duCadre, dire = surStderr } = {}) {
591
+ rendreLIndex(copie);
407
592
  releverLesResolus(copie);
408
593
  const restants = [
409
594
  ...new Set([...enConflit(copie), ...suspects.filter(f => porteDesMarques(copie, f))]),
@@ -574,6 +759,8 @@ export function preparer(copie, cible, { env = process.env, sortie = 2, ecrit, s
574
759
  }
575
760
  return r;
576
761
  };
762
+ // Before any command that reads the index, the pose of the submodules included.
763
+ rendreLIndex(copie);
577
764
  const echec = (r, quoi) => ({
578
765
  ok: false,
579
766
  message: `⛔ ${quoi} de la copie ${copie} échoue (code ${r.status ?? r.signal}).${r.stderr?.length ? `\n${String(r.stderr).trim()}` : ''}`,
@@ -646,14 +833,16 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
646
833
  ecrit = ecritPar(role, f => langageDeLaCopie(copie).estUnTest(f, copie));
647
834
  }
648
835
  const r =
649
- geste === 'reporter' && reste.length === 2
836
+ geste === 'photographier' && reste.length === 0
837
+ ? { ok: true, message: JSON.stringify(photographier(copie)) }
838
+ : geste === 'reporter' && reste.length === 2
650
839
  ? reporter(copie, { base: reste[0], pointe: reste[1] })
651
840
  : geste === 'preparer' && reste.length <= 1
652
841
  ? preparer(copie, reste[0] ?? null, { ecrit })
653
842
  : {
654
843
  ok: false,
655
844
  message:
656
- 'usage: travail-de-la-copie.mjs reporter <copie> <base> <pointe> | preparer <copie> [<cible>] [--role <role>]',
845
+ 'usage: travail-de-la-copie.mjs reporter <copie> <base> <pointe> | preparer <copie> [<cible>] [--role <role>] | photographier <copie>',
657
846
  };
658
847
  // `preparer` prints the list its pose fixes on stdout, its messages on stderr.
659
848
  if (geste === 'preparer') {
@@ -2,11 +2,12 @@
2
2
  // which the circuit (scripts/circuit.mjs), the board (scripts/tableau.mjs), the bilan
3
3
  // (scripts/bilan.mjs) and the texts read. The list of the steps is told here and at circuit.md
4
4
  // §5.1 alone; the gestures and the stops, at §5.4 and §5.5. The code today holds the long and the
5
- // short circuits; the direct one is a target (circuit.md §9.1).
5
+ // short circuits; of the direct one, it holds the steps and their rule.
6
6
  //
7
- // - A step (ETAPES): its number (« 2 », « 4.1 »), its title, who works there (`qui`: the role
8
- // agents, or AUTO for a step the circuit leads itself; none for a step that only holds its
9
- // sub-steps), its sub-steps (`sous`), and the step of the circuit's state it is (`etat`: the
7
+ // - A step (ETAPES): its number (« 2 », « 4.1 »), its title, the circuits that play it
8
+ // (`circuits`: long, court, direct, `joue`), who works there (`qui`: the role agents, or AUTO for
9
+ // a step the circuit leads itself; none for a step that only holds its sub-steps; a circuit whose
10
+ // roles differ names them in `quiAuCircuit`, `rolesDe`), its sub-steps (`sous`), and the step of the circuit's state it is (`etat`: the
10
11
  // `etape` of the state the circuit writes, which the workflow of its ticket holds, the final pass being the checks once
11
12
  // `finale`). Every step runs once for the whole ticket, as a merge request has one author of
12
13
  // its tests and one of its code, one CI on the whole and one review: one session of the
@@ -22,7 +23,9 @@
22
23
  // - A step carries as many bounded loops as it needs (`boucles`), each spanning the step and its
23
24
  // sub-steps: each its key (`cle`, which keys its count in the state's `boucles`), its label and
24
25
  // its maximum (`max`, the pass that stops it): the testwriter's sessions after a refused proof,
25
- // the developpeur's sessions with their checks, the reviews. The circuit stops each loop at its
26
+ // the developpeur's sessions with their checks, the reviews. A loop a circuit alone runs at a
27
+ // further step stands in `bouclesAuCircuit`: in a direct circuit, which plays no checks (3.1),
28
+ // the sessions of the code still count at the final pass. The circuit stops each loop at its
26
29
  // maximum and writes its count in its state; the board shows « <label> <n>/<max> » on the
27
30
  // ticket's line from the second pass.
28
31
  // - The stops of the circuit, each by its name and its exit code (ARRETS): the circuit ends on one
@@ -43,44 +46,68 @@ export const EXPLORATEUR = 'explorateur';
43
46
  export const AUTEUR_DU_CIRCUIT = 'circuit';
44
47
  export const QUESTIONNEUR = 'questionneur';
45
48
 
49
+ // The circuits of a ticket: the paths through the list.
50
+ const TOUS = ['long', 'court', 'direct'];
51
+ const AVEC_PLAN = ['long', 'court'];
52
+
53
+ // The role of the agent who writes tests and code together in a direct circuit.
54
+ const DIRECT = 'direct';
55
+
56
+ // The sessions of the author of the code, with the passes that judge them.
57
+ const BOUCLE_DU_CODE = { cle: 'code', libelle: 'essai', max: 3 };
58
+
46
59
  export const ETAPES = [
47
60
  {
48
61
  numero: '1',
49
62
  titre: 'Plan',
63
+ circuits: AVEC_PLAN,
50
64
  qui: ['explorateur', 'questionneur'],
51
65
  etat: null,
52
66
  questionnement: 'plan',
53
67
  arrets: ['questionnement'],
54
68
  // The gesture of a mechanical ticket, in the copy, in place of the testwriter and the
55
69
  // developpeur.
56
- sous: [{ numero: '1.1', titre: 'Geste mécanique', qui: [EXPLORATEUR], etat: 'geste' }],
70
+ sous: [{ numero: '1.1', titre: 'Geste mécanique', circuits: ['court'], qui: [EXPLORATEUR], etat: 'geste' }],
57
71
  },
58
72
  {
59
73
  numero: '2',
60
74
  titre: 'Tests',
75
+ circuits: ['long'],
61
76
  qui: ['testwriter'],
62
77
  etat: 'testwriter',
63
78
  boucles: [{ cle: 'tests', libelle: 'essai', max: 3 }],
64
- sous: [{ numero: '2.1', titre: 'Preuve du rouge', qui: [AUTO], etat: 'preuve' }],
79
+ sous: [{ numero: '2.1', titre: 'Preuve du rouge', circuits: ['long'], qui: [AUTO], etat: 'preuve' }],
65
80
  },
66
81
  {
67
82
  numero: '3',
68
83
  titre: 'Code',
84
+ circuits: TOUS,
69
85
  qui: ['developpeur'],
86
+ quiAuCircuit: { direct: [DIRECT] },
70
87
  etat: 'developpeur',
71
- boucles: [{ cle: 'code', libelle: 'essai', max: 3 }],
72
- sous: [{ numero: '3.1', titre: 'Contrôles', qui: [AUTO], etat: 'controles' }],
88
+ boucles: [BOUCLE_DU_CODE],
89
+ sous: [{ numero: '3.1', titre: 'Contrôles', circuits: AVEC_PLAN, qui: [AUTO], etat: 'controles' }],
73
90
  },
74
91
  {
75
92
  numero: '4',
76
93
  titre: 'Passe finale et relecture',
94
+ circuits: TOUS,
77
95
  qui: [],
78
96
  etat: null,
79
97
  sous: [
80
- { numero: '4.1', titre: 'Passe finale', qui: [AUTO], etat: 'controles', finale: true },
98
+ {
99
+ numero: '4.1',
100
+ titre: 'Passe finale',
101
+ circuits: TOUS,
102
+ qui: [AUTO],
103
+ etat: 'controles',
104
+ finale: true,
105
+ bouclesAuCircuit: { direct: [BOUCLE_DU_CODE] },
106
+ },
81
107
  {
82
108
  numero: '4.2',
83
109
  titre: 'Régénération des références',
110
+ circuits: TOUS,
84
111
  qui: [AUTO],
85
112
  etat: 'references',
86
113
  arrets: ['references'],
@@ -88,6 +115,7 @@ export const ETAPES = [
88
115
  {
89
116
  numero: '4.3',
90
117
  titre: 'Relecture',
118
+ circuits: TOUS,
91
119
  qui: ['relecteur'],
92
120
  etat: 'relecture',
93
121
  boucles: [{ cle: 'relecture', libelle: 'tour', max: 3 }],
@@ -97,13 +125,14 @@ export const ETAPES = [
97
125
  {
98
126
  numero: '5',
99
127
  titre: 'Intégration',
128
+ circuits: TOUS,
100
129
  qui: [],
101
130
  etat: null,
102
131
  sous: [
103
- { numero: '5.1', titre: 'Commit', qui: [AUTO], etat: 'integration' },
104
- { numero: '5.2', titre: 'File : passe finale, main', qui: [AUTO], etat: 'file' },
132
+ { numero: '5.1', titre: 'Commit', circuits: TOUS, qui: [AUTO], etat: 'integration' },
133
+ { numero: '5.2', titre: 'File : passe finale, main', circuits: TOUS, qui: [AUTO], etat: 'file' },
105
134
  // The tri of the discoveries of the ticket, on the lot entered on main.
106
- { numero: '5.3', titre: 'Tri des découvertes', qui: [EXPLORATEUR], etat: 'tri' },
135
+ { numero: '5.3', titre: 'Tri des découvertes', circuits: TOUS, qui: [EXPLORATEUR], etat: 'tri' },
107
136
  ],
108
137
  },
109
138
  ];
@@ -114,16 +143,49 @@ export const SUITE = ETAPES.flatMap(e => [e, ...(e.sous ?? [])]);
114
143
  // The bounded loop of key <cle>.
115
144
  export const boucle = cle => SUITE.flatMap(e => e.boucles ?? []).find(b => b.cle === cle) ?? null;
116
145
 
117
- // The loops that run at the step <etape>: its own and its parent's.
118
- export const bouclesDe = etape => {
146
+ // The loops that run at the step <etape> in the circuit <circuit>: its own, its parent's, and those
147
+ // the circuit alone runs there.
148
+ export const bouclesDe = (etape, circuit) => {
119
149
  const parent = ETAPES.find(e => e === etape || e.sous?.includes(etape));
120
- return [...new Set([parent, etape])].flatMap(e => e?.boucles ?? []);
150
+ return [...new Set([parent, etape])].flatMap(e => [
151
+ ...(e?.boucles ?? []),
152
+ ...(e?.bouclesAuCircuit?.[circuit] ?? []),
153
+ ]);
121
154
  };
122
155
 
123
- // The agents who write the lot, the testwriter its tests and the developpeur its code: the roles a
124
- // blocking finding of the reviewer names.
156
+ // Whether the circuit <circuit> plays the step of number <numero>.
157
+ export const joue = (numero, circuit) =>
158
+ Boolean(SUITE.find(e => e.numero === numero)?.circuits.includes(circuit));
159
+
160
+ // The roles of the step <e> in the circuit <circuit> (the long one when none is said); none when
161
+ // the circuit does not play it.
162
+ export const rolesDe = (e, circuit) =>
163
+ e.circuits.includes(circuit ?? 'long') ? (e.quiAuCircuit?.[circuit] ?? e.qui) : [];
164
+
165
+ // The roles of the step <e> in any circuit.
166
+ export const tousLesRolesDe = e => [
167
+ ...new Set([...e.qui, ...Object.values(e.quiAuCircuit ?? {}).flat()]),
168
+ ];
169
+
170
+ // The agent who writes the code (3) in the circuit <circuit>.
171
+ export const auteurDuCode = circuit =>
172
+ rolesDe(
173
+ SUITE.find(e => e.numero === '3'),
174
+ circuit
175
+ )[0];
176
+
177
+ // The agents who write the lot of a long or short circuit, the testwriter its tests and the
178
+ // developpeur its code.
125
179
  export const AGENTS_DU_LOT = ['testwriter', 'developpeur'];
126
180
 
181
+ // The agents who write the lot of the circuit <circuit>: the roles a blocking finding of the
182
+ // reviewer names.
183
+ export const agentsDuLot = circuit =>
184
+ circuit === DIRECT ? [auteurDuCode(circuit)] : AGENTS_DU_LOT;
185
+
186
+ // Every agent who writes the lot of a circuit.
187
+ export const AUTEURS_DE_LOT = [...AGENTS_DU_LOT, DIRECT];
188
+
127
189
  // The exit code of each stop of the circuit.
128
190
  export const ARRETS = {
129
191
  lancement: 10,
@@ -143,7 +205,6 @@ export const ARRETS = {
143
205
  besoin: 20,
144
206
  questionnement: 22,
145
207
  references: 23,
146
- 'hors-plan': 24,
147
208
  inattendu: 25,
148
209
  // A session the usage limit stops: the circuit reports itself to the hour the usage returns and
149
210
  // resumes the step, no question gone up.
@@ -161,6 +222,9 @@ export const roleDeLAgent = nom =>
161
222
  const NOMS = { developpeur: 'développeur' };
162
223
  export const nomDuRole = role => NOMS[role] ?? role;
163
224
 
225
+ // A role as the subject of a sentence, « Le développeur », « L’agent direct ».
226
+ export const leRole = role => (role === DIRECT ? 'L’agent direct' : `Le ${nomDuRole(role)}`);
227
+
164
228
  // Who works at the step <e>, in words: its roles' names.
165
229
  export const quiDe = e => e.qui.map(nomDuRole).join(' ⇄ ');
166
230
 
@@ -268,7 +332,7 @@ export const RESPONSABLE = 'responsable';
268
332
  // The commands by which the supervisor answers a question (scripts/circuit.mjs): resume, extend
269
333
  // the plan, stop.
270
334
  export const REPONSES =
271
- 'Le superviseur répond par une commande du circuit : `--reprendre` (avec `--contexte`) ou `--depuis <testwriter|developpeur>` (avec `--contexte`), `--mecanique [<commande>]` (avec `--contexte` : à l’arrêt du testwriter qui ne trouve aucun comportement à tester, ou de la preuve du rouge qui refuse le lot de tests, le ticket bascule en circuit court sur le même plan, vers 1.1 avec sa commande, vers le développeur sans elle), `--etendre <paquet>` (le plan gagne ce paquet, puis l’étape en cours reprend), `--reporter <heure>` (la question se tait jusqu’à l’heure, le circuit en attente), ou `--arreter`.';
335
+ 'Le superviseur répond par une commande du circuit : `--reprendre` (avec `--contexte`) ou `--depuis <testwriter|developpeur>` (avec `--contexte`), `--depuis direct` dans un circuit direct (avec `--contexte`), `--mecanique [<commande>]` (avec `--contexte` : à l’arrêt du testwriter qui ne trouve aucun comportement à tester, ou de la preuve du rouge qui refuse le lot de tests, le ticket bascule en circuit court sur le même plan, vers 1.1 avec sa commande, vers le développeur sans elle), `--etendre <paquet>` (le plan gagne ce paquet, puis l’étape en cours reprend), `--reporter <heure>` (la question se tait jusqu’à l’heure, le circuit en attente), ou `--arreter`.';
272
336
 
273
337
  // The question of each stop no gesture settles, as a CI calls a person only for what no rule
274
338
  // settles (the approval of a review): every stop of ARRETS, « a-repasser » once the circuit has
@@ -308,8 +372,6 @@ export const MONTEES = Object.fromEntries(
308
372
  'Des questions du plan restent ouvertes après la réponse de l’explorateur : le plan change-t-il (`bd update`), ou reste-t-il tel quel ? `--reprendre` le fait passer tel qu’il est alors.',
309
373
  references:
310
374
  'La régénération des références change un fichier qu’aucune référence n’écrit, ou sa commande échoue (ses écarts ci-dessus) : qui corrige la référence ou le lot ?',
311
- 'hors-plan':
312
- 'La séance écrit hors du plan du ticket : le plan s’étend-il à ce paquet (`--etendre`), ou l’écriture est-elle refusée (`--reprendre` avec son contexte) ?',
313
375
  inattendu:
314
376
  'Une exception que le circuit ne prévoit pas (une lecture de la copie, une commande, un fichier illisible) l’a arrêté : sa cause se lève-t-elle, pour reprendre (`--reprendre`, qui écrit de nouveau cet arrêt si la cause reste), ou le circuit s’arrête-t-il ?',
315
377
  'limite-d-usage':
@@ -66,6 +66,7 @@ import {
66
66
  arretDe,
67
67
  arreter,
68
68
  avantLaPasse,
69
+ circuitSansTrace,
69
70
  contexte,
70
71
  ecrireEtat,
71
72
  finirLOuverture,
@@ -98,10 +99,11 @@ import {
98
99
  import { rougesDUnePasse } from './activites.mjs';
99
100
  import { ecrireLEffet } from './effets.mjs';
100
101
  import { Arret, commenter, geste } from './ticket-du-circuit.mjs';
102
+ import { AUTEURS_DE_LOT } from './etapes.mjs';
101
103
  import { arretDeLaLimiteDUsage, MEMOIRE } from './transitions.mjs';
102
104
 
103
105
  // What the workflow keeps of the circuit's memory besides the decisions': the session a relaunch
104
- // resumes, the rank of arrival, the sort of the ticket, what the opening reads of the project's
106
+ // resumes, the rank of arrival, the circuit and the sort of the ticket, what the opening reads of the project's
105
107
  // package.json (its tools, its data, its generated files), which every pass of a later act plays
106
108
  // with, each act in a process of its own, and the supervisor's context of the
107
109
  // run (`contexte`), which each session of the run reads at the head of its instruction, with the
@@ -111,6 +113,7 @@ const GARDEE = [
111
113
  ...MEMOIRE,
112
114
  'seanceReprise',
113
115
  'rang',
116
+ 'circuit',
114
117
  'sorte',
115
118
  'outils',
116
119
  'donnees',
@@ -200,7 +203,7 @@ export const optionsDe = reponse => {
200
203
  return {
201
204
  depuis: reponse.role,
202
205
  contexte: contexteDuSuperviseur,
203
- destinataire: ['testwriter', 'developpeur'].includes(reponse.role) ? reponse.role : null,
206
+ destinataire: AUTEURS_DE_LOT.includes(reponse.role) ? reponse.role : null,
204
207
  };
205
208
  }
206
209
  if (reponse.genre === 'mecanique') {
@@ -332,6 +335,8 @@ const ACTES = {
332
335
  async arret({ ticket, memoire, arret, etat, monter: aMonter, paquets, menee }) {
333
336
  const ctx = leContexte(ticket, memoire, { paquets });
334
337
  return rendre(ctx, () => {
338
+ // A stop of an opening that failed before its first state still says its circuit.
339
+ ctx.circuit ??= circuitSansTrace(ctx);
335
340
  const a = publierLArret(ctx, erreurDe(ctx, arret), etat);
336
341
  finirLEtape(ctx, menee ?? null);
337
342
  if (a.nom === 'limite-d-usage' && !aMonter) {
@@ -432,6 +437,7 @@ const lOuverture = (ctx, debut) => ({
432
437
  paquets: ctx.paquets,
433
438
  sorte: ctx.sorte ?? null,
434
439
  copie: ctx.copie,
440
+ circuit: ctx.circuit ?? null,
435
441
  },
436
442
  });
437
443