@roomi-fields/grillhouse 0.52.0 → 0.54.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 (155) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +96 -0
  3. package/agents/direct.md +1 -1
  4. package/cadre/templates/projet/docs/agents/issue-tracker.md +2 -2
  5. package/cadre/templates/projet/vitest.config.cjs +45 -0
  6. package/charte/superviseur.md +36 -37
  7. package/charte.md +13 -1
  8. package/dist/temporal/circuit/appel.d.ts +2 -0
  9. package/dist/temporal/circuit/appel.js +24 -2
  10. package/dist/temporal/circuit/appel.js.map +1 -1
  11. package/dist/temporal/circuit/client.d.ts +14 -5
  12. package/dist/temporal/circuit/client.js +41 -9
  13. package/dist/temporal/circuit/client.js.map +1 -1
  14. package/dist/temporal/circuit/commande.js +17 -6
  15. package/dist/temporal/circuit/commande.js.map +1 -1
  16. package/dist/temporal/circuit/contrat.d.ts +9 -0
  17. package/dist/temporal/circuit/contrat.js +6 -0
  18. package/dist/temporal/circuit/contrat.js.map +1 -1
  19. package/dist/temporal/circuit/deroule.js +29 -12
  20. package/dist/temporal/circuit/deroule.js.map +1 -1
  21. package/dist/temporal/client.d.ts +35 -1
  22. package/dist/temporal/client.js +144 -1
  23. package/dist/temporal/client.js.map +1 -1
  24. package/dist/temporal/commande.js +31 -13
  25. package/dist/temporal/commande.js.map +1 -1
  26. package/dist/temporal/etat.d.ts +3 -1
  27. package/dist/temporal/etat.js +31 -17
  28. package/dist/temporal/etat.js.map +1 -1
  29. package/dist/temporal/file/activites.js +1 -1
  30. package/dist/temporal/file/activites.js.map +1 -1
  31. package/dist/temporal/file/contrat.d.ts +4 -5
  32. package/dist/temporal/file/contrat.js +2 -2
  33. package/dist/temporal/file/contrat.js.map +1 -1
  34. package/dist/temporal/file/deroule.js +7 -5
  35. package/dist/temporal/file/deroule.js.map +1 -1
  36. package/dist/temporal/installation.d.ts +116 -53
  37. package/dist/temporal/installation.js +898 -241
  38. package/dist/temporal/installation.js.map +1 -1
  39. package/dist/temporal/nuits/deroule.js +3 -1
  40. package/dist/temporal/nuits/deroule.js.map +1 -1
  41. package/dist/temporal/places/deroule.js +2 -1
  42. package/dist/temporal/places/deroule.js.map +1 -1
  43. package/dist/temporal/sonde/deroule.js +2 -1
  44. package/dist/temporal/sonde/deroule.js.map +1 -1
  45. package/dist/temporal/tickets/deroule.js +4 -3
  46. package/dist/temporal/tickets/deroule.js.map +1 -1
  47. package/dist/temporal/travailleur.d.ts +7 -1
  48. package/dist/temporal/travailleur.js +49 -25
  49. package/dist/temporal/travailleur.js.map +1 -1
  50. package/docs/INTERFACE.md +37 -12
  51. package/docs/architecture/circuit.md +21 -18
  52. package/docs/architecture/entree.md +10 -11
  53. package/docs/architecture/greffon.md +45 -27
  54. package/docs/architecture/installation.md +92 -59
  55. package/docs/architecture/machine.md +2 -2
  56. package/docs/architecture/tests.md +15 -6
  57. package/docs/lexique.md +2 -2
  58. package/hooks/hooks.json +10 -0
  59. package/hooks/register.tsx +59 -39
  60. package/package.json +3 -2
  61. package/scripts/activites.mjs +5 -4
  62. package/scripts/aiguillage.mjs +5 -2
  63. package/scripts/bd-garde.mjs +69 -0
  64. package/scripts/ci-de-main.mjs +259 -56
  65. package/scripts/circuit.mjs +274 -47
  66. package/scripts/circuits-du-serveur.mjs +3 -2
  67. package/scripts/circuits-tenus.d.mts +7 -0
  68. package/scripts/circuits-tenus.mjs +17 -0
  69. package/scripts/commandes-composees.mjs +1 -1
  70. package/scripts/copie-de-montee.mjs +354 -0
  71. package/scripts/copies-du-depot.d.mts +13 -0
  72. package/scripts/copies-du-depot.mjs +66 -0
  73. package/scripts/copies-finies.mjs +6 -40
  74. package/scripts/crochets.mjs +16 -2
  75. package/scripts/direct.mjs +2 -2
  76. package/scripts/droits.mjs +13 -6
  77. package/scripts/engendres.mjs +5 -3
  78. package/scripts/enveloppe/travail-de-la-copie.mjs +77 -0
  79. package/scripts/etapes.mjs +11 -3
  80. package/scripts/faits-du-circuit.mjs +12 -5
  81. package/scripts/file-des-tickets.d.mts +13 -2
  82. package/scripts/file-des-tickets.mjs +71 -21
  83. package/scripts/greffons.mjs +42 -27
  84. package/scripts/grillhouse-maj.mjs +105 -85
  85. package/scripts/init.mjs +1 -1
  86. package/scripts/integration/file.mjs +5 -2
  87. package/scripts/integration/integrer.mjs +14 -4
  88. package/scripts/jointure.d.ts +16 -0
  89. package/scripts/langages/c/commandes.mjs +18 -8
  90. package/scripts/langages/cargo/commandes.mjs +88 -35
  91. package/scripts/langages/cargo/index.mjs +6 -3
  92. package/scripts/langages/cargo/sccache.mjs +15 -12
  93. package/scripts/langages/cargo/tailles-des-tests.mjs +115 -6
  94. package/scripts/langages/python/commandes.mjs +19 -9
  95. package/scripts/langages/python/squelette.mjs +2 -2
  96. package/scripts/langages/typescript/code-mort.mjs +36 -3
  97. package/scripts/langages/typescript/configurations-de-vitest.mjs +118 -0
  98. package/scripts/langages/typescript/index.mjs +2 -0
  99. package/scripts/langages/typescript/migrations/configurations-en-commonjs.mjs +370 -0
  100. package/scripts/langages/typescript/mise-a-jour.mjs +49 -12
  101. package/scripts/langages/typescript/parcours.mjs +5 -1
  102. package/scripts/langages/typescript/squelette.mjs +20 -17
  103. package/scripts/langages/typescript/tests-de-nuit.mjs +3 -3
  104. package/scripts/langages/typescript/turbo-des-paquets.mjs +24 -37
  105. package/scripts/langages/typescript/vitest-config/base.mjs +1 -1
  106. package/scripts/langages/typescript/vitest-config/bornes.mjs +1 -1
  107. package/scripts/langages/typescript/vitest-config/cibles.mjs +2 -2
  108. package/scripts/langages/typescript/{vitest.nuit.config.mjs → vitest.nuit.config.cjs} +61 -50
  109. package/scripts/langages.d.mts +6 -0
  110. package/scripts/langages.mjs +6 -0
  111. package/scripts/lire.mjs +236 -0
  112. package/scripts/mesure/pression.mjs +5 -3
  113. package/scripts/migrations/cout-des-jetons-au-registre.mjs +136 -0
  114. package/scripts/migrations/lire-un-ticket.mjs +46 -0
  115. package/scripts/migrations.mjs +4 -0
  116. package/scripts/montee.mjs +588 -0
  117. package/scripts/nuit.sh +21 -12
  118. package/scripts/outil.mjs +5 -3
  119. package/scripts/paquet-npm.mjs +22 -0
  120. package/scripts/paquet.mjs +5 -5
  121. package/scripts/pre-compact.mjs +25 -0
  122. package/scripts/registre.d.mts +7 -1
  123. package/scripts/registre.mjs +114 -102
  124. package/scripts/reponses-du-circuit.d.mts +17 -2
  125. package/scripts/reponses-du-circuit.mjs +78 -20
  126. package/scripts/resultats.mjs +55 -17
  127. package/scripts/retirer-les-copies-finies.mjs +4 -7
  128. package/scripts/seances.mjs +28 -3
  129. package/scripts/services-du-noyau.mjs +7 -2
  130. package/scripts/session-start.sh +18 -11
  131. package/scripts/sortie.mjs +4 -7
  132. package/scripts/sous-commandes.mjs +2 -0
  133. package/scripts/suiveur.mjs +12 -4
  134. package/scripts/superviseur.mjs +135 -84
  135. package/scripts/tableau.mjs +651 -224
  136. package/scripts/tarifs.mjs +67 -0
  137. package/scripts/ticket-du-circuit.mjs +25 -4
  138. package/scripts/transitions.d.mts +6 -14
  139. package/scripts/transitions.mjs +126 -49
  140. package/scripts/verdict-de-la-nuit.mjs +2 -2
  141. package/scripts/verrou-de-fichier.d.mts +11 -0
  142. package/skills/direct/SKILL.md +21 -11
  143. package/skills/explorateur/SKILL.md +16 -6
  144. package/skills/grill/SKILL.md +9 -7
  145. package/skills/grill/references/paquets.md +4 -4
  146. package/skills/mesure/SKILL.md +4 -3
  147. package/skills/pitmaster/SKILL.md +56 -35
  148. package/skills/pitmaster/references/consigne-agent.md +1 -1
  149. package/skills/pitmaster/references/erreurs.md +4 -2
  150. package/skills/pitmaster/references/tour.md +11 -4
  151. package/skills/relecteur/SKILL.md +8 -1
  152. package/skills/testwriter/SKILL.md +1 -1
  153. package/types/index.d.ts +3 -1
  154. package/cadre/templates/projet/vitest.config.ts +0 -44
  155. package/scripts/base-des-workflows.mjs +0 -58
@@ -16,7 +16,16 @@
16
16
  // questions that wait for the owner), one « ❓ » line per such question, « file » (the queues),
17
17
  // « en cours » (in progress, done, deferred; a circuit launched and not integrated is in
18
18
  // progress, not done); these lines once per project on a board of several. Then the day's
19
- // discoveries, and the day's and cumulative time and tokens.
19
+ // discoveries, and the day's line and the cumul's, each its time, its tokens and its cost.
20
+ // - Spending: the tokens of the day and of the cumul add every billed kind (input, output, cache
21
+ // written and read), and their cost is the register's `cout`. Each agent counts once, by its
22
+ // latest line, or by its transcript when that holds a spending the register lacks (no line, an
23
+ // agent running again, a response after its latest line); the day takes the responses dated
24
+ // since its marker, an agent without a transcript whole the day of its end. A sum that lacks the
25
+ // cost of an agent that spent tokens says its known cost, « ≥ 12 $ ». A response present in
26
+ // several transcripts of the project, named by its message's id and its request's id, counts once
27
+ // (`retenuesAilleurs`). A transcript silent for 30 minutes keeps in the cache its spending and
28
+ // the responses it shares alone (`lireLesDepenses`).
20
29
  // - AGENTS: the tree of the steps (scripts/etapes.mjs), one block per step and sub-step. A ticket
21
30
  // stands at a step only by its circuit or by an agent that runs on it; a ticket in the queue,
22
31
  // its circuit not launched, stands at no step. A circuit (scripts/circuit.mjs) launched and not
@@ -27,6 +36,10 @@
27
36
  // shows « ⤷ Question · <qui> » under its step;
28
37
  // its card opens on that question, or on the stop (name, code) and the first line of its
29
38
  // reason.
39
+ // - The direct circuit and the rescue command: an open circuit (it runs, or waits for an answer,
40
+ // never ended without its issue) keeps its ticket's line, and its agent `direct` stands at 3
41
+ // Code; on a ticket labelled `direct` without an open circuit, a role agent that works shows
42
+ // alone (`direct` under the block « Direct »), without the circuit's line.
30
43
  // - Readings: a reading of the circuits or of the tickets that fails gives way to the last one
31
44
  // that succeeded (`lectureGardee`, `tableau-lu-<quoi>.json` in the common git directory), its
32
45
  // age in the alert that names the fault; a project beside the session's says its own faults.
@@ -42,7 +55,7 @@
42
55
  // sub-agent or a session whose transcript moved in the last 2 minutes. With an end in the
43
56
  // register, an agent runs again only when an incoming message follows its latest end strictly.
44
57
  // A sub-agent also runs while its last tool call awaits its answer, its transcript having
