@roomi-fields/grillhouse 0.28.3 → 0.30.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 (238) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +739 -0
  3. package/bin/grillhouse.mjs +128 -26
  4. package/cadre/templates/projet/.github/workflows/ci.yml +2 -13
  5. package/cadre/templates/projet/CLAUDE.md +5 -1
  6. package/cadre/templates/projet/README.md +11 -11
  7. package/cadre/templates/projet/_gitignore +2 -5
  8. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  9. package/cadre/templates/projet/package.json +2 -2
  10. package/charte.md +37 -4
  11. package/dist/temporal/acte.d.ts +24 -0
  12. package/dist/temporal/acte.js +139 -0
  13. package/dist/temporal/acte.js.map +1 -0
  14. package/dist/temporal/attributs.d.ts +6 -0
  15. package/dist/temporal/attributs.js +15 -0
  16. package/dist/temporal/attributs.js.map +1 -0
  17. package/dist/temporal/circuit/activites.d.ts +13 -0
  18. package/dist/temporal/circuit/activites.js +33 -0
  19. package/dist/temporal/circuit/activites.js.map +1 -0
  20. package/dist/temporal/circuit/client.d.ts +72 -0
  21. package/dist/temporal/circuit/client.js +247 -0
  22. package/dist/temporal/circuit/client.js.map +1 -0
  23. package/dist/temporal/circuit/commande.d.ts +2 -0
  24. package/dist/temporal/circuit/commande.js +238 -0
  25. package/dist/temporal/circuit/commande.js.map +1 -0
  26. package/dist/temporal/circuit/contrat.d.ts +305 -0
  27. package/dist/temporal/circuit/contrat.js +24 -0
  28. package/dist/temporal/circuit/contrat.js.map +1 -0
  29. package/dist/temporal/circuit/deroule.d.ts +3 -0
  30. package/dist/temporal/circuit/deroule.js +540 -0
  31. package/dist/temporal/circuit/deroule.js.map +1 -0
  32. package/dist/temporal/client.d.ts +47 -0
  33. package/dist/temporal/client.js +69 -0
  34. package/dist/temporal/client.js.map +1 -0
  35. package/dist/temporal/commande.d.ts +2 -0
  36. package/dist/temporal/commande.js +95 -0
  37. package/dist/temporal/commande.js.map +1 -0
  38. package/dist/temporal/deroules.d.ts +5 -0
  39. package/dist/temporal/deroules.js +10 -0
  40. package/dist/temporal/deroules.js.map +1 -0
  41. package/dist/temporal/etat.d.ts +33 -0
  42. package/dist/temporal/etat.js +59 -0
  43. package/dist/temporal/etat.js.map +1 -0
  44. package/dist/temporal/file/activites.d.ts +10 -0
  45. package/dist/temporal/file/activites.js +25 -0
  46. package/dist/temporal/file/activites.js.map +1 -0
  47. package/dist/temporal/file/client.d.ts +4 -0
  48. package/dist/temporal/file/client.js +6 -0
  49. package/dist/temporal/file/client.js.map +1 -0
  50. package/dist/temporal/file/contrat.d.ts +158 -0
  51. package/dist/temporal/file/contrat.js +14 -0
  52. package/dist/temporal/file/contrat.js.map +1 -0
  53. package/dist/temporal/file/deroule.d.ts +15 -0
  54. package/dist/temporal/file/deroule.js +235 -0
  55. package/dist/temporal/file/deroule.js.map +1 -0
  56. package/dist/temporal/installation.d.ts +124 -0
  57. package/dist/temporal/installation.js +408 -0
  58. package/dist/temporal/installation.js.map +1 -0
  59. package/dist/temporal/places/activites.d.ts +8 -0
  60. package/dist/temporal/places/activites.js +13 -0
  61. package/dist/temporal/places/activites.js.map +1 -0
  62. package/dist/temporal/places/client.d.ts +28 -0
  63. package/dist/temporal/places/client.js +64 -0
  64. package/dist/temporal/places/client.js.map +1 -0
  65. package/dist/temporal/places/contrat.d.ts +106 -0
  66. package/dist/temporal/places/contrat.js +21 -0
  67. package/dist/temporal/places/contrat.js.map +1 -0
  68. package/dist/temporal/places/deroule.d.ts +3 -0
  69. package/dist/temporal/places/deroule.js +198 -0
  70. package/dist/temporal/places/deroule.js.map +1 -0
  71. package/dist/temporal/sonde/activites.d.ts +6 -0
  72. package/dist/temporal/sonde/activites.js +52 -0
  73. package/dist/temporal/sonde/activites.js.map +1 -0
  74. package/dist/temporal/sonde/contrat.d.ts +35 -0
  75. package/dist/temporal/sonde/contrat.js +10 -0
  76. package/dist/temporal/sonde/contrat.js.map +1 -0
  77. package/dist/temporal/sonde/deroule.d.ts +3 -0
  78. package/dist/temporal/sonde/deroule.js +39 -0
  79. package/dist/temporal/sonde/deroule.js.map +1 -0
  80. package/dist/temporal/tickets/activites.d.ts +7 -0
  81. package/dist/temporal/tickets/activites.js +81 -0
  82. package/dist/temporal/tickets/activites.js.map +1 -0
  83. package/dist/temporal/tickets/client.d.ts +10 -0
  84. package/dist/temporal/tickets/client.js +31 -0
  85. package/dist/temporal/tickets/client.js.map +1 -0
  86. package/dist/temporal/tickets/contrat.d.ts +56 -0
  87. package/dist/temporal/tickets/contrat.js +13 -0
  88. package/dist/temporal/tickets/contrat.js.map +1 -0
  89. package/dist/temporal/tickets/deroule.d.ts +3 -0
  90. package/dist/temporal/tickets/deroule.js +94 -0
  91. package/dist/temporal/tickets/deroule.js.map +1 -0
  92. package/dist/temporal/travailleur.d.ts +2 -0
  93. package/dist/temporal/travailleur.js +69 -0
  94. package/dist/temporal/travailleur.js.map +1 -0
  95. package/docs/ARCHITECTURE.md +813 -53
  96. package/docs/CADRE.md +17 -0
  97. package/docs/INTERFACE.md +161 -30
  98. package/hooks/crochet.mjs +19 -2
  99. package/hooks/hooks.json +11 -0
  100. package/package.json +16 -4
  101. package/scripts/activites.mjs +2182 -0
  102. package/scripts/aiguillage.d.mts +37 -0
  103. package/scripts/aiguillage.mjs +328 -0
  104. package/scripts/avancement.mjs +159 -64
  105. package/scripts/bilan.mjs +37 -19
  106. package/scripts/cadre.mjs +11 -2
  107. package/scripts/circuit.mjs +888 -3654
  108. package/scripts/circuits-cles.d.mts +4 -0
  109. package/scripts/circuits-cles.mjs +21 -0
  110. package/scripts/circuits-du-serveur.mjs +105 -0
  111. package/scripts/codes-de-sortie.mjs +9 -0
  112. package/scripts/commandes-composees.mjs +45 -41
  113. package/scripts/commandes-du-path.d.mts +7 -0
  114. package/scripts/commandes-du-path.mjs +25 -0
  115. package/scripts/composition-des-langages.mjs +30 -11
  116. package/scripts/conformite.mjs +19 -10
  117. package/scripts/copies-finies.mjs +188 -42
  118. package/scripts/depart-du-ticket.d.mts +53 -0
  119. package/scripts/depart-du-ticket.mjs +124 -0
  120. package/scripts/dependances-internes.mjs +115 -0
  121. package/scripts/dernier-vert.mjs +7 -15
  122. package/scripts/donnees-cles.mjs +228 -0
  123. package/scripts/droits.mjs +11 -1
  124. package/scripts/effets.mjs +352 -0
  125. package/scripts/enveloppe/enveloppe.mjs +119 -8
  126. package/scripts/enveloppe/lancer.sh +27 -32
  127. package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
  128. package/scripts/enveloppe/travail-de-la-copie.mjs +99 -12
  129. package/scripts/etapes.mjs +6 -3
  130. package/scripts/faits-du-circuit.mjs +493 -0
  131. package/scripts/file-des-tickets.d.mts +21 -0
  132. package/scripts/file-des-tickets.mjs +58 -0
  133. package/scripts/flux-des-paquets.mjs +187 -0
  134. package/scripts/fusion-du-changelog.mjs +0 -1
  135. package/scripts/gardes-du-cadre.mjs +12 -2
  136. package/scripts/grillhouse-maj.mjs +16 -7
  137. package/scripts/integration/file.mjs +477 -422
  138. package/scripts/integration/integrer.mjs +20 -22
  139. package/scripts/integration/rejeu.mjs +19 -4
  140. package/scripts/jointure.d.ts +168 -28
  141. package/scripts/langages/cargo/commandes.mjs +426 -119
  142. package/scripts/langages/cargo/composants.mjs +187 -3
  143. package/scripts/langages/cargo/exemples.mjs +75 -17
  144. package/scripts/langages/cargo/index.mjs +32 -13
  145. package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +35 -0
  146. package/scripts/langages/cargo/sccache.mjs +62 -16
  147. package/scripts/langages/cargo/squelette.mjs +72 -3
  148. package/scripts/langages/cargo/tailles-des-tests.mjs +195 -0
  149. package/scripts/langages/cargo/tests-de-head.mjs +159 -0
  150. package/scripts/langages/python/commandes.mjs +232 -79
  151. package/scripts/langages/python/composants.mjs +65 -3
  152. package/scripts/langages/python/exemples.mjs +21 -12
  153. package/scripts/langages/python/index.mjs +25 -5
  154. package/scripts/langages/python/lot.mjs +1 -36
  155. package/scripts/langages/python/squelette.mjs +119 -17
  156. package/scripts/langages/typescript/construire.mjs +6 -163
  157. package/scripts/langages/typescript/exemples.mjs +19 -11
  158. package/scripts/langages/typescript/frontieres.mjs +1 -1
  159. package/scripts/langages/typescript/index.mjs +48 -63
  160. package/scripts/langages/typescript/interfaces-contre-code.mjs +4 -4
  161. package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
  162. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +31 -0
  163. package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
  164. package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
  165. package/scripts/langages/typescript/regle-des-tests.mjs +13 -0
  166. package/scripts/langages/typescript/squelette.mjs +18 -2
  167. package/scripts/langages/typescript/tailles-des-tests.mjs +40 -9
  168. package/scripts/langages/typescript/tests-de-nuit.mjs +44 -21
  169. package/scripts/langages/typescript/tests.mjs +17 -8
  170. package/scripts/langages/typescript/titres-de-tests.mjs +297 -0
  171. package/scripts/langages/typescript/turbo-des-paquets.mjs +183 -38
  172. package/scripts/langages/typescript/verdict.mjs +1 -1
  173. package/scripts/langages/typescript/verifier.mjs +110 -296
  174. package/scripts/langages/typescript/vitest-config/base.mjs +30 -10
  175. package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
  176. package/scripts/langages/typescript/vitest-config/cibles.mjs +123 -62
  177. package/scripts/langages/typescript/vitest-config/delais.mjs +54 -0
  178. package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
  179. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +100 -0
  180. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +56 -64
  181. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +7 -2
  182. package/scripts/langages/typescript/vitest-config/mesure.mjs +3 -2
  183. package/scripts/langages/typescript/vitest.nuit.config.mjs +22 -13
  184. package/scripts/lecture-unique.mjs +51 -0
  185. package/scripts/mesure/pression.mjs +11 -9
  186. package/scripts/mesure-de-la-machine.d.mts +21 -0
  187. package/scripts/mesure-de-la-machine.mjs +76 -0
  188. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +8 -2
  189. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +120 -0
  190. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
  191. package/scripts/migrations.mjs +5 -0
  192. package/scripts/nuit.sh +29 -15
  193. package/scripts/outil.mjs +72 -0
  194. package/scripts/outils-cles.d.mts +24 -0
  195. package/scripts/outils-cles.mjs +0 -1
  196. package/scripts/paquet-npm.mjs +147 -0
  197. package/scripts/paquet.mjs +112 -14
  198. package/scripts/paquets.mjs +34 -6
  199. package/scripts/passe-de-la-machine.mjs +66 -0
  200. package/scripts/places-de-la-machine.mjs +360 -0
  201. package/scripts/places-du-serveur.mjs +170 -0
  202. package/scripts/prefixe-des-tickets.mjs +68 -0
  203. package/scripts/preparation.mjs +10 -3
  204. package/scripts/registre.mjs +3 -2
  205. package/scripts/regles-des-places.d.mts +36 -0
  206. package/scripts/regles-des-places.mjs +70 -0
  207. package/scripts/reponses-du-circuit.d.mts +6 -0
  208. package/scripts/reponses-du-circuit.mjs +28 -0
  209. package/scripts/resultats.mjs +29 -14
  210. package/scripts/retirer-les-copies-finies.mjs +25 -0
  211. package/scripts/sans-reponse.d.mts +4 -0
  212. package/scripts/sans-reponse.mjs +13 -0
  213. package/scripts/seances.mjs +918 -0
  214. package/scripts/services-du-noyau.mjs +28 -11
  215. package/scripts/session-start.sh +10 -1
  216. package/scripts/sortie.mjs +23 -4
  217. package/scripts/sources.mjs +3 -3
  218. package/scripts/sous-commandes.mjs +39 -9
  219. package/scripts/style-a-l-ecriture.mjs +229 -0
  220. package/scripts/superviseur.mjs +382 -16
  221. package/scripts/tableau.mjs +329 -130
  222. package/scripts/taches-du-graphe.mjs +328 -0
  223. package/scripts/ticket-du-circuit.mjs +206 -0
  224. package/scripts/transitions.d.mts +148 -0
  225. package/scripts/transitions.mjs +901 -0
  226. package/scripts/verrou-de-fichier.mjs +2 -2
  227. package/scripts/verrou-de-machine.mjs +322 -62
  228. package/skills/developpeur/SKILL.md +11 -3
  229. package/skills/explorateur/SKILL.md +2 -1
  230. package/skills/pitmaster/SKILL.md +62 -28
  231. package/skills/pitmaster/references/consigne-agent.md +5 -1
  232. package/skills/release/SKILL.md +3 -3
  233. package/skills/relecteur/SKILL.md +22 -8
  234. package/skills/testwriter/SKILL.md +47 -39
  235. package/scripts/demon.mjs +0 -138
  236. package/scripts/integration/file-attente.mjs +0 -61
  237. package/scripts/langages/cargo/touches.mjs +0 -93
  238. package/scripts/langages/typescript/script-des-tests.mjs +0 -6
