@roomi-fields/grillhouse 0.29.0 → 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 (222) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +739 -0
  3. package/bin/grillhouse.mjs +79 -18
  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/docs/agents/issue-tracker.md +1 -1
  7. package/cadre/templates/projet/package.json +2 -2
  8. package/charte.md +24 -0
  9. package/dist/temporal/acte.d.ts +24 -0
  10. package/dist/temporal/acte.js +139 -0
  11. package/dist/temporal/acte.js.map +1 -0
  12. package/dist/temporal/attributs.d.ts +6 -0
  13. package/dist/temporal/attributs.js +15 -0
  14. package/dist/temporal/attributs.js.map +1 -0
  15. package/dist/temporal/circuit/activites.d.ts +13 -0
  16. package/dist/temporal/circuit/activites.js +33 -0
  17. package/dist/temporal/circuit/activites.js.map +1 -0
  18. package/dist/temporal/circuit/client.d.ts +72 -0
  19. package/dist/temporal/circuit/client.js +247 -0
  20. package/dist/temporal/circuit/client.js.map +1 -0
  21. package/dist/temporal/circuit/commande.d.ts +2 -0
  22. package/dist/temporal/circuit/commande.js +238 -0
  23. package/dist/temporal/circuit/commande.js.map +1 -0
  24. package/dist/temporal/circuit/contrat.d.ts +305 -0
  25. package/dist/temporal/circuit/contrat.js +24 -0
  26. package/dist/temporal/circuit/contrat.js.map +1 -0
  27. package/dist/temporal/circuit/deroule.d.ts +3 -0
  28. package/dist/temporal/circuit/deroule.js +540 -0
  29. package/dist/temporal/circuit/deroule.js.map +1 -0
  30. package/dist/temporal/client.d.ts +47 -0
  31. package/dist/temporal/client.js +69 -0
  32. package/dist/temporal/client.js.map +1 -0
  33. package/dist/temporal/commande.d.ts +2 -0
  34. package/dist/temporal/commande.js +95 -0
  35. package/dist/temporal/commande.js.map +1 -0
  36. package/dist/temporal/deroules.d.ts +5 -0
  37. package/dist/temporal/deroules.js +10 -0
  38. package/dist/temporal/deroules.js.map +1 -0
  39. package/dist/temporal/etat.d.ts +33 -0
  40. package/dist/temporal/etat.js +59 -0
  41. package/dist/temporal/etat.js.map +1 -0
  42. package/dist/temporal/file/activites.d.ts +10 -0
  43. package/dist/temporal/file/activites.js +25 -0
  44. package/dist/temporal/file/activites.js.map +1 -0
  45. package/dist/temporal/file/client.d.ts +4 -0
  46. package/dist/temporal/file/client.js +6 -0
  47. package/dist/temporal/file/client.js.map +1 -0
  48. package/dist/temporal/file/contrat.d.ts +158 -0
  49. package/dist/temporal/file/contrat.js +14 -0
  50. package/dist/temporal/file/contrat.js.map +1 -0
  51. package/dist/temporal/file/deroule.d.ts +15 -0
  52. package/dist/temporal/file/deroule.js +235 -0
  53. package/dist/temporal/file/deroule.js.map +1 -0
  54. package/dist/temporal/installation.d.ts +124 -0
  55. package/dist/temporal/installation.js +408 -0
  56. package/dist/temporal/installation.js.map +1 -0
  57. package/dist/temporal/places/activites.d.ts +8 -0
  58. package/dist/temporal/places/activites.js +13 -0
  59. package/dist/temporal/places/activites.js.map +1 -0
  60. package/dist/temporal/places/client.d.ts +28 -0
  61. package/dist/temporal/places/client.js +64 -0
  62. package/dist/temporal/places/client.js.map +1 -0
  63. package/dist/temporal/places/contrat.d.ts +106 -0
  64. package/dist/temporal/places/contrat.js +21 -0
  65. package/dist/temporal/places/contrat.js.map +1 -0
  66. package/dist/temporal/places/deroule.d.ts +3 -0
  67. package/dist/temporal/places/deroule.js +198 -0
  68. package/dist/temporal/places/deroule.js.map +1 -0
  69. package/dist/temporal/sonde/activites.d.ts +6 -0
  70. package/dist/temporal/sonde/activites.js +52 -0
  71. package/dist/temporal/sonde/activites.js.map +1 -0
  72. package/dist/temporal/sonde/contrat.d.ts +35 -0
  73. package/dist/temporal/sonde/contrat.js +10 -0
  74. package/dist/temporal/sonde/contrat.js.map +1 -0
  75. package/dist/temporal/sonde/deroule.d.ts +3 -0
  76. package/dist/temporal/sonde/deroule.js +39 -0
  77. package/dist/temporal/sonde/deroule.js.map +1 -0
  78. package/dist/temporal/tickets/activites.d.ts +7 -0
  79. package/dist/temporal/tickets/activites.js +81 -0
  80. package/dist/temporal/tickets/activites.js.map +1 -0
  81. package/dist/temporal/tickets/client.d.ts +10 -0
  82. package/dist/temporal/tickets/client.js +31 -0
  83. package/dist/temporal/tickets/client.js.map +1 -0
  84. package/dist/temporal/tickets/contrat.d.ts +56 -0
  85. package/dist/temporal/tickets/contrat.js +13 -0
  86. package/dist/temporal/tickets/contrat.js.map +1 -0
  87. package/dist/temporal/tickets/deroule.d.ts +3 -0
  88. package/dist/temporal/tickets/deroule.js +94 -0
  89. package/dist/temporal/tickets/deroule.js.map +1 -0
  90. package/dist/temporal/travailleur.d.ts +2 -0
  91. package/dist/temporal/travailleur.js +69 -0
  92. package/dist/temporal/travailleur.js.map +1 -0
  93. package/docs/ARCHITECTURE.md +609 -80
  94. package/docs/CADRE.md +17 -0
  95. package/docs/INTERFACE.md +134 -42
  96. package/hooks/crochet.mjs +19 -2
  97. package/hooks/hooks.json +11 -0
  98. package/package.json +16 -4
  99. package/scripts/activites.mjs +2182 -0
  100. package/scripts/aiguillage.d.mts +37 -0
  101. package/scripts/aiguillage.mjs +7 -3
  102. package/scripts/avancement.mjs +128 -16
  103. package/scripts/bilan.mjs +37 -19
  104. package/scripts/cadre.mjs +11 -2
  105. package/scripts/circuit.mjs +881 -4059
  106. package/scripts/circuits-cles.d.mts +4 -0
  107. package/scripts/circuits-cles.mjs +21 -0
  108. package/scripts/circuits-du-serveur.mjs +105 -0
  109. package/scripts/codes-de-sortie.mjs +9 -0
  110. package/scripts/commandes-composees.mjs +45 -41
  111. package/scripts/commandes-du-path.d.mts +7 -0
  112. package/scripts/commandes-du-path.mjs +25 -0
  113. package/scripts/composition-des-langages.mjs +16 -12
  114. package/scripts/conformite.mjs +6 -13
  115. package/scripts/copies-finies.mjs +52 -47
  116. package/scripts/depart-du-ticket.d.mts +53 -0
  117. package/scripts/depart-du-ticket.mjs +124 -0
  118. package/scripts/dependances-internes.mjs +115 -0
  119. package/scripts/dernier-vert.mjs +7 -15
  120. package/scripts/donnees-cles.mjs +228 -0
  121. package/scripts/droits.mjs +11 -1
  122. package/scripts/effets.mjs +352 -0
  123. package/scripts/enveloppe/enveloppe.mjs +119 -8
  124. package/scripts/enveloppe/lancer.sh +14 -18
  125. package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
  126. package/scripts/enveloppe/travail-de-la-copie.mjs +5 -1
  127. package/scripts/etapes.mjs +5 -2
  128. package/scripts/faits-du-circuit.mjs +493 -0
  129. package/scripts/file-des-tickets.d.mts +21 -0
  130. package/scripts/file-des-tickets.mjs +58 -0
  131. package/scripts/flux-des-paquets.mjs +187 -0
  132. package/scripts/gardes-du-cadre.mjs +12 -2
  133. package/scripts/integration/file.mjs +475 -420
  134. package/scripts/integration/integrer.mjs +17 -19
  135. package/scripts/integration/rejeu.mjs +19 -4
  136. package/scripts/jointure.d.ts +145 -27
  137. package/scripts/langages/cargo/commandes.mjs +289 -109
  138. package/scripts/langages/cargo/composants.mjs +130 -34
  139. package/scripts/langages/cargo/exemples.mjs +12 -21
  140. package/scripts/langages/cargo/index.mjs +18 -8
  141. package/scripts/langages/cargo/sccache.mjs +8 -14
  142. package/scripts/langages/python/commandes.mjs +216 -100
  143. package/scripts/langages/python/composants.mjs +53 -21
  144. package/scripts/langages/python/exemples.mjs +6 -16
  145. package/scripts/langages/python/index.mjs +24 -8
  146. package/scripts/langages/python/lot.mjs +1 -36
  147. package/scripts/langages/typescript/construire.mjs +6 -163
  148. package/scripts/langages/typescript/exemples.mjs +3 -11
  149. package/scripts/langages/typescript/frontieres.mjs +1 -1
  150. package/scripts/langages/typescript/index.mjs +43 -61
  151. package/scripts/langages/typescript/interfaces-contre-code.mjs +4 -4
  152. package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
  153. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +31 -0
  154. package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
  155. package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
  156. package/scripts/langages/typescript/tailles-des-tests.mjs +40 -9
  157. package/scripts/langages/typescript/tests-de-nuit.mjs +12 -9
  158. package/scripts/langages/typescript/tests.mjs +17 -8
  159. package/scripts/langages/typescript/titres-de-tests.mjs +297 -0
  160. package/scripts/langages/typescript/turbo-des-paquets.mjs +183 -38
  161. package/scripts/langages/typescript/verdict.mjs +1 -1
  162. package/scripts/langages/typescript/verifier.mjs +31 -11
  163. package/scripts/langages/typescript/vitest-config/base.mjs +22 -1
  164. package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
  165. package/scripts/langages/typescript/vitest-config/cibles.mjs +36 -14
  166. package/scripts/langages/typescript/vitest-config/delais.mjs +54 -0
  167. package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
  168. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +100 -0
  169. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +49 -63
  170. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +3 -0
  171. package/scripts/langages/typescript/vitest.nuit.config.mjs +4 -0
  172. package/scripts/mesure/pression.mjs +3 -3
  173. package/scripts/mesure-de-la-machine.d.mts +21 -0
  174. package/scripts/mesure-de-la-machine.mjs +76 -0
  175. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +8 -2
  176. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +120 -0
  177. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
  178. package/scripts/migrations.mjs +5 -0
  179. package/scripts/nuit.sh +10 -3
  180. package/scripts/outils-cles.d.mts +24 -0
  181. package/scripts/outils-cles.mjs +0 -1
  182. package/scripts/paquet-npm.mjs +147 -0
  183. package/scripts/paquet.mjs +73 -4
  184. package/scripts/paquets.mjs +34 -6
  185. package/scripts/passe-de-la-machine.mjs +66 -0
  186. package/scripts/places-de-la-machine.mjs +360 -0
  187. package/scripts/places-du-serveur.mjs +170 -0
  188. package/scripts/prefixe-des-tickets.mjs +68 -0
  189. package/scripts/preparation.mjs +10 -3
  190. package/scripts/registre.mjs +3 -2
  191. package/scripts/regles-des-places.d.mts +36 -0
  192. package/scripts/regles-des-places.mjs +70 -0
  193. package/scripts/reponses-du-circuit.d.mts +6 -0
  194. package/scripts/reponses-du-circuit.mjs +28 -0
  195. package/scripts/resultats.mjs +7 -9
  196. package/scripts/retirer-les-copies-finies.mjs +25 -0
  197. package/scripts/sans-reponse.d.mts +4 -0
  198. package/scripts/sans-reponse.mjs +13 -0
  199. package/scripts/seances.mjs +918 -0
  200. package/scripts/services-du-noyau.mjs +26 -8
  201. package/scripts/session-start.sh +2 -2
  202. package/scripts/sortie.mjs +3 -3
  203. package/scripts/sous-commandes.mjs +38 -9
  204. package/scripts/style-a-l-ecriture.mjs +229 -0
  205. package/scripts/superviseur.mjs +122 -111
  206. package/scripts/tableau.mjs +148 -110
  207. package/scripts/taches-du-graphe.mjs +328 -0
  208. package/scripts/ticket-du-circuit.mjs +206 -0
  209. package/scripts/transitions.d.mts +148 -0
  210. package/scripts/transitions.mjs +901 -0
  211. package/scripts/verrou-de-fichier.mjs +2 -2
  212. package/scripts/verrou-de-machine.mjs +28 -13
  213. package/skills/explorateur/SKILL.md +2 -1
  214. package/skills/pitmaster/SKILL.md +17 -18
  215. package/skills/pitmaster/references/consigne-agent.md +5 -1
  216. package/skills/release/SKILL.md +3 -3
  217. package/skills/relecteur/SKILL.md +4 -2
  218. package/skills/testwriter/SKILL.md +36 -24
  219. package/scripts/demon.mjs +0 -251
  220. package/scripts/integration/file-attente.mjs +0 -61
  221. package/scripts/langages/cargo/touches.mjs +0 -93
  222. package/scripts/langages/typescript/script-des-tests.mjs +0 -6
