@roomi-fields/grillhouse 0.34.2 → 0.36.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 (67) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +33 -13
  3. package/cadre/templates/cargo/package.json +4 -2
  4. package/cadre/templates/projet/.claude/settings.json +0 -1
  5. package/cadre/templates/projet/CLAUDE.md +5 -0
  6. package/cadre/templates/python/package.json +4 -2
  7. package/charte.md +4 -4
  8. package/dist/temporal/file/contrat.d.ts +3 -1
  9. package/dist/temporal/file/deroule.js +2 -2
  10. package/dist/temporal/file/deroule.js.map +1 -1
  11. package/dist/temporal/places/contrat.d.ts +12 -0
  12. package/dist/temporal/places/deroule.js +2 -0
  13. package/dist/temporal/places/deroule.js.map +1 -1
  14. package/dist/temporal/tickets/activites.js +30 -3
  15. package/dist/temporal/tickets/activites.js.map +1 -1
  16. package/docs/ARCHITECTURE.md +37 -10
  17. package/docs/INTERFACE.md +6 -5
  18. package/hooks/crochet.mjs +0 -6
  19. package/package.json +1 -1
  20. package/scripts/activites.mjs +41 -7
  21. package/scripts/attente-a-l-arret.mjs +1 -1
  22. package/scripts/attente-au-tour.mjs +1 -1
  23. package/scripts/circuit.mjs +10 -2
  24. package/scripts/enveloppe/enveloppe.mjs +44 -14
  25. package/scripts/enveloppe/lancer.sh +5 -1
  26. package/scripts/enveloppe/paquets-du-plan.mjs +3 -0
  27. package/scripts/file-des-tickets.d.mts +23 -1
  28. package/scripts/file-des-tickets.mjs +94 -3
  29. package/scripts/flux-des-paquets.mjs +22 -8
  30. package/scripts/gabarit-absent.mjs +30 -0
  31. package/scripts/grillhouse-maj.mjs +77 -1
  32. package/scripts/groupe-cles.d.mts +25 -0
  33. package/scripts/groupe-cles.mjs +73 -0
  34. package/scripts/integration/file.mjs +30 -5
  35. package/scripts/jointure.d.ts +11 -0
  36. package/scripts/langages/cargo/index.mjs +3 -2
  37. package/scripts/langages/cargo/mise-a-jour.mjs +17 -0
  38. package/scripts/langages/python/index.mjs +3 -1
  39. package/scripts/langages/python/mise-a-jour.mjs +22 -5
  40. package/scripts/langages/typescript/mise-a-jour.mjs +8 -20
  41. package/scripts/mesure/base-de-passe.mjs +7 -0
  42. package/scripts/migrations/0.35.0-greffon-mattpocock-retire.mjs +41 -0
  43. package/scripts/migrations.mjs +2 -0
  44. package/scripts/places-de-la-machine.mjs +15 -5
  45. package/scripts/places-du-serveur.mjs +12 -2
  46. package/scripts/regles-des-places.d.mts +7 -0
  47. package/scripts/regles-des-places.mjs +46 -4
  48. package/scripts/seances.mjs +24 -2
  49. package/scripts/services-du-noyau.mjs +2 -1
  50. package/scripts/sigle-du-projet.mjs +49 -0
  51. package/scripts/superviseur.mjs +37 -19
  52. package/scripts/tableau.mjs +115 -15
  53. package/scripts/verrous/verrou.mjs +7 -0
  54. package/skills/codebase-design/DEEPENING.md +37 -0
  55. package/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
  56. package/skills/codebase-design/SKILL.md +114 -0
  57. package/skills/domain-modeling/ADR-FORMAT.md +47 -0
  58. package/skills/domain-modeling/GLOSSARY-FORMAT.md +60 -0
  59. package/skills/domain-modeling/SKILL.md +74 -0
  60. package/skills/grill/SKILL.md +4 -5
  61. package/skills/grilling/SKILL.md +30 -0
  62. package/skills/pitmaster/SKILL.md +4 -3
  63. package/skills/pitmaster/references/cadre.md +1 -1
  64. package/skills/redacteur/SKILL.md +1 -1
  65. package/skills/testwriter/SKILL.md +7 -4
  66. package/skills/writing-for-agents/SKILL-MECHANICS.md +22 -0
  67. package/skills/writing-for-agents/SKILL.md +81 -0
