@roomi-fields/grillhouse 0.24.2 → 0.24.4

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.
@@ -25,12 +25,23 @@
25
25
  // npx grillhouse circuit <ticket> --etendre <paquet>[,<paquet>…] [--contexte <texte>]
26
26
  // npx grillhouse circuit <ticket> --arreter [--contexte <motif>]
27
27
  //
28
+ // The run is a daemon (scripts/demon.mjs), as daemon(3) and `setsid --fork` make one: the command
29
+ // launches a relay,
30
+ // which launches the run in a session of its own and ends at once, so that the run is neither in
31
+ // the caller's process group nor under it in the tree of processes, and goes on to its end when
32
+ // its caller dies (BP 320.8: the circuit, a background command of the supervisor's session, died
33
+ // with it). The caller relays the run's output to its own streams while it lives, and ends on the
34
+ // run's exit code; the state names the run (`processus` and its start `depart`), which the board
35
+ // reads, and a second run of the ticket while it lives is refused (exit 2), `--arreter` stopping
36
+ // it.
37
+ //
28
38
  // The circuit decides on structured results only (scripts/resultats.mjs, the one module of their
29
39
  // formats), as Bazel's Build Event Protocol and the JUnit reports carry the outcome of a build:
30
40
  // the sheet that ends each session, the summaries of Turborepo, the JSON reports of Vitest and the
31
41
  // SARIF of the guards. It reads no comment, no answer and no log to decide (a guard holds it:
32
42
  // tests/unit/circuit-sans-texte-libre.spec.ts); the handovers at the ticket are for the human and
33
- // for the next session of their author, the log for the human.
43
+ // for the next session of their author, the log for the human. Each header of the log, a step's or
44
+ // a session's, dates it in local time with its offset (ISO 8601), one time for the whole log.
34
45
  //
35
46
  // - The plan is read in the ticket's title (`bd show <ticket> --json`), after its last « — »,
36
47
  // separated by commas: each one a path (`packages/<nom>`, or `.`), or the name of a package,
@@ -43,12 +54,14 @@
43
54
  // description and notes, the context), writes the plan in its sheet: its criteria, the packages
44
55
  // to touch, and its open questions, each with its piece; it surveys the components the ticket
45
56
  // reaches by `npx grillhouse composants-affectes <ticket>` (scripts/composants-affectes.mjs),
46
- // which the circuit plays no more. A package the repository does not hold, or one named twice,
47
- // makes the sheet out of conformity. The circuit writes the plan at the ticket (`bd update
48
- // --title -d`): the packages end its title, the list the envelope of every later session
49
- // writes; the criteria already written stay as they are, the owner's decision, and the criteria
50
- // of the sheet, those the plan adds, follow them, numbered after them (a change or a removal of
51
- // a criterion written is an open question of the sheet); the open questions a section
57
+ // which the circuit plays no more as a step. A package the repository does not hold, one named
58
+ // twice, or a component of the survey of the plan (`releve`, which the circuit plays with no
59
+ // session to check the sheet) that the sheet neither puts in its packages nor sets apart with
60
+ // its reason (`ecartes`, written at the ticket) makes the sheet out of conformity. The circuit
61
+ // writes the plan at the ticket (`bd update --title -d`): the packages end its title, the list the envelope of every later
62
+ // session writes; the criteria already written stay as they are, the owner's decision, and the
63
+ // criteria of the sheet, those the plan adds, follow them, numbered after them (a change or a
64
+ // removal of a criterion written is an open question of the sheet); the open questions a section
52
65
  // « Questions ouvertes » after them. Each writing starts again from the description before the
53
66
  // plan. Then one session of the questionneur out of the envelope, read-only (no tool of
54
67
  // writing, every write of bd refused, scripts/droits.mjs), as Amazon's bar raiser, a cockpit's
@@ -66,12 +79,12 @@
66
79
  // question the explorateur leaves without an answer) stops at « questionnement », the open questions as its piece, a
67
80
  // question for the supervisor: he changes the plan (`bd update`) or keeps it, then
68
81
  // `--reprendre` lets the plan pass as it is then, from the testwriter. Nothing open, the plan
69
- // passes (`plan`, its fingerprint); a plan that passed, its title and description unchanged
70
- // since, passes with no session.
82
+ // passes (`plan`, its fingerprint: its title and its criteria); a plan that passed, its title
83
+ // and criteria unchanged since, passes with no session, whatever else of its description
84
+ // changed.
71
85
  // - Each session is a launch of scripts/enveloppe/lancer.sh, a child process the circuit waits
72
86
  // for, in its own process group, its errors written to a file: a session outlives the death of
73
- // its circuit (its caller dead, the circuit with it), and the state names its group while it
74
- // runs. Its plan, the packages it writes (`--paquets`, the envelope's list), is the plan of the
87
+ // its circuit, and the state names its group while it runs. Its plan, the packages it writes (`--paquets`, the envelope's list), is the plan of the
75
88
  // ticket, the whole copy in sight, the session at the root (`.`); lancer.sh builds the packages
76
89
  // of the plan and what they read before it opens. A session its lock stops on a write out of
77
90
  // the plan ends the circuit at « hors-plan », a question for the supervisor, the write as its
@@ -81,8 +94,11 @@
81
94
  // section absent without notes), both read with `bd show` at the session's launch, the report of
82
95
  // the step before (the proof, the reds of a check), the findings of the reviewer still open, the
83
96
  // last handover of the session's author at the ticket, for a developpeur without one yet the last
84
- // of the testwriter, else « aucune » (no verdict), and the line `CONTEXTE :`: the text of
85
- // `--contexte`, for each agent of the run. The session's own exit code is the one lancer.sh
97
+ // of the testwriter, else « aucune » (no verdict), the line `CONTEXTE :`: the text of
98
+ // `--contexte`, for each agent of the run, and the references 4.2 regenerates, each with its
99
+ // files (`lesReferences`), so that no session stops on what the circuit writes itself (BP
100
+ // 320.8: a developpeur, code and tests green, stopped on a ceiling, the debt and the index).
101
+ // The session's own exit code is the one lancer.sh
86
102
  // writes to `.claude/worktrees/<ticket>.fin`; a launch that leaves none stopped before its
87
103
  // session.
88
104
  // - Each session of the explorateur, the questionneur, the testwriter, the developpeur and the
@@ -235,33 +251,36 @@
235
251
  // commande, fichiers, tests, gardes }`, its name, the shell command that writes it again from the
236
252
  // root of the copy, the files it writes (paths, directories or glob patterns, `*` and `**`, from
237
253
  // the root, as the inputs of Turborepo), the test files that judge it, as `rustc --bless` ties a
