@roomi-fields/grillhouse 0.50.3 → 0.52.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 +68 -0
- package/agents/developpeur.md +1 -1
- package/agents/direct.md +1 -1
- package/agents/explorateur.md +1 -1
- package/agents/questionneur.md +1 -1
- package/agents/relecteur.md +1 -1
- package/agents/testwriter.md +1 -1
- package/cadre/templates/c/package.json +1 -0
- package/cadre/templates/cargo/package.json +1 -0
- package/cadre/templates/python/package.json +1 -0
- package/charte/plan.md +47 -0
- package/charte/preuve.md +39 -0
- package/charte/superviseur.md +61 -0
- package/charte/tests.md +38 -0
- package/charte.md +39 -189
- package/dist/machine/part-par-sorte.d.ts +16 -0
- package/dist/machine/part-par-sorte.js +36 -0
- package/dist/machine/part-par-sorte.js.map +1 -0
- package/dist/temporal/circuit/appel.js +1 -1
- package/dist/temporal/circuit/appel.js.map +1 -1
- package/dist/temporal/circuit/client.d.ts +4 -4
- package/dist/temporal/circuit/client.js +38 -16
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/circuit/contrat.d.ts +11 -7
- package/dist/temporal/circuit/contrat.js +5 -9
- package/dist/temporal/circuit/contrat.js.map +1 -1
- package/dist/temporal/circuit/deroule.js +18 -6
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/commande.js +12 -3
- package/dist/temporal/commande.js.map +1 -1
- package/dist/temporal/installation.d.ts +54 -3
- package/dist/temporal/installation.js +187 -17
- package/dist/temporal/installation.js.map +1 -1
- package/dist/temporal/places/client.d.ts +5 -1
- package/dist/temporal/places/client.js +23 -11
- package/dist/temporal/places/client.js.map +1 -1
- package/docs/ARCHITECTURE.md +23 -2700
- package/docs/INTERFACE.md +26 -10
- package/docs/architecture/circuit.md +61 -14
- package/docs/architecture/entree.md +21 -8
- package/docs/architecture/greffon.md +49 -20
- package/docs/architecture/installation.md +46 -17
- package/docs/architecture/machine.md +79 -39
- package/docs/architecture/tests.md +59 -16
- package/docs/lexique.md +163 -0
- package/hooks/hooks.json +0 -10
- package/hooks/register.tsx +92 -4
- package/package.json +2 -1
- package/scripts/activites.mjs +105 -65
- package/scripts/aiguillage.mjs +15 -8
- package/scripts/attente-au-tour.mjs +2 -3
- package/scripts/attente-de-la-machine.mjs +4 -8
- package/scripts/avancement.mjs +12 -8
- package/scripts/bilan.mjs +126 -63
- package/scripts/bilans-gardes.mjs +37 -0
- package/scripts/branche-de-nuit.mjs +2 -2
- package/scripts/ci-de-main.mjs +18 -21
- package/scripts/circuit.mjs +89 -44
- package/scripts/circuits-du-serveur.mjs +5 -5
- package/scripts/composants-affectes.mjs +30 -12
- package/scripts/composition-des-langages.mjs +5 -3
- package/scripts/conformite.mjs +1 -1
- package/scripts/consommation-des-passes.mjs +8 -6
- package/scripts/copies-finies.mjs +3 -14
- package/scripts/depart-du-ticket.d.mts +8 -2
- package/scripts/depart-du-ticket.mjs +26 -8
- package/scripts/direct.mjs +158 -72
- package/scripts/droits.mjs +165 -208
- package/scripts/engendres.mjs +3 -14
- package/scripts/entree-de-seance.mjs +35 -0
- package/scripts/enveloppe/enveloppe.mjs +98 -46
- package/scripts/enveloppe/lancer.sh +90 -66
- package/scripts/enveloppe/paquets-du-plan.mjs +38 -11
- package/scripts/enveloppe/travail-de-la-copie.mjs +192 -3
- package/scripts/etapes.mjs +84 -22
- package/scripts/faits-du-circuit.mjs +8 -2
- package/scripts/grillhouse-maj.mjs +43 -18
- package/scripts/groupe-cles.d.mts +15 -0
- package/scripts/groupe-cles.mjs +77 -2
- package/scripts/init.mjs +9 -2
- package/scripts/integration/rejeu.mjs +8 -1
- package/scripts/jointure.d.ts +24 -4
- package/scripts/langages/c/index.mjs +5 -2
- package/scripts/langages/cargo/commandes.mjs +35 -15
- package/scripts/langages/cargo/composants.mjs +45 -3
- package/scripts/langages/cargo/index.mjs +6 -3
- package/scripts/langages/python/commandes.mjs +50 -7
- package/scripts/langages/python/index.mjs +5 -2
- package/scripts/langages/python/squelette.mjs +2 -1
- package/scripts/langages/typescript/chemins-des-tests.mjs +1 -1
- package/scripts/langages/typescript/index.mjs +16 -14
- package/scripts/langages/typescript/mise-a-jour.mjs +1 -1
- package/scripts/langages/typescript/rapports-aux-lignes.mjs +74 -0
- package/scripts/langages/typescript/turbo-des-paquets.mjs +151 -38
- package/scripts/langages/typescript/verdict.mjs +29 -3
- package/scripts/langages/typescript/verifier.mjs +28 -3
- package/scripts/langages/typescript/vitest-config/changements.mjs +8 -6
- package/scripts/langages/typescript/vitest-config/lances.mjs +15 -32
- package/scripts/langages.mjs +54 -4
- package/scripts/matieres-lues.mjs +1 -1
- package/scripts/mesure/base-de-passe.mjs +32 -90
- package/scripts/migrations/serveurs-de-l-index.mjs +79 -0
- package/scripts/migrations/suivi-du-superviseur-retire.mjs +56 -0
- package/scripts/migrations.mjs +23 -7
- package/scripts/nuit.sh +3 -2
- package/scripts/paquet.mjs +1 -1
- package/scripts/paquets.d.ts +3 -0
- package/scripts/paquets.mjs +88 -1
- package/scripts/passe-de-la-machine.mjs +109 -36
- package/scripts/places-de-la-machine.mjs +81 -29
- package/scripts/plafond-de-la-machine.d.mts +2 -5
- package/scripts/plafond-de-la-machine.mjs +9 -9
- package/scripts/reprise.mjs +42 -13
- package/scripts/resultats.mjs +78 -56
- package/scripts/retirer-les-copies-finies.mjs +1 -1
- package/scripts/seances.mjs +471 -133
- package/scripts/services-du-noyau.mjs +9 -1
- package/scripts/session-start.sh +22 -7
- package/scripts/sortie-de-seance.mjs +70 -0
- package/scripts/sortie.mjs +37 -6
- package/scripts/sous-commandes.mjs +0 -3
- package/scripts/superviseur.mjs +400 -162
- package/scripts/tableau.mjs +188 -65
- package/scripts/transitions.d.mts +25 -2
- package/scripts/transitions.mjs +137 -29
- package/scripts/verrous/ecriture-hors-enveloppe.mjs +31 -9
- package/skills/codebase-design/DESIGN-IT-TWICE.md +1 -1
- package/skills/developpeur/SKILL.md +38 -15
- package/skills/direct/SKILL.md +29 -9
- package/skills/domain-modeling/GLOSSARY-FORMAT.md +9 -9
- package/skills/domain-modeling/SKILL.md +14 -12
- package/skills/explorateur/SKILL.md +32 -8
- package/skills/grill/SKILL.md +3 -2
- package/skills/pitmaster/SKILL.md +80 -50
- package/skills/pitmaster/references/cadre.md +1 -1
- package/skills/pitmaster/references/consigne-agent.md +12 -11
- package/skills/pitmaster/references/tour.md +6 -5
- package/skills/relecteur/SKILL.md +13 -6
- package/skills/systematic-debugging/SKILL.md +281 -0
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/skills/systematic-debugging/find-polluter.sh +72 -0
- package/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/skills/testwriter/SKILL.md +37 -31
- package/cadre/templates/projet/pitmaster/SUIVI.md +0 -22
- package/scripts/attente-a-l-arret.mjs +0 -114
- package/scripts/verrous/commande.mjs +0 -214
- package/scripts/verrous/verrou.mjs +0 -311
package/scripts/superviseur.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Mechanism: greffon.md, §5.1 and §5.2. Played by the session start (scripts/session-start.sh),
|
|
4
4
|
// which writes what it says to the session.
|
|
5
5
|
//
|
|
6
|
-
// npx grillhouse superviseur <racine>
|
|
6
|
+
// npx grillhouse superviseur <racine> [<source>]
|
|
7
7
|
//
|
|
8
8
|
// - Out of a git repository, in an agent's copy (a worktree whose git directory is not the common
|
|
9
9
|
// one) and in a session of a role that the circuit launches (BEADS_ACTOR set), nothing is taken
|
|
@@ -12,11 +12,16 @@
|
|
|
12
12
|
// copies, taken through scripts/verrou-de-fichier.mjs for the session's own process: the first
|
|
13
13
|
// process above this one named `claude`, whatever stands between them; without one, the first
|
|
14
14
|
// that is not a shell (sh, bash, dash, zsh). It holds as long as that process lives.
|
|
15
|
-
// -
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
15
|
+
// - <source> is the one of the SessionStart hook (`startup` without one). Free, or held by a
|
|
16
|
+
// process that is gone: taken. Held by the session itself: kept, and nothing is said after a
|
|
17
|
+
// compaction or a resume. After a /clear, the session that holds the lock receives « ## Reprise
|
|
18
|
+
// de la supervision après un /clear » (load `grillhouse:pitmaster`, take up the note of
|
|
19
|
+
// resumption, no whole round, put the owner's pending question again at the first turn), then
|
|
20
|
+
// what a session that takes the lock receives. Held by another live session: the section « ## Un
|
|
21
|
+
// autre superviseur tient ce dépôt » names its process and since when, and asks to say so to the
|
|
22
|
+
// owner and to launch no circuit. A declared milestone ends with the context that declared it: it
|
|
23
|
+
// is removed at every opening of the holder but after a compaction.
|
|
24
|
+
// - The session whose opening takes the lock (`ouvertureDuSuperviseur`) receives « ## Les questions
|
|
20
25
|
// des circuits », then, when the repository has circuits (read from the Temporal server in one
|
|
21
26
|
// call, scripts/circuits-du-serveur.mjs), « ## Les circuits du dépôt »: each circuit that runs;
|
|
22
27
|
// each circuit stopped on a question, with the command that answers it; each circuit ended
|
|
@@ -24,34 +29,56 @@
|
|
|
24
29
|
// written, else `--depuis <testwriter|developpeur> --contexte <texte>`); a server that does not
|
|
25
30
|
// answer is said; then « ## La file des tickets », the tickets of the queue without their
|
|
26
31
|
// section « ## Architecture », which the queue never starts (scripts/file-des-tickets.mjs).
|
|
32
|
+
// Last, « ## La note de reprise » gives the note of resumption, when one is written.
|
|
27
33
|
// Exit 0, whatever it finds.
|
|
28
34
|
//
|
|
29
|
-
// npx grillhouse superviseur --
|
|
35
|
+
// npx grillhouse superviseur --jalon <fichier>
|
|
36
|
+
// npx grillhouse superviseur --question <fichier>
|
|
37
|
+
//
|
|
38
|
+
// - Played by the session that holds the lock, from the root of the repository. The note of
|
|
39
|
+
// resumption, one per repository, is `<git common dir>/grillhouse-reprise.md`. `--jalon` replaces
|
|
40
|
+
// it whole by the text of <fichier> and declares a milestone, which replaces the one before
|
|
41
|
+
// (`<git common dir>/grillhouse-jalon.json`); `--question` adds the text at its end, creating it,
|
|
42
|
+
// and declares nothing. Exit 2 and the reason on the error stream, nothing written, on a file
|
|
43
|
+
// that is absent or empty, a session that does not hold the lock, a session of a role or a copy.
|
|
44
|
+
//
|
|
45
|
+
// npx grillhouse superviseur --renouveler <dossier> <arretA> <messageA>
|
|
46
|
+
//
|
|
47
|
+
// - Played by the greffon at each period: writes the message of resumption when the renewal is due
|
|
48
|
+
// (`renouvellement`), nothing otherwise.
|
|
49
|
+
//
|
|
50
|
+
// npx grillhouse superviseur --relever [<dossier>] [--compaction]
|
|
30
51
|
//
|
|
31
52
|
// - One reading of the circuits for the greffon (mods/grillhouse/hooks/register.tsx), which runs
|
|
32
53
|
// it at each period and submits what it writes. It reads and writes nothing unless the session
|
|
33
54
|
// that runs it holds the lock; a lock whose process is gone is taken over by the session that
|
|
34
55
|
// reads. It writes the message (`texteDesQuestions`) when `relever` gives something, nothing
|
|
35
|
-
// otherwise; exit 1 and the fault on the error stream when `grillhouse.rappel`
|
|
56
|
+
// otherwise; exit 1 and the fault on the error stream when `grillhouse.rappel` of the project is
|
|
57
|
+
// at fault, or when the reading of another project of the group fails, the message of the others
|
|
58
|
+
// then written all the same. The message ends with the request to write the note and declare a
|
|
59
|
+
// milestone after a compaction (`--compaction`), and once for each night
|
|
60
|
+
// (`grillhouse.plageDeNuit`) at a reading where no question of a circuit waits for the
|
|
61
|
+
// supervisor.
|
|
36
62
|
// - `superviseur --lue <dossier> <lueA> <envoyeesAvant>` marks read the questions sent up to
|
|
37
63
|
// `envoyeesAvant`; `superviseur --chez-le-responsable <dossier> <ticket>` marks a question
|
|
38
64
|
// carried to the owner: silent until the circuit answers.
|
|
39
65
|
// - `relever` is the one function of the reading, of the re-presentation and of the file of the
|
|
40
66
|
// stops gone up: a question that never went up, or was read <rappelMs> ago (`grillhouse.rappel`
|
|
41
67
|
// minutes, 10 by default, scripts/circuits-cles.mjs), is given once per due time while its
|
|
42
|
-
// circuit stands on the same stop; one
|
|
68
|
+
// circuit stands on the same stop; one addressed to the owner goes up once, without reminder,
|
|
69
|
+
// and the opening lists it; one answered leaves the file
|
|
43
70
|
// `.claude/worktrees/questions-remontees.json`. A stop is kept there by its ticket, the run of
|
|
44
71
|
// its workflow, the rank of its question in that run and its stop, with the times of the first
|
|
45
|
-
// going up and of the last presentation. The
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
// (`.claude/worktrees/ci-de-main-rendue.json`), cleared at the next green.
|
|
72
|
+
// going up and of the last presentation. The alert of the CI of main (a red, or a CI not read,
|
|
73
|
+
// scripts/ci-de-main.mjs) is given once per passage (`.claude/worktrees/ci-de-main-rendue.json`),
|
|
74
|
+
// cleared at the next green. A circuit integrated gives nothing: it is read on the board.
|
|
49
75
|
// - The reading covers the project and each other project of its group (`grillhouse.groupe`) that
|
|
50
76
|
// no other live session of supervision holds, each under its name and its folder.
|
|
51
77
|
import { spawnSync } from 'node:child_process';
|
|
52
|
-
import { mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
|
|
78
|
+
import { mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
53
79
|
import path from 'node:path';
|
|
54
80
|
import { pathToFileURL } from 'node:url';
|
|
81
|
+
import { nuitEnCours, plageDeNuit } from './bilan.mjs';
|
|
55
82
|
import { lireEtOuvrirLeDefautDeMain } from './ci-de-main.mjs';
|
|
56
83
|
import { lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
|
|
57
84
|
import { vivant } from './mesure/base-de-passe.mjs';
|
|
@@ -65,7 +92,14 @@ import {
|
|
|
65
92
|
} from './tableau.mjs';
|
|
66
93
|
import { rappelDuProjet, reglageDuRappel } from './circuits-cles.mjs';
|
|
67
94
|
import { lireGroupe } from './groupe-cles.mjs';
|
|
68
|
-
import {
|
|
95
|
+
import {
|
|
96
|
+
etapeDuCircuit,
|
|
97
|
+
libelle,
|
|
98
|
+
REPONSES,
|
|
99
|
+
RESPONSABLE,
|
|
100
|
+
sansLesReponses,
|
|
101
|
+
SUPERVISEUR,
|
|
102
|
+
} from './etapes.mjs';
|
|
69
103
|
import { sigleDuProjet } from './sigle-du-projet.mjs';
|
|
70
104
|
import {
|
|
71
105
|
enFileSansArchitecture,
|
|
@@ -76,6 +110,15 @@ import {
|
|
|
76
110
|
} from './file-des-tickets.mjs';
|
|
77
111
|
|
|
78
112
|
const VERROU_SUPERVISEUR = 'grillhouse-superviseur.lock';
|
|
113
|
+
// In the common directory of git: the note of resumption of the supervisor, its declared milestone,
|
|
114
|
+
// and the start of the last night whose request was given.
|
|
115
|
+
const NOTE_DE_REPRISE = 'grillhouse-reprise.md';
|
|
116
|
+
const JALON = 'grillhouse-jalon.json';
|
|
117
|
+
const DEMANDE_DE_NUIT = 'grillhouse-demande-de-nuit.json';
|
|
118
|
+
// The message the greffon submits once the /clear of a renewal is done; the note, the questions and
|
|
119
|
+
// the circuits come with the opening.
|
|
120
|
+
const MESSAGE_DE_REPRISE =
|
|
121
|
+
"Reprends la supervision : ta séance vient de se renouveler au jalon que tu as déclaré. L'ouverture te donne la note de reprise, les questions et les circuits : suis-la.";
|
|
79
122
|
const COQUILLES = new Set(['sh', 'bash', 'dash', 'zsh']);
|
|
80
123
|
// The name of the process of a session of the engine.
|
|
81
124
|
const MOTEUR = 'claude';
|
|
@@ -162,16 +205,21 @@ export function horsAttente(tickets, maintenant) {
|
|
|
162
205
|
|
|
163
206
|
// Of the tickets <ids> of the repository at <racine>, those whose question does not wait now
|
|
164
207
|
// (`horsAttente`); null when bd does not read them (unknown, never « none »): a machine under
|
|
165
|
-
// load can take seconds to answer.
|
|
208
|
+
// load can take seconds to answer. One listing reads them all, whatever their number: `bd show`
|
|
209
|
+
// costs more than a second per ticket and overruns the time given when many circuits stand.
|
|
166
210
|
export function ticketsHorsAttente(racine, ids) {
|
|
167
|
-
const r = spawnSync('bd', ['
|
|
211
|
+
const r = spawnSync('bd', ['list', '--all', '--limit', '0', '--id', ids.join(','), '--json'], {
|
|
168
212
|
cwd: racine,
|
|
169
213
|
encoding: 'utf8',
|
|
170
214
|
timeout: 30_000,
|
|
171
215
|
maxBuffer: 256 * 1024 * 1024,
|
|
172
216
|
});
|
|
173
217
|
try {
|
|
174
|
-
|
|
218
|
+
const demandes = new Set(ids);
|
|
219
|
+
return horsAttente(
|
|
220
|
+
JSON.parse(r.stdout).filter(t => demandes.has(t.id)),
|
|
221
|
+
Date.now()
|
|
222
|
+
);
|
|
175
223
|
} catch {
|
|
176
224
|
return null;
|
|
177
225
|
}
|
|
@@ -187,21 +235,6 @@ const ou = c => {
|
|
|
187
235
|
// of the circuits (scripts/tableau.mjs reads it: its alerts).
|
|
188
236
|
const etatsDe = racine => path.join(racine, '.claude', 'worktrees');
|
|
189
237
|
|
|
190
|
-
// The integrations given by the waits of the repository at <racine>: `depuis`, the time (ms) of
|
|
191
|
-
// the last reading of the last wait, from which an integration is new; `rendues`, the keys of the
|
|
192
|
-
// integrations it gave, ended at that time or after. Absent or unreadable: none since <maintenant>.
|
|
193
|
-
const integrationsDe = racine => path.join(etatsDe(racine), 'integrations-rendues.json');
|
|
194
|
-
function lireLesIntegrations(racine, maintenant) {
|
|
195
|
-
try {
|
|
196
|
-
const lu = JSON.parse(readFileSync(integrationsDe(racine), 'utf8'));
|
|
197
|
-
if (Number.isFinite(lu?.depuis) && Array.isArray(lu?.rendues)) {
|
|
198
|
-
return { depuis: lu.depuis, rendues: new Set(lu.rendues.map(String)) };
|
|
199
|
-
}
|
|
200
|
-
} catch {
|
|
201
|
-
// none yet
|
|
202
|
-
}
|
|
203
|
-
return { depuis: maintenant, rendues: new Set() };
|
|
204
|
-
}
|
|
205
238
|
// The alert of the CI of main of the project at <racine> (scripts/ci-de-main.mjs), read for the
|
|
206
239
|
// supervisor: `{ cle, texte }` for a red or a CI not read, null for a green (the alert clears),
|
|
207
240
|
// undefined for a project with no CI to read. The lots entered since the last green are named by
|
|
@@ -257,19 +290,6 @@ function releverLaCiDeMain(racine, alerte, toutes) {
|
|
|
257
290
|
];
|
|
258
291
|
}
|
|
259
292
|
|
|
260
|
-
// A file that cannot be written never costs the batch: the next wait reads the former one.
|
|
261
|
-
function ecrireLesIntegrations(racine, depuis, rendues) {
|
|
262
|
-
const f = integrationsDe(racine);
|
|
263
|
-
try {
|
|
264
|
-
mkdirSync(path.dirname(f), { recursive: true });
|
|
265
|
-
const provisoire = `${f}.${process.pid}`;
|
|
266
|
-
writeFileSync(provisoire, `${JSON.stringify({ depuis, rendues: [...rendues].sort() })}\n`);
|
|
267
|
-
renameSync(provisoire, f);
|
|
268
|
-
} catch {
|
|
269
|
-
// kept as it was
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
293
|
// The file of the stops gone up as text: each stop with its key, its times, and its reading and its
|
|
274
294
|
// mark when it has them, sorted by key.
|
|
275
295
|
const enTexteDesRemontees = liste =>
|
|
@@ -350,23 +370,22 @@ export function marquerChezLeResponsable(racine, { cle, depuisA }) {
|
|
|
350
370
|
}
|
|
351
371
|
|
|
352
372
|
/**
|
|
353
|
-
* One reading of the circuits <circuits>
|
|
373
|
+
* One reading of the circuits <circuits> of the repository at <racine>,
|
|
354
374
|
* at <maintenant> ms, under the lock of the file of the stops gone up; what the greffon of the
|
|
355
375
|
* session of supervision submits, and the opening lists. Each stop that waits for the supervisor
|
|
356
|
-
* and never went up, or whose last presentation is <rappelMs> ms old or more (
|
|
357
|
-
*
|
|
376
|
+
* and never went up, or whose last presentation is <rappelMs> ms old or more, is given (a
|
|
377
|
+
* question addressed to the owner goes up once and is never given again; <toutes>: every
|
|
378
|
+
* one), its ticket <fermes> gives closed left out (bd is asked of those alone); a stop
|
|
358
379
|
* given is presented now, and one that goes up has its `depuis` set now. The file is written whole
|
|
359
380
|
* with the stops that still stand, their circuit waiting for the supervisor: a question answered
|
|
360
|
-
* so leaves it, and the next stop of its circuit is new. The
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
* result is the questions given, each marked `representee` when it comes back, then the ends, then
|
|
365
|
-
* the alert of the CI of main.
|
|
381
|
+
* so leaves it, and the next stop of its circuit is new. The alert of the CI of main <ciDeMain>
|
|
382
|
+
* (`{ cle, texte }`; null at a green, which clears it; undefined when it is not read, which keeps
|
|
383
|
+
* what was given) is given once per passage. A circuit integrated gives nothing. The result is the
|
|
384
|
+
* questions given, each marked `representee` when it comes back, then the alert of the CI of main.
|
|
366
385
|
* @param {string} racine
|
|
367
386
|
* @param {import('./circuits-du-serveur.mjs').CircuitDuServeur[]} circuits
|
|
368
387
|
* @param {{ fermes: (racine: string, ids: string[]) => Set<string> | null, maintenant: number, rappelMs: number, toutes?: boolean, ciDeMain?: { cle: string, texte: string } | null }} options
|
|
369
|
-
* @returns {{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string, representee?: boolean
|
|
388
|
+
* @returns {{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string, representee?: boolean }[]}
|
|
370
389
|
*/
|
|
371
390
|
export function relever(
|
|
372
391
|
racine,
|
|
@@ -379,34 +398,21 @@ export function relever(
|
|
|
379
398
|
// Held for one reading of the circuits: older than that, abandoned.
|
|
380
399
|
prendreVerrou(verrou, { attendre: true, perime: 30_000 });
|
|
381
400
|
try {
|
|
382
|
-
const { depuis: depuisIntegrations, rendues } = lireLesIntegrations(racine, maintenant);
|
|
383
|
-
const integres = circuits
|
|
384
|
-
.filter(
|
|
385
|
-
c => c.integre && c.fin !== null && c.fin >= depuisIntegrations && !rendues.has(cleDe(c))
|
|
386
|
-
)
|
|
387
|
-
.map(enFin)
|
|
388
|
-
.sort((a, b) => a.ticket.localeCompare(b.ticket, 'en'));
|
|
389
|
-
const fins = new Map(circuits.map(c => [cleDe(c), c.fin]));
|
|
390
|
-
ecrireLesIntegrations(
|
|
391
|
-
racine,
|
|
392
|
-
maintenant,
|
|
393
|
-
[...rendues, ...integres.map(i => i.cle)].filter(
|
|
394
|
-
k => (fins.get(k) ?? -Infinity) >= maintenant
|
|
395
|
-
)
|
|
396
|
-
);
|
|
397
401
|
const rouges = ciDeMain === undefined ? [] : releverLaCiDeMain(racine, ciDeMain, toutes);
|
|
398
|
-
circuits = circuits.filter(c => !c.integre);
|
|
399
402
|
const avant = new Map(lireLesRemontees(racine, maintenant).map(r => [r.cle, r]));
|
|
400
403
|
const debout = questionsEnAttente(racine, circuits, { fermes: aucunFerme });
|
|
401
|
-
// A question comes back from its reading, never from its sending: one read,
|
|
402
|
-
// owner, whose delay has passed since its reading. One still in
|
|
403
|
-
//
|
|
404
|
+
// A question comes back from its reading, never from its sending: one read, waiting for the
|
|
405
|
+
// supervisor, not carried to the owner, whose delay has passed since its reading. One still in
|
|
406
|
+
// the queue (sent, unread), addressed to the owner or carried to him is never given again.
|
|
404
407
|
const aRendre = debout.filter(q => {
|
|
405
408
|
const r = avant.get(q.cle);
|
|
406
409
|
return (
|
|
407
410
|
toutes ||
|
|
408
411
|
!r ||
|
|
409
|
-
(
|
|
412
|
+
(q.qui !== RESPONSABLE &&
|
|
413
|
+
estLue(r) &&
|
|
414
|
+
r.chez === undefined &&
|
|
415
|
+
maintenant - r.lue >= rappelMs)
|
|
410
416
|
);
|
|
411
417
|
});
|
|
412
418
|
const fermesDe = aRendre.length
|
|
@@ -442,7 +448,7 @@ export function relever(
|
|
|
442
448
|
})
|
|
443
449
|
);
|
|
444
450
|
ecrireLesRemontees(racine, ecrit, debout.length === 0 && avant.size === 0);
|
|
445
|
-
return [...rendu, ...
|
|
451
|
+
return [...rendu, ...rouges];
|
|
446
452
|
} finally {
|
|
447
453
|
lacherVerrou(verrou);
|
|
448
454
|
}
|
|
@@ -464,17 +470,6 @@ const enQuestion = c => ({
|
|
|
464
470
|
arret: c.arret,
|
|
465
471
|
});
|
|
466
472
|
|
|
467
|
-
// The end of the circuit <c> integrated, given once by the wait: its ticket, its step, and its key.
|
|
468
|
-
const enFin = c => ({
|
|
469
|
-
ticket: c.ticket,
|
|
470
|
-
etape: '5 Intégration',
|
|
471
|
-
question: 'son lot est sur main.',
|
|
472
|
-
qui: SUPERVISEUR,
|
|
473
|
-
commande: '',
|
|
474
|
-
cle: cleDe(c),
|
|
475
|
-
integre: true,
|
|
476
|
-
});
|
|
477
|
-
|
|
478
473
|
// Of the circuits <lus> of the repository at <racine>, those whose ticket <fermes> does not give
|
|
479
474
|
// closed, sorted by ticket.
|
|
480
475
|
function enAttente(lus, racine, fermes) {
|
|
@@ -571,19 +566,13 @@ export const ligneDeQuestion = (q, o = {}) => {
|
|
|
571
566
|
/**
|
|
572
567
|
* The message the greffon submits to the session of supervision for the questions <questions> of
|
|
573
568
|
* one reading (`relever`), and the lines of the opening: for each one, its ticket, step, who must
|
|
574
|
-
* answer it, its question and the command that answers it
|
|
575
|
-
* (`
|
|
576
|
-
*
|
|
577
|
-
* @param {{ ticket: string, etape: string, question: string, qui: string, commande: string, representee?: boolean, integre?: boolean }[]} questions
|
|
569
|
+
* answer it, its question and the command that answers it. A question presented again
|
|
570
|
+
* (`representee`) says that it still waits for an answer.
|
|
571
|
+
* @param {{ ticket: string, etape: string, question: string, qui: string, commande: string, representee?: boolean }[]} questions
|
|
578
572
|
* @returns {string}
|
|
579
573
|
*/
|
|
580
574
|
export function texteDesQuestions(questions, o = {}) {
|
|
581
|
-
|
|
582
|
-
const attente = questions.filter(q => !q.integre);
|
|
583
|
-
return [
|
|
584
|
-
...attente.map(q => ligneDeQuestion(q, o)),
|
|
585
|
-
...fins.map(q => `${o.sigle ? `[${o.sigle}] ` : ''}Intégré · ${q.ticket}`),
|
|
586
|
-
].join('\n');
|
|
575
|
+
return questions.map(q => ligneDeQuestion(q, o)).join('\n');
|
|
587
576
|
}
|
|
588
577
|
|
|
589
578
|
/**
|
|
@@ -602,7 +591,7 @@ export function texteDesQuestions(questions, o = {}) {
|
|
|
602
591
|
* then those whose lot is already on main (`enFileSurMain`, main read by <surMainDe>,
|
|
603
592
|
* `lotEstSurMain` by default), which it never starts again.
|
|
604
593
|
* @param {string} racine the root of the repository
|
|
605
|
-
* The circuits are read once, by <circuitsDe> (
|
|
594
|
+
* The circuits are read once, by <circuitsDe> (lists of the Temporal server that it filters,
|
|
606
595
|
* scripts/circuits-du-serveur.mjs, by default); a server that does not answer is said, and no
|
|
607
596
|
* question goes up.
|
|
608
597
|
* @param {{ fermes?: (racine: string, ids: string[]) => Set<string> | null,
|
|
@@ -631,7 +620,6 @@ export async function circuitsALOuverture(
|
|
|
631
620
|
? `${e.message} : les circuits ne se lisent pas.`
|
|
632
621
|
: `Les circuits ne se lisent pas : ${message}.`;
|
|
633
622
|
}
|
|
634
|
-
ecrireLesIntegrations(racine, Date.now(), []);
|
|
635
623
|
const ouverteA = Date.now();
|
|
636
624
|
const questions = circuits
|
|
637
625
|
? relever(racine, circuits, {
|
|
@@ -640,7 +628,7 @@ export async function circuitsALOuverture(
|
|
|
640
628
|
rappelMs: rappelDuProjet(racine) * 60_000,
|
|
641
629
|
toutes: true,
|
|
642
630
|
ciDeMain: ciDeMainDe(racine),
|
|
643
|
-
})
|
|
631
|
+
})
|
|
644
632
|
: [];
|
|
645
633
|
// The opening lists every question that waits: the session reads them, and their reminder runs
|
|
646
634
|
// from now (a question sent to a closed session, or whose message was never recognised, included).
|
|
@@ -675,7 +663,7 @@ export async function circuitsALOuverture(
|
|
|
675
663
|
);
|
|
676
664
|
return [
|
|
677
665
|
'## Les questions des circuits',
|
|
678
|
-
"Le greffon de ta séance pousse dans la file de tes messages chaque question neuve d'un circuit du dépôt, quel que soit son lanceur
|
|
666
|
+
"Le greffon de ta séance pousse dans la file de tes messages chaque question neuve d'un circuit du dépôt, quel que soit son lanceur ; il n'y a aucune attente à lancer. Une question sans réponse au superviseur revient une fois lue, à intervalle réglable depuis sa lecture (`grillhouse.rappel`, 10 min par défaut) : ta réponse au circuit l'acquitte, et répondue elle ne revient plus ; une question que tu as portée au responsable se tait par `npx grillhouse circuit <ticket> --chez-le-responsable`, jusqu'à la réponse du circuit ; une question adressée au responsable part une fois, pour que tu la lui portes, et ne revient pas. Tu ne te mets pas en attente du responsable tant qu'une question d'un circuit attend ta réponse. Les questions en attente sont listées ci-dessous.",
|
|
679
667
|
...(panne ? ['', '## Les circuits du dépôt', panne] : []),
|
|
680
668
|
...(nommes.length ? ['', '## Les circuits du dépôt', ...nommes.map(n => n.ligne)] : []),
|
|
681
669
|
...(questions.length ? ['', `Les réponses à une question : ${REPONSES}`] : []),
|
|
@@ -698,41 +686,213 @@ const git = (racine, ...args) =>
|
|
|
698
686
|
encoding: 'utf8',
|
|
699
687
|
});
|
|
700
688
|
|
|
689
|
+
// Where the session of supervision of the directory <dossier> stands: the common directory of git
|
|
690
|
+
// and the lock; `refus` says why <dossier> or the session has none (a role's session, out of git, a
|
|
691
|
+
// copy).
|
|
692
|
+
function depotDuSuperviseur(dossier, env) {
|
|
693
|
+
if (env.BEADS_ACTOR) {
|
|
694
|
+
return { refus: "la séance d'un rôle ne supervise pas" };
|
|
695
|
+
}
|
|
696
|
+
const r = git(dossier, '--git-dir', '--git-common-dir');
|
|
697
|
+
if (r.status !== 0) {
|
|
698
|
+
return { refus: `${dossier} n'est pas dans un dépôt git` };
|
|
699
|
+
}
|
|
700
|
+
const [dossierGit, commun] = r.stdout.trim().split('\n');
|
|
701
|
+
if (path.resolve(dossierGit) !== path.resolve(commun)) {
|
|
702
|
+
return { refus: 'une copie de ticket ne supervise pas : joue la commande à la racine du dépôt' };
|
|
703
|
+
}
|
|
704
|
+
return { commun, verrou: path.join(commun, VERROU_SUPERVISEUR) };
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// The process the lock <verrou> names; null when no lock reads.
|
|
708
|
+
function tenantDe(verrou) {
|
|
709
|
+
try {
|
|
710
|
+
const pid = Number(/^(\d+)/.exec(readFileSync(verrou, 'utf8'))?.[1]);
|
|
711
|
+
return Number.isInteger(pid) ? pid : null;
|
|
712
|
+
} catch {
|
|
713
|
+
return null;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// `depotDuSuperviseur` for the session that holds the lock alone, its process in `tenant`.
|
|
718
|
+
function laSeanceQuiTient(dossier, env) {
|
|
719
|
+
const depot = depotDuSuperviseur(dossier, env);
|
|
720
|
+
if (depot.refus) {
|
|
721
|
+
return depot;
|
|
722
|
+
}
|
|
723
|
+
const tenant = tenantDe(depot.verrou);
|
|
724
|
+
return tenant !== null && estAuDessus(tenant)
|
|
725
|
+
? { ...depot, tenant }
|
|
726
|
+
: { refus: 'cette séance ne tient pas le verrou du superviseur' };
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
// Writes <texte> whole into <f>, by a rename.
|
|
730
|
+
function ecrireEntier(f, texte) {
|
|
731
|
+
const provisoire = `${f}.${process.pid}`;
|
|
732
|
+
writeFileSync(provisoire, texte);
|
|
733
|
+
renameSync(provisoire, f);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
function lireJson(f) {
|
|
737
|
+
try {
|
|
738
|
+
return JSON.parse(readFileSync(f, 'utf8'));
|
|
739
|
+
} catch {
|
|
740
|
+
return null;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
function lireTexte(f) {
|
|
745
|
+
try {
|
|
746
|
+
return readFileSync(f, 'utf8');
|
|
747
|
+
} catch {
|
|
748
|
+
return '';
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
// The gesture of the holder of the lock on the note: <ecrire> is given its session and the text of
|
|
753
|
+
// <fichier>. Code 2 and the reason, nothing written, when the session or the file is refused.
|
|
754
|
+
function surLaNote(dossier, fichier, env, ecrire) {
|
|
755
|
+
const session = laSeanceQuiTient(dossier, env);
|
|
756
|
+
if (session.refus) {
|
|
757
|
+
return { code: 2, raison: session.refus };
|
|
758
|
+
}
|
|
759
|
+
let texte;
|
|
760
|
+
try {
|
|
761
|
+
texte = readFileSync(fichier, 'utf8');
|
|
762
|
+
} catch {
|
|
763
|
+
return { code: 2, raison: `le fichier ${fichier} ne se lit pas` };
|
|
764
|
+
}
|
|
765
|
+
if (!texte.trim()) {
|
|
766
|
+
return { code: 2, raison: `le fichier ${fichier} est vide` };
|
|
767
|
+
}
|
|
768
|
+
ecrire(session, texte);
|
|
769
|
+
return { code: 0, raison: '' };
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* The session that holds the lock of the supervisor of <dossier> declares a milestone: the text of
|
|
774
|
+
* <fichier> replaces its note of resumption whole, and the milestone, which holds for the context
|
|
775
|
+
* that declares it, replaces the one before (`superviseur --jalon`).
|
|
776
|
+
* @param {string} dossier
|
|
777
|
+
* @param {string} fichier
|
|
778
|
+
* @param {{ env?: Record<string, string | undefined> }} [options]
|
|
779
|
+
* @returns {Promise<{ code: number, raison: string }>} code 2 and its reason, nothing written, on a
|
|
780
|
+
* refusal
|
|
781
|
+
*/
|
|
782
|
+
export async function declarerLeJalon(dossier, fichier, { env = process.env } = {}) {
|
|
783
|
+
return surLaNote(dossier, fichier, env, ({ commun, tenant }, texte) => {
|
|
784
|
+
ecrireEntier(path.join(commun, NOTE_DE_REPRISE), texte);
|
|
785
|
+
ecrireEntier(path.join(commun, JALON), `${JSON.stringify({ declareA: Date.now(), tenant })}\n`);
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* The session that holds the lock adds the text of <fichier> at the end of its note of resumption,
|
|
791
|
+
* which it creates when there is none; no milestone is declared (`superviseur --question`).
|
|
792
|
+
* @param {string} dossier
|
|
793
|
+
* @param {string} fichier
|
|
794
|
+
* @param {{ env?: Record<string, string | undefined> }} [options]
|
|
795
|
+
* @returns {Promise<{ code: number, raison: string }>} code 2 and its reason, nothing written, on a
|
|
796
|
+
* refusal
|
|
797
|
+
*/
|
|
798
|
+
export async function ajouterLaQuestion(dossier, fichier, { env = process.env } = {}) {
|
|
799
|
+
return surLaNote(dossier, fichier, env, ({ commun }, texte) => {
|
|
800
|
+
const note = path.join(commun, NOTE_DE_REPRISE);
|
|
801
|
+
const avant = lireTexte(note);
|
|
802
|
+
const joint = avant ? `${avant.replace(/\n*$/, '')}\n\n` : '';
|
|
803
|
+
ecrireEntier(note, `${joint}${texte}`);
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
|
|
701
807
|
/**
|
|
702
|
-
* The
|
|
703
|
-
*
|
|
704
|
-
*
|
|
705
|
-
*
|
|
808
|
+
* The message of resumption when the renewal of the session of supervision of <dossier> is due,
|
|
809
|
+
* empty otherwise (`superviseur --renouveler`): the session holds the lock, a milestone it declared
|
|
810
|
+
* stands, and a quiet Stop (<arretA>, ms, 0 without one) is later than it. A message of the owner
|
|
811
|
+
* (<messageA>, ms, 0 without one) later than the declaration cancels the milestone. The reading
|
|
812
|
+
* keeps a milestone that is due: the opening that follows the /clear removes it.
|
|
813
|
+
* @param {string} dossier
|
|
814
|
+
* @param {{ arretA: number, messageA: number, env?: Record<string, string | undefined> }} options
|
|
706
815
|
* @returns {Promise<string>}
|
|
707
816
|
*/
|
|
708
|
-
async function
|
|
709
|
-
|
|
817
|
+
export async function renouvellement(dossier, { arretA, messageA, env = process.env }) {
|
|
818
|
+
const session = laSeanceQuiTient(dossier, env);
|
|
819
|
+
if (session.refus) {
|
|
710
820
|
return '';
|
|
711
821
|
}
|
|
712
|
-
const
|
|
713
|
-
|
|
822
|
+
const f = path.join(session.commun, JALON);
|
|
823
|
+
const jalon = lireJson(f);
|
|
824
|
+
if (!jalon || jalon.tenant !== session.tenant) {
|
|
714
825
|
return '';
|
|
715
826
|
}
|
|
716
|
-
|
|
717
|
-
|
|
827
|
+
if (messageA > jalon.declareA) {
|
|
828
|
+
rmSync(f, { force: true });
|
|
718
829
|
return '';
|
|
719
830
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
831
|
+
return arretA > jalon.declareA ? MESSAGE_DE_REPRISE : '';
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// The section the opening gives of the note of resumption <note>; empty when none is written.
|
|
835
|
+
function laNote(note) {
|
|
836
|
+
const texte = lireTexte(note).trimEnd();
|
|
837
|
+
return texte
|
|
838
|
+
? [
|
|
839
|
+
'## La note de reprise',
|
|
840
|
+
`Elle est au fichier \`${note}\` : lis-le en entier si ce texte est coupé.`,
|
|
841
|
+
'',
|
|
842
|
+
texte,
|
|
843
|
+
].join('\n')
|
|
844
|
+
: '';
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
// What the opening that follows a /clear asks, before the circuits and the note.
|
|
848
|
+
const APRES_CLEAR = [
|
|
849
|
+
'## Reprise de la supervision après un /clear',
|
|
850
|
+
'Charge la compétence `grillhouse:pitmaster`, puis reprends la note de reprise donnée plus bas ; ne fais aucun tour complet.',
|
|
851
|
+
'À ton premier tour, quel que soit le message qui l’ouvre, repose au responsable la question que la note tient en attente.',
|
|
852
|
+
].join('\n');
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* The check of the supervisor at the opening of a session in <dossier> (greffon.md, §5.2): what it
|
|
856
|
+
* says (empty when nothing), the lock taken when it is free. <source> is the one of the
|
|
857
|
+
* SessionStart hook. The session that takes the lock, and the holder after a /clear, receive the
|
|
858
|
+
* circuits and the note of resumption; every opening of the holder but after a compaction removes
|
|
859
|
+
* the declared milestone.
|
|
860
|
+
* @param {string} dossier the directory the session opens in
|
|
861
|
+
* @param {{ source?: string, env?: Record<string, string | undefined>, circuitsDe?: (racine: string) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]> }} [options]
|
|
862
|
+
* @returns {Promise<string>}
|
|
863
|
+
*/
|
|
864
|
+
export async function ouvertureDuSuperviseur(
|
|
865
|
+
dossier,
|
|
866
|
+
{ source = 'startup', env = process.env, circuitsDe = circuitsDuServeur } = {}
|
|
867
|
+
) {
|
|
868
|
+
const depot = depotDuSuperviseur(dossier, env);
|
|
869
|
+
if (depot.refus) {
|
|
730
870
|
return '';
|
|
731
871
|
}
|
|
732
|
-
|
|
733
|
-
|
|
872
|
+
const { commun, verrou } = depot;
|
|
873
|
+
const moi = seance();
|
|
874
|
+
const tenait = tenantDe(verrou) === moi;
|
|
875
|
+
if (!tenait && !prendreVerrou(verrou, { attendre: false, pid: moi })) {
|
|
876
|
+
return unAutreSuperviseur(verrou, moi);
|
|
734
877
|
}
|
|
735
|
-
|
|
878
|
+
if (source !== 'compact') {
|
|
879
|
+
rmSync(path.join(commun, JALON), { force: true });
|
|
880
|
+
}
|
|
881
|
+
if (tenait && source !== 'clear') {
|
|
882
|
+
return '';
|
|
883
|
+
}
|
|
884
|
+
return [
|
|
885
|
+
source === 'clear' ? APRES_CLEAR : '',
|
|
886
|
+
await circuitsALOuverture(path.dirname(commun), { circuitsDe }),
|
|
887
|
+
laNote(path.join(commun, NOTE_DE_REPRISE)),
|
|
888
|
+
]
|
|
889
|
+
.filter(Boolean)
|
|
890
|
+
.join('\n\n');
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
// The section a session receives when another live one holds the lock <verrou>; empty when none does.
|
|
894
|
+
function unAutreSuperviseur(verrou, moi) {
|
|
895
|
+
const autre = tenantDe(verrou);
|
|
736
896
|
if (!autre || autre === moi || !vivant(autre)) {
|
|
737
897
|
return '';
|
|
738
898
|
}
|
|
@@ -748,60 +908,103 @@ async function superviseur(racine, { env = process.env } = {}) {
|
|
|
748
908
|
].join('\n');
|
|
749
909
|
}
|
|
750
910
|
|
|
911
|
+
// Whether a question of the circuits <circuits> of the repository at <racine> waits for the
|
|
912
|
+
// supervisor, read or not: neither addressed to the owner, nor carried to him, nor deferred to a
|
|
913
|
+
// later time, its ticket open. null when the tickets do not read.
|
|
914
|
+
function uneQuestionAttend(racine, circuits) {
|
|
915
|
+
const chez = new Set(
|
|
916
|
+
lireLesRemontees(racine, Date.now())
|
|
917
|
+
.filter(r => r.chez !== undefined)
|
|
918
|
+
.map(r => r.cle)
|
|
919
|
+
);
|
|
920
|
+
const debout = circuits.filter(
|
|
921
|
+
c => attendLeSuperviseur(c) && c.qui !== RESPONSABLE && !chez.has(cleDe(c))
|
|
922
|
+
);
|
|
923
|
+
if (!debout.length) {
|
|
924
|
+
return false;
|
|
925
|
+
}
|
|
926
|
+
const hors = ticketsHorsAttente(
|
|
927
|
+
racine,
|
|
928
|
+
debout.map(c => c.ticket)
|
|
929
|
+
);
|
|
930
|
+
return hors === null ? null : debout.some(c => !hors.has(c.ticket));
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
// The request the reading submits to the session, for the reason <raison>.
|
|
934
|
+
const demandeDuJalon = raison =>
|
|
935
|
+
`Jalon · ${raison} : écris ta note de reprise et déclare le jalon (compétence \`grillhouse:pitmaster\`), par \`npx grillhouse superviseur --jalon <fichier>\`.`;
|
|
936
|
+
|
|
751
937
|
/**
|
|
752
938
|
* One reading for the greffon of the session of supervision of the repository at <racine>
|
|
753
939
|
* (`npx grillhouse superviseur --relever`): the message of what `relever` gives (the questions of
|
|
754
|
-
* the circuits due, the
|
|
940
|
+
* the circuits due, the reds of main), empty when it gives nothing, when the
|
|
755
941
|
* circuits do not read, or when the session that runs it is not the one that holds the lock of the
|
|
756
942
|
* supervisor (a role's session, an agent's copy, another project's, a session that took no lock).
|
|
757
943
|
* The interval of the re-presentation is the key `grillhouse.rappel` of the project, applied at
|
|
758
944
|
* each reading. The session reads too each other project of its group (`grillhouse.groupe`) that
|
|
759
945
|
* no other live session of supervision holds (`voisinsSansSuperviseur`): its part follows, under
|
|
760
946
|
* the name and the folder of that project, where its answers are played, with that project's own
|
|
761
|
-
* interval and state.
|
|
947
|
+
* interval and state. A fault in the reading of one of these projects costs the others nothing: it
|
|
948
|
+
* is thrown once all are read, each project at fault named with its reason, the message of the
|
|
949
|
+
* others in the `texte` of the error. Last comes the request to write the note of resumption and
|
|
950
|
+
* declare a milestone: after a compaction (<compaction>), and once for each night of the project
|
|
951
|
+
* (`grillhouse.plageDeNuit`) at a reading where every project read says that no question waits for
|
|
952
|
+
* the supervisor.
|
|
762
953
|
* @param {string} racine
|
|
763
|
-
* @param {{ env?: Record<string, string | undefined>, circuitsDe?: (racine: string
|
|
954
|
+
* @param {{ env?: Record<string, string | undefined>, compaction?: boolean, circuitsDe?: (racine: string) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]> }} [options]
|
|
764
955
|
* @returns {Promise<string>}
|
|
765
|
-
* @throws {Error} `grillhouse.rappel` is at fault, named with its
|
|
956
|
+
* @throws {Error} `grillhouse.rappel` of the project of the session is at fault, named with its
|
|
957
|
+
* value; or the reading of another project of the group failed (its `texte`: the others' message)
|
|
766
958
|
*/
|
|
767
959
|
export async function releverPourLeGreffon(
|
|
768
960
|
racine,
|
|
769
|
-
{ env = process.env, circuitsDe = circuitsDuServeur } = {}
|
|
961
|
+
{ env = process.env, circuitsDe = circuitsDuServeur, compaction = false } = {}
|
|
770
962
|
) {
|
|
771
|
-
|
|
963
|
+
const depot = depotDuSuperviseur(racine, env);
|
|
964
|
+
if (depot.refus) {
|
|
772
965
|
return '';
|
|
773
966
|
}
|
|
774
|
-
const
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
}
|
|
778
|
-
const [dossierGit, commun] = r.stdout.trim().split('\n');
|
|
779
|
-
if (path.resolve(dossierGit) !== path.resolve(commun)) {
|
|
780
|
-
return '';
|
|
781
|
-
}
|
|
782
|
-
const verrou = path.join(commun, VERROU_SUPERVISEUR);
|
|
783
|
-
let tenant = null;
|
|
784
|
-
try {
|
|
785
|
-
tenant = Number(/^(\d+)/.exec(readFileSync(verrou, 'utf8'))?.[1]);
|
|
786
|
-
} catch {
|
|
967
|
+
const { commun, verrou } = depot;
|
|
968
|
+
let tenant = tenantDe(verrou);
|
|
969
|
+
if (tenant === null) {
|
|
787
970
|
return '';
|
|
788
971
|
}
|
|
789
972
|
// A lock whose process is gone is taken over, as the opening does: the session that reads holds it.
|
|
790
|
-
if (
|
|
973
|
+
if (!estAuDessus(tenant) && !vivant(tenant)) {
|
|
791
974
|
const moi = seance();
|
|
792
975
|
tenant = prendreVerrou(verrou, { attendre: false, pid: moi }) ? moi : null;
|
|
793
976
|
}
|
|
794
|
-
if (
|
|
977
|
+
if (tenant === null || !estAuDessus(tenant)) {
|
|
795
978
|
return '';
|
|
796
979
|
}
|
|
797
|
-
const
|
|
980
|
+
const demandeNocturne = path.join(commun, DEMANDE_DE_NUIT);
|
|
981
|
+
const nuit = nuitEnCours(Date.now(), plageDeNuit(racine));
|
|
982
|
+
const aDemander = nuit !== null && lireJson(demandeNocturne)?.nuit !== nuit;
|
|
983
|
+
const apresCompaction = compaction ? demandeDuJalon('une compaction a eu lieu') : '';
|
|
984
|
+
const parts = [];
|
|
985
|
+
try {
|
|
986
|
+
parts.push(await leReleveDe(racine, circuitsDe, { nocturne: aDemander }));
|
|
987
|
+
} catch (e) {
|
|
988
|
+
throw Object.assign(e, { texte: apresCompaction });
|
|
989
|
+
}
|
|
990
|
+
const fautes = [];
|
|
798
991
|
for (const p of voisinsSansSuperviseur(racine)) {
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
992
|
+
try {
|
|
993
|
+
parts.push(await leReleveDe(p.chemin, circuitsDe, { voisin: true, nocturne: aDemander }));
|
|
994
|
+
} catch (e) {
|
|
995
|
+
fautes.push(`${path.basename(p.chemin)} : ${e.message}`);
|
|
802
996
|
}
|
|
803
997
|
}
|
|
804
|
-
|
|
998
|
+
let demande = apresCompaction;
|
|
999
|
+
if (aDemander && !fautes.length && parts.every(p => p.attend === false)) {
|
|
1000
|
+
ecrireEntier(demandeNocturne, `${JSON.stringify({ nuit })}\n`);
|
|
1001
|
+
demande ||= demandeDuJalon('la nuit a commencé');
|
|
1002
|
+
}
|
|
1003
|
+
const texte = [...parts.map(p => p.texte), demande].filter(Boolean).join('\n\n');
|
|
1004
|
+
if (fautes.length) {
|
|
1005
|
+
throw Object.assign(new Error(fautes.join('\n')), { texte });
|
|
1006
|
+
}
|
|
1007
|
+
return texte;
|
|
805
1008
|
}
|
|
806
1009
|
|
|
807
1010
|
// The package.json of the project at <racine>; empty when it does not read.
|
|
@@ -813,19 +1016,22 @@ function paquetDe(racine) {
|
|
|
813
1016
|
}
|
|
814
1017
|
}
|
|
815
1018
|
|
|
816
|
-
//
|
|
817
|
-
//
|
|
818
|
-
//
|
|
819
|
-
|
|
1019
|
+
// One reading of the project at <racine>, under its own interval (`grillhouse.rappel`) and its own
|
|
1020
|
+
// state of the questions presented: `texte`, its message, empty when it gives nothing or when its
|
|
1021
|
+
// circuits do not read; `attend`, read for the request of the night (<o.nocturne>), whether a
|
|
1022
|
+
// question waits for the supervisor (`uneQuestionAttend`), null when unknown. A faulty interval
|
|
1023
|
+
// throws, the project of the session named (a neighbour is named by the caller, as for any fault of
|
|
1024
|
+
// its reading).
|
|
1025
|
+
async function leReleveDe(racine, circuitsDe, { voisin = false, nocturne = false } = {}) {
|
|
820
1026
|
const { minutes, faute } = reglageDuRappel(paquetDe(racine));
|
|
821
1027
|
if (faute) {
|
|
822
|
-
throw new Error(`${path.basename(racine)} : ${faute}`);
|
|
1028
|
+
throw new Error(voisin ? faute : `${path.basename(racine)} : ${faute}`);
|
|
823
1029
|
}
|
|
824
1030
|
let circuits;
|
|
825
1031
|
try {
|
|
826
|
-
circuits = await circuitsDe(racine
|
|
1032
|
+
circuits = await circuitsDe(racine);
|
|
827
1033
|
} catch {
|
|
828
|
-
return '';
|
|
1034
|
+
return { texte: '', attend: null };
|
|
829
1035
|
}
|
|
830
1036
|
const lot = relever(racine, circuits, {
|
|
831
1037
|
fermes: ticketsHorsAttente,
|
|
@@ -837,7 +1043,10 @@ async function leReleveDe(racine, circuitsDe, voisin = false) {
|
|
|
837
1043
|
const projet = voisin
|
|
838
1044
|
? { sigle: sigleDuProjet(racine).sigle ?? path.basename(racine), dossier: racine }
|
|
839
1045
|
: {};
|
|
840
|
-
return
|
|
1046
|
+
return {
|
|
1047
|
+
texte: lot.length ? texteDesQuestions(lot, projet) : '',
|
|
1048
|
+
attend: nocturne ? uneQuestionAttend(racine, circuits) : null,
|
|
1049
|
+
};
|
|
841
1050
|
}
|
|
842
1051
|
|
|
843
1052
|
// The other projects of the group of the project at <racine> (`grillhouse.groupe`) that no other
|
|
@@ -872,13 +1081,40 @@ function racineDe(dossier) {
|
|
|
872
1081
|
}
|
|
873
1082
|
|
|
874
1083
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
875
|
-
if (process.argv[2] === '--
|
|
1084
|
+
if (process.argv[2] === '--jalon' || process.argv[2] === '--question') {
|
|
1085
|
+
// superviseur --jalon|--question <fichier> : played from the root of the repository.
|
|
1086
|
+
const geste = process.argv[2] === '--jalon' ? declarerLeJalon : ajouterLaQuestion;
|
|
1087
|
+
const { code, raison } = process.argv[3]
|
|
1088
|
+
? await geste(process.cwd(), process.argv[3])
|
|
1089
|
+
: { code: 2, raison: 'le fichier manque' };
|
|
1090
|
+
if (raison) {
|
|
1091
|
+
process.stderr.write(`${process.argv[2]} : ${raison}.\n`);
|
|
1092
|
+
}
|
|
1093
|
+
process.exitCode = code;
|
|
1094
|
+
} else if (process.argv[2] === '--renouveler') {
|
|
1095
|
+
// superviseur --renouveler <dossier> <arretA> <messageA> (the greffon, at each period).
|
|
1096
|
+
const [, , , dossier, arretA, messageA] = process.argv;
|
|
1097
|
+
const texte = await renouvellement(dossier ?? process.cwd(), {
|
|
1098
|
+
arretA: Number(arretA),
|
|
1099
|
+
messageA: Number(messageA),
|
|
1100
|
+
});
|
|
1101
|
+
if (texte) {
|
|
1102
|
+
process.stdout.write(`${texte}\n`);
|
|
1103
|
+
}
|
|
1104
|
+
} else if (process.argv[2] === '--relever') {
|
|
1105
|
+
const args = process.argv.slice(3);
|
|
1106
|
+
const dossier = args.find(a => a !== '--compaction') ?? process.cwd();
|
|
876
1107
|
try {
|
|
877
|
-
const texte = await releverPourLeGreffon(racineDe(
|
|
1108
|
+
const texte = await releverPourLeGreffon(racineDe(dossier), {
|
|
1109
|
+
compaction: args.includes('--compaction'),
|
|
1110
|
+
});
|
|
878
1111
|
if (texte) {
|
|
879
1112
|
process.stdout.write(`${texte}\n`);
|
|
880
1113
|
}
|
|
881
1114
|
} catch (e) {
|
|
1115
|
+
if (e.texte) {
|
|
1116
|
+
process.stdout.write(`${e.texte}\n`);
|
|
1117
|
+
}
|
|
882
1118
|
process.stderr.write(`${e.message}\n`);
|
|
883
1119
|
process.exitCode = 1;
|
|
884
1120
|
}
|
|
@@ -916,7 +1152,9 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
|
916
1152
|
}
|
|
917
1153
|
}
|
|
918
1154
|
} else {
|
|
919
|
-
const texte = await
|
|
1155
|
+
const texte = await ouvertureDuSuperviseur(process.argv[2] ?? process.cwd(), {
|
|
1156
|
+
source: process.argv[3] || undefined,
|
|
1157
|
+
});
|
|
920
1158
|
if (texte) {
|
|
921
1159
|
process.stdout.write(`${texte}\n`);
|
|
922
1160
|
}
|