@@ -39,6 +39,7 @@ import * as ciDesBranchesDeTicket from './migrations/0.33.0-ci-des-branches-de-t
39
39
  import * as node26 from './migrations/0.33.0-node-26.mjs';
40
40
  import * as ciDuCadre from './migrations/0.33.0-ci-du-cadre.mjs';
41
41
  import * as cacheDistant from './migrations/0.33.0-cache-distant.mjs';
42
+ import * as greffonMattpocockRetire from './migrations/0.35.0-greffon-mattpocock-retire.mjs';
42
43
 
43
44
  /** The migrations of the core. */
44
45
  export const MIGRATIONS = [
@@ -57,6 +58,7 @@ export const MIGRATIONS = [
57
58
  node26,
58
59
  ciDuCadre,
59
60
  cacheDistant,
61
+ greffonMattpocockRetire,
60
62
  ];
61
63
 
62
64
  /**
@@ -42,7 +42,7 @@ import { paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
42
42
  import { ecrireLaTrace, traceDesPlaces } from './journal-des-etats.mjs';
43
43
  import { mesureDeLaMachine } from './mesure-de-la-machine.mjs';
44
44
  import { plafondDe } from './plafond-de-la-machine.mjs';
45
- import { AttenteDeLaMachine, avecLaMachine, borneDe } from './verrou-de-machine.mjs';
45
+ import { AttenteDeLaMachine, avecLaMachine, borneDe, racineDuDepot } from './verrou-de-machine.mjs';
46
46
 
47
47
  export const VARIABLE_ESPACEMENT = 'GRILLHOUSE_ESPACEMENT_MS';
48
48
  export const VARIABLE_TRAVAILLEURS = 'GRILLHOUSE_TRAVAILLEURS';
@@ -205,6 +205,7 @@ export function prendreUnePlace({
205
205
  pid,
206
206
  depart: depart === undefined ? departDe(pid) : depart,
207
207
  ticket,
208
+ racine: racineDuDepot(racine),
208
209
  ...(rang === undefined || rang === null ? {} : { rang }),
209
210
  borneMs,
210
211
  rappelMs,
@@ -344,7 +345,7 @@ export function avecLaMachineEtUnePlace(mesure, options = {}) {
344
345
  * The places taken and the waits of the machine under <env>, as the server holds them: `{ plafond,
345
346
  * faute, prises, attentes, circuits }` (`faute`, a value of the ceiling the poste names and the
346
347
  * server refused, the ceiling read before kept; `circuits`, the places of the circuits, held or
347
- * waited for, `{ racine, ticket, rang, accordee, depuis, vu }`), `prises` `{ id, pid, depart, ticket, rang, depuis }`, `attentes` in the
348
+ * waited for, `{ racine, ticket, rang, accordee, depuis, vu }`), `prises` `{ id, pid, depart, ticket, racine, rang, depuis }`, `attentes` in the
348
349
  * order of arrival `{ id, pid, ticket, rang, raison, depuis }`; none where no place is taken.
349
350
  * @param {{ env?: Record<string, string | undefined> }} [o]
350
351
  */
@@ -399,15 +400,24 @@ function mesureDEssai(env) {
399
400
  * started (`circuits` of the server, which the queue of each project reserves). The
400
401
  * machine is the one GRILLHOUSE_MESURE_D_ESSAI fixes, else the real one (`mesurer`).
401
402
  * @param {{ env?: Record<string, string | undefined>, mesurer?: () => { coeurs: number,
402
- * charge: number, memoireLibre: number, memoireTotale: number } }} [o]
403
+ * charge: number, memoireLibre: number, memoireTotale: number },
404
+ * lues?: { plafond: number, faute?: string | null, prises: { ticket: string | null,
405
+ * racine?: string | null }[], attentes: { ticket: string, depuis: number }[],
406
+ * circuits?: { ticket: string, depuis: number, accordee?: boolean, raison?: string | null }[] }
407
+ * }} [o] `lues`, the places as the server holds them (`lirePlaces` by default); `tenues` of the
408
+ * result gives each place taken, its ticket and the root of its project (null without one)
409
+ * @returns {{ prises: number, tenues: { ticket: string | null, racine: string | null }[],
410
+ * plafond: number, faute: string | null, charge: number, coeurs: number, memoireGo: number,
411
+ * memoireTotaleGo: number, attentes: { ticket: string, depuis: number, disque?: string | null }[] }}
403
412
  * @throws {Error} naming GRILLHOUSE_MESURE_D_ESSAI when its value is faulty
