@roomi-fields/grillhouse 0.50.2 → 0.51.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 (132) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +52 -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.md +17 -12
  13. package/dist/machine/part-par-sorte.d.ts +16 -0
  14. package/dist/machine/part-par-sorte.js +36 -0
  15. package/dist/machine/part-par-sorte.js.map +1 -0
  16. package/dist/temporal/circuit/appel.js +1 -1
  17. package/dist/temporal/circuit/appel.js.map +1 -1
  18. package/dist/temporal/circuit/client.d.ts +5 -4
  19. package/dist/temporal/circuit/client.js +39 -16
  20. package/dist/temporal/circuit/client.js.map +1 -1
  21. package/dist/temporal/circuit/contrat.d.ts +11 -7
  22. package/dist/temporal/circuit/contrat.js +5 -9
  23. package/dist/temporal/circuit/contrat.js.map +1 -1
  24. package/dist/temporal/circuit/deroule.js +18 -6
  25. package/dist/temporal/circuit/deroule.js.map +1 -1
  26. package/dist/temporal/commande.js +12 -3
  27. package/dist/temporal/commande.js.map +1 -1
  28. package/dist/temporal/installation.d.ts +54 -3
  29. package/dist/temporal/installation.js +187 -17
  30. package/dist/temporal/installation.js.map +1 -1
  31. package/dist/temporal/places/client.d.ts +5 -1
  32. package/dist/temporal/places/client.js +23 -11
  33. package/dist/temporal/places/client.js.map +1 -1
  34. package/docs/ARCHITECTURE.md +23 -2700
  35. package/docs/INTERFACE.md +23 -8
  36. package/docs/architecture/circuit.md +59 -12
  37. package/docs/architecture/entree.md +20 -7
  38. package/docs/architecture/greffon.md +6 -2
  39. package/docs/architecture/installation.md +30 -11
  40. package/docs/architecture/machine.md +50 -37
  41. package/docs/architecture/tests.md +52 -14
  42. package/docs/lexique.md +154 -0
  43. package/hooks/register.tsx +1 -1
  44. package/package.json +1 -1
  45. package/scripts/activites.mjs +85 -60
  46. package/scripts/aiguillage.mjs +15 -7
  47. package/scripts/attente-de-la-machine.mjs +4 -8
  48. package/scripts/avancement.mjs +12 -8
  49. package/scripts/bilan.mjs +10 -7
  50. package/scripts/branche-de-nuit.mjs +2 -2
  51. package/scripts/ci-de-main.mjs +18 -21
  52. package/scripts/circuit.mjs +86 -43
  53. package/scripts/circuits-du-serveur.mjs +5 -5
  54. package/scripts/composants-affectes.mjs +30 -12
  55. package/scripts/composition-des-langages.mjs +5 -3
  56. package/scripts/conformite.mjs +1 -1
  57. package/scripts/consommation-des-passes.mjs +8 -6
  58. package/scripts/copies-finies.mjs +3 -14
  59. package/scripts/depart-du-ticket.d.mts +8 -2
  60. package/scripts/depart-du-ticket.mjs +26 -8
  61. package/scripts/direct.mjs +158 -72
  62. package/scripts/droits.mjs +63 -185
  63. package/scripts/engendres.mjs +3 -14
  64. package/scripts/enveloppe/enveloppe.mjs +75 -30
  65. package/scripts/enveloppe/lancer.sh +59 -45
  66. package/scripts/enveloppe/paquets-du-plan.mjs +38 -11
  67. package/scripts/enveloppe/travail-de-la-copie.mjs +115 -3
  68. package/scripts/etapes.mjs +84 -22
  69. package/scripts/faits-du-circuit.mjs +8 -2
  70. package/scripts/grillhouse-maj.mjs +43 -18
  71. package/scripts/groupe-cles.d.mts +15 -0
  72. package/scripts/groupe-cles.mjs +77 -2
  73. package/scripts/init.mjs +9 -2
  74. package/scripts/integration/rejeu.mjs +8 -1
  75. package/scripts/jointure.d.ts +22 -3
  76. package/scripts/langages/c/index.mjs +5 -2
  77. package/scripts/langages/cargo/commandes.mjs +35 -15
  78. package/scripts/langages/cargo/composants.mjs +45 -3
  79. package/scripts/langages/cargo/index.mjs +6 -3
  80. package/scripts/langages/cargo/sccache.mjs +10 -3
  81. package/scripts/langages/python/index.mjs +5 -2
  82. package/scripts/langages/typescript/chemins-des-tests.mjs +1 -1
  83. package/scripts/langages/typescript/index.mjs +4 -2
  84. package/scripts/langages/typescript/mise-a-jour.mjs +1 -1
  85. package/scripts/langages/typescript/rapports-aux-lignes.mjs +74 -0
  86. package/scripts/langages/typescript/turbo-des-paquets.mjs +99 -36
  87. package/scripts/langages/typescript/verdict.mjs +29 -3
  88. package/scripts/langages/typescript/verifier.mjs +1 -1
  89. package/scripts/langages/typescript/vitest-config/changements.mjs +8 -6
  90. package/scripts/langages/typescript/vitest-config/lances.mjs +15 -32
  91. package/scripts/langages.mjs +54 -4
  92. package/scripts/matieres-lues.mjs +1 -1
  93. package/scripts/mesure/base-de-passe.mjs +32 -90
  94. package/scripts/migrations/serveurs-de-l-index.mjs +79 -0
  95. package/scripts/migrations.mjs +21 -7
  96. package/scripts/paquets.d.ts +3 -0
  97. package/scripts/paquets.mjs +88 -1
  98. package/scripts/passe-de-la-machine.mjs +109 -36
  99. package/scripts/places-de-la-machine.mjs +81 -29
  100. package/scripts/plafond-de-la-machine.d.mts +2 -5
  101. package/scripts/plafond-de-la-machine.mjs +9 -9
  102. package/scripts/reprise.mjs +42 -13
  103. package/scripts/resultats.mjs +76 -54
  104. package/scripts/retirer-les-copies-finies.mjs +1 -1
  105. package/scripts/seances.mjs +426 -115
  106. package/scripts/services-du-noyau.mjs +9 -1
  107. package/scripts/session-start.sh +14 -1
  108. package/scripts/sortie.mjs +37 -6
  109. package/scripts/sous-commandes.mjs +0 -2
  110. package/scripts/superviseur.mjs +33 -13
  111. package/scripts/tableau.mjs +61 -16
  112. package/scripts/transitions.d.mts +25 -2
  113. package/scripts/transitions.mjs +137 -29
  114. package/scripts/verrous/ecriture-hors-enveloppe.mjs +31 -9
  115. package/skills/codebase-design/DESIGN-IT-TWICE.md +1 -1
  116. package/skills/developpeur/SKILL.md +38 -15
  117. package/skills/direct/SKILL.md +29 -9
  118. package/skills/domain-modeling/GLOSSARY-FORMAT.md +9 -9
  119. package/skills/domain-modeling/SKILL.md +14 -12
  120. package/skills/explorateur/SKILL.md +30 -6
  121. package/skills/pitmaster/SKILL.md +12 -16
  122. package/skills/pitmaster/references/consigne-agent.md +12 -11
  123. package/skills/relecteur/SKILL.md +12 -5
  124. package/skills/systematic-debugging/SKILL.md +281 -0
  125. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  126. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  127. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  128. package/skills/systematic-debugging/find-polluter.sh +72 -0
  129. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  130. package/skills/testwriter/SKILL.md +35 -29
  131. package/scripts/verrous/commande.mjs +0 -214
  132. package/scripts/verrous/verrou.mjs +0 -311