@@ -1,6 +1,6 @@
1
1
  // The lock of a file shared between processes: the file `<verrou>` stands while someone holds it.
2
- // Taken by the integration (`.git/integration.lock`, `.git/file-integration.lock`) and by the
3
- // register (`registre.jsonl.verrou`).
2
+ // Taken by the integration (`.git/integration.lock`) and by the register
3
+ // (`registre.jsonl.verrou`).
4
4
  //
5
5
  // - A lock is created whole and exclusively: its mark (the owner's process number, then a token
6
6
  // unique to the taking) is written to a private file that is linked to `<verrou>`; the link
@@ -39,14 +39,30 @@
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
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
48
- // names no one and goes. Between measures of one rank, the first to find the lock free takes
49
- // it. The bound of the wait is the same for both ranks, and the wait says its rank.
42
+ // second, « mesure d'un projet ». A measure that waits for the lock names its rank among the
43
+ // waits (`<lock>.attentes/`, below); a measure of the second rank does not take the lock, even
44
+ // free, while a live measure of the first waits for it, so a check of the frame, whose next
45
+ // version every project waits for, never waits behind the projects' measures (the verification
46
+ // of 0.26.0 waited 61 min behind five measures of two projects). Between measures of one rank,
47
+ // the first to find the lock free takes it. The bound of the wait is the same for both ranks,
48
+ // and the wait says its rank.
49
+ // - The lock names its holder and its waits, as lslocks names who holds a lock and cargo's
50
+ // « Blocking waiting for file lock » says what a wait waits for. Whoever takes it, a pass out of
51
+ // a ticket or the circuit of a ticket, of any project of the machine, names itself beside it in
52
+ // `<lock>.detenteur.json`: its mark, its process, its project, its ticket or null, its kind
53
+ // (`sorte`: « Vérification » by default, or GRILLHOUSE_VERIFICATION_SORTE and
54
+ // GRILLHOUSE_VERIFICATION_TICKET from the caller, a step's title for a circuit), since when, and its progress
55
+ // directory once it names it (`nommerLAvancement`); the name goes with the lock. Each measure
56
+ // that waits, for the lock or for room in the temporary directory, names itself in the
57
+ // directory `<lock>.attentes/`, one file per waiting process (its process, its rank, its
58
+ // project, ticket and kind, what it waits for `quoi`, since when), removed once it stops
59
+ // waiting. The project is named by the root of the main tree of the repository the measure
60
+ // plays in, its copies included (`depot`, `racineDuDepot`); the board gives it the name it
61
+ // gives that project, its folder's for a project out of the board (scripts/tableau.mjs).
62
+ // `lireLeVerrou` reads them for the board (through `lireLaMesure` of scripts/avancement.mjs): a
63
+ // holder or a wait whose process is gone names no one, and the wait's file goes; a lock a live
64
+ // process holds without naming itself (a frame older than this naming) shows as the repository
65
+ // of its process's directory, of the kind « Verrou ».
50
66
  // - The lock is let go at the end of the measure, whether it succeeds or throws.