404
413
  */
405
- export function etatDesPlaces({ env = process.env, mesurer = mesureDeLaMachine } = {}) {
414
+ export function etatDesPlaces({ env = process.env, mesurer = mesureDeLaMachine, lues } = {}) {
406
415
  const fixee = mesureDEssai(env);
407
- const { plafond, faute = null, prises, attentes, circuits = [] } = lirePlaces({ env });
416
+ const { plafond, faute = null, prises, attentes, circuits = [] } = lues ?? lirePlaces({ env });
408
417
  const m = fixee ?? mesurer();
409
418
  return {
410
419
  prises: prises.length,
420
+ tenues: prises.map(p => ({ ticket: p.ticket ?? null, racine: p.racine ?? null })),
411
421
  plafond,
412
422
  faute,
413
423
  charge: Math.round(m.charge * 10) / 10,
@@ -69,9 +69,19 @@ export async function avecReprises(
69
69
  }
70
70
  }
71
71
  }
72
+ /**
73
+ * Whether the socket <s> is connected to itself: its local end is its remote end, as Linux opens a
74
+ * connection to a free local port whose source port happens to be that port (TCP simultaneous
75
+ * open; go-redis and Go's PostgreSQL driver tell it the same way).
76
+ * @param {import('node:net').Socket} s
77
+ */
78
+ export const connecteeASoi = s =>
79
+ s.localPort === s.remotePort && s.localAddress === s.remoteAddress;
80
+
72
81
  /**
73
82
  * Whether something listens on <adresse> (`hote:port`): false when the connection is refused (no
74
- * server), true when it opens or does not answer within <delaiMs> (a server busy).
83
+ * server) or opens on itself (`connecteeASoi`), true when it opens on another end or does not
84
+ * answer within <delaiMs> (a server busy).
75
85
  * @param {string} adresse
76
86
  * @param {number} [delaiMs]
77
87
  * @returns {Promise<boolean>}
@@ -84,7 +94,7 @@ export function ecoute(adresse, delaiMs = 2_000) {
84
94
  s.destroy();
85
95
  ok(r);
86
96
  };
87
- s.once('connect', () => fin(true));
97
+ s.once('connect', () => fin(!connecteeASoi(s)));
88
98
  s.once('error', () => fin(false));
89
99
  s.setTimeout(delaiMs, () => fin(true));
90
100
  });
@@ -50,6 +50,11 @@ export interface PlaceDeCircuit {
50
50
  reprise?: boolean;
51
51
  /** Why it waits apart from the order of arrival (its disk of copies), null without. */
52
52
  raison?: string | null;
53
+ /** Its Beads priority (0 to 4) and creation, which order the circuits that wait of one group. */
54
+ priorite?: number;
55
+ creation?: string;
56
+ /** The identity of its project's group, absent out of a group. */
57
+ groupe?: string;
53
58
  }
54
59
 