@@ -31,8 +31,8 @@
31
31
  // socket of the session comes back. The file of the remote cache of the poste
32
32
  // (`~/.config/grillhouse/`, scripts/fichier-du-poste.mjs) stays out.
33
33
  // - A project that names its published version (`grillhouse.outil`) gets `~/.cache/grillhouse/outil`
34
- // read-only, the version installed by the envelope before the session starts: the write lock
35
- // runs on that version, never on the code of the copy it guards.
34
+ // read-only, the version installed by the envelope before the session starts: the hooks of the
35
+ // session run on that version, never on the code of the copy.
36
36
  // - The tools of the project (`grillhouse.outils` of the package.json of the main tree, never of
37
37
  // the copy; `{ "<VARIABLE>": "<chemin>" }`, read by scripts/outils-cles.mjs): each path comes
38
38
  // back read-only after the declared paths of the home, before the copy and the packages of the
@@ -50,10 +50,10 @@
50
50
  // cache, `npm_config_ignore_scripts=true` (npm runs no lifecycle script; `npm test` and
51
51
  // `npm run <script>` still run their script, without its `pre` or `post`), and `TMPDIR`, `TMP`
52
52
  // and `TEMP`, the session's working directory (under a launch, the temporary directory of the
53
- // ticket, scripts/enveloppe/lancer.sh). No other variable of the machine (`GH_TOKEN`,
53
+ // session, scripts/enveloppe/lancer.sh). No other variable of the machine (`GH_TOKEN`,
54
54
  // `NPM_TOKEN`…) enters. It also gets `GRILLHOUSE_ENVELOPPE`, the packages of the plan
55
- // (`paquets-du-plan.mjs`): the frame's commands build, judge and write those packages only, and
56
- // its lock refuses a write out of them. A declared variable that names a path
55
+ // (`paquets-du-plan.mjs`): the frame's commands build, judge and write those packages only; the
56
+ // mounts refuse a write out of them. A declared variable that names a path
57
57
  // (`VARIABLES_DE_CHEMIN`) enters only when its path is in sight inside the envelope. The
58
58
  // session has its own process space.
59
59
  // - A declared path that is a symbolic link, or that holds one among its components, comes back as
@@ -72,7 +72,9 @@
72
72
  // A component writes itself alone, `src/parser` of a one-package project included, as does a
73
73
  // package out of the frame (`docs/agents/hors-cadre.txt`). A path that no component holds (a
