@roomi-fields/grillhouse 0.35.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +28 -0
  3. package/cadre/templates/cargo/package.json +4 -2
  4. package/cadre/templates/projet/.github/workflows/ci.yml +10 -0
  5. package/cadre/templates/projet/.github/workflows/nuit.yml +5 -0
  6. package/cadre/templates/projet/CLAUDE.md +5 -0
  7. package/cadre/templates/python/package.json +4 -2
  8. package/charte.md +5 -0
  9. package/dist/temporal/file/contrat.d.ts +3 -1
  10. package/dist/temporal/file/deroule.js +2 -2
  11. package/dist/temporal/file/deroule.js.map +1 -1
  12. package/dist/temporal/nuits/activites.d.ts +10 -1
  13. package/dist/temporal/nuits/activites.js +59 -3
  14. package/dist/temporal/nuits/activites.js.map +1 -1
  15. package/dist/temporal/nuits/contrat.d.ts +15 -0
  16. package/dist/temporal/nuits/deroule.js +67 -35
  17. package/dist/temporal/nuits/deroule.js.map +1 -1
  18. package/dist/temporal/places/client.d.ts +12 -0
  19. package/dist/temporal/places/client.js +23 -1
  20. package/dist/temporal/places/client.js.map +1 -1
  21. package/dist/temporal/places/contrat.d.ts +47 -0
  22. package/dist/temporal/places/contrat.js +11 -0
  23. package/dist/temporal/places/contrat.js.map +1 -1
  24. package/dist/temporal/places/deroule.js +49 -2
  25. package/dist/temporal/places/deroule.js.map +1 -1
  26. package/dist/temporal/tickets/activites.js +30 -3
  27. package/dist/temporal/tickets/activites.js.map +1 -1
  28. package/docs/ARCHITECTURE.md +41 -9
  29. package/docs/CADRE.md +11 -0
  30. package/docs/INTERFACE.md +7 -4
  31. package/package.json +1 -1
  32. package/scripts/activites.mjs +10 -4
  33. package/scripts/aiguillage.mjs +1 -0
  34. package/scripts/attente-a-l-arret.mjs +1 -1
  35. package/scripts/attente-au-tour.mjs +1 -1
  36. package/scripts/binaires.mjs +119 -0
  37. package/scripts/file-des-tickets.d.mts +23 -1
  38. package/scripts/file-des-tickets.mjs +94 -3
  39. package/scripts/gabarit-absent.mjs +30 -0
  40. package/scripts/grillhouse-maj.mjs +61 -61
  41. package/scripts/groupe-cles.d.mts +25 -0
  42. package/scripts/groupe-cles.mjs +73 -0
  43. package/scripts/integration/file.mjs +30 -5
  44. package/scripts/jointure.d.ts +11 -0
  45. package/scripts/langages/cargo/binaires.mjs +1 -1
  46. package/scripts/langages/cargo/clippy.mjs +1 -1
  47. package/scripts/langages/cargo/commandes.mjs +1 -1
  48. package/scripts/langages/cargo/index.mjs +3 -2
  49. package/scripts/langages/cargo/mise-a-jour.mjs +17 -0
  50. package/scripts/langages/cargo/sccache.mjs +1 -1
  51. package/scripts/langages/python/commandes.mjs +1 -1
  52. package/scripts/langages/python/index.mjs +3 -1
  53. package/scripts/langages/python/mise-a-jour.mjs +22 -5
  54. package/scripts/langages/typescript/mise-a-jour.mjs +8 -20
  55. package/scripts/paquet.mjs +2 -7
  56. package/scripts/places-de-la-machine.mjs +53 -31
  57. package/scripts/regles-des-places.d.mts +34 -2
  58. package/scripts/regles-des-places.mjs +112 -9
  59. package/scripts/services-du-noyau.mjs +2 -1
  60. package/scripts/sigle-du-projet.mjs +49 -0
  61. package/scripts/sous-commandes.mjs +1 -0
  62. package/scripts/superviseur.mjs +31 -18
  63. package/scripts/tableau.mjs +483 -193
@@ -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';
@@ -129,8 +146,14 @@ import {
129
146
  circuitsDuServeur,
130
147
  nuitDuServeur,
131
148
  } from './circuits-du-serveur.mjs';
132
- import { enFileSansArchitecture } from './file-des-tickets.mjs';
149
+ import {
150
+ attendDeLAutreProjet,
151
+ enFileSansArchitecture,
152
+ lireLesExternes,
153
+ } from './file-des-tickets.mjs';
133
154
  import { etatDesPlaces } from './places-de-la-machine.mjs';
155
+ import { prefixe as prefixeDeLaRacine } from './prefixe-des-tickets.mjs';
156
+ import { sigleDuProjet } from './sigle-du-projet.mjs';
134
157
  import { vivant } from './mesure/base-de-passe.mjs';
135
158
 
136
159
  const MINUTE = 60_000;