55
60
  /**
@@ -66,6 +71,8 @@ export function reserverDesCircuits(
66
71
  candidats?: string[];
67
72
  disque?: string | null;
68
73
  reprise?: { ticket: string; rang: number | null };
74
+ groupe?: string;
75
+ priorites?: Record<string, { priorite: number; creation: string }>;
69
76
  },
70
77
  o: { rang: number; plafond: number; maintenant: number }
71
78
  ): { circuits: PlaceDeCircuit[]; rang: number; accordes: string[] };
@@ -86,14 +86,31 @@ export const PERIME_MS = 10 * 60_000;
86
86
  * the circuits that hold one are fewer than <plafond>: the first that waits keeps the next ones
87
87
  * waiting, but a candidate short of disk, which waits with its reason and keeps no one. Gives the
88
88
  * places, the last rank drawn, and the tickets of the demand that hold a place.
89
+ *
90
+ * Between the projects of one group (`grillhouse.groupe`, `groupe` its identity, absent out of a
91
+ * group), the priority orders the circuits that wait: each candidate carries its Beads priority and
92
+ * its creation (`priorites`), and the circuits not granted of one group share out their own ranks
93
+ * of arrival again by priority (P0 to P4), age, then rank. A circuit already granted keeps its
94
+ * place (a higher priority arriving later passes only the ones that wait), a project out of a
95
+ * group and the order of the groups between them keep the order of arrival.
89
96
  * @param {Array<{ racine: string, ticket: string, rang: number, accordee: boolean, depuis: number,
90
- * vu: number, reprise?: boolean, raison?: string | null }>} places
97
+ * vu: number, reprise?: boolean, raison?: string | null, priorite?: number, creation?: string,
98
+ * groupe?: string }>} places
91
99
  * @param {{ racine: string, vivants?: string[], candidats?: string[], disque?: string | null,
92
- * reprise?: { ticket: string, rang: number | null } }} demande
100
+ * reprise?: { ticket: string, rang: number | null }, groupe?: string,
101
+ * priorites?: Record<string, { priorite: number, creation: string }> }} demande
93
102
  * @param {{ rang: number, plafond: number, maintenant: number }} o
94
103
  */
95
104
  export function reserverDesCircuits(places, demande, o) {
96
- const { racine, vivants = [], candidats = [], disque = null, reprise } = demande;
105
+ const {
106
+ racine,
107
+ vivants = [],
108
+ candidats = [],
109
+ disque = null,
110
+ reprise,
111
+ groupe,
112
+ priorites = {},
113
+ } = demande;
97
114
  const { plafond, maintenant } = o;
98
115
  let { rang } = o;
99
116
  const siens = new Set([...vivants, ...candidats]);
@@ -101,6 +118,13 @@ export function reserverDesCircuits(places, demande, o) {
101
118
  maintenant - c.vu < PERIME_MS &&
102
119
  (c.racine !== racine || siens.has(c.ticket) || Boolean(reprise) || (c.reprise && !c.accordee));
103
120
  const circuits = places.filter(garde).map(c => ({ ...c }));
121
+ // What the demand says of a ticket's place: its group, its priority and its creation.
122
+ const dit = ticket => ({
123
+ ...(groupe === undefined ? {} : { groupe }),
124
+ ...(priorites[ticket] === undefined
125
+ ? {}
126
+ : { priorite: priorites[ticket].priorite, creation: priorites[ticket].creation }),
127
+ });
104
128
  const placer = (ticket, accordee, o2 = {}) => {
105
129
  const c = circuits.find(x => x.racine === racine && x.ticket === ticket);
106
130
  if (c) {
@@ -109,7 +133,7 @@ export function reserverDesCircuits(places, demande, o) {
109
133
  if (accordee) {
110
134
  c.reprise = false;
111
135
  }
112
- Object.assign(c, o2.maj ?? {});
136
+ Object.assign(c, dit(ticket), o2.maj ?? {});
113
137
  return;
114
138
  }
115
139
  const r = o2.rang ?? (rang += 1);
@@ -121,6 +145,7 @@ export function reserverDesCircuits(places, demande, o) {
121
145
  accordee,
122
146
  depuis: maintenant,
123
147
  vu: maintenant,
148
+ ...dit(ticket),
124
149
  ...(o2.maj ?? {}),
125
150
  });
126
151
  };
@@ -132,6 +157,23 @@ export function reserverDesCircuits(places, demande, o) {
132
157
  maj: { reprise: true, raison: null },
133
158
  });
134
159
  }
160
+ // The circuits not granted of each group share out their own ranks again, by priority, age, rank.
161
+ const sorte = c => [c.priorite ?? 2, Date.parse(c.creation ?? '') || 0, c.rang];
162
+ const parGroupe = Map.groupBy(
163
+ circuits.filter(c => !c.accordee && c.groupe !== undefined),
164
+ c => c.groupe
165
+ );
166
+ for (const attente of parGroupe.values()) {
167
+ const rangs = attente.map(c => c.rang).sort((a, b) => a - b);
168
+ attente
169
+ .toSorted((a, b) => {
170
+ const [x, y] = [sorte(a), sorte(b)];
171
+ return x[0] - y[0] || x[1] - y[1] || x[2] - y[2];
172
+ })
173
+ .forEach((c, i) => {
174
+ c.rang = rangs[i];
175
+ });
176
+ }
135
177
  let tenues = circuits.filter(c => c.accordee).length;