238
- // test to its expected outputs, and the guards of the project that judge it, by the name their
239
- // SARIF finding carries (its guard or its rule). The frame's references follow in every project
240
- // (REFERENCES_DU_CADRE): the files the frame generates, each judged by a guard of the frame, by
241
- // the names its findings carry (the index of the interfaces, the turbo.json of the packages, the
242
- // API reports), and the known debt of the guards; a reference of the project whose first file
243
- // is one of theirs replaces it. A final pass with a red of a reference (a failed test of one of
254
+ // test to its expected outputs, `lit`, the files it reads that another reference writes, and the
255
+ // guards of the project that judge it, by the name their SARIF finding carries (its guard or its
256
+ // rule). The frame's references follow in every project (REFERENCES_DU_CADRE): the files the
257
+ // frame generates, each judged by a guard of the frame, by the names its findings carry (the
258
+ // index of the interfaces, which reads the interfaces, the turbo.json of the packages, the API
259
+ // reports, which write the generated part of the interfaces), and the known debt of the guards;
260
+ // a reference of the project whose first file is one of theirs replaces it. A final pass with a red of a reference (a failed test of one of
244
261
  // their test files, a finding of one of their guards, whatever file it aims at, or a failed test
245
262
  // or a finding on a file a reference of the project covers), mixed with other reds or not, or a
246
263
  // guard's note of a key of the debt inscribed above what it finds (`a-elaguer`, the pass green
247
264
  // or not), sends no developpeur: the gesture `regeneration`, once for that pass. The circuit
248
265
  // keeps the copy as a lot, runs the command of each reference concerned on the whole copy (the
249
266
  // debt lowered from the notes of the pass, its guards not played again), out of the envelope,
250
- // under the lock of the machine, its output added to the log, keeps the copy again on that lot, then plays the final pass restricted to what the regeneration changed and its
267
+ // under the lock of the machine, its output added to the log, then, as make remakes the targets
268
+ // that depend on an output, the command of each reference that reads a file one has just
269
+ // written, after it (the index after the API reports), keeps the copy again on that lot, then plays the final pass restricted to what the regeneration changed and its
251
270
  // dependents (`--filter=...[<avant>...<après>] --filter=//`); each red of the pass before in a
252
271
  // package that pass does not play again stands, and a regeneration that changes nothing plays no
253
272
  // pass, every red of the pass before standing. What remains goes each to its owner, as any red
254
273
  // of the final pass; a ceiling never rises (its command lowers it), so a lot beyond it stays red.
255
274
  // That pass green after a whole one keeps its tree as verified. The files regenerated stay in
256
- // the copy: the lot carries them, and the reviewer reads them with the rest of the lot, the
257
- // step's report among the circuit's. A reference of the project changed that the ticket's
258
- // description names neither by its name nor by one of its files, a file changed that the files
259
- // of no reference run cover, or a command that fails stops at « references » (23): a command of
275
+ // the copy: the lot carries them, without a word of the plan, as a genrule writes its output,
276
+ // and the reviewer reads them with the rest of the lot, the step's report among the circuit's. A
277
+ // file changed that the files of no reference run cover, or a command that fails stops at
278
+ // « references » (23): a command of
260
279
  // the project at a code other than 0, one of the frame on a real failure alone (not found, killed
261
280
  // by a signal), since its code also judges the reds it leaves (`npm run api` refuses beside
262
281
  // them), which the pass that follows judges. The stop leaves the copy restored as it was before
263
- // the regeneration, each reference and file named, a
264
- // question for the supervisor; the state keeps the references to regenerate and the reds of the
282
+ // the regeneration, a question for the supervisor that carries each deviation (the command and
283
+ // its code, the file), as the comment at the ticket does; the state keeps the references to regenerate and the reds of the
265
284
  // pass before (`aRegenerer`), for a regeneration resumed.
266
285
  // - The proof, the checks and the final pass are heavy passes: each holds the lock of the machine
267
286
  // (scripts/verrou-de-machine.mjs), shared by every repository of the machine, and waits, the
@@ -347,8 +366,9 @@
347
366
  // live in the base of the run (scripts/vitest-config/base-de-passe.mjs), removed at its end.
348
367
  // - The state is `.claude/worktrees/<ticket>.circuit.json`, written again at each step and at the
349
368
  // start and end of each session: `{ etape, tentative, code, raison, rapport, finale, boucles,
350
- // seance, question, questionnement, processus, paquets, constats, verifie, mene, reprise,
351
- // journal }`; `processus` the process of the circuit that writes it; `questionnement` the work
369
+ // seance, question, questionnement, processus, depart, paquets, constats, verifie, mene, reprise,
370
+ // journal }`; `processus` the process of the circuit that writes it, `depart` its start (field
371
+ // 22 of /proc/<pid>/stat), which together name it, a number alone being reused; `questionnement` the work
352
372
  // on the plan under way (`{ objet, role, seance }`: the plan, the explorateur or the
353
373
  // questionneur, its session), null otherwise; `etape` is the state's name of a numbered step of
354
374
  // the process (scripts/etapes.mjs: testwriter 2, preuve 2.1, developpeur 3, controles 3.1, or 4.1
@@ -365,7 +385,7 @@
365
385
  // itself while it runs, null otherwise; `reprise` the session of the testwriter or developpeur
366
386
  // its relaunches resume, `{ agent, seance }`, null before any.
367
387
  // - `--reprendre` starts again at the step of the state, its report given to the next session,
368
- // after any stop, the death of the circuit with its caller included. A session the state names
388
+ // after any stop, the death of the circuit included. A session the state names
369
389
  // that still runs is waited for first, and stopped when it stands still as long as a motionless
370
390
  // session. On a stop « questionnement », it lets the plan pass as it is then (the supervisor
371
391
  // changed it or kept it), from the testwriter.
@@ -380,9 +400,10 @@
380
400
  // package of the plan that depends on it (its package.json), else at its end, said at the ticket
381
401
  // (`Circuit · plan : le superviseur étend le plan à …`); then the step under way resumes as
382
402
  // after `--reprendre`, on the plan extended, the question as its context with the text of
383
- // `--contexte`. The plan so extended has passed (`plan`, its fingerprint): neither the
384
- // explorateur nor the questionneur works on it again. A package the repository does not hold is
385
- // refused, exit 2.
403
+ // `--contexte`; a stop « sans-livraison » on the developpeur's sending to the testwriter
404
+ // resumes at the testwriter, the role it names. The plan so extended has passed (`plan`, its
405
+ // fingerprint): neither the explorateur nor the questionneur works on it again. A package the
406
+ // repository does not hold is refused, exit 2.
386
407
  // - `--arreter` stops the circuit on the supervisor's word, as a pipeline cancelled: a circuit
387
408
  // running on the ticket (the state's `processus`, alive) stops, SIGTERM then SIGKILL, and so does
388
409
  // the session it led (`seance`); the state keeps its step, its stop « arrete », its question
@@ -422,9 +443,11 @@
422
443
  // RENDU), 17 integration (the integration script refuses the lot, or the queue reopens the
