@roomi-fields/grillhouse 0.35.0 → 0.37.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/CHANGELOG.md +28 -0
- package/cadre/templates/cargo/package.json +4 -2
- package/cadre/templates/projet/.github/workflows/ci.yml +10 -0
- package/cadre/templates/projet/.github/workflows/nuit.yml +5 -0
- package/cadre/templates/projet/CLAUDE.md +5 -0
- package/cadre/templates/python/package.json +4 -2
- package/charte.md +5 -0
- package/dist/temporal/file/contrat.d.ts +3 -1
- package/dist/temporal/file/deroule.js +2 -2
- package/dist/temporal/file/deroule.js.map +1 -1
- package/dist/temporal/nuits/activites.d.ts +10 -1
- package/dist/temporal/nuits/activites.js +59 -3
- package/dist/temporal/nuits/activites.js.map +1 -1
- package/dist/temporal/nuits/contrat.d.ts +15 -0
- package/dist/temporal/nuits/deroule.js +67 -35
- package/dist/temporal/nuits/deroule.js.map +1 -1
- package/dist/temporal/places/client.d.ts +12 -0
- package/dist/temporal/places/client.js +23 -1
- package/dist/temporal/places/client.js.map +1 -1
- package/dist/temporal/places/contrat.d.ts +47 -0
- package/dist/temporal/places/contrat.js +11 -0
- package/dist/temporal/places/contrat.js.map +1 -1
- package/dist/temporal/places/deroule.js +49 -2
- package/dist/temporal/places/deroule.js.map +1 -1
- package/dist/temporal/tickets/activites.js +30 -3
- package/dist/temporal/tickets/activites.js.map +1 -1
- package/docs/ARCHITECTURE.md +41 -9
- package/docs/CADRE.md +11 -0
- package/docs/INTERFACE.md +7 -4
- package/package.json +1 -1
- package/scripts/activites.mjs +10 -4
- package/scripts/aiguillage.mjs +1 -0
- package/scripts/attente-a-l-arret.mjs +1 -1
- package/scripts/attente-au-tour.mjs +1 -1
- package/scripts/binaires.mjs +119 -0
- package/scripts/file-des-tickets.d.mts +23 -1
- package/scripts/file-des-tickets.mjs +94 -3
- package/scripts/gabarit-absent.mjs +30 -0
- package/scripts/grillhouse-maj.mjs +61 -61
- package/scripts/groupe-cles.d.mts +25 -0
- package/scripts/groupe-cles.mjs +73 -0
- package/scripts/integration/file.mjs +30 -5
- package/scripts/jointure.d.ts +11 -0
- package/scripts/langages/cargo/binaires.mjs +1 -1
- package/scripts/langages/cargo/clippy.mjs +1 -1
- package/scripts/langages/cargo/commandes.mjs +1 -1
- package/scripts/langages/cargo/index.mjs +3 -2
- package/scripts/langages/cargo/mise-a-jour.mjs +17 -0
- package/scripts/langages/cargo/sccache.mjs +1 -1
- package/scripts/langages/python/commandes.mjs +1 -1
- package/scripts/langages/python/index.mjs +3 -1
- package/scripts/langages/python/mise-a-jour.mjs +22 -5
- package/scripts/langages/typescript/mise-a-jour.mjs +8 -20
- package/scripts/paquet.mjs +2 -7
- package/scripts/places-de-la-machine.mjs +53 -31
- package/scripts/regles-des-places.d.mts +34 -2
- package/scripts/regles-des-places.mjs +112 -9
- package/scripts/services-du-noyau.mjs +2 -1
- package/scripts/sigle-du-projet.mjs +49 -0
- package/scripts/sous-commandes.mjs +1 -0
- package/scripts/superviseur.mjs +31 -18
- package/scripts/tableau.mjs +483 -193
|
@@ -42,9 +42,16 @@ import { paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
|
|
|
42
42
|
import { ecrireLaTrace, traceDesPlaces } from './journal-des-etats.mjs';
|
|
43
43
|
import { mesureDeLaMachine } from './mesure-de-la-machine.mjs';
|
|
44
44
|
import { plafondDe } from './plafond-de-la-machine.mjs';
|
|
45
|
-
import {
|
|
45
|
+
import { VARIABLE_JETON } from './regles-des-places.mjs';
|
|
46
|
+
import { AttenteDeLaMachine, avecLaMachine, borneDe, racineDuDepot } from './verrou-de-machine.mjs';
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
// The spacing and the jeton of the night are rules (./regles-des-places.mjs), published here too.
|
|
49
|
+
export {
|
|
50
|
+
ESPACEMENT_MS,
|
|
51
|
+
espacementDe,
|
|
52
|
+
VARIABLE_ESPACEMENT,
|
|
53
|
+
VARIABLE_JETON,
|
|
54
|
+
} from './regles-des-places.mjs';
|
|
48
55
|
export const VARIABLE_TRAVAILLEURS = 'GRILLHOUSE_TRAVAILLEURS';
|
|
49
56
|
/** The mark of a place held, which the children of its holder inherit. */
|
|
50
57
|
export const VARIABLE_TENUE = 'GRILLHOUSE_PLACE_TENUE';
|
|
@@ -53,31 +60,10 @@ export const VARIABLE_MESURE_D_ESSAI = 'GRILLHOUSE_MESURE_D_ESSAI';
|
|
|
53
60
|
// The server of the places of a trial machine.
|
|
54
61
|
const VARIABLE_ESSAI = 'GRILLHOUSE_PLACES_D_ESSAI';
|
|
55
62
|
|
|
56
|
-
/** The gap between two starts when GRILLHOUSE_ESPACEMENT_MS names none, in ms. */
|
|
57
|
-
export const ESPACEMENT_MS = 10_000;
|
|
58
63
|
const RAPPEL_MS = 30_000;
|
|
59
64
|
// The reading and the taking of the places on the server, in a process of their own.
|
|
60
65
|
const PONT = path.join(import.meta.dirname, 'places-du-serveur.mjs');
|
|
61
66
|
|
|
62
|
-
/**
|
|
63
|
-
* The gap between two starts under <env>, in ms.
|
|
64
|
-
* @param {Record<string, string | undefined>} [env]
|
|
65
|
-
* @returns {number}
|
|
66
|
-
* @throws {Error} naming GRILLHOUSE_ESPACEMENT_MS when its value is not a number of ms
|
|
67
|
-
*/
|
|
68
|
-
export function espacementDe(env = process.env) {
|
|
69
|
-
const v = env[VARIABLE_ESPACEMENT];
|
|
70
|
-
if (v === undefined || v === '') {
|
|
71
|
-
return ESPACEMENT_MS;
|
|
72
|
-
}
|
|
73
|
-
if (!/^\d+$/.test(v)) {
|
|
74
|
-
throw new Error(
|
|
75
|
-
`${VARIABLE_ESPACEMENT} vaut « ${v} » : un nombre de millisecondes est attendu.`
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
return Number(v);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
67
|
/**
|
|
82
68
|
* The number of workers of the tests of a session: max(1, cores ÷ places), the division whole.
|
|
83
69
|
* @param {{ coeurs?: number, places?: number, env?: Record<string, string | undefined> }} [o]
|
|
@@ -171,6 +157,28 @@ export function prendreUnRang({ env = process.env } = {}) {
|
|
|
171
157
|
return e ? auServeur(e, ['rang']).lignes[0] : null;
|
|
172
158
|
}
|
|
173
159
|
|
|
160
|
+
/**
|
|
161
|
+
* The request of a place for the process <pid>: its start, its ticket, the root of its project,
|
|
162
|
+
* the rank of its circuit, and the jeton of the night when <env> carries it (VARIABLE_JETON: the
|
|
163
|
+
* passes of the night), which the workflow of the machine lets pass during the reservation of the
|
|
164
|
+
* machine.
|
|
165
|
+
* @param {{ env?: Record<string, string | undefined>, pid: number, depart?: string | null,
|
|
166
|
+
* ticket?: string | null, racine?: string, rang?: number | null }} o
|
|
167
|
+
* @returns {{ pid: number, depart: string | null, ticket: string | null, racine?: string | null,
|
|
168
|
+
* rang?: number, jeton?: string }}
|
|
169
|
+
*/
|
|
170
|
+
export function demandeDePlace({ env = process.env, pid, depart, ticket = null, racine, rang }) {
|
|
171
|
+
const jeton = env[VARIABLE_JETON];
|
|
172
|
+
return {
|
|
173
|
+
pid,
|
|
174
|
+
depart: depart === undefined ? departDe(pid) : depart,
|
|
175
|
+
ticket,
|
|
176
|
+
...(racine === undefined ? {} : { racine: racineDuDepot(racine) }),
|
|
177
|
+
...(rang === undefined || rang === null ? {} : { rang }),
|
|
178
|
+
...(jeton ? { jeton } : {}),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
174
182
|
/**
|
|
175
183
|
* Takes a place of the machine, waiting for one, saying why it waits (`dire`), and returns the
|
|
176
184
|
* place. Where no place is taken, or under a place already held (GRILLHOUSE_PLACE_TENUE), the
|
|
@@ -202,10 +210,7 @@ export function prendreUnePlace({
|
|
|
202
210
|
return { id: null, rang: rang ?? null, env, rendre: () => {}, rattacher: () => {} };
|
|
203
211
|
}
|
|
204
212
|
const demande = {
|
|
205
|
-
pid,
|
|
206
|
-
depart: depart === undefined ? departDe(pid) : depart,
|
|
207
|
-
ticket,
|
|
208
|
-
...(rang === undefined || rang === null ? {} : { rang }),
|
|
213
|
+
...demandeDePlace({ env, pid, depart, ticket, racine, rang }),
|
|
209
214
|
borneMs,
|
|
210
215
|
rappelMs,
|
|
211
216
|
};
|
|
@@ -344,7 +349,7 @@ export function avecLaMachineEtUnePlace(mesure, options = {}) {
|
|
|
344
349
|
* The places taken and the waits of the machine under <env>, as the server holds them: `{ plafond,
|
|
345
350
|
* faute, prises, attentes, circuits }` (`faute`, a value of the ceiling the poste names and the
|
|
346
351
|
* server refused, the ceiling read before kept; `circuits`, the places of the circuits, held or
|
|
347
|
-
* waited for, `{ racine, ticket, rang, accordee, depuis, vu }`), `prises` `{ id, pid, depart, ticket, rang, depuis }`, `attentes` in the
|
|
352
|
+
* waited for, `{ racine, ticket, rang, accordee, depuis, vu }`), `prises` `{ id, pid, depart, ticket, racine, rang, depuis }`, `attentes` in the
|
|
348
353
|
* order of arrival `{ id, pid, ticket, rang, raison, depuis }`; none where no place is taken.
|
|
349
354
|
* @param {{ env?: Record<string, string | undefined> }} [o]
|
|
350
355
|
*/
|
|
@@ -399,15 +404,32 @@ function mesureDEssai(env) {
|
|
|
399
404
|
* started (`circuits` of the server, which the queue of each project reserves). The
|
|
400
405
|
* machine is the one GRILLHOUSE_MESURE_D_ESSAI fixes, else the real one (`mesurer`).
|
|
401
406
|
* @param {{ env?: Record<string, string | undefined>, mesurer?: () => { coeurs: number,
|
|
402
|
-
* charge: number, memoireLibre: number, memoireTotale: number }
|
|
407
|
+
* charge: number, memoireLibre: number, memoireTotale: number },
|
|
408
|
+
* lues?: { plafond: number, faute?: string | null, prises: { ticket: string | null,
|
|
409
|
+
* racine?: string | null }[], attentes: { ticket: string, depuis: number }[],
|
|
410
|
+
* circuits?: { ticket: string, depuis: number, accordee?: boolean, raison?: string | null }[] }
|
|
411
|
+
* }} [o] `lues`, the places as the server holds them (`lirePlaces` by default); `tenues` of the
|
|
412
|
+
* result gives each place taken, its ticket and the root of its project (null without one)
|
|
413
|
+
* @returns {{ prises: number, tenues: { ticket: string | null, racine: string | null }[],
|
|
414
|
+
* plafond: number, faute: string | null, charge: number, coeurs: number, memoireGo: number,
|
|
415
|
+
* memoireTotaleGo: number, attentes: { ticket: string, depuis: number, disque?: string | null }[] }}
|
|
403
416
|
* @throws {Error} naming GRILLHOUSE_MESURE_D_ESSAI when its value is faulty
|
|
404
417
|
*/
|
|
405
|
-
export function etatDesPlaces({ env = process.env, mesurer = mesureDeLaMachine } = {}) {
|
|
418
|
+
export function etatDesPlaces({ env = process.env, mesurer = mesureDeLaMachine, lues } = {}) {
|
|
406
419
|
const fixee = mesureDEssai(env);
|
|
407
|
-
const {
|
|
420
|
+
const {
|
|
421
|
+
plafond,
|
|
422
|
+
faute = null,
|
|
423
|
+
prises,
|
|
424
|
+
attentes,
|
|
425
|
+
circuits = [],
|
|
426
|
+
nuit = null,
|
|
427
|
+
} = lues ?? lirePlaces({ env });
|
|
408
428
|
const m = fixee ?? mesurer();
|
|
409
429
|
return {
|
|
410
430
|
prises: prises.length,
|
|
431
|
+
tenues: prises.map(p => ({ ticket: p.ticket ?? null, racine: p.racine ?? null })),
|
|
432
|
+
nuit: nuit?.phase ?? null,
|
|
411
433
|
plafond,
|
|
412
434
|
faute,
|
|
413
435
|
charge: Math.round(m.charge * 10) / 10,
|
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
/** The memory a start wants free, in bytes: 4 GB. */
|
|
5
5
|
export const MEMOIRE_MIN: number;
|
|
6
6
|
|
|
7
|
+
export const VARIABLE_ESPACEMENT: string;
|
|
8
|
+
/** The jeton of the reservation of the machine by the night, which the passes of the night carry. */
|
|
9
|
+
export const VARIABLE_JETON: string;
|
|
10
|
+
/** The gap between two starts when GRILLHOUSE_ESPACEMENT_MS names none, in ms. */
|
|
11
|
+
export const ESPACEMENT_MS: number;
|
|
12
|
+
/** The gap between two starts under <env>, in ms. */
|
|
13
|
+
export function espacementDe(env?: Record<string, string | undefined>): number;
|
|
14
|
+
|
|
7
15
|
/** A duration as a line says it: seconds under 2 min, else minutes. */
|
|
8
16
|
export function duree(ms: number): string;
|
|
9
17
|
|
|
@@ -22,8 +30,15 @@ export function admission(m: MesureDeLaMachine): { ok: true } | { ok: false; rai
|
|
|
22
30
|
export function refusDeLaPlace(
|
|
23
31
|
etat: {
|
|
24
32
|
prises: readonly unknown[];
|
|
25
|
-
attentes: readonly {
|
|
33
|
+
attentes: readonly {
|
|
34
|
+
id: string;
|
|
35
|
+
rang: number;
|
|
36
|
+
ticket?: string | null;
|
|
37
|
+
raison?: string;
|
|
38
|
+
jeton?: string | null;
|
|
39
|
+
}[];
|
|
26
40
|
dernier: number;
|
|
41
|
+
reservation?: { jeton: string } | null;
|
|
27
42
|
},
|
|
28
43
|
o: {
|
|
29
44
|
id: string;
|
|
@@ -32,12 +47,22 @@ export function refusDeLaPlace(
|
|
|
32
47
|
espacementMs: number;
|
|
33
48
|
maintenant: number;
|
|
34
49
|
mesurer: () => MesureDeLaMachine;
|
|
50
|
+
jeton?: string | null;
|
|
35
51
|
}
|
|
36
52
|
): string | null;
|
|
37
53
|
|
|
38
54
|
/** A place of a circuit not given by its project's queue for this long is gone, in ms: 10 min. */
|
|
39
55
|
export const PERIME_MS: number;
|
|
40
56
|
|
|
57
|
+
/** The phase of the night on the places: none without a reservation, waiting, or under way. */
|
|
58
|
+
export function phaseDeLaNuit(etat: {
|
|
59
|
+
prises: readonly { id?: string; jeton?: string | null }[];
|
|
60
|
+
reservation?: { jeton: string } | null;
|
|
61
|
+
}): 'attend' | 'en cours' | null;
|
|
62
|
+
|
|
63
|
+
/** Whether a reservation's last beat is PERIME_MS old at <maintenant>. */
|
|
64
|
+
export function reservationPerimee(reservation: { battement: number }, maintenant: number): boolean;
|
|
65
|
+
|
|
41
66
|
/** The place of a circuit of the machine: held (`accordee`) or waited for, its rank of arrival. */
|
|
42
67
|
export interface PlaceDeCircuit {
|
|
43
68
|
racine: string;
|
|
@@ -50,6 +75,11 @@ export interface PlaceDeCircuit {
|
|
|
50
75
|
reprise?: boolean;
|
|
51
76
|
/** Why it waits apart from the order of arrival (its disk of copies), null without. */
|
|
52
77
|
raison?: string | null;
|
|
78
|
+
/** Its Beads priority (0 to 4) and creation, which order the circuits that wait of one group. */
|
|
79
|
+
priorite?: number;
|
|
80
|
+
creation?: string;
|
|
81
|
+
/** The identity of its project's group, absent out of a group. */
|
|
82
|
+
groupe?: string;
|
|
53
83
|
}
|
|
54
84
|
|
|
55
85
|
/**
|
|
@@ -66,6 +96,8 @@ export function reserverDesCircuits(
|
|
|
66
96
|
candidats?: string[];
|
|
67
97
|
disque?: string | null;
|
|
68
98
|
reprise?: { ticket: string; rang: number | null };
|
|
99
|
+
groupe?: string;
|
|
100
|
+
priorites?: Record<string, { priorite: number; creation: string }>;
|
|
69
101
|
},
|
|
70
|
-
o: { rang: number; plafond: number; maintenant: number }
|
|
102
|
+
o: { rang: number; plafond: number; maintenant: number; reservee?: boolean }
|
|
71
103
|
): { circuits: PlaceDeCircuit[]; rang: number; accordes: string[] };
|
|
@@ -9,6 +9,31 @@
|
|
|
9
9
|
/** The memory a start wants free, in bytes: 4 GB. */
|
|
10
10
|
export const MEMOIRE_MIN = 4 * 1024 ** 3;
|
|
11
11
|
|
|
12
|
+
export const VARIABLE_ESPACEMENT = 'GRILLHOUSE_ESPACEMENT_MS';
|
|
13
|
+
/** The jeton of the reservation of the machine by the night, which the passes of the night carry. */
|
|
14
|
+
export const VARIABLE_JETON = 'GRILLHOUSE_JETON_DE_LA_NUIT';
|
|
15
|
+
/** The gap between two starts when GRILLHOUSE_ESPACEMENT_MS names none, in ms. */
|
|
16
|
+
export const ESPACEMENT_MS = 10_000;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The gap between two starts under <env>, in ms.
|
|
20
|
+
* @param {Record<string, string | undefined>} [env]
|
|
21
|
+
* @returns {number}
|
|
22
|
+
* @throws {Error} naming GRILLHOUSE_ESPACEMENT_MS when its value is not a number of ms
|
|
23
|
+
*/
|
|
24
|
+
export function espacementDe(env = process.env) {
|
|
25
|
+
const v = env[VARIABLE_ESPACEMENT];
|
|
26
|
+
if (v === undefined || v === '') {
|
|
27
|
+
return ESPACEMENT_MS;
|
|
28
|
+
}
|
|
29
|
+
if (!/^\d+$/.test(v)) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`${VARIABLE_ESPACEMENT} vaut « ${v} » : un nombre de millisecondes est attendu.`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return Number(v);
|
|
35
|
+
}
|
|
36
|
+
|
|
12
37
|
// 11.2 → « 11,2 », 4 → « 4 ».
|
|
13
38
|
const nombre = n => (Number.isInteger(n) ? String(n) : n.toFixed(1).replace('.', ','));
|
|
14
39
|
|
|
@@ -51,11 +76,21 @@ export function admission({ coeurs, charge, memoireLibre }) {
|
|
|
51
76
|
* mesurer: () => { coeurs: number, charge: number, memoireLibre: number } }} o
|
|
52
77
|
* @returns {string | null}
|
|
53
78
|
*/
|
|
54
|
-
export function refusDeLaPlace(
|
|
79
|
+
export function refusDeLaPlace(
|
|
80
|
+
etat,
|
|
81
|
+
{ id, rang, plafond, espacementMs, maintenant, mesurer, jeton = null }
|
|
82
|
+
) {
|
|
83
|
+
const reservation = etat.reservation ?? null;
|
|
84
|
+
if (reservation && jeton !== reservation.jeton) {
|
|
85
|
+
return 'la nuit tient la machine : la place est donnée à la fin des nuits';
|
|
86
|
+
}
|
|
55
87
|
if (etat.prises.length >= plafond) {
|
|
56
88
|
return `aucune place libre : ${etat.prises.length} prises sur ${plafond}`;
|
|
57
89
|
}
|
|
58
|
-
|
|
90
|
+
// Under a reservation, only the waits of the night count for the turn: the others wait for it.
|
|
91
|
+
const avant = etat.attentes.find(
|
|
92
|
+
a => a.id !== id && a.rang < rang && (!reservation || (a.jeton ?? null) === reservation.jeton)
|
|
93
|
+
);
|
|
59
94
|
if (avant) {
|
|
60
95
|
return `place réservée : ${avant.ticket ?? 'un départ'} est arrivé avant et attend (${avant.raison})`;
|
|
61
96
|
}
|
|
@@ -73,6 +108,30 @@ export function refusDeLaPlace(etat, { id, rang, plafond, espacementMs, maintena
|
|
|
73
108
|
/** A place of a circuit not given by its project's queue for this long is gone, in ms: 10 min. */
|
|
74
109
|
export const PERIME_MS = 10 * 60_000;
|
|
75
110
|
|
|
111
|
+
/**
|
|
112
|
+
* The phase of the night on a state of the places: null without a reservation of the machine;
|
|
113
|
+
* `'attend'` while a place is held that is not one of the night's passes (the stages under way
|
|
114
|
+
* finish); `'en cours'` once none is.
|
|
115
|
+
* @param {{ prises: { jeton?: string | null }[], reservation?: { jeton: string } | null }} etat
|
|
116
|
+
* @returns {'attend' | 'en cours' | null}
|
|
117
|
+
*/
|
|
118
|
+
export function phaseDeLaNuit({ prises, reservation = null }) {
|
|
119
|
+
if (!reservation) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
return prises.some(p => (p.jeton ?? null) !== reservation.jeton) ? 'attend' : 'en cours';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Whether a reservation of the machine is out of date at <maintenant>: its last beat, the one the
|
|
127
|
+
* workflow of the nights renews, is PERIME_MS old, as a place of a circuit is.
|
|
128
|
+
* @param {{ battement: number }} reservation
|
|
129
|
+
* @param {number} maintenant
|
|
130
|
+
* @returns {boolean}
|
|
131
|
+
*/
|
|
132
|
+
export const reservationPerimee = (reservation, maintenant) =>
|
|
133
|
+
maintenant - reservation.battement >= PERIME_MS;
|
|
134
|
+
|
|
76
135
|
/**
|
|
77
136
|
* The places of the circuits of the machine once a demand comes, as Buildkite bounds its pipelines
|
|
78
137
|
* in one fleet of agents. The queue of the project <racine> gives its circuits active <vivants>
|
|
@@ -86,21 +145,46 @@ export const PERIME_MS = 10 * 60_000;
|
|
|
86
145
|
* the circuits that hold one are fewer than <plafond>: the first that waits keeps the next ones
|
|
87
146
|
* waiting, but a candidate short of disk, which waits with its reason and keeps no one. Gives the
|
|
88
147
|
* places, the last rank drawn, and the tickets of the demand that hold a place.
|
|
148
|
+
*
|
|
149
|
+
* Between the projects of one group (`grillhouse.groupe`, `groupe` its identity, absent out of a
|
|
150
|
+
* group), the priority orders the circuits that wait: each candidate carries its Beads priority and
|
|
151
|
+
* its creation (`priorites`), and the circuits not granted of one group share out their own ranks
|
|
152
|
+
* of arrival again by priority (P0 to P4), age, then rank. A circuit already granted keeps its
|
|
153
|
+
* place (a higher priority arriving later passes only the ones that wait), a project out of a
|
|
154
|
+
* group and the order of the groups between them keep the order of arrival.
|
|
89
155
|
* @param {Array<{ racine: string, ticket: string, rang: number, accordee: boolean, depuis: number,
|
|
90
|
-
* vu: number, reprise?: boolean, raison?: string | null
|
|
156
|
+
* vu: number, reprise?: boolean, raison?: string | null, priorite?: number, creation?: string,
|
|
157
|
+
* groupe?: string }>} places
|
|
91
158
|
* @param {{ racine: string, vivants?: string[], candidats?: string[], disque?: string | null,
|
|
92
|
-
* reprise?: { ticket: string, rang: number | null }
|
|
93
|
-
*
|
|
159
|
+
* reprise?: { ticket: string, rang: number | null }, groupe?: string,
|
|
160
|
+
* priorites?: Record<string, { priorite: number, creation: string }> }} demande
|
|
161
|
+
* @param {{ rang: number, plafond: number, maintenant: number, reservee?: boolean }} o `reservee`:
|
|
162
|
+
* the machine is reserved by the night, no place is given
|
|
94
163
|
*/
|
|
95
164
|
export function reserverDesCircuits(places, demande, o) {
|
|
96
|
-
const {
|
|
97
|
-
|
|
165
|
+
const {
|
|
166
|
+
racine,
|
|
167
|
+
vivants = [],
|
|
168
|
+
candidats = [],
|
|
169
|
+
disque = null,
|
|
170
|
+
reprise,
|
|
171
|
+
groupe,
|
|
172
|
+
priorites = {},
|
|
173
|
+
} = demande;
|
|
174
|
+
const { plafond, maintenant, reservee = false } = o;
|
|
98
175
|
let { rang } = o;
|
|
99
176
|
const siens = new Set([...vivants, ...candidats]);
|
|
100
177
|
const garde = c =>
|
|
101
178
|
maintenant - c.vu < PERIME_MS &&
|
|
102
179
|
(c.racine !== racine || siens.has(c.ticket) || Boolean(reprise) || (c.reprise && !c.accordee));
|
|
103
180
|
const circuits = places.filter(garde).map(c => ({ ...c }));
|
|
181
|
+
// What the demand says of a ticket's place: its group, its priority and its creation.
|
|
182
|
+
const dit = ticket => ({
|
|
183
|
+
...(groupe === undefined ? {} : { groupe }),
|
|
184
|
+
...(priorites[ticket] === undefined
|
|
185
|
+
? {}
|
|
186
|
+
: { priorite: priorites[ticket].priorite, creation: priorites[ticket].creation }),
|
|
187
|
+
});
|
|
104
188
|
const placer = (ticket, accordee, o2 = {}) => {
|
|
105
189
|
const c = circuits.find(x => x.racine === racine && x.ticket === ticket);
|
|
106
190
|
if (c) {
|
|
@@ -109,7 +193,7 @@ export function reserverDesCircuits(places, demande, o) {
|
|
|
109
193
|
if (accordee) {
|
|
110
194
|
c.reprise = false;
|
|
111
195
|
}
|
|
112
|
-
Object.assign(c, o2.maj ?? {});
|
|
196
|
+
Object.assign(c, dit(ticket), o2.maj ?? {});
|
|
113
197
|
return;
|
|
114
198
|
}
|
|
115
199
|
const r = o2.rang ?? (rang += 1);
|
|
@@ -121,6 +205,7 @@ export function reserverDesCircuits(places, demande, o) {
|
|
|
121
205
|
accordee,
|
|
122
206
|
depuis: maintenant,
|
|
123
207
|
vu: maintenant,
|
|
208
|
+
...dit(ticket),
|
|
124
209
|
...(o2.maj ?? {}),
|
|
125
210
|
});
|
|
126
211
|
};
|
|
@@ -132,9 +217,27 @@ export function reserverDesCircuits(places, demande, o) {
|
|
|
132
217
|
maj: { reprise: true, raison: null },
|
|
133
218
|
});
|
|
134
219
|
}
|
|
220
|
+
// The circuits not granted of each group share out their own ranks again, by priority, age, rank.
|
|
221
|
+
const sorte = c => [c.priorite ?? 2, Date.parse(c.creation ?? '') || 0, c.rang];
|
|
222
|
+
const parGroupe = Map.groupBy(
|
|
223
|
+
circuits.filter(c => !c.accordee && c.groupe !== undefined),
|
|
224
|
+
c => c.groupe
|
|
225
|
+
);
|
|
226
|
+
for (const attente of parGroupe.values()) {
|
|
227
|
+
const rangs = attente.map(c => c.rang).sort((a, b) => a - b);
|
|
228
|
+
attente
|
|
229
|
+
.toSorted((a, b) => {
|
|
230
|
+
const [x, y] = [sorte(a), sorte(b)];
|
|
231
|
+
return x[0] - y[0] || x[1] - y[1] || x[2] - y[2];
|
|
232
|
+
})
|
|
233
|
+
.forEach((c, i) => {
|
|
234
|
+
c.rang = rangs[i];
|
|
235
|
+
});
|
|
236
|
+
}
|
|
135
237
|
let tenues = circuits.filter(c => c.accordee).length;
|
|
136
238
|
for (const c of circuits.filter(x => !x.accordee).sort((a, b) => a.rang - b.rang)) {
|
|
137
|
-
|
|
239
|
+
// Under the reservation of the night no place is new: circuits alive keep theirs.
|
|
240
|
+
if (reservee || tenues >= plafond) {
|
|
138
241
|
break;
|
|
139
242
|
}
|
|
140
243
|
if (c.raison) {
|
|
@@ -12,12 +12,13 @@ export * from './langages.mjs';
|
|
|
12
12
|
// The services of the core to a module of language: the plan of an envelope, the progress of a
|
|
13
13
|
// pass and its measure, the tasks of the graph of the packages, the base of a pass, the pressure of the machine, its place and its lock, the last
|
|
14
14
|
// green, the arbitrages of a ticket, the source files of a project, the search of a command in the
|
|
15
|
-
// PATH.
|
|
15
|
+
// PATH, the copy of a template a project lacks.
|
|
16
16
|
export { arbitrageTranche, estArbitrage } from './arbitrages.mjs';
|
|
17
17
|
export { garderLeTotal, inscrireLePlan, ouvrirAvancement } from './avancement.mjs';
|
|
18
18
|
export { sources } from './sources.mjs';
|
|
19
19
|
export { trouverDansLePath } from './commandes-du-path.mjs';
|
|
20
20
|
export { paquetsSansPackageJson } from './paquet-npm.mjs';
|
|
21
|
+
export { poserLeGabaritAbsent } from './gabarit-absent.mjs';
|
|
21
22
|
export {
|
|
22
23
|
cheminsDeLaTache,
|
|
23
24
|
construireDepuisLesArguments,
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// The short name of a project on the displays shared between projects (the line of the places, the
|
|
2
|
+
// board of several projects): the key `grillhouse.sigle` of its package.json (grillhouse-1lf, the
|
|
3
|
+
// owner's word of 2026-11-12), else its ticket prefix (`issue-prefix` of .beads/config.yaml,
|
|
4
|
+
// ./prefixe-des-tickets.mjs). Read like the other keys `grillhouse.*` (./circuits-cles.mjs): as
|
|
5
|
+
// written, a faulty value is named by its key.
|
|
6
|
+
import { readFileSync } from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { prefixe } from './prefixe-des-tickets.mjs';
|
|
9
|
+
|
|
10
|
+
// Returns { sigle, faute }: `sigle` the short name declared, null when the key is absent, null or
|
|
11
|
+
// faulty; `faute` the fault by its key, null when the key reads.
|
|
12
|
+
export function lireSigle(pkg) {
|
|
13
|
+
const s = pkg?.grillhouse?.sigle;
|
|
14
|
+
if (s === undefined || s === null) {
|
|
15
|
+
return { sigle: null, faute: null };
|
|
16
|
+
}
|
|
17
|
+
if (typeof s !== 'string' || s === '' || /\s/.test(s)) {
|
|
18
|
+
return {
|
|
19
|
+
sigle: null,
|
|
20
|
+
faute: `grillhouse.sigle vaut ${JSON.stringify(s)}, pas une chaîne non vide sans espace.`,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return { sigle: s, faute: null };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The sigle of the project whose root is <racine>: `{ sigle, faute }`; the declared key, else its
|
|
28
|
+
* ticket prefix (the prefix also when the key is faulty, `faute` saying it); no sigle, and no
|
|
29
|
+
* throw, when neither reads.
|
|
30
|
+
* @param {string} racine
|
|
31
|
+
* @returns {{ sigle: string | null, faute: string | null }}
|
|
32
|
+
*/
|
|
33
|
+
export function sigleDuProjet(racine) {
|
|
34
|
+
let pkg = null;
|
|
35
|
+
try {
|
|
36
|
+
pkg = JSON.parse(readFileSync(path.join(racine, 'package.json'), 'utf8'));
|
|
37
|
+
} catch {
|
|
38
|
+
pkg = null;
|
|
39
|
+
}
|
|
40
|
+
const { sigle, faute } = lireSigle(pkg);
|
|
41
|
+
if (sigle) {
|
|
42
|
+
return { sigle, faute: null };
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
return { sigle: prefixe(racine), faute };
|
|
46
|
+
} catch {
|
|
47
|
+
return { sigle: null, faute };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -32,6 +32,7 @@ export const SOUS_COMMANDES = {
|
|
|
32
32
|
'attente-a-l-arret': 'attente-a-l-arret.mjs',
|
|
33
33
|
'attente-au-tour': 'attente-au-tour.mjs',
|
|
34
34
|
bilan: 'bilan.mjs',
|
|
35
|
+
binaires: 'binaires.mjs',
|
|
35
36
|
circuit: '../dist/temporal/circuit/commande.js',
|
|
36
37
|
commande: 'verrous/commande.mjs',
|
|
37
38
|
'composants-affectes': 'composants-affectes.mjs',
|
package/scripts/superviseur.mjs
CHANGED
|
@@ -134,18 +134,19 @@ export function horsAttente(tickets, maintenant) {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
// Of the tickets <ids> of the repository at <racine>, those whose question does not wait now
|
|
137
|
-
// (`horsAttente`);
|
|
137
|
+
// (`horsAttente`); null when bd does not read them (unknown, never « none »): a machine under
|
|
138
|
+
// load can take seconds to answer.
|
|
138
139
|
export function ticketsHorsAttente(racine, ids) {
|
|
139
140
|
const r = spawnSync('bd', ['show', ...ids, '--json'], {
|
|
140
141
|
cwd: racine,
|
|
141
142
|
encoding: 'utf8',
|
|
142
|
-
timeout:
|
|
143
|
+
timeout: 30_000,
|
|
143
144
|
maxBuffer: 256 * 1024 * 1024,
|
|
144
145
|
});
|
|
145
146
|
try {
|
|
146
147
|
return horsAttente(JSON.parse(r.stdout), Date.now());
|
|
147
148
|
} catch {
|
|
148
|
-
return
|
|
149
|
+
return null;
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
|
|
@@ -293,10 +294,15 @@ function relever(racine, circuits, { fermes, maintenant, rappelMs, toutes = fals
|
|
|
293
294
|
aRendre.map(q => q.ticket)
|
|
294
295
|
)
|
|
295
296
|
: new Set();
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const
|
|
297
|
+
// Tickets that do not read: nothing is given at this reading, nor counted presented, so that
|
|
298
|
+
// the next reading that reads them gives what still waits.
|
|
299
|
+
const lisible = fermesDe !== null;
|
|
300
|
+
const rendu = lisible
|
|
301
|
+
? aRendre
|
|
302
|
+
.filter(q => !fermesDe.has(q.ticket))
|
|
303
|
+
.map(q => (avant.has(q.cle) && !toutes ? { ...q, representee: true } : q))
|
|
304
|
+
: [];
|
|
305
|
+
const presentes = new Set(lisible ? aRendre.map(q => q.cle) : []);
|
|
300
306
|
const enTexte = liste =>
|
|
301
307
|
`${JSON.stringify(
|
|
302
308
|
{
|
|
@@ -307,15 +313,18 @@ function relever(racine, circuits, { fermes, maintenant, rappelMs, toutes = fals
|
|
|
307
313
|
null,
|
|
308
314
|
2
|
|
309
315
|
)}\n`;
|
|
316
|
+
// A question never presented, its ticket unread, is not written: the next reading gives it.
|
|
310
317
|
const ecrit = enTexte(
|
|
311
|
-
debout
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
318
|
+
debout
|
|
319
|
+
.filter(q => presentes.has(q.cle) || avant.has(q.cle))
|
|
320
|
+
.map(q => {
|
|
321
|
+
const r = avant.get(q.cle);
|
|
322
|
+
return {
|
|
323
|
+
cle: q.cle,
|
|
324
|
+
depuis: r?.depuis ?? maintenant,
|
|
325
|
+
presentee: presentes.has(q.cle) ? maintenant : r.presentee,
|
|
326
|
+
};
|
|
327
|
+
})
|
|
319
328
|
);
|
|
320
329
|
let enFichier = '';
|
|
321
330
|
try {
|
|
@@ -370,6 +379,10 @@ function enAttente(lus, racine, fermes) {
|
|
|
370
379
|
lus.map(c => c.ticket)
|
|
371
380
|
)
|
|
372
381
|
: new Set();
|
|
382
|
+
// Tickets that do not read: no question can be told waiting, none is.
|
|
383
|
+
if (ferme === null) {
|
|
384
|
+
return [];
|
|
385
|
+
}
|
|
373
386
|
return lus
|
|
374
387
|
.filter(c => !ferme.has(c.ticket))
|
|
375
388
|
.sort((a, b) => a.ticket.localeCompare(b.ticket, 'en'));
|
|
@@ -386,7 +399,7 @@ function enAttente(lus, racine, fermes) {
|
|
|
386
399
|
* its circuit ended without its issue (`interrompu`) and its stop (`arret`).
|
|
387
400
|
* @param {string} racine the root of the repository
|
|
388
401
|
* @param {import('./circuits-du-serveur.mjs').CircuitDuServeur[]} circuits
|
|
389
|
-
* @param {{ fermes?: (racine: string, ids: string[]) => Set<string
|
|
402
|
+
* @param {{ fermes?: (racine: string, ids: string[]) => Set<string> | null, sauf?: Set<string> }} options
|
|
390
403
|
* @returns {{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string, interrompu: boolean, arret: string | null }[]}
|
|
391
404
|
*/
|
|
392
405
|
export function questionsEnAttente(
|
|
@@ -425,7 +438,7 @@ const aucunFerme = () => new Set();
|
|
|
425
438
|
* <fluxRouges>: bd by default) is given as a batch of its own, once per run (`adresse`: the
|
|
426
439
|
* workflow, the URL of the run, the commit), and again at another run; taken up or closed, it is
|
|
427
440
|
* no longer given.
|
|
428
|
-
* @param {{ racine: string, fermes?: (racine: string, ids: string[]) => Set<string
|
|
441
|
+
* @param {{ racine: string, fermes?: (racine: string, ids: string[]) => Set<string> | null, pas?: number, signal?: AbortSignal, circuitsDe?: (racine: string, options?: { integres?: boolean }) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]>, fluxRouges?: (racine: string) => { ticket: string, adresse: string }[] | Promise<{ ticket: string, adresse: string }[]>, maintenant?: () => number, rappel?: number }} options
|
|
429
442
|
* @returns {Promise<{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string, representee?: boolean, integre?: boolean }[]>}
|
|
430
443
|
* @throws {Error} another wait runs
|
|
431
444
|
*/
|
|
@@ -601,7 +614,7 @@ export function texteDesQuestions(questions) {
|
|
|
601
614
|
* The circuits are read once, by <circuitsDe> (one call to the Temporal server,
|
|
602
615
|
* scripts/circuits-du-serveur.mjs, by default); a server that does not answer is said, and no
|
|
603
616
|
* question goes up.
|
|
604
|
-
* @param {{ fermes?: (racine: string, ids: string[]) => Set<string
|
|
617
|
+
* @param {{ fermes?: (racine: string, ids: string[]) => Set<string> | null,
|
|
605
618
|
* circuitsDe?: (racine: string) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]>,
|
|
606
619
|
* ticketsDe?: (racine: string) => import('./file-des-tickets.mjs').TicketDeBeads[] }} options
|
|
607
620
|
* @returns {Promise<string>}
|