45
- // moved in the last 30 minutes; the board reads no transcript older than 30 minutes.
58
+ // moved in the last 30 minutes; the running view reads no transcript older than 30 minutes.
46
59
  // - Time: a transcript's working time is the union of its turns (`horsDuTour` leaves out what a
47
60
  // resumption writes before its incoming message), read where the board stopped, its reading in
48
61
  // the cache file. A ticket's time adds the steps its circuit leads itself (the register's lines
@@ -60,18 +73,21 @@
60
73
  // cœurs · 26 réservés sur 28 · 4 Go réservés, limite 8 Go · <durée> » for a wait. The block at
61
74
  // the head of AGENTS (`lignesDesParts`) keeps the budget taken, « Parts · 2 passes · 6 sur 8
62
75
  // cœurs · 11 sur 16 Go », which counts
63
- // every pass that holds a part, a ticket the board does not show included, then the passes with
64
- // no ticket (« 🔒 <sorte> · <projet> · 4 cœurs · 8 Go »), then each wait in the order of its
65
- // rank (« ⏳ <sorte> · <projet> · attend <raison> »). Such a line is marked `avancement`, which
66
- // the pane measures again more often.
76
+ // every pass of the machine that holds a part, a ticket the board does not show and another
77
+ // project's pass included, then the passes with no ticket of the board's project (the
78
+ // session's, `ici`; « 🔒 <sorte> · <projet> · 4 cœurs · 8 Go »), then their waits in the order of
79
+ // their rank (« ⏳ <sorte> · <projet> · attend <raison> »). Such a line is marked `avancement`,
80
+ // which the pane measures again more often.
67
81
  // - Signs: a ticket's line in AGENTS takes one of three, by the tone of its state: ▶ its step
68
- // works (cyan; ▷ in a short circuit, a ticket led in direct included); ⏸ it waits, the reason on
69
- // its right (« attend une place », « verrou », « disque », « démarre » in grey, waiting for the
70
- // machine; « question au superviseur », « question au responsable », « arrêté » in yellow,
71
- // waiting for someone); ⛔ it stopped on a fault or its pass is frozen (red). At the head of
72
- // AGENTS, 🔒 and ⏳ for a pass with no ticket, 🌙 the night under way. Alerts: 💤 a ticket
73
- // claimed with nothing running, 🌙 a red night, ⚠ the others. A sign is followed by a space; the
74
- // width of a line counts its columns (`colonnes`), ⏳ and ⛔ two.
82
+ // works (cyan; ▷ in a short circuit, ✎ in a direct one, by its view, `circuit`); ⏸ it waits,
83
+ // the reason on its right (« attend une place », « verrou », « disque », « démarre » in grey,
84
+ // waiting for the machine; « question au superviseur », « question au responsable », « arrêté »
85
+ // in yellow, waiting for someone); ⛔ it stopped on a fault or its pass is frozen (red). At
86
+ // the head of AGENTS, 🔒 and ⏳ for a pass with no ticket of the board's project, 🌙 the night
87
+ // under way. Alerts:
88
+ // 💤 a ticket claimed with nothing running, 🌙 a red night, ⚠ the others.
89
+ // A sign is followed by a space; the width of a line counts its columns (`colonnes`), ⏳ and ⛔
90
+ // two.
75
91
  // - Alerts: one per open night ticket (🌙), per circuit that waits for the supervisor (⏳, how
76
92
  // long), a shell agent silent for 10 minutes, a ticket in progress with nothing running for 30
77
93
  // minutes (💤), each with its state (`etat`).