423
444
  // ticket), 19 hors-portee (a testwriter or developpeur whose sheet says BLOQUÉ, without a
424
445
  // sending to the testwriter), 20 besoin (a testwriter or developpeur whose sheet says BESOIN, a
425
- // reviewer whose sheet carries a `question`), 22 questionnement (questions of the plan left open
426
- // after the explorateur's answer), 23 references (a regeneration of 4.2 the plan does not
427
- // cover, or whose command fails), 24 hors-plan (a testwriter or developpeur session its lock
446
+ // reviewer whose sheet carries a `question`, or a ticket labelled `arbitrage` whose arbitrage
447
+ // `refusArbitrage` of scripts/integration/integrer.mjs refuses, at the launch or a resumption,
448
+ // before any session), 22 questionnement (questions of the plan left open
449
+ // after the explorateur's answer), 23 references (a regeneration of 4.2 that changes a file
450
+ // no reference writes, or whose command fails), 24 hors-plan (a testwriter or developpeur session its lock
428
451
  // stops on a write out of the plan, `<ticket>.hors-plan` that lancer.sh writes), each a question
429
452
  // for the supervisor; 75 a-repasser (a check or the integration still at 75 once played again,
430
453
  // or the branch still in the queue), the gesture `a-repasser`.
@@ -473,6 +496,7 @@ import {
473
496
  SUPERVISEUR,
474
497
  } from './etapes.mjs';
475
498
  import { paquets } from './paquets.mjs';
499
+ import { releve } from './composants-affectes.mjs';
476
500
  import { ecrire as ecrireAuRegistre, ligneDEtape, transcriptionsDeLaCopie } from './registre.mjs';
477
501
  import { FICHIER as DETTE } from './dette.mjs';