136
178
  for (const c of circuits.filter(x => !x.accordee).sort((a, b) => a.rang - b.rang)) {
137
179
  if (tenues >= plafond) {
@@ -134,6 +134,7 @@ export function rangDeLaSeance(ctx, id) {
134
134
  fin: path.join(dossier, 'fin'),
135
135
  resultat: path.join(dossier, 'resultat.json'),
136
136
  horsPlan: path.join(dossier, 'hors-plan'),
137
+ horsPlanFait: path.join(dossier, 'hors-plan.json'),
137
138
  };
138
139
  }
139
140
 
@@ -147,6 +148,7 @@ function resultatRange(rang, id) {
147
148
  seance: Number(readFileSync(rang.fin, 'utf8').trim()),
148
149
  bloque: false,
149
150
  horsPlan: existsSync(rang.horsPlan) ? lire(rang.horsPlan).trim() : null,
151
+ ecriture: ecritureRangee(rang),
150
152
  erreur: null,
151
153
  sortie: lire(rang.resultat).trim(),
152
154
  id,
@@ -244,6 +246,7 @@ export async function lancer(
244
246
  rmSync(rang.fin, { force: true });
245
247
  rmSync(rang.resultat, { force: true });
246
248
  rmSync(rang.horsPlan, { force: true });
249
+ rmSync(rang.horsPlanFait, { force: true });
247
250
  inscrire(ctx, {
248
251
  role: AUTEUR_DU_CIRCUIT,
249
252
  lancement: { role, seance: id, ...(objet ? { objet } : {}) },
@@ -373,6 +376,7 @@ export async function lancer(
373
376
  let seance;
374
377
  let sortie;
375
378
  let horsPlan = null;
379
+ let ecriture = null;
376
380
  if (horsEnveloppe) {
377
381
  seance = existsSync(rang.fin)
378
382
  ? Number(readFileSync(rang.fin, 'utf8').trim())
@@ -389,12 +393,14 @@ export async function lancer(
389
393
  seance = existsSync(rang.fin) ? Number(readFileSync(rang.fin, 'utf8').trim()) : null;
390
394
  sortie = lire(rang.resultat).trim();
391
395
  horsPlan = existsSync(rang.horsPlan) ? lire(rang.horsPlan).trim() : null;
396
+ ecriture = ecritureRangee(rang);
392
397
  }
393
398
  return {
394
399
  code: r.code,
395
400
  seance,
396
401
  bloque: r.bloque,
397
402
  horsPlan,
403
+ ecriture,
398
404
  erreur: r.erreur ?? lire(erreurs),
399
405
  sortie,
400
406
  id,
@@ -747,15 +753,31 @@ function avecLesReponses(constats, fiche) {
747
753
  });
748
754
  }
749
755
 
756
+ // The write the lock stopped, `{ chemin, paquet, racine }`, as it ranged it at <rang>
757
+ // (`hors-plan.json`), or null without it.
758
+ function ecritureRangee(rang) {
759
+ return existsSync(rang.horsPlanFait) ? JSON.parse(lire(rang.horsPlanFait)) : null;
760
+ }
761
+
750
762
  // The launch <r> of a session of <role>, or the Arret it is: a session its lock stopped on a
751
763
  // write out of the plan (« hors-plan », the write as its piece), a motionless session
752
764
  // (« bloqué »), a launch that stops before its session (« lancement »).
753
765
  export function seanceLancee(ctx, role, r) {
754
766
  if (r.horsPlan) {
767
+ // The lock's structured write: the first line of the report names the path and its package;
768
+ // the question carries the command (none for the root, which no package holds).
769
+ const ecriture = r.ecriture;
770
+ const nom = ecriture ? (ecriture.racine ? 'la racine du dépôt' : ecriture.paquet) : null;
771
+ const dit = ecriture ? `${ecriture.chemin} est dans ${nom}` : null;
772
+ const question = !ecriture
773
+ ? null
774
+ : ecriture.racine
775
+ ? `La séance écrit ${ecriture.chemin}, que tient la racine du dépôt, hors du plan du ticket : aucun paquet ne le porte, l'écriture est-elle refusée (\`--reprendre\` avec son contexte) ?`
776
+ : `La séance écrit ${ecriture.chemin}, que tient ${ecriture.paquet}, hors du plan du ticket : le plan s'étend-il à ce paquet (\`--etendre ${ecriture.paquet}\`), ou l'écriture est-elle refusée (\`--reprendre\` avec son contexte) ?`;
755
777
  throw new Arret(
756
778
  'hors-plan',
757
- `Le crochet de la séance du ${nomDuRole(role)} l'arrête sur une écriture hors du plan du ticket (ses paquets : ${ctx.paquets.join(', ')}) :\n\n${r.horsPlan}`,
758
- { piece: r.horsPlan }
779
+ `${dit ? `${dit}, hors du plan du ticket (ses paquets : ${ctx.paquets.join(', ')}).\n\n` : ''}Le crochet de la séance du ${nomDuRole(role)} l'arrête sur une écriture hors du plan du ticket (ses paquets : ${ctx.paquets.join(', ')}) :\n\n${r.horsPlan}`,
780
+ { piece: r.horsPlan, ...(question ? { question } : {}) }
759
781
  );
760
782
  }
761
783
  if (r.bloque) {
@@ -12,12 +12,13 @@ export * from './langages.mjs';
12
12
  // The services of the core to a module of language: the plan of an envelope, the progress of a
13
13
  // pass and its measure, the tasks of the graph of the packages, the base of a pass, the pressure of the machine, its place and its lock, the last
14
14
  // green, the arbitrages of a ticket, the source files of a project, the search of a command in the
15
- // PATH.
15
+ // PATH, the copy of a template a project lacks.
16
16
  export { arbitrageTranche, estArbitrage } from './arbitrages.mjs';
17
17
  export { garderLeTotal, inscrireLePlan, ouvrirAvancement } from './avancement.mjs';
18
18
  export { sources } from './sources.mjs';
19
19
  export { trouverDansLePath } from './commandes-du-path.mjs';
20
20
  export { paquetsSansPackageJson } from './paquet-npm.mjs';
21
+ export { poserLeGabaritAbsent } from './gabarit-absent.mjs';
21
22
  export {
22
23
  cheminsDeLaTache,
23
24
  construireDepuisLesArguments,
@@ -0,0 +1,49 @@
1
+ // The short name of a project on the displays shared between projects (the line of the places, the
2
+ // board of several projects): the key `grillhouse.sigle` of its package.json (grillhouse-1lf, the
3
+ // owner's word of 2026-11-12), else its ticket prefix (`issue-prefix` of .beads/config.yaml,
4
+ // ./prefixe-des-tickets.mjs). Read like the other keys `grillhouse.*` (./circuits-cles.mjs): as
5
+ // written, a faulty value is named by its key.
6
+ import { readFileSync } from 'node:fs';
7
+ import path from 'node:path';
8
+ import { prefixe } from './prefixe-des-tickets.mjs';
9
+
10
+ // Returns { sigle, faute }: `sigle` the short name declared, null when the key is absent, null or
11
+ // faulty; `faute` the fault by its key, null when the key reads.
12
+ export function lireSigle(pkg) {
13
+ const s = pkg?.grillhouse?.sigle;
14
+ if (s === undefined || s === null) {
15
+ return { sigle: null, faute: null };
16
+ }
17
+ if (typeof s !== 'string' || s === '' || /\s/.test(s)) {
18
+ return {
19
+ sigle: null,
20
+ faute: `grillhouse.sigle vaut ${JSON.stringify(s)}, pas une chaîne non vide sans espace.`,
21
+ };
22
+ }
23
+ return { sigle: s, faute: null };
24
+ }
25
+
26
+ /**
27
+ * The sigle of the project whose root is <racine>: `{ sigle, faute }`; the declared key, else its
28
+ * ticket prefix (the prefix also when the key is faulty, `faute` saying it); no sigle, and no
29
+ * throw, when neither reads.
30
+ * @param {string} racine
31
+ * @returns {{ sigle: string | null, faute: string | null }}
32
+ */
33
+ export function sigleDuProjet(racine) {
34
+ let pkg = null;
35
+ try {
36
+ pkg = JSON.parse(readFileSync(path.join(racine, 'package.json'), 'utf8'));
37
+ } catch {
38
+ pkg = null;
39
+ }
40
+ const { sigle, faute } = lireSigle(pkg);
41
+ if (sigle) {
42
+ return { sigle, faute: null };
43
+ }
44
+ try {
45
+ return { sigle: prefixe(racine), faute };
46
+ } catch {
47
+ return { sigle: null, faute };
48
+ }
49
+ }
@@ -111,6 +111,11 @@ function seance(depart = process.ppid) {
111
111
  return depart;
112
112
  }
113
113
 
114
+ // The time in ms of <texte>, a `defer_until` as Beads writes it: the local wall time of the
115
+ // machine, followed by a « Z » it does not mean (`bd update --defer 17:30` gives `…T17:30:00Z`);
116
+ // NaN without one.
117
+ const heureMurale = texte => Date.parse(String(texte ?? '').replace(/Z$/, ''));
118
+
114
119
  /**
115
120
  * Of the tickets <tickets> (as `bd show --json` gives them), the ids of those whose question does
116
121
  * not wait for the supervisor at <maintenant> (ms): closed, or deferred to a later time
@@ -123,24 +128,25 @@ function seance(depart = process.ppid) {
123
128
  export function horsAttente(tickets, maintenant) {
124
129
  return new Set(
125
130
  tickets
126
- .filter(t => t.status === 'closed' || Date.parse(t.defer_until ?? '') > maintenant)
131
+ .filter(t => t.status === 'closed' || heureMurale(t.defer_until) > maintenant)
127
132
  .map(t => t.id)
128
133
  );
129
134
  }
130
135
 
131
136
  // Of the tickets <ids> of the repository at <racine>, those whose question does not wait now
132
- // (`horsAttente`); none when bd does not read them.
137
+ // (`horsAttente`); null when bd does not read them (unknown, never « none »): a machine under
138
+ // load can take seconds to answer.
133
139
  export function ticketsHorsAttente(racine, ids) {
134
140
  const r = spawnSync('bd', ['show', ...ids, '--json'], {
135
141
  cwd: racine,
136
142
  encoding: 'utf8',
137
- timeout: 5000,
143
+ timeout: 30_000,
138
144
  maxBuffer: 256 * 1024 * 1024,
139
145
  });
140
146
  try {
141
147
  return horsAttente(JSON.parse(r.stdout), Date.now());
142
148
  } catch {
143
- return new Set();
149
+ return null;
144
150
  }
145
151
  }
146
152
 
@@ -288,10 +294,15 @@ function relever(racine, circuits, { fermes, maintenant, rappelMs, toutes = fals
288
294
  aRendre.map(q => q.ticket)
289
295
  )
290
296
  : new Set();
291
- const rendu = aRendre
292
- .filter(q => !fermesDe.has(q.ticket))
293
- .map(q => (avant.has(q.cle) && !toutes ? { ...q, representee: true } : q));
294
- const presentes = new Set(aRendre.map(q => q.cle));
297
+ // Tickets that do not read: nothing is given at this reading, nor counted presented, so that
298
+ // the next reading that reads them gives what still waits.
299
+ const lisible = fermesDe !== null;
300
+ const rendu = lisible
301
+ ? aRendre
302
+ .filter(q => !fermesDe.has(q.ticket))
303
+ .map(q => (avant.has(q.cle) && !toutes ? { ...q, representee: true } : q))
304
+ : [];
305
+ const presentes = new Set(lisible ? aRendre.map(q => q.cle) : []);
295
306
  const enTexte = liste =>
296
307
  `${JSON.stringify(
297
308
  {
@@ -302,15 +313,18 @@ function relever(racine, circuits, { fermes, maintenant, rappelMs, toutes = fals
302
313
  null,
303
314
  2
304
315
  )}\n`;
316
+ // A question never presented, its ticket unread, is not written: the next reading gives it.
305
317
  const ecrit = enTexte(
306
- debout.map(q => {
307
- const r = avant.get(q.cle);
308
- return {
309
- cle: q.cle,
310
- depuis: r?.depuis ?? maintenant,
311
- presentee: presentes.has(q.cle) ? maintenant : r.presentee,
312
- };
313
- })
318
+ debout
319
+ .filter(q => presentes.has(q.cle) || avant.has(q.cle))
320
+ .map(q => {
321
+ const r = avant.get(q.cle);
322
+ return {
323
+ cle: q.cle,
324
+ depuis: r?.depuis ?? maintenant,
325
+ presentee: presentes.has(q.cle) ? maintenant : r.presentee,
326
+ };
327
+ })
314
328
  );
315
329
  let enFichier = '';
316
330
  try {
@@ -365,6 +379,10 @@ function enAttente(lus, racine, fermes) {
365
379
  lus.map(c => c.ticket)
366
380
  )
367
381
  : new Set();
382
+ // Tickets that do not read: no question can be told waiting, none is.
383
+ if (ferme === null) {
384
+ return [];
385
+ }
368
386
  return lus
369
387
  .filter(c => !ferme.has(c.ticket))
370
388
  .sort((a, b) => a.ticket.localeCompare(b.ticket, 'en'));
@@ -381,7 +399,7 @@ function enAttente(lus, racine, fermes) {
381
399
  * its circuit ended without its issue (`interrompu`) and its stop (`arret`).
382
400
  * @param {string} racine the root of the repository
383
401
  * @param {import('./circuits-du-serveur.mjs').CircuitDuServeur[]} circuits
384
- * @param {{ fermes?: (racine: string, ids: string[]) => Set<string>, sauf?: Set<string> }} options
402
+ * @param {{ fermes?: (racine: string, ids: string[]) => Set<string> | null, sauf?: Set<string> }} options
385
403
  * @returns {{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string, interrompu: boolean, arret: string | null }[]}
386
404
  */
387
405
  export function questionsEnAttente(
@@ -420,7 +438,7 @@ const aucunFerme = () => new Set();
420
438
  * <fluxRouges>: bd by default) is given as a batch of its own, once per run (`adresse`: the
421
439
  * workflow, the URL of the run, the commit), and again at another run; taken up or closed, it is
422
440
  * no longer given.
423
- * @param {{ racine: string, fermes?: (racine: string, ids: string[]) => Set<string>, pas?: number, signal?: AbortSignal, circuitsDe?: (racine: string, options?: { integres?: boolean }) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]>, fluxRouges?: (racine: string) => { ticket: string, adresse: string }[] | Promise<{ ticket: string, adresse: string }[]>, maintenant?: () => number, rappel?: number }} options
441
+ * @param {{ racine: string, fermes?: (racine: string, ids: string[]) => Set<string> | null, pas?: number, signal?: AbortSignal, circuitsDe?: (racine: string, options?: { integres?: boolean }) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]>, fluxRouges?: (racine: string) => { ticket: string, adresse: string }[] | Promise<{ ticket: string, adresse: string }[]>, maintenant?: () => number, rappel?: number }} options
424
442
  * @returns {Promise<{ ticket: string, etape: string, question: string, qui: string, commande: string, cle: string, representee?: boolean, integre?: boolean }[]>}
425
443
  * @throws {Error} another wait runs
426
444
  */
@@ -596,7 +614,7 @@ export function texteDesQuestions(questions) {
596
614
  * The circuits are read once, by <circuitsDe> (one call to the Temporal server,
597
615
  * scripts/circuits-du-serveur.mjs, by default); a server that does not answer is said, and no
598
616
  * question goes up.
599
- * @param {{ fermes?: (racine: string, ids: string[]) => Set<string>,
617
+ * @param {{ fermes?: (racine: string, ids: string[]) => Set<string> | null,
600
618
  * circuitsDe?: (racine: string) => Promise<import('./circuits-du-serveur.mjs').CircuitDuServeur[]>,
601
619
  * ticketsDe?: (racine: string) => import('./file-des-tickets.mjs').TicketDeBeads[] }} options
602
620
  * @returns {Promise<string>}