@roomi-fields/grillhouse 0.28.2 → 0.29.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.
- package/.claude-plugin/plugin.json +1 -1
- package/bin/grillhouse.mjs +55 -14
- package/cadre/templates/projet/CLAUDE.md +1 -1
- package/cadre/templates/projet/README.md +11 -11
- package/cadre/templates/projet/_gitignore +2 -5
- package/charte.md +24 -3
- package/docs/ARCHITECTURE.md +279 -31
- package/docs/INTERFACE.md +59 -11
- package/package.json +1 -1
- package/scripts/aiguillage.mjs +324 -0
- package/scripts/avancement.mjs +33 -50
- package/scripts/circuit.mjs +558 -146
- package/scripts/composition-des-langages.mjs +16 -1
- package/scripts/conformite.mjs +16 -0
- package/scripts/copies-finies.mjs +181 -29
- package/scripts/demon.mjs +134 -21
- package/scripts/enveloppe/enveloppe.mjs +8 -5
- package/scripts/enveloppe/lancer.sh +24 -15
- package/scripts/enveloppe/travail-de-la-copie.mjs +94 -11
- package/scripts/etapes.mjs +1 -1
- package/scripts/fusion-du-changelog.mjs +0 -1
- package/scripts/grillhouse-maj.mjs +16 -7
- package/scripts/integration/file.mjs +3 -3
- package/scripts/integration/integrer.mjs +3 -3
- package/scripts/jointure.d.ts +53 -17
- package/scripts/langages/cargo/commandes.mjs +152 -25
- package/scripts/langages/cargo/composants.mjs +94 -2
- package/scripts/langages/cargo/exemples.mjs +68 -1
- package/scripts/langages/cargo/index.mjs +21 -10
- package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +35 -0
- package/scripts/langages/cargo/sccache.mjs +89 -6
- package/scripts/langages/cargo/squelette.mjs +72 -3
- package/scripts/langages/cargo/tailles-des-tests.mjs +195 -0
- package/scripts/langages/cargo/tests-de-head.mjs +159 -0
- package/scripts/langages/python/commandes.mjs +53 -9
- package/scripts/langages/python/composants.mjs +33 -3
- package/scripts/langages/python/exemples.mjs +19 -0
- package/scripts/langages/python/index.mjs +7 -2
- package/scripts/langages/python/squelette.mjs +119 -17
- package/scripts/langages/typescript/exemples.mjs +16 -0
- package/scripts/langages/typescript/index.mjs +6 -3
- package/scripts/langages/typescript/regle-des-tests.mjs +13 -0
- package/scripts/langages/typescript/squelette.mjs +18 -2
- package/scripts/langages/typescript/tests-de-nuit.mjs +50 -20
- package/scripts/langages/typescript/verifier.mjs +82 -288
- package/scripts/langages/typescript/vitest-config/base.mjs +8 -9
- package/scripts/langages/typescript/vitest-config/cibles.mjs +92 -53
- package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +11 -5
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +6 -1
- package/scripts/langages/typescript/vitest-config/mesure.mjs +3 -2
- package/scripts/langages/typescript/vitest.nuit.config.mjs +18 -13
- package/scripts/lecture-unique.mjs +51 -0
- package/scripts/mesure/base-de-passe.mjs +202 -9
- package/scripts/mesure/pression.mjs +9 -7
- package/scripts/nuit.sh +19 -12
- package/scripts/outil.mjs +72 -0
- package/scripts/paquet.mjs +39 -10
- package/scripts/resultats.mjs +22 -5
- package/scripts/services-du-noyau.mjs +16 -10
- package/scripts/session-start.sh +10 -1
- package/scripts/sortie.mjs +20 -1
- package/scripts/sources.mjs +3 -3
- package/scripts/sous-commandes.mjs +2 -0
- package/scripts/superviseur.mjs +369 -14
- package/scripts/tableau.mjs +219 -58
- package/scripts/verrou-de-machine.mjs +425 -37
- package/skills/developpeur/SKILL.md +11 -3
- package/skills/pitmaster/SKILL.md +64 -23
- package/skills/pitmaster/references/consigne-agent.md +4 -0
- package/skills/relecteur/SKILL.md +18 -6
- package/skills/testwriter/SKILL.md +11 -15
|
@@ -39,36 +39,80 @@
|
|
|
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
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
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`: « Mesure » by default, a step's title for a circuit), since when, and its progress
|
|
54
|
+
// directory once it names it (`nommerLAvancement`); the name goes with the lock. Each measure
|
|
55
|
+
// that waits, for the lock or for room in the temporary directory, names itself in the
|
|
56
|
+
// directory `<lock>.attentes/`, one file per waiting process (its process, its rank, its
|
|
57
|
+
// project, ticket and kind, what it waits for `quoi`, since when), removed once it stops
|
|
58
|
+
// waiting. The project is named by the root of the main tree of the repository the measure
|
|
59
|
+
// plays in, its copies included (`depot`, `racineDuDepot`); the board gives it the name it
|
|
60
|
+
// gives that project, its folder's for a project out of the board (scripts/tableau.mjs).
|
|
61
|
+
// `lireLeVerrou` reads them for the board (through `lireLaMesure` of scripts/avancement.mjs): a
|
|
62
|
+
// holder or a wait whose process is gone names no one, and the wait's file goes; a lock a live
|
|
63
|
+
// process holds without naming itself (a frame older than this naming) shows as the repository
|
|
64
|
+
// of its process's directory, of the kind « Verrou ».
|
|
50
65
|
// - The lock is let go at the end of the measure, whether it succeeds or throws.
|
|
66
|
+
// - A measure first wants room in the temporary directory (`os.tmpdir()` under its environment),
|
|
67
|
+
// a disk in memory that the sessions of the machine share: under LIBRE_MIN, 4 GB free
|
|
68
|
+
// (GRILLHOUSE_TEMPORAIRE_LIBRE names another floor, in bytes; the base configuration of the
|
|
69
|
+
// tests sets 0, scripts/langages/typescript/vitest-config/machine.setup.mjs), it waits for room
|
|
70
|
+
// instead of failing for lack of it (ENOSPC: 25 reds of the night of 2026-11-01, the
|
|
71
|
+
// scratchpads holding 8 GB of 16), as Kubernetes schedules no new pod on a node under
|
|
72
|
+
// DiskPressure. It says so, with what holds the directory (its largest
|
|
73
|
+
// entries, by the blocks their files hold, the temporary directory of a ticket naming its
|
|
74
|
+
// ticket), when it begins and every 30 s, under the same bound as the
|
|
75
|
+
// lock's, then « à repasser » (75).
|
|
76
|
+
// - It then wants room on the disk of the copy it plays in (its root, `racine`), where cargo
|
|
77
|
+
// writes its target directories: under LIBRE_MIN as well (GRILLHOUSE_COPIE_LIBRE names another
|
|
78
|
+
// floor, in bytes; the base configuration of the tests sets 0), it waits the same way, under
|
|
79
|
+
// the same bound counted from the start of the wait, and says what holds that disk: the copies
|
|
80
|
+
// of its repository, the largest first, each with its ticket and its tools' outputs
|
|
81
|
+
// (`occupantsDesCopies` of scripts/copies-finies.mjs: « .claude/worktrees/SH-ae6.2.7 (le
|
|
82
|
+
// ticket SH-ae6.2.7, 5,0 Go, dont target 4,8 Go) »), as Bazel and Buildkite refuse to start a
|
|
83
|
+
// build under a floor of free room rather than fail in its middle (the main disk full on
|
|
84
|
+
// 2026-11-01, three circuits killed without a word, grillhouse-k5y).
|
|
85
|
+
import { spawnSync } from 'node:child_process';
|
|
51
86
|
import { randomUUID } from 'node:crypto';
|
|
52
87
|
import {
|
|
88
|
+
lstatSync,
|
|
53
89
|
mkdirSync,
|
|
54
90
|
readdirSync,
|
|
55
91
|
readFileSync,
|
|
56
92
|
readlinkSync,
|
|
57
93
|
rmSync,
|
|
94
|
+
statfsSync,
|
|
58
95
|
statSync,
|
|
59
|
-
writeFileSync,
|
|
60
96
|
} from 'node:fs';
|
|
61
|
-
import { homedir } from 'node:os';
|
|
97
|
+
import { homedir, tmpdir } from 'node:os';
|
|
62
98
|
import path from 'node:path';
|
|
99
|
+
import { occupantsDesCopies } from './copies-finies.mjs';
|
|
63
100
|
import { paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
|
|
64
101
|
import { paquets } from './paquets.mjs';
|
|
65
102
|
import { attendreUnPeu, lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
|
|
66
|
-
import {
|
|
103
|
+
import { ecrireAtomique } from './mesure/avancement.mjs';
|
|
104
|
+
import { ticketDeLaBase, vivant } from './mesure/base-de-passe.mjs';
|
|
67
105
|
import { A_REPASSER } from './mesure/pression.mjs';
|
|
68
106
|
|
|
69
107
|
const VARIABLE_VERROU = 'GRILLHOUSE_VERROU_MACHINE';
|
|
70
108
|
const VARIABLE_TENUE = 'GRILLHOUSE_MESURE_TENUE';
|
|
71
109
|
const VARIABLE_ATTENTE = 'GRILLHOUSE_ATTENTE_MACHINE_MS';
|
|
110
|
+
const VARIABLE_LIBRE = 'GRILLHOUSE_TEMPORAIRE_LIBRE';
|
|
111
|
+
const VARIABLE_COPIE = 'GRILLHOUSE_COPIE_LIBRE';
|
|
112
|
+
|
|
113
|
+
/** The room a heavy measure wants free in the temporary directory, and on the disk of its copy,
|
|
114
|
+
* in bytes: 4 GB. */
|
|
115
|
+
export const LIBRE_MIN = 4 * 1024 ** 3;
|
|
72
116
|
|
|
73
117
|
// The name of the frame's package, which a repository of the first rank develops.
|
|
74
118
|
const CADRE = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).name;
|
|
@@ -103,8 +147,8 @@ export class AttenteDeLaMachine extends Error {
|
|
|
103
147
|
}
|
|
104
148
|
}
|
|
105
149
|
|
|
106
|
-
// The lock file of the machine under <env>, beside which
|
|
107
|
-
//
|
|
150
|
+
// The lock file of the machine under <env>, beside which its holder and its waits name
|
|
151
|
+
// themselves.
|
|
108
152
|
export function verrouDeMachine(env = process.env) {
|
|
109
153
|
if (env[VARIABLE_VERROU]) return env[VARIABLE_VERROU];
|
|
110
154
|
const cache = env.XDG_CACHE_HOME || path.join(env.HOME || homedir(), '.cache');
|
|
@@ -164,36 +208,194 @@ function qui(verrou) {
|
|
|
164
208
|
return `${processus(pid)}${depuis}`;
|
|
165
209
|
}
|
|
166
210
|
|
|
167
|
-
|
|
168
|
-
|
|
211
|
+
/**
|
|
212
|
+
* The root of the repository at <racine>: its main tree, its copies included (the parent of its
|
|
213
|
+
* common directory of git); <racine> itself out of git.
|
|
214
|
+
* @param {string} racine
|
|
215
|
+
* @returns {string}
|
|
216
|
+
*/
|
|
217
|
+
export function racineDuDepot(racine) {
|
|
218
|
+
const r = spawnSync(
|
|
219
|
+
'git',
|
|
220
|
+
['-C', racine, 'rev-parse', '--path-format=absolute', '--git-common-dir'],
|
|
221
|
+
{ encoding: 'utf8' }
|
|
222
|
+
);
|
|
223
|
+
return r.status === 0 ? path.dirname(r.stdout.trim()) : path.resolve(racine);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const lireJson = f => {
|
|
227
|
+
try {
|
|
228
|
+
return JSON.parse(readFileSync(f, 'utf8'));
|
|
229
|
+
} catch {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// The file where the holder of <verrou> names itself, and the directory of its waits.
|
|
235
|
+
const fichierDuDetenteur = verrou => `${verrou}.detenteur.json`;
|
|
236
|
+
const dossierDesAttentes = verrou => `${verrou}.attentes`;
|
|
237
|
+
|
|
238
|
+
// Who a measure is, from its options: `{ depot, ticket, sorte }`, the root of its repository
|
|
239
|
+
// read when first asked.
|
|
240
|
+
function identite({ racine, ticket = null, sorte = 'Mesure' }) {
|
|
241
|
+
let depot = null;
|
|
242
|
+
return {
|
|
243
|
+
get depot() {
|
|
244
|
+
depot ??= racineDuDepot(racine);
|
|
245
|
+
return depot;
|
|
246
|
+
},
|
|
247
|
+
ticket,
|
|
248
|
+
sorte,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
169
251
|
|
|
170
|
-
// Names this process among the
|
|
171
|
-
// removes its name.
|
|
172
|
-
function
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
252
|
+
// Names this process, <id>, among the waits of <verrou>, waiting for <quoi> (« verrou »,
|
|
253
|
+
// « place ») at the rank <rang> (null for room); a function that removes its name.
|
|
254
|
+
function inscrireLAttente(verrou, id, quoi, rang = null) {
|
|
255
|
+
const f = path.join(dossierDesAttentes(verrou), `${process.pid}-${randomUUID()}.json`);
|
|
256
|
+
try {
|
|
257
|
+
ecrireAtomique(f, {
|
|
258
|
+
pid: process.pid,
|
|
259
|
+
rang,
|
|
260
|
+
depot: id.depot,
|
|
261
|
+
ticket: id.ticket,
|
|
262
|
+
sorte: id.sorte,
|
|
263
|
+
quoi,
|
|
264
|
+
depuis: Date.now(),
|
|
265
|
+
});
|
|
266
|
+
} catch {
|
|
267
|
+
return () => {};
|
|
268
|
+
}
|
|
177
269
|
return () => rmSync(f, { force: true });
|
|
178
270
|
}
|
|
179
271
|
|
|
180
|
-
// The
|
|
181
|
-
//
|
|
182
|
-
function
|
|
183
|
-
const dossier =
|
|
272
|
+
// The waits of <verrou> whose process lives, the oldest first; the file of a process that is gone
|
|
273
|
+
// is removed.
|
|
274
|
+
function attentesDe(verrou) {
|
|
275
|
+
const dossier = dossierDesAttentes(verrou);
|
|
184
276
|
let noms;
|
|
185
277
|
try {
|
|
186
278
|
noms = readdirSync(dossier);
|
|
187
279
|
} catch {
|
|
188
280
|
return [];
|
|
189
281
|
}
|
|
190
|
-
const
|
|
282
|
+
const out = [];
|
|
191
283
|
for (const nom of noms) {
|
|
192
284
|
const pid = Number(/^(\d+)-/.exec(nom)?.[1]);
|
|
193
|
-
if (pid
|
|
194
|
-
|
|
285
|
+
if (!pid || !vivant(pid)) {
|
|
286
|
+
rmSync(path.join(dossier, nom), { force: true });
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
const a = nom.endsWith('.json') ? lireJson(path.join(dossier, nom)) : null;
|
|
290
|
+
if (a?.pid === pid) out.push(a);
|
|
195
291
|
}
|
|
196
|
-
return
|
|
292
|
+
return out.sort((a, b) => (a.depuis ?? 0) - (b.depuis ?? 0));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// The live processes of the measures of the first rank that wait for <verrou>.
|
|
296
|
+
const premiersQuiAttendent = verrou =>
|
|
297
|
+
attentesDe(verrou)
|
|
298
|
+
.filter(a => a.quoi === 'verrou' && a.rang === 1)
|
|
299
|
+
.map(a => a.pid);
|
|
300
|
+
|
|
301
|
+
// Names this process, <id>, holder of <verrou> under the mark it holds; a function that removes
|
|
302
|
+
// the name while it is still this taking's.
|
|
303
|
+
function nommerLeDetenteur(verrou, id) {
|
|
304
|
+
const f = fichierDuDetenteur(verrou);
|
|
305
|
+
const marque = lire(verrou);
|
|
306
|
+
try {
|
|
307
|
+
ecrireAtomique(f, {
|
|
308
|
+
marque,
|
|
309
|
+
pid: process.pid,
|
|
310
|
+
depot: id.depot,
|
|
311
|
+
ticket: id.ticket,
|
|
312
|
+
sorte: id.sorte,
|
|
313
|
+
depuis: Date.now(),
|
|
314
|
+
dossier: null,
|
|
315
|
+
});
|
|
316
|
+
} catch {
|
|
317
|
+
return () => {};
|
|
318
|
+
}
|
|
319
|
+
return () => {
|
|
320
|
+
if (lireJson(f)?.marque === marque) rmSync(f, { force: true });
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Names the progress directory <dossier> of the measure that holds the lock of the machine under
|
|
326
|
+
* <env> (its mark in GRILLHOUSE_MESURE_TENUE), beside the lock, where the board reads it; a
|
|
327
|
+
* function that takes it out. Nothing without a lock this environment holds (in the envelope of
|
|
328
|
+
* an agent).
|
|
329
|
+
* @param {{ env?: Record<string, string | undefined>, dossier: string }} o
|
|
330
|
+
* @returns {() => void}
|
|
331
|
+
*/
|
|
332
|
+
export function nommerLAvancement({ env = process.env, dossier }) {
|
|
333
|
+
const f = fichierDuDetenteur(verrouDeMachine(env));
|
|
334
|
+
const marque = env[VARIABLE_TENUE];
|
|
335
|
+
const ecrire = d => {
|
|
336
|
+
const n = lireJson(f);
|
|
337
|
+
if (!marque || n?.marque !== marque) return false;
|
|
338
|
+
try {
|
|
339
|
+
ecrireAtomique(f, { ...n, dossier: d });
|
|
340
|
+
return true;
|
|
341
|
+
} catch {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
return ecrire(dossier) ? () => void ecrire(null) : () => {};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Who holds the lock of the machine under <env> and who waits for it. `detenteur`: its process,
|
|
350
|
+
* repository (`depot`, the root of its main tree, and `projet`, its folder), ticket, kind, since
|
|
351
|
+
* when (ms) and progress directory; null when the lock is free or its process gone; a live process
|
|
352
|
+
* that names nothing beside the lock shows as the repository of its directory, of the kind
|
|
353
|
+
* « Verrou ». `attentes`: each live wait, the oldest first, its process, rank, repository,
|
|
354
|
+
* ticket, kind, what it waits for (`quoi`: « verrou » or « place ») and since when.
|
|
355
|
+
* @param {Record<string, string | undefined>} [env]
|
|
356
|
+
*/
|
|
357
|
+
export function lireLeVerrou(env = process.env) {
|
|
358
|
+
const verrou = verrouDeMachine(env);
|
|
359
|
+
const attentes = attentesDe(verrou).map(({ pid, rang, depot, ticket, sorte, quoi, depuis }) => ({
|
|
360
|
+
pid,
|
|
361
|
+
rang,
|
|
362
|
+
depot,
|
|
363
|
+
projet: path.basename(String(depot)),
|
|
364
|
+
ticket,
|
|
365
|
+
sorte,
|
|
366
|
+
quoi,
|
|
367
|
+
depuis,
|
|
368
|
+
}));
|
|
369
|
+
const marque = lire(verrou);
|
|
370
|
+
const pid = detenteur(verrou);
|
|
371
|
+
if (marque === null || pid === null || !vivant(pid)) return { detenteur: null, attentes };
|
|
372
|
+
const n = lireJson(fichierDuDetenteur(verrou));
|
|
373
|
+
if (n?.marque === marque) {
|
|
374
|
+
const { depot, ticket, sorte, depuis, dossier } = n;
|
|
375
|
+
const projet = path.basename(String(depot));
|
|
376
|
+
return { detenteur: { pid, depot, projet, ticket, sorte, depuis, dossier }, attentes };
|
|
377
|
+
}
|
|
378
|
+
let depuis = null;
|
|
379
|
+
let ou = null;
|
|
380
|
+
try {
|
|
381
|
+
depuis = statSync(verrou).mtimeMs;
|
|
382
|
+
ou = readlinkSync(`/proc/${pid}/cwd`);
|
|
383
|
+
} catch {
|
|
384
|
+
// the lock gone meanwhile, or the directory of its process unreadable: its number names it
|
|
385
|
+
}
|
|
386
|
+
const depot = ou ? racineDuDepot(ou) : null;
|
|
387
|
+
return {
|
|
388
|
+
detenteur: {
|
|
389
|
+
pid,
|
|
390
|
+
depot,
|
|
391
|
+
projet: depot ? path.basename(depot) : `processus ${pid}`,
|
|
392
|
+
ticket: null,
|
|
393
|
+
sorte: 'Verrou',
|
|
394
|
+
depuis,
|
|
395
|
+
dossier: null,
|
|
396
|
+
},
|
|
397
|
+
attentes,
|
|
398
|
+
};
|
|
197
399
|
}
|
|
198
400
|
|
|
199
401
|
// Whom a measure of the rank <rang> waits for at <verrou>: the holder of the lock, and for the
|
|
@@ -227,6 +429,178 @@ function ancetre(pid) {
|
|
|
227
429
|
return false;
|
|
228
430
|
}
|
|
229
431
|
|
|
432
|
+
// The floor of room the variable <variable> names under <env>, in bytes, LIBRE_MIN by default.
|
|
433
|
+
function plancherDe(env, variable) {
|
|
434
|
+
const n = Number(env[variable]);
|
|
435
|
+
return env[variable] && Number.isFinite(n) && n >= 0 ? n : LIBRE_MIN;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// The room free in <dossier>, in bytes; Infinity when it does not read.
|
|
439
|
+
function libreDans(dossier) {
|
|
440
|
+
try {
|
|
441
|
+
const s = statfsSync(dossier);
|
|
442
|
+
return s.bavail * s.bsize;
|
|
443
|
+
} catch {
|
|
444
|
+
return Infinity;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const go = octets => `${(octets / 1024 ** 3).toFixed(1).replace('.', ',')} Go`;
|
|
449
|
+
|
|
450
|
+
// The entries a count of what holds the temporary directory reads at most, so that it stays
|
|
451
|
+
// short on a directory of millions of files: past it, a size is a floor.
|
|
452
|
+
const ENTREES_LUES = 500_000;
|
|
453
|
+
|
|
454
|
+
// The largest entries of <dossier>, the five first, each by the blocks its files hold, as `du`
|
|
455
|
+
// counts them: « claude-1000 (8,0 Go), grillhouse-vitest-x (1,2 Go) ».
|
|
456
|
+
function occupants(dossier) {
|
|
457
|
+
let noms;
|
|
458
|
+
try {
|
|
459
|
+
noms = readdirSync(dossier);
|
|
460
|
+
} catch {
|
|
461
|
+
return 'illisible';
|
|
462
|
+
}
|
|
463
|
+
if (noms.length === 0) return 'rien';
|
|
464
|
+
let budget = ENTREES_LUES;
|
|
465
|
+
const taille = racine => {
|
|
466
|
+
let octets = 0;
|
|
467
|
+
const pile = [racine];
|
|
468
|
+
while (pile.length > 0 && budget-- > 0) {
|
|
469
|
+
const p = pile.pop();
|
|
470
|
+
let e;
|
|
471
|
+
try {
|
|
472
|
+
e = lstatSync(p);
|
|
473
|
+
} catch {
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
octets += e.blocks * 512;
|
|
477
|
+
if (e.isDirectory()) {
|
|
478
|
+
try {
|
|
479
|
+
for (const n of readdirSync(p)) pile.push(path.join(p, n));
|
|
480
|
+
} catch {
|
|
481
|
+
// an unreadable directory counts for itself alone
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return octets;
|
|
486
|
+
};
|
|
487
|
+
return noms
|
|
488
|
+
.map(nom => ({ nom, octets: taille(path.join(dossier, nom)) }))
|
|
489
|
+
.sort((a, b) => b.octets - a.octets)
|
|
490
|
+
.slice(0, 5)
|
|
491
|
+
.map(o => {
|
|
492
|
+
const ticket = ticketDeLaBase(o.nom);
|
|
493
|
+
return `${o.nom} (${ticket ? `le ticket ${ticket}, ` : ''}${go(o.octets)})`;
|
|
494
|
+
})
|
|
495
|
+
.join(', ');
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// The disks a heavy pass waits for room on, in order: `{ nom, ou, variable }`, the words of its
|
|
499
|
+
// lines (« le dossier temporaire », « dans le dossier temporaire »), and the variable of its floor.
|
|
500
|
+
const DISQUES = {
|
|
501
|
+
temporaire: {
|
|
502
|
+
nom: 'le dossier temporaire',
|
|
503
|
+
ou: 'dans le dossier temporaire',
|
|
504
|
+
variable: VARIABLE_LIBRE,
|
|
505
|
+
},
|
|
506
|
+
copie: {
|
|
507
|
+
nom: 'le disque de la copie',
|
|
508
|
+
ou: 'sur le disque de la copie',
|
|
509
|
+
variable: VARIABLE_COPIE,
|
|
510
|
+
},
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
// Waits until <dossier> holds <plancher> bytes free (`libre`, a statfs at each turn), saying so
|
|
514
|
+
// (`dire`) in the words of <disque> (DISQUES) with what holds it (`occupe`, counted only when a
|
|
515
|
+
// line is written) when it begins and every <rappelMs>, and naming itself among the waits once it
|
|
516
|
+
// waits (`inscrire`, a function that returns the removal of its name). Throws an
|
|
517
|
+
// AttenteDeLaMachine (75) at <borneMs> from <debut> (now by default), the start of the whole wait.
|
|
518
|
+
function attendreLaPlace(dossier, { inscrire, ...o }) {
|
|
519
|
+
let retirer = null;
|
|
520
|
+
try {
|
|
521
|
+
return attendreLaPlaceEnNommant(dossier, {
|
|
522
|
+
...o,
|
|
523
|
+
nommer: () => {
|
|
524
|
+
retirer ??= inscrire();
|
|
525
|
+
},
|
|
526
|
+
});
|
|
527
|
+
} finally {
|
|
528
|
+
retirer?.();
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function attendreLaPlaceEnNommant(
|
|
533
|
+
dossier,
|
|
534
|
+
{ disque, plancher, libre, occupe, dire, borneMs, rappelMs, nommer, debut = Date.now() }
|
|
535
|
+
) {
|
|
536
|
+
let dit = null;
|
|
537
|
+
for (;;) {
|
|
538
|
+
const l = libre(dossier);
|
|
539
|
+
if (l >= plancher) {
|
|
540
|
+
if (dit !== null) dire(`✓ place ${disque.ou} après ${duree(Date.now() - debut)}.`);
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
nommer();
|
|
544
|
+
const t = Date.now();
|
|
545
|
+
const etat = () =>
|
|
546
|
+
`${disque.nom} (${dossier}) n'a que ${go(l)} libres, moins des ${go(plancher)} qu'une passe lourde demande (${disque.variable}) ; l'occupent : ${occupe(dossier)}`;
|
|
547
|
+
if (t - debut >= borneMs)
|
|
548
|
+
throw new AttenteDeLaMachine(
|
|
549
|
+
`⏱ attente de place bornée à ${duree(borneMs)} (${VARIABLE_ATTENTE}) : ${etat()} ; à repasser (code ${A_REPASSER}).`,
|
|
550
|
+
A_REPASSER
|
|
551
|
+
);
|
|
552
|
+
if (dit === null) dire(`⏳ ${etat()} ; attente de place, ${duree(borneMs)} au plus.`);
|
|
553
|
+
else if (t - dit >= rappelMs)
|
|
554
|
+
dire(`⏳ attente de place depuis ${duree(t - debut)} : ${etat()}.`);
|
|
555
|
+
if (dit === null || t - dit >= rappelMs) dit = t;
|
|
556
|
+
attendreUnPeu(Math.max(1, Math.min(200, borneMs - (Date.now() - debut))));
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Waits for room in the temporary directory under <env> (`os.tmpdir()` as it reads it), then on
|
|
562
|
+
* the disk of the copy at <racine>, where the pass writes its target directories: what a heavy
|
|
563
|
+
* pass does before it plays (see the header).
|
|
564
|
+
* @param {{ env?: Record<string, string | undefined>, dire?: (l: string) => void, borneMs?: number,
|
|
565
|
+
* rappelMs?: number, libre?: (dossier: string) => number, occupe?: (dossier: string) => string,
|
|
566
|
+
* occupeLaCopie?: (racine: string) => string, racine?: string, ticket?: string | null,
|
|
567
|
+
* sorte?: string }} [o] `libre` reads the room of each disk, `occupe` what holds the temporary
|
|
568
|
+
* directory, `occupeLaCopie` the copies that hold the disk of the copy; the wait names its
|
|
569
|
+
* project <racine>, its ticket and its kind among the waits of the lock of the machine under
|
|
570
|
+
* <env> while it waits
|
|
571
|
+
* @throws {AttenteDeLaMachine} at the bound of the wait (code 75)
|
|
572
|
+
*/
|
|
573
|
+
export function attendreDeLaPlace({
|
|
574
|
+
env = process.env,
|
|
575
|
+
dire = l => process.stdout.write(`${l}\n`),
|
|
576
|
+
borneMs = borneDe(env),
|
|
577
|
+
rappelMs = RAPPEL_MS,
|
|
578
|
+
libre = libreDans,
|
|
579
|
+
occupe = occupants,
|
|
580
|
+
occupeLaCopie = occupantsDesCopies,
|
|
581
|
+
racine = process.cwd(),
|
|
582
|
+
ticket = null,
|
|
583
|
+
sorte = 'Mesure',
|
|
584
|
+
} = {}) {
|
|
585
|
+
const temporaire = env.TMPDIR || env.TMP || env.TEMP || tmpdir();
|
|
586
|
+
const id = identite({ racine, ticket, sorte });
|
|
587
|
+
const inscrire = () => inscrireLAttente(verrouDeMachine(env), id, 'place');
|
|
588
|
+
const debut = Date.now();
|
|
589
|
+
const commun = { libre, dire, borneMs, rappelMs, inscrire, debut };
|
|
590
|
+
attendreLaPlace(temporaire, {
|
|
591
|
+
...commun,
|
|
592
|
+
disque: DISQUES.temporaire,
|
|
593
|
+
plancher: plancherDe(env, VARIABLE_LIBRE),
|
|
594
|
+
occupe,
|
|
595
|
+
});
|
|
596
|
+
attendreLaPlace(racine, {
|
|
597
|
+
...commun,
|
|
598
|
+
disque: DISQUES.copie,
|
|
599
|
+
plancher: plancherDe(env, VARIABLE_COPIE),
|
|
600
|
+
occupe: occupeLaCopie,
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
|
|
230
604
|
// The bound of the wait under <env>, in ms.
|
|
231
605
|
function borneDe(env) {
|
|
232
606
|
const n = Number(env[VARIABLE_ATTENTE]);
|
|
@@ -235,10 +609,10 @@ function borneDe(env) {
|
|
|
235
609
|
|
|
236
610
|
// Waits for the lock <verrou> at the rank <rang>, saying so (`dire`) when it begins and every
|
|
237
611
|
// <rappelMs>; returns the time waited, in ms. Throws an AttenteDeLaMachine at once when an ancestor
|
|
238
|
-
// holds the lock, and at the bound <borneMs>.
|
|
239
|
-
//
|
|
240
|
-
function attendreLaMachine(verrou, { rang, dire, borneMs, rappelMs }) {
|
|
241
|
-
const retirer =
|
|
612
|
+
// holds the lock, and at the bound <borneMs>. The measure, <id>, names itself among the waits,
|
|
613
|
+
// with its rank, while it waits.
|
|
614
|
+
function attendreLaMachine(verrou, { id, rang, dire, borneMs, rappelMs }) {
|
|
615
|
+
const retirer = inscrireLAttente(verrou, id, 'verrou', rang);
|
|
242
616
|
try {
|
|
243
617
|
return attendreAuRang(verrou, { rang, dire, borneMs, rappelMs });
|
|
244
618
|
} finally {
|
|
@@ -282,11 +656,16 @@ function attendreAuRang(verrou, { rang, dire, borneMs, rappelMs }) {
|
|
|
282
656
|
* environment of its children, which carries the lock to them.
|
|
283
657
|
* @param {(envEnfant: Record<string, string | undefined>) => T} mesure a synchronous measure
|
|
284
658
|
* @param {{ env?: Record<string, string | undefined>, racine?: string,
|
|
285
|
-
* dire?: (ligne: string) => void, borneMs?: number, rappelMs?: number
|
|
659
|
+
* dire?: (ligne: string) => void, borneMs?: number, rappelMs?: number,
|
|
660
|
+
* libre?: (dossier: string) => number, occupe?: (dossier: string) => string,
|
|
661
|
+
* ticket?: string | null, sorte?: string }} options `racine`, the
|
|
286
662
|
* root of the repository the measure plays in, which gives its rank (`rangDeLaMesure`; the
|
|
287
663
|
* working directory by default); `borneMs`, the bound of the wait
|
|
288
664
|
* (GRILLHOUSE_ATTENTE_MACHINE_MS, else ATTENTE_MACHINE_MS); `rappelMs`, the gap between two
|
|
289
|
-
* lines that say the wait goes on (30 s)
|
|
665
|
+
* lines that say the wait goes on (30 s); `libre`, the room free in a directory, in bytes
|
|
666
|
+
* (`statfs`, at each turn); `occupe`, what holds it, counted when a line of the wait is written;
|
|
667
|
+
* `ticket` (null out of a ticket) and `sorte` (« Mesure » by default), who the measure is,
|
|
668
|
+
* named beside the lock while it waits and while it holds it, with its project
|
|
290
669
|
* @returns {T}
|
|
291
670
|
* @throws {AttenteDeLaMachine} at the bound of the wait (code 75), or at once when an ancestor
|
|
292
671
|
* holds the lock (code 1)
|
|
@@ -300,20 +679,29 @@ export function avecLaMachine(
|
|
|
300
679
|
dire = l => process.stdout.write(`${l}\n`),
|
|
301
680
|
borneMs = borneDe(env),
|
|
302
681
|
rappelMs = RAPPEL_MS,
|
|
682
|
+
libre = libreDans,
|
|
683
|
+
occupe = occupants,
|
|
684
|
+
ticket = null,
|
|
685
|
+
sorte = 'Mesure',
|
|
303
686
|
} = {}
|
|
304
687
|
) {
|
|
305
688
|
if (paquetsDeLEnveloppe(env)) return mesure(env);
|
|
306
689
|
const verrou = verrouDeMachine(env);
|
|
307
690
|
if (env[VARIABLE_TENUE] && lire(verrou) === env[VARIABLE_TENUE]) return mesure(env);
|
|
691
|
+
attendreDeLaPlace({ env, libre, occupe, dire, borneMs, rappelMs, racine, ticket, sorte });
|
|
692
|
+
const id = identite({ racine, ticket, sorte });
|
|
308
693
|
mkdirSync(path.dirname(verrou), { recursive: true });
|
|
309
694
|
const rang = rangDeLaMesure(racine);
|
|
310
695
|
if (!(peutPrendre(verrou, rang) && prendreVerrou(verrou, { attendre: false }))) {
|
|
311
|
-
const attendu = attendreLaMachine(verrou, { rang, dire, borneMs, rappelMs });
|
|
696
|
+
const attendu = attendreLaMachine(verrou, { id, rang, dire, borneMs, rappelMs });
|
|
312
697
|
dire(`✓ verrou de la machine pris après ${Math.round(attendu / 1000)} s.`);
|
|
313
698
|
}
|
|
699
|
+
let oublier = () => {};
|
|
314
700
|
try {
|
|
701
|
+
oublier = nommerLeDetenteur(verrou, id);
|
|
315
702
|
return mesure({ ...env, [VARIABLE_TENUE]: lire(verrou) ?? '' });
|
|
316
703
|
} finally {
|
|
704
|
+
oublier();
|
|
317
705
|
lacherVerrou(verrou);
|
|
318
706
|
}
|
|
319
707
|
}
|
|
@@ -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.
|
|
87
|
-
|
|
88
|
-
|
|
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
|
|