478
502
  import {
@@ -489,6 +513,7 @@ import {
489
513
  } from './resultats.mjs';
490
514
  import { AUTEUR_DE_LA_FILE } from './integration/file.mjs';
491
515
  import { dossierCommun, lireEntrees } from './integration/file-attente.mjs';
516
+ import { refusArbitrage } from './integration/integrer.mjs';
492
517
  import { AUTEUR_DU_VERDICT } from './integration/verdict.mjs';
493
518
  import { attendreUnPeu } from './verrou-de-fichier.mjs';
494
519
  import { AttenteDeLaMachine, avecLaMachine } from './verrou-de-machine.mjs';
@@ -497,14 +522,18 @@ import { AVANCEMENT } from './vitest-config/avancement.mjs';
497
522
  import { NOMS_DES_GARDES } from './gardes-du-cadre.mjs';
498
523
  import { isTesterFile } from './verrous/verrou.mjs';
499
524
  import { A_REPASSER } from './vitest-config/pression.mjs';
500
- import { ouvrirBase, vivant } from './vitest-config/base-de-passe.mjs';
525
+ import { departDe, leMemeVivant, ouvrirBase, vivant } from './vitest-config/base-de-passe.mjs';
501
526
  import { GREFFON } from './cadre.mjs';
527
+ import { executerEnDemon } from './demon.mjs';
502
528
 
503
529
  // The time a session's transcripts may stand still before the circuit stops it.
504
530
  export const IMMOBILE_MS = 20 * 60 * 1000;
505
531
  // The exit code of each stop, from the list of the steps and stops.
506
532
  export { ARRETS };
507
533
  const CODE_USAGE = 2;
534
+ // The start of this process (departDe), which the state writes beside its number: a number alone
535
+ // may name another process once reused.
536
+ const DEPART = departDe(process.pid);
508
537
  // The bounded loops, each declared with its step (scripts/etapes.mjs, `boucles`): the testwriter is
509
538
  // relaunched twice at most after a failed proof (three sessions); the developpeur has three
510
539
  // sessions, the last on the strong model; the third RENDU of one ticket stops the circuit.
@@ -561,20 +590,24 @@ const generateur = (script, ...args) =>
561
590
  // frame generates, each judged by a guard of the frame and written again by its generator, whose
562
591
  // code the circuit does not read (a real failure aside): what it writes, then the pass that
563
592
  // follows, judge it; and the known debt of the guards, lowered from the notes of the final pass (`dette.mjs --abaisser`,
564
- // `abaisser`: its command names the file of those notes). Each `{ nom, commande, fichiers,
565
- // gardes }`, `gardes` the names the findings its regeneration lifts carry (their guard or their
566
- // rule).
593
+ // `abaisser`: its command names the file of those notes). Each `{ nom, commande, fichiers, lit,
594
+ // gardes }`, `lit` the files of the copy it reads that another reference writes (as the
595
+ // prerequisites of a rule of make: the index reads the interfaces, whose generated part the API
596
+ // reports write), `gardes` the names the findings its regeneration lifts carry (their guard or
597
+ // their rule).
567
598
  const REFERENCES_DU_CADRE = [
568
599
  {
569
600
  nom: "l'index des interfaces",
570
601
  commande: generateur('index-interfaces.mjs'),
571
602
  fichiers: ['docs/agents/index-des-interfaces.md'],
603
+ lit: ['docs/INTERFACE.md', '**/docs/INTERFACE.md'],
572
604
  gardes: ['index-interfaces'],
573
605
  },
574
606
  {
575
607
  nom: 'les turbo.json des paquets',
576
608
  commande: generateur('turbo-des-paquets.mjs', '--ecrire'),
577
609
  fichiers: ['turbo.json', 'turbo.jsonc', '**/turbo.json'],
610
+ lit: [],
578
611
  gardes: ['turbo-des-paquets'],
579
612
  },
580
613
  {
@@ -586,12 +619,14 @@ const REFERENCES_DU_CADRE = [
586
619
  '**/docs/INTERFACE.api.md',
587
620
  '**/docs/INTERFACE.md',
588
621
  ],
622
+ lit: [],
589
623
  gardes: ['rapport-api', 'partie-generee'],
590
624
  },
591
625
  {
592
626
  nom: 'la dette des gardes',
593
627
  commande: generateur('dette.mjs', '--abaisser', '<notes>'),
594
628
  fichiers: [DETTE],
629
+ lit: [],
595
630
  gardes: [],
596
631
  abaisser: true,
597
632
  },
@@ -602,8 +637,8 @@ const GABARIT = path.join(GREFFON, 'skills', 'pitmaster', 'references', 'consign
602
637
 
603
638
  // A stop of the circuit: its name (a key of ARRETS) and its report; for a stop of the checks, its
604
639
  // reds read in the structured results (`{ paquet, texte, detail }`) and its motive, the report
605
- // without their list; the outcome of the step it stops, when it has one (a proof's), which the
606
- // bilan reads; and what its montée carries beyond the question of its kind (scripts/etapes.mjs,
640
+ // without their list; the outcome of the step it stops, when it has one (a proof's, the checks'
641
+ // with their reds), which the bilan reads; and what its montée carries beyond the question of its kind (scripts/etapes.mjs,
607
642
  // MONTEES): its `piece` (file:line, or command and output), its own `question`, and who must
608
643
  // answer it (`qui`, the owner for the reviewer's question).
609
644
  class Arret extends Error {
@@ -810,8 +845,9 @@ function lesCommentaires(ctx) {
810
845
  }));
811
846
  }
812
847
 
813
- // The ticket's description (its criteria), notes and title as Beads holds them at this moment, read
814
- // at the launch of each session: `{ description, notes, titre }`; a failed read throws.
848
+ // The ticket's description (its criteria), notes, title and labels as Beads holds them at this
849
+ // moment, read at the launch of each session: `{ description, notes, titre, labels }`; a failed
850
+ // read throws.
815
851
  function leTicket(ctx) {
816
852
  const r = ctx.bd('show', ctx.ticket, '--json');
817
853
  if (r.status !== 0) {
@@ -824,6 +860,7 @@ function leTicket(ctx) {
824
860
  description: String(t.description ?? ''),
825
861
  notes: String(t.notes ?? ''),
826
862
  titre: String(t.title ?? ''),
863
+ labels: Array.isArray(t.labels) ? t.labels.map(String) : [],
827
864
  };
828
865
  }
829
866
 
@@ -879,7 +916,7 @@ function commenter(ctx, etape, texte) {
879
916
  // The report of a proof or of checks: its line at the ticket, and its report kept for the
880
917
  // reviewer, <rapport> when the comment carries only its summary, beside its outcome <resultat>,
881
918
  // which the bilan reads (scripts/bilan.mjs): for a proof `{ ok, rouges, justifies, sans, casses,
882
- // anciens, vide }`, for checks `{ issue, finale }`.
919
+ // anciens, vide }`, for checks `{ issue, finale, rouges }`.
883
920
  function ecrireRapport(ctx, etape, texte, resultat, rapport = texte) {
884
921
  commenter(ctx, etape, texte);
885
922
  inscrire(ctx, {
@@ -903,6 +940,7 @@ function ecrireEtat(ctx, etat) {
903
940
  avancement: null,
904
941
  ...etat,
905
942
  processus: process.pid,
943
+ depart: DEPART,
906
944
  paquets: ctx.paquets,
907
945
  constats: ctx.constats ?? [],
908
946
  verifie: ctx.verifie ?? null,
@@ -935,9 +973,19 @@ function inscrireEtape(ctx, { etape, debut }) {
935
973
  }
936
974
  }
937
975
 
938
- // The header line of a step or a session in the ticket's log.
976
+ // The time <d> in local time with its offset, to the second, as ISO 8601 writes it and as the
977
+ // envelope dates the header of a session (`date -Iseconds`): « 2026-10-25T12:42:11+01:00 ».
978
+ function heureLocale(d = new Date()) {
979
+ const deux = n => String(n).padStart(2, '0');
980
+ const decalage = -d.getTimezoneOffset();
981
+ const a = Math.abs(decalage);
982
+ return `${d.getFullYear()}-${deux(d.getMonth() + 1)}-${deux(d.getDate())}T${deux(d.getHours())}:${deux(d.getMinutes())}:${deux(d.getSeconds())}${decalage < 0 ? '-' : '+'}${deux(Math.floor(a / 60))}:${deux(a % 60)}`;
983
+ }
984
+
985
+ // The header line of a step or a session in the ticket's log, in local time, as the envelope
986
+ // dates a session's.
939
987
  const entete = (ctx, etape) =>
940
- appendFileSync(ctx.journal, `=== ${new Date().toISOString()} · circuit · ${etape} ===\n`);
988
+ appendFileSync(ctx.journal, `=== ${heureLocale()} · circuit · ${etape} ===\n`);
941
989
 
942
990
  // The latest moment a transcript of the copy moved, or 0.
943
991
  function derniereTrace(dossier) {
@@ -1202,6 +1250,9 @@ async function seance(ctx, role, { tentative, rapport, fort, derniere }) {
1202
1250
  rapport: rapport ?? 'aucun',
1203
1251
  constats,
1204
1252
  passation: passation?.text ?? 'aucune',
1253
+ references: lesReferences(ctx)
1254
+ .map(r => `- ${r.nom} : ${r.fichiers.map(f => `\`${f}\``).join(', ')}`)
1255
+ .join('\n'),
1205
1256
  };
1206
1257
  return await jusquALaFiche(ctx, role, consigne(valeurs), { fort, neuve: role });
1207
1258
  }
@@ -1604,12 +1655,13 @@ function laPasseFinale(ctx) {
1604
1655
  }
1605
1656
 
1606
1657
  // The references of the circuit: those the project declares in the package.json of the copy
1607
- // (`grillhouse.references`), each `{ nom, commande, fichiers, tests, gardes }` with a name, a
1608
- // command and files, `tests` and `gardes` arrays when given, empty when not; then the frame's
1658
+ // (`grillhouse.references`), each `{ nom, commande, fichiers, tests, lit, gardes }` with a name, a
1659
+ // command and files, `tests`, `lit` and `gardes` arrays when given, empty when not; then the frame's
1609
1660
  // (REFERENCES_DU_CADRE, `cadre`), each but one whose first file a reference of the project covers,
1610
1661
  // which replaces it.
1611
1662
  function lesReferences(ctx) {
1612
- const l = lireJson(path.join(ctx.copie, 'package.json'))?.grillhouse?.references;
1663
+ const l = lireJson(path.join(existsSync(ctx.copie) ? ctx.copie : ctx.racine, 'package.json'))
1664
+ ?.grillhouse?.references;
1613
1665
  const duProjet = (Array.isArray(l) ? l : [])
1614
1666
  .filter(
1615
1667
  r =>
@@ -1618,9 +1670,16 @@ function lesReferences(ctx) {
1618
1670
  Array.isArray(r.fichiers) &&
1619
1671
  r.fichiers.length > 0 &&
1620
1672
  (r.tests === undefined || Array.isArray(r.tests)) &&
1673
+ (r.lit === undefined || Array.isArray(r.lit)) &&
1621
1674
  (r.gardes === undefined || Array.isArray(r.gardes))
1622
1675
  )
1623
- .map(r => ({ ...r, tests: r.tests ?? [], gardes: r.gardes ?? [], cadre: false }));
1676
+ .map(r => ({
1677
+ ...r,
1678
+ tests: r.tests ?? [],
1679
+ lit: r.lit ?? [],
1680
+ gardes: r.gardes ?? [],
1681
+ cadre: false,
1682
+ }));
1624
1683
  const duCadre = REFERENCES_DU_CADRE.filter(
1625
1684
  c => !duProjet.some(r => couvertPar(r.fichiers, c.fichiers[0]))
1626
1685
  ).map(c => ({ ...c, tests: [], cadre: true }));
@@ -1652,27 +1711,28 @@ function referencesDesRouges(ctx, lieux, aElaguer = false) {
1652
1711
  );
1653
1712
  }
1654
1713
 
1655
- // The regeneration of the references named <noms> (4.2): the copy kept as a lot on the one the
1656
- // last review read (or HEAD), each command run on the whole copy, the copy kept again on that lot.
1657
- // `{ texte, regenerees, fichiers, restreinte }`: the report, the names of the references changed,
1658
- // the files changed, and the range of the final pass that follows (null when nothing changed: no
1659
- // pass plays again, and the reds stand). A file the frame generates follows from the lot, as the
1660
- // output of a genrule, and the reviewer reads its difference; a reference of the project changed
1661
- // that the ticket's description does not name (its name or one of its files), a file changed that
1662
- // none of the references run declares, or a command that fails (a reference of the project at
1663
- // another code than 0, one of the frame on a real failure alone) restores the copy as it was and
1664
- // stops at « references ».
1714
+ // The regeneration of the references named <noms> (4.2), as make remakes a target and then the
1715
+ // targets that depend on its outputs: the copy kept as a lot on the one the last review read (or
1716
+ // HEAD), each command run on the whole copy, in their order; a reference that reads (`lit`) a file
1717
+ // another one has just written runs after it, once for each reference whose writing calls for it;
1718
+ // then the copy kept again on that lot. `{ texte, regenerees, fichiers, restreinte }`: the report,
1719
+ // the names of the references changed, the files changed, and the range of the final pass that
1720
+ // follows (null when nothing changed: no pass plays again, and the reds stand). A file a reference
1721
+ // writes follows from the lot, as the output of a genrule, without a word of the plan, and the
1722
+ // reviewer reads its difference; a file changed that none of the references run declares, or a
1723
+ // command that fails (a reference of the project at another code than 0, one of the frame on a
1724
+ // real failure alone) restores the copy as it was and stops at « references », each deviation in
1725
+ // its question.
1665
1726
  function regenerer(ctx, noms, notes = []) {
1666
1727
  // The notes of the debt, in a file of the run, which the command that lowers it reads.
1667
1728
  const fichierDesNotes = path.join(ctx.base.dossier, 'dette-a-abaisser.json');
1668
- const refs = lesReferences(ctx)
1669
- .filter(r => noms.includes(r.nom))
1670
- .map(r =>
1671
- r.abaisser
1672
- ? { ...r, commande: generateur('dette.mjs', '--abaisser', JSON.stringify(fichierDesNotes)) }
1673
- : r
1674
- );
1675
- if (refs.some(r => r.abaisser)) writeFileSync(fichierDesNotes, `${JSON.stringify(notes)}\n`);
1729
+ const toutes = lesReferences(ctx).map(r =>
1730
+ r.abaisser
1731
+ ? { ...r, commande: generateur('dette.mjs', '--abaisser', JSON.stringify(fichierDesNotes)) }
1732
+ : r
1733
+ );
1734
+ const aJouer = toutes.filter(r => noms.includes(r.nom));
1735
+ if (aJouer.some(r => r.abaisser)) writeFileSync(fichierDesNotes, `${JSON.stringify(notes)}\n`);
1676
1736
  const avant = garderLeLot(ctx, relectureDAvant(ctx)?.lot.commit);
1677
1737
  if (!avant) {
1678
1738
  throw new Arret(
@@ -1683,47 +1743,62 @@ function regenerer(ctx, noms, notes = []) {
1683
1743
  // The command of a reference of the frame is judged by what it writes, then by the pass that
1684
1744
  // follows, never by its code, which also judges the reds it leaves (`npm run api` refuses beside
1685
1745
  // them): a real failure alone counts; a reference of the project, by its code.
1686
- const echecs = refs
1687
- .map(r => ({ r, ...commandeDeReference(ctx, r.commande) }))
1688
- .filter(x => x.panne || (!x.r.cadre && x.code !== 0))
1689
- .map(
1690
- x =>
1691
- `- ${x.r.nom} : \`${x.r.commande}\` rend le code ${x.code}${x.panne ? ' (une panne)' : ''}.`
1692
- );
1746
+ const refs = [];
1747
+ const echecs = [];
1748
+ const appelees = new Set();
1749
+ let arbre = avant.arbre;
1750
+ while (aJouer.length) {
1751
+ const r = aJouer.shift();
1752
+ const x = commandeDeReference(ctx, r.commande);
1753
+ if (!refs.includes(r)) refs.push(r);
1754
+ if (x.panne || (!r.cadre && x.code !== 0)) {
1755
+ echecs.push(
1756
+ `- ${r.nom} : \`${r.commande}\` rend le code ${x.code}${x.panne ? ' (une panne)' : ''}.`
1757
+ );
1758
+ }
1759
+ // The references that read a file this command wrote run after it.
1760
+ const suivant = arbreDeLaCopie(ctx);
1761
+ const ecrits = suivant ? differenceDesLots(ctx, arbre, suivant) : [];
1762
+ arbre = suivant ?? arbre;
1763
+ for (const s of toutes) {
1764
+ const appel = `${r.nom}\0${s.nom}`;
1765
+ if (s === r || appelees.has(appel) || !ecrits.some(f => couvertPar(s.lit, f))) continue;
1766
+ appelees.add(appel);
1767
+ if (!aJouer.includes(s)) aJouer.push(s);
1768
+ }
1769
+ }
1693
1770
  const apres = garderLeLot(ctx, avant.commit);
1694
1771
  const fichiers = apres ? differenceDesLots(ctx, avant.commit, apres.commit) : [];
1695
- const description = leTicket(ctx).description;
1696
1772
  const siens = r => fichiers.filter(f => couvertPar(r.fichiers, f));
1697
1773
  const regenerees = refs.filter(r => siens(r).length);
1698
- const nommee = r => r.cadre || [r.nom, ...r.fichiers].some(x => description.includes(x));
1699
1774
  const horsDeclaration = fichiers.filter(f => !refs.some(r => couvertPar(r.fichiers, f)));
1700
1775
  const ecarts = [
1701
1776
  ...echecs,
1702
1777
  ...(!apres ? ['- Le circuit ne garde pas la copie après la régénération (git échoue).'] : []),
1703
- ...regenerees
1704
- .filter(r => !nommee(r))
1705
- .map(
1706
- r =>
1707
- `- ${r.nom} change (${siens(r).join(', ')}), et le plan du ticket ne nomme pas ce changement (ni « ${r.nom} » ni ses fichiers).`
1708
- ),
1709
1778
  ...horsDeclaration.map(f => `- ${f} change, et aucune référence régénérée ne l'écrit.`),
1710
1779
  ];
1711
1780
  if (ecarts.length) {
1712
1781
  restaurer(ctx, avant.commit, fichiers);
1782
+ const difference =
1783
+ apres && fichiers.length
1784
+ ? [
1785
+ `La différence, avant d'être rendue : \`git diff ${avant.commit} ${apres.commit}\`, dans la copie du ticket.`,
1786
+ ]
1787
+ : [];
1713
1788
  throw new Arret(
1714
1789
  'references',
1715
1790
  [
1716
- `La régénération des références, sur la copie entière, s'arrête ; la copie est rendue telle qu'avant elle. Le superviseur fait nommer le changement au plan du ticket, puis \`--reprendre\`, ou fait corriger le lot qui le cause (\`--depuis developpeur\`).`,
1791
+ `La régénération des références, sur la copie entière, s'arrête ; la copie est rendue telle qu'avant elle. Le superviseur fait corriger la référence ou le lot qui cause l'écart (\`--depuis developpeur\`), ou \`--reprendre\` une fois la cause levée.`,
1717
1792
  '',
1718
1793
  ...ecarts,
1719
1794
  '',
1720
- ...(apres && fichiers.length
1721
- ? [
1722
- `La différence, avant d'être rendue : \`git diff ${avant.commit} ${apres.commit}\`, dans la copie du ticket.`,
1723
- ]
1724
- : []),
1795
+ ...difference,
1725
1796
  `Le journal du ticket : ${ctx.journal}`,
1726
- ].join('\n')
1797
+ ].join('\n'),
1798
+ {
1799
+ piece: [...ecarts, ...difference].join('\n'),
1800
+ question: `Les écarts de la régénération :\n${ecarts.join('\n')}`,
1801
+ }
1727
1802
  );
1728
1803
  }
1729
1804
  if (!fichiers.length) {
@@ -2192,16 +2267,30 @@ function mesureDeLaPreuve(ctx, liste, fichiers) {
2192
2267
  return runs;
2193
2268
  }
2194
2269
 
2270
+ // The full name of a test <nom> with each separator between a group and what it holds, « > » or
2271
+ // « › » between blanks, read as the blank that Vitest's full name puts there.
2272
+ const sansSeparateur = nom =>
2273
+ String(nom ?? '')
2274
+ .replace(/\s+[>›]\s+/g, ' ')
2275
+ .trim();
2276
+
2195
2277
  // The proof of the red, on every test of the lot: `{ ok, rouges, texte, resume }`, `texte` without
2196
2278
  // the list of the justified greens, which only the whole report, written to its file, holds. A
2197
2279
  // green test passes by the expected greens of the testwriter's sheets (`verts_attendus`), read at
2198
- // each proof; the measure plays again only when the copy changed (`mesureDeLaPreuve`).
2280
+ // each proof, a sheet without them justifying none; a test's full name is read whatever the
2281
+ // separator between its group and its title, a blank, or « > » as Vitest prints it, or « › » as
2282
+ // Jest and the report of the proof print it (`sansSeparateur`); the measure plays again only when
2283
+ // the copy changed (`mesureDeLaPreuve`).
2199
2284
  function preuve(ctx) {
2200
2285
  const fichiers = testsDuLot(ctx);
2201
2286
  const verts = fichesDe(ctx, 'testwriter').flatMap(f => f.verts_attendus ?? []);
2202
2287
  const raisonDuTest = (f, a) =>
2203
- verts.find(v => v.fichier === f && v.test && (v.test === a.nom || v.test === a.titre))
2204
- ?.raison ?? null;
2288
+ verts.find(
2289
+ v =>
2290
+ v.fichier === f &&
2291
+ v.test &&
2292
+ [a.nom, a.titre].some(n => sansSeparateur(v.test) === sansSeparateur(n))
2293
+ )?.raison ?? null;
2205
2294
  const duFichier = f => verts.find(v => v.fichier === f && !v.test) ?? null;
2206
2295
  const rouges = [];
2207
2296
  // The reds of the files of the lot, apart from the existing ones and the builds.
@@ -2848,18 +2937,26 @@ async function derouler(ctx, debut) {
2848
2937
  ? { arbre: arbreDeLaCopie(ctx), restreinte: regeneration.restreinte }
2849
2938
  : laPasseFinale(ctx);
2850
2939
  const k = controles(ctx, passeFinale, passe.restreinte, regeneration?.reportes ?? null);
2851
- const resultat = issue => ({ issue, finale: passeFinale });
2940
+ // The outcome the bilan reads (scripts/bilan.mjs): with the reds, each its place and its
2941
+ // text, by which it knows two checks that measured the same thing.
2942
+ const resultat = issue => ({
2943
+ issue,
2944
+ finale: passeFinale,
2945
+ rouges: k.rouges.map(r => `${r.paquet} : ${r.texte}`),
2946
+ });
2852
2947
  rapport = k.texte;
2853
2948
  // A developpeur who had nothing to deliver before these checks.
2854
2949
  const rien = ctx.rienALivrer ?? null;
2855
2950
  ctx.rienALivrer = null;
2856
- // A stop of the checks: <phrase>, then the report, its reds also kept apart, as its piece.
2951
+ // A stop of the checks: <phrase>, then the report, its reds also kept apart, as its piece;
2952
+ // the stop kept at the checks keeps their outcome.
2857
2953
  const arreter = (nom, phrase, lieu = null) => {
2858
2954
  const avant = phrase ? `${phrase}\n\n` : '';
2859
2955
  throw new Arret(nom, `${avant}${k.complet}`, {
2860
2956
  rouges: k.rouges,
2861
2957
  motif: `${avant}${k.sansListe}`,
2862
2958
  etape: lieu,
2959
+ resultat: lieu ? null : resultat(nom === 'a-repasser' ? 'a-repasser' : 'rouge'),
2863
2960
  });
2864
2961
  };
2865
2962
  const suivante = tentative + 1;
@@ -3224,9 +3321,19 @@ function rubrique(ctx, titre) {
3224
3321
  // The meta-frame, the frame's plugin's, read at the plugin's root (scripts/cadre.mjs).
3225
3322
  const METACADRE = path.join(GREFFON, 'METACADRE.md');
3226
3323
 
3227
- // The fingerprint of a plan, its title and its description.
3228
- const empreinteDuPlan = ({ titre, description }) =>
3229
- createHash('sha256').update(`${titre}\n${description}`).digest('hex');
3324
+ // The fingerprint of a plan, its title and its section of criteria, each line without its blank
3325
+ // lines: the rest of the description (an answer of the supervisor, the open questions, its notes)
3326
+ // is not the plan, as a CI replays a job only when its inputs move.
3327
+ const empreinteDuPlan = ({ titre, description }) => {
3328
+ const criteres = sectionsDe(description)
3329
+ .filter(deCriteres)
3330
+ .flatMap(s => [s.tete, ...s.lignes])
3331
+ .map(l => l.trim())
3332
+ .filter(Boolean);
3333
+ return createHash('sha256')
3334
+ .update([titre, ...criteres].join('\n'))
3335
+ .digest('hex');
3336
+ };
3230
3337
 
3231
3338
  // Whether the plan of fingerprint <empreinte> has passed: a plan whose questioning left no
3232
3339
  // question open, or the supervisor's resumption of its stop.
@@ -3315,26 +3422,47 @@ function ecrireLePlan(ctx, plan, description = null) {
3315
3422
  }
3316
3423
 
3317
3424
  // What makes the packages of the sheet <fiche> of the explorateur out of conformity, or null: a
3318
- // package that names neither a package nor a path of the repository, or one package named twice
3319
- // (by its name and by its path). A session that writes one is resumed once (`jusquALaFiche`).
3320
- function fautesDesPaquets(ctx, fiche) {
3321
- const dossiers = fiche.paquets.map(p => {
3425
+ // package that names neither a package nor a path of the repository, one package named twice
3426
+ // (by its name and by its path), or a component of the survey of the plan's description
3427
+ // <description> (scripts/composants-affectes.mjs, `releve`, played by the circuit with no
3428
+ // session, as it checks the packages) that the sheet neither puts in its packages nor sets apart
3429
+ // with its reason (`ecartes`). A session that writes one is resumed once (`jusquALaFiche`).
3430
+ function fautesDesPaquets(ctx, fiche, description) {
3431
+ const dossier = p => {
3322
3432
  try {
3323
3433
  return ctx.resoudre(p);
3324
3434
  } catch {
3325
3435
  return null;
3326
3436
  }
3327
- });
3437
+ };
3438
+ const dossiers = fiche.paquets.map(dossier);
3328
3439
  const inconnus = fiche.paquets.filter((p, i) => dossiers[i] === null);
3329
3440
  if (inconnus.length) {
3330
3441
  return `paquets : ${inconnus.join(', ')} ne nomme ni un paquet ni un chemin du dépôt`;
3331
3442
  }
3332
3443
  const doubles = fiche.paquets.filter((p, i) => dossiers.indexOf(dossiers[i]) !== i);
3333
- return doubles.length
3334
- ? `paquets : ${doubles.join(', ')} nomme un paquet déjà nommé dans le plan`
3444
+ if (doubles.length) {
3445
+ return `paquets : ${doubles.join(', ')} nomme un paquet déjà nommé dans le plan`;
3446
+ }
3447
+ const tenus = [...dossiers, ...(fiche.ecartes ?? []).map(e => dossier(e.composant))];
3448
+ const couvre = (d, c) => d === '.' || c === d || c.startsWith(`${d}/`);
3449
+ const racine = existsSync(ctx.copie) ? ctx.copie : ctx.racine;
3450
+ const absents = releve(racine, description).composants.filter(c => {
3451
+ const d = dossier(c);
3452
+ return d !== null && !tenus.some(t => t !== null && couvre(t, d));
3453
+ });
3454
+ return absents.length
3455
+ ? `paquets : ${absents.join(', ')}, que le relevé nomme, n'est ni dans les paquets ni dans les écartés (ecartes, avec sa raison)`
3335
3456
  : null;
3336
3457
  }
3337
3458
 
3459
+ // The components the sheet <fiche> of the explorateur sets apart, each with its reason, as the
3460
+ // circuit writes them at the ticket; empty without one.
3461
+ const ecartsDe = fiche =>
3462
+ (fiche.ecartes ?? []).length
3463
+ ? ` ; écartés : ${fiche.ecartes.map(e => `${e.composant} (${e.raison})`).join(' ; ')}`
3464
+ : '';
3465
+
3338
3466
  // The plan of the ticket (step 1 of scripts/etapes.mjs) before its testwriter, as an RFC: its
3339
3467
  // author writes it after surveying what exists, a review reads it once,
3340
3468
  // the author answers once, and what stays open goes to who decides. One session of the
@@ -3345,8 +3473,8 @@ function fautesDesPaquets(ctx, fiche) {
3345
3473
  // question it leaves without an answer stays open with its own. Each session's work is named in
3346
3474
  // the state while it runs (`questionnement`); the exchange is written at the ticket and its end
3347
3475
  // kept with the circuit's results (`questionnement`, which the bilan counts). A plan that has
3348
- // passed, its title and description unchanged since, passes. Null when nothing stays open (the
3349
- // plan passes, kept as `plan`); else the exit code of the question it goes up with,
3476
+ // passed, its title and criteria unchanged since (`empreinteDuPlan`), passes. Null when nothing
3477
+ // stays open (the plan passes, kept as `plan`); else the exit code of the question it goes up with,
3350
3478
  // « questionnement », the open questions as its piece, or the stop of a session that cannot end.
3351
3479
  async function lePlan(ctx) {
3352
3480
  if (planPasse(ctx, empreinteDuPlan(leTicket(ctx)))) return null;
@@ -3368,10 +3496,12 @@ async function lePlan(ctx) {
3368
3496
  ecrireEtat(ctx, etat());
3369
3497
  return fiche;
3370
3498
  };
3499
+ // The description before the plan, from which each sheet's plan is written.
3500
+ const avant = leTicket(ctx).description;
3371
3501
  const explorateur = {
3372
3502
  droits: horsDeLEnveloppe(ctx, EXPLORATEUR, 'sonnet'),
3373
3503
  id: randomUUID(),
3374
- valider: f => fautesDesPaquets(ctx, f),
3504
+ valider: f => fautesDesPaquets(ctx, f, decrireLePlan(avant, f.criteres, f.questions)),
3375
3505
  };
3376
3506
  try {
3377
3507
  const t = leTicket(ctx);
@@ -3399,7 +3529,7 @@ async function lePlan(ctx) {
3399
3529
  const ouvertesDuPlan = plan.questions.length ? `\n${lignesOuvertes(plan.questions)}` : 'aucune';
3400
3530
  dire(
3401
3531
  'plan',
3402
- `l'explorateur écrit le plan — paquets : ${plan.paquets.join(', ')} ; ${plan.criteres.length} critère(s) ajouté(s) ; questions ouvertes : ${ouvertesDuPlan}`
3532
+ `l'explorateur écrit le plan — paquets : ${plan.paquets.join(', ')}${ecartsDe(plan)} ; ${plan.criteres.length} critère(s) ajouté(s) ; questions ouvertes : ${ouvertesDuPlan}`
3403
3533
  );
3404
3534
  const ecrit = leTicket(ctx);
3405
3535
  const lu = await session(
@@ -3451,7 +3581,10 @@ async function lePlan(ctx) {
3451
3581
  );
3452
3582
  reponses = plan.reponses ?? [];
3453
3583
  const lignes = reponses.map(r => `${r.numero}. ${r.reponse} — ${r.texte}`).join('\n');
3454
- dire('questionnement', `la réponse de l'explorateur :\n${lignes || 'aucune'}`);
3584
+ dire(
3585
+ 'questionnement',
3586
+ `la réponse de l'explorateur${ecartsDe(plan)} :\n${lignes || 'aucune'}`
3587
+ );
3455
3588
  }
3456
3589
  // What stays open: the plan's own questions, then each question left without an answer.
3457
3590
  const ouvertes = [
@@ -3537,7 +3670,7 @@ async function terminer(cible) {
3537
3670
  // it, its session gone.
3538
3671
  async function arreterLeCircuit(ctx, e) {
3539
3672
  const pid = e.processus;
3540
- if (Number.isInteger(pid) && pid !== process.pid && vivant(pid)) {
3673
+ if (pid !== process.pid && leMemeVivant(pid, e.depart)) {
3541
3674
  commenter(
3542
3675
  ctx,
3543
3676
  'arret',
@@ -3581,8 +3714,11 @@ async function arreter(ctx, e) {
3581
3714
  // name of the repository, else a Usage): each one enters the title before the first package of
3582
3715
  // the plan whose package.json depends on it, else at its end, written by bd and said at the
3583
3716
  // ticket. With the state <e>, the run then resumes the step under way, as `--reprendre` does, the
3584
- // question of the stop and the text of `--contexte` as the context of its sessions; without one,
3585
- // it starts on the plan extended.
3717
+ // question of the stop and the text of `--contexte` as the context of its sessions; a stop
3718
+ // « sans-livraison » whose developpeur's last sheet sends the red to the testwriter (`renvoi`,
3719
+ // twice in a row) resumes at the step of the role it names, the testwriter's, as a retry plays the
3720
+ // job that failed. Without a state, it starts on the plan extended. The state the run resumes
3721
+ // from.
3586
3722
  function etendre(ctx, e) {
3587
3723
  const gagnes = [...new Set(ctx.etendre.map(ctx.resoudre))].filter(c => !ctx.paquets.includes(c));
3588
3724
  const liste = paquets(existsSync(ctx.copie) ? ctx.copie : ctx.racine);
@@ -3610,12 +3746,17 @@ function etendre(ctx, e) {
3610
3746
  'plan',
3611
3747
  `le superviseur étend le plan à ${ctx.etendre.join(', ')} : ${titre.split(' — ').at(-1)}.`
3612
3748
  );
3613
- if (!e) return;
3749
+ if (!e) return e;
3614
3750
  ctx.contexte =
3615
3751
  [e.question ? `${e.question.fait}\n\n${e.question.piece}` : null, ctx.contexte]
3616
3752
  .filter(Boolean)
3617
3753
  .join('\n\n') || null;
3618
3754
  ctx.reprendre = true;
3755
+ const renvoi =
3756
+ e.etape === CODE && e.raison === 'sans-livraison'
3757
+ ? fichesDe(ctx, 'developpeur').at(-1)?.renvoi
3758
+ : null;
3759
+ return renvoi?.role === 'testwriter' ? { ...e, etape: TESTS } : e;
3619
3760
  }
3620
3761
 
3621
3762
  export async function main(argv) {
@@ -3623,7 +3764,7 @@ export async function main(argv) {
3623
3764
  try {
3624
3765
  ctx = contexte(lireArguments(argv));
3625
3766
  mkdirSync(path.dirname(ctx.copie), { recursive: true });
3626
- const e = existsSync(ctx.etat) ? JSON.parse(readFileSync(ctx.etat, 'utf8')) : null;
3767
+ let e = existsSync(ctx.etat) ? JSON.parse(readFileSync(ctx.etat, 'utf8')) : null;
3627
3768
  // The findings of the reviewer still open, the lot the whole final pass verified, the session a
3628
3769
  // relaunch resumes, and the references a regeneration has to run, kept from one run to the next.
3629
3770
  ctx.constats = [...(e?.constats ?? [])];
@@ -3632,10 +3773,16 @@ export async function main(argv) {
3632
3773
  ctx.aRegenerer = e?.aRegenerer ?? null;
3633
3774
  // The supervisor's answers to a question: stop the circuit, or extend its plan and resume.
3634
3775
  if (ctx.arreter) return await arreter(ctx, e);
3776
+ // A circuit that outlives its caller is still the ticket's: no second run beside it.
3777
+ if (e && e.processus !== process.pid && leMemeVivant(e.processus, e.depart)) {
3778
+ throw new Usage(
3779
+ `un circuit tourne déjà sur ${ctx.ticket} (processus ${e.processus}) : il mène le ticket à sa fin, \`--arreter\` l'arrête.`
3780
+ );
3781
+ }
3635
3782
  if (ctx.etendre) {
3636
3783
  if (e?.etape === 'integre')
3637
3784
  throw new Usage(`--etendre : le lot de ${ctx.ticket} est intégré.`);
3638
- etendre(ctx, e);
3785
+ e = etendre(ctx, e);
3639
3786
  }
3640
3787
  // The supervisor's resumption of the questioning lets the plan pass as it is now.
3641
3788
  if (ctx.reprendre && e?.raison === 'questionnement') {
@@ -3652,6 +3799,23 @@ export async function main(argv) {
3652
3799
  const d = depart(ctx, e);
3653
3800
  // A session a dead circuit left running ends before this run launches its own.
3654
3801
  await attendreLaSeance(ctx, e?.seance);
3802
+ // A ticket labelled arbitrage starts and resumes only on the arbitrage its integration will
3803
+ // ask for: the integration's rule, before any session.
3804
+ const arbitrage = refusArbitrage({ id: ctx.ticket, ...leTicket(ctx) }, lesCommentaires(ctx));
3805
+ if (arbitrage) {
3806
+ return aLaFin(
3807
+ ctx,
3808
+ monter(ctx, {
3809
+ code: ARRETS.besoin,
3810
+ nom: 'besoin',
3811
+ rapport: arbitrage,
3812
+ piece: `$ bd show ${ctx.ticket} --json ; bd comments ${ctx.ticket} --json\n${arbitrage}`,
3813
+ question: `${arbitrage} L'arbitrage s'écrit au ticket (« ## Arbitrage — … », tranché ou répondu par le responsable), puis \`--reprendre\`.`,
3814
+ // From the testwriter, the plan comes first: the stop is at « 1 Plan ».
3815
+ etat: d.etape === TESTS ? { ...d, questionnement: { objet: 'plan' } } : d,
3816
+ })
3817
+ );
3818
+ }
3655
3819
  // From the testwriter: the plan, which the explorateur writes and the questionneur reads once.
3656
3820
  if (d.etape === TESTS) {
3657
3821
  const arret = await lePlan(ctx);
@@ -3669,6 +3833,7 @@ export async function main(argv) {
3669
3833
  }
3670
3834
  }
3671
3835
 
3836
+ // The entry: the run as a daemon (scripts/demon.mjs), apart from its caller.
3672
3837
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
3673
- process.exitCode = await main(process.argv.slice(2));
3838
+ process.exitCode = await executerEnDemon(import.meta.filename, process.argv.slice(2), main);
3674
3839
  }