@@ -168,10 +191,10 @@ export const ETATS = [
168
191
  // The tone of each state the board shows, defined once: as a dashboard of states (GitHub Checks,
169
192
  // Alertmanager), the severity belongs to the state, never to its duration nor to the line that
170
193
  // shows it; the duration stays in the text. Every line and every alert takes its tone here:
171
- // `alerte` (red), what asks for a correction; `attention` (yellow), what waits for an answer or a
172
- // look; `actif` (cyan), what runs; `discret`, what is done, empty or a measure; `titre`, a
173
- // heading; none, a ticket at rest. The pane turns each tone into its colour (mods/grillhouse
174
- // `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`).
175
198
  export const TONS = Object.freeze({
176
199
  // A ticket's state (ETATS).
177
200
  enCours: 'actif',
@@ -183,11 +206,13 @@ export const TONS = Object.freeze({
183
206
  reportes: undefined,
184
207
  fermes: 'discret',
185
208
  // A circuit, a pass, a wait.
186
- attendUnePlace: 'attention',
187
- attendLeVerrou: 'actif',
209
+ attendUnePlace: 'discret',
210
+ attendLeVerrou: 'discret',
211
+ attendLeDisque: 'discret',
212
+ attendLaCI: 'discret',
213
+ sansEtape: 'discret',
188
214
  enDirect: 'actif',
189
215
  nuitEnCours: 'actif',
190
- attendLeDisque: 'attention',
191
216
  attendLeSuperviseur: 'attention',
192
217
  attendLeResponsable: 'attention',
193
218
  arrete: 'attention',
@@ -197,6 +222,7 @@ export const TONS = Object.freeze({
197
222
  outilNonInstallable: 'attention',
198
223
  machineChargee: 'attention',
199
224
  fige: 'alerte',
225
+ sansIssue: 'alerte',
200
226
  panne: 'alerte',
201
227
  nuitRouge: 'alerte',
202
228
  sansAttente: 'alerte',
@@ -804,21 +830,28 @@ export function lecture(t, prefix) {
804
830
  * under way on the machine (scripts/circuits-du-serveur.mjs `nuitDuServeur`), its line under the
805
831
  * places'; `muet`, the Temporal
806
832
  * server did not answer the reading of the circuits, which the first alert says; `faute`, any
807
- * other fault of that reading, said in the first alert as it is; `echecPrefixe`, the cause of a
808
- * ticket prefix that did not read, named in an alert; `voies`, the way of each circuit done
809
- * (`voiesDesCircuits`), whose sign FAITS AUJOURD'HUI shows.
810
- * @param {{ tous: any[], prefix?: string, registre: any[], vivants: any[], circuits?: any[],
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.
839
+ * @param {{ tous: any[], prefix?: string, racine?: string | null, registre: any[], vivants: any[],
840
+ * circuits?: any[],
841
+ * circuitsLusA?: number | null, fauteTickets?: string | null, ticketsLusA?: number | null,
811
842
  * maintenant: number, jour: number,
812
843
  * machine?: Machine | null, outil?: { version: string, raison: string } | null,
813
844
  * places?: { prises: number, plafond: number, faute?: string | null, charge: number,
814
- * coeurs: number, memoireGo: number, memoireTotaleGo: number, attentes: { ticket: string,
815
- * depuis: number, disque?: string | null }[] } | null,
845
+ * coeurs: number, memoireGo: number, memoireTotaleGo: number,
846
+ * tenues?: { ticket: string | null, racine?: string | null }[], attentes: { ticket: string,
847
+ * depuis: number, disque?: string | null }[], nuit?: 'attend' | 'en cours' | null } | null,
816
848
  * nuit?: { racine: string, depuis: number | null } | null, muet?: boolean, faute?: string | null,
817
849
  * echecPrefixe?: string | null, voies?: Record<string, 'complet' | 'court'> }} lu
818
850
  */
819
851
  export function assembler({
820
852
  tous,
821
853
  prefix = '',
854
+ racine = null,
822
855
  registre: lignesDuRegistre,
823
856
  vivants,
824
857
  circuits = [],
@@ -830,11 +863,15 @@ export function assembler({
830
863
  nuit: nuitEnCours = null,
831
864
  muet = false,
832
865
  faute = null,
866
+ circuitsLusA = null,
867
+ fauteTickets = null,
868
+ ticketsLusA = null,
833
869
  echecPrefixe = null,
834
870
  remontees = [],
835
871
  attenteVivante: attenteQuiVit = true,
836
872
  voies = {},
837
873
  superviseur = {},
874
+ externes,
838
875
  }) {
839
876
  // A circuit's lines are its steps, no agent's passage.
840
877
  const etapesFinies = lignesDuRegistre.filter(r => r.role === ROLE_DU_CIRCUIT);
@@ -858,7 +895,13 @@ export function assembler({
858
895
  // Ready: open, every ticket that blocks it closed (Beads' own rule, without a second call).
859
896
  const blocages = t =>
860
897
  (t.dependencies ?? []).filter(d => d.type === 'blocks' && ouvert(d.depends_on_id));
861
- const prets = tous.filter(t => t.status === 'open' && blocages(t).length === 0);
898
+ // What a ticket waits for from another project, « <project>:<capability> » (the capability not
899
+ // delivered by the provider, or its project not resolved: `externes`, the tickets of each other
900
+ // project by its name in Beads' `external_projects`).
901
+ const attentesExternes = t => attendDeLAutreProjet(t, externes).map(a => a.attend);
902
+ const prets = tous.filter(
903
+ t => t.status === 'open' && blocages(t).length === 0 && attentesExternes(t).length === 0
904
+ );
862
905
  const aValider = tous.filter(
863
906
  t => t.status !== 'closed' && (t.labels ?? []).includes('a-valider')
864
907
  );
@@ -873,12 +916,11 @@ export function assembler({
873
916
  for (const l of enfants.values()) {
874
917
  l.sort(ordre);
875
918
  }
876
- // The circuits of the open tickets, and the running ones of the closed tickets (the queue closes
877
- // 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.
878
922
  const parCircuit = new Map(
879
- circuits
880
- .filter(c => ouvert(c.ticket) || (c.vivant && parId.has(c.ticket)))
881
- .map(c => [c.ticket, c])
923
+ circuits.filter(c => parId.has(c.ticket) && !c.integre).map(c => [c.ticket, c])
882
924
  );
883
925
  const actifs = new Set([
884
926
  ...enCoursMesures.map(v => v.ticket).filter(Boolean),
@@ -892,13 +934,16 @@ export function assembler({
892
934
  (!enfants.has(t.id) || t.status === 'in_progress' || actifs.has(t.id) || travailles.has(t.id));
893
935
  const pret = new Set(prets.map(t => t.id));
894
936
  const avalider = new Set(aValider.map(t => t.id));
895
- const bloquePar = t => blocages(t).map(d => numero(d.depends_on_id));
937
+ const bloquePar = t => [...blocages(t).map(d => numero(d.depends_on_id)), ...attentesExternes(t)];
896
938
  // The owner's go: the label `circuit`, set on his word.
897
939
  const circuit = t => (t.labels ?? []).includes('circuit');
898
- // A ticket's state: done, in progress, deferred, awaiting validation; else, with the owner's go,
899
- // waiting (ready) or blocked (an open ticket it depends on); without it, awaiting his go.
940
+ // A ticket's state: in progress (claimed, or its circuit launched and not integrated, its
941
+ // question deferred or its ticket closed before its integration included: AGENTS shows it, and it
942
+ // is done only once integrated), done, deferred,
943
+ // awaiting validation; else, with the owner's go, waiting (ready) or blocked (an open ticket it
944
+ // depends on); without it, awaiting his go.
900
945
  const etat = t => {
901
- if (t.status === 'in_progress' || actifs.has(t.id)) {
946
+ if (t.status === 'in_progress' || actifs.has(t.id) || parCircuit.has(t.id)) {
902
947
  return 'enCours';
903
948
  }
904
949
  if (t.status === 'closed') {
@@ -1159,6 +1204,7 @@ export function assembler({
1159
1204
  t =>
1160
1205
  travail(t) &&
1161
1206
  !actifs.has(t.id) &&
1207
+ !parCircuit.has(t.id) &&
1162
1208
  !estDecouverte(t) &&
1163
1209
  !sansLivraison(t) &&
1164
1210
  t.closed_at &&
@@ -1193,12 +1239,21 @@ export function assembler({
1193
1239
  // Alerts, each with its state (`etat`) and the tone of that state (TONS).
1194
1240
  const alertes = [];
1195
1241
  const alerter = (etat, champs) => alertes.push({ etat, ton: TONS[etat], ...champs });
1196
- // The Temporal server does not answer: the board shows the tickets without their circuits, and
1197
- // its first alert names the command that tells the state of the service.
1242
+ // The Temporal server does not answer: the board shows the circuits of the last reading that
1243
+ // succeeded, whose age the first alert says, or none without one; that alert names the command
1244
+ // that tells the state of the service.
1245
+ const ageDesCircuits =
1246
+ circuitsLusA === null ? '' : ` · circuits lus il y a ${ilYa(maintenant - circuitsLusA)}`;
1198
1247
  if (muet) {
1199
- alerter('panne', { texte: `${SANS_REPONSE_EN} · temporal etat` });
1248
+ alerter('panne', { texte: `${SANS_REPONSE_EN} · temporal etat${ageDesCircuits}` });
1200
1249
  } else if (faute) {
1201
- alerter('panne', { texte: `Circuits illisibles : ${faute}` });
1250
+ alerter('panne', { texte: `Circuits illisibles : ${faute}${ageDesCircuits}` });
1251
+ }
1252
+ // Beads did not read: the board shows the tickets of the last reading that succeeded.
1253
+ if (fauteTickets) {
1254
+ alerter('panne', {
1255
+ texte: `Tickets illisibles : ${fauteTickets}${ticketsLusA === null ? '' : ` · tickets lus il y a ${ilYa(maintenant - ticketsLusA)}`}`,
1256
+ });
1202
1257
  }
1203
1258
  // The ticket prefix did not read: the project keeps its folder's name, and the alert says why.
1204
1259
  if (echecPrefixe) {
@@ -1307,8 +1362,8 @@ export function assembler({
1307
1362
  // holds them, a mother of theirs or a ticket under them (a circuit holds its ticket's mothers and
1308
1363
  // children): one that runs or waits for an answer (`attendLeSuperviseur`), never one the
1309
1364
  // supervisor stopped; or labelled `direct` and claimed (led out of the circuit); and no role
1310
- // agent shown at a step. None while the circuits do not read (a
1311
- // silent server, a fault), when no ticket can be told out of a circuit.
1365
+ // agent shown at a step. None while the circuits do not read (a silent server, a fault) and no
1366
+ // earlier reading is kept, when no ticket can be told out of a circuit.
1312
1367
  const aUneEtape = new Set(blocs.flatMap(b => b.enCours.map(x => x.id)));
1313
1368
  const tenus = new Set(
1314
1369
  [...parCircuit.values()].filter(c => c.vivant || attendLeSuperviseur(c)).map(c => c.ticket)
@@ -1323,7 +1378,7 @@ export function assembler({
1323
1378
  return sousUnCircuit(t);
1324
1379
  };
1325
1380
  const horsCircuit =
1326
- muet || faute
1381
+ (muet || faute) && circuitsLusA === null
1327
1382
  ? []
1328
1383
  : tous
1329
1384
  .filter(
@@ -1360,7 +1415,10 @@ export function assembler({
1360
1415
  agents: blocs,
1361
1416
  maintenant,
1362
1417
  machine,
1363
- places: placesDeLaMachine,
1418
+ places: placesDeLaMachine && {
1419
+ ...placesDeLaMachine,
1420
+ noms: nommerLesPrises(placesDeLaMachine.tenues ?? [], { racine, prefix }),
1421
+ },
1364
1422
  nuit: nuitEnCours,
1365
1423
  faitsDuJour,
1366
1424
  etats,
@@ -1391,8 +1449,9 @@ const ilYa = ms => (ms < MINUTE ? `${Math.max(0, Math.round(ms / 1000))} s` : du
1391
1449
 
1392
1450
  // The witness of the automatic step of the running circuit <c> at <maintenant>: the progress of
1393
1451
  // its pass (` · faits/prévus · <durée>`, the figures once a task wrote, the time since the start
1394
- // of the pass, as Bazel's counter); past FIGEE without a sign, ` · ⚠ figée <durée> ·
1395
- // faits/prévus`, the time since the last sign, `fige`. Null without a progress.
1452
+ // of the pass, as Bazel's counter); past FIGEE without a sign, ` · figée <durée> ·
1453
+ // faits/prévus`, the time since the last sign, `fige`, which the line's ⛔ signs. Null without a
1454
+ // progress.
1396
1455
  function temoinDe(c, maintenant) {
1397
1456
  let age;
1398
1457
  let ecoule;
@@ -1411,7 +1470,7 @@ function temoinDe(c, maintenant) {
1411
1470
  return {
1412
1471
  fige,
1413
1472
  texte: fige
1414
- ? ` · ⚠ figée ${ilYa(age)}${compte ? ` · ${compte}` : ''}`
1473
+ ? ` · figée ${ilYa(age)}${compte ? ` · ${compte}` : ''}`
1415
1474
  : ` · ${compte ? `${compte} · ` : ''}${ilYa(ecoule)}`,
1416
1475
  };
1417
1476
  }
@@ -1455,9 +1514,9 @@ export function voiesDesCircuits(racine, tickets) {
1455
1514
  const conso = (ms, jetons) =>
1456
1515
  Math.round(ms / MINUTE) === 0 && !jetons ? '' : `${duree(ms)} · ${k(jetons)}`;
1457
1516
 
1458
- // The columns <s> takes in a terminal: a character one, ⏳ two, as the signs out of the basic
1459
- // plane (🔒 💤 🌙), which count two code units, take two.
1460
- const colonnes = s => s.length + (s.match(/⏳/g)?.length ?? 0);
1517
+ // The columns <s> takes in a terminal: a character one, ⏳ and ⛔ two, as the signs out of the
1518
+ // basic plane (🔒 💤 🌙), which count two code units, take two.
1519
+ const colonnes = s => s.length + (s.match(/[⏳⛔]/g)?.length ?? 0);
1461
1520
  // The start of <s> that holds in <n> columns, a sign out of the basic plane never split.
1462
1521
  const debutDe = (s, n) => {
1463
1522
  let out = '';
@@ -1498,6 +1557,142 @@ const signeDe = a => a.signe ?? '⚠';
1498
1557
  // project's prefix, which the line already names, « bp-mono-vbwf.320.11 » → « vbwf.320.11 »,
1499
1558
  // « SH-ae6.5 » → « ae6.5 ».
1500
1559
  const courtDuTicket = id => id.slice(id.lastIndexOf('-') + 1);
1560
+
1561
+ // Who holds each place of the machine, in the order of the places: the project of the board (the
1562
+ // root <racine> of its main tree, its ticket prefix <prefix>) by the short number of its ticket,
1563
+ // another project by « <sigle> <short number> » (its sigle and its prefix read from its own root),
1564
+ // a place with no ticket « passe »; a place with no root (a state of before) is the board's.
1565
+ function nommerLesPrises(tenues, { racine, prefix }) {
1566
+ return tenues.map(({ ticket, racine: deLaPrise }) => {
1567
+ const ici = !deLaPrise || (racine && path.resolve(deLaPrise) === path.resolve(racine));
1568
+ let prefixeDuProjet = prefix;
1569
+ if (!ici) {
1570
+ try {
1571
+ prefixeDuProjet = prefixeDeLaRacine(deLaPrise);
1572
+ } catch {
1573
+ prefixeDuProjet = '';
1574
+ }
1575
+ }
1576
+ const numero = !ticket
1577
+ ? 'passe'
1578
+ : prefixeDuProjet && ticket.startsWith(`${prefixeDuProjet}-`)
1579
+ ? ticket.slice(prefixeDuProjet.length + 1)
1580
+ : courtDuTicket(ticket);
1581
+ return ici ? numero : `${sigleDuProjet(deLaPrise).sigle ?? path.basename(deLaPrise)} ${numero}`;
1582
+ });
1583
+ }
1584
+ // The sign of a ticket's line in AGENTS, by the tone of its state: ▶ what runs, ⛔ what asks for a
1585
+ // correction, ⏸ a wait, for the machine (grey) or for someone (yellow).
1586
+ const signeDuTon = ton => (ton === TONS.enCours ? '▶' : ton === 'alerte' ? '⛔' : '⏸');
1587
+ // The step of the circuit <c>, by its state or its stop.
1588
+ const etapeDuCircuitLu = c => etapeDuCircuit({ ...c, raison: c.arret });
1589
+ // A circuit that waits for the supervisor (`attendLeSuperviseur`, the one rule): who must answer
1590
+ // its question, the supervisor when its stop names no one.
1591
+ const enQuestion = c => (attendLeSuperviseur(c) ? (c.qui ?? SUPERVISEUR) : null);
1592
+
1593
+ /**
1594
+ * The state of each ticket's line of AGENTS on the board <t>, the one source of its signs, which
1595
+ * AGENTS draws and the head and the status line count. Each circuit (`circuits`, by its ticket):
1596
+ * its state (`etat`, whose tone TONS gives), the reason of its wait (`raison`), its tone, its sign
1597
+ * and its witness (`temoin`: the lock it holds or waits for, « · <sorte> faits/prévus · <durée> »,
1598
+ * « · verrou <sorte> · <durée> », else the progress of its automatic pass, `temoinDe`), in this
1599
+ * order: frozen; ended without its issue; its question (to the supervisor or to another); stopped;
1600
+ * its wait for the disk, a place (« nuit » while the night holds the machine), the lock, the CI of
1601
+ * its queue (5.2, the lock not held) or its first state; else it runs. `lignes`: one entry per
1602
+ * ticket's line of AGENTS, its id, its project on a board of several and its sign: each circuit,
1603
+ * each ticket led in direct (▶) and each agent shown out of a circuit (▶).
1604
+ */
1605
+ export function etatsDAgents(t) {
1606
+ const maintenant = t.maintenant ?? Date.now();
1607
+ const p = t.places;
1608
+ const enCircuit = new Set((t.circuits ?? []).map(c => c.id));
1609
+ const duCircuit = x => Boolean(x.ticket && enCircuit.has(x.ticket));
1610
+ const verrouDe = new Map();
1611
+ const tenu = t.machine?.detenteur;
1612
+ if (tenu && duCircuit(tenu)) {
1613
+ const a = tenu.avancement;
1614
+ const age = a ? maintenant - a.dernier : 0;
1615
+ const compte = a && (a.faits || a.prevus) ? `${a.faits}/${a.prevus}` : '';
1616
+ const fige = age > FIGEE;
1617
+ const sorte = tenu.sorte.toLocaleLowerCase('fr');
1618
+ verrouDe.set(tenu.ticket, {
1619
+ fige,
1620
+ texte: fige
1621
+ ? ` · ${sorte} figée ${ilYa(age)}${compte ? ` · ${compte}` : ''}`
1622
+ : ` · ${sorte}${compte ? ` ${compte}` : ''} · ${ilYa(maintenant - (tenu.depuis ?? maintenant))}`,
1623
+ });
1624
+ }
1625
+ for (const w of [...(t.machine?.attentes ?? [])].sort((x, y) => x.depuis - y.depuis)) {
1626
+ if (duCircuit(w) && !verrouDe.has(w.ticket)) {
1627
+ verrouDe.set(w.ticket, {
1628
+ fige: false,
1629
+ texte: ` · verrou ${w.sorte.toLocaleLowerCase('fr')} · ${ilYa(maintenant - w.depuis)}`,
1630
+ });
1631
+ }
1632
+ }
1633
+ const attendLeVerrou = new Set((t.machine?.attentes ?? []).map(w => w.ticket).filter(Boolean));
1634
+ const attendUnePlace = new Set((p?.attentes ?? []).map(w => w.ticket).filter(Boolean));
1635
+ const attendLeDisque = new Set((p?.attentes ?? []).filter(w => w.disque).map(w => w.ticket));
1636
+ const tientLeVerrou = tenu && duCircuit(tenu) ? tenu.ticket : null;
1637
+ const etatDuCircuit = (c, temoin) => {
1638
+ if (temoin?.fige) {
1639
+ return ['fige', ''];
1640
+ }
1641
+ if (!c.vivant) {
1642
+ const qui = enQuestion(c);
1643
+ return c.sansIssue
1644
+ ? ['sansIssue', 'fini sans son issue']
1645
+ : qui === SUPERVISEUR
1646
+ ? ['attendLeSuperviseur', `question au ${SUPERVISEUR}`]
1647
+ : qui
1648
+ ? ['attendLeResponsable', `question au ${qui}`]
1649
+ : ['arrete', 'arrêté'];
1650
+ }
1651
+ const etape = etapeDuCircuitLu(c);
1652
+ return attendLeDisque.has(c.id)
1653
+ ? ['attendLeDisque', 'disque']
1654
+ : attendUnePlace.has(c.id)
1655
+ ? ['attendUnePlace', p?.nuit ? 'nuit' : 'attend une place']
1656
+ : attendLeVerrou.has(c.id)
1657
+ ? ['attendLeVerrou', '']
1658
+ : !etape
1659
+ ? ['sansEtape', 'démarre']
1660
+ : etape.etat === 'file' && tientLeVerrou !== c.id
1661
+ ? ['attendLaCI', 'CI']
1662
+ : ['enCours', ''];
1663
+ };
1664
+ const circuits = new Map();
1665
+ for (const c of t.circuits ?? []) {
1666
+ const etape = etapeDuCircuitLu(c);
1667
+ const temoin =
1668
+ verrouDe.get(c.id) ??
1669
+ (c.vivant && etape?.qui.includes(AUTO) ? temoinDe(c, maintenant) : null);
1670
+ const [etat, raison] = etatDuCircuit(c, temoin);
1671
+ circuits.set(c.id, { etat, raison, ton: TONS[etat], signe: signeDuTon(TONS[etat]), temoin });
1672
+ }
1673
+ const ligne = (x, signe) => ({ id: x.id, projet: x.projet, signe });
1674
+ return {
1675
+ circuits,
1676
+ lignes: [
1677
+ ...(t.circuits ?? []).map(c => ligne(c, circuits.get(c.id).signe)),
1678
+ ...(t.horsCircuit ?? []).map(x => ligne(x, '▶')),
1679
+ ...t.agents.flatMap(b => b.enCours.filter(x => !enCircuit.has(x.id)).map(x => ligne(x, '▶'))),
1680
+ ],
1681
+ };
1682
+ }
1683
+
1684
+ /**
1685
+ * The counts of the signs of AGENTS on the board <t> (`etatsDAgents`), of the project <projet> on a
1686
+ * board of several, of all its lines otherwise: `enCours` ▶, `enAttente` ⏸, `arretes` ⛔.
1687
+ * @param {any} t
1688
+ * @param {string} [projet]
1689
+ */
1690
+ export function comptesDAgents(t, projet) {
1691
+ const l = etatsDAgents(t).lignes.filter(x => projet === undefined || x.projet === projet);
1692
+ const n = s => l.filter(x => x.signe === s).length;
1693
+ return { enCours: n('▶'), enAttente: n('⏸'), arretes: n('⛔') };
1694
+ }
1695
+
1501
1696
  // The board's lines, `largeur` columns wide, each with its tone (titre, alerte, attention, actif,
1502
1697
  // discret, or none), its section (`section`: agents, chantier or faits, in that order) and, for a
1503
1698
  // ticket's line, its id (`ticket`), which the pane makes selectable; an epic's line is marked
@@ -1524,6 +1719,16 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1524
1719
  const large = Math.max(0, ...(t.projets ?? []).map(p => p.etiquette.length + 3));
1525
1720
  const colonneDe = etiquette => `[${etiquette}]`.padEnd(large);
1526
1721
  L(nom.toUpperCase(), TONS.titre);
1722
+ // The state of each ticket's line of AGENTS, which AGENTS draws and the head counts.
1723
+ const etats = etatsDAgents(t);
1724
+ // The first line of the head, the signs of AGENTS counted (`comptesDAgents`) as AGENTS signs its
1725
+ // lines, then the tickets done: « ▶ N · ⏸ N · ⛔ N · ✓ N ».
1726
+ const ligneDesSignes = (a, fermes) =>
1727
+ `▶ ${a.enCours} · ⏸ ${a.enAttente} · ⛔ ${a.arretes} · ✓ ${fermes}`;
1728
+ // The line of the queues, under their signs: ● the tickets ready for the circuit, ✎ the direct
1729
+ // queue, ⊘ the tickets blocked by an open ticket.
1730
+ const ligneDeLaFile = c =>
1731
+ `⏭ file : ● ${c.enAttente} · ✎ ${c.fileDirecte ?? 0} · ⊘ ${c.bloques ?? 0}`;
1527
1732
  if (plusieurs) {
1528
1733
  // The three lines of states of each project, as one project's board says them: the first
1529
1734
  // under its label, the two others aligned below it; or the fault that keeps its board out.
@@ -1536,18 +1741,12 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1536
1741
  const c = p.compteurs;
1537
1742
  L(
1538
1743
  cadre(
1539
- `${colonneDe(p.etiquette)}▶ ${c.enCours} en cours · ${c.bloques ?? 0} bloqués · ${c.fermes} faits`,
1540
- '',
1541
- largeur
1542
- )
1543
- );
1544
- L(
1545
- cadre(
1546
- `${retrait}⏭ file : ${c.enAttente} en circuit · ${c.fileDirecte ?? 0} en direct`,
1744
+ `${colonneDe(p.etiquette)}${ligneDesSignes(comptesDAgents(t, p.etiquette), c.fermes)}`,
1547
1745
  '',
1548
1746
  largeur
1549
1747
  )
1550
1748
  );
1749
+ L(cadre(`${retrait}${ligneDeLaFile(c)}`, '', largeur));
1551
1750
  L(
1552
1751
  cadre(
1553
1752
  `${retrait}${c.sansGo ?? 0} sans go · ${c.aValider ?? 0} à valider · ${c.reportes ?? 0} reportés`,
@@ -1570,10 +1769,10 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1570
1769
  } else {
1571
1770
  const g = t.global;
1572
1771
  const c = g.compteurs;
1573
- // Three lines of states: the work, the queues (the circuit's, the direct one), then those that
1574
- // wait for the owner.
1575
- L(cadre(`▶ ${c.enCours} en cours · ${c.bloques} bloqués · ${c.fermes} faits`, '', largeur));
1576
- L(cadre(`⏭ file : ${c.enAttente} en circuit · ${c.fileDirecte} en direct`, '', largeur));
1772
+ // Three lines of states: the signs of AGENTS and the tickets done, the queues (the circuit's,
1773
+ // the direct one, the blocked), then those that wait for the owner.
1774
+ L(cadre(ligneDesSignes(comptesDAgents(t), c.fermes), '', largeur));
1775
+ L(cadre(ligneDeLaFile(c), '', largeur));
1577
1776
  L(
1578
1777
  cadre(`${c.sansGo} sans go · ${c.aValider} à valider · ${c.reportes} reportés`, '', largeur),
1579
1778
  c.sansGo ? TONS.sansGo : c.aValider ? TONS.aValider : TONS.reportes
@@ -1625,12 +1824,26 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1625
1824
  const p = t.places;
1626
1825
  if (p) {
1627
1826
  const nb = n => (Number.isInteger(n) ? String(n) : n.toFixed(1).replace('.', ','));
1827
+ // Who holds each place stands between the count and the load: the most names that keep the
1828
+ // line within the width, the others counted « +n ».
1829
+ const noms = p.noms ?? [];
1830
+ const suite = p.faute
1831
+ ? `plafond refusé : ${p.faute}`
1832
+ : `charge ${nb(p.charge)}/${p.coeurs} · mémoire ${p.memoireGo}/${p.memoireTotaleGo} Go`;
1833
+ const ligne = k =>
1834
+ `Places ${p.prises}/${p.plafond} · ${
1835
+ noms.length
1836
+ ? `${[noms.slice(0, k).join(', '), ...(k < noms.length ? [`+${noms.length - k}`] : [])]
1837
+ .filter(Boolean)
1838
+ .join(' ')} · `
1839
+ : ''
1840
+ }${suite}`;
1841
+ let k = noms.length;
1842
+ while (k > 0 && colonnes(ligne(k)) > largeur) {
1843
+ k--;
1844
+ }
1628
1845
  poser({
1629
- texte: cadre(
1630
- `Places ${p.prises}/${p.plafond} · ${p.faute ? `plafond refusé : ${p.faute}` : `charge ${nb(p.charge)}/${p.coeurs} · mémoire ${p.memoireGo}/${p.memoireTotaleGo} Go`}`,
1631
- '',
1632
- largeur
1633
- ),
1846
+ texte: cadre(ligne(k), '', largeur),
1634
1847
  ton: p.faute ? TONS.plafondRefuse : p.charge >= p.coeurs ? TONS.machineChargee : TONS.mesure,
1635
1848
  });
1636
1849
  // A ticket that waits for the disk of its project's copies: what holds it, the ticket named.
@@ -1641,6 +1854,18 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1641
1854
  ticket: w.ticket,
1642
1855
  });
1643
1856
  }
1857
+ // The night reserving the machine (`nuit` of the places: `attend`, `en cours`, none outside
1858
+ // the night): the stages under way finish, then the nights play.
1859
+ if (p.nuit) {
1860
+ poser({
1861
+ texte: cadre(
1862
+ p.nuit === 'attend' ? 'nuit : attend la fin des étapes en cours' : 'nuit en cours',
1863
+ '',
1864
+ largeur
1865
+ ),
1866
+ ton: p.nuit === 'attend' ? TONS.attendLeDisque : TONS.nuitEnCours,
1867
+ });
1868
+ }
1644
1869
  }
1645
1870
  // The night under way on the machine, under the places: « 🌙 nuit · <projet> · depuis <durée> »,
1646
1871
  // its project by its folder's name, the time since it started when the server gives it.
@@ -1679,41 +1904,24 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1679
1904
  }
1680
1905
  return couperAvant(avecQui, fin, '', largeur);
1681
1906
  };
1682
- // The lock on the line of each circuit shown that holds it or waits for it, by its ticket.
1683
- const verrouDe = new Map();
1907
+ // The lock of each circuit shown stands on its line (`etatsDAgents`); any other, here.
1684
1908
  const tenu = t.machine?.detenteur;
1685
- if (tenu) {
1909
+ if (tenu && !duCircuit(tenu)) {
1686
1910
  const a = tenu.avancement;
1687
1911
  const age = a ? maintenant - a.dernier : 0;
1688
1912
  const compte = a && (a.faits || a.prevus) ? `${a.faits}/${a.prevus}` : '';
1689
1913
  const fige = age > FIGEE;
1690
1914
  const depuis = ilYa(maintenant - (tenu.depuis ?? maintenant));
1691
- if (duCircuit(tenu)) {
1692
- const sorte = tenu.sorte.toLocaleLowerCase('fr');
1693
- verrouDe.set(tenu.ticket, {
1694
- fige,
1695
- texte: fige
1696
- ? ` · ⚠ ${sorte} figée ${ilYa(age)}${compte ? ` · ${compte}` : ''}`
1697
- : ` · 🔒 ${sorte}${compte ? ` ${compte}` : ''} · ${depuis}`,
1698
- });
1699
- } else {
1700
- poser({
1701
- texte: fige
1702
- ? ligneDuVerrou(`⚠ ${tenu.sorte} figée ${ilYa(age)}`, tenu, compte ? ` · ${compte}` : '')
1703
- : ligneDuVerrou(`🔒 ${tenu.sorte}`, tenu, ` · ${compte ? `${compte} · ` : ''}${depuis}`),
1704
- ton: fige ? TONS.fige : TONS.enCours,
1705
- avancement: true,
1706
- });
1707
- }
1915
+ poser({
1916
+ texte: fige
1917
+ ? ligneDuVerrou(`⚠ ${tenu.sorte} figée ${ilYa(age)}`, tenu, compte ? ` · ${compte}` : '')
1918
+ : ligneDuVerrou(`🔒 ${tenu.sorte}`, tenu, ` · ${compte ? `${compte} · ` : ''}${depuis}`),
1919
+ ton: fige ? TONS.fige : TONS.enCours,
1920
+ avancement: true,
1921
+ });
1708
1922
  }
1709
1923
  for (const w of [...(t.machine?.attentes ?? [])].sort((x, y) => x.depuis - y.depuis)) {
1710
1924
  if (duCircuit(w)) {
1711
- if (!verrouDe.has(w.ticket)) {
1712
- verrouDe.set(w.ticket, {
1713
- fige: false,
1714
- texte: ` · ⏳ ${w.sorte.toLocaleLowerCase('fr')} · ${ilYa(maintenant - w.depuis)}`,
1715
- });
1716
- }
1717
1925
  continue;
1718
1926
  }
1719
1927
  poser({
@@ -1727,31 +1935,28 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1727
1935
  avancement: true,
1728
1936
  });
1729
1937
  }
1730
- // The tickets whose circuit waits for the lock or for room.
1731
- const attendLeVerrou = new Set((t.machine?.attentes ?? []).map(w => w.ticket).filter(Boolean));
1732
- const enAttente = new Set(attendLeVerrou);
1733
- // The tickets whose circuit waits for a place of the machine, and those that wait for a place of
1734
- // a circuit, not started, whose line in their chantier says « attend une place ».
1938
+ // The tickets that wait for a place of a circuit, not started, whose line in their chantier says
1939
+ // « attend une place ».
1735
1940
  const attendUnePlace = new Set((p?.attentes ?? []).map(w => w.ticket).filter(Boolean));
1736
1941
  // The tickets that wait for the disk of their project's copies.
1737
1942
  const attendLeDisque = new Set((p?.attentes ?? []).filter(w => w.disque).map(w => w.ticket));
1738
- for (const id of attendUnePlace) {
1739
- enAttente.add(id);
1740
- }
1741
1943
  // The tree of the steps (scripts/etapes.mjs), in its order, as a pipeline of GitLab CI shows its
1742
1944
  // stages and folds the jobs of a stage that has nothing: a step with sub-steps is folded
1743
1945
  // (« ▸ 2 · Composants ») while none of them holds a ticket, unfolded (« ▾ ») once one does, all
1744
1946
  // its sub-steps then shown, indented, the empty ones in the discreet tone; a step without
1745
1947
  // sub-steps stands on one line « number · title · who », discreet when empty, a title with its
1746
- // tickets under it. A circuit's ticket stands on one line, at the step of its state, and nowhere
1747
- // else in AGENTS: the work on the plan at its step; waiting for the supervisor
1748
- // (`attendLeSuperviseur`), under its step after a line « ⤷ Question · <qui> », who
1948
+ // tickets under it. A circuit launched and not integrated stands on one line from its launch to
1949
+ // its end, and nowhere else in AGENTS: at the step that works, or, while it waits, at the step
1950
+ // about to be launched: the step of its state; the work on the plan at its step; a running
1951
+ // circuit with no known step at the step of its stop, else at the plan (1); waiting for the
1952
+ // supervisor (`attendLeSuperviseur`), under its step after a line « ⤷ Question · <qui> », who
1749
1953
  // must answer it, the supervisor or the owner, which unfolds the step, its counters those of its
1750
1954
  // step; a stopped circuit at no step of the list stands under that line after the steps. A
1751
1955
  // circuit's line gives its subject (`texte`), then the counters of the bounded loops of its step
1752
1956
  // from their second pass (`boucles` of the step, scripts/etapes.mjs, their counts in the state's
1753
- // `boucles`), whole; then its ticket's working time and tokens. Its card opens on
1754
- // its question, or says where it stopped and why. The tickets' numbers line up in one column.
1957
+ // `boucles`), whole, the reason of its wait; then its ticket's working time and tokens. Its card
1958
+ // opens on its question, or says where it stopped and why. The tickets' numbers line up in one
1959
+ // column.
1755
1960
  // The block of the step <e>, an empty one when the board holds none.
1756
1961
  const vides = new Map();
1757
1962
  const blocDe = e =>
@@ -1767,13 +1972,12 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1767
1972
  .get(e.numero);
1768
1973
  // The block of the circuits at no step of the list, after the steps.
1769
1974
  const ailleurs = { numero: null, titre: '', qui: '', enCours: [] };
1770
- const etapeDe = c => etapeDuCircuit({ ...c, raison: c.arret });
1771
- // A circuit that waits for the supervisor (`attendLeSuperviseur`, the one rule): who must answer
1772
- // its question, the supervisor when its stop names no one.
1773
- const enQuestion = c => (attendLeSuperviseur(c) ? (c.qui ?? SUPERVISEUR) : null);
1975
+ const etapeDe = etapeDuCircuitLu;
1976
+ // The block of the circuit <c>: the step of its state, else, while it stopped, the block after
1977
+ // the steps, else, running with no known step (it starts or resumes), the plan (1).
1774
1978
  const blocDuCircuit = c => {
1775
1979
  const e = etapeDe(c);
1776
- return e ? blocDe(e) : !c.vivant ? ailleurs : undefined;
1980
+ return e ? blocDe(e) : !c.vivant ? ailleurs : blocDe(ETAPES[0]);
1777
1981
  };
1778
1982
  const montres = t.agents.flatMap(b => b.enCours.filter(x => !enCircuit.has(x.id)));
1779
1983
  // A ticket's number, or on several projects' board its whole id, in one column.
@@ -1790,56 +1994,45 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1790
1994
  : `${signe} ${nomme(x).padEnd(colonne)} `;
1791
1995
  const droiteDe = (signe, droite) =>
1792
1996
  plusieurs ? `${signe}${droite ? ` ${droite}` : ''}` : droite;
1793
- // The state of a circuit's line, whose tone TONS gives: frozen, its question (to the supervisor
1794
- // or to another), stopped, its wait for the disk, a place or the lock, else it runs.
1795
- const etatDuCircuit = (c, temoin) =>
1796
- temoin?.fige
1797
- ? 'fige'
1798
- : !c.vivant
1799
- ? enQuestion(c) === SUPERVISEUR
1800
- ? 'attendLeSuperviseur'
1801
- : enQuestion(c)
1802
- ? 'attendLeResponsable'
1803
- : 'arrete'
1804
- : attendLeDisque.has(c.id)
1805
- ? 'attendLeDisque'
1806
- : attendUnePlace.has(c.id)
1807
- ? 'attendUnePlace'
1808
- : attendLeVerrou.has(c.id)
1809
- ? 'attendLeVerrou'
1810
- : 'enCours';
1997
+ // A ticket's line of `largeur` columns: its head <tete> (its sign and number, or its project and
1998
+ // id) whole, then its subject, cut to leave <suite> and the right part <droite> whole; without
1999
+ // room for the subject, <suite> is cut, never the head.
2000
+ const ligneDuTicket = (tete, sujet, suite, droite) => {
2001
+ const place = largeur - colonnes(tete) - colonnes(suite) - (droite ? colonnes(droite) + 1 : 0);
2002
+ if (place < 2) {
2003
+ return couper(`${tete}${suite}`, droite, largeur);
2004
+ }
2005
+ const s = colonnes(sujet) > place ? `${debutDe(sujet, place - 1)}…` : sujet;
2006
+ return couper(`${tete}${s}${suite}`, droite, largeur);
2007
+ };
1811
2008
  const ligneDuCircuit = c => {
1812
- const signe = !c.vivant ? '⏸' : enAttente.has(c.id) ? '⏳' : '▶';
2009
+ const etape = etapeDe(c);
2010
+ // Its state, its sign, its reason and its witness, as the head counts them.
2011
+ const { ton, signe, raison, temoin } = etats.circuits.get(c.id);
1813
2012
  const droite = droiteDe(
1814
2013
  signe,
1815
2014
  conso(t.parTicket?.[c.id]?.travail ?? 0, t.parTicket?.[c.id]?.jetons ?? 0)
1816
2015
  );
1817
- const etape = etapeDe(c);
1818
2016
  const boucles = (etape ? bouclesDe(etape) : [])
1819
2017
  .filter(b => b.max && c.boucles?.[b.cle] >= 2)
1820
2018
  .map(b => ` · ${b.libelle} ${c.boucles[b.cle]}/${b.max}`)
1821
2019
  .join('');
1822
2020
  const tete = teteDe(signe, c);
1823
- // The lock it holds or waits for, else the progress of its pass.
1824
- const temoin =
1825
- verrouDe.get(c.id) ??
1826
- (c.vivant && etape?.qui.includes(AUTO) ? temoinDe(c, maintenant) : null);
2021
+ const pourquoi = raison ? ` · ${raison}` : '';
1827
2022
  // The progress after the counters of the loops while the subject keeps its room beside them,
1828
- // in their place otherwise.
2023
+ // in their place otherwise; the reason of its wait last.
1829
2024
  const reste = avec =>
1830
2025
  largeur - (droite ? colonnes(droite) + 1 : 0) - colonnes(tete) - colonnes(avec);
1831
- const place = attendUnePlace.has(c.id) ? ' · attend une place' : '';
1832
- const tag = enQuestion(c) === SUPERVISEUR ? ' · en attente du superviseur' : '';
1833
- const suite = `${tag}${
2026
+ const suite = `${
1834
2027
  !temoin
1835
2028
  ? boucles
1836
- : reste(`${boucles}${temoin.texte}`) >= Math.min(PLACE_DU_SUJET, c.sujet.length)
2029
+ : reste(`${boucles}${temoin.texte}${pourquoi}`) >= Math.min(PLACE_DU_SUJET, c.sujet.length)
1837
2030
  ? `${boucles}${temoin.texte}`
1838
2031
  : temoin.texte
1839
- }${place}`;
2032
+ }${pourquoi}`;
1840
2033
  poser({
1841
- texte: couperAvant(`${tete}${c.sujet}`, suite, droite, largeur),
1842
- ton: TONS[etatDuCircuit(c, temoin)],
2034
+ texte: ligneDuTicket(tete, c.sujet, suite, droite),
2035
+ ton,
1843
2036
  ticket: c.id,
1844
2037
  ...(temoin ? { avancement: true } : {}),
1845
2038
  });
@@ -1871,7 +2064,7 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1871
2064
  }
1872
2065
  for (const x of enCours) {
1873
2066
  L(
1874
- cadre(`${teteDe('▶', x)}${x.sujet}`, droiteDe('▶', conso(x.travail, x.jetons)), largeur),
2067
+ ligneDuTicket(teteDe('▶', x), x.sujet, '', droiteDe('▶', conso(x.travail, x.jetons))),
1875
2068
  TONS.enCours,
1876
2069
  x.id
1877
2070
  );
@@ -1889,10 +2082,10 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1889
2082
  plein ? TONS.titre : TONS.vide
1890
2083
  );
1891
2084
  // The tickets worked out of a circuit, once each, before the steps, from their claim to their
1892
- // close: « ✎ <numéro> <sujet> · en direct ».
2085
+ // close: « ▶ <numéro> <sujet> · en direct ».
1893
2086
  for (const x of t.horsCircuit ?? []) {
1894
2087
  poser({
1895
- texte: couperAvant(`${teteDe('✎', x)}${x.sujet}`, ' · en direct', droiteDe('✎', ''), largeur),
2088
+ texte: ligneDuTicket(teteDe('▶', x), x.sujet, ' · en direct', droiteDe('▶', '')),
1896
2089
  ton: TONS.enDirect,
1897
2090
  ticket: x.id,
1898
2091
  });
@@ -2220,9 +2413,12 @@ export function dernierBouge(tous, lignesDuTableau, vivants = [], maintenant = D
2220
2413
 
2221
2414
  // The status line: the chantier in progress; first the alerts, counted by their signs as the board
2222
2415
  // shows them (🌙, 💤, ⚠), then the holder of the lock of the machine, « 🔒 <sorte> · <projet> »,
2223
- // and the count of its waits, « ⏳ <n> ».
2224
- export function ligneEtat(t) {
2225
- const signes = t.alertes.map(signeDe);
2416
+ // and the count of its waits, « ⏳ <n> »; then the signs of AGENTS counted as the head counts them
2417
+ // (`comptesDAgents`), « ▶ N · ⏸ N · ⛔ N ». The alerts of the other projects of a board of several
2418
+ // (<voisins>, their boards) count beside the session's, as a multi-root status bar counts the problems
2419
+ // of every root; the counters and the chantier stay the session's.
2420
+ export function ligneEtat(t, voisins = []) {
2421
+ const signes = [t, ...voisins].flatMap(b => b.alertes ?? []).map(signeDe);
2226
2422
  const tenu = t.machine?.detenteur;
2227
2423
  const attentes = t.machine?.attentes?.length ?? 0;
2228
2424
  const alerte = [
@@ -2234,27 +2430,76 @@ export function ligneEtat(t) {
2234
2430
  .join('');
2235
2431
  const ch = t.chantiers[0];
2236
2432
  const c = t.global.compteurs;
2433
+ const a = comptesDAgents(t);
2434
+ const dAgents = `▶ ${a.enCours} · ⏸ ${a.enAttente} · ⛔ ${a.arretes}`;
2237
2435
  if (!ch) {
2238
- return `${alerte}Grillhouse : ${c.enCours} en cours · ⏭ ${c.enAttente} · ✎ ${c.fileDirecte} · ${c.fermes} faits`;
2436
+ return `${alerte}Grillhouse : ${dAgents} · ⏭ ● ${c.enAttente} · ✎ ${c.fileDirecte} · ✓ ${c.fermes}`;
2239
2437
  }
2240
- return `${alerte}${ch.numero} ${ch.faits}/${ch.total} · ▶ ${c.enCours} en cours · ${k(t.global.jour.jetons)} aujourd'hui`;
2438
+ return `${alerte}${ch.numero} ${ch.faits}/${ch.total} · ${dAgents} · ${k(t.global.jour.jetons)} aujourd'hui`;
2241
2439
  }
2242
2440
 
2441
+ // The answer of Beads to <args> in the repository at <racine>, as JSON (`liste`), or the first line
2442
+ // of its fault (`faute`), its error output first.
2243
2443
  const bdJson = (racine, ...args) => {
2244
2444
  try {
2245
- return JSON.parse(
2246
- execFileSync('bd', [...args, '--json'], {
2247
- cwd: racine,
2248
- encoding: 'utf8',
2249
- stdio: ['ignore', 'pipe', 'ignore'],
2250
- maxBuffer: 256 * 1024 * 1024,
2251
- })
2252
- );
2253
- } catch {
2254
- return [];
2445
+ return {
2446
+ liste: JSON.parse(
2447
+ execFileSync('bd', [...args, '--json'], {
2448
+ cwd: racine,
2449
+ encoding: 'utf8',
2450
+ stdio: ['ignore', 'pipe', 'pipe'],
2451
+ maxBuffer: 256 * 1024 * 1024,
2452
+ })
2453
+ ),
2454
+ faute: null,
2455
+ };
2456
+ } catch (e) {
2457
+ const message = String(e?.stderr ?? '').trim() || String(e?.message ?? e);
2458
+ return { liste: [], faute: message.split('\n')[0] };
2255
2459
  }
2256
2460
  };
2257
2461
 
2462
+ // The file of the last reading that succeeded of <quoi> (`circuits`, `tickets`), beside the
2463
+ // status line in the common dir <commun>; null without a common dir.
2464
+ const fichierDeLaLecture = (commun, quoi) => commun && path.join(commun, `tableau-lu-${quoi}.json`);
2465
+
2466
+ /**
2467
+ * The reading of <quoi> (`circuits`, `tickets`) of the project whose common dir is <commun>, kept
2468
+ * when it succeeded, as a dashboard keeps showing its last data with their age: a reading that
2469
+ * succeeded (<liste>, not null) is written with its time <maintenant> and comes back as it is,
2470
+ * `lu` null; a reading that failed (<liste> null) comes back as the last one kept, `lu` its time,
2471
+ * or empty, `lu` null, without one. A place that cannot be written or read keeps none.
2472
+ * @param {string | null} commun
2473
+ * @param {'circuits' | 'tickets'} quoi
2474
+ * @param {any[] | null} liste
2475
+ * @param {number} maintenant
2476
+ * @returns {{ liste: any[], lu: number | null }}
2477
+ */
2478
+ export function lectureGardee(commun, quoi, liste, maintenant) {
2479
+ const fichier = fichierDeLaLecture(commun, quoi);
2480
+ if (liste) {
2481
+ try {
2482
+ if (fichier) {
2483
+ // Written beside, then renamed: a reader never sees a file half written.
2484
+ writeFileSync(`${fichier}.${process.pid}`, JSON.stringify({ lu: maintenant, liste }));
2485
+ renameSync(`${fichier}.${process.pid}`, fichier);
2486
+ }
2487
+ } catch {
2488
+ // A read-only place keeps the board working, without the reading kept.
2489
+ }
2490
+ return { liste, lu: null };
2491
+ }
2492
+ try {
2493
+ const garde = JSON.parse(readFileSync(fichier, 'utf8'));
2494
+ if (Array.isArray(garde.liste) && typeof garde.lu === 'number') {
2495
+ return { liste: garde.liste, lu: garde.lu };
2496
+ }
2497
+ } catch {
2498
+ // No reading kept.
2499
+ }
2500
+ return { liste: [], lu: null };
2501
+ }
2502
+
2258
2503
  // The folder git keeps a repository's shared files in (its common dir), absolute; null when
2259
2504
  // <racine> is no git repository. The board's cache and the day's marker live there.
2260
2505
  export function dossierCommun(racine) {
@@ -2351,8 +2596,22 @@ function lire(
2351
2596
  ps = '';
2352
2597
  }
2353
2598
  const registre = existsSync(REGISTRE) ? lireRegistre(readFileSync(REGISTRE, 'utf8'), racine) : [];
2354
- const tous = bdJson(racine, 'list', '--all', '--limit', '0');
2355
2599
  const commun = dossierCommun(racine);
2600
+ // The tickets and the circuits, each the last reading that succeeded when this one failed.
2601
+ const lesTickets = bdJson(racine, 'list', '--all', '--limit', '0');
2602
+ const tickets = lectureGardee(
2603
+ commun,
2604
+ 'tickets',
2605
+ lesTickets.faute ? null : lesTickets.liste,
2606
+ maintenant
2607
+ );
2608
+ const tous = tickets.liste;
2609
+ const lesCircuitsLus = lectureGardee(
2610
+ commun,
2611
+ 'circuits',
2612
+ muet || faute ? null : circuits,
2613
+ maintenant
2614
+ );
2356
2615
  const fichierCache = commun && path.join(commun, 'tableau-cache.json');
2357
2616
  let cache = {};
2358
2617
  try {
@@ -2389,9 +2648,10 @@ function lire(
2389
2648
  const t = assembler({
2390
2649
  tous,
2391
2650
  prefix,
2651
+ racine: commun ? path.dirname(commun) : racine,
2392
2652
  registre,
2393
2653
  vivants,
2394
- circuits,
2654
+ circuits: lesCircuitsLus.liste,
2395
2655
  maintenant,
2396
2656
  jour,
2397
2657
  voies,
@@ -2400,11 +2660,15 @@ function lire(
2400
2660
  nuit,
2401
2661
  muet,
2402
2662
  faute,
2663
+ circuitsLusA: lesCircuitsLus.lu,
2664
+ fauteTickets: lesTickets.faute,
2665
+ ticketsLusA: tickets.lu,
2403
2666
  echecPrefixe,
2404
2667
  outil: echecDeLOutil(racine),
2405
2668
  remontees: lireLesRemontees(racine, maintenant),
2406
2669
  attenteVivante: attenteVivante(racine),
2407
2670
  superviseur,
2671
+ externes: lireLesExternes(racine, tous),
2408
2672
  });
2409
2673
  return { t, prefix, tous, vivants, commun };
2410
2674
  }
@@ -2477,8 +2741,8 @@ export function ensemble(lus) {
2477
2741
  };
2478
2742
  }
2479
2743
 
2480
- // A project beside the session's, read in its folder <dossier>: its board, or the fault that keeps
2481
- // it out, on one line.
2744
+ // A project beside the session's, read in its folder <dossier>: its board, the faults of its
2745
+ // reading of the circuits in its alerts, or the fault that keeps it out, on one line.
2482
2746
  async function lireUnAutre(dossier, { circuitsDe, ...o }) {
2483
2747
  try {
2484
2748
  if (!existsSync(dossier)) {
@@ -2486,7 +2750,7 @@ async function lireUnAutre(dossier, { circuitsDe, ...o }) {
2486
2750
  }
2487
2751
  return {
2488
2752
  dossier,
2489
- ...lire(dossier, { ...o, circuits: (await lesCircuits(circuitsDe, dossier)).circuits }),
2753
+ ...lire(dossier, { ...o, ...(await lesCircuits(circuitsDe, dossier)) }),
2490
2754
  };
2491
2755
  } catch (e) {
2492
2756
  return { dossier, erreur: String(e.message ?? e).split('\n')[0] };
@@ -2494,8 +2758,9 @@ async function lireUnAutre(dossier, { circuitsDe, ...o }) {
2494
2758
  }
2495
2759
 
2496
2760
  // The circuits of the repository at <racine> by the reader <circuitsDe>; none when the reading
2497
- // fails, the board shows the rest: the server stayed silent (`muet`, `ServeurMuet`), or another
2498
- // fault, a client not built among them, by the first line of its message (`faute`).
2761
+ // fails, which `lire` replaces by the last reading kept: the server stayed silent (`muet`,
2762
+ // `ServeurMuet`), or another fault, a client not built among them, by the first line of its
2763
+ // message (`faute`).
2499
2764
  async function lesCircuits(circuitsDe, racine) {
2500
2765
  try {
2501
2766
  return { circuits: await circuitsDe(racine), muet: false, faute: null };
@@ -2573,7 +2838,32 @@ export async function tableau(
2573
2838
  }),
2574
2839
  };
2575
2840
  const lus = [ici, ...autres];
2576
- const etiquette = l => l.prefix || path.basename(l.dossier);
2841
+ // A project is labelled by its sigle (scripts/sigle-du-projet.mjs: the key `grillhouse.sigle`, else
2842
+ // its ticket prefix), as the line of the places names it; a project with neither keeps its
2843
+ // folder's name. A faulty key is said in an alert, the prefix staying the sigle; two projects of
2844
+ // the board with one sigle are said, both named.
2845
+ const sigles = new Map(lus.map(l => [l, sigleDuProjet(l.dossier)]));
2846
+ const etiquette = l => sigles.get(l).sigle || l.prefix || path.basename(l.dossier);
2847
+ const alerteDeSigle = (l, texte) =>
2848
+ (l.t ?? ici.t).alertes.push({ etat: 'panne', ton: TONS.panne, texte });
2849
+ for (const l of lus) {
2850
+ const { faute } = sigles.get(l);
2851
+ if (faute) {
2852
+ alerteDeSigle(l, `Sigle illisible : ${faute}`);
2853
+ }
2854
+ }
2855
+ const memeSigle = new Map();
2856
+ for (const l of lus) {
2857
+ memeSigle.set(etiquette(l), [...(memeSigle.get(etiquette(l)) ?? []), l]);
2858
+ }
2859
+ for (const [sigle, deux] of memeSigle) {
2860
+ if (deux.length > 1) {
2861
+ alerteDeSigle(
2862
+ ici,
2863
+ `Sigle « ${sigle} » porté par ${deux.map(l => path.basename(l.dossier)).join(' et ')}`
2864
+ );
2865
+ }
2866
+ }
2577
2867
  // The lock of the machine names each project of the board as the board does: the session's by
2578
2868
  // its folder, another by its label; the root of its main tree, its common git directory's parent.
2579
2869
  ici.t.machine = nommerLesProjets(
@@ -2585,7 +2875,7 @@ export async function tableau(
2585
2875
  ),
2586
2876
  ici.commun ? path.dirname(ici.commun) : null
2587
2877
  );
2588
- const etat = ligneEtat(ici.t);
2878
+ const etat = ligneEtat(ici.t, autres.map(l => l.t).filter(Boolean));
2589
2879
  try {
2590
2880
  if (ici.commun) {
2591
2881
  writeFileSync(path.join(ici.commun, 'grillhouse-etat.txt'), `${etat}\n`);