@roomi-fields/grillhouse 0.29.0 → 0.31.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 +769 -0
- package/agents/developpeur.md +0 -1
- package/agents/explorateur.md +0 -1
- package/agents/questionneur.md +0 -1
- package/agents/testwriter.md +0 -1
- package/bin/grillhouse.mjs +79 -18
- package/cadre/templates/projet/.github/workflows/ci.yml +2 -13
- package/cadre/templates/projet/CLAUDE.md +5 -1
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/cadre/templates/projet/package.json +2 -2
- package/charte.md +24 -0
- package/dist/temporal/acte.d.ts +24 -0
- package/dist/temporal/acte.js +139 -0
- package/dist/temporal/acte.js.map +1 -0
- package/dist/temporal/attributs.d.ts +6 -0
- package/dist/temporal/attributs.js +15 -0
- package/dist/temporal/attributs.js.map +1 -0
- package/dist/temporal/circuit/activites.d.ts +13 -0
- package/dist/temporal/circuit/activites.js +33 -0
- package/dist/temporal/circuit/activites.js.map +1 -0
- package/dist/temporal/circuit/client.d.ts +72 -0
- package/dist/temporal/circuit/client.js +247 -0
- package/dist/temporal/circuit/client.js.map +1 -0
- package/dist/temporal/circuit/commande.d.ts +2 -0
- package/dist/temporal/circuit/commande.js +238 -0
- package/dist/temporal/circuit/commande.js.map +1 -0
- package/dist/temporal/circuit/contrat.d.ts +305 -0
- package/dist/temporal/circuit/contrat.js +30 -0
- package/dist/temporal/circuit/contrat.js.map +1 -0
- package/dist/temporal/circuit/deroule.d.ts +3 -0
- package/dist/temporal/circuit/deroule.js +540 -0
- package/dist/temporal/circuit/deroule.js.map +1 -0
- package/dist/temporal/client.d.ts +47 -0
- package/dist/temporal/client.js +69 -0
- package/dist/temporal/client.js.map +1 -0
- package/dist/temporal/commande.d.ts +2 -0
- package/dist/temporal/commande.js +94 -0
- package/dist/temporal/commande.js.map +1 -0
- package/dist/temporal/deroules.d.ts +5 -0
- package/dist/temporal/deroules.js +10 -0
- package/dist/temporal/deroules.js.map +1 -0
- package/dist/temporal/etat.d.ts +33 -0
- package/dist/temporal/etat.js +59 -0
- package/dist/temporal/etat.js.map +1 -0
- package/dist/temporal/file/activites.d.ts +10 -0
- package/dist/temporal/file/activites.js +25 -0
- package/dist/temporal/file/activites.js.map +1 -0
- package/dist/temporal/file/client.d.ts +4 -0
- package/dist/temporal/file/client.js +6 -0
- package/dist/temporal/file/client.js.map +1 -0
- package/dist/temporal/file/contrat.d.ts +158 -0
- package/dist/temporal/file/contrat.js +14 -0
- package/dist/temporal/file/contrat.js.map +1 -0
- package/dist/temporal/file/deroule.d.ts +15 -0
- package/dist/temporal/file/deroule.js +235 -0
- package/dist/temporal/file/deroule.js.map +1 -0
- package/dist/temporal/installation.d.ts +120 -0
- package/dist/temporal/installation.js +386 -0
- package/dist/temporal/installation.js.map +1 -0
- package/dist/temporal/places/activites.d.ts +8 -0
- package/dist/temporal/places/activites.js +13 -0
- package/dist/temporal/places/activites.js.map +1 -0
- package/dist/temporal/places/client.d.ts +28 -0
- package/dist/temporal/places/client.js +64 -0
- package/dist/temporal/places/client.js.map +1 -0
- package/dist/temporal/places/contrat.d.ts +106 -0
- package/dist/temporal/places/contrat.js +21 -0
- package/dist/temporal/places/contrat.js.map +1 -0
- package/dist/temporal/places/deroule.d.ts +3 -0
- package/dist/temporal/places/deroule.js +198 -0
- package/dist/temporal/places/deroule.js.map +1 -0
- package/dist/temporal/sonde/activites.d.ts +6 -0
- package/dist/temporal/sonde/activites.js +52 -0
- package/dist/temporal/sonde/activites.js.map +1 -0
- package/dist/temporal/sonde/contrat.d.ts +35 -0
- package/dist/temporal/sonde/contrat.js +10 -0
- package/dist/temporal/sonde/contrat.js.map +1 -0
- package/dist/temporal/sonde/deroule.d.ts +3 -0
- package/dist/temporal/sonde/deroule.js +39 -0
- package/dist/temporal/sonde/deroule.js.map +1 -0
- package/dist/temporal/tickets/activites.d.ts +7 -0
- package/dist/temporal/tickets/activites.js +81 -0
- package/dist/temporal/tickets/activites.js.map +1 -0
- package/dist/temporal/tickets/client.d.ts +10 -0
- package/dist/temporal/tickets/client.js +31 -0
- package/dist/temporal/tickets/client.js.map +1 -0
- package/dist/temporal/tickets/contrat.d.ts +56 -0
- package/dist/temporal/tickets/contrat.js +13 -0
- package/dist/temporal/tickets/contrat.js.map +1 -0
- package/dist/temporal/tickets/deroule.d.ts +3 -0
- package/dist/temporal/tickets/deroule.js +94 -0
- package/dist/temporal/tickets/deroule.js.map +1 -0
- package/dist/temporal/travailleur.d.ts +2 -0
- package/dist/temporal/travailleur.js +69 -0
- package/dist/temporal/travailleur.js.map +1 -0
- package/docs/ARCHITECTURE.md +646 -87
- package/docs/CADRE.md +27 -0
- package/docs/INTERFACE.md +139 -42
- package/hooks/crochet.mjs +19 -2
- package/hooks/hooks.json +11 -0
- package/package.json +16 -4
- package/scripts/activites.mjs +2255 -0
- package/scripts/aiguillage.d.mts +37 -0
- package/scripts/aiguillage.mjs +40 -14
- package/scripts/avancement.mjs +155 -26
- package/scripts/bilan.mjs +137 -43
- package/scripts/cadre.mjs +16 -4
- package/scripts/circuit.mjs +993 -4075
- package/scripts/circuits-cles.d.mts +4 -0
- package/scripts/circuits-cles.mjs +21 -0
- package/scripts/circuits-du-serveur.mjs +105 -0
- package/scripts/codes-de-sortie.mjs +9 -0
- package/scripts/commandes-composees.mjs +45 -41
- package/scripts/commandes-du-path.d.mts +7 -0
- package/scripts/commandes-du-path.mjs +25 -0
- package/scripts/composants-affectes.mjs +64 -21
- package/scripts/composition-des-langages.mjs +18 -12
- package/scripts/conformite.mjs +56 -28
- package/scripts/copies-finies.mjs +52 -47
- package/scripts/depart-du-ticket.d.mts +53 -0
- package/scripts/depart-du-ticket.mjs +124 -0
- package/scripts/dependances-internes.mjs +121 -0
- package/scripts/dernier-vert.mjs +61 -34
- package/scripts/dette.mjs +32 -11
- package/scripts/donnees-cles.mjs +244 -0
- package/scripts/droits.mjs +51 -16
- package/scripts/effets.mjs +352 -0
- package/scripts/empreinte-d-etape.mjs +17 -0
- package/scripts/engendres.mjs +15 -5
- package/scripts/enveloppe/enveloppe.mjs +259 -55
- package/scripts/enveloppe/lancer.sh +14 -18
- package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
- package/scripts/enveloppe/travail-de-la-copie.mjs +41 -13
- package/scripts/etapes.mjs +5 -2
- package/scripts/faits-du-circuit.mjs +493 -0
- package/scripts/file-des-tickets.d.mts +21 -0
- package/scripts/file-des-tickets.mjs +58 -0
- package/scripts/flux-des-paquets.mjs +201 -0
- package/scripts/gardes-du-cadre.mjs +21 -5
- package/scripts/init.mjs +11 -4
- package/scripts/integration/file.mjs +544 -434
- package/scripts/integration/integrer.mjs +87 -43
- package/scripts/integration/rejeu.mjs +45 -13
- package/scripts/jointure.d.ts +151 -28
- package/scripts/langages/cargo/commandes.mjs +383 -124
- package/scripts/langages/cargo/composants.mjs +154 -42
- package/scripts/langages/cargo/exemples.mjs +12 -21
- package/scripts/langages/cargo/index.mjs +22 -8
- package/scripts/langages/cargo/sccache.mjs +8 -14
- package/scripts/langages/cargo/tests-de-head.mjs +25 -9
- package/scripts/langages/python/commandes.mjs +218 -100
- package/scripts/langages/python/composants.mjs +53 -21
- package/scripts/langages/python/exemples.mjs +6 -16
- package/scripts/langages/python/index.mjs +28 -8
- package/scripts/langages/python/lot.mjs +1 -36
- package/scripts/langages/typescript/chemins-des-tests.mjs +6 -2
- package/scripts/langages/typescript/composants.mjs +9 -3
- package/scripts/langages/typescript/consommateurs-arbitres.mjs +40 -14
- package/scripts/langages/typescript/consommateurs.mjs +39 -14
- package/scripts/langages/typescript/construire.mjs +6 -163
- package/scripts/langages/typescript/elements-du-lot.mjs +36 -12
- package/scripts/langages/typescript/exemples.mjs +3 -11
- package/scripts/langages/typescript/frontieres.mjs +66 -22
- package/scripts/langages/typescript/index-interfaces.mjs +36 -13
- package/scripts/langages/typescript/index.mjs +50 -61
- package/scripts/langages/typescript/interfaces-contre-code.mjs +113 -45
- package/scripts/langages/typescript/lecteurs.mjs +36 -11
- package/scripts/langages/typescript/migrations/0.23.0-config-vitest.mjs +15 -5
- package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +6 -2
- package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +6 -2
- package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
- package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +33 -0
- package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
- package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
- package/scripts/langages/typescript/parcours.mjs +12 -4
- package/scripts/langages/typescript/regle-des-tests.mjs +9 -3
- package/scripts/langages/typescript/resumes.mjs +9 -3
- package/scripts/langages/typescript/tailles-des-tests.mjs +93 -20
- package/scripts/langages/typescript/tests-de-nuit.mjs +15 -10
- package/scripts/langages/typescript/tests.mjs +40 -15
- package/scripts/langages/typescript/titres-de-tests.mjs +320 -0
- package/scripts/langages/typescript/turbo-des-paquets.mjs +327 -81
- package/scripts/langages/typescript/verdict.mjs +4 -2
- package/scripts/langages/typescript/verifier.mjs +58 -20
- package/scripts/langages/typescript/vitest-config/avancement.reporter.mjs +15 -5
- package/scripts/langages/typescript/vitest-config/base.mjs +29 -3
- package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
- package/scripts/langages/typescript/vitest-config/changements.mjs +21 -8
- package/scripts/langages/typescript/vitest-config/cibles.mjs +36 -14
- package/scripts/langages/typescript/vitest-config/delais.mjs +60 -0
- package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
- package/scripts/langages/typescript/vitest-config/duree.classement.mjs +108 -0
- package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +56 -59
- package/scripts/langages/typescript/vitest-config/lances.mjs +83 -27
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +10 -0
- package/scripts/langages/typescript/vitest-config/resultats.mjs +3 -1
- package/scripts/langages/typescript/vitest.nuit.config.mjs +4 -0
- package/scripts/lint-des-scripts.mjs +58 -0
- package/scripts/mesure/base-de-passe.mjs +117 -25
- package/scripts/mesure/pression.mjs +12 -6
- package/scripts/mesure-de-la-machine.d.mts +21 -0
- package/scripts/mesure-de-la-machine.mjs +76 -0
- package/scripts/migrations/0.23.0-charte-importee.mjs +6 -2
- package/scripts/migrations/0.23.0-crochets-de-seance.mjs +25 -8
- package/scripts/migrations/0.23.0-marche-du-projet.mjs +18 -6
- package/scripts/migrations/0.23.2-copies-du-cadre.mjs +56 -18
- package/scripts/migrations/0.24.12-tri-des-decouvertes.mjs +6 -2
- package/scripts/migrations/0.25.0-script-des-tests.mjs +15 -5
- package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +124 -0
- package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
- package/scripts/migrations.mjs +5 -0
- package/scripts/nuit.sh +25 -3
- package/scripts/outil.mjs +3 -1
- package/scripts/outils-cles.d.mts +24 -0
- package/scripts/outils-cles.mjs +18 -8
- package/scripts/paquet-npm.mjs +157 -0
- package/scripts/paquet.mjs +73 -4
- package/scripts/paquets.mjs +46 -10
- package/scripts/passe-de-la-machine.mjs +71 -0
- package/scripts/places-de-la-machine.mjs +414 -0
- package/scripts/places-du-serveur.mjs +170 -0
- package/scripts/prefixe-des-tickets.mjs +68 -0
- package/scripts/preparation.mjs +25 -8
- package/scripts/registre.mjs +9 -4
- package/scripts/regles-des-places.d.mts +36 -0
- package/scripts/regles-des-places.mjs +70 -0
- package/scripts/reponses-du-circuit.d.mts +6 -0
- package/scripts/reponses-du-circuit.mjs +28 -0
- package/scripts/reprise.mjs +66 -0
- package/scripts/resultats.mjs +112 -46
- package/scripts/retirer-les-copies-finies.mjs +25 -0
- package/scripts/sans-reponse.d.mts +4 -0
- package/scripts/sans-reponse.mjs +13 -0
- package/scripts/seances.mjs +936 -0
- package/scripts/services-du-noyau.mjs +27 -8
- package/scripts/session-start.sh +2 -2
- package/scripts/sortie.mjs +3 -3
- package/scripts/sous-commandes.mjs +41 -10
- package/scripts/style-a-l-ecriture.mjs +260 -0
- package/scripts/superviseur.mjs +122 -111
- package/scripts/tableau.mjs +180 -117
- package/scripts/taches-du-graphe.mjs +348 -0
- package/scripts/ticket-du-circuit.mjs +216 -0
- package/scripts/transitions.d.mts +148 -0
- package/scripts/transitions.mjs +1018 -0
- package/scripts/verrou-de-fichier.mjs +8 -4
- package/scripts/verrou-de-machine.mjs +150 -51
- package/scripts/verrous/commande.mjs +50 -17
- package/scripts/verrous/ticket-du-sous-agent.mjs +9 -3
- package/scripts/verrous/verrou.mjs +42 -14
- package/skills/explorateur/SKILL.md +9 -2
- package/skills/grill/SKILL.md +1 -1
- package/skills/mesure/SKILL.md +3 -0
- package/skills/pitmaster/SKILL.md +17 -18
- package/skills/pitmaster/references/consigne-agent.md +5 -1
- package/skills/release/SKILL.md +3 -3
- package/skills/relecteur/SKILL.md +5 -3
- package/skills/testwriter/SKILL.md +49 -31
- package/scripts/demon.mjs +0 -251
- package/scripts/integration/file-attente.mjs +0 -61
- package/scripts/langages/cargo/touches.mjs +0 -93
- package/scripts/langages/typescript/script-des-tests.mjs +0 -6
|
@@ -57,6 +57,7 @@ import { existsSync, rmSync, statSync, writeFileSync, writeSync } from 'node:fs'
|
|
|
57
57
|
import path from 'node:path';
|
|
58
58
|
import { pathToFileURL } from 'node:url';
|
|
59
59
|
import { couvertPar, engendresDe, regenerer, touchesPar } from '../engendres.mjs';
|
|
60
|
+
import { avecLesDonnees, donneesDe } from '../donnees-cles.mjs';
|
|
60
61
|
import { avecLesOutils, outilsDe } from '../outils-cles.mjs';
|
|
61
62
|
|
|
62
63
|
const LOT = 'grillhouse-travail.patch';
|
|
@@ -89,7 +90,10 @@ const fichiersDuLot = (copie, lot) =>
|
|
|
89
90
|
*/
|
|
90
91
|
function lesCles(copie) {
|
|
91
92
|
try {
|
|
92
|
-
return {
|
|
93
|
+
return {
|
|
94
|
+
engendres: engendresDe(copie),
|
|
95
|
+
env: avecLesDonnees(donneesDe(copie), avecLesOutils(outilsDe(copie), process.env)),
|
|
96
|
+
};
|
|
93
97
|
} catch (e) {
|
|
94
98
|
return {
|
|
95
99
|
refus: `⛔ Une clé grillhouse du package.json est refusée :\n${/** @type {Error} */ (e).message}`,
|
|
@@ -118,8 +122,12 @@ function appliquer(copie, lot, cles = null, autres = []) {
|
|
|
118
122
|
lot
|
|
119
123
|
);
|
|
120
124
|
const conflits = enConflit(copie);
|
|
121
|
-
if (r.status !== 0 && !conflits.length)
|
|
122
|
-
|
|
125
|
+
if (r.status !== 0 && !conflits.length) {
|
|
126
|
+
return { conflits: null };
|
|
127
|
+
}
|
|
128
|
+
if (conflits.length || !touches.length || !cles) {
|
|
129
|
+
return { conflits };
|
|
130
|
+
}
|
|
123
131
|
const refus = regenerer({
|
|
124
132
|
refs: touches.map(e => ({ ...e, cadre: false })),
|
|
125
133
|
lancer: commande =>
|
|
@@ -145,13 +153,17 @@ export function reporter(copie, { base, pointe }) {
|
|
|
145
153
|
return { ok: false, message: `⛔ Le lot de ${base} à ${pointe} ne se lit pas : ${texte(d)}` };
|
|
146
154
|
}
|
|
147
155
|
const cles = lesCles(copie);
|
|
148
|
-
if (cles.refus !== undefined)
|
|
156
|
+
if (cles.refus !== undefined) {
|
|
157
|
+
return { ok: false, message: cles.refus };
|
|
158
|
+
}
|
|
149
159
|
const a = appliquer(copie, d.stdout, cles);
|
|
150
160
|
if (a.conflits === null) {
|
|
151
161
|
return { ok: false, message: `⛔ Le lot ne s'applique pas à la copie ${copie}.` };
|
|
152
162
|
}
|
|
153
163
|
const r = git(copie, ['reset', '-q']);
|
|
154
|
-
if (a.refus)
|
|
164
|
+
if (a.refus) {
|
|
165
|
+
return { ok: false, message: `⛔ ${a.refus}` };
|
|
166
|
+
}
|
|
155
167
|
return r.status === 0 ? { ok: true, message: '' } : { ok: false, message: texte(r) };
|
|
156
168
|
}
|
|
157
169
|
|
|
@@ -186,7 +198,9 @@ export function avancer(copie, cible) {
|
|
|
186
198
|
};
|
|
187
199
|
}
|
|
188
200
|
const cles = lesCles(copie);
|
|
189
|
-
if (cles.refus !== undefined)
|
|
201
|
+
if (cles.refus !== undefined) {
|
|
202
|
+
return { ok: false, message: cles.refus };
|
|
203
|
+
}
|
|
190
204
|
const tete = String(git(copie, ['rev-parse', 'HEAD']).stdout).trim();
|
|
191
205
|
const vise = git(copie, ['rev-parse', '--verify', `${cible}^{commit}`]);
|
|
192
206
|
if (vise.status !== 0) {
|
|
@@ -282,7 +296,9 @@ export function preparer(copie, cible, { env = process.env, sortie = 2 } = {}) {
|
|
|
282
296
|
stdio,
|
|
283
297
|
maxBuffer: 64 * 1024 * 1024,
|
|
284
298
|
});
|
|
285
|
-
if (r.status === 0 && r.stderr?.length)
|
|
299
|
+
if (r.status === 0 && r.stderr?.length) {
|
|
300
|
+
writeSync(sortie, r.stderr);
|
|
301
|
+
}
|
|
286
302
|
return r;
|
|
287
303
|
};
|
|
288
304
|
const echec = (r, quoi) => ({
|
|
@@ -292,18 +308,26 @@ export function preparer(copie, cible, { env = process.env, sortie = 2 } = {}) {
|
|
|
292
308
|
});
|
|
293
309
|
if (cible !== null) {
|
|
294
310
|
const g = bash(['garde', copie], ['ignore', sortie, 'pipe']);
|
|
295
|
-
if (g.status !== 0)
|
|
311
|
+
if (g.status !== 0) {
|
|
312
|
+
return echec(g, 'La garde des sous-modules');
|
|
313
|
+
}
|
|
296
314
|
const a = avancer(copie, cible);
|
|
297
|
-
if (!a.ok)
|
|
315
|
+
if (!a.ok) {
|
|
316
|
+
return { ...a, partages: '' };
|
|
317
|
+
}
|
|
298
318
|
}
|
|
299
319
|
const p = bash(['pose', copie], ['ignore', 'pipe', 'pipe']);
|
|
300
|
-
if (p.status !== 0)
|
|
320
|
+
if (p.status !== 0) {
|
|
321
|
+
return echec(p, 'La pose des sous-modules');
|
|
322
|
+
}
|
|
301
323
|
// As `$(…)` reads it: the final newlines dropped.
|
|
302
324
|
const partages = String(p.stdout).replace(/\n+$/, '');
|
|
303
325
|
const monter = (...commande) =>
|
|
304
326
|
bash(['monter', copie, '--partages', partages, ...commande], ['ignore', sortie, 'pipe']);
|
|
305
327
|
const m = monter('true');
|
|
306
|
-
if (m.status !== 0)
|
|
328
|
+
if (m.status !== 0) {
|
|
329
|
+
return echec(m, 'Le montage des sous-modules partagés');
|
|
330
|
+
}
|
|
307
331
|
if (existsSync(path.join(copie, 'package.json'))) {
|
|
308
332
|
// As `[ lock -nt installed ]`: the lock newer than the installation, or no installation.
|
|
309
333
|
const verrou = path.join(copie, 'package-lock.json');
|
|
@@ -323,7 +347,9 @@ export function preparer(copie, cible, { env = process.env, sortie = 2 } = {}) {
|
|
|
323
347
|
'--no-fund',
|
|
324
348
|
'--silent'
|
|
325
349
|
);
|
|
326
|
-
if (i.status !== 0)
|
|
350
|
+
if (i.status !== 0) {
|
|
351
|
+
return echec(i, "L'installation");
|
|
352
|
+
}
|
|
327
353
|
}
|
|
328
354
|
}
|
|
329
355
|
return { ok: true, message: '', partages };
|
|
@@ -343,7 +369,9 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
|
|
|
343
369
|
};
|
|
344
370
|
// `preparer` prints the list its pose fixes on stdout, its messages on stderr.
|
|
345
371
|
if (geste === 'preparer') {
|
|
346
|
-
if (r.message)
|
|
372
|
+
if (r.message) {
|
|
373
|
+
process.stderr.write(`${r.message}\n`);
|
|
374
|
+
}
|
|
347
375
|
process.stdout.write(r.partages ?? '');
|
|
348
376
|
} else if (r.message) {
|
|
349
377
|
process.stdout.write(`${r.message}\n`);
|
package/scripts/etapes.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// - A step (ETAPES): its number (« 2 », « 4.1 »), its title, who works there (`qui`: the role
|
|
7
7
|
// agents, or AUTO for a step the circuit leads itself; none for a step that only holds its
|
|
8
8
|
// sub-steps), its sub-steps (`sous`), and the step of the circuit's state it is (`etat`: the
|
|
9
|
-
// `etape` of
|
|
9
|
+
// `etape` of the state the circuit writes, which the workflow of its ticket holds, the final pass being the checks once
|
|
10
10
|
// `finale`). Every step runs once for the whole ticket, as a merge request has one author of
|
|
11
11
|
// its tests and one of its code, one CI on the whole and one review: one session of the
|
|
12
12
|
// testwriter (2) and one of the developpeur (3) carry the whole plan.
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
// with no session.
|
|
31
31
|
// - The question of each other stop (MONTEES, below): what goes up to the supervisor, and who
|
|
32
32
|
// must answer it.
|
|
33
|
-
import { A_REPASSER } from './
|
|
33
|
+
import { A_REPASSER } from './codes-de-sortie.mjs';
|
|
34
34
|
|
|
35
35
|
// Who works at a step the circuit leads itself, with no agent.
|
|
36
36
|
export const AUTO = 'auto';
|
|
@@ -136,6 +136,7 @@ export const ARRETS = {
|
|
|
136
136
|
questionnement: 22,
|
|
137
137
|
references: 23,
|
|
138
138
|
'hors-plan': 24,
|
|
139
|
+
inattendu: 25,
|
|
139
140
|
'a-repasser': A_REPASSER,
|
|
140
141
|
};
|
|
141
142
|
|
|
@@ -276,6 +277,8 @@ export const MONTEES = Object.fromEntries(
|
|
|
276
277
|
'La régénération des références change un fichier qu’aucune référence n’écrit, ou sa commande échoue (ses écarts ci-dessus) : qui corrige la référence ou le lot ?',
|
|
277
278
|
'hors-plan':
|
|
278
279
|
'La séance écrit hors du plan du ticket : le plan s’étend-il à ce paquet (`--etendre`), ou l’écriture est-elle refusée (`--reprendre` avec son contexte) ?',
|
|
280
|
+
inattendu:
|
|
281
|
+
'Une exception que le circuit ne prévoit pas (une lecture de la copie, une commande, un fichier illisible) l’a arrêté : sa cause se lève-t-elle, pour reprendre (`--reprendre`, qui écrit de nouveau cet arrêt si la cause reste), ou le circuit s’arrête-t-il ?',
|
|
279
282
|
}).map(([arret, question]) => [arret, { question: `${question} ${REPONSES}`, qui: SUPERVISEUR }])
|
|
280
283
|
);
|
|
281
284
|
|
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// One act of the circuit of a ticket for its workflow under Temporal (src/temporal/circuit/), in a
|
|
3
|
+
// process of its own, as Buildkite's agent and GitLab's runner play each job in a child process:
|
|
4
|
+
// the circuit's code waits on its passes synchronously, so the worker that awaits this process
|
|
5
|
+
// keeps serving, and sends its heartbeats, while the act plays. The worker's activities
|
|
6
|
+
// (src/temporal/circuit/activites.ts) start it in the main tree of the repository:
|
|
7
|
+
//
|
|
8
|
+
// node scripts/faits-du-circuit.mjs <acte> (its input in JSON on the standard input)
|
|
9
|
+
//
|
|
10
|
+
// Each sign of life of a session goes out as a line `vie <json>`, and the act's outcome as the
|
|
11
|
+
// last line, `resultat <json>`. SIGTERM cancels the act: the session it leads ends, its group
|
|
12
|
+
// killed (scripts/seances.mjs). The act ends with its worker: once the worker is gone, it exits
|
|
13
|
+
// at once, the group of its session left running, which the attempt played again waits for.
|
|
14
|
+
//
|
|
15
|
+
// The acts of a ticket write nothing outside themselves (docs/ARCHITECTURE.md, « une activité, un
|
|
16
|
+
// effet, une clé »): each gathers the effects the circuit's code emits (scripts/effets.mjs) and
|
|
17
|
+
// gives them back with its outcome (`effets`), its own readings seeing those it already emitted;
|
|
18
|
+
// the workflow then plays each one in an activity of its own, the act `effet`, under the key of
|
|
19
|
+
// that activity (`cle`: its workflow, its run, its activity, the same for each of its attempts).
|
|
20
|
+
// A fact (the act `fait`) is read again on an attempt played again: a reading, a measure, a pass
|
|
21
|
+
// of the checks, a regeneration and the integration (no second commit for a lot already in the
|
|
22
|
+
// queue) replay without harm. Under the opening and a fact, a session draws its id from the key of
|
|
23
|
+
// its activity, its event and the attempt of the activity (`idDeSeance` of scripts/seances.mjs,
|
|
24
|
+
// `<séance>-e<essai>`), and ranges its result under it (`rangDeLaSeance`). Only an attempt Temporal plays again (its
|
|
25
|
+
// attempt 2 or more, `essai`), at the launch the dead attempt made last, takes the result of a
|
|
26
|
+
// session the dead attempt launched in its envelope once its group has ended, with no second
|
|
27
|
+
// session (scripts/seances.mjs `lancer`); a session out of the envelope (the explorateur's, the
|
|
28
|
+
// questionneur's, the reviewer's), which writes nothing in the lot, is launched again. The acts of
|
|
29
|
+
// the queue of a project follow the same model: each of their gestures replays without harm (main
|
|
30
|
+
// moved onto a lot already on main enters it, a ticket closed stays closed, a commit pushed is
|
|
31
|
+
// pushed again as it is), and their comments are effects they give back, which the workflow of
|
|
32
|
+
// the queue writes one per activity (`effet-de-la-file`).
|
|
33
|
+
//
|
|
34
|
+
// The acts, each on the context the circuit builds for a run (`contexte` of scripts/circuit.mjs)
|
|
35
|
+
// and the memory the workflow holds:
|
|
36
|
+
//
|
|
37
|
+
// - `ouvrir`, the opening of a run up to its plan (`ouvrirJusquAuPlan`), first or on the
|
|
38
|
+
// supervisor's answer to a stop, the state of a circuit stopped on his word read from its file;
|
|
39
|
+
// - `plan`, one step of the plan (`unPasDuPlan`: the explorateur, the questionneur, the answer,
|
|
40
|
+
// the conclusion playing with the last), which the workflow decides (`pasDuPlan`);
|
|
41
|
+
// - `preparer`, the start of a step (`commencerLEtape`) and the copy prepared on the tip of main
|
|
42
|
+
// before its pass (`avantLaPasse`);
|
|
43
|
+
// - `fait`, the fact a decision asks for (`lireLeFait`), an Arret it raises given back as such;
|
|
44
|
+
// - `effets`, the effects of a decision (`appliquer`), then the end of its step (`finirLEtape`);
|
|
45
|
+
// - `arret`, a stop written (`publierLArret`), its question gone up (`monter`) unless it is a
|
|
46
|
+
// « a-repasser » the workflow plays again, the end of its step, then the end of the run
|
|
47
|
+
// (`aLaFin`);
|
|
48
|
+
// - `fin`, the end of a run integrated; `arreter`, the stop on the supervisor's word (`arreter`);
|
|
49
|
+
// - `effet`, one effect an act gave back, written under the key of its activity (`ecrireLEffet`):
|
|
50
|
+
// an effect not written has its outcome, said on the error output or the failure of its
|
|
51
|
+
// activity;
|
|
52
|
+
// - the acts of the queue of a project (scripts/integration/file.mjs, grillhouse-4nr.8): `situer`,
|
|
53
|
+
// where the lot of a ticket stands (`situerLeLot`); `avancer`, main moved onto its branch
|
|
54
|
+
// (`avancerMain`), the ticket told of a branch out of the queue or kept (`direLIssue`);
|
|
55
|
+
// `fermer`, the ticket closed and main pushed (`fermerLEntree`); `ci`, one reading of the CI of
|
|
56
|
+
// a commit (`lireUneFoisLaCI`); `conclure`, the CI concluded at the ticket (`conclureLaCI`);
|
|
57
|
+
// `effet-de-la-file`, one effect they gave back, under the key of its activity. Their lines go
|
|
58
|
+
// to the error output.
|
|
59
|
+
import { appendFileSync, readFileSync } from 'node:fs';
|
|
60
|
+
import path from 'node:path';
|
|
61
|
+
import { pathToFileURL } from 'node:url';
|
|
62
|
+
import {
|
|
63
|
+
aLaFin,
|
|
64
|
+
appliquer,
|
|
65
|
+
commencerLEtape,
|
|
66
|
+
finirLEtape,
|
|
67
|
+
arretDe,
|
|
68
|
+
arreter,
|
|
69
|
+
avantLaPasse,
|
|
70
|
+
contexte,
|
|
71
|
+
ecrireEtat,
|
|
72
|
+
finirLOuverture,
|
|
73
|
+
lireLeFait,
|
|
74
|
+
MEMOIRE,
|
|
75
|
+
monter,
|
|
76
|
+
ouvrirJusquAuPlan,
|
|
77
|
+
publierLArret,
|
|
78
|
+
unPasDuPlan,
|
|
79
|
+
} from './circuit.mjs';
|
|
80
|
+
import {
|
|
81
|
+
avancerMain,
|
|
82
|
+
conclureLaCI,
|
|
83
|
+
direLIssue,
|
|
84
|
+
fermerLEntree,
|
|
85
|
+
lireUneFoisLaCI,
|
|
86
|
+
outilsDeLaFile,
|
|
87
|
+
situerLeLot,
|
|
88
|
+
} from './integration/file.mjs';
|
|
89
|
+
import { avancementDeLaCI, avecLAvancementDuTravail } from './avancement.mjs';
|
|
90
|
+
import { ecrireLEffet } from './effets.mjs';
|
|
91
|
+
import { Arret, geste } from './ticket-du-circuit.mjs';
|
|
92
|
+
|
|
93
|
+
// What the workflow keeps of the circuit's memory besides the decisions': the session a relaunch
|
|
94
|
+
// resumes, the rank of arrival, the sort of the ticket, what the opening reads of the project's
|
|
95
|
+
// package.json (its tools, its data, its generated files), which every pass of a later act plays
|
|
96
|
+
// with, each act in a process of its own, and the supervisor's context of the
|
|
97
|
+
// run (`contexte`), which each session of the run reads at the head of its instruction; a context
|
|
98
|
+
// the act is given (an answer's, a motive) is kept over it.
|
|
99
|
+
const GARDEE = [
|
|
100
|
+
...MEMOIRE,
|
|
101
|
+
'seanceReprise',
|
|
102
|
+
'rang',
|
|
103
|
+
'sorte',
|
|
104
|
+
'outils',
|
|
105
|
+
'donnees',
|
|
106
|
+
'engendres',
|
|
107
|
+
'contexte',
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
// The bases of the passes of the contexts this act opened, which its end removes, its death
|
|
111
|
+
// before its `finally` included.
|
|
112
|
+
const bases = new Set();
|
|
113
|
+
|
|
114
|
+
const dire = (genre, valeur) => process.stdout.write(`${genre} ${JSON.stringify(valeur)}\n`);
|
|
115
|
+
|
|
116
|
+
// The context of a run of the circuit of <ticket> with the options <options>, its memory
|
|
117
|
+
// <memoire>: its ports say each sign of life on the standard output, and the effects it emits are
|
|
118
|
+
// gathered (`rendus`), which the act gives back.
|
|
119
|
+
// The supervisor's session of the act being played (`superviseur` of its input, the entry of the
|
|
120
|
+
// workflow), which `leContexte` gives each context: one act per process. An act after the opening
|
|
121
|
+
// passes the plan its workflow holds (`paquets`): its context reads only the
|
|
122
|
+
// subject of the title, since the integration removes the copy while the circuit still runs.
|
|
123
|
+
let superviseurDeLActe = null;
|
|
124
|
+
|
|
125
|
+
function leContexte(ticket, memoire = {}, options = {}) {
|
|
126
|
+
const ctx = contexte({
|
|
127
|
+
ticket,
|
|
128
|
+
reprendre: false,
|
|
129
|
+
contexte: null,
|
|
130
|
+
depuis: null,
|
|
131
|
+
etendre: null,
|
|
132
|
+
arreter: false,
|
|
133
|
+
...options,
|
|
134
|
+
});
|
|
135
|
+
Object.assign(ctx, laMemoireReprise(memoire, options));
|
|
136
|
+
bases.add(ctx.base);
|
|
137
|
+
ctx.superviseur = superviseurDeLActe;
|
|
138
|
+
ctx.rendus = [];
|
|
139
|
+
ctx.constats = [...(ctx.constats ?? [])];
|
|
140
|
+
ctx.ports = { signeDeVie: vie => dire('vie', vie) };
|
|
141
|
+
return ctx;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// The tools of the queue on the main tree <racine> (the act plays there), its lines on the error
|
|
145
|
+
// output, the progress directory <avancement> of a reading of the CI, the effects it emits
|
|
146
|
+
// gathered (`rendus`), which the act gives back.
|
|
147
|
+
const laFile = (racine, avancement = null) => {
|
|
148
|
+
const o = outilsDeLaFile(racine, l => process.stderr.write(`${l}\n`), avancement);
|
|
149
|
+
o.rendus = [];
|
|
150
|
+
return o;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/** The memory of <ctx> the workflow keeps from one act to the next. */
|
|
154
|
+
export const laMemoire = ctx => Object.fromEntries(GARDEE.map(k => [k, ctx[k] ?? null]));
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* What a context takes back of the memory <memoire> the workflow kept, but what the act is given
|
|
158
|
+
* (<options>: an answer's context, a motive).
|
|
159
|
+
*/
|
|
160
|
+
export const laMemoireReprise = (memoire, options = {}) =>
|
|
161
|
+
Object.fromEntries(GARDEE.filter(k => k in memoire && !(k in options)).map(k => [k, memoire[k]]));
|
|
162
|
+
|
|
163
|
+
// The stop the state of <ctx> names once `monter` wrote it, at the state <etat>.
|
|
164
|
+
const arretDeLEtat = (ctx, code, etat) => ({
|
|
165
|
+
code,
|
|
166
|
+
nom: ctx.courant?.raison ?? null,
|
|
167
|
+
question: ctx.courant?.question ?? null,
|
|
168
|
+
etat: { ...etat, raison: ctx.courant?.raison ?? null },
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// The options of a run on the supervisor's answer <reponse>.
|
|
172
|
+
const optionsDe = reponse => {
|
|
173
|
+
if (!reponse) {
|
|
174
|
+
return {};
|
|
175
|
+
}
|
|
176
|
+
const contexteDuSuperviseur = reponse.contexte ?? null;
|
|
177
|
+
if (reponse.genre === 'reprendre') {
|
|
178
|
+
return { reprendre: true, contexte: contexteDuSuperviseur };
|
|
179
|
+
}
|
|
180
|
+
if (reponse.genre === 'depuis') {
|
|
181
|
+
return { depuis: reponse.role, contexte: contexteDuSuperviseur };
|
|
182
|
+
}
|
|
183
|
+
return { etendre: reponse.paquets, contexte: contexteDuSuperviseur };
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// The act <f> on the context <ctx>: its outcome and the effects it emitted (`effets`), its bases
|
|
187
|
+
// closed.
|
|
188
|
+
async function rendre(ctx, f) {
|
|
189
|
+
try {
|
|
190
|
+
const valeur = await f();
|
|
191
|
+
return { ...(valeur ?? {}), effets: ctx.rendus };
|
|
192
|
+
} finally {
|
|
193
|
+
ctx.base.fermer();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// The acts, each on its input; each returns its outcome.
|
|
198
|
+
const ACTES = {
|
|
199
|
+
async ouvrir({ ticket, memoire, reponse, arrete, cle, essai }) {
|
|
200
|
+
const ctx = leContexte(ticket, memoire, optionsDe(reponse));
|
|
201
|
+
// The key of its activity and its attempt name the sessions of the plan (`idDeSeance`).
|
|
202
|
+
ctx.cle = cle ?? null;
|
|
203
|
+
ctx.essaiDeLActe = essai ?? 1;
|
|
204
|
+
return rendre(ctx, () => ouvrirSur(ctx, memoire, arrete));
|
|
205
|
+
},
|
|
206
|
+
// One step of the plan (`unPasDuPlan`): the state of the plan that follows, the opening once it
|
|
207
|
+
// passes, or its stop gone up.
|
|
208
|
+
async plan({ ticket, memoire, reponse, pas, plan, cle, essai }) {
|
|
209
|
+
const ctx = leContexte(ticket, memoire, optionsDe(reponse));
|
|
210
|
+
ctx.cle = cle ?? null;
|
|
211
|
+
ctx.essaiDeLActe = essai ?? 1;
|
|
212
|
+
ctx.contexte = plan.contexte ?? ctx.contexte ?? null;
|
|
213
|
+
return rendre(ctx, async () => {
|
|
214
|
+
const r = await unPasDuPlan(ctx, pas, plan.etat);
|
|
215
|
+
if ('code' in r) {
|
|
216
|
+
aLaFin(ctx, r.code);
|
|
217
|
+
return { arret: arretDeLEtat(ctx, r.code, ctx.courant ?? {}) };
|
|
218
|
+
}
|
|
219
|
+
if (r.passe) {
|
|
220
|
+
finirLOuverture(ctx, plan.debut);
|
|
221
|
+
return { ouverture: lOuverture(ctx, plan.debut) };
|
|
222
|
+
}
|
|
223
|
+
return { plan: { ...plan, etat: r.plan, memoire: laMemoire(ctx) } };
|
|
224
|
+
});
|
|
225
|
+
},
|
|
226
|
+
async preparer({ ticket, memoire, etape, paquets }) {
|
|
227
|
+
const ctx = leContexte(ticket, memoire, { paquets });
|
|
228
|
+
return rendre(ctx, () => {
|
|
229
|
+
const { etat, menee } = commencerLEtape(ctx, etape);
|
|
230
|
+
const pointe = avantLaPasse(ctx, etape.etape, ctx.regeneration ?? null);
|
|
231
|
+
if (pointe.arret) {
|
|
232
|
+
const { nom, rapport, piece, question } = pointe.arret;
|
|
233
|
+
return { arret: { leve: { nom, rapport, piece, question } }, etat, menee };
|
|
234
|
+
}
|
|
235
|
+
if (pointe.avancee) {
|
|
236
|
+
appendFileSync(ctx.journal, 'la copie avance sur la pointe de main avant la passe.\n');
|
|
237
|
+
}
|
|
238
|
+
return { memoire: { regeneration: pointe.regeneration ?? null }, etat, menee };
|
|
239
|
+
});
|
|
240
|
+
},
|
|
241
|
+
async fait(
|
|
242
|
+
{ ticket, memoire, fait, parametres, faits, sorte, paquets, precedent, cle, essai },
|
|
243
|
+
annulation
|
|
244
|
+
) {
|
|
245
|
+
const ctx = leContexte(ticket, memoire, { paquets });
|
|
246
|
+
ctx.sorte = sorte;
|
|
247
|
+
// A fact is read again on an attempt played again: the key of its activity names its sessions
|
|
248
|
+
// (`idDeSeance`), and its attempt says whether Temporal plays it again (`lancer` of
|
|
249
|
+
// scripts/seances.mjs).
|
|
250
|
+
ctx.cle = cle ?? null;
|
|
251
|
+
ctx.essaiDeLActe = essai ?? 1;
|
|
252
|
+
return rendre(ctx, async () => {
|
|
253
|
+
const avec = fait === 'seance' ? { ...parametres, precedent, annulation } : parametres;
|
|
254
|
+
try {
|
|
255
|
+
const valeur = await lireLeFait(ctx, fait, avec, faits);
|
|
256
|
+
return { valeur: valeur ?? null, memoire: laMemoire(ctx) };
|
|
257
|
+
} catch (e) {
|
|
258
|
+
if (!(e instanceof Arret)) {
|
|
259
|
+
throw e;
|
|
260
|
+
}
|
|
261
|
+
const { nom, rapport, rouges, motif, resultat, piece, question, qui, etape } = e;
|
|
262
|
+
return {
|
|
263
|
+
leve: { nom, rapport, rouges, motif, resultat, piece, question, qui, etape },
|
|
264
|
+
memoire: laMemoire(ctx),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
},
|
|
269
|
+
async effets({ ticket, memoire, effets, menee, paquets }) {
|
|
270
|
+
const ctx = leContexte(ticket, memoire, { paquets });
|
|
271
|
+
return rendre(ctx, () => {
|
|
272
|
+
for (const e of effets) {
|
|
273
|
+
appliquer(ctx, e);
|
|
274
|
+
}
|
|
275
|
+
finirLEtape(ctx, menee ?? null);
|
|
276
|
+
return null;
|
|
277
|
+
});
|
|
278
|
+
},
|
|
279
|
+
async arret({ ticket, memoire, arret, etat, monter: aMonter, paquets, menee }) {
|
|
280
|
+
const ctx = leContexte(ticket, memoire, { paquets });
|
|
281
|
+
return rendre(ctx, () => {
|
|
282
|
+
const a = publierLArret(ctx, erreurDe(ctx, arret), etat);
|
|
283
|
+
finirLEtape(ctx, menee ?? null);
|
|
284
|
+
if (a.nom === 'a-repasser' && !aMonter) {
|
|
285
|
+
geste(ctx, 'a-repasser');
|
|
286
|
+
aLaFin(ctx, a.code);
|
|
287
|
+
return { code: a.code, nom: a.nom, question: null, etat: { ...a.etat, raison: a.nom } };
|
|
288
|
+
}
|
|
289
|
+
const code = monter(ctx, a);
|
|
290
|
+
aLaFin(ctx, code);
|
|
291
|
+
return arretDeLEtat(ctx, code, a.etat);
|
|
292
|
+
});
|
|
293
|
+
},
|
|
294
|
+
async fin({ ticket, memoire, etat, paquets }) {
|
|
295
|
+
const ctx = leContexte(ticket, memoire, { paquets });
|
|
296
|
+
return rendre(ctx, () => {
|
|
297
|
+
ecrireEtat(ctx, { ...etat, etape: 'integre', code: 0 });
|
|
298
|
+
aLaFin(ctx, 0);
|
|
299
|
+
return null;
|
|
300
|
+
});
|
|
301
|
+
},
|
|
302
|
+
async arreter({ ticket, memoire, etat, contexte: motif }) {
|
|
303
|
+
const ctx = leContexte(ticket, memoire, { arreter: true, contexte: motif ?? null });
|
|
304
|
+
return rendre(ctx, async () => {
|
|
305
|
+
await arreter(ctx, { ...etat, ...laMemoire(ctx) });
|
|
306
|
+
return null;
|
|
307
|
+
});
|
|
308
|
+
},
|
|
309
|
+
// One effect an act gave back, under the key of its activity, with the outcome of the
|
|
310
|
+
// circuit when it is not written (`ecrireLEffet`): said at the last attempt of its activity
|
|
311
|
+
// (`derniere`), tried again by Temporal before it, or the act fails.
|
|
312
|
+
async effet({ ticket, effet, cle, derniere }) {
|
|
313
|
+
const ctx = contexte({
|
|
314
|
+
ticket,
|
|
315
|
+
reprendre: false,
|
|
316
|
+
contexte: null,
|
|
317
|
+
depuis: null,
|
|
318
|
+
etendre: null,
|
|
319
|
+
arreter: true,
|
|
320
|
+
});
|
|
321
|
+
bases.add(ctx.base);
|
|
322
|
+
try {
|
|
323
|
+
ecrireLEffet(ctx, effet, cle ?? null, { reessayer: derniere === false });
|
|
324
|
+
return null;
|
|
325
|
+
} finally {
|
|
326
|
+
ctx.base.fermer();
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// The opening of a run of <ctx> on the stopped state <arrete>, which the workflow holds (null at
|
|
332
|
+
// the first launch, and for a circuit the server no longer holds, reopened by --depuis), up to its
|
|
333
|
+
// plan: the plan still to write goes to the workflow (`plan`), which plays each of its steps (the
|
|
334
|
+
// act `plan`).
|
|
335
|
+
async function ouvrirSur(ctx, memoire, arrete) {
|
|
336
|
+
const lu = arrete ?? null;
|
|
337
|
+
if (lu) {
|
|
338
|
+
// What the stopped run kept and the new workflow of the answer does not hold yet.
|
|
339
|
+
for (const k of GARDEE) {
|
|
340
|
+
if (!(k in memoire) && lu[k] !== undefined) {
|
|
341
|
+
ctx[k] = lu[k];
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
const e = lu ? { ...lu, rang: memoire.rang ?? lu.rang ?? null } : null;
|
|
346
|
+
const o = await ouvrirJusquAuPlan(ctx, e);
|
|
347
|
+
if ('code' in o) {
|
|
348
|
+
aLaFin(ctx, o.code);
|
|
349
|
+
return { arret: arretDeLEtat(ctx, o.code, ctx.courant ?? {}) };
|
|
350
|
+
}
|
|
351
|
+
if (o.plan) {
|
|
352
|
+
return {
|
|
353
|
+
plan: {
|
|
354
|
+
etat: o.plan,
|
|
355
|
+
debut: o.debut,
|
|
356
|
+
contexte: ctx.contexte ?? null,
|
|
357
|
+
memoire: laMemoire(ctx),
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
finirLOuverture(ctx, o.debut);
|
|
362
|
+
return { ouverture: lOuverture(ctx, o.debut) };
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// The opening of the run of <ctx> at the step <debut>, as the workflow keeps it.
|
|
366
|
+
const lOuverture = (ctx, debut) => ({
|
|
367
|
+
debut,
|
|
368
|
+
memoire: laMemoire(ctx),
|
|
369
|
+
ticket: {
|
|
370
|
+
id: ctx.ticket,
|
|
371
|
+
paquets: ctx.paquets,
|
|
372
|
+
sorte: ctx.sorte ?? null,
|
|
373
|
+
copie: ctx.copie,
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
// The exception of the stop <arret> the workflow hands the act `arret` (an Arret raised, an
|
|
378
|
+
// exception of an activity, a stop a decision returned).
|
|
379
|
+
function erreurDe(ctx, arret) {
|
|
380
|
+
if (arret.leve) {
|
|
381
|
+
const { nom, rapport, ...options } = arret.leve;
|
|
382
|
+
return new Arret(nom, rapport, options);
|
|
383
|
+
}
|
|
384
|
+
if (arret.inattendu) {
|
|
385
|
+
const erreur = new Error(arret.inattendu.message);
|
|
386
|
+
erreur.stack = arret.inattendu.pile ?? erreur.stack;
|
|
387
|
+
return erreur;
|
|
388
|
+
}
|
|
389
|
+
return arretDe(ctx, arret);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// The acts of the queue, each on its input: those that write give back their effects (`effets`).
|
|
393
|
+
Object.assign(ACTES, {
|
|
394
|
+
async situer({ racine, ticket }) {
|
|
395
|
+
return situerLeLot(laFile(racine), ticket);
|
|
396
|
+
},
|
|
397
|
+
// The replay of the ticket's branch on main writes the progress of its `npm run verifier` in
|
|
398
|
+
// the working directory of the ticket, where the board reads it while the circuit waits for the
|
|
399
|
+
// queue (`avecLAvancementDuTravail`, the kind `file`); a lot entered keeps it until the queue is done
|
|
400
|
+
// with the ticket closed, which removes the working directory (`retirerLeTravail`).
|
|
401
|
+
async avancer({ racine, ticket, branche }) {
|
|
402
|
+
const o = laFile(racine);
|
|
403
|
+
const entree = { ticket, branche };
|
|
404
|
+
const travail = path.join(racine, '.claude', 'worktrees', `${ticket}.travail`);
|
|
405
|
+
const r = avecLAvancementDuTravail(
|
|
406
|
+
travail,
|
|
407
|
+
{ racine, genre: 'file', garder: lu => Boolean(lu.entre) },
|
|
408
|
+
() => avancerMain(o, entree)
|
|
409
|
+
);
|
|
410
|
+
return { ...(r.entre ? r : { issue: direLIssue(o, entree, r) }), effets: o.rendus };
|
|
411
|
+
},
|
|
412
|
+
async fermer({ racine, ticket, branche, commit }) {
|
|
413
|
+
const o = laFile(racine);
|
|
414
|
+
return { ...fermerLEntree(o, { ticket, branche, commit }), effets: o.rendus };
|
|
415
|
+
},
|
|
416
|
+
// A reading of the CI writes the steps of its run done over planned in the working directory of
|
|
417
|
+
// the ticket, where the board reads them (scripts/avancement.mjs `avancementDeLaCI`); one that
|
|
418
|
+
// looks for its run (no run found yet) empties the records of another.
|
|
419
|
+
async ci({ racine, ticket, sha, branche, passage }) {
|
|
420
|
+
const travail = path.join(racine, '.claude', 'worktrees', `${ticket}.travail`);
|
|
421
|
+
const avancement = avancementDeLaCI(travail, { nouvelle: passage === null });
|
|
422
|
+
return lireUneFoisLaCI(laFile(racine, avancement), { sha, branche, passage });
|
|
423
|
+
},
|
|
424
|
+
async conclure({ racine, ...e }) {
|
|
425
|
+
const o = laFile(racine);
|
|
426
|
+
return { ...conclureLaCI(o, e), effets: o.rendus };
|
|
427
|
+
},
|
|
428
|
+
// One effect an act of the queue gave back, under the key of its activity, with the outcome of
|
|
429
|
+
// the queue when it is not written (`ecrireLEffet`).
|
|
430
|
+
async 'effet-de-la-file'({ racine, effet, cle, derniere }) {
|
|
431
|
+
ecrireLEffet(
|
|
432
|
+
outilsDeLaFile(racine, l => process.stderr.write(`${l}\n`)),
|
|
433
|
+
effet,
|
|
434
|
+
cle,
|
|
435
|
+
{
|
|
436
|
+
reessayer: derniere === false,
|
|
437
|
+
}
|
|
438
|
+
);
|
|
439
|
+
return null;
|
|
440
|
+
},
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* The error <e> of an act as it goes to its activity (src/temporal/acte.ts): its message, its
|
|
445
|
+
* stack, and whether Temporal tries it again (`reessayable`, an effect not written before its last
|
|
446
|
+
* attempt, `EffetNonEcrit` of scripts/effets.mjs).
|
|
447
|
+
*/
|
|
448
|
+
export const erreurDeLActe = e => ({
|
|
449
|
+
message: String(e?.message ?? e),
|
|
450
|
+
pile: String(e?.stack ?? e),
|
|
451
|
+
reessayable: e?.reessayable === true,
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
/** Plays the act <acte> on <entree>; <annulation> cancels it. */
|
|
455
|
+
export async function jouerLActe(acte, entree, annulation) {
|
|
456
|
+
const f = ACTES[acte];
|
|
457
|
+
if (!f) {
|
|
458
|
+
throw new Error(`acte inconnu du circuit : ${acte}`);
|
|
459
|
+
}
|
|
460
|
+
superviseurDeLActe = entree?.superviseur ?? null;
|
|
461
|
+
return f(entree, annulation);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
465
|
+
// The act ends with its worker, its bases removed, the group of its session left running: the
|
|
466
|
+
// worker gone (its process another's parent), or its output closed.
|
|
467
|
+
const finir = () => {
|
|
468
|
+
for (const b of bases) {
|
|
469
|
+
b.fermer();
|
|
470
|
+
}
|
|
471
|
+
// The worker gone, its output is closed: nothing to drain, and the act ends at once, the group
|
|
472
|
+
// of its session left running for the attempt played again (not `exitCode`, which would wait
|
|
473
|
+
// for that session).
|
|
474
|
+
// eslint-disable-next-line no-process-exit
|
|
475
|
+
process.exit(1);
|
|
476
|
+
};
|
|
477
|
+
process.stdout.on('error', finir);
|
|
478
|
+
const annulation = new AbortController();
|
|
479
|
+
process.on('SIGTERM', () => annulation.abort());
|
|
480
|
+
const travailleur = process.ppid;
|
|
481
|
+
setInterval(() => {
|
|
482
|
+
if (process.ppid !== travailleur) {
|
|
483
|
+
finir();
|
|
484
|
+
}
|
|
485
|
+
}, 1000).unref();
|
|
486
|
+
try {
|
|
487
|
+
const entree = JSON.parse(readFileSync(0, 'utf8'));
|
|
488
|
+
dire('resultat', await jouerLActe(process.argv[2], entree, annulation.signal));
|
|
489
|
+
} catch (e) {
|
|
490
|
+
dire('erreur', erreurDeLActe(e));
|
|
491
|
+
process.exitCode = 1;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The types of the rule of the queue of the tickets of a project (./file-des-tickets.mjs), which
|
|
2
|
+
// the queue of the tickets under Temporal (src/temporal/tickets/) imports.
|
|
3
|
+
|
|
4
|
+
/** A ticket as Beads gives it. */
|
|
5
|
+
export interface TicketDeBeads {
|
|
6
|
+
id: string;
|
|
7
|
+
status: string;
|
|
8
|
+
priority?: number;
|
|
9
|
+
labels?: string[];
|
|
10
|
+
created_at?: string;
|
|
11
|
+
dependencies?: Array<{ type: string; depends_on_id: string }>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The tickets of <tous> that start now, in the order they start. */
|
|
15
|
+
export function ticketsAPartir<T extends TicketDeBeads>(
|
|
16
|
+
tous: T[],
|
|
17
|
+
o?: { enCours?: Set<string> }
|
|
18
|
+
): T[];
|
|
19
|
+
|
|
20
|
+
/** Every ticket of the project at <racine>, the closed ones too, as Beads gives them; throws on a Beads that fails. */
|
|
21
|
+
export function lireLesTickets(racine: string): TicketDeBeads[];
|