@roomi-fields/grillhouse 0.36.0 → 0.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +22 -0
  3. package/cadre/templates/projet/.github/workflows/ci.yml +10 -0
  4. package/cadre/templates/projet/.github/workflows/nuit.yml +5 -0
  5. package/charte.md +5 -0
  6. package/dist/temporal/nuits/activites.d.ts +10 -1
  7. package/dist/temporal/nuits/activites.js +59 -3
  8. package/dist/temporal/nuits/activites.js.map +1 -1
  9. package/dist/temporal/nuits/contrat.d.ts +15 -0
  10. package/dist/temporal/nuits/deroule.js +67 -35
  11. package/dist/temporal/nuits/deroule.js.map +1 -1
  12. package/dist/temporal/places/client.d.ts +12 -0
  13. package/dist/temporal/places/client.js +23 -1
  14. package/dist/temporal/places/client.js.map +1 -1
  15. package/dist/temporal/places/contrat.d.ts +35 -0
  16. package/dist/temporal/places/contrat.js +11 -0
  17. package/dist/temporal/places/contrat.js.map +1 -1
  18. package/dist/temporal/places/deroule.js +47 -2
  19. package/dist/temporal/places/deroule.js.map +1 -1
  20. package/docs/ARCHITECTURE.md +14 -3
  21. package/docs/CADRE.md +11 -0
  22. package/docs/INTERFACE.md +6 -3
  23. package/package.json +1 -1
  24. package/scripts/activites.mjs +10 -4
  25. package/scripts/aiguillage.mjs +1 -0
  26. package/scripts/binaires.mjs +119 -0
  27. package/scripts/grillhouse-maj.mjs +3 -60
  28. package/scripts/integration/integrer.mjs +18 -10
  29. package/scripts/langages/cargo/binaires.mjs +1 -1
  30. package/scripts/langages/cargo/clippy.mjs +1 -1
  31. package/scripts/langages/cargo/commandes.mjs +1 -1
  32. package/scripts/langages/cargo/sccache.mjs +1 -1
  33. package/scripts/langages/python/commandes.mjs +1 -1
  34. package/scripts/paquet.mjs +2 -7
  35. package/scripts/places-de-la-machine.mjs +40 -28
  36. package/scripts/regles-des-places.d.mts +27 -2
  37. package/scripts/regles-des-places.mjs +66 -5
  38. package/scripts/sous-commandes.mjs +1 -0
  39. package/scripts/tableau.mjs +395 -180
@@ -12,22 +12,32 @@
12
12
  // common git directory, where the status line (`scripts/ligne-etat/`) reads it.
13
13
  //
14
14
  // - Global: the work tickets of the project (a ticket without children; a mother is a grouping)
15
- // by state, the agents' working time and tokens of the day and in all, the alerts.
15
+ // by state, the agents' working time and tokens of the day and in all, the alerts. The head's
16
+ // first line counts the signs AGENTS shows (`etatsDAgents`, the one source: « ▶ N · ⏸ N · ⛔ N
17
+ // · N faits », a ticket closed and not integrated counted under its sign, not as done), one line
18
+ // per project on a board of several; the line of the queues counts the tickets blocked
19
+ // by an open ticket; the status line says the same signs in the same words.
16
20
  // - Agents: the tree of the steps of the process (scripts/etapes.mjs), one block per step and
17
21
  // sub-step, with who works there, for the whole project. A ticket stands at a step only by its
18
22
  // circuit (below) or by an agent that runs on it, at that agent's step; a ticket in the queue,
19
- // with neither, stands at no step.
20
- // - Circuits: one entry per open ticket whose circuit (scripts/circuit.mjs) runs or stopped, read
21
- // from the Temporal server in one call (scripts/circuits-du-serveur.mjs, the memo of its
22
- // workflow): it runs while its workflow runs with no question awaited, and stands at the step of
23
- // its last state, with its attempt, every step one for the whole ticket; while the explorateur
24
- // or the questionneur works on its plan (`questionnement`, of the plan), it stands at the plan
25
- // (1); waiting for the supervisor (`attendLeSuperviseur`, the one rule the opening and the wait
26
- // of the questions read too: stopped, « à repasser » included, but by the supervisor's
27
- // « arrete », or ended without its issue), it stands under the stopped
28
- // step after a line « ⤷ Question · <qui> », who must answer it, the supervisor or the owner, the
29
- // supervisor when it names no question; its card opens on that question, or on the stop
30
- // (its name and code) and the first line of its reason.
23
+ // its circuit not launched, stands at no step.
24
+ // - Circuits: one entry per known ticket, open or closed, whose circuit (scripts/circuit.mjs) is
25
+ // launched and not integrated, read from the Temporal server in one call
26
+ // (scripts/circuits-du-serveur.mjs, the memo of its workflow), so that the ticket stands in
27
+ // AGENTS at every instant from the launch of its circuit to its end: it runs while its workflow
28
+ // runs with no question awaited, and stands at the step of its last state, with its attempt,
29
+ // every step one for the whole ticket, a running one with no known state at the step of its
30
+ // stop, else at the plan (1); while the explorateur or the questionneur works on its plan
31
+ // (`questionnement`, of the plan), it stands at the plan (1); waiting for the supervisor
32
+ // (`attendLeSuperviseur`, the one rule the opening and the wait of the questions read too:
33
+ // stopped, « à repasser » included, but by the supervisor's « arrete », or ended without its
34
+ // issue), it stands under the stopped step after a line « ⤷ Question · <qui> », who must answer
35
+ // it, the supervisor or the owner, the supervisor when it names no question; its card opens on
36
+ // that question, or on the stop (its name and code) and the first line of its reason.
37
+ // - Readings: a reading of the circuits or of the tickets that fails (the Temporal server silent
38
+ // or at fault, Beads at fault) gives way to the last one that succeeded, kept in the common git
39
+ // directory (`lectureGardee`, `tableau-lu-<quoi>.json`), its age in the alert that names the
40
+ // fault; a project beside the session's says the faults of its own reading.
31
41
  // - Bilans: the card of a ticket whose circuit kept its bilan (scripts/bilan.mjs,
32
42
  // `.claude/worktrees/<ticket>.bilan.json`) opens on its key figures: wall time, share lost,
33
43
  // sessions, cost.
@@ -62,37 +72,43 @@
62
72
  // its pass, read in the progress directory its state names (scripts/avancement.mjs), in
63
73
  // figures, as Bazel's counter of actions: « faits/prévus · <durée> » since the start of the
64
74
  // pass, after the counters of its loops, or in their place when room lacks (the subject is cut,
65
- // never the figures); the queue (5.2), the steps of its CI. Past FIGEE
66
- // without a sign, « ⚠ figée <durée> · faits/prévus », the time since its last sign, in the
67
- // tone of an alert.
75
+ // never the figures nor the ticket's number); the queue (5.2), the steps of its CI. Past FIGEE
76
+ // without a sign, « figée <durée> · faits/prévus », the time since its last sign, signed ⛔ in
77
+ // the tone of an alert.
68
78
  // - The lock of the machine (scripts/verrou-de-machine.mjs, read by `lireLaMesure`), as lslocks
69
79
  // names who holds a lock and cargo says what its wait waits for. A holder or a wait of a circuit
70
80
  // AGENTS shows stands on that circuit's line, one line per ticket, in place of the progress of