74
74
  // folder of the root, `scripts`; `.`) writes the package that holds it, the root: the copy
75
- // stays written, its `.git` read-only.
75
+ // stays written, its `.git` read-only. A new path of a direct (`estUnCheminNeuf`), which no
76
+ // package holds and the base commit of the copy lacks, is created empty by the agent direct's
77
+ // launch when it does not exist, and writes itself alone.
76
78
  // - The package of the shared test material is every component of <copie> whose `package.json`
77
79
  // exports `./test-fixtures` (`matieres` of the module of the language). It is mounted after the
78
80
  // packages of the plan: written for the `testwriter`, read-only for every other role, in the
@@ -100,6 +102,7 @@ import { langageDeLaCopie } from '../langages.mjs';
100
102
  import { CODE_REFUS, CODE_USAGE } from './codes.mjs';
101
103
  import {
102
104
  ecritsDuPlan,
105
+ estUnCheminNeuf,
103
106
  ecrireLaListe,
104
107
  lireLaListe,
105
108
  paquetsDuLangage,
@@ -118,7 +121,11 @@ import {
118
121
  travailleursDe,
119
122
  VARIABLE_TENUE,
120
123
  } from '../places-de-la-machine.mjs';
121
- import { commandeDuGroupe, groupeIndisponible } from '../passe-de-la-machine.mjs';
124
+ import {
125
+ commandeDuGroupe,
126
+ groupeIndisponible,
127
+ mesureDeLaSeance,
128
+ } from '../passe-de-la-machine.mjs';
122
129
  import { donneesDe } from '../donnees-cles.mjs';
123
130
  import { matieresDeclareesDe } from '../matieres-cles.mjs';
124
131
  import { outilsDe } from '../outils-cles.mjs';
@@ -157,8 +164,8 @@ export function matieresDeLaCopie(langage, copie) {
157
164
  // The packages of the copy that the plan <paquets> does not name and that are not the shared test
158
165
  // material, relative to the copy: where the envelope opens an empty own output to each run. The
159
166
  // root package is the copy's own root, treated apart.
160
- const paquetsHorsDuPlan = (paquets, paquetsDeLaCopie, matieres) => {
161
- const ecrits = ecritsDuPlan(paquets, paquetsDeLaCopie);
167
+ const paquetsHorsDuPlan = (copie, paquets, paquetsDeLaCopie, matieres) => {
168
+ const ecrits = ecritsDuPlan(paquets, paquetsDeLaCopie, copie);
162
169
  return paquetsDeLaCopie
163
170
  .map(p => p.dossier)
164
171
  .filter(d => d !== '.' && !ecrits.includes(d) && !matieres.includes(d));
@@ -167,13 +174,26 @@ const paquetsHorsDuPlan = (paquets, paquetsDeLaCopie, matieres) => {
167
174
  // that are missing: in each package out of the plan, in the shared test material for a role that
168
175
  // does not write it, and at the root of the copy when the plan does not write it. An output that a
169
176
  // link carries out of the copy is left out. bwrap then has a directory to mount an empty one over.
177
+ // For the agent direct, a new path that the plan writes as itself (`ecritsDuPlan`) and that does
178
+ // not exist yet is created first, so that bwrap mounts it in writing inside the read-only copy; a
179
+ // path that exists, file or directory, stays as it is.
170
180
  export function preparerLesSorties({ copie, paquets, paquetsDeLaCopie, matieres, role, sorties }) {
171
- const dossiers = paquetsHorsDuPlan(paquets, paquetsDeLaCopie, matieres);
181
+ if (role === 'direct') {
182
+ const ecrits = ecritsDuPlan(paquets, paquetsDeLaCopie, copie);
183
+ for (const p of paquets.filter(estUnCheminNeuf)) {
184
+ const rel = path.normalize(p).replace(/\/+$/, '');
185
+ const chemin = path.join(copie, rel);
186
+ if (ecrits.includes(rel) && !existsSync(chemin)) {
187
+ mkdirSync(chemin, { recursive: true });
188
+ }
189
+ }
190
+ }
191
+ const dossiers = paquetsHorsDuPlan(copie, paquets, paquetsDeLaCopie, matieres);
172
192
  if (!ROLES_MATIERE.includes(role)) {
173
193
  // A declared folder of test material is no package: no run of tests writes outputs in it.
174
194
  dossiers.push(...matieres.filter(m => paquetsDeLaCopie.some(p => p.dossier === m)));
175
195
  }
176
- if (!ecritsDuPlan(paquets, paquetsDeLaCopie).includes('.')) {
196
+ if (!ecritsDuPlan(paquets, paquetsDeLaCopie, copie).includes('.')) {
177
197
  dossiers.push('.');
178
198
  }
179
199
  for (const d of dossiers) {
@@ -354,7 +374,8 @@ export function environnementDeLaSeance(
354
374
  * @param {{ argsBwrap: string[], commande: string[], env: Record<string, string | undefined>,
355
375
  * cacheNpm: string, paquets: string[], travail: string, outils?: Record<string, string>,
356
376
  * donnees?: Record<string, string>, part?: { coeurs: number, memoire: number },
357
- * sonde?: () => boolean }} o
377
+ * sonde?: () => boolean, unite?: string | null }} o <unite> names the group, which the measure
378
+ * of the session reads
358
379
  * @returns {{ cmd: string, args: string[], env: Record<string, string>, sansBorne: string | null }}
359
380
  * `sansBorne`: why the session starts without a group (null when it has one)
360
381
  *
@@ -375,6 +396,7 @@ export function lancementDeLaSeance({
375
396
  part,
376
397
  sonde,
377
398
  testsEtendus,
399
+ unite = null,
378
400
  }) {
379
401
  const seance = {
380
402
  cmd: 'bwrap',
@@ -385,7 +407,14 @@ export function lancementDeLaSeance({
385
407
  : 'aucune part du projet connue';
386
408
  const lancee =
387
409
  sansBorne === null
388
- ? commandeDuGroupe({ part, cmd: seance.cmd, args: seance.args, plafond: true, memoire: false })
410
+ ? commandeDuGroupe({
411
+ part,
412
+ cmd: seance.cmd,
413
+ args: seance.args,
414
+ unite,
415
+ plafond: true,
416
+ memoire: false,
417
+ })
389
418
  : seance;
390
419
  return {
391
420
  ...lancee,
@@ -581,13 +610,14 @@ const inside = (child, parent) => {
581
610
  // The refusal of <composant> in the repository at <depot>, or null when it is the path of a
582
611
  // directory there (`.`, the whole repository, included). A <composant> that is the name of a
583
612
  // component of `paquets` (`paquetsDuLangage`), or the name of its folder, is told
584
- // its path, as git says « did you mean ». `fs` gives `existe(path)`. The launcher judges the
613
+ // its path, as git says « did you mean ». A new path (`estUnCheminNeuf`) stands on a session of
614
+ // the agent direct (<neuf>), which creates it. `fs` gives `existe(path)`. The launcher judges the
585
615
  // component with it before preparing the copy, in the ticket's copy when it exists, else in the
586
616
  // main tree or in the tree of the ticket's branch, its `existe` accepting either; `plan` judges it
587
617
  // in the copy.
588
- export function jugerComposant({ depot, composant, paquets = [] }, fs) {
618
+ export function jugerComposant({ depot, composant, paquets = [], neuf = false }, fs) {
589
619
  const propre = path.join(depot, composant);
590
- if (fs.existe(propre)) {
620
+ if (fs.existe(propre) || (neuf && estUnCheminNeuf(composant))) {
591
621
  return null;
592
622
  }
593
623
  const nomme =
@@ -664,12 +694,15 @@ export function plan(
664
694
  return { refus: "Le plan ne nomme aucun paquet : l'enveloppe n'ouvre rien en écriture." };
665
695
  }
666
696
  for (const p of paquets) {
667
- const refus = jugerComposant({ depot: copie, composant: p, paquets: paquetsDeLaCopie }, fs);
697
+ const refus = jugerComposant(
698
+ { depot: copie, composant: p, paquets: paquetsDeLaCopie, neuf: role === 'direct' },
699
+ fs
700
+ );
668
701
  if (refus) {
669
702
  return { refus };
670
703
  }
671
704
  }
672
- const ecrits = ecritsDuPlan(paquets, paquetsDeLaCopie);
705
+ const ecrits = ecritsDuPlan(paquets, paquetsDeLaCopie, copie);
673
706
  const toute = ecrits.includes('.');
674
707
 
675
708
  // /dev/shm, which /dev brings in writing, becomes an empty directory proper to the session.
@@ -759,7 +792,7 @@ export function plan(
759
792
  // Each package out of the plan has its own outputs as empty directories proper to the session,
760
793
  // as a sandbox of Bazel opens the declared outputs whatever the package; the rest stays read-only.
761
794
  if (!toute) {
762
- for (const d of paquetsHorsDuPlan(paquets, paquetsDeLaCopie, matieres)) {
795
+ for (const d of paquetsHorsDuPlan(copie, paquets, paquetsDeLaCopie, matieres)) {
763
796
  for (const s of sortiesDe(path.join(copie, d), sorties.propres, fs.lien)) {
764
797
  if (fs.existe(s)) {
765
798
  args.push('--tmpfs', s);
@@ -789,8 +822,8 @@ export function plan(
789
822
  const d = path.join(copie, e);
790
823
  args.push('--bind', d, d);
791
824
  }
792
- // The reader packages the plan extended to their tests: the testwriter writes them (his lock
793
- // lets only their test files through), every other role reads them.
825
+ // The reader packages the plan extended to their tests: the testwriter writes them (the
826
+ // judgment of his lot lets only their test files through), every other role reads them.
794
827
  for (const e of testsEtendus.filter(t => !ecrits.includes(t))) {
795
828
  const d = path.join(copie, e);
796
829
  if (fs.existe(d)) {
@@ -831,7 +864,7 @@ const disque = { existe: existsSync, lien: lienSurDisque };
831
864
  // The cache of the published versions to mount when the project of <copie> names its version
832
865
  // (`grillhouse.outil`, read in the main tree), after installing the version here, outside the
833
866
  // session; null without the key, or when the version cannot be installed (said on the error stream:
834
- // the lock then falls back on the code of the copy, and refuses when that does not load either).
867
+ // the hooks then fall back on the code of the copy).
835
868
  function cacheDeLaVersionPubliee(copie) {
836
869
  const commun = execFileSync(
837
870
  'git',
@@ -906,8 +939,8 @@ function envelopper(argv) {
906
939
  return CODE_REFUS;
907
940
  }
908
941
  // The cache of the published versions (`grillhouse.outil` of the main tree's package.json) comes
909
- // in read-only, the version installed here, outside the session: the write lock runs on it, and
910
- // a session cannot install it. A version that cannot be installed is said, nothing mounted.
942
+ // in read-only, the version installed here, outside the session: the session's hooks run on it,
943
+ // and a session cannot install it. A version that cannot be installed is said, nothing mounted.
911
944
  const publie = cacheDeLaVersionPubliee(copie);
912
945
  mkdirSync(projet, { recursive: true });
913
946
  // The session's working directory, created here inside the scratchpads that bwrap mounts.
@@ -962,7 +995,7 @@ function envelopper(argv) {
962
995
  preparerLesSorties({ copie, paquets, paquetsDeLaCopie, matieres, role, sorties });
963
996
  // For a plan that leaves the root read-only, where the language's tools write at the root of the
964
997
  // copy is created here, so that bwrap mounts it in writing, inside the read-only copy.
965
- if (!ecritsDuPlan(paquets, paquetsDeLaCopie).includes('.')) {
998
+ if (!ecritsDuPlan(paquets, paquetsDeLaCopie, copie).includes('.')) {
966
999
  for (const s of sortiesDe(copie, sorties.ecrites, lienSurDisque)) {
967
1000
  creer(s, fichiers.includes(path.relative(copie, s)));
968
1001
  }
@@ -993,26 +1026,37 @@ function envelopper(argv) {
993
1026
  process.stderr.write(`⛔ ENVELOPPE REFUSÉE — ${refus}\n`);
994
1027
  code = CODE_REFUS;
995
1028
  } else {
996
- // The session reserves its cores for its phase alone (3, a direct's 2) against the budget of
997
- // the machine, and gives them back at its end; under a part already held, its cap is that part.
1029
+ // The session reserves its cores for its phase alone (3 by default, a direct's too) against
1030
+ // the budget of the machine, and gives them back at its end; under a part already held, its cap is that part.
998
1031
  let part;
999
1032
  let prise = null;
1000
1033
  try {
1001
- const direct = role === 'direct';
1002
1034
  prise = prendreUnePart({
1003
1035
  racine: copie,
1004
1036
  ticket: path.basename(copie),
1005
1037
  sorte: `séance ${role ?? ''}`.trim(),
1006
- direct,
1038
+ bornee: false,
1007
1039
  dire: l => process.stderr.write(`${l}\n`),
1008
1040
  });
1009
- part = prise.part ?? partDeLaPasse({ racine: copie, direct });
1041
+ part =
1042
+ prise.part ??
1043
+ partDeLaPasse({ racine: copie, sorte: `séance ${role ?? ''}`.trim() });
1010
1044
  } catch (e) {
1011
1045
  process.stderr.write(`⛔ ENVELOPPE REFUSÉE — ${e.message}\n`);
1012
1046
  temporaire.fermer();
1013
1047
  return CODE_REFUS;
1014
1048
  }
1049
+ // The peak of the session, which its group measures, enters the register under its role.
1050
+ const mesure = prise.part
1051
+ ? mesureDeLaSeance({
1052
+ racine: copie,
1053
+ role,
1054
+ ticket: path.basename(copie),
1055
+ part: { ...prise.part, id: prise.id },
1056
+ })
1057
+ : null;
1015
1058
  const lancement = lancementDeLaSeance({
1059
+ unite: mesure?.unite ?? null,
1016
1060
  argsBwrap: args,
1017
1061
  commande,
1018
1062
  env: process.env,
@@ -1031,6 +1075,7 @@ function envelopper(argv) {
1031
1075
  try {
1032
1076
  r = spawnSync(lancement.cmd, lancement.args, { stdio: 'inherit', env: lancement.env });
1033
1077
  } finally {
1078
+ mesure?.garder(r ?? { error: true });
1034
1079
  prise.rendre();
1035
1080
  }
1036
1081
  if (r.error) {
@@ -32,8 +32,9 @@
32
32
  # mounts in writing over the real directory, so that a transcript outlives its session). The
33
33
  # circuit gives them, so that a relaunch of an agent on its step resumes its session. The two
34
34
  # together are refused, CODE_USAGE; each takes a value as --modele does.
35
- # A resumed session receives its instruction alone: the session it resumes holds the sections
36
- # the launcher adds below, save « La construction échoue », which it receives.
35
+ # A resumed session receives its instruction and the sections « Ton dossier de travail » (its
36
+ # directory is new) and « La construction échoue »: the session it resumes holds the other
37
+ # sections the launcher adds below.
37
38
  # - The agent's copy is the worktree .claude/worktrees/<ticket> (branch agent/<ticket>), created
38
39
  # from the main tree's HEAD when absent and moved forward to it otherwise. When the branch exists
39
40
  # without a copy, it is brought back to the main tree's HEAD and the copy is made on it: the lot
@@ -84,17 +85,23 @@
84
85
  # CODE_COPIE), then the
85
86
  # section « Ton dossier de travail », which names the session's working directory, where every
86
87
  # temporary file goes (`dossierDeTravail` of enveloppe.mjs, the envelope's TMPDIR, TMP and TEMP,
87
- # in the temporary directory of the ticket, which the launcher opens once the call is judged and
88
- # which stays from one session and one resumption to the next, removed when the ticket is
89
- # closed, scripts/mesure/base-de-passe.mjs), then the
90
- # section « La construction échoue » when it fails. The prompt
91
- # carries « TON TICKET : <ticket> », which the role's locks read. The envelope is the sandbox, so
88
+ # in the temporary directory of the session), then the
89
+ # section « La construction échoue » when it fails. The temporary directory of the session is a
90
+ # base of a pass (scripts/mesure/base-de-passe.mjs) which the launcher, its owner, opens once the
91
+ # call is judged, empty: its TMPDIR, TMP and TEMP, those of the preparation of the copy and of
92
+ # the session, whatever CLAUDE_CODE_TMPDIR the poste holds. The launcher's own files (the output
93
+ # of a failed build, the prompt) lie in the base, beside that directory, never in it, as the
94
+ # runner's files of GitHub Actions lie in RUNNER_TEMP, out of the job's workspace. The base goes
95
+ # when the launcher ends, even interrupted, once the witness the session left
96
+ # there is ranged in the folder of the session; the next session sweeps the one of a launcher
97
+ # killed. The prompt
98
+ # carries « TON TICKET : <ticket> », the ticket of the session. The envelope is the sandbox, so
92
99
  # the session runs without permission prompts, under the rights and the context of its role
93
100
  # (scripts/droits.mjs, given the main tree, the copy and the ticket; a reading that fails stops
94
101
  # the launch, CODE_COPIE): the user's own configuration left out, its settings on the command
95
102
  # line (its refusals, among them the change of its author at the ticket, AUTEUR_FIXE: its
96
- # comments carry the author the launch names in BEADS_ACTOR, which the envelope passes on; its
97
- # locks), its tools and the servers of the index, for the reading of the whole copy.
103
+ # comments carry the author the launch names in BEADS_ACTOR, which the envelope passes on), its
104
+ # tools and the servers of the index, for the reading of the whole copy.
98
105
  # - A role that ends on a sheet (scripts/resultats.mjs: the testwriter, the developpeur) runs with
99
106
  # `--output-format json --json-schema <its schema>` (`npx grillhouse resultats --schema
100
107
  # <rôle>`); --fiche <sorte> names the schema of a sheet that is not its role's (`geste`, the
@@ -113,10 +120,9 @@
113
120
  # The command the envelope runs leaves a witness of its start in the working directory, which the
114
121
  # launcher ranges beside it (`demarree`, removed first): an envelope that ends without it refused
115
122
  # the launch before the session, whatever its code (scripts/seances.mjs `seanceLancee`).
116
- # A session its lock stopped on a write out of the plan (scripts/verrous/verrou.mjs) left the
117
- # reason in its working directory (`hors-plan`, removed before the session): the launcher moves
118
- # it to `hors-plan` in the folder of the session, which a launch removes first and the circuit reads,
119
- # and adds it to the log. It then writes the session's line to the register
123
+ # Once the copy is prepared, before the session, the launcher writes the tree the copy holds to
124
+ # `avant` in the folder of the session (travail-de-la-copie.mjs `photographier`), which a launch
125
+ # removes first: the circuit reads the session's lot from it. It then writes the session's line to the register
120
126
  # (scripts/registre.mjs --copie), and exits with the envelope's code.
121
127
  # - The exit codes are named in scripts/enveloppe/codes.mjs; a malformed call exits CODE_USAGE.
122
128
  # - CLAUDE_BIN replaces `claude` (the tests use it).
@@ -173,7 +179,7 @@ if [ -d "$racine/.claude/worktrees/$ticket" ]; then
173
179
  elif git -C "$racine" rev-parse --verify --quiet "refs/heads/agent/$ticket" > /dev/null; then
174
180
  branche="agent/$ticket"
175
181
  fi
176
- refus_composant=$(node --input-type=module -e "import { spawnSync } from 'node:child_process'; import { existsSync } from 'node:fs'; import path from 'node:path'; import { jugerComposant, paquetsDuLangage } from '$ici/enveloppe.mjs'; import { lireLaListe } from '$ici/paquets-du-plan.mjs'; import { langageDeLaCopie } from '$ici/../langages.mjs'; const [depot, composant, liste, branche] = process.argv.slice(1); const dansBranche = p => { const rel = path.relative(depot, p); return rel === '' || (!rel.startsWith('..') && spawnSync('git', ['-C', depot, 'cat-file', '-e', branche + ':' + rel]).status === 0); }; const existe = p => existsSync(p) || (branche !== '' && dansBranche(p)); const tous = paquetsDuLangage(langageDeLaCopie(depot), depot); process.stdout.write([composant, ...lireLaListe(liste)].map(c => jugerComposant({ depot, composant: c, paquets: tous }, { existe })).find(Boolean) ?? '');" "$juge" "$composant" "$paquets" "$branche") || exit "$CODE_USAGE"
182
+ refus_composant=$(node --input-type=module -e "import { spawnSync } from 'node:child_process'; import { existsSync } from 'node:fs'; import path from 'node:path'; import { jugerComposant, paquetsDuLangage } from '$ici/enveloppe.mjs'; import { lireLaListe } from '$ici/paquets-du-plan.mjs'; import { langageDeLaCopie } from '$ici/../langages.mjs'; const [depot, composant, liste, branche, role] = process.argv.slice(1); const dansBranche = p => { const rel = path.relative(depot, p); return rel === '' || (!rel.startsWith('..') && spawnSync('git', ['-C', depot, 'cat-file', '-e', branche + ':' + rel]).status === 0); }; const existe = p => existsSync(p) || (branche !== '' && dansBranche(p)); const tous = paquetsDuLangage(langageDeLaCopie(depot), depot); process.stdout.write([composant, ...lireLaListe(liste)].map(c => jugerComposant({ depot, composant: c, paquets: tous, neuf: role === 'direct' }, { existe })).find(Boolean) ?? '');" "$juge" "$composant" "$paquets" "$branche" "$role") || exit "$CODE_USAGE"
177
183
  [ -z "$refus_composant" ] || { echo "⛔ $refus_composant" >&2; exit "$CODE_USAGE"; }
178
184
  # The ticket is matched whole: `demo-3160` is not `demo-316`, and its dots are dots.
179
185
  motif=$(printf '%s' "$ticket" | sed 's/[.[\*^$]/\\&/g')
@@ -186,22 +192,42 @@ journal="$copie.log"
186
192
  rang="$copie.travail/seances/${seance:-${reprise:-courante}}"
187
193
  fin="$rang/fin"
188
194
  resultat="$rang/resultat.json"
189
- hors_plan="$rang/hors-plan"
190
- hors_plan_fait="$rang/hors-plan.json"
195
+ avant="$rang/avant"
191
196
  demarree="$rang/demarree"
192
197
  mkdir -p "$(dirname "$copie")" "$rang"
193
- rm -f "$fin" "$resultat" "$hors_plan" "$hors_plan_fait" "$demarree"
198
+ rm -f "$fin" "$resultat" "$avant" "$demarree"
194
199
  printf '=== %s · %s · %s ===\n' "$(date -Iseconds)" "$role" "$composant" >> "$journal"
195
- # The temporary directory of the ticket (`ouvrirBaseDuTicket`, scripts/mesure/base-de-passe.mjs):
196
- # TMPDIR, TMP and TEMP of the rest of the launch and of the session, whose scratchpads and working
197
- # directory lie in it. It stays from one session and one resumption of the ticket to the next, and
198
- # goes when the ticket is closed (scripts/copies-finies.mjs).
199
- temporaire=$(node "$ici/../mesure/base-de-passe.mjs" "$ticket" 2>> "$journal") \
200
- || { echo "⛔ Le dossier temporaire du ticket n'a pas pu s'ouvrir : voir $journal." >&2; exit "$CODE_COPIE"; }
200
+ # The temporary directory of the session, a base this shell owns: TMPDIR, TMP and TEMP of the rest
201
+ # of the launch and of the session, whose scratchpads and working directory lie in it.
202
+ temporaire=$(node --input-type=module -e "import { ouvrirBase } from '$ici/../mesure/base-de-passe.mjs'; process.stdout.write(ouvrirBase('seance', { pid: Number(process.argv[1]) }).dossier);" "$$" 2>> "$journal") \
203
+ || { echo "⛔ Le dossier temporaire de la séance n'a pas pu s'ouvrir : voir $journal." >&2; exit "$CODE_COPIE"; }
201
204
  export TMPDIR="$temporaire" TMP="$temporaire" TEMP="$temporaire"
205
+ # The launcher's own files lie in its base, beside the directory of the session, which holds what
206
+ # the session and the preparation of its copy write.
207
+ base_du_lanceur="${temporaire%/t}"
208
+ unset CLAUDE_CODE_TMPDIR
209
+ travail=
210
+ # What the circuit reads after the session leaves its working directory for the session's folder:
211
+ # the witness that the envelope started its command (a launch the envelope refuses before the
212
+ # session, a mount bwrap cannot make, leaves none).
213
+ ranger() {
214
+ [ -n "$travail" ] || return 0
215
+ if [ -f "$travail/.demarree" ]; then
216
+ mv "$travail/.demarree" "$demarree"
217
+ fi
218
+ }
219
+ # The directory goes at the end of the launcher, whatever ends it.
220
+ fermer() {
221
+ ranger || true
222
+ rm -rf -- "$base_du_lanceur" || true
223
+ }
224
+ trap fermer EXIT
225
+ trap 'exit 129' HUP
226
+ trap 'exit 130' INT
227
+ trap 'exit 143' TERM
202
228
  # The output of the session's build, when it fails, behind its first line, which says what failed
203
229
  # and what was built: the module's command `construire` writes it.
204
- echec=$(mktemp)
230
+ echec=$(mktemp -p "$base_du_lanceur")
205
231
  (
206
232
  # Each step returns on failure: `set -e` does not act inside a subshell tested by `||`.
207
233
  # An existing copy moves forward to main by the preparation (`cible`); a new one is made on it.
@@ -250,10 +276,6 @@ publie=$(cd "$copie" && node "$ici/../../bin/grillhouse.mjs" index-interfaces --
250
276
  # The session's working directory, the one the envelope gives as TMPDIR, follows them.
251
277
  travail=$(node --input-type=module -e "import { dossierDeTravail } from '$ici/enveloppe.mjs'; process.stdout.write(dossierDeTravail(process.argv[1]));" "$copie" 2>> "$journal") \
252
278
  || { rm -f "$echec"; echo "⛔ Le dossier de travail de la séance n'a pas pu se lire : voir $journal." >&2; exit "$CODE_COPIE"; }
253
- # The mark a lock leaves there when it stops the session out of the plan, and the witness the
254
- # envelope's command leaves there at its start (`TEMOIN_DE_DEMARRAGE` of enveloppe.mjs): none before
255
- # the session.
256
- rm -f "$travail/hors-plan" "$travail/.demarree"
257
279
  dossier=$'\n\n'"## Ton dossier de travail"$'\n\n'"Tout fichier temporaire s'écrit dans \`$travail\`, que \`\$TMPDIR\` nomme aussi."
258
280
  construction=
259
281
  if [ -s "$echec" ]; then
@@ -262,10 +284,11 @@ fi
262
284
  rm -f "$echec"
263
285
  # The prompt, assembled in a file: claude reads it on its standard input, since as an argument it
264
286
  # may pass the size Linux allows one (MAX_ARG_STRLEN, 128 KiB).
265
- # A resumed session holds the sections of its first instruction: only a failed build is news.
266
- prompt=$(mktemp)
287
+ # A resumed session holds the sections of its first instruction: its new working directory and a
288
+ # failed build alone are news.
289
+ prompt=$(mktemp -p "$base_du_lanceur")
267
290
  if [ -n "$reprise" ]; then
268
- printf '%s' "$(cat "$consigne")$construction" > "$prompt"
291
+ printf '%s' "$(cat "$consigne")$dossier$construction" > "$prompt"
269
292
  else
270
293
  printf '%s' "$(cat "$consigne")"$'\n\n'"$publie$dossier$construction" > "$prompt"
271
294
  fi
@@ -281,6 +304,10 @@ fiche=()
281
304
  schema=$(node "$ici/../resultats.mjs" --schema "${sorte:-$role}" 2> /dev/null) || schema=
282
305
  [ -z "$schema" ] || fiche=(--output-format json --json-schema "$schema")
283
306
 
307
+ # The state of the prepared copy, which the session's lot is read from.
308
+ node "$ici/travail-de-la-copie.mjs" photographier "$copie" > "$avant" 2>> "$journal" \
309
+ || { rm -f "$prompt" "$avant"; echo "⛔ L'état de la copie avant la séance n'a pas pu se lire : voir $journal." >&2; exit "$CODE_COPIE"; }
310
+
284
311
  # An envelope in error does not stop the launcher (set -e): its code is kept for the exit.
285
312
  code=0
286
313
  lancer_claude() {
@@ -296,20 +323,7 @@ else
296
323
  lancer_claude >> "$journal" 2>&1 || code=$?
297
324
  fi
298
325
  rm -f "$prompt"
299
- # The witness that the envelope started its command goes to the circuit: a launch the envelope
300
- # refuses before the session (a mount bwrap cannot make) leaves none.
301
- if [ -f "$travail/.demarree" ]; then
302
- mv "$travail/.demarree" "$demarree"
303
- fi
304
- # A session its lock stopped out of the plan (scripts/verrous/verrou.mjs): its reason goes to the
305
- # circuit, and to the log.
306
- if [ -f "$travail/hors-plan" ]; then
307
- mv "$travail/hors-plan" "$hors_plan"
308
- { cat "$hors_plan"; echo; } >> "$journal"
309
- fi
310
- if [ -f "$travail/hors-plan.json" ]; then
311
- mv "$travail/hors-plan.json" "$hors_plan_fait"
312
- fi
326
+ ranger
313
327
  echo "$code" > "$fin"
314
328
  # The envelope ended: the session's line goes to the register from outside it, whatever its end hook did.
315
329
  node "$ici/../registre.mjs" --copie "$copie" >> "$journal" 2>&1 || true
@@ -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
  }