51
67
  // - A measure first wants room in the temporary directory (`os.tmpdir()` under its environment),
52
68
  // a disk in memory that the sessions of the machine share: under LIBRE_MIN, 4 GB free
@@ -58,6 +74,16 @@
58
74
  // entries, by the blocks their files hold, the temporary directory of a ticket naming its
59
75
  // ticket), when it begins and every 30 s, under the same bound as the
60
76
  // lock's, then « à repasser » (75).
77
+ // - It then wants room on the disk of the copy it plays in (its root, `racine`), where cargo
78
+ // writes its target directories: under LIBRE_MIN as well (GRILLHOUSE_COPIE_LIBRE names another
79
+ // floor, in bytes; the base configuration of the tests sets 0), it waits the same way, under
80
+ // the same bound counted from the start of the wait, and says what holds that disk: the copies
81
+ // of its repository, the largest first, each with its ticket and its tools' outputs
82
+ // (`occupantsDesCopies` of scripts/copies-finies.mjs: « .claude/worktrees/SH-ae6.2.7 (le
83
+ // ticket SH-ae6.2.7, 5,0 Go, dont target 4,8 Go) »), as Bazel and Buildkite refuse to start a
84
+ // build under a floor of free room rather than fail in its middle (the main disk full on
85
+ // 2026-11-01, three circuits killed without a word, grillhouse-k5y).
86
+ import { spawnSync } from 'node:child_process';
61
87
  import { randomUUID } from 'node:crypto';