71
- // its pass: « · 🔒 <sorte> faits/prévus · <durée> » since it took the lock, « · ⚠ <sorte> figée
72
- // <durée> · faits/prévus » past FIGEE without a sign, « · ⏳ <sorte> · <durée> » for a wait, the
73
- // kind in lower case. Any other stands at the head of AGENTS: its holder, whoever it is (a pass
74
- // out of a ticket, the circuit of a ticket of any project of the machine), « 🔒 <sorte> ·
75
- // <projet> · <qui> · faits/prévus · <durée> », « ⚠ <sorte> figée <durée> · <projet> · <qui> ·
76
- // faits/prévus »; then each pass that waits for the lock or for room under /tmp, the oldest
77
- // first, « ⏳ <sorte> · <projet> · <qui> · attend · <durée> ». <qui> is its ticket without its
78
- // prefix (`courtDuTicket`), else the folder of its copy (`copie`, under .claude/worktrees/, or
79
- // the main tree when the project is not named); <projet> is left out for the project of the
80
- // board (`ici`). The width cuts the project first, then leaves out « attend », then cuts <qui>,
81
- // never the kind, the figures nor the time. Such a line
82
- // is marked `avancement`, which the pane measures again more often. A circuit that waits shows
83
- // ⏳ on its ticket's line, ▶ while it waits for nothing.
84
- // - Signs: each sign keeps one sense (the owner's decision of 2026-11-01): ▶ in progress, ⏸ a
85
- // stopped circuit, 🔒 the holder of the lock, ⏳ a wait for it or for room, 💤 a ticket claimed
86
- // with nothing running, 🌙 a red night, ⚠ the alerts without a kind of their own. A sign two
87
- // columns wide stands as the others, a sign then a space; the width of a line counts its
88
- // columns (`colonnes`), ⏳ two.
81
+ // its pass: « · <sorte> faits/prévus · <durée> » since it took the lock, « · <sorte> figée
82
+ // <durée> · faits/prévus » past FIGEE without a sign, « · verrou <sorte> · <durée> » for a
83
+ // wait, the kind in lower case. Any other stands at the head of AGENTS, with the machine: its
84
+ // holder, whoever it is (a pass out of a ticket, the circuit of a ticket of any project of the
85
+ // machine), « 🔒 <sorte> · <projet> · <qui> · faits/prévus · <durée> », « ⚠ <sorte> figée
86
+ // <durée> · <projet> · <qui> · faits/prévus »; then each pass that waits for the lock or for
87
+ // room under /tmp, the oldest first, « ⏳ <sorte> · <projet> · <qui> · attend · <durée> ». <qui>
88
+ // is its ticket without its prefix (`courtDuTicket`), else the folder of its copy (`copie`,
89
+ // under .claude/worktrees/, or the main tree when the project is not named); <projet> is left
90
+ // out for the project of the board (`ici`). The width cuts the project first, then leaves out
91
+ // « attend », then cuts <qui>, never the kind, the figures nor the time. Such a line is marked
92
+ // `avancement`, which the pane measures again more often.
93
+ // - Signs: each sign keeps one sense (the owner's decisions of 2026-11-01 and 2026-11-12). A
94
+ // ticket's line in AGENTS takes one of three, by the tone of its state: ▶ its step works (cyan),
95
+ // a ticket led in direct included; ⏸ it waits, under the step about to be launched, the reason
96
+ // on its right (« attend une place », « verrou », « CI », « disque », « démarre » in grey, the
97
+ // circuit waiting for the machine; « question au superviseur », « question au responsable »,
98
+ // « arrêté » in yellow, the circuit waiting for someone); ⛔ it stopped on a fault or its pass is
99
+ // frozen, to correct (red). The head of AGENTS, the machine's lines: 🔒 the holder of the lock,
100
+ // ⏳ a pass that waits for it or for room, 🌙 the night under way. The alerts: 💤 a ticket
101
+ // claimed with nothing running, 🌙 a red night, ⚠ the alerts without a kind of their own. A
102
+ // sign two columns wide stands as the others, a sign then a space; the width of a line counts
103
+ // its columns (`colonnes`), ⏳ and ⛔ two.
89
104
  // - Alerts: one alert per open night ticket (🌙, its subject, then its number), per circuit that
90
105
  // waits for the supervisor (⏳, how long), a shell agent silent for 10 minutes, a ticket in
91
106
  // progress without anything running for 30 minutes (💤), each with its state (`etat`).
92
107
  // - Tones: each state the board shows has one tone, defined once (`TONS`), which every line and
93
108
  // every alert takes, whatever its duration or the line that shows it: red for what asks for a
94
109
  // correction (frozen, a fault, a question with no live wait, a ceiling refused), yellow for what
95
- // waits for an answer or a look (the supervisor, the owner, the disk), cyan for what runs.
110
+ // waits for someone (the supervisor, the owner), grey for what waits for the machine (a place,
111
+ // the lock, the disk, the CI), cyan for what runs.
96
112
  import { execFileSync } from 'node:child_process';