@@ -0,0 +1,360 @@
1
+ // The places of the machine: a fixed number of places for the whole machine, whatever repository a
2
+ // session or a pass plays in, as the executors of Jenkins and the agents of Buildkite are a fixed
3
+ // number, and as the job server of GNU make shares its slots between every make of one build.
4
+ // Each session of an agent (testwriter, developer, reviewer…) takes a place at its start and gives
5
+ // it back at its end; a circuit that waits for a question, or between two sessions, holds none.
6
+ // Each pass takes one too (scripts/passe-de-la-machine.mjs: a targeted pass, and a heavy one
7
+ // besides the exclusive lock of the machine, scripts/verrou-de-machine.mjs). Witness: 2026-11-02,
8
+ // load 39 on 12 cores with five circuits at once (grillhouse-9kq).
9
+ //
10
+ // - The places live on the Temporal server, in the one workflow of the machine
11
+ // (src/temporal/places/deroule.ts), which grants them by the rule of scripts/regles-des-places.mjs
12
+ // (a free place under the ceiling, the turn of the rank of arrival, the admission at the load and
13
+ // the memory as `make -l`'s, the spacing of the starts) and frees the place of a process gone. A
14
+ // synchronous caller reads and takes them by ./places-du-serveur.mjs, in a process of its own.
15
+ // - The server is required on the workstation: one that does not answer stops the taking, named.
16
+ // In the CI (CI set) no place is taken. A trial machine (GRILLHOUSE_VERROU_MACHINE, the base
17
+ // configuration of the tests) takes its places on the server GRILLHOUSE_PLACES_D_ESSAI names,
18
+ // and none without it, so that no test takes a place of the user's machine.
19
+ // - A pass or a session that holds a place carries its mark to its children
20
+ // (GRILLHOUSE_PLACE_TENUE): a pass they play takes no second place. In the envelope of an agent
21
+ // (GRILLHOUSE_ENVELOPPE set, ./enveloppe/paquets-du-plan.mjs) no place is taken, as no lock is
22
+ // (./verrou-de-machine.mjs): the place of the session, taken out of it by the circuit, covers its
23
+ // commands, and the envelope passes on its mark; a number of process there means nothing on
24
+ // the machine.
25
+ // - The ceiling is PLAFOND_PAR_DEFAUT, 3, unless GRILLHOUSE_PLACES names another (a positive
26
+ // integer; any other value is refused by the name of the variable); two starts are spaced by
27
+ // ESPACEMENT_MS (GRILLHOUSE_ESPACEMENT_MS names another, in ms). The workflow reads both when it
28
+ // starts.
29
+ // - A wait says its reason (place, rank, load, memory or spacing) when it begins and every 30 s,
30
+ // and is bounded as the wait for the lock of the machine, GRILLHOUSE_ATTENTE_MACHINE_MS: at the
31
+ // bound, « à repasser » (75), the request withdrawn.
32
+ // - A wait keeps the rank of its arrival, as the queue of a merge train keeps its order: the rank
33
+ // is drawn when the circuit is launched (`prendreUnRang`) and kept from one session to the next.
34
+ // - The number of workers of the tests of a session is `travailleursDe`: max(1, cores ÷ places),
35
+ // passed to the tool of each language (GRILLHOUSE_TRAVAILLEURS).
36
+ import { spawnSync } from 'node:child_process';
37
+ import { availableParallelism } from 'node:os';
38
+ import path from 'node:path';
39
+ import { departDe } from './mesure/base-de-passe.mjs';
40
+ import { A_REPASSER } from './codes-de-sortie.mjs';
41
+ import { paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
42
+ import { mesureDeLaMachine } from './mesure-de-la-machine.mjs';
43
+ import { AttenteDeLaMachine, avecLaMachine, borneDe } from './verrou-de-machine.mjs';
44
+
45
+ export const VARIABLE_PLACES = 'GRILLHOUSE_PLACES';
46
+ export const VARIABLE_ESPACEMENT = 'GRILLHOUSE_ESPACEMENT_MS';
47
+ export const VARIABLE_TRAVAILLEURS = 'GRILLHOUSE_TRAVAILLEURS';
48
+ /** The mark of a place held, which the children of its holder inherit. */
49
+ export const VARIABLE_TENUE = 'GRILLHOUSE_PLACE_TENUE';
50
+ // The server of the places of a trial machine.
51
+ const VARIABLE_ESSAI = 'GRILLHOUSE_PLACES_D_ESSAI';
52
+
53
+ /** The ceiling of the places of the machine when GRILLHOUSE_PLACES names none. */
54
+ export const PLAFOND_PAR_DEFAUT = 3;
55
+ /** The gap between two starts when GRILLHOUSE_ESPACEMENT_MS names none, in ms. */
56
+ export const ESPACEMENT_MS = 10_000;
57
+ const RAPPEL_MS = 30_000;
58
+ // The reading and the taking of the places on the server, in a process of their own.
59
+ const PONT = path.join(import.meta.dirname, 'places-du-serveur.mjs');
60
+
61
+ /**
62
+ * The ceiling of the places under <env>.
63
+ * @param {Record<string, string | undefined>} [env]
64
+ * @returns {number}
65
+ * @throws {Error} naming GRILLHOUSE_PLACES when its value is not a positive integer
66
+ */
67
+ export function plafondDe(env = process.env) {
68
+ const v = env[VARIABLE_PLACES];
69
+ if (v === undefined || v === '') return PLAFOND_PAR_DEFAUT;
70
+ if (!/^[1-9]\d*$/.test(v))
71
+ throw new Error(
72
+ `${VARIABLE_PLACES} vaut « ${v} » : un entier positif est attendu (3 par défaut).`
73
+ );
74
+ return Number(v);
75
+ }
76
+
77
+ /**
78
+ * The gap between two starts under <env>, in ms.
79
+ * @param {Record<string, string | undefined>} [env]
80
+ * @returns {number}
81
+ * @throws {Error} naming GRILLHOUSE_ESPACEMENT_MS when its value is not a number of ms
82
+ */
83
+ export function espacementDe(env = process.env) {
84
+ const v = env[VARIABLE_ESPACEMENT];
85
+ if (v === undefined || v === '') return ESPACEMENT_MS;
86
+ if (!/^\d+$/.test(v))
87
+ throw new Error(
88
+ `${VARIABLE_ESPACEMENT} vaut « ${v} » : un nombre de millisecondes est attendu.`
89
+ );
90
+ return Number(v);
91
+ }
92
+
93
+ /**
94
+ * The number of workers of the tests of a session: max(1, cores ÷ places), the division whole.
95
+ * @param {{ coeurs?: number, places?: number, env?: Record<string, string | undefined> }} [o]
96
+ * @returns {number}
97
+ */
98
+ export function travailleursDe({
99
+ coeurs = availableParallelism(),
100
+ places,
101
+ env = process.env,
102
+ } = {}) {
103
+ return Math.max(1, Math.floor(coeurs / (places ?? plafondDe(env))));
104
+ }
105
+
106
+ /**
107
+ * The workers a session of an agent plays its tests on, as its environment gives them
108
+ * (GRILLHOUSE_TRAVAILLEURS, set by the envelope): what the module of each language passes to its
109
+ * tool. Null without the variable (a heavy pass): the tool keeps every core.
110
+ * @param {Record<string, string | undefined>} [env]
111
+ * @returns {number | null}
112
+ * @throws {Error} naming GRILLHOUSE_TRAVAILLEURS when its value is not a positive integer
113
+ */
114
+ export function travailleursDeLaSeance(env = process.env) {
115
+ const v = env[VARIABLE_TRAVAILLEURS];
116
+ if (v === undefined || v === '') return null;
117
+ if (!/^[1-9]\d*$/.test(v))
118
+ throw new Error(`${VARIABLE_TRAVAILLEURS} vaut « ${v} » : un entier positif est attendu.`);
119
+ return Number(v);
120
+ }
121
+
122
+ /**
123
+ * The environment the places are read under on <env>: the address of their server
124
+ * (TEMPORAL_ADDRESS), or null where no place is taken (the CI, the envelope of an agent, a trial
125
+ * machine without its server).
126
+ * @param {Record<string, string | undefined>} env
127
+ * @returns {Record<string, string | undefined> | null}
128
+ */
129
+ function surLeServeur(env) {
130
+ if (env.CI || paquetsDeLEnveloppe(env)) return null;
131
+ if (env.GRILLHOUSE_VERROU_MACHINE) {
132
+ return env[VARIABLE_ESSAI] ? { ...env, TEMPORAL_ADDRESS: env[VARIABLE_ESSAI] } : null;
133
+ }
134
+ return env;
135
+ }
136
+
137
+ // The mode <args> of ./places-du-serveur.mjs under <env>, waited for within <ms>: its exit code,
138
+ // its lines in JSON; a server that does not answer, or a call that fails, stops the measure as a
139
+ // wait of the machine does (`AttenteDeLaMachine`, code 1), its reason named.
140
+ function auServeur(env, args, ms = 30_000) {
141
+ const r = spawnSync(process.execPath, [PONT, ...args], {
142
+ env,
143
+ encoding: 'utf8',
144
+ timeout: ms,
145
+ maxBuffer: 16 * 1024 * 1024,
146
+ });
147
+ const lignes = (r.stdout ?? '')
148
+ .split('\n')
149
+ .filter(Boolean)
150
+ .map(l => JSON.parse(l));
151
+ if (r.status !== 0 && r.status !== A_REPASSER) {
152
+ throw new AttenteDeLaMachine(
153
+ `✗ ${(r.stderr || r.error?.message || `les places de la machine ne se lisent pas, code ${r.status}`).trim()}`,
154
+ 1
155
+ );
156
+ }
157
+ return { code: r.status, lignes };
158
+ }
159
+
160
+ /**
161
+ * Draws the next rank of arrival of the machine: a circuit draws it when it is launched and keeps
162
+ * it from one session to the next, so a wait for a place keeps its place in the line. Null where no
163
+ * place is taken.
164
+ * @param {{ env?: Record<string, string | undefined> }} [o]
165
+ * @returns {number | null}
166
+ */
167
+ export function prendreUnRang({ env = process.env } = {}) {
168
+ const e = surLeServeur(env);
169
+ return e ? auServeur(e, ['rang']).lignes[0] : null;
170
+ }
171
+
172
+ /**
173
+ * Takes a place of the machine, waiting for one, saying why it waits (`dire`), and returns the
174
+ * place. Where no place is taken, or under a place already held (GRILLHOUSE_PLACE_TENUE), the
175
+ * place returned holds nothing.
176
+ * @param {{ env?: Record<string, string | undefined>, ticket?: string | null, rang?: number,
177
+ * pid?: number, depart?: string | null, borneMs?: number, rappelMs?: number,
178
+ * dire?: (l: string) => void }} [o] `pid` and `depart` name the process of the session (the
179
+ * taking process by default); `rang` the rank of the arrival of the circuit (drawn by the server
180
+ * when absent)
181
+ * @returns {{ id: string | null, rang: number | null, env: Record<string, string | undefined>,
182
+ * rendre: () => void, rattacher: (p: { pid: number, depart: string | null }) => void }} `env`,
183
+ * the environment of its holder's children, with the mark of the place; `rattacher` names the
184
+ * process of the session once launched (the taking process held the place until then)
185
+ * @throws {AttenteDeLaMachine} at the bound of the wait (code 75), its reason named
186
+ */
187
+ export function prendreUnePlace({
188
+ env = process.env,
189
+ ticket = null,
190
+ rang,
191
+ pid = process.pid,
192
+ depart,
193
+ borneMs = borneDe(env),
194
+ rappelMs = RAPPEL_MS,
195
+ dire = l => process.stdout.write(`${l}\n`),
196
+ } = {}) {
197
+ const e = env[VARIABLE_TENUE] ? null : surLeServeur(env);
198
+ if (!e) {
199
+ return { id: null, rang: rang ?? null, env, rendre: () => {}, rattacher: () => {} };
200
+ }
201
+ const demande = {
202
+ pid,
203
+ depart: depart === undefined ? departDe(pid) : depart,
204
+ ticket,
205
+ ...(rang === undefined || rang === null ? {} : { rang }),
206
+ borneMs,
207
+ rappelMs,
208
+ };
209
+ const { code, lignes } = auServeur(e, ['prendre', JSON.stringify(demande)], borneMs + 60_000);
210
+ for (const l of lignes) {
211
+ if (l.dire) dire(l.dire);
212
+ }
213
+ if (code === A_REPASSER) {
214
+ throw new AttenteDeLaMachine(lignes.at(-1)?.dire ?? 'attente de place bornée', A_REPASSER);
215
+ }
216
+ const place = lignes.find(l => l.id);
217
+ return {
218
+ id: place.id,
219
+ rang: place.rang,
220
+ env: { ...env, [VARIABLE_TENUE]: place.id },
221
+ // A place that does not go back is said, and the pass keeps its code: the workflow of the
222
+ // machine frees the place of a process gone.
223
+ rendre: () => {
224
+ try {
225
+ auServeur(e, ['rendre', place.id]);
226
+ } catch (x) {
227
+ if (!(x instanceof AttenteDeLaMachine)) throw x;
228
+ dire(
229
+ `⚠ la place ${place.id} ne se rend pas (${x.message}) : le déroulé de la machine la libère à la fin de son processus.`
230
+ );
231
+ }
232
+ },
233
+ rattacher: p => {
234
+ auServeur(e, ['rattacher', place.id, String(p.pid), String(p.depart)]);
235
+ },
236
+ };
237
+ }
238
+
239
+ /**
240
+ * Plays <seance> holding a place, given back at its end, whether it returns, throws or (for an
241
+ * asynchronous one) settles; <seance> receives the place, its `env` the environment of its
242
+ * children.
243
+ * @param {(place: ReturnType<typeof prendreUnePlace>) => T} seance
244
+ * @param {Parameters<typeof prendreUnePlace>[0]} [options]
245
+ * @returns {T}
246
+ * @template T
247
+ */
248
+ export function avecUnePlace(seance, options) {
249
+ const place = prendreUnePlace(options);
250
+ let r;
251
+ try {
252
+ r = seance(place);
253
+ } catch (e) {
254
+ place.rendre();
255
+ throw e;
256
+ }
257
+ if (r && typeof r.then === 'function') {
258
+ return r.then(
259
+ v => {
260
+ place.rendre();
261
+ return v;
262
+ },
263
+ e => {
264
+ place.rendre();
265
+ throw e;
266
+ }
267
+ );
268
+ }
269
+ place.rendre();
270
+ return r;
271
+ }
272
+
273
+ /**
274
+ * Plays the pass <passe> on a place of the machine, as a command a person or an agent runs (`npm
275
+ * test`): its exit code, or, a wait that stops (its bound, 75; a server that does not answer, 1),
276
+ * its reason said and its code. <passe> receives the environment of its children, with the mark
277
+ * of the place.
278
+ * @param {(env: Record<string, string | undefined>) => number} passe
279
+ * @param {{ env?: Record<string, string | undefined>, dire?: (l: string) => void }} [o]
280
+ * @returns {number}
281
+ */
282
+ export function surUnePlace(
283
+ passe,
284
+ { env = process.env, dire = l => process.stderr.write(`${l}\n`) } = {}
285
+ ) {
286
+ try {
287
+ return avecUnePlace(place => passe(place.env), { env, dire });
288
+ } catch (e) {
289
+ if (!(e instanceof AttenteDeLaMachine)) throw e;
290
+ dire(e.message);
291
+ return e.code;
292
+ }
293
+ }
294
+
295
+ /**
296
+ * Plays the heavy measure <mesure> on a place of the machine, then under its exclusive lock
297
+ * (`avecLaMachine` of ./verrou-de-machine.mjs), and returns what it returns: the place first, so
298
+ * that a pass that waits for its place holds no lock. <mesure> receives the environment of its
299
+ * children, which carries the marks of both.
300
+ * @param {(env: Record<string, string | undefined>) => T} mesure
301
+ * @param {Parameters<typeof avecLaMachine>[1] & { rang?: number }} [options] those of the lock,
302
+ * whose `env`, `ticket`, `dire`, `borneMs` and `rappelMs` the place reads too, and `rang`, the
303
+ * rank of the circuit of the pass
304
+ * @returns {T}
305
+ * @template T
306
+ */
307
+ export function avecLaMachineEtUnePlace(mesure, options = {}) {
308
+ const { env = process.env, ticket, rang, dire, borneMs, rappelMs, ...verrou } = options;
309
+ return avecUnePlace(
310
+ place =>
311
+ avecLaMachine(mesure, {
312
+ ...verrou,
313
+ env: place.env,
314
+ ...(ticket === undefined ? {} : { ticket }),
315
+ ...(dire ? { dire } : {}),
316
+ ...(borneMs === undefined ? {} : { borneMs }),
317
+ ...(rappelMs === undefined ? {} : { rappelMs }),
318
+ }),
319
+ {
320
+ env,
321
+ ticket: ticket ?? null,
322
+ ...(rang === undefined ? {} : { rang }),
323
+ ...(dire ? { dire } : {}),
324
+ ...(borneMs === undefined ? {} : { borneMs }),
325
+ ...(rappelMs === undefined ? {} : { rappelMs }),
326
+ }
327
+ );
328
+ }
329
+
330
+ /**
331
+ * The places taken and the waits of the machine under <env>, as the server holds them: `{ plafond,
332
+ * prises, attentes }`, `prises` `{ id, pid, depart, ticket, rang, depuis }`, `attentes` in the
333
+ * order of arrival `{ id, pid, ticket, rang, raison, depuis }`; none where no place is taken.
334
+ * @param {{ env?: Record<string, string | undefined> }} [o]
335
+ */
336
+ export function lirePlaces({ env = process.env } = {}) {
337
+ const e = surLeServeur(env);
338
+ return e
339
+ ? auServeur(e, ['lire']).lignes[0]
340
+ : { plafond: plafondDe(env), prises: [], attentes: [] };
341
+ }
342
+
343
+ /**
344
+ * The places as the board shows them: taken and ceiling, the load over one minute and the cores,
345
+ * the free memory in whole GB, and the waits (ticket, since when) in the order of arrival.
346
+ * @param {{ env?: Record<string, string | undefined>, mesurer?: () => { coeurs: number,
347
+ * charge: number, memoireLibre: number } }} [o]
348
+ */
349
+ export function etatDesPlaces({ env = process.env, mesurer = mesureDeLaMachine } = {}) {
350
+ const { plafond, prises, attentes } = lirePlaces({ env });
351
+ const m = mesurer();
352
+ return {
353
+ prises: prises.length,
354
+ plafond,
355
+ charge: Math.round(m.charge * 10) / 10,
356
+ coeurs: m.coeurs,
357
+ memoireGo: Math.floor(m.memoireLibre / 1024 ** 3),
358
+ attentes: attentes.map(a => ({ ticket: a.ticket, depuis: a.depuis })),
359
+ };
360
+ }
@@ -0,0 +1,170 @@
1
+ // The places of the machine read and taken on the Temporal server, in a process of its own, so
2
+ // that a synchronous caller (scripts/places-de-la-machine.mjs) waits for them as it waits for a
3
+ // lock: the workflow of the machine (src/temporal/places/deroule.ts) holds them, its client
4
+ // (src/temporal/places/client.ts) speaks to it.
5
+ //
6
+ // node places-du-serveur.mjs rang
7
+ // node places-du-serveur.mjs prendre <demande>
8
+ // node places-du-serveur.mjs rendre <id>
9
+ // node places-du-serveur.mjs rattacher <id> <pid> <depart>
10
+ // node places-du-serveur.mjs lire
11
+ //
12
+ // - Each mode first starts the workflow of the machine when none runs (`demarrerLesPlaces`, on the
13
+ // task queue of the worker of the machine), its ceiling GRILLHOUSE_PLACES and its spacing
14
+ // GRILLHOUSE_ESPACEMENT_MS (scripts/places-de-la-machine.mjs).
15
+ // - `rang` writes the next rank of arrival of the machine, which a circuit draws at its launch.
16
+ // - `prendre` asks for a place for <demande> (JSON: `{ pid, depart, ticket, rang, borneMs,
17
+ // rappelMs }`, the process that holds it), then waits for it: each line it says, at the start of
18
+ // a wait and every <rappelMs>, is one JSON line `{ dire }` on the standard output, then the place
19
+ // given, `{ id, rang }`. At the bound <borneMs>, the request is withdrawn, its line said, exit 75.
20
+ // - `rendre` gives the place <id> back (or withdraws its request), `rattacher` names the process
21
+ // that holds it; `lire` writes the places as the board reads them (`{ plafond, prises, attentes
22
+ // }`).
23
+ // - A server that does not answer within 5 s, or a client not built, is said on the error stream,
24
+ // exit 1; a malformed call, exit 2.
25
+ import { randomUUID } from 'node:crypto';
26
+ import { existsSync } from 'node:fs';
27
+ import path from 'node:path';
28
+ import { pathToFileURL } from 'node:url';
29
+ import { A_REPASSER } from './codes-de-sortie.mjs';
30
+ import { duree } from './regles-des-places.mjs';
31
+
32
+ const DIST = path.join(import.meta.dirname, '..', 'dist', 'temporal');
33
+ // How long a call waits for the server to answer.
34
+ const DELAI_MS = 5_000;
35
+ // How often a wait reads its request again.
36
+ const VEILLE_MS = 250;
37
+
38
+ // The ceiling and the spacing of the machine under <env>, as scripts/places-de-la-machine.mjs reads
39
+ // them; the workflow's veille, a second.
40
+ const entreeDe = async env => {
41
+ const { plafondDe, espacementDe } = await import('./places-de-la-machine.mjs');
42
+ return { plafond: plafondDe(env), espacementMs: espacementDe(env), veilleMs: 1_000 };
43
+ };
44
+
45
+ const MODES = { rang: 0, prendre: 1, rendre: 1, rattacher: 3, lire: 0 };
46
+ const ecrire = o => process.stdout.write(`${JSON.stringify(o)}\n`);
47
+
48
+ // The wait of the request <id> for its place, under the handle <h> of the workflow of the
49
+ // machine, its lines said: 0 once given, 75 at the bound <borneMs>, the request withdrawn.
50
+ async function attendreLaPlace(c, places, { h, id, rang, borneMs, rappelMs, sous, LA_DEMANDE }) {
51
+ const debut = Date.now();
52
+ let dit = null;
53
+ for (;;) {
54
+ const e = await sous(() => h.query(LA_DEMANDE, id));
55
+ if (e.etat === 'donnee') {
56
+ if (dit !== null) {
57
+ ecrire({ dire: `✓ place prise après ${duree(Date.now() - debut)}.` });
58
+ }
59
+ ecrire({ id, rang });
60
+ return 0;
61
+ }
62
+ if (e.etat === 'inconnue') {
63
+ throw new Error(`la demande de place ${id} n'est plus : retirée, ou son processus a disparu`);
64
+ }
65
+ const t = Date.now();
66
+ if (t - debut >= borneMs) {
67
+ await sous(() => places.rendreLaPlace(c.client, id));
68
+ ecrire({
69
+ dire: `⏱ attente de place bornée à ${duree(borneMs)} (GRILLHOUSE_ATTENTE_MACHINE_MS) : ${e.raison} ; à repasser (code ${A_REPASSER}).`,
70
+ });
71
+ return A_REPASSER;
72
+ }
73
+ if (dit === null) {
74
+ ecrire({ dire: `⏳ attente d'une place : ${e.raison} ; ${duree(borneMs)} au plus.` });
75
+ dit = t;
76
+ } else if (t - dit >= rappelMs) {
77
+ ecrire({ dire: `⏳ attente d'une place depuis ${duree(t - debut)} : ${e.raison}.` });
78
+ dit = t;
79
+ }
80
+ await new Promise(r => setTimeout(r, VEILLE_MS));
81
+ }
82
+ }
83
+
84
+ // The call <mode> with <args>: its exit code.
85
+ async function principal(mode, args) {
86
+ if (!Object.hasOwn(MODES, mode ?? '') || args.length !== MODES[mode]) {
87
+ process.stderr.write(
88
+ 'usage : places-du-serveur.mjs rang | prendre <demande> | rendre <id> | rattacher <id> <pid> <depart> | lire\n'
89
+ );
90
+ return 2;
91
+ }
92
+ if (!existsSync(path.join(DIST, 'places', 'client.js'))) {
93
+ process.stderr.write(
94
+ `le client Temporal n'est pas construit (${DIST}) : la construction du paquet le pose, \`npm run build --workspace @roomi-fields/grillhouse\`.\n`
95
+ );
96
+ return 1;
97
+ }
98
+ const depuisDist = (...p) => import(pathToFileURL(path.join(DIST, ...p)).href);
99
+ const { ouvrirLeClient } = await depuisDist('client.js');
100
+ const { FILE_DE_LA_MACHINE } = await depuisDist('installation.js');
101
+ const { ID_DES_PLACES, LA_DEMANDE, PRENDRE } = await depuisDist('places', 'contrat.js');
102
+ const places = await depuisDist('places', 'client.js');
103
+ const c = ouvrirLeClient();
104
+ const sous = f => c.client.connection.withDeadline(Date.now() + DELAI_MS, f);
105
+ try {
106
+ try {
107
+ await sous(async () =>
108
+ places.demarrerLesPlaces(c.client, await entreeDe(process.env), {
109
+ file: FILE_DE_LA_MACHINE,
110
+ })
111
+ );
112
+ } catch (x) {
113
+ if (x?.name !== 'WorkflowExecutionAlreadyStartedError') {
114
+ throw x;
115
+ }
116
+ }
117
+ if (mode === 'rang') {
118
+ ecrire(await sous(() => places.tirerUnRangParTemporal(c.client)));
119
+ } else if (mode === 'rendre') {
120
+ await sous(() => places.rendreLaPlace(c.client, args[0]));
121
+ } else if (mode === 'rattacher') {
122
+ const [id, pid, depart] = args;
123
+ await sous(() =>
124
+ places.rattacherLaPlace(c.client, id, {
125
+ pid: Number(pid),
126
+ depart: depart === 'null' ? null : depart,
127
+ })
128
+ );
129
+ } else if (mode === 'lire') {
130
+ ecrire(await sous(() => places.lireLesPlaces(c.client)));
131
+ } else {
132
+ const { borneMs, rappelMs, ...demande } = JSON.parse(args[0]);
133
+ const h = c.client.workflow.getHandle(ID_DES_PLACES);
134
+ const id = randomUUID();
135
+ const { rang } = await sous(() =>
136
+ h.executeUpdate(PRENDRE, { args: [{ ...demande, id }], updateId: id })
137
+ );
138
+ return await attendreLaPlace(c, places, {
139
+ h,
140
+ id,
141
+ rang,
142
+ borneMs,
143
+ rappelMs,
144
+ sous,
145
+ LA_DEMANDE,
146
+ });
147
+ }
148
+ return 0;
149
+ } catch (x) {
150
+ process.stderr.write(
151
+ `les places de la machine ne se lisent pas sur le serveur Temporal (${c.adresse}) : ${x?.message ?? x}${x?.cause?.message ? ` (${x.cause.message})` : ''} ; le serveur est requis sur le poste (\`npx grillhouse temporal installer\`).\n`
152
+ );
153
+ return 1;
154
+ } finally {
155
+ await c.fermer();
156
+ }
157
+ }
158
+
159
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
160
+ const [mode, ...args] = process.argv.slice(2);
161
+ principal(mode, args).then(
162
+ code => {
163
+ process.exitCode = code;
164
+ },
165
+ x => {
166
+ process.stderr.write(`${x?.stack ?? x}\n`);
167
+ process.exitCode = 1;
168
+ }
169
+ );
170
+ }
@@ -0,0 +1,68 @@
1
+ // The prefix of the tickets of a project, in the key `issue-prefix` of its committed
2
+ // `.beads/config.yaml`, the one place a CI reads it (it has no `bd`): the guard of the titles of the
3
+ // tests reads it there (scripts/langages/typescript/titres-de-tests.mjs). `bd init` writes the key
4
+ // commented out and keeps the prefix in its database, so the frame writes the key itself, by one
5
+ // function: the preparation of a new project (./preparation.mjs) and the update of a project
6
+ // (the migration 0.30.0 « préfixe des tickets »).
7
+ import { readFileSync, writeFileSync } from 'node:fs';
8
+ import path from 'node:path';
9
+
10
+ export const CONFIG_BEADS = '.beads/config.yaml';
11
+
12
+ // The key `issue-prefix`, not commented out, and one written empty.
13
+ const CLE = /^issue-prefix:\s*(?:"([^"]*)"|'([^']*)'|([^\s#]+))\s*(?:#.*)?$/m;
14
+ const CLE_VIDE = /^issue-prefix:\s*(?:""|'')?\s*(?:#.*)?$/m;
15
+ // The value of the key in <texte>, '' without one.
16
+ const valeurDe = texte => {
17
+ const m = CLE.exec(texte);
18
+ return m ? (m[1] ?? m[2] ?? m[3] ?? '') : '';
19
+ };
20
+
21
+ /**
22
+ * The prefix of the tickets of the repository at <racine>, read from the key `issue-prefix` of its
23
+ * committed file of Beads, never from `bd` (absent in a CI). Throws an error that names the file or
24
+ * the key when it is missing, so that nothing is counted by halves.
25
+ * @param {string} racine
26
+ * @returns {string}
27
+ */
28
+ export function prefixe(racine) {
29
+ let texte;
30
+ try {
31
+ texte = readFileSync(path.join(racine, CONFIG_BEADS), 'utf8');
32
+ } catch {
33
+ throw new Error(
34
+ `${CONFIG_BEADS} manque : le préfixe des tickets s'y lit (clé \`issue-prefix\`), jamais par bd.`
35
+ );
36
+ }
37
+ const valeur = valeurDe(texte);
38
+ if (!valeur) {
39
+ throw new Error(
40
+ `${CONFIG_BEADS} n'a pas la clé \`issue-prefix\` (une ligne commentée n'est pas la clé) : le préfixe des tickets s'y lit.`
41
+ );
42
+ }
43
+ return valeur;
44
+ }
45
+
46
+ /**
47
+ * Writes the key `issue-prefix: "<valeur>"` in the `.beads/config.yaml` of the repository at
48
+ * <racine>, which exists: a key written empty is replaced, an absent one added at the end; a key
49
+ * that already holds a value is left. Returns the line written, or null when nothing was written.
50
+ * @param {string} racine
51
+ * @param {string} valeur
52
+ * @returns {string | null}
53
+ */
54
+ export function ecrireLePrefixe(racine, valeur) {
55
+ const f = path.join(racine, CONFIG_BEADS);
56
+ const texte = readFileSync(f, 'utf8');
57
+ if (valeurDe(texte)) {
58
+ return null;
59
+ }
60
+ const ligne = `issue-prefix: "${valeur}"`;
61
+ writeFileSync(
62
+ f,
63
+ CLE_VIDE.test(texte)
64
+ ? texte.replace(CLE_VIDE, ligne)
65
+ : `${texte}${texte.endsWith('\n') || texte === '' ? '' : '\n'}${ligne}\n`
66
+ );
67
+ return ligne;
68
+ }
@@ -4,7 +4,10 @@
4
4
  // - git: the directory becomes a repository when it is none.
5
5
  // - Beads, the ticket store the skills work from: the tool (`bd`, installed by
6
6
  // `npm install -g @beads/bd` when absent), then the store, under the prefix given, else the
7
- // store's own, else the directory's name; the repository's `beads.role` is `maintainer`.
7
+ // store's own, else the directory's name; the repository's `beads.role` is `maintainer`. That
8
+ // prefix is written in the key `issue-prefix` of `.beads/config.yaml`, which `bd init` leaves
9
+ // commented out and the guard of the titles of the tests reads (`ecrireLePrefixe` of
10
+ // ./prefixe-des-tickets.mjs, as the update writes it).
8
11
  // - CodeGraph, the code knowledge graph the skills query (the MCP server of `.mcp.json`): the tool
9
12
  // (installed by `npm install -g @colbymchenry/codegraph` when absent) and the index of the code.
10
13
  // - The folder git reads the hooks from: `core.hooksPath` set to Beads' (`.beads/hooks`) when the
@@ -17,7 +20,9 @@
17
20
  import { execFileSync, spawnSync } from 'node:child_process';
18
21
  import { existsSync } from 'node:fs';
19
22
  import path from 'node:path';
23
+ import { trouverDansLePath } from './commandes-du-path.mjs';
20
24
  import { installerGreffons } from './greffons.mjs';
25
+ import { ecrireLePrefixe } from './prefixe-des-tickets.mjs';
21
26
 
22
27
  // The prefix of the tickets: the one given, else the store's own, else the directory's name.
23
28
  function prefixeDe(projet, donne) {
@@ -40,7 +45,7 @@ function prefixeDe(projet, donne) {
40
45
  // Runs <commande> in <projet>, its output this process's; throws on a failure.
41
46
  const lancer = (projet, commande, args) =>
42
47
  execFileSync(commande, args, { cwd: projet, stdio: 'inherit' });
43
- const present = commande => spawnSync('sh', ['-c', `command -v ${commande}`]).status === 0;
48
+ const present = commande => trouverDansLePath(commande) !== null;
44
49
 
45
50
  // A global tool of the preparation, installed by npm when absent.
46
51
  function outil(commande, paquet) {
@@ -65,6 +70,7 @@ export function preparer(projet, prefixe) {
65
70
  outil('bd', '@beads/bd');
66
71
  outil('codegraph', '@colbymchenry/codegraph');
67
72
  if (!existsSync(path.join(projet, '.codegraph'))) lancer(projet, 'codegraph', ['init', projet]);
73
+ const lePrefixe = prefixeDe(projet, prefixe);
68
74
  lancer(projet, 'bd', [
69
75
  'init',
70
76
  '--init-if-missing',
@@ -72,8 +78,9 @@ export function preparer(projet, prefixe) {
72
78
  '--skip-agents',
73
79
  '--quiet',
74
80
  '--prefix',
75
- prefixeDe(projet, prefixe),
81
+ lePrefixe,
76
82
  ]);
83
+ ecrireLePrefixe(projet, lePrefixe);
77
84
  lancer(projet, 'git', ['config', 'beads.role', 'maintainer']);
78
85
  const r = spawnSync('git', ['-C', projet, 'config', 'core.hooksPath'], { encoding: 'utf8' });
79
86
  if ((r.stdout ?? '').trim() === '') {
@@ -225,7 +225,8 @@ export function aRattraper(racine, home, connus, maintenant = Date.now()) {
225
225
  // time of one read and one append.
226
226
  const PERIME = 30_000;
227
227
 
228
- // Appends `l` to the register unless it already holds the line of this agent's end. Returns whether
228
+ // Appends `l` to the register unless it already holds the line of this agent's end, or the line of
229
+ // its key (`cle`, a gesture of an act of the circuit under Temporal played again). Returns whether
229
230
  // it wrote. The check and the append happen under the register's lock.
230
231
  export function ecrire(l) {
231
232
  mkdirSync(path.dirname(REGISTRE), { recursive: true });
@@ -236,7 +237,7 @@ export function ecrire(l) {
236
237
  for (const x of deja.split('\n')) {
237
238
  try {
238
239
  const e = JSON.parse(x);
239
- if (e.agent === l.agent && e.fin === l.fin) {
240
+ if ((l.cle && e.cle === l.cle) || (e.agent === l.agent && e.fin === l.fin)) {
240
241
  return false;
241
242
  }
242
243
  } catch {