62
88
  import {
63
89
  lstatSync,
@@ -68,22 +94,27 @@ import {
68
94
  rmSync,
69
95
  statfsSync,
70
96
  statSync,
71
- writeFileSync,
72
97
  } from 'node:fs';
73
98
  import { homedir, tmpdir } from 'node:os';
74
99
  import path from 'node:path';
100
+ import { occupantsDesCopies } from './copies-finies.mjs';
75
101
  import { paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
76
102
  import { paquets } from './paquets.mjs';
77
103
  import { attendreUnPeu, lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
104
+ import { ecrireAtomique } from './mesure/avancement.mjs';
78
105
  import { ticketDeLaBase, vivant } from './mesure/base-de-passe.mjs';
79
- import { A_REPASSER } from './mesure/pression.mjs';
106
+ import { A_REPASSER } from './codes-de-sortie.mjs';
80
107
 
81
108
  const VARIABLE_VERROU = 'GRILLHOUSE_VERROU_MACHINE';
82
109
  const VARIABLE_TENUE = 'GRILLHOUSE_MESURE_TENUE';
110
+ const VARIABLE_VERIFICATION_SORTE = 'GRILLHOUSE_VERIFICATION_SORTE';
111
+ const VARIABLE_VERIFICATION_TICKET = 'GRILLHOUSE_VERIFICATION_TICKET';
83
112
  const VARIABLE_ATTENTE = 'GRILLHOUSE_ATTENTE_MACHINE_MS';
84
113
  const VARIABLE_LIBRE = 'GRILLHOUSE_TEMPORAIRE_LIBRE';
114
+ const VARIABLE_COPIE = 'GRILLHOUSE_COPIE_LIBRE';
85
115
 
86
- /** The room a heavy measure wants free in the temporary directory, in bytes: 4 GB. */
116
+ /** The room a heavy measure wants free in the temporary directory, and on the disk of its copy,
117
+ * in bytes: 4 GB. */
87
118
  export const LIBRE_MIN = 4 * 1024 ** 3;
88
119
 
89
120
  // The name of the frame's package, which a repository of the first rank develops.
@@ -119,8 +150,8 @@ export class AttenteDeLaMachine extends Error {
119
150
  }
120
151
  }
121
152
 
122
- // The lock file of the machine under <env>, beside which a measure out of a ticket names its
123
- // progress (scripts/avancement.mjs).
153
+ // The lock file of the machine under <env>, beside which its holder and its waits name
154
+ // themselves.
124
155
  export function verrouDeMachine(env = process.env) {
125
156
  if (env[VARIABLE_VERROU]) return env[VARIABLE_VERROU];
126
157
  const cache = env.XDG_CACHE_HOME || path.join(env.HOME || homedir(), '.cache');
@@ -180,36 +211,199 @@ function qui(verrou) {
180
211
  return `${processus(pid)}${depuis}`;
181
212
  }
182
213
 
183
- // The directory where the measures of the first rank that wait for <verrou> name themselves.
184
- const fileDuPremierRang = verrou => `${verrou}.premier-rang`;
214
+ /**
215
+ * The root of the repository at <racine>: its main tree, its copies included (the parent of its
216
+ * common directory of git); <racine> itself out of git.
217
+ * @param {string} racine
218
+ * @returns {string}
219
+ */
220
+ export function racineDuDepot(racine) {
221
+ const r = spawnSync(
222
+ 'git',
223
+ ['-C', racine, 'rev-parse', '--path-format=absolute', '--git-common-dir'],
224
+ { encoding: 'utf8' }
225
+ );
226
+ return r.status === 0 ? path.dirname(r.stdout.trim()) : path.resolve(racine);
227
+ }
228
+
229
+ const lireJson = f => {
230
+ try {
231
+ return JSON.parse(readFileSync(f, 'utf8'));
232
+ } catch {
233
+ return null;
234
+ }
235
+ };
185
236
 
186
- // Names this process among the measures of the first rank that wait for <verrou>; a function that
187
- // removes its name.
188
- function attendreAuPremierRang(verrou) {
189
- const dossier = fileDuPremierRang(verrou);
190
- const f = path.join(dossier, `${process.pid}-${randomUUID()}`);
191
- mkdirSync(dossier, { recursive: true });
192
- writeFileSync(f, String(process.pid));
237
+ // The file where the holder of <verrou> names itself, and the directory of its waits.
238
+ const fichierDuDetenteur = verrou => `${verrou}.detenteur.json`;
239
+ const dossierDesAttentes = verrou => `${verrou}.attentes`;
240
+
241
+ // Who a measure is, from its options: `{ depot, ticket, sorte }`, the root of its repository
242
+ // read when first asked.
243
+ // The kind and the ticket come from the option of the caller (the circuit) when it gives one,
244
+ // else from the caller's environment (GRILLHOUSE_VERIFICATION_SORTE, GRILLHOUSE_VERIFICATION_TICKET,
245
+ // empty as absent), else « Vérification » and null.
246
+ function identite({ racine, env = {}, ticket, sorte }) {
247
+ ticket = ticket ?? (env[VARIABLE_VERIFICATION_TICKET] || null);
248
+ sorte = sorte ?? (env[VARIABLE_VERIFICATION_SORTE] || 'Vérification');
249
+ let depot = null;
250
+ return {
251
+ get depot() {
252
+ depot ??= racineDuDepot(racine);
253
+ return depot;
254
+ },
255
+ ticket,
256
+ sorte,
257
+ };
258
+ }
259
+
260
+ // Names this process, <id>, among the waits of <verrou>, waiting for <quoi> (« verrou »,
261
+ // « place ») at the rank <rang> (null for room); a function that removes its name.
262
+ function inscrireLAttente(verrou, id, quoi, rang = null) {
263
+ const f = path.join(dossierDesAttentes(verrou), `${process.pid}-${randomUUID()}.json`);
264
+ try {
265
+ ecrireAtomique(f, {
266
+ pid: process.pid,
267
+ rang,
268
+ depot: id.depot,
269
+ ticket: id.ticket,
270
+ sorte: id.sorte,
271
+ quoi,
272
+ depuis: Date.now(),
273
+ });
274
+ } catch {
275
+ return () => {};
276
+ }
193
277
  return () => rmSync(f, { force: true });
194
278
  }
195
279
 
196
- // The live processes of the measures of the first rank that wait for <verrou>; the name of a
197
- // process that is gone is removed.
198
- function premiersQuiAttendent(verrou) {
199
- const dossier = fileDuPremierRang(verrou);
280
+ // The waits of <verrou> whose process lives, the oldest first; the file of a process that is gone
281
+ // is removed.
282
+ function attentesDe(verrou) {
283
+ const dossier = dossierDesAttentes(verrou);
200
284
  let noms;
201
285
  try {
202
286
  noms = readdirSync(dossier);
203
287
  } catch {
204
288
  return [];
205
289
  }
206
- const pids = [];
290
+ const out = [];
207
291
  for (const nom of noms) {
208
292
  const pid = Number(/^(\d+)-/.exec(nom)?.[1]);
209
- if (pid && vivant(pid)) pids.push(pid);
210
- else rmSync(path.join(dossier, nom), { force: true });
293
+ if (!pid || !vivant(pid)) {
294
+ rmSync(path.join(dossier, nom), { force: true });
295
+ continue;
296
+ }
297
+ const a = nom.endsWith('.json') ? lireJson(path.join(dossier, nom)) : null;
298
+ if (a?.pid === pid) out.push(a);
299
+ }
300
+ return out.sort((a, b) => (a.depuis ?? 0) - (b.depuis ?? 0));
301
+ }
302
+
303
+ // The live processes of the measures of the first rank that wait for <verrou>.
304
+ const premiersQuiAttendent = verrou =>
305
+ attentesDe(verrou)
306
+ .filter(a => a.quoi === 'verrou' && a.rang === 1)
307
+ .map(a => a.pid);
308
+
309
+ // Names this process, <id>, holder of <verrou> under the mark it holds; a function that removes
310
+ // the name while it is still this taking's.
311
+ function nommerLeDetenteur(verrou, id) {
312
+ const f = fichierDuDetenteur(verrou);
313
+ const marque = lire(verrou);
314
+ try {
315
+ ecrireAtomique(f, {
316
+ marque,
317
+ pid: process.pid,
318
+ depot: id.depot,
319
+ ticket: id.ticket,
320
+ sorte: id.sorte,
321
+ depuis: Date.now(),
322
+ dossier: null,
323
+ });
324
+ } catch {
325
+ return () => {};
326
+ }
327
+ return () => {
328
+ if (lireJson(f)?.marque === marque) rmSync(f, { force: true });
329
+ };
330
+ }
331
+
332
+ /**
333
+ * Names the progress directory <dossier> of the measure that holds the lock of the machine under
334
+ * <env> (its mark in GRILLHOUSE_MESURE_TENUE), beside the lock, where the board reads it; a
335
+ * function that takes it out. Nothing without a lock this environment holds (in the envelope of
336
+ * an agent).
337
+ * @param {{ env?: Record<string, string | undefined>, dossier: string }} o
338
+ * @returns {() => void}
339
+ */
340
+ export function nommerLAvancement({ env = process.env, dossier }) {
341
+ const f = fichierDuDetenteur(verrouDeMachine(env));
342
+ const marque = env[VARIABLE_TENUE];
343
+ const ecrire = d => {
344
+ const n = lireJson(f);
345
+ if (!marque || n?.marque !== marque) return false;
346
+ try {
347
+ ecrireAtomique(f, { ...n, dossier: d });
348
+ return true;
349
+ } catch {
350
+ return false;
351
+ }
352
+ };
353
+ return ecrire(dossier) ? () => void ecrire(null) : () => {};
354
+ }
355
+
356
+ /**
357
+ * Who holds the lock of the machine under <env> and who waits for it. `detenteur`: its process,
358
+ * repository (`depot`, the root of its main tree, and `projet`, its folder), ticket, kind, since
359
+ * when (ms) and progress directory; null when the lock is free or its process gone; a live process
360
+ * that names nothing beside the lock shows as the repository of its directory, of the kind
361
+ * « Verrou ». `attentes`: each live wait, the oldest first, its process, rank, repository,
362
+ * ticket, kind, what it waits for (`quoi`: « verrou » or « place ») and since when.
363
+ * @param {Record<string, string | undefined>} [env]
364
+ */
365
+ export function lireLeVerrou(env = process.env) {
366
+ const verrou = verrouDeMachine(env);
367
+ const attentes = attentesDe(verrou).map(({ pid, rang, depot, ticket, sorte, quoi, depuis }) => ({
368
+ pid,
369
+ rang,
370
+ depot,
371
+ projet: path.basename(String(depot)),
372
+ ticket,
373
+ sorte,
374
+ quoi,
375
+ depuis,
376
+ }));
377
+ const marque = lire(verrou);
378
+ const pid = detenteur(verrou);
379
+ if (marque === null || pid === null || !vivant(pid)) return { detenteur: null, attentes };
380
+ const n = lireJson(fichierDuDetenteur(verrou));
381
+ if (n?.marque === marque) {
382
+ const { depot, ticket, sorte, depuis, dossier } = n;
383
+ const projet = path.basename(String(depot));
384
+ return { detenteur: { pid, depot, projet, ticket, sorte, depuis, dossier }, attentes };
211
385
  }
212
- return pids;
386
+ let depuis = null;
387
+ let ou = null;
388
+ try {
389
+ depuis = statSync(verrou).mtimeMs;
390
+ ou = readlinkSync(`/proc/${pid}/cwd`);
391
+ } catch {
392
+ // the lock gone meanwhile, or the directory of its process unreadable: its number names it
393
+ }
394
+ const depot = ou ? racineDuDepot(ou) : null;
395
+ return {
396
+ detenteur: {
397
+ pid,
398
+ depot,
399
+ projet: depot ? path.basename(depot) : `processus ${pid}`,
400
+ ticket: null,
401
+ sorte: 'Verrou',
402
+ depuis,
403
+ dossier: null,
404
+ },
405
+ attentes,
406
+ };
213
407
  }
214
408
 
215
409
  // Whom a measure of the rank <rang> waits for at <verrou>: the holder of the lock, and for the
@@ -243,10 +437,10 @@ function ancetre(pid) {
243
437
  return false;
244
438
  }
245
439
 
246
- // The floor of room under <env>, in bytes.
247
- function plancherDe(env) {
248
- const n = Number(env[VARIABLE_LIBRE]);
249
- return env[VARIABLE_LIBRE] && Number.isFinite(n) && n >= 0 ? n : LIBRE_MIN;
440
+ // The floor of room the variable <variable> names under <env>, in bytes, LIBRE_MIN by default.
441
+ function plancherDe(env, variable) {
442
+ const n = Number(env[variable]);
443
+ return env[variable] && Number.isFinite(n) && n >= 0 ? n : LIBRE_MIN;
250
444
  }
251
445
 
252
446
  // The room free in <dossier>, in bytes; Infinity when it does not read.
@@ -309,22 +503,55 @@ function occupants(dossier) {
309
503
  .join(', ');
310
504
  }
311
505
 
506
+ // The disks a heavy pass waits for room on, in order: `{ nom, ou, variable }`, the words of its
507
+ // lines (« le dossier temporaire », « dans le dossier temporaire »), and the variable of its floor.
508
+ const DISQUES = {
509
+ temporaire: {
510
+ nom: 'le dossier temporaire',
511
+ ou: 'dans le dossier temporaire',
512
+ variable: VARIABLE_LIBRE,
513
+ },
514
+ copie: {
515
+ nom: 'le disque de la copie',
516
+ ou: 'sur le disque de la copie',
517
+ variable: VARIABLE_COPIE,
518
+ },
519
+ };
520
+
312
521
  // Waits until <dossier> holds <plancher> bytes free (`libre`, a statfs at each turn), saying so
313
- // (`dire`) with what holds it (`occupe`, counted only when a line is written) when it begins and
314
- // every <rappelMs>. Throws an AttenteDeLaMachine (75) at <borneMs>.
315
- function attendreLaPlace(dossier, { plancher, libre, occupe, dire, borneMs, rappelMs }) {
316
- const debut = Date.now();
522
+ // (`dire`) in the words of <disque> (DISQUES) with what holds it (`occupe`, counted only when a
523
+ // line is written) when it begins and every <rappelMs>, and naming itself among the waits once it
524
+ // waits (`inscrire`, a function that returns the removal of its name). Throws an
525
+ // AttenteDeLaMachine (75) at <borneMs> from <debut> (now by default), the start of the whole wait.
526
+ function attendreLaPlace(dossier, { inscrire, ...o }) {
527
+ let retirer = null;
528
+ try {
529
+ return attendreLaPlaceEnNommant(dossier, {
530
+ ...o,
531
+ nommer: () => {
532
+ retirer ??= inscrire();
533
+ },
534
+ });
535
+ } finally {
536
+ retirer?.();
537
+ }
538
+ }
539
+
540
+ function attendreLaPlaceEnNommant(
541
+ dossier,
542
+ { disque, plancher, libre, occupe, dire, borneMs, rappelMs, nommer, debut = Date.now() }
543
+ ) {
317
544
  let dit = null;
318
545
  for (;;) {
319
546
  const l = libre(dossier);
320
547
  if (l >= plancher) {
321
- if (dit !== null)
322
- dire(`✓ place dans le dossier temporaire après ${duree(Date.now() - debut)}.`);
548
+ if (dit !== null) dire(`✓ place ${disque.ou} après ${duree(Date.now() - debut)}.`);
323
549
  return;
324
550
  }
551
+ nommer();
325
552
  const t = Date.now();
326
553
  const etat = () =>
327
- `le dossier temporaire (${dossier}) n'a que ${go(l)} libres, moins des ${go(plancher)} qu'une passe lourde demande (${VARIABLE_LIBRE}) ; l'occupent : ${occupe(dossier)}`;
554
+ `${disque.nom} (${dossier}) n'a que ${go(l)} libres, moins des ${go(plancher)} qu'une passe lourde demande (${disque.variable}) ; l'occupent : ${occupe(dossier)}`;
328
555
  if (t - debut >= borneMs)
329
556
  throw new AttenteDeLaMachine(
330
557
  `⏱ attente de place bornée à ${duree(borneMs)} (${VARIABLE_ATTENTE}) : ${etat()} ; à repasser (code ${A_REPASSER}).`,
@@ -339,11 +566,16 @@ function attendreLaPlace(dossier, { plancher, libre, occupe, dire, borneMs, rapp
339
566
  }
340
567
 
341
568
  /**
342
- * Waits for room in the temporary directory under <env> (`os.tmpdir()` as it reads it): what a
343
- * heavy pass does before it plays (`avecLaMachine`, the night tests).
344
- * @param {{ env?: Record<string, string | undefined>, dire?: (ligne: string) => void,
345
- * borneMs?: number, rappelMs?: number, libre?: (dossier: string) => number,
346
- * occupe?: (dossier: string) => string }} [options] as `avecLaMachine`'s
569
+ * Waits for room in the temporary directory under <env> (`os.tmpdir()` as it reads it), then on
570
+ * the disk of the copy at <racine>, where the pass writes its target directories: what a heavy
571
+ * pass does before it plays (see the header).
572
+ * @param {{ env?: Record<string, string | undefined>, dire?: (l: string) => void, borneMs?: number,
573
+ * rappelMs?: number, libre?: (dossier: string) => number, occupe?: (dossier: string) => string,
574
+ * occupeLaCopie?: (racine: string) => string, racine?: string, ticket?: string | null,
575
+ * sorte?: string }} [o] `libre` reads the room of each disk, `occupe` what holds the temporary
576
+ * directory, `occupeLaCopie` the copies that hold the disk of the copy; the wait names its
577
+ * project <racine>, its ticket and its kind among the waits of the lock of the machine under
578
+ * <env> while it waits
347
579
  * @throws {AttenteDeLaMachine} at the bound of the wait (code 75)
348
580
  */
349
581
  export function attendreDeLaPlace({
@@ -353,30 +585,47 @@ export function attendreDeLaPlace({
353
585
  rappelMs = RAPPEL_MS,
354
586
  libre = libreDans,
355
587
  occupe = occupants,
588
+ occupeLaCopie = occupantsDesCopies,
589
+ racine = process.cwd(),
590
+ ticket,
591
+ sorte,
356
592
  } = {}) {
357
593
  const temporaire = env.TMPDIR || env.TMP || env.TEMP || tmpdir();
594
+ const id = identite({ racine, env, ticket, sorte });
595
+ const inscrire = () => inscrireLAttente(verrouDeMachine(env), id, 'place');
596
+ const debut = Date.now();
597
+ const commun = { libre, dire, borneMs, rappelMs, inscrire, debut };
358
598
  attendreLaPlace(temporaire, {
359
- plancher: plancherDe(env),
360
- libre,
599
+ ...commun,
600
+ disque: DISQUES.temporaire,
601
+ plancher: plancherDe(env, VARIABLE_LIBRE),
361
602
  occupe,
362
- dire,
363
- borneMs,
364
- rappelMs,
603
+ });
604
+ attendreLaPlace(racine, {
605
+ ...commun,
606
+ disque: DISQUES.copie,
607
+ plancher: plancherDe(env, VARIABLE_COPIE),
608
+ occupe: occupeLaCopie,
365
609
  });
366
610
  }
367
611
 
368
- // The bound of the wait under <env>, in ms.
369
- function borneDe(env) {
612
+ /**
613
+ * The bound of the wait under <env>, in ms (GRILLHOUSE_ATTENTE_MACHINE_MS, else ATTENTE_MACHINE_MS);
614
+ * the wait for a place of the machine (scripts/places-de-la-machine.mjs) has the same.
615
+ * @param {Record<string, string | undefined>} env
616
+ * @returns {number}
617
+ */
618
+ export function borneDe(env) {
370
619
  const n = Number(env[VARIABLE_ATTENTE]);
371
620
  return env[VARIABLE_ATTENTE] && Number.isFinite(n) && n >= 0 ? n : ATTENTE_MACHINE_MS;
372
621
  }
373
622
 
374
623
  // Waits for the lock <verrou> at the rank <rang>, saying so (`dire`) when it begins and every
375
624
  // <rappelMs>; returns the time waited, in ms. Throws an AttenteDeLaMachine at once when an ancestor
376
- // holds the lock, and at the bound <borneMs>. A measure of the first rank names itself among those
377
- // that wait while it waits.
378
- function attendreLaMachine(verrou, { rang, dire, borneMs, rappelMs }) {
379
- const retirer = rang === 1 ? attendreAuPremierRang(verrou) : () => {};
625
+ // holds the lock, and at the bound <borneMs>. The measure, <id>, names itself among the waits,
626
+ // with its rank, while it waits.
627
+ function attendreLaMachine(verrou, { id, rang, dire, borneMs, rappelMs }) {
628
+ const retirer = inscrireLAttente(verrou, id, 'verrou', rang);
380
629
  try {
381
630
  return attendreAuRang(verrou, { rang, dire, borneMs, rappelMs });
382
631
  } finally {
@@ -421,12 +670,16 @@ function attendreAuRang(verrou, { rang, dire, borneMs, rappelMs }) {
421
670
  * @param {(envEnfant: Record<string, string | undefined>) => T} mesure a synchronous measure
422
671
  * @param {{ env?: Record<string, string | undefined>, racine?: string,
423
672
  * dire?: (ligne: string) => void, borneMs?: number, rappelMs?: number,
424
- * libre?: (dossier: string) => number, occupe?: (dossier: string) => string }} options `racine`, the
673
+ * libre?: (dossier: string) => number, occupe?: (dossier: string) => string,
674
+ * ticket?: string | null, sorte?: string }} options `racine`, the
425
675
  * root of the repository the measure plays in, which gives its rank (`rangDeLaMesure`; the
426
676
  * working directory by default); `borneMs`, the bound of the wait
427
677
  * (GRILLHOUSE_ATTENTE_MACHINE_MS, else ATTENTE_MACHINE_MS); `rappelMs`, the gap between two
428
678
  * lines that say the wait goes on (30 s); `libre`, the room free in a directory, in bytes
429
- * (`statfs`, at each turn); `occupe`, what holds it, counted when a line of the wait is written
679
+ * (`statfs`, at each turn); `occupe`, what holds it, counted when a line of the wait is written;
680
+ * `ticket` (null out of a ticket) and `sorte` (« Vérification » by default), who the measure is;
681
+ * an option left out is read from GRILLHOUSE_VERIFICATION_TICKET and GRILLHOUSE_VERIFICATION_SORTE,
682
+ * named beside the lock while it waits and while it holds it, with its project
430
683
  * @returns {T}
431
684
  * @throws {AttenteDeLaMachine} at the bound of the wait (code 75), or at once when an ancestor
432
685
  * holds the lock (code 1)
@@ -442,21 +695,28 @@ export function avecLaMachine(
442
695
  rappelMs = RAPPEL_MS,
443
696
  libre = libreDans,
444
697
  occupe = occupants,
698
+ ticket,
699
+ sorte,
445
700
  } = {}
446
701
  ) {
447
702
  if (paquetsDeLEnveloppe(env)) return mesure(env);
448
703
  const verrou = verrouDeMachine(env);
449
704
  if (env[VARIABLE_TENUE] && lire(verrou) === env[VARIABLE_TENUE]) return mesure(env);
450
- attendreDeLaPlace({ env, libre, occupe, dire, borneMs, rappelMs });
705
+ attendreDeLaPlace({ env, libre, occupe, dire, borneMs, rappelMs, racine, ticket, sorte });
706
+ const id = identite({ racine, env, ticket, sorte });
451
707
  mkdirSync(path.dirname(verrou), { recursive: true });
452
708
  const rang = rangDeLaMesure(racine);
453
709
  if (!(peutPrendre(verrou, rang) && prendreVerrou(verrou, { attendre: false }))) {
454
- const attendu = attendreLaMachine(verrou, { rang, dire, borneMs, rappelMs });
710
+ const attendu = attendreLaMachine(verrou, { id, rang, dire, borneMs, rappelMs });
455
711
  dire(`✓ verrou de la machine pris après ${Math.round(attendu / 1000)} s.`);
456
712
  }
713
+ let oublier = () => {};
457
714
  try {
458
- return mesure({ ...env, [VARIABLE_TENUE]: lire(verrou) ?? '' });
715
+ oublier = nommerLeDetenteur(verrou, id);
716
+ const { [VARIABLE_VERIFICATION_SORTE]: _s, [VARIABLE_VERIFICATION_TICKET]: _t, ...enfant } = env;
717
+ return mesure({ ...enfant, [VARIABLE_TENUE]: lire(verrou) ?? '' });
459
718
  } finally {
719
+ oublier();
460
720
  lacherVerrou(verrou);
461
721
  }
462
722
  }
@@ -83,9 +83,10 @@ partagée, en lecture seule pour toi, arrive construite : `npm test -- <un test
83
83
  joue sans la construire, et les journaux et le cache du lancement restent dans ta séance. Les
84
84
  gardes du cadre (frontières, consommateurs, index des interfaces, rapports d'API) tournent à côté
85
85
  des tests, dans la passe complète que l'intégration joue ; le relecteur les joue seules sur la
86
- copie ; leur refus nomme la commande qui corrige. Un lancement qui sort en 75, « à repasser », n'a vu que des échecs de durée sous charge
87
- (la pression CPU écrite à chaque échec) : tu le relances la machine au repos, et un échec au repos
88
- est un vrai rouge.
86
+ copie ; leur refus nomme la commande qui corrige. Le jour ne mesure aucun temps : un délai dépassé
87
+ est un rouge. Un lancement qui nomme une mesure de temps (un banc, un témoin de temps) ou un test
88
+ de nuit et sort en 75, « à repasser », n'a vu que des échecs de durée sous charge (la pression CPU
89
+ écrite à chaque échec) : la nuit le juge, et un échec au repos est un vrai rouge.
89
90
 
90
91
  **Un fichier s'écrit par l'outil Write ou Edit**, que ton verrou juge : jamais par un script
91
92
  (python3, sed -i, perl -i) ni par une redirection du shell, que ta séance refuse ; un fichier
@@ -93,6 +94,13 @@ temporaire va dans `$TMPDIR`. Les tests se lancent par `npm test -- <fichiers>`,
93
94
  de test directement. Ainsi chaque écriture passe par le verrou de ton rôle, et une substitution qui
94
95
  ne trouve pas son texte échoue au lieu de passer en silence.
95
96
 
97
+ **Cargo compile sans compilation incrémentale** (`CARGO_INCREMENTAL=0`, posé par le cadre, comme
98
+ la CI de Rust) : une copie compile une fois, et son `target/` reste petit. Pour déboguer, tu la
99
+ rallumes pour ta propre passe : `CARGO_INCREMENTAL=1 npm test -- <fichiers>` ; la valeur que tu
100
+ poses l'emporte. Un projet garde ses profils de compilation (`[profile.*]` de son `Cargo.toml`) :
101
+ un `incremental` qu'il y écrit reste le sien, et le cadre ne pose rien. Ainsi la place disque reste
102
+ bornée, et le débogage garde son outil.
103
+
96
104
  **Tu attends au premier plan ce que tu lances** : ta séance n'a aucune tâche de fond, et elle finit
97
105
  avec ta fiche. Ainsi le circuit reprend dès ta fiche rendue.
98
106
 
@@ -62,7 +62,8 @@ change, et ceux qu'il peut casser.
62
62
  responsable, que le circuit garde tels quels, les miens après eux. Pour changer ou retirer un
63
63
  critère écrit, je pose une question ouverte. Un critère sur le changelog s'écrit
64
64
  « le CHANGELOG le dit », sans le lier à un titre de section, que chaque sortie déplace : le
65
- relecteur juge l'entrée sur le lot, et aucun test ne la lit ;
65
+ relecteur juge l'entrée sur le lot, dans le CHANGELOG du paquet publié que le lot touche (dans
66
+ le dossier de ce paquet, donc dans son plan), et aucun test ne la lit ;
66
67
  - `paquets` : les paquets à toucher, le fournisseur d'abord, puis ses lecteurs, chacun comme le
67
68
  titre le nomme (le nom de son paquet, ou son chemin) ; le circuit les écrit au titre, et
68
69
  chaque séance du ticket n'écrit qu'eux ;