97
113
  import {
98
114
  closeSync,
@@ -101,6 +117,7 @@ import {
101
117
  readdirSync,
102
118
  readFileSync,
103
119
  readSync,
120
+ renameSync,
104
121
  statSync,
105
122
  writeFileSync,
106
123
  } from 'node:fs';
@@ -174,10 +191,10 @@ export const ETATS = [
174
191
  // The tone of each state the board shows, defined once: as a dashboard of states (GitHub Checks,
175
192
  // Alertmanager), the severity belongs to the state, never to its duration nor to the line that
176
193
  // shows it; the duration stays in the text. Every line and every alert takes its tone here:
177
- // `alerte` (red), what asks for a correction; `attention` (yellow), what waits for an answer or a
178
- // look; `actif` (cyan), what runs; `discret`, what is done, empty or a measure; `titre`, a
179
- // heading; none, a ticket at rest. The pane turns each tone into its colour (mods/grillhouse
180
- // `couleur`).
194
+ // `alerte` (red), what asks for a correction; `attention` (yellow), what waits for someone, an
195
+ // answer or a look; `actif` (cyan), what runs; `discret` (grey), what waits for the machine (a
196
+ // place, the lock, the disk, the CI), what is done, empty or a measure; `titre`, a heading; none,
197
+ // a ticket at rest. The pane turns each tone into its colour (mods/grillhouse `couleur`).
181
198
  export const TONS = Object.freeze({
182
199
  // A ticket's state (ETATS).
183
200
  enCours: 'actif',
@@ -189,11 +206,13 @@ export const TONS = Object.freeze({
189
206
  reportes: undefined,
190
207
  fermes: 'discret',
191
208
  // A circuit, a pass, a wait.
192
- attendUnePlace: 'attention',
193
- attendLeVerrou: 'actif',
209
+ attendUnePlace: 'discret',
210
+ attendLeVerrou: 'discret',
211
+ attendLeDisque: 'discret',
212
+ attendLaCI: 'discret',
213
+ sansEtape: 'discret',
194
214
  enDirect: 'actif',
195
215
  nuitEnCours: 'actif',
196
- attendLeDisque: 'attention',
197
216
  attendLeSuperviseur: 'attention',
198
217
  attendLeResponsable: 'attention',
199
218
  arrete: 'attention',
@@ -203,6 +222,7 @@ export const TONS = Object.freeze({
203
222
  outilNonInstallable: 'attention',
204
223
  machineChargee: 'attention',
205
224
  fige: 'alerte',
225
+ sansIssue: 'alerte',
206
226
  panne: 'alerte',
207
227
  nuitRouge: 'alerte',
208
228
  sansAttente: 'alerte',
@@ -810,16 +830,21 @@ export function lecture(t, prefix) {
810
830
  * under way on the machine (scripts/circuits-du-serveur.mjs `nuitDuServeur`), its line under the
811
831
  * places'; `muet`, the Temporal
812
832
  * server did not answer the reading of the circuits, which the first alert says; `faute`, any
813
- * other fault of that reading, said in the first alert as it is; `echecPrefixe`, the cause of a
814
- * ticket prefix that did not read, named in an alert; `voies`, the way of each circuit done
815
- * (`voiesDesCircuits`), whose sign FAITS AUJOURD'HUI shows.
833
+ * other fault of that reading, said in the first alert as it is; `circuitsLusA`, when the reading
834
+ * failed, the time of the last one that succeeded, whose circuits `circuits` holds and whose age
835
+ * the alert says; `fauteTickets`, the fault of the reading of the tickets, said in an alert, and
836
+ * `ticketsLusA`, the time of the last one that succeeded, whose tickets `tous` holds;
837
+ * `echecPrefixe`, the cause of a ticket prefix that did not read, named in an alert; `voies`, the
838
+ * way of each circuit done (`voiesDesCircuits`), whose sign FAITS AUJOURD'HUI shows.
816
839
  * @param {{ tous: any[], prefix?: string, racine?: string | null, registre: any[], vivants: any[],
817
- * circuits?: any[], maintenant: number, jour: number,
840
+ * circuits?: any[],
841
+ * circuitsLusA?: number | null, fauteTickets?: string | null, ticketsLusA?: number | null,
842
+ * maintenant: number, jour: number,
818
843
  * machine?: Machine | null, outil?: { version: string, raison: string } | null,
819
844
  * places?: { prises: number, plafond: number, faute?: string | null, charge: number,
820
845
  * coeurs: number, memoireGo: number, memoireTotaleGo: number,
821
846
  * tenues?: { ticket: string | null, racine?: string | null }[], attentes: { ticket: string,
822
- * depuis: number, disque?: string | null }[] } | null,
847
+ * depuis: number, disque?: string | null }[], nuit?: 'attend' | 'en cours' | null } | null,
823
848
  * nuit?: { racine: string, depuis: number | null } | null, muet?: boolean, faute?: string | null,
824
849
  * echecPrefixe?: string | null, voies?: Record<string, 'complet' | 'court'> }} lu
825
850
  */
@@ -838,6 +863,9 @@ export function assembler({
838
863
  nuit: nuitEnCours = null,
839
864
  muet = false,
840
865
  faute = null,
866
+ circuitsLusA = null,
867
+ fauteTickets = null,
868
+ ticketsLusA = null,
841
869
  echecPrefixe = null,
842
870
  remontees = [],
843
871
  attenteVivante: attenteQuiVit = true,
@@ -888,11 +916,18 @@ export function assembler({
888
916
  for (const l of enfants.values()) {
889
917
  l.sort(ordre);
890
918
  }
891
- // The circuits of the open tickets, and the running ones of the closed tickets (the queue closes
892
- // a ticket before it reads the CI); a ticket whose circuit runs is in progress.
919
+ // The circuits not integrated of the known tickets, open or closed (the queue closes a ticket
920
+ // before it reads the CI, and its circuit may then wait); a ticket whose circuit runs is in
921
+ // progress. A closed ticket keeps its circuit only while it runs or waits for the supervisor:
922
+ // stopped by the supervisor, its lot entered another way, the ticket is done.
893
923
  const parCircuit = new Map(
894
924
  circuits
895
- .filter(c => ouvert(c.ticket) || (c.vivant && parId.has(c.ticket)))
925
+ .filter(
926
+ c =>
927
+ parId.has(c.ticket) &&
928
+ !c.integre &&
929
+ (parId.get(c.ticket).status !== 'closed' || c.vivant || attendLeSuperviseur(c))
930
+ )
896
931
  .map(c => [c.ticket, c])
897
932
  );
898
933
  const actifs = new Set([
@@ -910,10 +945,13 @@ export function assembler({
910
945
  const bloquePar = t => [...blocages(t).map(d => numero(d.depends_on_id)), ...attentesExternes(t)];
911
946
  // The owner's go: the label `circuit`, set on his word.
912
947
  const circuit = t => (t.labels ?? []).includes('circuit');
913
- // A ticket's state: done, in progress, deferred, awaiting validation; else, with the owner's go,
914
- // waiting (ready) or blocked (an open ticket it depends on); without it, awaiting his go.
948
+ // A ticket's state: in progress (claimed, or its circuit launched and not integrated, its
949
+ // question deferred or its ticket closed before its integration included: AGENTS shows it, and it
950
+ // is done only once integrated), done, deferred,
951
+ // awaiting validation; else, with the owner's go, waiting (ready) or blocked (an open ticket it
952
+ // depends on); without it, awaiting his go.
915
953
  const etat = t => {
916
- if (t.status === 'in_progress' || actifs.has(t.id)) {
954
+ if (t.status === 'in_progress' || actifs.has(t.id) || parCircuit.has(t.id)) {
917
955
  return 'enCours';
918
956
  }
919
957
  if (t.status === 'closed') {
@@ -1174,6 +1212,7 @@ export function assembler({
1174
1212
  t =>
1175
1213
  travail(t) &&
1176
1214
  !actifs.has(t.id) &&
1215
+ !parCircuit.has(t.id) &&
1177
1216
  !estDecouverte(t) &&
1178
1217
  !sansLivraison(t) &&
1179
1218
  t.closed_at &&
@@ -1208,12 +1247,21 @@ export function assembler({
1208
1247
  // Alerts, each with its state (`etat`) and the tone of that state (TONS).
1209
1248
  const alertes = [];
1210
1249
  const alerter = (etat, champs) => alertes.push({ etat, ton: TONS[etat], ...champs });
1211
- // The Temporal server does not answer: the board shows the tickets without their circuits, and
1212
- // its first alert names the command that tells the state of the service.
1250
+ // The Temporal server does not answer: the board shows the circuits of the last reading that
1251
+ // succeeded, whose age the first alert says, or none without one; that alert names the command
1252
+ // that tells the state of the service.
1253
+ const ageDesCircuits =
1254
+ circuitsLusA === null ? '' : ` · circuits lus il y a ${ilYa(maintenant - circuitsLusA)}`;
1213
1255
  if (muet) {
1214
- alerter('panne', { texte: `${SANS_REPONSE_EN} · temporal etat` });
1256
+ alerter('panne', { texte: `${SANS_REPONSE_EN} · temporal etat${ageDesCircuits}` });
1215
1257
  } else if (faute) {
1216
- alerter('panne', { texte: `Circuits illisibles : ${faute}` });
1258
+ alerter('panne', { texte: `Circuits illisibles : ${faute}${ageDesCircuits}` });
1259
+ }
1260
+ // Beads did not read: the board shows the tickets of the last reading that succeeded.
1261
+ if (fauteTickets) {
1262
+ alerter('panne', {
1263
+ texte: `Tickets illisibles : ${fauteTickets}${ticketsLusA === null ? '' : ` · tickets lus il y a ${ilYa(maintenant - ticketsLusA)}`}`,
1264
+ });
1217
1265
  }
1218
1266
  // The ticket prefix did not read: the project keeps its folder's name, and the alert says why.
1219
1267
  if (echecPrefixe) {
@@ -1322,8 +1370,8 @@ export function assembler({
1322
1370
  // holds them, a mother of theirs or a ticket under them (a circuit holds its ticket's mothers and
1323
1371
  // children): one that runs or waits for an answer (`attendLeSuperviseur`), never one the
1324
1372
  // supervisor stopped; or labelled `direct` and claimed (led out of the circuit); and no role
1325
- // agent shown at a step. None while the circuits do not read (a
1326
- // silent server, a fault), when no ticket can be told out of a circuit.
1373
+ // agent shown at a step. None while the circuits do not read (a silent server, a fault) and no
1374
+ // earlier reading is kept, when no ticket can be told out of a circuit.
1327
1375
  const aUneEtape = new Set(blocs.flatMap(b => b.enCours.map(x => x.id)));
1328
1376
  const tenus = new Set(
1329
1377
  [...parCircuit.values()].filter(c => c.vivant || attendLeSuperviseur(c)).map(c => c.ticket)
@@ -1338,7 +1386,7 @@ export function assembler({
1338
1386
  return sousUnCircuit(t);
1339
1387
  };
1340
1388
  const horsCircuit =
1341
- muet || faute
1389
+ (muet || faute) && circuitsLusA === null
1342
1390
  ? []
1343
1391
  : tous
1344
1392
  .filter(
@@ -1409,8 +1457,9 @@ const ilYa = ms => (ms < MINUTE ? `${Math.max(0, Math.round(ms / 1000))} s` : du
1409
1457
 
1410
1458
  // The witness of the automatic step of the running circuit <c> at <maintenant>: the progress of
1411
1459
  // its pass (` · faits/prévus · <durée>`, the figures once a task wrote, the time since the start
1412
- // of the pass, as Bazel's counter); past FIGEE without a sign, ` · ⚠ figée <durée> ·
1413
- // faits/prévus`, the time since the last sign, `fige`. Null without a progress.
1460
+ // of the pass, as Bazel's counter); past FIGEE without a sign, ` · figée <durée> ·
1461
+ // faits/prévus`, the time since the last sign, `fige`, which the line's ⛔ signs. Null without a
1462
+ // progress.
1414
1463
  function temoinDe(c, maintenant) {
1415
1464
  let age;
1416
1465
  let ecoule;
@@ -1429,7 +1478,7 @@ function temoinDe(c, maintenant) {
1429
1478
  return {
1430
1479
  fige,
1431
1480
  texte: fige
1432
- ? ` · ⚠ figée ${ilYa(age)}${compte ? ` · ${compte}` : ''}`
1481
+ ? ` · figée ${ilYa(age)}${compte ? ` · ${compte}` : ''}`
1433
1482
  : ` · ${compte ? `${compte} · ` : ''}${ilYa(ecoule)}`,
1434
1483
  };
1435
1484
  }
@@ -1473,9 +1522,9 @@ export function voiesDesCircuits(racine, tickets) {
1473
1522
  const conso = (ms, jetons) =>
1474
1523
  Math.round(ms / MINUTE) === 0 && !jetons ? '' : `${duree(ms)} · ${k(jetons)}`;
1475
1524
 
1476
- // The columns <s> takes in a terminal: a character one, ⏳ two, as the signs out of the basic
1477
- // plane (🔒 💤 🌙), which count two code units, take two.
1478
- const colonnes = s => s.length + (s.match(/⏳/g)?.length ?? 0);
1525
+ // The columns <s> takes in a terminal: a character one, ⏳ and ⛔ two, as the signs out of the
1526
+ // basic plane (🔒 💤 🌙), which count two code units, take two.
1527
+ const colonnes = s => s.length + (s.match(/[⏳⛔]/g)?.length ?? 0);
1479
1528
  // The start of <s> that holds in <n> columns, a sign out of the basic plane never split.
1480
1529
  const debutDe = (s, n) => {
1481
1530
  let out = '';
@@ -1540,6 +1589,118 @@ function nommerLesPrises(tenues, { racine, prefix }) {
1540
1589
  return ici ? numero : `${sigleDuProjet(deLaPrise).sigle ?? path.basename(deLaPrise)} ${numero}`;
1541
1590
  });
1542
1591
  }
1592
+ // The sign of a ticket's line in AGENTS, by the tone of its state: ▶ what runs, ⛔ what asks for a
1593
+ // correction, ⏸ a wait, for the machine (grey) or for someone (yellow).
1594
+ const signeDuTon = ton => (ton === TONS.enCours ? '▶' : ton === 'alerte' ? '⛔' : '⏸');
1595
+ // The step of the circuit <c>, by its state or its stop.
1596
+ const etapeDuCircuitLu = c => etapeDuCircuit({ ...c, raison: c.arret });
1597
+ // A circuit that waits for the supervisor (`attendLeSuperviseur`, the one rule): who must answer
1598
+ // its question, the supervisor when its stop names no one.
1599
+ const enQuestion = c => (attendLeSuperviseur(c) ? (c.qui ?? SUPERVISEUR) : null);
1600
+
1601
+ /**
1602
+ * The state of each ticket's line of AGENTS on the board <t>, the one source of its signs, which
1603
+ * AGENTS draws and the head and the status line count. Each circuit (`circuits`, by its ticket):
1604
+ * its state (`etat`, whose tone TONS gives), the reason of its wait (`raison`), its tone, its sign
1605
+ * and its witness (`temoin`: the lock it holds or waits for, « · <sorte> faits/prévus · <durée> »,
1606
+ * « · verrou <sorte> · <durée> », else the progress of its automatic pass, `temoinDe`), in this
1607
+ * order: frozen; ended without its issue; its question (to the supervisor or to another); stopped;
1608
+ * its wait for the disk, a place (« nuit » while the night holds the machine), the lock, the CI of
1609
+ * its queue (5.2, the lock not held) or its first state; else it runs. `lignes`: one entry per
1610
+ * ticket's line of AGENTS, its id, its project on a board of several and its sign: each circuit,
1611
+ * each ticket led in direct (▶) and each agent shown out of a circuit (▶).
1612
+ */
1613
+ export function etatsDAgents(t) {
1614
+ const maintenant = t.maintenant ?? Date.now();
1615
+ const p = t.places;
1616
+ const enCircuit = new Set((t.circuits ?? []).map(c => c.id));
1617
+ const duCircuit = x => Boolean(x.ticket && enCircuit.has(x.ticket));
1618
+ const verrouDe = new Map();
1619
+ const tenu = t.machine?.detenteur;
1620
+ if (tenu && duCircuit(tenu)) {
1621
+ const a = tenu.avancement;
1622
+ const age = a ? maintenant - a.dernier : 0;
1623
+ const compte = a && (a.faits || a.prevus) ? `${a.faits}/${a.prevus}` : '';
1624
+ const fige = age > FIGEE;
1625
+ const sorte = tenu.sorte.toLocaleLowerCase('fr');
1626
+ verrouDe.set(tenu.ticket, {
1627
+ fige,
1628
+ texte: fige
1629
+ ? ` · ${sorte} figée ${ilYa(age)}${compte ? ` · ${compte}` : ''}`
1630
+ : ` · ${sorte}${compte ? ` ${compte}` : ''} · ${ilYa(maintenant - (tenu.depuis ?? maintenant))}`,
1631
+ });
1632
+ }
1633
+ for (const w of [...(t.machine?.attentes ?? [])].sort((x, y) => x.depuis - y.depuis)) {
1634
+ if (duCircuit(w) && !verrouDe.has(w.ticket)) {
1635
+ verrouDe.set(w.ticket, {
1636
+ fige: false,
1637
+ texte: ` · verrou ${w.sorte.toLocaleLowerCase('fr')} · ${ilYa(maintenant - w.depuis)}`,
1638
+ });
1639
+ }
1640
+ }
1641
+ const attendLeVerrou = new Set((t.machine?.attentes ?? []).map(w => w.ticket).filter(Boolean));
1642
+ const attendUnePlace = new Set((p?.attentes ?? []).map(w => w.ticket).filter(Boolean));
1643
+ const attendLeDisque = new Set((p?.attentes ?? []).filter(w => w.disque).map(w => w.ticket));
1644
+ const tientLeVerrou = tenu && duCircuit(tenu) ? tenu.ticket : null;
1645
+ const etatDuCircuit = (c, temoin) => {
1646
+ if (temoin?.fige) {
1647
+ return ['fige', ''];
1648
+ }
1649
+ if (!c.vivant) {
1650
+ const qui = enQuestion(c);
1651
+ return c.sansIssue
1652
+ ? ['sansIssue', 'fini sans son issue']
1653
+ : qui === SUPERVISEUR
1654
+ ? ['attendLeSuperviseur', `question au ${SUPERVISEUR}`]
1655
+ : qui
1656
+ ? ['attendLeResponsable', `question au ${qui}`]
1657
+ : ['arrete', 'arrêté'];
1658
+ }
1659
+ const etape = etapeDuCircuitLu(c);
1660
+ return attendLeDisque.has(c.id)
1661
+ ? ['attendLeDisque', 'disque']
1662
+ : attendUnePlace.has(c.id)
1663
+ ? ['attendUnePlace', p?.nuit ? 'nuit' : 'attend une place']
1664
+ : attendLeVerrou.has(c.id)
1665
+ ? ['attendLeVerrou', '']
1666
+ : !etape
1667
+ ? ['sansEtape', 'démarre']
1668
+ : etape.etat === 'file' && tientLeVerrou !== c.id
1669
+ ? ['attendLaCI', 'CI']
1670
+ : ['enCours', ''];
1671
+ };
1672
+ const circuits = new Map();
1673
+ for (const c of t.circuits ?? []) {
1674
+ const etape = etapeDuCircuitLu(c);
1675
+ const temoin =
1676
+ verrouDe.get(c.id) ??
1677
+ (c.vivant && etape?.qui.includes(AUTO) ? temoinDe(c, maintenant) : null);
1678
+ const [etat, raison] = etatDuCircuit(c, temoin);
1679
+ circuits.set(c.id, { etat, raison, ton: TONS[etat], signe: signeDuTon(TONS[etat]), temoin });
1680
+ }
1681
+ const ligne = (x, signe) => ({ id: x.id, projet: x.projet, signe });
1682
+ return {
1683
+ circuits,
1684
+ lignes: [
1685
+ ...(t.circuits ?? []).map(c => ligne(c, circuits.get(c.id).signe)),
1686
+ ...(t.horsCircuit ?? []).map(x => ligne(x, '▶')),
1687
+ ...t.agents.flatMap(b => b.enCours.filter(x => !enCircuit.has(x.id)).map(x => ligne(x, '▶'))),
1688
+ ],
1689
+ };
1690
+ }
1691
+
1692
+ /**
1693
+ * The counts of the signs of AGENTS on the board <t> (`etatsDAgents`), of the project <projet> on a
1694
+ * board of several, of all its lines otherwise: `enCours` ▶, `enAttente` ⏸, `arretes` ⛔.
1695
+ * @param {any} t
1696
+ * @param {string} [projet]
1697
+ */
1698
+ export function comptesDAgents(t, projet) {
1699
+ const l = etatsDAgents(t).lignes.filter(x => projet === undefined || x.projet === projet);
1700
+ const n = s => l.filter(x => x.signe === s).length;
1701
+ return { enCours: n('▶'), enAttente: n('⏸'), arretes: n('⛔') };
1702
+ }
1703
+
1543
1704
  // The board's lines, `largeur` columns wide, each with its tone (titre, alerte, attention, actif,
1544
1705
  // discret, or none), its section (`section`: agents, chantier or faits, in that order) and, for a
1545
1706
  // ticket's line, its id (`ticket`), which the pane makes selectable; an epic's line is marked
@@ -1566,6 +1727,16 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1566
1727
  const large = Math.max(0, ...(t.projets ?? []).map(p => p.etiquette.length + 3));
1567
1728
  const colonneDe = etiquette => `[${etiquette}]`.padEnd(large);
1568
1729
  L(nom.toUpperCase(), TONS.titre);
1730
+ // The state of each ticket's line of AGENTS, which AGENTS draws and the head counts.
1731
+ const etats = etatsDAgents(t);
1732
+ // The first line of the head, the signs of AGENTS counted (`comptesDAgents`) as AGENTS signs its
1733
+ // lines, then the tickets done: « ▶ N · ⏸ N · ⛔ N · ✓ N ».
1734
+ const ligneDesSignes = (a, fermes) =>
1735
+ `▶ ${a.enCours} · ⏸ ${a.enAttente} · ⛔ ${a.arretes} · ✓ ${fermes}`;
1736
+ // The line of the queues, under their signs: ● the tickets ready for the circuit, ✎ the direct
1737
+ // queue, ⊘ the tickets blocked by an open ticket.
1738
+ const ligneDeLaFile = c =>
1739
+ `⏭ file : ● ${c.enAttente} · ✎ ${c.fileDirecte ?? 0} · ⊘ ${c.bloques ?? 0}`;
1569
1740
  if (plusieurs) {
1570
1741
  // The three lines of states of each project, as one project's board says them: the first
1571
1742
  // under its label, the two others aligned below it; or the fault that keeps its board out.
@@ -1578,18 +1749,12 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1578
1749
  const c = p.compteurs;
1579
1750
  L(
1580
1751
  cadre(
1581
- `${colonneDe(p.etiquette)}▶ ${c.enCours} en cours · ${c.bloques ?? 0} bloqués · ${c.fermes} faits`,
1582
- '',
1583
- largeur
1584
- )
1585
- );
1586
- L(
1587
- cadre(
1588
- `${retrait}⏭ file : ${c.enAttente} en circuit · ${c.fileDirecte ?? 0} en direct`,
1752
+ `${colonneDe(p.etiquette)}${ligneDesSignes(comptesDAgents(t, p.etiquette), c.fermes)}`,
1589
1753
  '',
1590
1754
  largeur
1591
1755
  )
1592
1756
  );
1757
+ L(cadre(`${retrait}${ligneDeLaFile(c)}`, '', largeur));
1593
1758
  L(
1594
1759
  cadre(
1595
1760
  `${retrait}${c.sansGo ?? 0} sans go · ${c.aValider ?? 0} à valider · ${c.reportes ?? 0} reportés`,
@@ -1612,10 +1777,10 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1612
1777
  } else {
1613
1778
  const g = t.global;
1614
1779
  const c = g.compteurs;
1615
- // Three lines of states: the work, the queues (the circuit's, the direct one), then those that
1616
- // wait for the owner.
1617
- L(cadre(`▶ ${c.enCours} en cours · ${c.bloques} bloqués · ${c.fermes} faits`, '', largeur));
1618
- L(cadre(`⏭ file : ${c.enAttente} en circuit · ${c.fileDirecte} en direct`, '', largeur));
1780
+ // Three lines of states: the signs of AGENTS and the tickets done, the queues (the circuit's,
1781
+ // the direct one, the blocked), then those that wait for the owner.
1782
+ L(cadre(ligneDesSignes(comptesDAgents(t), c.fermes), '', largeur));
1783
+ L(cadre(ligneDeLaFile(c), '', largeur));
1619
1784
  L(
1620
1785
  cadre(`${c.sansGo} sans go · ${c.aValider} à valider · ${c.reportes} reportés`, '', largeur),
1621
1786
  c.sansGo ? TONS.sansGo : c.aValider ? TONS.aValider : TONS.reportes
@@ -1697,6 +1862,18 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1697
1862
  ticket: w.ticket,
1698
1863
  });
1699
1864
  }
1865
+ // The night reserving the machine (`nuit` of the places: `attend`, `en cours`, none outside
1866
+ // the night): the stages under way finish, then the nights play.
1867
+ if (p.nuit) {
1868
+ poser({
1869
+ texte: cadre(
1870
+ p.nuit === 'attend' ? 'nuit : attend la fin des étapes en cours' : 'nuit en cours',
1871
+ '',
1872
+ largeur
1873
+ ),
1874
+ ton: p.nuit === 'attend' ? TONS.attendLeDisque : TONS.nuitEnCours,
1875
+ });
1876
+ }
1700
1877
  }
1701
1878
  // The night under way on the machine, under the places: « 🌙 nuit · <projet> · depuis <durée> »,
1702
1879
  // its project by its folder's name, the time since it started when the server gives it.
@@ -1735,41 +1912,24 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1735
1912
  }
1736
1913
  return couperAvant(avecQui, fin, '', largeur);
1737
1914
  };
1738
- // The lock on the line of each circuit shown that holds it or waits for it, by its ticket.
1739
- const verrouDe = new Map();
1915
+ // The lock of each circuit shown stands on its line (`etatsDAgents`); any other, here.
1740
1916
  const tenu = t.machine?.detenteur;
1741
- if (tenu) {
1917
+ if (tenu && !duCircuit(tenu)) {
1742
1918
  const a = tenu.avancement;
1743
1919
  const age = a ? maintenant - a.dernier : 0;
1744
1920
  const compte = a && (a.faits || a.prevus) ? `${a.faits}/${a.prevus}` : '';
1745
1921
  const fige = age > FIGEE;
1746
1922
  const depuis = ilYa(maintenant - (tenu.depuis ?? maintenant));
1747
- if (duCircuit(tenu)) {
1748
- const sorte = tenu.sorte.toLocaleLowerCase('fr');
1749
- verrouDe.set(tenu.ticket, {
1750
- fige,
1751
- texte: fige
1752
- ? ` · ⚠ ${sorte} figée ${ilYa(age)}${compte ? ` · ${compte}` : ''}`
1753
- : ` · 🔒 ${sorte}${compte ? ` ${compte}` : ''} · ${depuis}`,
1754
- });
1755
- } else {
1756
- poser({
1757
- texte: fige
1758
- ? ligneDuVerrou(`⚠ ${tenu.sorte} figée ${ilYa(age)}`, tenu, compte ? ` · ${compte}` : '')
1759
- : ligneDuVerrou(`🔒 ${tenu.sorte}`, tenu, ` · ${compte ? `${compte} · ` : ''}${depuis}`),
1760
- ton: fige ? TONS.fige : TONS.enCours,
1761
- avancement: true,
1762
- });
1763
- }
1923
+ poser({
1924
+ texte: fige
1925
+ ? ligneDuVerrou(`⚠ ${tenu.sorte} figée ${ilYa(age)}`, tenu, compte ? ` · ${compte}` : '')
1926
+ : ligneDuVerrou(`🔒 ${tenu.sorte}`, tenu, ` · ${compte ? `${compte} · ` : ''}${depuis}`),
1927
+ ton: fige ? TONS.fige : TONS.enCours,
1928
+ avancement: true,
1929
+ });
1764
1930
  }
1765
1931
  for (const w of [...(t.machine?.attentes ?? [])].sort((x, y) => x.depuis - y.depuis)) {
1766
1932
  if (duCircuit(w)) {
1767
- if (!verrouDe.has(w.ticket)) {
1768
- verrouDe.set(w.ticket, {
1769
- fige: false,
1770
- texte: ` · ⏳ ${w.sorte.toLocaleLowerCase('fr')} · ${ilYa(maintenant - w.depuis)}`,
1771
- });
1772
- }
1773
1933
  continue;
1774
1934
  }
1775
1935
  poser({
@@ -1783,31 +1943,28 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1783
1943
  avancement: true,
1784
1944
  });
1785
1945
  }
1786
- // The tickets whose circuit waits for the lock or for room.
1787
- const attendLeVerrou = new Set((t.machine?.attentes ?? []).map(w => w.ticket).filter(Boolean));
1788
- const enAttente = new Set(attendLeVerrou);
1789
- // The tickets whose circuit waits for a place of the machine, and those that wait for a place of
1790
- // a circuit, not started, whose line in their chantier says « attend une place ».
1946
+ // The tickets that wait for a place of a circuit, not started, whose line in their chantier says
1947
+ // « attend une place ».
1791
1948
  const attendUnePlace = new Set((p?.attentes ?? []).map(w => w.ticket).filter(Boolean));
1792
1949
  // The tickets that wait for the disk of their project's copies.
1793
1950
  const attendLeDisque = new Set((p?.attentes ?? []).filter(w => w.disque).map(w => w.ticket));
1794
- for (const id of attendUnePlace) {
1795
- enAttente.add(id);
1796
- }
1797
1951
  // The tree of the steps (scripts/etapes.mjs), in its order, as a pipeline of GitLab CI shows its
1798
1952
  // stages and folds the jobs of a stage that has nothing: a step with sub-steps is folded
1799
1953
  // (« ▸ 2 · Composants ») while none of them holds a ticket, unfolded (« ▾ ») once one does, all
1800
1954
  // its sub-steps then shown, indented, the empty ones in the discreet tone; a step without
1801
1955
  // sub-steps stands on one line « number · title · who », discreet when empty, a title with its
1802
- // tickets under it. A circuit's ticket stands on one line, at the step of its state, and nowhere
1803
- // else in AGENTS: the work on the plan at its step; waiting for the supervisor
1804
- // (`attendLeSuperviseur`), under its step after a line « ⤷ Question · <qui> », who
1956
+ // tickets under it. A circuit launched and not integrated stands on one line from its launch to
1957
+ // its end, and nowhere else in AGENTS: at the step that works, or, while it waits, at the step
1958
+ // about to be launched: the step of its state; the work on the plan at its step; a running
1959
+ // circuit with no known step at the step of its stop, else at the plan (1); waiting for the
1960
+ // supervisor (`attendLeSuperviseur`), under its step after a line « ⤷ Question · <qui> », who
1805
1961
  // must answer it, the supervisor or the owner, which unfolds the step, its counters those of its
1806
1962
  // step; a stopped circuit at no step of the list stands under that line after the steps. A
1807
1963
  // circuit's line gives its subject (`texte`), then the counters of the bounded loops of its step
1808
1964
  // from their second pass (`boucles` of the step, scripts/etapes.mjs, their counts in the state's
1809
- // `boucles`), whole; then its ticket's working time and tokens. Its card opens on
1810
- // its question, or says where it stopped and why. The tickets' numbers line up in one column.
1965
+ // `boucles`), whole, the reason of its wait; then its ticket's working time and tokens. Its card
1966
+ // opens on its question, or says where it stopped and why. The tickets' numbers line up in one
1967
+ // column.
1811
1968
  // The block of the step <e>, an empty one when the board holds none.
1812
1969
  const vides = new Map();
1813
1970
  const blocDe = e =>
@@ -1823,13 +1980,12 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1823
1980
  .get(e.numero);
1824
1981
  // The block of the circuits at no step of the list, after the steps.
1825
1982
  const ailleurs = { numero: null, titre: '', qui: '', enCours: [] };
1826
- const etapeDe = c => etapeDuCircuit({ ...c, raison: c.arret });
1827
- // A circuit that waits for the supervisor (`attendLeSuperviseur`, the one rule): who must answer
1828
- // its question, the supervisor when its stop names no one.
1829
- const enQuestion = c => (attendLeSuperviseur(c) ? (c.qui ?? SUPERVISEUR) : null);
1983
+ const etapeDe = etapeDuCircuitLu;
1984
+ // The block of the circuit <c>: the step of its state, else, while it stopped, the block after
1985
+ // the steps, else, running with no known step (it starts or resumes), the plan (1).
1830
1986
  const blocDuCircuit = c => {
1831
1987
  const e = etapeDe(c);
1832
- return e ? blocDe(e) : !c.vivant ? ailleurs : undefined;
1988
+ return e ? blocDe(e) : !c.vivant ? ailleurs : blocDe(ETAPES[0]);
1833
1989
  };
1834
1990
  const montres = t.agents.flatMap(b => b.enCours.filter(x => !enCircuit.has(x.id)));
1835
1991
  // A ticket's number, or on several projects' board its whole id, in one column.
@@ -1846,56 +2002,45 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1846
2002
  : `${signe} ${nomme(x).padEnd(colonne)} `;
1847
2003
  const droiteDe = (signe, droite) =>
1848
2004
  plusieurs ? `${signe}${droite ? ` ${droite}` : ''}` : droite;
1849
- // The state of a circuit's line, whose tone TONS gives: frozen, its question (to the supervisor
1850
- // or to another), stopped, its wait for the disk, a place or the lock, else it runs.
1851
- const etatDuCircuit = (c, temoin) =>
1852
- temoin?.fige
1853
- ? 'fige'
1854
- : !c.vivant
1855
- ? enQuestion(c) === SUPERVISEUR
1856
- ? 'attendLeSuperviseur'
1857
- : enQuestion(c)
1858
- ? 'attendLeResponsable'
1859
- : 'arrete'
1860
- : attendLeDisque.has(c.id)
1861
- ? 'attendLeDisque'
1862
- : attendUnePlace.has(c.id)
1863
- ? 'attendUnePlace'
1864
- : attendLeVerrou.has(c.id)
1865
- ? 'attendLeVerrou'
1866
- : 'enCours';
2005
+ // A ticket's line of `largeur` columns: its head <tete> (its sign and number, or its project and
2006
+ // id) whole, then its subject, cut to leave <suite> and the right part <droite> whole; without
2007
+ // room for the subject, <suite> is cut, never the head.
2008
+ const ligneDuTicket = (tete, sujet, suite, droite) => {
2009
+ const place = largeur - colonnes(tete) - colonnes(suite) - (droite ? colonnes(droite) + 1 : 0);
2010
+ if (place < 2) {
2011
+ return couper(`${tete}${suite}`, droite, largeur);
2012
+ }
2013
+ const s = colonnes(sujet) > place ? `${debutDe(sujet, place - 1)}…` : sujet;
2014
+ return couper(`${tete}${s}${suite}`, droite, largeur);
2015
+ };
1867
2016
  const ligneDuCircuit = c => {
1868
- const signe = !c.vivant ? '⏸' : enAttente.has(c.id) ? '⏳' : '▶';
2017
+ const etape = etapeDe(c);
2018
+ // Its state, its sign, its reason and its witness, as the head counts them.
2019
+ const { ton, signe, raison, temoin } = etats.circuits.get(c.id);
1869
2020
  const droite = droiteDe(
1870
2021
  signe,
1871
2022
  conso(t.parTicket?.[c.id]?.travail ?? 0, t.parTicket?.[c.id]?.jetons ?? 0)
1872
2023
  );
1873
- const etape = etapeDe(c);
1874
2024
  const boucles = (etape ? bouclesDe(etape) : [])
1875
2025
  .filter(b => b.max && c.boucles?.[b.cle] >= 2)
1876
2026
  .map(b => ` · ${b.libelle} ${c.boucles[b.cle]}/${b.max}`)
1877
2027
  .join('');
1878
2028
  const tete = teteDe(signe, c);
1879
- // The lock it holds or waits for, else the progress of its pass.
1880
- const temoin =
1881
- verrouDe.get(c.id) ??
1882
- (c.vivant && etape?.qui.includes(AUTO) ? temoinDe(c, maintenant) : null);
2029
+ const pourquoi = raison ? ` · ${raison}` : '';
1883
2030
  // The progress after the counters of the loops while the subject keeps its room beside them,
1884
- // in their place otherwise.
2031
+ // in their place otherwise; the reason of its wait last.
1885
2032
  const reste = avec =>
1886
2033
  largeur - (droite ? colonnes(droite) + 1 : 0) - colonnes(tete) - colonnes(avec);
1887
- const place = attendUnePlace.has(c.id) ? ' · attend une place' : '';
1888
- const tag = enQuestion(c) === SUPERVISEUR ? ' · en attente du superviseur' : '';
1889
- const suite = `${tag}${
2034
+ const suite = `${
1890
2035
  !temoin
1891
2036
  ? boucles
1892
- : reste(`${boucles}${temoin.texte}`) >= Math.min(PLACE_DU_SUJET, c.sujet.length)
2037
+ : reste(`${boucles}${temoin.texte}${pourquoi}`) >= Math.min(PLACE_DU_SUJET, c.sujet.length)
1893
2038
  ? `${boucles}${temoin.texte}`
1894
2039
  : temoin.texte
1895
- }${place}`;
2040
+ }${pourquoi}`;
1896
2041
  poser({
1897
- texte: couperAvant(`${tete}${c.sujet}`, suite, droite, largeur),
1898
- ton: TONS[etatDuCircuit(c, temoin)],
2042
+ texte: ligneDuTicket(tete, c.sujet, suite, droite),
2043
+ ton,
1899
2044
  ticket: c.id,
1900
2045
  ...(temoin ? { avancement: true } : {}),
1901
2046
  });
@@ -1927,7 +2072,7 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1927
2072
  }
1928
2073
  for (const x of enCours) {
1929
2074
  L(
1930
- cadre(`${teteDe('▶', x)}${x.sujet}`, droiteDe('▶', conso(x.travail, x.jetons)), largeur),
2075
+ ligneDuTicket(teteDe('▶', x), x.sujet, '', droiteDe('▶', conso(x.travail, x.jetons))),
1931
2076
  TONS.enCours,
1932
2077
  x.id
1933
2078
  );
@@ -1945,10 +2090,10 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1945
2090
  plein ? TONS.titre : TONS.vide
1946
2091
  );
1947
2092
  // The tickets worked out of a circuit, once each, before the steps, from their claim to their
1948
- // close: « ✎ <numéro> <sujet> · en direct ».
2093
+ // close: « ▶ <numéro> <sujet> · en direct ».
1949
2094
  for (const x of t.horsCircuit ?? []) {
1950
2095
  poser({
1951
- texte: couperAvant(`${teteDe('✎', x)}${x.sujet}`, ' · en direct', droiteDe('✎', ''), largeur),
2096
+ texte: ligneDuTicket(teteDe('▶', x), x.sujet, ' · en direct', droiteDe('▶', '')),
1952
2097
  ton: TONS.enDirect,
1953
2098
  ticket: x.id,
1954
2099
  });
@@ -2276,9 +2421,12 @@ export function dernierBouge(tous, lignesDuTableau, vivants = [], maintenant = D
2276
2421
 
2277
2422
  // The status line: the chantier in progress; first the alerts, counted by their signs as the board
2278
2423
  // shows them (🌙, 💤, ⚠), then the holder of the lock of the machine, « 🔒 <sorte> · <projet> »,
2279
- // and the count of its waits, « ⏳ <n> ».
2280
- export function ligneEtat(t) {
2281
- const signes = t.alertes.map(signeDe);
2424
+ // and the count of its waits, « ⏳ <n> »; then the signs of AGENTS counted as the head counts them
2425
+ // (`comptesDAgents`), « ▶ N · ⏸ N · ⛔ N ». The alerts of the other projects of a board of several
2426
+ // (<voisins>, their boards) count beside the session's, as a multi-root status bar counts the problems
2427
+ // of every root; the counters and the chantier stay the session's.
2428
+ export function ligneEtat(t, voisins = []) {
2429
+ const signes = [t, ...voisins].flatMap(b => b.alertes ?? []).map(signeDe);
2282
2430
  const tenu = t.machine?.detenteur;
2283
2431
  const attentes = t.machine?.attentes?.length ?? 0;
2284
2432
  const alerte = [
@@ -2290,27 +2438,76 @@ export function ligneEtat(t) {
2290
2438
  .join('');
2291
2439
  const ch = t.chantiers[0];
2292
2440
  const c = t.global.compteurs;
2441
+ const a = comptesDAgents(t);
2442
+ const dAgents = `▶ ${a.enCours} · ⏸ ${a.enAttente} · ⛔ ${a.arretes}`;
2293
2443
  if (!ch) {
2294
- return `${alerte}Grillhouse : ${c.enCours} en cours · ⏭ ${c.enAttente} · ✎ ${c.fileDirecte} · ${c.fermes} faits`;
2444
+ return `${alerte}Grillhouse : ${dAgents} · ⏭ ● ${c.enAttente} · ✎ ${c.fileDirecte} · ✓ ${c.fermes}`;
2295
2445
  }
2296
- return `${alerte}${ch.numero} ${ch.faits}/${ch.total} · ▶ ${c.enCours} en cours · ${k(t.global.jour.jetons)} aujourd'hui`;
2446
+ return `${alerte}${ch.numero} ${ch.faits}/${ch.total} · ${dAgents} · ${k(t.global.jour.jetons)} aujourd'hui`;
2297
2447
  }
2298
2448
 
2449
+ // The answer of Beads to <args> in the repository at <racine>, as JSON (`liste`), or the first line
2450
+ // of its fault (`faute`), its error output first.
2299
2451
  const bdJson = (racine, ...args) => {
2300
2452
  try {
2301
- return JSON.parse(
2302
- execFileSync('bd', [...args, '--json'], {
2303
- cwd: racine,
2304
- encoding: 'utf8',
2305
- stdio: ['ignore', 'pipe', 'ignore'],
2306
- maxBuffer: 256 * 1024 * 1024,
2307
- })
2308
- );
2309
- } catch {
2310
- return [];
2453
+ return {
2454
+ liste: JSON.parse(
2455
+ execFileSync('bd', [...args, '--json'], {
2456
+ cwd: racine,
2457
+ encoding: 'utf8',
2458
+ stdio: ['ignore', 'pipe', 'pipe'],
2459
+ maxBuffer: 256 * 1024 * 1024,
2460
+ })
2461
+ ),
2462
+ faute: null,
2463
+ };
2464
+ } catch (e) {
2465
+ const message = String(e?.stderr ?? '').trim() || String(e?.message ?? e);
2466
+ return { liste: [], faute: message.split('\n')[0] };
2311
2467
  }
2312
2468
  };
2313
2469
 
2470
+ // The file of the last reading that succeeded of <quoi> (`circuits`, `tickets`), beside the
2471
+ // status line in the common dir <commun>; null without a common dir.
2472
+ const fichierDeLaLecture = (commun, quoi) => commun && path.join(commun, `tableau-lu-${quoi}.json`);
2473
+
2474
+ /**
2475
+ * The reading of <quoi> (`circuits`, `tickets`) of the project whose common dir is <commun>, kept
2476
+ * when it succeeded, as a dashboard keeps showing its last data with their age: a reading that
2477
+ * succeeded (<liste>, not null) is written with its time <maintenant> and comes back as it is,
2478
+ * `lu` null; a reading that failed (<liste> null) comes back as the last one kept, `lu` its time,
2479
+ * or empty, `lu` null, without one. A place that cannot be written or read keeps none.
2480
+ * @param {string | null} commun
2481
+ * @param {'circuits' | 'tickets'} quoi
2482
+ * @param {any[] | null} liste
2483
+ * @param {number} maintenant
2484
+ * @returns {{ liste: any[], lu: number | null }}
2485
+ */
2486
+ export function lectureGardee(commun, quoi, liste, maintenant) {
2487
+ const fichier = fichierDeLaLecture(commun, quoi);
2488
+ if (liste) {
2489
+ try {
2490
+ if (fichier) {
2491
+ // Written beside, then renamed: a reader never sees a file half written.
2492
+ writeFileSync(`${fichier}.${process.pid}`, JSON.stringify({ lu: maintenant, liste }));
2493
+ renameSync(`${fichier}.${process.pid}`, fichier);
2494
+ }
2495
+ } catch {
2496
+ // A read-only place keeps the board working, without the reading kept.
2497
+ }
2498
+ return { liste, lu: null };
2499
+ }
2500
+ try {
2501
+ const garde = JSON.parse(readFileSync(fichier, 'utf8'));
2502
+ if (Array.isArray(garde.liste) && typeof garde.lu === 'number') {
2503
+ return { liste: garde.liste, lu: garde.lu };
2504
+ }
2505
+ } catch {
2506
+ // No reading kept.
2507
+ }
2508
+ return { liste: [], lu: null };
2509
+ }
2510
+
2314
2511
  // The folder git keeps a repository's shared files in (its common dir), absolute; null when
2315
2512
  // <racine> is no git repository. The board's cache and the day's marker live there.
2316
2513
  export function dossierCommun(racine) {
@@ -2407,8 +2604,22 @@ function lire(
2407
2604
  ps = '';
2408
2605
  }
2409
2606
  const registre = existsSync(REGISTRE) ? lireRegistre(readFileSync(REGISTRE, 'utf8'), racine) : [];
2410
- const tous = bdJson(racine, 'list', '--all', '--limit', '0');
2411
2607
  const commun = dossierCommun(racine);
2608
+ // The tickets and the circuits, each the last reading that succeeded when this one failed.
2609
+ const lesTickets = bdJson(racine, 'list', '--all', '--limit', '0');
2610
+ const tickets = lectureGardee(
2611
+ commun,
2612
+ 'tickets',
2613
+ lesTickets.faute ? null : lesTickets.liste,
2614
+ maintenant
2615
+ );
2616
+ const tous = tickets.liste;
2617
+ const lesCircuitsLus = lectureGardee(
2618
+ commun,
2619
+ 'circuits',
2620
+ muet || faute ? null : circuits,
2621
+ maintenant
2622
+ );
2412
2623
  const fichierCache = commun && path.join(commun, 'tableau-cache.json');
2413
2624
  let cache = {};
2414
2625
  try {
@@ -2448,7 +2659,7 @@ function lire(
2448
2659
  racine: commun ? path.dirname(commun) : racine,
2449
2660
  registre,
2450
2661
  vivants,
2451
- circuits,
2662
+ circuits: lesCircuitsLus.liste,
2452
2663
  maintenant,
2453
2664
  jour,
2454
2665
  voies,
@@ -2457,6 +2668,9 @@ function lire(
2457
2668
  nuit,
2458
2669
  muet,
2459
2670
  faute,
2671
+ circuitsLusA: lesCircuitsLus.lu,
2672
+ fauteTickets: lesTickets.faute,
2673
+ ticketsLusA: tickets.lu,
2460
2674
  echecPrefixe,
2461
2675
  outil: echecDeLOutil(racine),
2462
2676
  remontees: lireLesRemontees(racine, maintenant),
@@ -2535,8 +2749,8 @@ export function ensemble(lus) {
2535
2749
  };
2536
2750
  }
2537
2751
 
2538
- // A project beside the session's, read in its folder <dossier>: its board, or the fault that keeps
2539
- // it out, on one line.
2752
+ // A project beside the session's, read in its folder <dossier>: its board, the faults of its
2753
+ // reading of the circuits in its alerts, or the fault that keeps it out, on one line.
2540
2754
  async function lireUnAutre(dossier, { circuitsDe, ...o }) {
2541
2755
  try {
2542
2756
  if (!existsSync(dossier)) {
@@ -2544,7 +2758,7 @@ async function lireUnAutre(dossier, { circuitsDe, ...o }) {
2544
2758
  }
2545
2759
  return {
2546
2760
  dossier,
2547
- ...lire(dossier, { ...o, circuits: (await lesCircuits(circuitsDe, dossier)).circuits }),
2761
+ ...lire(dossier, { ...o, ...(await lesCircuits(circuitsDe, dossier)) }),
2548
2762
  };
2549
2763
  } catch (e) {
2550
2764
  return { dossier, erreur: String(e.message ?? e).split('\n')[0] };
@@ -2552,8 +2766,9 @@ async function lireUnAutre(dossier, { circuitsDe, ...o }) {
2552
2766
  }
2553
2767
 
2554
2768
  // The circuits of the repository at <racine> by the reader <circuitsDe>; none when the reading
2555
- // fails, the board shows the rest: the server stayed silent (`muet`, `ServeurMuet`), or another
2556
- // fault, a client not built among them, by the first line of its message (`faute`).
2769
+ // fails, which `lire` replaces by the last reading kept: the server stayed silent (`muet`,
2770
+ // `ServeurMuet`), or another fault, a client not built among them, by the first line of its
2771
+ // message (`faute`).
2557
2772
  async function lesCircuits(circuitsDe, racine) {
2558
2773
  try {
2559
2774
  return { circuits: await circuitsDe(racine), muet: false, faute: null };
@@ -2668,7 +2883,7 @@ export async function tableau(
2668
2883
  ),
2669
2884
  ici.commun ? path.dirname(ici.commun) : null
2670
2885
  );
2671
- const etat = ligneEtat(ici.t);
2886
+ const etat = ligneEtat(ici.t, autres.map(l => l.t).filter(Boolean));
2672
2887
  try {
2673
2888
  if (ici.commun) {
2674
2889
  writeFileSync(path.join(ici.commun, 'grillhouse-etat.txt'), `${etat}\n`);