@@ -85,6 +101,7 @@ import {
85
101
  openSync,
86
102
  readdirSync,
87
103
  readFileSync,
104
+ realpathSync,
88
105
  readSync,
89
106
  renameSync,
90
107
  statSync,
@@ -107,9 +124,11 @@ import {
107
124
  SUPERVISEUR,
108
125
  } from './etapes.mjs';
109
126
  import { echecDeLOutil } from './aiguillage.mjs';
127
+ import { bdAAppeler, garderBd } from './bd-garde.mjs';
110
128
  import { maxDuProjet } from './circuits-cles.mjs';
111
129
  import { bilansGardes, enBref } from './bilans-gardes.mjs';
112
130
  import { REGISTRE } from './adresse-du-registre.mjs';
131
+ import { cleDuTarif, coutDe } from './tarifs.mjs';
113
132
  import { lireLaMesure } from './avancement.mjs';
114
133
  import {
115
134
  alerteDeDeclenchement,
@@ -129,8 +148,10 @@ import {
129
148
  attendDeLAutreProjet,
130
149
  enFileSansArchitecture,
131
150
  enFileSurMain,
151
+ leReportRendLaPlace,
132
152
  lireLesExternes,
133
153
  lotEstSurMain,
154
+ reporteJusqua,
134
155
  } from './file-des-tickets.mjs';
135
156
  import { etatDesPlaces } from './places-de-la-machine.mjs';
136
157
  import { duree as dureeDeLaFermeture } from './regles-des-places.mjs';
@@ -169,8 +190,8 @@ export const ROLE_DU_CIRCUIT = 'circuit';
169
190
  // The role of a register line that the workflow of the nights writes for a night it skips
170
191
  // (src/temporal/nuits/): no agent, no ticket, no turn; the board counts it nowhere.
171
192
  export const ROLE_DE_LA_NUIT = 'nuit';
172
- // The agent of a ticket led out of the circuit (scripts/direct.mjs), and the block of the board
173
- // that lists the sessions of that role.
193
+ // The agent who writes tests and code together, of a direct circuit or of the rescue command
194
+ // (scripts/direct.mjs), and the block of the board that lists those of the rescue command.
174
195
  const ROLE_DIRECT = 'direct';
175
196
  // A sub-agent's role from its meta file: the type it was spawned as; a named agent's `agentType`
176
197
  // is its name.
@@ -179,13 +200,12 @@ export const roleDuMeta = m =>
179
200
  // The states of a ticket, in the order the states' view lists them, with their meaning.
180
201
  export const ETATS = [
181
202
  { cle: 'enCours', nom: 'en cours', sens: 'un agent y travaille' },
182
- { cle: 'enAttente', nom: 'en attente', sens: 'ton go, prêt à partir' },
203
+ { cle: 'enAttente', nom: 'en file', sens: 'ton go, prêt à partir' },
183
204
  {
184
205
  cle: 'attendArchi',
185
206
  nom: 'attend archi',
186
207
  sens: 'ton go, sa section Architecture reste à écrire',
187
208
  },
188
- { cle: 'fileDirecte', nom: 'en direct', sens: 'mené hors du circuit, pas encore pris' },
189
209
  { cle: 'bloques', nom: 'bloqué', sens: 'ton go, il attend un autre ticket' },
190
210
  { cle: 'sansGo', nom: 'sans go', sens: 'validé, il attend ton go' },
191
211
  { cle: 'aValider', nom: 'à valider', sens: 'une trouvaille attend ton accord' },
@@ -204,7 +224,6 @@ export const TONS = Object.freeze({
204
224
  enCours: 'actif',
205
225
  enAttente: 'discret',
206
226
  attendArchi: 'discret',
207
- fileDirecte: 'discret',
208
227
  bloques: 'discret',
209
228
  sansGo: 'attention',
210
229
  aValider: 'attention',
@@ -213,6 +232,7 @@ export const TONS = Object.freeze({
213
232
  // A circuit, a pass, a wait.
214
233
  attendUnePlace: 'discret',
215
234
  reporteLimite: 'discret',
235
+ reporteQuestion: 'discret',
216
236
  attendUnePart: 'discret',
217
237
  attendLeDisque: 'discret',
218
238
  sansEtape: 'discret',
@@ -286,14 +306,17 @@ const etatNeuf = () => ({
286
306
  entre: null,
287
307
  ticket: null,
288
308
  role: null,
289
- cout: null,
290
309
  modeles: {},
291
310
  appel: null,
292
311
  reponses: [],
293
312
  tours: [],
294
313
  recu: false,
295
- vus: [],
314
+ sorties: [],
315
+ partagees: {},
316
+ sans: [],
296
317
  minutes: {},
318
+ couts: {},
319
+ derniereDepense: null,
297
320
  });
298
321
 
299
322
  // The union of intervals, ordered by date: no instant is in two of them.
@@ -327,9 +350,73 @@ function tourDeLUsage(u) {
327
350
  return Object.values(tour).every(n => Number.isFinite(n)) ? tour : null;
328
351
  }
329
352
 
330
- // Adds the lines of `texte` to the state `etat`, which it returns.
331
- function avancer(etat, texte) {
332
- const vus = new Set(etat.vus);
353
+ // A response is the same from one transcript to another by the pair of its message's id and its
354
+ // request's id, as ccusage names it; without one of them it is its transcript's own. A replay of a
355
+ // sidechain under another request id, which ccusage merges, stays apart: the key is that pair alone,
356
+ // and none was seen on a machine.
357
+ const cleEntreTranscriptions = e =>
358
+ e.message?.id && e.requestId ? `${e.message.id} ${e.requestId}` : null;
359
+
360
+ // What ranks a copy of a response against its other copies, each part the larger the better: off a
361
+ // sidechain, its tokens of the four kinds, its detail of the write of the cache (`cache_creation`).
362
+ // ccusage's last tie-breakers, the speed and the written cost, are not read: they tell apart no
363
+ // copies the cost of the frame, reckoned from the tokens, distinguishes.
364
+ const rangDeLaCopie = (e, u) => [
365
+ e.isSidechain === true ? 0 : 1,
366
+ (u.input_tokens ?? 0) +
367
+ (u.output_tokens ?? 0) +
368
+ (u.cache_creation_input_tokens ?? 0) +
369
+ (u.cache_read_input_tokens ?? 0),
370
+ u.cache_creation ? 1 : 0,
371
+ ];
372
+
373
+ // The order of two copies of a response (`{ rang, naissance, f }`: its rank, its file's date of
374
+ // creation and path), the retained one first. At equal usage the file created first wins, before
375
+ // the first path, unlike ccusage: the register only adds lines, so a copy created later must not
376
+ // take a response from a line already written.
377
+ const devant = (a, b) =>
378
+ b.rang[0] - a.rang[0] ||
379
+ b.rang[1] - a.rang[1] ||
380
+ b.rang[2] - a.rang[2] ||
381
+ a.naissance - b.naissance ||
382
+ (a.f < b.f ? -1 : a.f > b.f ? 1 : 0);
383
+
384
+ // The responses each transcript of `copies` (`{ f, naissance, partagees }`) holds and another one of
385
+ // them retains: by file, their keys, sorted. A file that loses none is absent.
386
+ function retenuesAilleurs(copies) {
387
+ const retenues = new Map();
388
+ for (const { f, naissance, partagees } of copies) {
389
+ for (const [cle, rang] of Object.entries(partagees)) {
390
+ const copie = { rang, naissance, f };
391
+ const avant = retenues.get(cle);
392
+ if (!avant || devant(copie, avant) < 0) {
393
+ retenues.set(cle, copie);
394
+ }
395
+ }
396
+ }
397
+ const out = new Map();
398
+ for (const { f, partagees } of copies) {
399
+ const perdues = Object.keys(partagees).filter(cle => retenues.get(cle).f !== f);
400
+ if (perdues.length > 0) {
401
+ out.set(f, perdues.sort());
402
+ }
403
+ }
404
+ return out;
405
+ }
406
+
407
+ // Adds the lines of `texte` to the state `etat`, which it returns. A response, known by the
408
+ // identifier of its message (else of its request), is written over one or several lines: as ccusage
409
+ // reads them, its output is the largest one read, whatever their order, and its input and cache
410
+ // count once, from its first line; `etat.sorties` keeps for each its output counted, its key of
411
+ // tariff, that of the whole request, and its key from one transcript to another. Its tokens, cache,
412
+ // cost and minutes leave out the responses `etat.sans` names, retained by another transcript; its
413
+ // time and turns count every line. `depense` receives what each line counts: its date (NaN without
414
+ // one), its key of tariff, its usage (on a following line, the extra output alone) and
415
+ // `{ jetons, cache, partagee }`, its tokens (the input, the output and the writes of the cache),
416
+ // its cache reads and its key from one transcript to another.
417
+ function avancer(etat, texte, depense) {
418
+ const sorties = new Map(etat.sorties);
419
+ const sans = new Set(etat.sans);
333
420
  const reponses = new Set(etat.reponses);
334
421
  for (const ligne of texte.split('\n')) {
335
422
  if (!ligne.trim()) {
@@ -344,9 +431,6 @@ function avancer(etat, texte) {
344
431
  if (e.type === 'agent-setting') {
345
432
  etat.role ??= e.agentSetting ?? null;
346
433
  }
347
- if (e.type === 'cost-state' && typeof e.totalCostUSD === 'number') {
348
- etat.cout = e.totalCostUSD;
349
- }
350
434
  const t = e.timestamp ? Date.parse(e.timestamp) : NaN;
351
435
  if (!Number.isNaN(t)) {
352
436
  etat.premier = etat.premier === null ? t : Math.min(etat.premier, t);
@@ -396,50 +480,75 @@ function avancer(etat, texte) {
396
480
  etat.premierTour = tourDeLUsage(e.message.usage);
397
481
  }
398
482
  const u = e.message?.usage;
483
+ if (!u) {
484
+ continue;
485
+ }
399
486
  const id = e.message?.id ?? e.requestId;
400
- if (!u || (id && vus.has(id))) {
487
+ const vue = id ? sorties.get(id) : undefined;
488
+ const sortie = u.output_tokens ?? 0;
489
+ if (vue && sortie <= vue.sortie) {
401
490
  continue;
402
491
  }
492
+ // The usage of the response: a write of the cache by its duration, one without them of five
493
+ // minutes, the default of the API.
494
+ const ecrit = vue ? 0 : (u.cache_creation_input_tokens ?? 0);
495
+ const uneHeure = vue ? 0 : (u.cache_creation?.ephemeral_1h_input_tokens ?? 0);
496
+ const usage = {
497
+ entree: vue ? 0 : (u.input_tokens ?? 0),
498
+ sortie: sortie - (vue?.sortie ?? 0),
499
+ lecture: vue ? 0 : (u.cache_read_input_tokens ?? 0),
500
+ ecriture5m: vue ? 0 : (u.cache_creation?.ephemeral_5m_input_tokens ?? ecrit - uneHeure),
501
+ ecriture1h: uneHeure,
502
+ };
503
+ const cle = vue?.cle ?? cleDuTarif(String(e.message?.model ?? ''), usage);
504
+ const partagee = vue ? vue.partagee : cleEntreTranscriptions(e);
403
505
  if (id) {
404
- vus.add(id);
506
+ sorties.set(id, { sortie, cle, partagee });
405
507
  }
406
- const n = (u.input_tokens ?? 0) + (u.output_tokens ?? 0) + (u.cache_creation_input_tokens ?? 0);
407
- etat.jetons += n;
408
- // The tokens by minute of their message, which share the supervisor's among the tickets he
409
- // leads directly (`jetonsDuSuperviseur`); a state kept before them starts its own.
410
- if (!Number.isNaN(t)) {
411
- etat.minutes ??= {};
412
- const minute = Math.floor(t / 60_000);
413
- etat.minutes[minute] = (etat.minutes[minute] ?? 0) + n;
414
- }
415
- etat.cache += u.cache_read_input_tokens ?? 0;
416
- // The usage of the message's model: a write of the cache by its duration, one without them
417
- // of five minutes, the default of the API.
418
- const ecrit = u.cache_creation_input_tokens ?? 0;
419
- const uneHeure = u.cache_creation?.ephemeral_1h_input_tokens ?? 0;
420
- const m = (etat.modeles[String(e.message?.model ?? '')] ??= {
508
+ if (partagee) {
509
+ // The line of the largest output ranks the copy.
510
+ etat.partagees[partagee] = rangDeLaCopie(e, u);
511
+ if (sans.has(partagee)) {
512
+ continue;
513
+ }
514
+ }
515
+ const jetons = usage.entree + usage.sortie + ecrit;
516
+ etat.jetons += jetons;
517
+ etat.cache += usage.lecture;
518
+ const m = (etat.modeles[cle] ??= {
421
519
  entree: 0,
422
520
  sortie: 0,
423
521
  lecture: 0,
424
522
  ecriture5m: 0,
425
523
  ecriture1h: 0,
426
524
  });
427
- m.entree += u.input_tokens ?? 0;
428
- m.sortie += u.output_tokens ?? 0;
429
- m.lecture += u.cache_read_input_tokens ?? 0;
430
- m.ecriture5m += u.cache_creation?.ephemeral_5m_input_tokens ?? ecrit - uneHeure;
431
- m.ecriture1h += uneHeure;
525
+ for (const [part, n] of Object.entries(usage)) {
526
+ m[part] += n;
527
+ }
528
+ depense?.(t, cle, usage, { jetons, cache: usage.lecture, partagee });
529
+ // The billed tokens (every kind) and their cost by minute of their line, of which the
530
+ // board counts in the day those since its marker; a null cost, unknown, stays so.
531
+ const factures = Object.values(usage).reduce((s, n) => s + n, 0);
532
+ if (!Number.isNaN(t) && factures > 0) {
533
+ const minute = Math.floor(t / 60_000);
534
+ etat.minutes[minute] = (etat.minutes[minute] ?? 0) + factures;
535
+ const cout = coutDe({ [cle]: usage });
536
+ const avant = etat.couts[minute] === undefined ? 0 : etat.couts[minute];
537
+ etat.couts[minute] = avant === null || cout === null ? null : avant + cout;
538
+ etat.derniereDepense = Math.max(etat.derniereDepense ?? t, t);
539
+ }
432
540
  }
433
- etat.vus = [...vus];
541
+ etat.sorties = [...sorties];
434
542
  etat.reponses = [...reponses];
435
543
  return etat;
436
544
  }
437
545
 
438
546
  // The measures of a state: the tokens, the turns and their working time (the union of the turns,
439
547
  // the waits left out), the start (the oldest date) and the end (the latest), the ticket, the role
440
- // (a session launched with `--agent`), the cost (the total a session writes), the usage by
441
- // model and the one of the first response of a model (`premierTour`, null without a readable
442
- // one). `entre` is the
548
+ // (a session launched with `--agent`), the usage by key of tariff (scripts/tarifs.mjs), the billed
549
+ // tokens and their cost by minute, the date of the latest response that spent tokens
550
+ // (`derniereDepense`, or null) and the usage of the first response of a model (`premierTour`, null
551
+ // without a readable one). `entre` is the
443
552
  // time of the latest incoming message, or null; `attend` tells whether the last tool call still
444
553
  // awaits its answer, the call and its answer paired by their identifier.
445
554
  const mesurer = etat => ({
@@ -453,9 +562,10 @@ const mesurer = etat => ({
453
562
  attend: etat.appel !== null && !etat.reponses.includes(etat.appel),
454
563
  ticket: etat.ticket || null,
455
564
  role: etat.role,
456
- cout: etat.cout,
457
565
  modeles: structuredClone(etat.modeles),
458
- minutes: { ...(etat.minutes ?? {}) },
566
+ minutes: { ...etat.minutes },
567
+ couts: { ...etat.couts },
568
+ derniereDepense: etat.derniereDepense,
459
569
  premierTour: etat.premierTour ? { ...etat.premierTour } : null,
460
570
  });
461
571
 
@@ -475,6 +585,59 @@ function parAgent(registre) {
475
585
  return [...derniere.values()];
476
586
  }
477
587
 
588
+ // The sum of the spendings `l` (each `{ jetons, cout }`, its billed tokens and its cost, null
589
+ // unknown): the tokens, the known cost, and whether the cost of one that spent tokens is missing
590
+ // (`partiel`).
591
+ const additionner = l =>
592
+ l.reduce(
593
+ (s, x) => ({
594
+ jetons: s.jetons + x.jetons,
595
+ cout: s.cout + (x.cout ?? 0),
596
+ partiel: s.partiel || Boolean(x.partiel) || (x.cout === null && x.jetons > 0),
597
+ }),
598
+ { jetons: 0, cout: 0, partiel: false }
599
+ );
600
+
601
+ // The billed tokens and the cost of the day (since the marker <jour>) and of the cumul, each agent
602
+ // counted once: by its latest line of the register (<registre>), or by the reading of its
603
+ // transcript (<depenses>, else its measure as it runs, <vivants>) when that holds a spending the
604
+ // register lacks: no line, an agent running again (<repris>), or a response after its latest
605
+ // line. The day takes of a read agent the responses dated since the marker; an agent without a
606
+ // transcript counts whole the day of its latest line.
607
+ function sommeDesDepenses({ registre, vivants, repris, depenses, maintenant, jour }) {
608
+ const lignesDe = new Map(registre.map(r => [r.agent, r]));
609
+ // An agent's measure as it runs counts without a line, or running again; a finished one with a
610
+ // line, only by the reading of its transcript.
611
+ const courants = vivants.filter(v => !lignesDe.has(v.agent) || repris.has(v.agent));
612
+ const lus = new Map([...courants, ...depenses].map(x => [x.agent, x]));
613
+ const depuis = Math.floor(jour / MINUTE);
614
+ const facture = x => ({ jetons: (x.jetons ?? 0) + (x.cache ?? 0), cout: x.cout ?? null });
615
+ const duCumul = [];
616
+ const duJour = [];
617
+ for (const agent of new Set([...lignesDe.keys(), ...lus.keys()])) {
618
+ const inscrit = lignesDe.get(agent);
619
+ const lu = lus.get(agent);
620
+ const parLui =
621
+ lu &&
622
+ (!inscrit ||
623
+ repris.has(agent) ||
624
+ (lu.derniereDepense ?? -Infinity) > Date.parse(inscrit.fin));
625
+ const entier = facture(parLui ? lu : inscrit);
626
+ duCumul.push(entier);
627
+ if (lu?.minutes) {
628
+ const minutes = Object.keys(lu.minutes).filter(m => Number(m) >= depuis);
629
+ const couts = minutes.map(m => lu.couts?.[m] ?? null);
630
+ duJour.push({
631
+ jetons: minutes.reduce((s, m) => s + lu.minutes[m], 0),
632
+ cout: couts.includes(null) ? null : couts.reduce((s, c) => s + c, 0),
633
+ });
634
+ } else if ((parLui ? maintenant : Date.parse(inscrit.fin)) >= jour) {
635
+ duJour.push(entier);
636
+ }
637
+ }
638
+ return { jour: additionner(duJour), cumul: additionner(duCumul) };
639
+ }
640
+
478
641
  // The intervals of <intervalles> (ordered, apart) out of those of <retires> (ordered, apart).
479
642
  function sauf(intervalles, retires) {
480
643
  const out = [];
@@ -543,8 +706,9 @@ function lireDepuis(f, decalage, taille) {
543
706
  const MORCEAU = 1_048_576;
544
707
 
545
708
  // Adds the lines of `f` between the bytes `decalage` and `taille` to the state `etat`, chunk by
546
- // chunk so the file is never held whole, and returns the bytes it consumed.
547
- function avancerDepuis(etat, f, decalage, taille) {
709
+ // chunk so the file is never held whole, and returns the bytes it consumed. `trier` keeps of each
710
+ // chunk the lines it reads.
711
+ function avancerDepuis(etat, f, decalage, taille, depense, trier) {
548
712
  let position = decalage;
549
713
  let pas = MORCEAU;
550
714
  while (position < taille) {
@@ -557,27 +721,119 @@ function avancerDepuis(etat, f, decalage, taille) {
557
721
  pas *= 2;
558
722
  continue;
559
723
  }
560
- avancer(etat, texte);
724
+ avancer(etat, trier ? trier(texte) : texte, depense);
561
725
  position += lus;
562
726
  pas = MORCEAU;
563
727
  }
564
728
  return position - decalage;
565
729
  }
566
730
 
567
- // The measures of the transcript file `f`, read in chunks. Throws when the file cannot be read.
568
- export function lireFichier(f) {
731
+ // The measures of the transcript file `f`, read in chunks, what each line counts handed to
732
+ // `depense` (`avancer`). Throws when the file cannot be read.
733
+ export function lireFichier(f, depense) {
734
+ return mesurer(etatDe(f, { depense }));
735
+ }
736
+
737
+ // The reading state of the whole file `f`.
738
+ function etatDe(f, { depense, trier } = {}) {
569
739
  const etat = etatNeuf();
570
- avancerDepuis(etat, f, 0, statSync(f).size);
571
- return mesurer(etat);
740
+ avancerDepuis(etat, f, 0, statSync(f).size, depense, trier);
741
+ return etat;
742
+ }
743
+
744
+ // The lines of `texte` that name one of the requests `requetes`.
745
+ function lignesDesRequetes(texte, requetes) {
746
+ const lignes = new Map();
747
+ for (const m of texte.matchAll(/"requestId"\s*:\s*"([^"]+)"/g)) {
748
+ if (requetes.has(m[1])) {
749
+ const debut = texte.lastIndexOf('\n', m.index) + 1;
750
+ const fin = texte.indexOf('\n', m.index);
751
+ lignes.set(debut, texte.slice(debut, fin < 0 ? texte.length : fin));
752
+ }
753
+ }
754
+ return [...lignes.values()].join('\n');
755
+ }
756
+
757
+ const cheminReel = f => {
758
+ try {
759
+ return realpathSync(f);
760
+ } catch {
761
+ return f;
762
+ }
763
+ };
764
+
765
+ // The readings of the transcripts `cibles` (files), whose responses another transcript retains,
766
+ // among them and the files `autres`, are marked: by file, `{ mesures, reponses }`, the measures of
767
+ // the whole transcript and each of its responses (`{ quand, cle, usage, jetons, cache, ailleurs }`,
768
+ // `ailleurs` when retained by another). Two paths of one file share its reading. Of the other files, only the lines that name a request of the targets are parsed, and a
769
+ // file last written before the targets began holds none of their copies. A file that cannot be read
770
+ // is left out. The register (scripts/registre.mjs) and its migration read by it.
771
+ export function lireSansLesRetenuesAilleurs(cibles, autres) {
772
+ const lues = new Map();
773
+ for (const f of cibles) {
774
+ if (lues.has(cheminReel(f))) {
775
+ continue;
776
+ }
777
+ try {
778
+ const reponses = [];
779
+ const etat = etatDe(f, {
780
+ depense: (quand, cle, usage, plus) => reponses.push({ quand, cle, usage, ...plus }),
781
+ });
782
+ lues.set(cheminReel(f), { f, naissance: statSync(f).birthtimeMs, etat, reponses });
783
+ } catch {
784
+ // A transcript it cannot read has no measure.
785
+ }
786
+ }
787
+ const requetes = new Set();
788
+ let depuis = Infinity;
789
+ for (const { etat } of lues.values()) {
790
+ for (const cle of Object.keys(etat.partagees)) {
791
+ requetes.add(cle.slice(cle.indexOf(' ') + 1));
792
+ depuis = Math.min(depuis, etat.premier ?? -Infinity);
793
+ }
794
+ }
795
+ const copies = [...lues.values()].map(({ f, naissance, etat }) => ({
796
+ f,
797
+ naissance,
798
+ partagees: etat.partagees,
799
+ }));
800
+ for (const f of requetes.size > 0 ? autres : []) {
801
+ try {
802
+ const { mtimeMs, birthtimeMs } = statSync(f);
803
+ if (mtimeMs < depuis || lues.has(cheminReel(f))) {
804
+ continue;
805
+ }
806
+ const { partagees } = etatDe(f, { trier: texte => lignesDesRequetes(texte, requetes) });
807
+ copies.push({ f, naissance: birthtimeMs, partagees });
808
+ } catch {
809
+ // A transcript it cannot read retains nothing.
810
+ }
811
+ }
812
+ const ailleurs = retenuesAilleurs(copies);
813
+ const lectures = new Map();
814
+ for (const [reel, { f, etat, reponses }] of lues) {
815
+ const sans = new Set(ailleurs.get(f));
816
+ lectures.set(reel, {
817
+ mesures: mesurer(etat),
818
+ reponses: reponses.map(r => ({ ...r, ailleurs: sans.has(r.partagee) })),
819
+ });
820
+ }
821
+ return new Map(
822
+ cibles.flatMap(f => {
823
+ const lecture = lectures.get(cheminReel(f));
824
+ return lecture ? [[f, lecture]] : [];
825
+ })
826
+ );
572
827
  }
573
828
 
574
829
  // A transcript read where it stopped: `cache` maps a file to its reading state and the byte it
575
- // reached. A transcript only grows; one that became shorter is read again from its start.
830
+ // reached. A transcript only grows; one that became shorter is read again from its start, like one
831
+ // whose kept state lacks the output counted of each response or the responses it shares.
576
832
  const lecteur = cache => f => {
577
833
  try {
578
834
  const taille = statSync(f).size;
579
835
  let { etat, decalage } = cache[f] ?? {};
580
- if (!etat || taille < decalage) {
836
+ if (!etat?.sorties || !etat.partagees || taille < decalage) {
581
837
  etat = etatNeuf();
582
838
  decalage = 0;
583
839
  }
@@ -626,34 +882,143 @@ export function tourne(f, maintenant, sousAgent) {
626
882
  return age < RECENT || (sousAgent && age <= SANS_AGENT && appelEnAttente(f));
627
883
  }
628
884
 
629
- // A sub-agent's meta file (next to its transcript `f`), or {}.
630
- const metaDe = f => {
631
- try {
632
- return JSON.parse(readFileSync(f.replace(/\.jsonl$/, '.meta.json'), 'utf8'));
633
- } catch {
634
- return {};
885
+ // The transcripts of the agents of the project at <racine>, in the home <home>: the sessions of
886
+ // its folder and of its agents' copies, and their sub-agents, each its file (`f`), its agent, its
887
+ // folder (`dossier`, `propre` for the project's own) and, for a sub-agent, its session's file
888
+ // (`session`). The board and the register (scripts/registre.mjs) read them.
889
+ export function transcriptionsDuProjet(racine, home) {
890
+ const projets = path.join(home, '.claude', 'projects');
891
+ if (!existsSync(projets)) {
892
+ return [];
635
893
  }
636
- };
894
+ const propre = enTirets(racine);
895
+ const copies = `${enTirets(path.join(racine, '.claude', 'worktrees'))}-`;
896
+ const out = [];
897
+ for (const d of readdirSync(projets)) {
898
+ if (d !== propre && !d.startsWith(copies)) {
899
+ continue;
900
+ }
901
+ const dossier = path.join(projets, d);
902
+ const commun = { dossier, propre: d === propre };
903
+ for (const s of readdirSync(dossier, { withFileTypes: true })) {
904
+ if (s.isDirectory()) {
905
+ for (const f of fichiers(path.join(dossier, s.name, 'subagents'), '.jsonl')) {
906
+ const agent = path.basename(f, '.jsonl').replace(/^agent-/, '');
907
+ const session = path.join(dossier, `${s.name}.jsonl`);
908
+ out.push({ ...commun, f, agent, session });
909
+ }
910
+ } else if (s.name.endsWith('.jsonl')) {
911
+ const f = path.join(dossier, s.name);
912
+ out.push({ ...commun, f, agent: path.basename(f, '.jsonl'), session: null });
913
+ }
914
+ }
915
+ }
916
+ return out;
917
+ }
637
918
 
638
- /**
639
- * The tokens of the supervisor's sessions of the repository at <racine> by minute (`{ <minute>:
640
- * <tokens> }`, the minute since the epoch): its main transcripts touched since the day's marker
641
- * <jour>, read through <cache>; the sub-agents' are counted by their tickets.
642
- */
643
- export function jetonsDuSuperviseur({ racine, home, jour, cache = {} }) {
919
+ // What a transcript's measures `lu` say of its spending.
920
+ const depenseDe = ({ jetons, cache, modeles, minutes, couts, derniereDepense }) => ({
921
+ jetons,
922
+ cache,
923
+ cout: coutDe(modeles),
924
+ minutes,
925
+ couts,
926
+ derniereDepense,
927
+ });
928
+
929
+ // The count of the responses (`avancer`) under which the cache keeps the spending of a silent
930
+ // transcript and the responses it shares: one kept under another is read again.
931
+ const COMPTE = 'plus grande sortie, une fois par projet';
932
+
933
+ // The spendings `a` and `b` of two transcripts of one agent, added: no response counts in both.
934
+ function ensembleDesDepenses(a, b) {
935
+ const minutes = { ...a.minutes };
936
+ const couts = { ...a.couts };
937
+ for (const [m, n] of Object.entries(b.minutes)) {
938
+ couts[m] =
939
+ minutes[m] === undefined
940
+ ? b.couts[m]
941
+ : couts[m] === null || b.couts[m] === null
942
+ ? null
943
+ : couts[m] + b.couts[m];
944
+ minutes[m] = (minutes[m] ?? 0) + n;
945
+ }
946
+ const dates = [a.derniereDepense, b.derniereDepense].filter(d => d !== null);
947
+ return {
948
+ jetons: a.jetons + b.jetons,
949
+ cache: a.cache + b.cache,
950
+ cout: a.cout === null || b.cout === null ? null : a.cout + b.cout,
951
+ minutes,
952
+ couts,
953
+ derniereDepense: dates.length > 0 ? Math.max(...dates) : null,
954
+ };
955
+ }
956
+
957
+ // The spending of each agent of the project, read from its transcripts, by `cache`: a transcript
958
+ // that moved in the last 30 minutes is read where it stopped (`lecteur`), an older one keeps its
959
+ // spending and the responses it shares, read again whole should it grow. A response present in
960
+ // several transcripts counts once, in the copy retained among those present (`retenuesAilleurs`):
961
+ // a transcript whose responses retained elsewhere changed is read again whole, without them. The
962
+ // transcripts of one agent add up.
963
+ export function lireLesDepenses({ racine, home, maintenant, cache = {} }) {
644
964
  const lire = lecteur(cache);
645
- const out = {};
646
- for (const f of fichiers(path.join(home, '.claude', 'projects', enTirets(racine)), '.jsonl')) {
647
- if (statSync(f).mtimeMs < jour) {
965
+ const lues = [];
966
+ for (const { f, agent } of transcriptionsDuProjet(racine, home)) {
967
+ let stat;
968
+ try {
969
+ stat = statSync(f);
970
+ } catch {
648
971
  continue;
649
972
  }
650
- for (const [minute, n] of Object.entries(lire(f)?.minutes ?? {})) {
651
- out[minute] = (out[minute] ?? 0) + n;
973
+ const gardee = cache[f]?.compte === COMPTE && cache[f].taille === stat.size ? cache[f] : null;
974
+ let { depense, partagees, sans } = gardee ?? {};
975
+ if (!gardee) {
976
+ const lu = lire(f);
977
+ if (!lu) {
978
+ continue;
979
+ }
980
+ depense = depenseDe(lu);
981
+ ({ partagees, sans } = cache[f].etat);
982
+ }
983
+ const muette = Boolean(gardee) || maintenant - stat.mtimeMs > SANS_AGENT;
984
+ const naissance = stat.birthtimeMs;
985
+ lues.push({ f, agent, naissance, taille: stat.size, muette, depense, partagees, sans });
986
+ }
987
+ const ailleurs = retenuesAilleurs(lues);
988
+ const depenses = new Map();
989
+ for (const x of lues) {
990
+ const sans = ailleurs.get(x.f) ?? [];
991
+ let { depense, partagees } = x;
992
+ if (sans.join('\n') !== x.sans.join('\n')) {
993
+ cache[x.f] = { etat: { ...etatNeuf(), sans }, decalage: 0 };
994
+ const lu = lire(x.f);
995
+ if (!lu) {
996
+ continue;
997
+ }
998
+ depense = depenseDe(lu);
999
+ ({ partagees } = cache[x.f].etat);
1000
+ }
1001
+ if (x.muette) {
1002
+ cache[x.f] = { depense, taille: x.taille, partagees, sans, compte: COMPTE };
652
1003
  }
1004
+ const avant = depenses.get(x.agent);
1005
+ depenses.set(x.agent, {
1006
+ agent: x.agent,
1007
+ ...(avant ? ensembleDesDepenses(avant, depense) : depense),
1008
+ });
653
1009
  }
654
- return out;
1010
+ return [...depenses.values()];
655
1011
  }
656
1012
 
1013
+ // A sub-agent's meta file (next to its transcript `f`), or {}.
1014
+ const metaDe = f => {
1015
+ try {
1016
+ return JSON.parse(readFileSync(f.replace(/\.jsonl$/, '.meta.json'), 'utf8'));
1017
+ } catch {
1018
+ return {};
1019
+ }
1020
+ };
1021
+
657
1022
  // The agents running now, each with its measures so far. `ps` is the process list
658
1023
  // (`pid etimes args` per line); `cache` keeps the readings of unchanged transcripts. A role agent
659
1024
  // launched in a shell shows by the envelope lancer.sh starts for it,
@@ -691,7 +1056,7 @@ export function lireVivant({ racine, home, prefix, maintenant, ps, cache = {} })
691
1056
  silence: dernier ? maintenant - dernier.mtime : null,
692
1057
  entre: lu?.entre ?? null,
693
1058
  jetons: lu?.jetons ?? 0,
694
- minutes: lu?.minutes,
1059
+ ...(lu ? depenseDe(lu) : {}),
695
1060
  travail: lu?.travail ?? 0,
696
1061
  tours: lu?.tours ?? [],
697
1062
  });
@@ -707,8 +1072,7 @@ export function lireVivant({ racine, home, prefix, maintenant, ps, cache = {} })
707
1072
  ligne: false,
708
1073
  depuis: lu.premier ?? maintenant,
709
1074
  entre: lu.entre,
710
- jetons: lu.jetons,
711
- minutes: lu.minutes,
1075
+ ...depenseDe(lu),
712
1076
  travail: lu.travail,
713
1077
  tours: lu.tours,
714
1078
  });
@@ -732,8 +1096,7 @@ export function lireVivant({ racine, home, prefix, maintenant, ps, cache = {} })
732
1096
  ligne: false,
733
1097
  depuis: lu.premier ?? maintenant,
734
1098
  entre: lu.entre,
735
- jetons: lu.jetons,
736
- minutes: lu.minutes,
1099
+ ...depenseDe(lu),
737
1100
  travail: lu.travail,
738
1101
  tours: lu.tours,
739
1102
  });
@@ -765,6 +1128,9 @@ export const attendLeSuperviseur = c =>
765
1128
  * @returns {string}
766
1129
  */
767
1130
  export const cleDe = c => [c.ticket, c.run, c.numero, c.arret ?? 'interrompu'].join(':');
1131
+ // The key of the stop of a circuit as the board holds it (`cle`, kept since its `numero` there is
1132
+ // its ticket's number), else `cleDe`.
1133
+ const cleDuStop = c => c.cle ?? cleDe(c);
768
1134
 
769
1135
  /** The file of the stops gone up to the supervisor of the repository at <racine>. */
770
1136
  export const remonteesDe = racine =>
@@ -854,7 +1220,11 @@ const goDe = octets => chiffre(Math.round((octets / 1024 ** 3) * 10) / 10);
854
1220
  // The limit of the part of a pass, after its reservation: « , limite 7,5 Go », « , sans limite »
855
1221
  // for a session; nothing for a part that names none.
856
1222
  const limiteDite = p =>
857
- p.limite === undefined ? '' : p.limite === null ? ', sans limite' : `, limite ${goDe(p.limite)} Go`;
1223
+ p.limite === undefined
1224
+ ? ''
1225
+ : p.limite === null
1226
+ ? ', sans limite'
1227
+ : `, limite ${goDe(p.limite)} Go`;
858
1228
  // What a pass that waits asks of the memory, its reservation and its limit.
859
1229
  const demandeDite = p =>
860
1230
  p.limite === undefined ? '' : ` · ${goDe(p.memoire ?? 0)} Go réservés${limiteDite(p)}`;
@@ -869,7 +1239,8 @@ const demandeDite = p =>
869
1239
  * « ⏳ <sorte> · <projet> · <qui> · attend <raison> · 2 Go réservés, limite 10 Go », what it waits
870
1240
  * for (cores, memory, load) with its figures, then what it asks of the memory.
871
1241
  * <masquer> leaves out the lines of the passes it names (those of a ticket, shown on its line or
872
- * not shown at all: the count keeps them), <court> gives the ticket as the board names it.
1242
+ * not shown at all, and those without a ticket of another project: the count keeps them),
1243
+ * <court> gives the ticket as the board names it.
873
1244
  * @param {{ budget: { coeurs: number, memoire: number }, prises: DUnePart[], attentes: DUnePart[],
874
1245
  * masquer?: (p: DUnePart) => boolean, court?: (ticket: string) => string }} o
875
1246
  * @returns {string[]}
@@ -913,7 +1284,8 @@ export function lignesDesParts({
913
1284
  * the alert says; `fauteTickets`, the fault of the reading of the tickets, said in an alert, and
914
1285
  * `ticketsLusA`, the time of the last one that succeeded, whose tickets `tous` holds;
915
1286
  * `echecPrefixe`, the cause of a ticket prefix that did not read, named in an alert; `voies`, the
916
- * way of each circuit done (`voiesDesCircuits`), whose sign FAITS AUJOURD'HUI shows.
1287
+ * way of each circuit done (`voiesDesCircuits`), whose sign FAITS AUJOURD'HUI shows; `bilans`,
1288
+ * the kept bilan of each ticket (`bilansGardes`), whose status says whether the engine led it.
917
1289
  * @param {{ tous: any[], prefix?: string, racine?: string | null, registre: any[], vivants: any[],
918
1290
  * circuits?: any[],
919
1291
  * circuitsLusA?: number | null, fauteTickets?: string | null, ticketsLusA?: number | null,
@@ -925,7 +1297,8 @@ export function lignesDesParts({
925
1297
  * depuis: number, disque?: string | null }[],
926
1298
  * fermeture?: { auteur: 'superviseur', depuis: number, phase: string } | null } | null,
927
1299
  * nuit?: { racine: string, depuis: number | null } | null, muet?: boolean, faute?: string | null,
928
- * echecPrefixe?: string | null, voies?: Record<string, 'complet' | 'court'> }} lu
1300
+ * echecPrefixe?: string | null, voies?: Record<string, 'complet' | 'court'>,
1301
+ * bilans?: Record<string, { statut?: string }> }} lu
929
1302
  */
930
1303
  export function assembler({
931
1304
  tous,
@@ -933,6 +1306,7 @@ export function assembler({
933
1306
  racine = null,
934
1307
  registre: lignesDuRegistre,
935
1308
  vivants,
1309
+ depenses = [],
936
1310
  circuits = [],
937
1311
  maintenant,
938
1312
  jour,
@@ -949,7 +1323,7 @@ export function assembler({
949
1323
  echecPrefixe = null,
950
1324
  remontees = [],
951
1325
  voies = {},
952
- superviseur = {},
1326
+ bilans = {},
953
1327
  externes,
954
1328
  limite = null,
955
1329
  lotSurMain = () => false,
@@ -1013,7 +1387,12 @@ export function assembler({
1013
1387
  !c.integre &&
1014
1388
  (parId.get(c.ticket).status !== 'closed' || c.vivant || attendLeSuperviseur(c))
1015
1389
  )
1016
- .map(c => [c.ticket, c])
1390
+ // `reporteA`: the hour its ticket is deferred to, still to come; none for a ticket closed.
1391
+ .map(c => {
1392
+ const t = parId.get(c.ticket);
1393
+ const reporteA = t.status === 'closed' ? null : reporteJusqua(t, maintenant);
1394
+ return [c.ticket, { ...c, reporteA }];
1395
+ })
1017
1396
  );
1018
1397
  const actifs = new Set([
1019
1398
  ...enCoursMesures.map(v => v.ticket).filter(Boolean),
@@ -1028,8 +1407,8 @@ export function assembler({
1028
1407
  const pret = new Set(prets.map(t => t.id));
1029
1408
  const avalider = new Set(aValider.map(t => t.id));
1030
1409
  const bloquePar = t => [...blocages(t).map(d => numero(d.depends_on_id)), ...attentesExternes(t)];
1031
- // The owner's go: the label `circuit`, set on his word.
1032
- const circuit = t => (t.labels ?? []).includes('circuit');
1410
+ // The owner's go: the label `circuit`, set on his word, or `direct`.
1411
+ const circuit = t => (t.labels ?? []).some(l => l === 'circuit' || l === 'direct');
1033
1412
  // A ticket's state: in progress (claimed, or its circuit launched and not integrated, its
1034
1413
  // question deferred or its ticket closed before its integration included: AGENTS shows it, and it
1035
1414
  // is done only once integrated), done, deferred,
@@ -1048,10 +1427,6 @@ export function assembler({
1048
1427
  if (avalider.has(t.id)) {
1049
1428
  return 'aValider';
1050
1429
  }
1051
- // A ticket led out of the circuit, not yet claimed: the direct queue.
1052
- if ((t.labels ?? []).includes('direct')) {
1053
- return 'fileDirecte';
1054
- }
1055
1430
  if (!circuit(t)) {
1056
1431
  return 'sansGo';
1057
1432
  }
@@ -1066,7 +1441,6 @@ export function assembler({
1066
1441
  enCours: 0,
1067
1442
  enAttente: 0,
1068
1443
  attendArchi: 0,
1069
- fileDirecte: 0,
1070
1444
  bloques: 0,
1071
1445
  fermes: 0,
1072
1446
  sansGo: 0,
@@ -1138,24 +1512,22 @@ export function assembler({
1138
1512
  travail: l.reduce((s, x) => s + (x.travail ?? 0), 0),
1139
1513
  jetons: l.reduce((s, x) => s + (x.jetons ?? 0), 0),
1140
1514
  });
1141
- // A measure with its turns counts in the day the parts since the day's marker of their union,
1142
- // and, with its tokens by minute, those spent since it: a session opened days ago counts in the
1143
- // day what it did today, time and tokens alike. A register line written without them counts
1144
- // whole in the day it ended.
1515
+ // A measure with its turns counts in the day the parts since the day's marker of their union:
1516
+ // a session opened days ago counts in the day what it did today. A register line written without
1517
+ // them counts whole in the day it ended.
1145
1518
  const partDuJour = tours =>
1146
1519
  reunir(tours).reduce((s, [debut, fin]) => s + Math.max(0, fin - Math.max(debut, jour)), 0);
1147
- const jetonsDuJour = minutes =>
1148
- Object.entries(minutes).reduce(
1149
- (s, [minute, n]) => s + (Number(minute) >= Math.floor(jour / MINUTE) ? n : 0),
1150
- 0
1151
- );
1152
1520
  const duJour = mesures
1153
1521
  .filter(m => m.quand >= jour)
1154
- .map(m => ({
1155
- ...m,
1156
- ...(m.tours ? { travail: partDuJour(m.tours) } : {}),
1157
- ...(m.minutes ? { jetons: jetonsDuJour(m.minutes) } : {}),
1158
- }));
1522
+ .map(m => ({ ...m, ...(m.tours ? { travail: partDuJour(m.tours) } : {}) }));
1523
+ const depensesDuProjet = sommeDesDepenses({
1524
+ registre,
1525
+ vivants,
1526
+ repris,
1527
+ depenses,
1528
+ maintenant,
1529
+ jour,
1530
+ });
1159
1531
  // The discoveries (label `decouverte`): each counts in one case, the first that
1160
1532
  // applies. « rejetés » and « validés » count only since the day's marker <jour>; « new » and
1161
1533
  // « →check », states that await the owner, do not filter by it.
@@ -1194,8 +1566,14 @@ export function assembler({
1194
1566
  const sansLeTempsDuSuperviseur = l => l.map(m => (m.ticket || m.role ? m : { ...m, travail: 0 }));
1195
1567
  const global = {
1196
1568
  compteurs,
1197
- jour: somme(sansLeTempsDuSuperviseur(duJour)),
1198
- cumul: somme(sansLeTempsDuSuperviseur(mesures)),
1569
+ jour: {
1570
+ travail: somme(sansLeTempsDuSuperviseur(duJour)).travail,
1571
+ ...depensesDuProjet.jour,
1572
+ },
1573
+ cumul: {
1574
+ travail: somme(sansLeTempsDuSuperviseur(mesures)).travail,
1575
+ ...depensesDuProjet.cumul,
1576
+ },
1199
1577
  decouvertes,
1200
1578
  };
1201
1579
 
@@ -1222,6 +1600,7 @@ export function assembler({
1222
1600
  ...titre(t),
1223
1601
  mere: !travail(t),
1224
1602
  etat: e,
1603
+ voie: aLabel(t, 'direct') ? 'direct' : 'complet',
1225
1604
  faits,
1226
1605
  total: liste.length,
1227
1606
  bloquePar: bloquePar(t),
@@ -1267,14 +1646,21 @@ export function assembler({
1267
1646
  const e = etapeDuRole(role);
1268
1647
  return e ? blocs.find(b => b.numero === e.numero) : undefined;
1269
1648
  };
1270
- // The block « Direct » heads them: the agents of the tickets led out of the circuit
1271
- // (`npx grillhouse direct`), at no step.
1649
+ // A circuit open: it runs, or waits for an answer; never ended without its issue.
1650
+ const ouvertSur = c => Boolean(c) && !c.sansIssue && (c.vivant || attendLeSuperviseur(c));
1651
+ // The block « Direct » heads them: the agents of the rescue command (`npx grillhouse direct`),
1652
+ // on a ticket with no open circuit, at no step.
1272
1653
  const directs = [];
1273
- // One line per ticket: a ticket on which a role agent runs stands at its step, the agent of a
1274
- // direct under the block « Direct ».
1654
+ // One line per ticket: a ticket on which a role agent runs stands at its step, the agent
1655
+ // `direct` of an open circuit at the step of the code, else under the block « Direct ».
1275
1656
  for (const v of enCoursMesures) {
1276
1657
  const t = v.ticket && parId.get(v.ticket);
1277
- const cible = v.role === ROLE_DIRECT ? { enCours: directs } : bloc(v.role);
1658
+ const cible =
1659
+ v.role !== ROLE_DIRECT
1660
+ ? bloc(v.role)
1661
+ : ouvertSur(parCircuit.get(v.ticket))
1662
+ ? bloc('developpeur')
1663
+ : { enCours: directs };
1278
1664
  if (!t || !cible) {
1279
1665
  continue;
1280
1666
  }
@@ -1290,37 +1676,26 @@ export function assembler({
1290
1676
  });
1291
1677
  }
1292
1678
  const debutJour = jour;
1293
- // The way of a ticket done: `direct` when labelled so; else the way its kept
1294
- // results give (`voies`, `voiesDesCircuits`: `court` for the short circuit, else `complet`); else
1679
+ // The way of a ticket done: the one of its circuit's integrated view; a circuit that runs or
1680
+ // waits keeps its ticket out of the facts, and one stopped gives no way, the lot having entered
1681
+ // another way. Without such a view: `direct` when labelled so; else the way its kept results
1682
+ // give (`voies`, `voiesDesCircuits`: `court` for the short circuit, else `complet`); else
1295
1683
  // `complet` when a circuit led a step of it (the register) or is read for it; else `direct`,
1296
1684
  // closed with no circuit.
1685
+ const integres = new Map(circuits.filter(c => c.integre).map(c => [c.ticket, c.circuit]));
1297
1686
  const parUnCircuit = new Set([...etapesFinies.map(r => r.ticket), ...parCircuit.keys()]);
1298
1687
  const voieDe = t =>
1299
- (t.labels ?? []).includes('direct')
1688
+ VOIE_DE_LA_VUE[integres.get(t.id)] ??
1689
+ ((t.labels ?? []).includes('direct')
1300
1690
  ? 'direct'
1301
- : (voies[t.id] ?? (parUnCircuit.has(t.id) ? 'complet' : 'direct'));
1691
+ : (voies[t.id] ?? (parUnCircuit.has(t.id) ? 'complet' : 'direct')));
1692
+ // The engine led a ticket's lot when its circuit's view is integrated, or its kept bilan says so.
1693
+ const meneParLeMoteur = t => integres.has(t.id) || bilans[t.id]?.statut === 'intégré';
1302
1694
  // A ticket closed with no delivery: a duplicate, superseded (`bd duplicate`, `bd supersede`), or
1303
1695
  // labelled `sans-suite`.
1304
1696
  const sansLivraison = t =>
1305
1697
  (t.dependencies ?? []).some(d => d.type === 'duplicates' || d.type === 'supersedes') ||
1306
1698
  aLabel(t, 'sans-suite');
1307
- // The supervisor leads a direct ticket from its claim to its close (now while it runs): each
1308
- // minute of his tokens is shared among the direct tickets he holds at that minute.
1309
- const tenusEnDirect = tous
1310
- .filter(t => voieDe(t) === 'direct' && Number.isFinite(Date.parse(t.started_at ?? '')))
1311
- .map(t => ({
1312
- id: t.id,
1313
- debut: Math.floor(Date.parse(t.started_at) / 60_000),
1314
- fin: Math.floor((t.closed_at ? Date.parse(t.closed_at) : maintenant) / 60_000),
1315
- }));
1316
- const partDuSuperviseur = new Map();
1317
- for (const [cle, n] of Object.entries(superviseur)) {
1318
- const minute = Number(cle);
1319
- const tenus = tenusEnDirect.filter(x => x.debut <= minute && minute <= x.fin);
1320
- for (const x of tenus) {
1321
- partDuSuperviseur.set(x.id, (partDuSuperviseur.get(x.id) ?? 0) + n / tenus.length);
1322
- }
1323
- }
1324
1699
  // A finding is done only once led to its end: validated and carried by the circuit, or led
1325
1700
  // direct; a finding just recorded, or rejected at its sorting, is no work done.
1326
1701
  const menee = t => aLabel(t, 'circuit') || aLabel(t, 'direct');
@@ -1339,17 +1714,15 @@ export function assembler({
1339
1714
  .map(t => {
1340
1715
  const m = mesure(new Set([t.id]));
1341
1716
  const voie = voieDe(t);
1342
- // A circuit's time is its agents' and steps' working time; a direct ticket's runs from its
1343
- // claim to its close, null without a claim.
1717
+ // A circuit's time is its agents' and steps' working time; the time of a direct ticket no
1718
+ // circuit led runs from its claim to its close, null without a claim.
1344
1719
  const pris = Date.parse(t.started_at ?? '');
1345
1720
  const dure =
1346
- voie !== 'direct'
1721
+ voie !== 'direct' || meneParLeMoteur(t)
1347
1722
  ? m.travail
1348
1723
  : Number.isFinite(pris)
1349
1724
  ? Date.parse(t.closed_at) - pris
1350
1725
  : null;
1351
- const jetons =
1352
- m.jetons + Math.round(voie === 'direct' ? (partDuSuperviseur.get(t.id) ?? 0) : 0);
1353
1726
  return {
1354
1727
  id: t.id,
1355
1728
  numero: numero(t.id),
@@ -1357,7 +1730,6 @@ export function assembler({
1357
1730
  voie,
1358
1731
  duree: dure,
1359
1732
  ...m,
1360
- jetons,
1361
1733
  };
1362
1734
  });
1363
1735
 
@@ -1425,7 +1797,9 @@ export function assembler({
1425
1797
  remontees.filter(r => !estLue(r) && !Number.isFinite(r.chez)).map(r => [r.cle, r.depuis])
1426
1798
  );
1427
1799
  const enAttenteDuSuperviseur = [...parCircuit.values()]
1428
- .filter(attendLeSuperviseur)
1800
+ // A deferred question asks nothing of the supervisor until its hour, whoever must answer it:
1801
+ // no alert. The owner's keeps its line ❓ and its count (`auResponsable`).
1802
+ .filter(c => attendLeSuperviseur(c) && !c.reporteA)
1429
1803
  .sort((a, b) => ordre({ id: a.ticket }, { id: b.ticket }));
1430
1804
  for (const c of enAttenteDuSuperviseur) {
1431
1805
  const depuis = depuisDe.get(cleDe(c));
@@ -1500,9 +1874,9 @@ export function assembler({
1500
1874
  // The tickets worked out of a circuit: claimed (`in_progress`), no circuit on the server that
1501
1875
  // holds them, a mother of theirs or a ticket under them (a circuit holds its ticket's mothers and
1502
1876
  // children): one that runs or waits for an answer (`attendLeSuperviseur`), never one the
1503
- // supervisor stopped; or labelled `direct` and claimed (led out of the circuit); and no role
1504
- // agent shown at a step. None while the circuits do not read (a silent server, a fault) and no
1505
- // earlier reading is kept, when no ticket can be told out of a circuit.
1877
+ // supervisor stopped; or labelled `direct` and claimed, with no such circuit of their own; and
1878
+ // no role agent shown at a step. None while the circuits do not read (a silent server, a fault)
1879
+ // and no earlier reading is kept, when no ticket can be told out of a circuit.
1506
1880
  const aUneEtape = new Set([...blocs.flatMap(b => b.enCours), ...directs].map(x => x.id));
1507
1881
  const tenus = new Set(
1508
1882
  [...parCircuit.values()].filter(c => c.vivant || attendLeSuperviseur(c)).map(c => c.ticket)
@@ -1525,7 +1899,7 @@ export function assembler({
1525
1899
  travail(t) &&
1526
1900
  !aUneEtape.has(t.id) &&
1527
1901
  t.status === 'in_progress' &&
1528
- (!dansUnCircuit(t) || (t.labels ?? []).includes('direct'))
1902
+ (!dansUnCircuit(t) || (aLabel(t, 'direct') && !tenus.has(t.id)))
1529
1903
  )
1530
1904
  .sort(ordre)
1531
1905
  .map(t => ({
@@ -1533,14 +1907,21 @@ export function assembler({
1533
1907
  numero: numero(t.id),
1534
1908
  sujet: titre(t).sujet,
1535
1909
  }));
1536
- // The circuits, in the tickets' order; a ticket worked in direct has its line alone.
1910
+ // The circuits, in the tickets' order; a ticket worked in direct has its line alone, as has one
1911
+ // labelled `direct` whose circuit is not open while a role agent works on it.
1537
1912
  const enDirect = new Set(horsCircuit.map(x => x.id));
1538
1913
  const lesCircuits = [...parCircuit.values()]
1539
- .filter(c => !enDirect.has(c.ticket))
1914
+ .filter(
1915
+ c =>
1916
+ !enDirect.has(c.ticket) &&
1917
+ !(aLabel(parId.get(c.ticket), 'direct') && !ouvertSur(c) && aUneEtape.has(c.ticket))
1918
+ )
1540
1919
  .sort((a, b) => ordre({ id: a.ticket }, { id: b.ticket }))
1541
1920
  .map(c => ({
1542
1921
  ...c,
1543
1922
  id: c.ticket,
1923
+ // The key of its stop, read before `numero` turns into its ticket's number.
1924
+ cle: cleDe(c),
1544
1925
  // Its way so far, read from its kept results (`voiesDesCircuits`).
1545
1926
  court: voies[c.ticket] === 'court',
1546
1927
  numero: numero(c.ticket),
@@ -1565,10 +1946,11 @@ export function assembler({
1565
1946
  });
1566
1947
  // The limit of circuits of the project (`limite`, its `grillhouse.circuits`): when it is held,
1567
1948
  // the circuits that hold it waiting for the supervisor (a question to no one, or to the
1568
- // supervisor; the owner's releases the place, as does a ticket deferred), by id.
1949
+ // supervisor; the owner's releases the place, as does a ticket deferred,
1950
+ // `leReportRendLaPlace`), by id.
1569
1951
  const tenantsDeLaLimite = [...parCircuit.values()].filter(
1570
1952
  c =>
1571
- parId.get(c.ticket).status !== 'deferred' &&
1953
+ !leReportRendLaPlace(parId.get(c.ticket), maintenant) &&
1572
1954
  (c.vivant || (attendLeSuperviseur(c) && (c.qui ?? SUPERVISEUR) !== RESPONSABLE))
1573
1955
  );
1574
1956
  const tenueLaLimite = limite !== null && tenantsDeLaLimite.length >= limite;
@@ -1620,6 +2002,12 @@ export const k = n =>
1620
2002
  : n >= 1e3
1621
2003
  ? `${Math.round(n / 1e3)} k`
1622
2004
  : `${n}`;
2005
+ // A cost in whole dollars, its thousands apart; a partial one, « ≥ » before the known cost.
2006
+ const dollars = (cout, partiel) => {
2007
+ // A known cost marked partial is a floor: never rounded up.
2008
+ const entiers = partiel ? Math.floor(cout + 1e-6) : Math.round(cout);
2009
+ return `${partiel ? '≥ ' : ''}${String(entiers).replace(/\B(?=(\d{3})+$)/g, ' ')} $`;
2010
+ };
1623
2011
  export const duree = ms => {
1624
2012
  const min = Math.round(ms / MINUTE);
1625
2013
  return min < 60 ? `${min} min` : `${Math.floor(min / 60)}h${String(min % 60).padStart(2, '0')}`;
@@ -1675,6 +2063,8 @@ function temoinDe(c, maintenant) {
1675
2063
  // The sign of a ticket done by its way: a full circuit, a short one (its gesture
1676
2064
  // played by a command, 1.1, or written by hand), a ticket led directly.
1677
2065
  export const SIGNE_DE_LA_VOIE = Object.freeze({ complet: '●', court: '○', direct: '✎' });
2066
+ // The way each circuit of a view (`circuit`) gives its ticket.
2067
+ const VOIE_DE_LA_VUE = Object.freeze({ long: 'complet', court: 'court', direct: 'direct' });
1678
2068
 
1679
2069
  /**
1680
2070
  * The way of the circuit each ticket of <tickets> went, read from its kept results in the main tree
@@ -1770,25 +2160,32 @@ const courtDuTicket = id => id.slice(id.lastIndexOf('-') + 1);
1770
2160
 
1771
2161
  // The sign of a ticket's line in AGENTS, by the tone of its state: ▶ what runs, ⛔ what asks for a
1772
2162
  // correction, ⏸ a wait, for the machine (grey) or for someone (yellow).
1773
- // A circuit that runs bears the full triangle, the hollow one in a short circuit (<court>), as
1774
- // its line of FAITS AUJOURD'HUI bears the full or the hollow round (`SIGNE_DE_LA_VOIE`).
1775
- const signeDuTon = (ton, court = false) =>
1776
- ton === TONS.enCours ? (court ? '▷' : '▶') : ton === 'alerte' ? '⛔' : '⏸';
2163
+ // A circuit <c> that runs bears the sign of the direct way when its view says it
2164
+ // (`SIGNE_DE_LA_VOIE`), else the full triangle, the hollow one in a short circuit (`court`), as
2165
+ // its line of FAITS AUJOURD'HUI bears the full or the hollow round.
2166
+ const signeEnCours = c => (c.circuit === 'direct' ? SIGNE_DE_LA_VOIE.direct : c.court ? '▷' : '▶');
2167
+ const signeDuTon = (ton, c) =>
2168
+ ton === TONS.enCours ? signeEnCours(c) : ton === 'alerte' ? '⛔' : '⏸';
1777
2169
  // The step of the circuit <c>, by its state or its stop.
1778
2170
  const etapeDuCircuitLu = c => etapeDuCircuit({ ...c, raison: c.arret });
1779
2171
  // A circuit that waits for the supervisor (`attendLeSuperviseur`, the one rule): who must answer
1780
2172
  // its question, the supervisor when its stop names no one.
1781
2173
  // A question the supervisor carried to the owner (`chez` in the file of the stops gone up) is the
1782
2174
  // owner's.
1783
- const enQuestion = (c, chez = new Set()) =>
1784
- attendLeSuperviseur(c) ? (chez.has(cleDe(c)) ? RESPONSABLE : (c.qui ?? SUPERVISEUR)) : null;
2175
+ const destinataire = (c, chez) =>
2176
+ attendLeSuperviseur(c) ? (chez.has(cleDuStop(c)) ? RESPONSABLE : (c.qui ?? SUPERVISEUR)) : null;
2177
+ // Whether the wait of <c> on the supervisor (its question, or its end without its issue) is deferred
2178
+ // to a later hour (`reporteA`): the board shows it paused until then. The owner's never is.
2179
+ const misEnPause = (c, chez) => Boolean(c.reporteA) && destinataire(c, chez) === SUPERVISEUR;
2180
+ // Who the board shows <c> on a question to: no one while paused.
2181
+ const enQuestion = (c, chez = new Set()) => (misEnPause(c, chez) ? null : destinataire(c, chez));
1785
2182
  const chezLui = t =>
1786
2183
  new Set((t.remontees ?? []).filter(r => Number.isFinite(r.chez)).map(r => r.cle));
1787
2184
  // The state at the right of the line « ⤷ Question » of the circuit <c>: « chez lui · N min » (N from
1788
2185
  // the mark), « lue il y a N min » (from the reading), « envoyée » (in the queue of the session);
1789
2186
  // empty when the greffon has not sent it.
1790
2187
  const etatDeLaQuestion = (c, t) => {
1791
- const r = (t.remontees ?? []).find(x => x.cle === cleDe(c));
2188
+ const r = (t.remontees ?? []).find(x => x.cle === cleDuStop(c));
1792
2189
  const min = depuis =>
1793
2190
  `${Math.max(0, Math.floor(((t.maintenant ?? Date.now()) - depuis) / MINUTE))} min`;
1794
2191
  return !r
@@ -1806,7 +2203,7 @@ const etatDeLaQuestion = (c, t) => {
1806
2203
  * its state (`etat`, whose tone TONS gives), the reason of its wait (`raison`), its tone, its sign
1807
2204
  * and its witness (`temoin`: the part it holds or waits for, « · <sorte> faits/prévus · <durée> »,
1808
2205
  * « · part <sorte> · <durée> », else the progress of its automatic pass, `temoinDe`), in this
1809
- * order: frozen; ended without its issue; its question (to the supervisor or to another); stopped;
2206
+ * order: frozen; its wait on the supervisor deferred to a later hour; ended without its issue; its question (to the supervisor or to another); stopped;
1810
2207
  * its wait for the disk, a place, a part or its first
1811
2208
  * state; else it runs. `lignes`: one entry per
1812
2209
  * ticket's line of AGENTS, its id and its sign: each circuit, each ticket led in direct (▶) and
@@ -1870,6 +2267,14 @@ export function etatsDAgents(t) {
1870
2267
  if (c.report?.raison === 'limite-d-usage') {
1871
2268
  return ['reporteLimite', `limite d'usage · reprise ${heureEtMinute(c.report.reprise)}`];
1872
2269
  }
2270
+ if (misEnPause(c, chezLui(t))) {
2271
+ const jour = jourEtMois(c.reporteA);
2272
+ const heure = heureEtMinute(c.reporteA);
2273
+ return [
2274
+ 'reporteQuestion',
2275
+ `reporté ${jour === jourEtMois(maintenant) ? heure : `${jour} ${heure}`}`,
2276
+ ];
2277
+ }
1873
2278
  if (!c.vivant) {
1874
2279
  const qui = enQuestion(c, chezLui(t));
1875
2280
  return c.sansIssue
@@ -1903,9 +2308,9 @@ export function etatsDAgents(t) {
1903
2308
  ton: TONS[etat],
1904
2309
  // A question carried to the owner is his to answer: ⛔, which « toi : … question » counts.
1905
2310
  signe:
1906
- etat === 'attendLeResponsable' && chezLui(t).has(cleDe(c))
2311
+ etat === 'attendLeResponsable' && chezLui(t).has(cleDuStop(c))
1907
2312
  ? '⛔'
1908
- : signeDuTon(TONS[etat], c.court),
2313
+ : signeDuTon(TONS[etat], c),
1909
2314
  temoin,
1910
2315
  });
1911
2316
  }
@@ -1924,14 +2329,18 @@ export function etatsDAgents(t) {
1924
2329
  }
1925
2330
 
1926
2331
  /**
1927
- * The counts of the signs of AGENTS on the board <t> (`etatsDAgents`): `enCours` ▶, `enAttente` ⏸,
1928
- * `arretes` ⛔.
2332
+ * The counts of the signs of AGENTS on the board <t> (`etatsDAgents`): `enCours` ▶, ▷ and ✎,
2333
+ * `enAttente` ⏸, `arretes` ⛔.
1929
2334
  * @param {any} t
1930
2335
  */
1931
2336
  export function comptesDAgents(t) {
1932
2337
  const l = etatsDAgents(t).lignes;
1933
2338
  const n = s => l.filter(x => x.signe === s).length;
1934
- return { enCours: n('▶') + n('▷'), enAttente: n('⏸'), arretes: n('⛔') };
2339
+ return {
2340
+ enCours: n('▶') + n('▷') + n(SIGNE_DE_LA_VOIE.direct),
2341
+ enAttente: n('⏸'),
2342
+ arretes: n('⛔'),
2343
+ };
1935
2344
  }
1936
2345
 
1937
2346
  // The board's lines, `largeur` columns wide, each with its tone (titre, alerte, attention, actif,
@@ -1968,7 +2377,7 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
1968
2377
  // counter reads 0. « toi »: what the owner decides or validates (sans go, à valider, question:
1969
2378
  // the questions that wait for him, `auResponsable`), then one line per such question,
1970
2379
  // « ❓ <number> <subject> · depuis <HH:MM> » (« jj/mm » for another day), the subject alone cut;
1971
- // « file »: the queues (● ready, ✎ direct, ⧗ attend archi, ⊘ blocked); « en cours »: where
2380
+ // « file »: the queues (● ready, ⧗ attend archi, ⊘ blocked); « en cours »: where
1972
2381
  // nobody acts (▶ in progress, ✓ done, ⏸ deferred). On a board of several projects, <projet>
1973
2382
  // names the one whose lines these are, and each line is laid under its label.
1974
2383
  const lignesDActeurs = (c, projet) => {
@@ -2005,7 +2414,7 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
2005
2414
  })),
2006
2415
  {
2007
2416
  texte: sousLeProjet(
2008
- `file : ● ${n('enAttente')} · ✎ ${n('fileDirecte')} · ⧗ ${n('attendArchi')} · ⊘ ${n('bloques')}`,
2417
+ `file : ● ${n('enAttente')} · ⧗ ${n('attendArchi')} · ⊘ ${n('bloques')}`,
2009
2418
  retrait
2010
2419
  ),
2011
2420
  ton: TONS.enAttente,
@@ -2019,6 +2428,21 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
2019
2428
  },
2020
2429
  ];
2021
2430
  };
2431
+ // The day's and the cumul's lines of <m> (`{ jour, cumul }`), each its working time, its billed
2432
+ // tokens and its cost.
2433
+ const lignesDesMesures = m => {
2434
+ for (const tete of ['jour', 'cumul']) {
2435
+ const x = { travail: 0, jetons: 0, cout: 0, partiel: false, ...m[tete] };
2436
+ L(
2437
+ cadre(
2438
+ `${tete} ${duree(x.travail)} · ${k(x.jetons)} · ${dollars(x.cout, x.partiel)}`,
2439
+ '',
2440
+ largeur
2441
+ ),
2442
+ TONS.mesure
2443
+ );
2444
+ }
2445
+ };
2022
2446
  if (plusieurs) {
2023
2447
  // The lines of each project, as one project's board says them: « toi » under its label, its
2024
2448
  // questions with the label on each, « file » and « en cours » aligned below; or the fault that
@@ -2042,18 +2466,9 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
2042
2466
  ),
2043
2467
  TONS.mesure
2044
2468
  );
2045
- // The day's and the cumulative work time and tokens, summed across the projects, as one
2046
- // project's board shows its own: a multi-root board sums the figures of its roots.
2047
- const m = t.jour ?? { travail: 0, jetons: 0 };
2048
- const mc = t.cumul ?? { travail: 0, jetons: 0 };
2049
- L(
2050
- cadre(
2051
- `jour ${duree(m.travail)} · ${k(m.jetons)} · cumul ${duree(mc.travail)} · ${k(mc.jetons)}`,
2052
- '',
2053
- largeur
2054
- ),
2055
- TONS.mesure
2056
- );
2469
+ // The day's and the cumul's lines, summed across the projects, as one project's board shows
2470
+ // its own: a multi-root board sums the figures of its roots.
2471
+ lignesDesMesures(t);
2057
2472
  } else {
2058
2473
  const g = t.global;
2059
2474
  const c = g.compteurs;
@@ -2072,14 +2487,7 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
2072
2487
  ),
2073
2488
  TONS.mesure
2074
2489
  );
2075
- L(
2076
- cadre(
2077
- `jour ${duree(g.jour.travail)} · ${k(g.jour.jetons)} · cumul ${duree(g.cumul.travail)} · ${k(g.cumul.jetons)}`,
2078
- '',
2079
- largeur
2080
- ),
2081
- TONS.mesure
2082
- );
2490
+ lignesDesMesures(g);
2083
2491
  }
2084
2492
  // An alert of several projects' board names its ticket by its whole id.
2085
2493
  for (const a of t.alertes) {
@@ -2177,7 +2585,8 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
2177
2585
  // The parts of the machine (`lireLaMesure`, `lignesDesParts`): the budget taken, then who holds
2178
2586
  // a part and who waits for what; the part of each ticket shown stands on its line
2179
2587
  // (`etatsDAgents`), a ticket's pass the board does not show nowhere but in the count, the pass
2180
- // without a ticket here. A reserve of the user that is faulty is said by its name.
2588
+ // without a ticket of the board's project (`ici`) here, another project's nowhere but in the
2589
+ // count. A reserve of the user that is faulty is said by its name.
2181
2590
  const m = t.machine;
2182
2591
  if (m?.faute) {
2183
2592
  poser({
@@ -2190,7 +2599,7 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
2190
2599
  budget: m.budget,
2191
2600
  prises: m.prises,
2192
2601
  attentes: m.attentes,
2193
- masquer: p => Boolean(p.ticket),
2602
+ masquer: p => Boolean(p.ticket) || p.ici === false,
2194
2603
  court: courtDuTicket,
2195
2604
  })) {
2196
2605
  poser({
@@ -2474,7 +2883,7 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
2474
2883
  : n.etat === 'attendArchi'
2475
2884
  ? 'attend archi'
2476
2885
  : n.etat === 'enAttente'
2477
- ? 'en attente'
2886
+ ? 'en file'
2478
2887
  : n.etat === 'reportes'
2479
2888
  ? 'reporté'
2480
2889
  : n.etat === 'fermes'
@@ -2505,8 +2914,10 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
2505
2914
  : etat === 'attendUnePlace'
2506
2915
  ? 'attend une place'
2507
2916
  : '';
2917
+ // A line of the group « en file » bears the sign of its way before its number.
2918
+ const marge = n.etat === 'enAttente' ? ` ${SIGNE_DE_LA_VOIE[n.voie]} ` : ' ';
2508
2919
  return {
2509
- texte: cadre(` ${duProjet(n)}${n.numero} ${n.sujet}`, droite, largeur),
2920
+ texte: cadre(`${marge}${duProjet(n)}${n.numero} ${n.sujet}`, droite, largeur),
2510
2921
  ton: TONS[etat],
2511
2922
  ticket: n.id,
2512
2923
  };
@@ -2598,7 +3009,7 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
2598
3009
  TONS.titre
2599
3010
  );
2600
3011
  // Each line: the sign of its way, then « <durée> · <jetons> », « — » for a direct ticket never
2601
- // claimed.
3012
+ // claimed that no circuit led.
2602
3013
  const fait = x => ({
2603
3014
  texte: cadre(
2604
3015
  `${SIGNE_DE_LA_VOIE[x.voie] ?? SIGNE_DE_LA_VOIE.direct} ${duProjet(x)}${x.numero} ${x.sujet}`,
@@ -2764,21 +3175,22 @@ export function ligneEtat(t, voisins = []) {
2764
3175
  const a = comptesDAgents(t);
2765
3176
  const dAgents = `▶ ${a.enCours} · ⏸ ${a.enAttente} · ⛔ ${a.arretes}`;
2766
3177
  if (!ch) {
2767
- return `${alerte}Grillhouse : ${dAgents} · ⏭ ● ${c.enAttente} · ✎ ${c.fileDirecte} · ✓ ${c.fermes}`;
3178
+ return `${alerte}Grillhouse : ${dAgents} · ⏭ ● ${c.enAttente} · ✓ ${c.fermes}`;
2768
3179
  }
2769
3180
  return `${alerte}${ch.numero} ${ch.faits}/${ch.total} · ${dAgents} · ${k(t.global.jour.jetons)} aujourd'hui`;
2770
3181
  }
2771
3182
 
2772
3183
  /**
2773
3184
  * The fault of a call of Beads that threw <e>, as an alert says it: the command `bd` missing from
2774
- * the PATH with its gesture, as the session start names it; else the first line of its error
2775
- * output, else of its message.
3185
+ * the PATH, with its gesture, the process that called it and its PATH; else the first line of its
3186
+ * error output, else of its message.
2776
3187
  * @param {unknown} e
3188
+ * @param {{ pid?: number, chemins?: string }} [appelant]
2777
3189
  * @returns {string}
2778
3190
  */
2779
- export function fauteDeBeads(e) {
3191
+ export function fauteDeBeads(e, { pid = process.pid, chemins = process.env.PATH ?? '' } = {}) {
2780
3192
  if (/** @type {{ code?: string }} */ (e)?.code === 'ENOENT') {
2781
- return 'la commande bd est absente du PATH de cette séance : `npm install -g @beads/bd`';
3193
+ return `la commande bd est absente du PATH du processus ${pid} qui mesure le tableau (\`npm install -g @beads/bd\`) — PATH : ${chemins}`;
2782
3194
  }
2783
3195
  const message =
2784
3196
  String(/** @type {{ stderr?: unknown }} */ (e)?.stderr ?? '').trim() ||
@@ -2786,14 +3198,24 @@ export function fauteDeBeads(e) {
2786
3198
  return message.split('\n')[0];
2787
3199
  }
2788
3200
 
2789
- // The answer of Beads to <args> in the repository at <racine>, as JSON (`liste`), or its fault
2790
- // (`faute`, `fauteDeBeads`).
2791
- const bdJson = (racine, ...args) => {
3201
+ /**
3202
+ * The answer of Beads to <args> in the repository at <racine>, as JSON (`liste`), or its fault
3203
+ * (`faute`, `fauteDeBeads`). The path of `bd` is kept in, or taken back from, the common git
3204
+ * directory <commun> (`bdAAppeler`, scripts/bd-garde.mjs).
3205
+ * @param {string} racine
3206
+ * @param {string | null} commun
3207
+ * @param {...string} args
3208
+ * @returns {{ liste: any[], faute: string | null }}
3209
+ */
3210
+ export const bdJson = (racine, commun, ...args) => {
3211
+ garderBd(commun);
3212
+ const bd = bdAAppeler(commun);
2792
3213
  try {
2793
3214
  return {
2794
3215
  liste: JSON.parse(
2795
- execFileSync('bd', [...args, '--json'], {
3216
+ execFileSync(bd.commande, [...args, '--json'], {
2796
3217
  cwd: racine,
3218
+ env: bd.env,
2797
3219
  encoding: 'utf8',
2798
3220
  stdio: ['ignore', 'pipe', 'pipe'],
2799
3221
  maxBuffer: 256 * 1024 * 1024,
@@ -2935,7 +3357,7 @@ function lire(
2935
3357
  const registre = existsSync(REGISTRE) ? lireRegistre(readFileSync(REGISTRE, 'utf8'), racine) : [];
2936
3358
  const commun = dossierCommun(racine);
2937
3359
  // The tickets and the circuits, each the last reading that succeeded when this one failed.
2938
- const lesTickets = bdJson(racine, 'list', '--all', '--limit', '0');
3360
+ const lesTickets = bdJson(racine, commun, 'list', '--all', '--limit', '0');
2939
3361
  const tickets = lectureGardee(
2940
3362
  commun,
2941
3363
  'tickets',
@@ -2956,6 +3378,9 @@ function lire(
2956
3378
  } catch {
2957
3379
  cache = {};
2958
3380
  }
3381
+ // The spendings first: they settle which responses each transcript leaves out, which the running
3382
+ // agents' readings then follow.
3383
+ const depenses = lireLesDepenses({ racine, home, maintenant, cache });
2959
3384
  const vivants = lireVivant({
2960
3385
  racine,
2961
3386
  home,
@@ -2965,7 +3390,6 @@ function lire(
2965
3390
  cache,
2966
3391
  });
2967
3392
  const jourLu = lireLeRepere(commun, maintenant);
2968
- const superviseur = jetonsDuSuperviseur({ racine, home, jour: jourLu, cache });
2969
3393
  try {
2970
3394
  if (fichierCache) {
2971
3395
  writeFileSync(
@@ -2983,12 +3407,14 @@ function lire(
2983
3407
  ...tous.filter(x => x.closed_at && Date.parse(x.closed_at) >= jour).map(x => x.id),
2984
3408
  ...lesCircuitsLus.liste.map(c => c.ticket),
2985
3409
  ]);
3410
+ const bilans = bilansGardes(commun ? path.dirname(commun) : racine);
2986
3411
  const t = assembler({
2987
3412
  tous,
2988
3413
  prefix,
2989
3414
  racine: commun ? path.dirname(commun) : racine,
2990
3415
  registre,
2991
3416
  vivants,
3417
+ depenses,
2992
3418
  circuits: lesCircuitsLus.liste,
2993
3419
  maintenant,
2994
3420
  jour,
@@ -3005,12 +3431,12 @@ function lire(
3005
3431
  echecPrefixe,
3006
3432
  outil: echecDeLOutil(racine),
3007
3433
  remontees: lireLesRemontees(racine, maintenant),
3008
- superviseur,
3434
+ bilans,
3009
3435
  externes: lireLesExternes(racine, tous),
3010
3436
  limite: maxDuProjet(commun ? path.dirname(commun) : racine) ?? null,
3011
3437
  lotSurMain: lotEstSurMain(commun ? path.dirname(commun) : racine),
3012
3438
  });
3013
- return { t, prefix, tous, vivants, commun };
3439
+ return { t, prefix, tous, vivants, commun, bilans };
3014
3440
  }
3015
3441
 
3016
3442
  // The places of the machine as the board shows them (`etatDesPlaces`), null when they do not read
@@ -3037,16 +3463,15 @@ export function ensemble(lus) {
3037
3463
  const marquer = projet => x => ({ ...x, projet });
3038
3464
  const noeud = projet => n => ({ ...n, projet, enfants: n.enfants.map(noeud(projet)) });
3039
3465
  const tous = cle => lisibles.flatMap(l => (l.t[cle] ?? []).map(marquer(l.etiquette)));
3040
- // The sum, across the projects, of a measure of `global` (`jour` or `cumul`): its work time and
3041
- // its tokens added.
3042
- const sommeDesMesures = cle =>
3043
- lisibles.reduce(
3044
- (s, l) => ({
3045
- travail: s.travail + (l.t.global[cle]?.travail ?? 0),
3046
- jetons: s.jetons + (l.t.global[cle]?.jetons ?? 0),
3047
- }),
3048
- { travail: 0, jetons: 0 }
3049
- );
3466
+ // The sum, across the projects, of a measure of `global` (`jour` or `cumul`): its work time,
3467
+ // its tokens and its cost added, partial when one project's is.
3468
+ const sommeDesMesures = cle => {
3469
+ const l = lisibles.map(x => x.t.global[cle] ?? {});
3470
+ return {
3471
+ travail: l.reduce((s, m) => s + (m.travail ?? 0), 0),
3472
+ ...additionner(l.map(m => ({ jetons: 0, cout: 0, ...m }))),
3473
+ };
3474
+ };
3050
3475
  return {
3051
3476
  projets: lus.map(l =>
3052
3477
  l.t
@@ -3092,8 +3517,8 @@ export function ensemble(lus) {
3092
3517
  },
3093
3518
  { new: 0, check: 0, rejetes: 0, valides: 0 }
3094
3519
  ),
3095
- // The day's and the cumulative work time and tokens, summed across the projects (each project's
3096
- // own `global.jour`/`global.cumul`), for the board's time-and-token line of several projects.
3520
+ // The day's and the cumulative work time, tokens and cost, summed across the projects (each
3521
+ // project's own `global.jour`/`global.cumul`), for their lines on a board of several.
3097
3522
  jour: sommeDesMesures('jour'),
3098
3523
  cumul: sommeDesMesures('cumul'),
3099
3524
  etats: premier.t.etats.map(e => ({
@@ -3164,7 +3589,7 @@ export function nommerLesProjets(machine, noms, ici = null) {
3164
3589
  // The board of the repository at <racine>; with <projets>, the folders of other projects, the
3165
3590
  // board of them all (`ensemble`), named « <dépôt> + <projet> + … », with the folder of each
3166
3591
  // ticket's project (`dossiers`), where the pane runs Beads for it. The status line is the
3167
- // session's project's alone. Each project's circuits are read by <circuitsDe> (lists of the
3592
+ // session's project's alone, as is the command of Beads (`bd`). Each project's circuits are read by <circuitsDe> (lists of the
3168
3593
  // Temporal server that it filters, scripts/circuits-du-serveur.mjs, by default), and the night under way on the
3169
3594
  // machine by <nuitDe> (`nuitDuServeur` by default); a night that does not read shows none.
3170
3595
  /**
@@ -3296,7 +3721,7 @@ export async function tableau(
3296
3721
  const lisibles = lus.filter(x => x.t);
3297
3722
  const parProjet = lisibles.map(x => ({
3298
3723
  dossier: x.dossier,
3299
- fiches: fiches(x.tous, toutes, x.prefix, x.t.parTicket, x.t.circuits, bilansGardes(x.dossier)),
3724
+ fiches: fiches(x.tous, toutes, x.prefix, x.t.parTicket, x.t.circuits, x.bilans),
3300
3725
  }));
3301
3726
  return {
3302
3727
  ...t,
@@ -3311,6 +3736,8 @@ export async function tableau(
3311
3736
  maintenant
3312
3737
  ),
3313
3738
  etat,
3739
+ // The command by which the pane calls Beads, resolved and checked at this measure.
3740
+ bd: bdAAppeler(ici.commun).commande,
3314
3741
  ...(projets.length
3315
3742
  ? {
3316
3743
  dossiers: Object.fromEntries(