@roomi-fields/grillhouse 0.48.0 → 0.49.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +90 -0
  3. package/agents/direct.md +9 -0
  4. package/cadre/templates/projet/.github/workflows/ci.yml +11 -0
  5. package/cadre/templates/projet/.github/workflows/nuit.yml +15 -6
  6. package/cadre/templates/projet/CLAUDE.md +10 -6
  7. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  8. package/cadre/templates/turbo/paquets.json +3 -1
  9. package/cadre/templates/turbo/sans-paquets.json +3 -1
  10. package/charte.md +51 -14
  11. package/dist/temporal/acte.d.ts +9 -0
  12. package/dist/temporal/acte.js +43 -20
  13. package/dist/temporal/acte.js.map +1 -1
  14. package/dist/temporal/circuit/appel.d.ts +4 -1
  15. package/dist/temporal/circuit/appel.js +15 -1
  16. package/dist/temporal/circuit/appel.js.map +1 -1
  17. package/dist/temporal/circuit/client.d.ts +7 -1
  18. package/dist/temporal/circuit/client.js +54 -1
  19. package/dist/temporal/circuit/client.js.map +1 -1
  20. package/dist/temporal/circuit/commande.js +30 -57
  21. package/dist/temporal/circuit/commande.js.map +1 -1
  22. package/dist/temporal/circuit/contrat.d.ts +2 -1
  23. package/dist/temporal/circuit/contrat.js +2 -1
  24. package/dist/temporal/circuit/contrat.js.map +1 -1
  25. package/dist/temporal/circuit/deroule.js +9 -2
  26. package/dist/temporal/circuit/deroule.js.map +1 -1
  27. package/dist/temporal/file/contrat.d.ts +16 -2
  28. package/dist/temporal/file/contrat.js +27 -3
  29. package/dist/temporal/file/contrat.js.map +1 -1
  30. package/dist/temporal/file/deroule.js +4 -4
  31. package/dist/temporal/file/deroule.js.map +1 -1
  32. package/dist/temporal/nuits/activites.d.ts +1 -15
  33. package/dist/temporal/nuits/activites.js +3 -62
  34. package/dist/temporal/nuits/activites.js.map +1 -1
  35. package/dist/temporal/nuits/contrat.d.ts +3 -21
  36. package/dist/temporal/nuits/deroule.js +38 -74
  37. package/dist/temporal/nuits/deroule.js.map +1 -1
  38. package/dist/temporal/places/client.d.ts +3 -16
  39. package/dist/temporal/places/client.js +3 -26
  40. package/dist/temporal/places/client.js.map +1 -1
  41. package/dist/temporal/places/contrat.d.ts +15 -51
  42. package/dist/temporal/places/contrat.js +3 -13
  43. package/dist/temporal/places/contrat.js.map +1 -1
  44. package/dist/temporal/places/deroule.js +11 -61
  45. package/dist/temporal/places/deroule.js.map +1 -1
  46. package/dist/temporal/tickets/activites.js +4 -2
  47. package/dist/temporal/tickets/activites.js.map +1 -1
  48. package/dist/temporal/tickets/contrat.d.ts +2 -1
  49. package/docs/ARCHITECTURE.md +337 -120
  50. package/docs/CADRE.md +16 -13
  51. package/docs/INTERFACE.md +90 -25
  52. package/hooks/hooks.json +9 -0
  53. package/hooks/register.tsx +59 -5
  54. package/package.json +1 -1
  55. package/scripts/activites.mjs +271 -42
  56. package/scripts/aiguillage.mjs +4 -1
  57. package/scripts/bilan.mjs +125 -2
  58. package/scripts/circuit.mjs +233 -159
  59. package/scripts/circuits-cles.d.mts +3 -3
  60. package/scripts/circuits-cles.mjs +6 -5
  61. package/scripts/coeurs-dedies.mjs +4 -4
  62. package/scripts/commandes-composees.mjs +12 -5
  63. package/scripts/dette.d.ts +2 -1
  64. package/scripts/dette.mjs +49 -6
  65. package/scripts/direct.mjs +343 -0
  66. package/scripts/droits.mjs +26 -4
  67. package/scripts/effets.mjs +4 -4
  68. package/scripts/engendres.mjs +2 -1
  69. package/scripts/enveloppe/enveloppe.mjs +119 -18
  70. package/scripts/enveloppe/lancer.sh +14 -3
  71. package/scripts/enveloppe/paquets-du-plan.mjs +9 -0
  72. package/scripts/enveloppe/travail-de-la-copie.mjs +119 -21
  73. package/scripts/etapes.mjs +3 -3
  74. package/scripts/faits-du-circuit.mjs +12 -11
  75. package/scripts/fermeture-de-la-machine.d.mts +4 -4
  76. package/scripts/fermeture-de-la-machine.mjs +10 -20
  77. package/scripts/fichiers-nommes.mjs +27 -1
  78. package/scripts/file-des-tickets.d.mts +18 -1
  79. package/scripts/file-des-tickets.mjs +63 -15
  80. package/scripts/flux-de-la-nuit.mjs +38 -0
  81. package/scripts/grillhouse-maj.mjs +13 -25
  82. package/scripts/groupe-cles.d.mts +6 -0
  83. package/scripts/groupe-cles.mjs +29 -1
  84. package/scripts/integration/file.mjs +148 -37
  85. package/scripts/jointure.d.ts +20 -3
  86. package/scripts/journal-des-etats.d.mts +16 -0
  87. package/scripts/journal-des-etats.mjs +44 -2
  88. package/scripts/journal.mjs +3 -0
  89. package/scripts/langages/c/commandes.mjs +5 -5
  90. package/scripts/langages/c/composants.mjs +13 -5
  91. package/scripts/langages/cargo/commandes.mjs +5 -6
  92. package/scripts/langages/python/commandes.mjs +5 -5
  93. package/scripts/langages/python/composants.mjs +10 -2
  94. package/scripts/langages/typescript/composants.mjs +10 -3
  95. package/scripts/langages/typescript/consommateurs-arbitres.mjs +15 -3
  96. package/scripts/langages/typescript/construire.mjs +2 -0
  97. package/scripts/langages/typescript/exemples.mjs +33 -1
  98. package/scripts/langages/typescript/index.mjs +19 -0
  99. package/scripts/langages/typescript/migrations/0.49.0-tests-equipes.mjs +32 -0
  100. package/scripts/langages/typescript/tests-de-nuit.mjs +158 -32
  101. package/scripts/langages/typescript/tests-du-poste.mjs +112 -32
  102. package/scripts/langages/typescript/titres-de-tests.mjs +11 -7
  103. package/scripts/langages/typescript/turbo-des-paquets.mjs +21 -4
  104. package/scripts/langages/typescript/verifier.mjs +3 -5
  105. package/scripts/langages/typescript/verrou-des-dependances.mjs +161 -0
  106. package/scripts/langages/typescript/vitest-config/cibles.mjs +57 -6
  107. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +11 -5
  108. package/scripts/langages/typescript/vitest.nuit.config.mjs +53 -5
  109. package/scripts/machine.mjs +1 -1
  110. package/scripts/mesure/base-de-passe.mjs +2 -1
  111. package/scripts/migrations/0.49.0-reservation-de-trois-coeurs.mjs +30 -0
  112. package/scripts/migrations.mjs +2 -0
  113. package/scripts/nuit.sh +129 -3
  114. package/scripts/paquet.mjs +16 -5
  115. package/scripts/paquets.d.ts +4 -0
  116. package/scripts/paquets.mjs +57 -0
  117. package/scripts/passe-de-la-machine.mjs +4 -7
  118. package/scripts/places-de-la-machine.mjs +55 -42
  119. package/scripts/places-du-serveur.mjs +2 -2
  120. package/scripts/plafond-de-la-machine.d.mts +7 -13
  121. package/scripts/plafond-de-la-machine.mjs +19 -35
  122. package/scripts/prefixe-des-tickets.mjs +1 -1
  123. package/scripts/references-changees.mjs +159 -0
  124. package/scripts/regles-des-places.d.mts +8 -31
  125. package/scripts/regles-des-places.mjs +14 -64
  126. package/scripts/repli-de-la-nuit.mjs +183 -0
  127. package/scripts/reponses-du-circuit.d.mts +2 -2
  128. package/scripts/reponses-du-circuit.mjs +21 -12
  129. package/scripts/reprise.mjs +27 -8
  130. package/scripts/resultats.mjs +21 -9
  131. package/scripts/seances.mjs +258 -40
  132. package/scripts/services-du-noyau.mjs +4 -0
  133. package/scripts/sous-commandes.mjs +24 -7
  134. package/scripts/superviseur.mjs +185 -39
  135. package/scripts/tableau.mjs +226 -94
  136. package/scripts/taches-du-graphe.mjs +84 -4
  137. package/scripts/ticket.mjs +348 -0
  138. package/scripts/transitions.d.mts +44 -0
  139. package/scripts/transitions.mjs +188 -17
  140. package/scripts/un-commit-par-ticket.mjs +4 -3
  141. package/scripts/verdict-de-la-nuit.mjs +47 -20
  142. package/scripts/verrou-de-fichier.mjs +2 -2
  143. package/scripts/verrous/ecriture-hors-enveloppe.mjs +86 -0
  144. package/scripts/verrous/verrou.mjs +17 -1
  145. package/skills/architecte/SKILL.md +203 -0
  146. package/skills/architecte/references/exemple-d-architecture.md +159 -0
  147. package/skills/developpeur/SKILL.md +1 -1
  148. package/skills/direct/SKILL.md +57 -0
  149. package/skills/explorateur/SKILL.md +10 -6
  150. package/skills/pitmaster/SKILL.md +37 -14
  151. package/skills/pitmaster/references/consigne-agent.md +7 -1
  152. package/skills/redacteur/references/documents-d-un-composant.md +2 -1
  153. package/skills/relecteur/SKILL.md +8 -0
  154. package/skills/testwriter/SKILL.md +10 -0
  155. package/scripts/ticket.sh +0 -25
@@ -5,7 +5,7 @@
5
5
  // reads no file, launches no process and imports no module that does (a guard holds it:
6
6
  // tests/unit/transitions.spec.ts).
7
7
  //
8
- // `transition({ etat, memoire, ticket, reprend, faits })`:
8
+ // `transition({ etat, memoire, ticket, reprend, faits, marqueurs })`:
9
9
  //
10
10
  // - `etat`, the run at its step: `{ etape, tentative, rapport, finale, relanceSurLeRefus }`;
11
11
  // - `memoire`, what the circuit keeps between steps (`controlesRouges`, `renvoiAuTestwriter`,
@@ -13,7 +13,10 @@
13
13
  // `toursDeLaPasseFinale`, `constats`);
14
14
  // - `ticket`, `{ id, paquets, sorte, copie }`;
15
15
  // - `reprend`, whether this step is the first of a `--reprendre`;
16
- // - `faits`, the facts read for this step, by their name.
16
+ // - `faits`, the facts read for this step, by their name;
17
+ // - `marqueurs`, the markers of the workflow of a ticket (`patched`), each true when the run
18
+ // carries it: `attributionAvantSansLivraison`, without which red checks after a developpeur who
19
+ // had nothing to deliver stop before any attribution, as a run recorded before it replays.
17
20
  //
18
21
  // It returns either the next fact to read, `{ besoin: { fait, ...parametres }, effets, memoire }` (a
19
22
  // session, a pass, a reading of the copy), which the circuit reads and gives back in `faits` with
@@ -30,7 +33,7 @@
30
33
  // the facts read so far, as Temporal replays a workflow on its history: the same facts give the
31
34
  // same decision.
32
35
  import { ARRETS, boucle, RESPONSABLE, SUITE } from './etapes.mjs';
33
- import { attribuerLeRouge } from './reprise.mjs';
36
+ import { attribuerLeRouge, departDepuis } from './reprise.mjs';
34
37
 
35
38
  // What the circuit keeps between steps, which the decisions read and change: the one list the
36
39
  // opening reads back (scripts/faits-du-circuit.mjs `GARDEE`) and the memo of a circuit keeps
@@ -376,6 +379,136 @@ export const etatDeReprise = etat =>
376
379
  }
377
380
  : etat;
378
381
 
382
+ // Where the run starts, from the command's options and the state of the stop: `{ suivant, memoire }`
383
+ // (the state the run starts at, the memory it changes), or `{ usage }`, a refusal. After a stop
384
+ // « integration », on --depuis developpeur, the developpeur, the refusal (`refus`) as his report,
385
+ // the session so launched marked (`lance`), as a merge queue sends the lot back to its author with
386
+ // the log of its check; else the step a --depuis names (the testwriter's, which makes the lot
387
+ // again, the refusal dropped, or the developpeur's), the step of the state `etat` (null without
388
+ // one) on --reprendre, the integration or the queue played again on the same lot after their stop,
389
+ // as bors retries, else the testwriter, the run starting over.
390
+ export function depart({ depuis = null, reprendre = false, marque = false, etat, refus, ticket }) {
391
+ // The supervisor's command wins over the sort of the plan: the mark of his `--depuis testwriter`.
392
+ const memoire = {
393
+ testwriterDemande: testwriterDemande({ depuis, reprendre: Boolean(reprendre), marque }),
394
+ };
395
+ // A --depuis plays its step and the ones after it, no result read back: no fingerprint kept, no
396
+ // resumption at a red, no attribution counted.
397
+ if (depuis) {
398
+ Object.assign(memoire, { verts: {}, reprise: null, relancesTestwriter: null });
399
+ }
400
+ if (depuis === 'developpeur' && etat?.raison === 'integration' && refus) {
401
+ memoire.refus = { ...refus, lance: true, relance: false };
402
+ return {
403
+ suivant: { etape: CODE, tentative: 1, rapport: rapportDuRefus(memoire.refus), finale: false },
404
+ memoire,
405
+ };
406
+ }
407
+ if (depuis === 'testwriter') {
408
+ memoire.refus = null;
409
+ }
410
+ if (depuis) {
411
+ const { etape, tentative, rapport, finale } = departDepuis(depuis);
412
+ return { suivant: { etape, tentative, rapport, finale }, memoire };
413
+ }
414
+ if (!reprendre) {
415
+ // The run starts over: no lot verified, no finding of a review open, no refusal, no checks played.
416
+ Object.assign(memoire, {
417
+ verts: null,
418
+ reprise: null,
419
+ relancesTestwriter: null,
420
+ verifie: null,
421
+ toursDeLaPasseFinale: null,
422
+ constats: [],
423
+ refus: null,
424
+ controlesRouges: null,
425
+ });
426
+ return { suivant: { etape: TESTS, tentative: 1, rapport: null, finale: false }, memoire };
427
+ }
428
+ if (!etat) {
429
+ return { usage: `rien à reprendre : le circuit de ${ticket} n'a aucun état d'arrêt.` };
430
+ }
431
+ if (etat.etape === 'integre') {
432
+ return { usage: `rien à reprendre : le lot de ${ticket} est intégré.` };
433
+ }
434
+ return {
435
+ suivant: {
436
+ etape: etat.etape,
437
+ tentative: etat.etape === CONTROLES ? 0 : 1,
438
+ rapport: etat.rapport,
439
+ finale: etat.finale === true,
440
+ },
441
+ memoire,
442
+ };
443
+ }
444
+
445
+ // The sending to the testwriter in the developpeur's sheet <fiche> (its `renvoi`): what the
446
+ // testwriter receives, the sending, the developpeur's handover <passation> (null: « aucune »), then
447
+ // the red output of the last checks <controlesRouges> when checks ran since the testwriter's
448
+ // session; null without a sending. <fichiersRouges> lists, in one go, every test file the lot
449
+ // breaks, the plan's and the extended readers' (`fichiersDeTestRouges`).
450
+ export function renvoiDe({ fiche, passation, controlesRouges, fichiersRouges = [] }) {
451
+ if (!fiche.renvoi) {
452
+ return null;
453
+ }
454
+ const raison = fiche.raison ? ` : ${fiche.raison}` : '';
455
+ const fichiers = fichiersRouges.length
456
+ ? `\n\nLes fichiers de test rouges, tous à lever en une séance : ${fichiersRouges.join(', ')}.`
457
+ : '';
458
+ const controles = controlesRouges
459
+ ? `\n\nLa sortie rouge des derniers contrôles :\n\n${controlesRouges}`
460
+ : '';
461
+ return `Le développeur renvoie le rouge qui reste aux tests du lot${raison}.${fichiers}\n\nSa passation :\n\n${passation ?? 'aucune'}${controles}`;
462
+ }
463
+
464
+ // The test files the red output <controlesRouges> of checks names (its lines `- test <fichier> › …`
465
+ // and `- test <fichier> — …`), each once, in order.
466
+ export function fichiersDeTestRouges(controlesRouges) {
467
+ const vus = new Set();
468
+ for (const ligne of String(controlesRouges ?? '').split('\n')) {
469
+ if (!ligne.startsWith('- test ')) {
470
+ continue;
471
+ }
472
+ const mot = ligne.slice('- test '.length).split(' ')[0];
473
+ const suite = ligne.slice('- test '.length + mot.length).trimStart();
474
+ if (mot && (suite.startsWith('›') || suite.startsWith('—'))) {
475
+ vus.add(mot);
476
+ }
477
+ }
478
+ return [...vus];
479
+ }
480
+
481
+ // The context `--etendre` gives the sessions of the run it resumes on the stop <question>: the
482
+ // supervisor's answer (the packages <etendus> the plan gains, the plan <plan> as it is now), then his own text <contexte>. The stop's fact
483
+ // and piece stay out of it: they say the plan as it was and tell a session to stop (a lock's
484
+ // message), and a session reads its context as the supervisor's word. Without a question, his
485
+ // text alone, or null.
486
+ export function contexteDeLExtension({ question, etendus, plan, contexte }) {
487
+ const reponse = question
488
+ ? `Le superviseur a étendu le plan à ${etendus.join(', ')} ; le plan du ticket est maintenant : ${plan}.`
489
+ : null;
490
+ return [reponse, contexte].filter(Boolean).join('\n\n') || null;
491
+ }
492
+
493
+ // Where the circuit resumes when the supervisor extends the plan: without a state <etat>, it starts
494
+ // on the plan extended (`suivant` null); else it resumes the step under way, as `--reprendre`
495
+ // does, the supervisor's answer to the stop as the context of its sessions; a stop
496
+ // « sans-livraison » whose developpeur's last sheet sends the red to the testwriter (<renvoi>)
497
+ // resumes at the step of the testwriter, as a retry plays the job that failed.
498
+ export function etendre({ etat, etendus, plan, contexte, renvoi }) {
499
+ if (!etat) {
500
+ return { suivant: null };
501
+ }
502
+ const suite = contexteDeLExtension({ question: etat.question, etendus, plan, contexte });
503
+ const auTestwriter =
504
+ etat.etape === CODE && etat.raison === 'sans-livraison' && renvoi?.role === 'testwriter';
505
+ return {
506
+ suivant: auTestwriter ? { ...etat, etape: TESTS } : etat,
507
+ contexte: suite,
508
+ reprend: true,
509
+ };
510
+ }
511
+
379
512
  // The decision of the step of <entree> (see the header), or the next fact it needs.
380
513
  export function transition(entree) {
381
514
  const faits = entree.faits ?? {};
@@ -401,7 +534,7 @@ export function transition(entree) {
401
534
  }
402
535
  }
403
536
 
404
- function decider({ etat, memoire = {}, ticket, reprend = false }, lire, partiel) {
537
+ function decider({ etat, memoire = {}, ticket, reprend = false, marqueurs = {} }, lire, partiel) {
405
538
  let { etape, tentative, rapport, finale } = etat;
406
539
  let relanceSurLeRefus = Boolean(etat.relanceSurLeRefus);
407
540
  const maj = {};
@@ -463,6 +596,11 @@ function decider({ etat, memoire = {}, ticket, reprend = false }, lire, partiel)
463
596
  return true;
464
597
  };
465
598
  const plan = ticket.paquets.join(', ');
599
+ // The plan skips the testwriter (« comportement inchangé » he was not asked for, or no package
600
+ // playing tests): a sending of the red to him leads nowhere, whatever the checks between two.
601
+ const inchangeSansTestwriter = () =>
602
+ ticket.sorte?.comportement === 'inchangé' && !m('testwriterDemande');
603
+ const testwriterSaute = () => inchangeSansTestwriter() || Boolean(lire('sansTests'));
466
604
 
467
605
  // After the plan: the gesture of a mechanical ticket, the developpeur of a plan without tests,
468
606
  // else the testwriter.
@@ -594,6 +732,13 @@ function decider({ etat, memoire = {}, ticket, reprend = false }, lire, partiel)
594
732
  }
595
733
  const p = lire('preuve', reprise ? { fichiers: reprise.fichiers } : {});
596
734
  rapport = p.texte;
735
+ if (p.aRepasser) {
736
+ // A proof whose pass is at 75 proved nothing, neither a red nor a refusal: « à repasser »,
737
+ // as the checks, with no testwriter relaunched; a wait of the machine at its bound plays
738
+ // again without limit.
739
+ garderLeVert('preuve', null);
740
+ return arreter('a-repasser', p.texte, p.attente ? { attente: true } : {});
741
+ }
597
742
  if (p.ok) {
598
743
  // Resumed at a red, a proof restricted to the file the red names goes to the checks.
599
744
  const auDeveloppeur = reprise
@@ -743,7 +888,8 @@ function decider({ etat, memoire = {}, ticket, reprend = false }, lire, partiel)
743
888
  // carried ('' for none), null after green checks: the same output twice in a row is a
744
889
  // round trip without a new fact.
745
890
  const sortie = m('controlesRouges') ?? '';
746
- if (m('renvoiAuTestwriter') === sortie) {
891
+ const dejaRenvoye = m('renvoiAuTestwriter') !== null;
892
+ if (m('renvoiAuTestwriter') === sortie || (dejaRenvoye && testwriterSaute())) {
747
893
  if (lire('empreinte') === avant) {
748
894
  inscrire({ etape: CODE, inchange: true }, 'inchange');
749
895
  }
@@ -965,7 +1111,9 @@ function decider({ etat, memoire = {}, ticket, reprend = false }, lire, partiel)
965
1111
  if (meles) {
966
1112
  maj.rienALivrer = rien;
967
1113
  } else {
968
- maj.renvoiAuTestwriter = null;
1114
+ if (!inchangeSansTestwriter()) {
1115
+ maj.renvoiAuTestwriter = null;
1116
+ }
969
1117
  tentative = 0;
970
1118
  }
971
1119
  // The report of the reds of the plan, which go to the developpeur when a command of the
@@ -1008,6 +1156,12 @@ function decider({ etat, memoire = {}, ticket, reprend = false }, lire, partiel)
1008
1156
  if (k.rouge && k.ecartesRouges?.length) {
1009
1157
  lire('etendreAuxEcartes', { composants: k.ecartesRouges, rouges: k.tous });
1010
1158
  }
1159
+ // The reds of a reader package out of the plan that all lie in test files: the plan extends to
1160
+ // those tests alone, without a stop, and the testwriter, who alone writes them, is relaunched
1161
+ // by the attribution below (the circuit writes the extension, with its piece, at the ticket).
1162
+ if (k.rouge && k.testsLecteurs?.length) {
1163
+ lire('etendreAuxTests', { composants: k.testsLecteurs, rouges: k.tous });
1164
+ }
1011
1165
  if (k.rouge && passeFinale && k.horsTitre.length) {
1012
1166
  return arret(
1013
1167
  'controles',
@@ -1033,14 +1187,24 @@ function decider({ etat, memoire = {}, ticket, reprend = false }, lire, partiel)
1033
1187
  `Le ticket est mécanique (${ticket.sorte.raison}) : ni testwriter ni développeur ne lève ce rouge du lot de sa commande. Le superviseur fait corriger le lot (\`--depuis developpeur\`, le rouge en \`--contexte\`), corrige le geste dans la copie puis \`--reprendre\`, ou arrête le circuit (\`--arreter\`).`
1034
1188
  );
1035
1189
  }
1036
- // The stop stands at the developpeur's step, which a resumption plays again.
1037
- if (k.rouge && rien) {
1190
+ // A run recorded before the marker `attribution-avant-sans-livraison` of the workflow of a
1191
+ // ticket (src/temporal/circuit/deroule.ts) keeps the former order: the stop of a developpeur
1192
+ // who had nothing to deliver before any attribution, the fact « portes » not read, as its
1193
+ // history replays. This path leaves once those runs have ended (grillhouse-3uv.177).
1194
+ if (k.rouge && rien && !marqueurs.attributionAvantSansLivraison) {
1038
1195
  return arret('sans-livraison', rien, CODE);
1039
1196
  }
1040
- if (k.rouge && suivante <= SEANCES_DEVELOPPEUR) {
1041
- // The red goes back to the step that carries it, by the files it names (scripts/reprise.mjs).
1042
- const portes = lire('portes', { lieux: k.lieux });
1043
- const a = attribuerLeRouge({ lieux: k.lieux, portes });
1197
+ // The red goes back to the step that carries it, by the files it names (scripts/reprise.mjs).
1198
+ const portes =
1199
+ k.rouge && suivante <= SEANCES_DEVELOPPEUR ? lire('portes', { lieux: k.lieux }) : null;
1200
+ const a = portes ? attribuerLeRouge({ lieux: k.lieux, portes }) : null;
1201
+ // A developpeur who had nothing to deliver stops the circuit on a red that is his: the stop
1202
+ // stands at his step, which a resumption plays again. A red that names a test file of the lot
1203
+ // is the testwriter's, who is relaunched: the developpeur had nothing to write for it.
1204
+ if (k.rouge && rien && a?.etape !== 'testwriter') {
1205
+ return arret('sans-livraison', rien, CODE);
1206
+ }
1207
+ if (a) {
1044
1208
  if (!a.etape) {
1045
1209
  return arret('controles', `Le rouge n'est attribué à aucune étape : ${a.motif}.`);
1046
1210
  }
@@ -1085,9 +1249,11 @@ function decider({ etat, memoire = {}, ticket, reprend = false }, lire, partiel)
1085
1249
  return arret('a-repasser', null);
1086
1250
  }
1087
1251
  ecrireRapport('controles', `${k.resume}.`, resultat('vert'), `${k.resume}.${k.avertissements}`);
1088
- // Green checks: a sending of the developpeur to the testwriter may come again.
1089
- maj.renvoiAuTestwriter = null;
1090
- maj.relancesTestwriter = 0;
1252
+ // Green checks: a sending of the developpeur to the testwriter may come again, unless the
1253
+ // plan skips the testwriter.
1254
+ if (!inchangeSansTestwriter()) {
1255
+ maj.renvoiAuTestwriter = null;
1256
+ }
1091
1257
  const entierement = !reprise && !regeneration;
1092
1258
  if (!passeFinale) {
1093
1259
  if (entierement && k.empreinte) {
@@ -1099,8 +1265,13 @@ function decider({ etat, memoire = {}, ticket, reprend = false }, lire, partiel)
1099
1265
  finale = true;
1100
1266
  return decision();
1101
1267
  }
1102
- // The whole pass green on this lot; the lot the last review accepted goes to the
1103
- // integration, any other to the review.
1268
+ // The whole pass green on this lot: the relaunches of the testwriter count again from none.
1269
+ // Green checks of the plan keep the count. The test file of a reader package extended to its
1270
+ // tests is red at the final pass and at the checks restricted to that file, each of which
1271
+ // sends the testwriter back; the checks of the whole plan, which play its packages and not
1272
+ // the reader, are green in between, and would else start the count again without end.
1273
+ maj.relancesTestwriter = 0;
1274
+ // The lot the last review accepted goes to the integration, any other to the review.
1104
1275
  // A final pass green on the band of the lot (after a regeneration, on what it changed, or not
1105
1276
  // played when it changed nothing) verifies its tree: the lot accepted on it goes to the
1106
1277
  // integration.
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  // A closed ticket keeps its one delivery: refuses a commit message whose title line names a ticket
3
3
  // an earlier commit already delivers, unless that ticket is open in Beads. An open ticket that
4
- // already has its delivery is a ticket reopened for a fix (by the queue or the CI): the commit is a
5
- // correction and passes. A closed ticket is finished: new work opens a new ticket, created under it
6
- // (`--parent`). Run by the commit-msg hook (`grillhouse hook commit-msg`, scripts/crochets.mjs), with
4
+ // already has its delivery is a ticket reopened for a fix led by hand: the commit is a correction
5
+ // and passes. The queue of the tickets never starts such a ticket again (its lot is on main,
6
+ // scripts/file-des-tickets.mjs). A closed ticket is finished: new work opens a new ticket, created
7
+ // under it (`--parent`). Run by the commit-msg hook (`grillhouse hook commit-msg`, scripts/crochets.mjs), with
7
8
  // the message file as argument.
8
9
  //
9
10
  // - A ticket is open when its Beads status (`bd show <id> --json`) is anything but `closed`; a
@@ -1,47 +1,74 @@
1
- // The durable verdict of a project's night: the night pass (scripts/nuit.sh) notes it at its end in
2
- // `<git common dir>/nuit/verdict`, and the board reads it without a server. `vert` when the pass
3
- // exits 0, `rouge` for any other code but 75 (a missing code included); 75 (« à repasser ») writes
4
- // nothing and leaves the previous verdict. A read that fails gives no verdict.
1
+ // The durable verdict of a project's night, in two parts: the night plays on two machines, the part
2
+ // of PC2 (the tranches of the Nuit flow, which PC3 reads by `gh`) and the part of PC3 (the tests of
3
+ // the poste, scripts/nuit.sh). Each part is noted at its end in `<git common dir>/nuit/verdict` (PC3)
4
+ // and `<git common dir>/nuit/verdict-pc2` (PC2), and the board reads them without a server. A part is
5
+ // `vert` when it exits 0, `rouge` for any other code but 75 (a missing code included); 75 (« à
6
+ // repasser ») writes nothing and leaves the previous verdict of that part, the other untouched. The
7
+ // night is `rouge` when a part is, else `vert` when a part is, else none. A read that fails gives
8
+ // no verdict for that part.
5
9
  import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
6
10
  import path from 'node:path';
7
11
  import { fileURLToPath } from 'node:url';
8
12
 
9
13
  const CODE_A_REPASSER = 75;
10
- const fichierDuVerdict = commun => path.join(commun, 'nuit', 'verdict');
14
+ const FICHIERS = { pc2: 'verdict-pc2', pc3: 'verdict' };
15
+ const fichierDuVerdict = (commun, part) => path.join(commun, 'nuit', FICHIERS[part]);
11
16
 
12
17
  /**
13
18
  * @param {string} commun the git common dir of the project
14
- * @param {number} code the exit code of the night pass
15
- * @returns {'vert' | 'rouge' | null} the verdict written, null when the night is to be replayed
19
+ * @param {number} code the exit code of the part's pass
20
+ * @param {'pc2' | 'pc3'} [part] the part noted: that of the machine that plays, PC3 by default
21
+ * @returns {'vert' | 'rouge' | null} the verdict written, null when the part is to be replayed
16
22
  */
17
- export function noterLeVerdict(commun, code) {
23
+ export function noterLeVerdict(commun, code, part = 'pc3') {
18
24
  if (code === CODE_A_REPASSER) {
19
25
  return null;
20
26
  }
21
27
  const verdict = code === 0 ? 'vert' : 'rouge';
22
28
  mkdirSync(path.join(commun, 'nuit'), { recursive: true });
23
- writeFileSync(fichierDuVerdict(commun), `${verdict}\n`);
29
+ writeFileSync(fichierDuVerdict(commun, part), `${verdict}\n`);
24
30
  return verdict;
25
31
  }
26
32
 
33
+ function lireLaPart(commun, part) {
34
+ try {
35
+ const v = readFileSync(fichierDuVerdict(commun, part), 'utf8').trim();
36
+ return v === 'vert' || v === 'rouge' ? v : null;
37
+ } catch {
38
+ return null;
39
+ }
40
+ }
41
+
27
42
  /**
28
43
  * @param {string | null} commun the git common dir of the project
29
- * @returns {'vert' | 'rouge' | null} the last night's verdict, null when none is known or it does not read
44
+ * @returns {{ pc2: 'vert' | 'rouge' | null, pc3: 'vert' | 'rouge' | null }} each part's last verdict,
45
+ * null when it has none or it does not read
30
46
  */
31
- export function lireLeVerdict(commun) {
47
+ export function lireLesParts(commun) {
32
48
  if (!commun) {
33
- return null;
49
+ return { pc2: null, pc3: null };
34
50
  }
35
- try {
36
- const v = readFileSync(fichierDuVerdict(commun), 'utf8').trim();
37
- return v === 'vert' || v === 'rouge' ? v : null;
38
- } catch {
39
- return null;
51
+ return { pc2: lireLaPart(commun, 'pc2'), pc3: lireLaPart(commun, 'pc3') };
52
+ }
53
+
54
+ /**
55
+ * @param {string | null} commun the git common dir of the project
56
+ * @returns {'vert' | 'rouge' | null} the last night's verdict over its two parts, null when none is known
57
+ */
58
+ export function lireLeVerdict(commun) {
59
+ const parts = Object.values(lireLesParts(commun));
60
+ if (parts.includes('rouge')) {
61
+ return 'rouge';
40
62
  }
63
+ return parts.includes('vert') ? 'vert' : null;
41
64
  }
42
65
 
43
- // `node verdict-de-la-nuit.mjs <commun> <code>`: what nuit.sh calls at the end of the night.
66
+ // `node verdict-de-la-nuit.mjs <commun> <code> [pc2|pc3]`: what nuit.sh calls at the end of the night.
44
67
  if (process.argv[1] && fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) {
45
- const [commun, code] = process.argv.slice(2);
46
- noterLeVerdict(commun, code === undefined || code === '' ? NaN : Number(code));
68
+ const [commun, code, part] = process.argv.slice(2);
69
+ noterLeVerdict(
70
+ commun,
71
+ code === undefined || code === '' ? NaN : Number(code),
72
+ part === 'pc2' ? 'pc2' : 'pc3'
73
+ );
47
74
  }
@@ -1,6 +1,6 @@
1
1
  // The lock of a file shared between processes: the file `<verrou>` stands while someone holds it.
2
- // Taken by the integration (`.git/integration.lock`) and by the register
3
- // (`registre.jsonl.verrou`).
2
+ // Taken by the integration (`.git/integration.lock`), by the register (`registre.jsonl.verrou`)
3
+ // and by the creation of a ticket (`.beads/grillhouse-ticket.lock`, scripts/ticket.mjs).
4
4
  //
5
5
  // - A lock is created whole and exclusively: its mark (the owner's process number, then a token
6
6
  // unique to the taking) is written to a private file that is linked to `<verrou>`; the link
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env node
2
+ // The write lock of a session out of the envelope: a PreToolUse hook of the frame's plugin
3
+ // (hooks/hooks.json, `npx grillhouse verrou-hors-enveloppe`), which runs in every session of a
4
+ // project that installs the frame. It reads the hook's JSON on stdin and refuses, exit code 2 and
5
+ // its reason on stderr, the write of the code or the tests of a package by a session that is no
6
+ // agent of the frame under its envelope: the supervisor, the person who starts Claude Code by hand,
7
+ // a session that lost its variable of envelope (`GRILLHOUSE_ENVELOPPE`, refusal by default).
8
+ //
9
+ // - A write of a document (a `.md` file) passes: the documents of a package (CADRE.md,
10
+ // INTERFACE.md, ARCHITECTURE.md, CHANGELOG, the skills and the charter of `mods/grillhouse`) and
11
+ // those of the root (CLAUDE.md, docs/, the configuration) stay the supervisor's.
12
+ // - What a package holds is read as its lock reads it (`paquetQuiTient`, the components of the
13
+ // module of the language); `mods/grillhouse`, the frame's plugin, is one too. A file of the root
14
+ // of the repository passes.
15
+ // - A path under the temporary directory of the session passes, and so does any tool that writes
16
+ // nothing. A session under its envelope is judged by its role's lock (verrou.mjs).
17
+ // - The reason names `npx grillhouse direct <ticket>`: the agent of a direct writes the tests and
18
+ // the code in a copy of its own, a reviewer reads its lot, and the supervisor verifies and
19
+ // commits it.
20
+ import { readFileSync } from 'node:fs';
21
+ import { tmpdir } from 'node:os';
22
+ import path from 'node:path';
23
+ import { pathToFileURL } from 'node:url';
24
+ import { paquetQuiTient, paquetsDuLangage, paquetsDeLEnveloppe } from '../enveloppe/paquets-du-plan.mjs';
25
+ import { langageDeLaCopie } from '../langages.mjs';
26
+ import { racineDe } from './verrou.mjs';
27
+
28
+ const OUTILS_D_ECRITURE = new Set(['Write', 'Edit', 'MultiEdit', 'NotebookEdit']);
29
+ // The frame's own code, a package though no table of components lists it.
30
+ const CADRE = 'mods/grillhouse';
31
+
32
+ const sous = (rel, dossier) => rel === dossier || rel.startsWith(`${dossier}/`);
33
+
34
+ /**
35
+ * The refusal of the write <input> of a session out of the envelope, or null when it passes.
36
+ * @param {{ tool_name?: string, tool_input?: Record<string, string>, cwd?: string }} input
37
+ * @param {{ env?: Record<string, string | undefined>, tmp?: string }} [options]
38
+ * @returns {string | null}
39
+ */
40
+ export function refusDeLEcritureHorsEnveloppe(
41
+ input,
42
+ { env = process.env, tmp = tmpdir() } = {}
43
+ ) {
44
+ if (!OUTILS_D_ECRITURE.has(input.tool_name ?? '') || paquetsDeLEnveloppe(env)) {
45
+ return null;
46
+ }
47
+ const brut = input.tool_input?.file_path ?? input.tool_input?.notebook_path;
48
+ if (!brut) {
49
+ return null;
50
+ }
51
+ const fichier = path.resolve(input.cwd ?? process.cwd(), brut);
52
+ const dansTmp = path.relative(path.resolve(tmp), fichier);
53
+ if (dansTmp !== '' && !dansTmp.startsWith('..') && !path.isAbsolute(dansTmp)) {
54
+ return null;
55
+ }
56
+ if (fichier.endsWith('.md')) {
57
+ return null;
58
+ }
59
+ const copie = racineDe(fichier);
60
+ if (!copie) {
61
+ return null;
62
+ }
63
+ const rel = path.relative(copie, fichier);
64
+ const tenant = sous(rel, CADRE)
65
+ ? CADRE
66
+ : paquetQuiTient(rel, paquetsDuLangage(langageDeLaCopie(copie), copie));
67
+ if (tenant === '.') {
68
+ return null;
69
+ }
70
+ return `⛔ ${rel} est du code ou un test du paquet ${tenant} : une séance hors enveloppe (le superviseur, une séance lancée à la main, une séance qui a perdu sa variable d'enveloppe) n'écrit ni le code ni les tests d'un paquet. Un ticket direct se mène par \`npx grillhouse direct <ticket>\` : un agent l'écrit dans une copie à lui, un relecteur le relit, puis le superviseur le vérifie et le commite. Les documents restent écrits ici.`;
71
+ }
72
+
73
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
74
+ // A hook that throws exits 1, which Claude Code lets pass: an input or a project the lock cannot
75
+ // judge is refused (a firewall's rule), its reason said.
76
+ try {
77
+ const raison = refusDeLEcritureHorsEnveloppe(JSON.parse(readFileSync(0, 'utf8')));
78
+ if (raison) {
79
+ process.stderr.write(`${raison}\n`);
80
+ process.exitCode = 2;
81
+ }
82
+ } catch (e) {
83
+ process.stderr.write(`⛔ verrou hors enveloppe : ${e.message} (écriture refusée)\n`);
84
+ process.exitCode = 2;
85
+ }
86
+ }
@@ -22,6 +22,7 @@
22
22
  // description holds a "## Architecture" section (`sansArchitecture`, which the start of the
23
23
  // circuit reads too). The ticket is the "TON TICKET : <id>" line of the agent's
24
24
  // launch prompt, read from its transcript.
25
+ // - direct writes tests and code of its plan together (a ticket led by `npx grillhouse direct`).
25
26
  // - In an envelope (`GRILLHOUSE_ENVELOPPE`, the packages of the plan, scripts/enveloppe/
26
27
  // paquets-du-plan.mjs), a write in the copy out of the packages the plan writes (`ecritsDuPlan`
27
28
  // on the components of the module of the language, `paquetsDuLangage`, as the envelope reads them)
@@ -44,6 +45,7 @@ import {
44
45
  paquetQuiTient,
45
46
  paquetsDeLEnveloppe,
46
47
  paquetsDuLangage,
48
+ testsEtendusDeLEnveloppe,
47
49
  } from '../enveloppe/paquets-du-plan.mjs';
48
50
  import { langageDeLaCopie } from '../langages.mjs';
49
51
 
@@ -67,7 +69,7 @@ const isScratch = (file, tmp = tmpdir()) => isInside(file, tmp);
67
69
 
68
70
  // The root of the git repository (or worktree) that holds the absolute path <file>, read from its
69
71
  // nearest existing directory; null when no repository holds it.
70
- function racineDe(file) {
72
+ export function racineDe(file) {
71
73
  let dir = path.dirname(file);
72
74
  while (!existsSync(dir)) {
73
75
  const parent = path.dirname(dir);
@@ -122,6 +124,15 @@ export function horsDuPlan(input, { tmp = tmpdir(), env = process.env, role = nu
122
124
  if (role === TESTWRITER && langage.manifestes.verrous.includes(rel)) {
123
125
  return null;
124
126
  }
127
+ // The test files of a reader package the circuit extended the plan to (`testsEtendus`, given to
128
+ // the testwriter's envelope alone): never its code nor its manifest.
129
+ if (
130
+ role === TESTWRITER &&
131
+ testsEtendusDeLEnveloppe(env).some(d => rel.startsWith(`${d}/`)) &&
132
+ langage.estUnTest(file, copie)?.test
133
+ ) {
134
+ return null;
135
+ }
125
136
  const tenant = paquetQuiTient(rel, liste);
126
137
  const paquet = tenant === '.' ? 'la racine du dépôt' : tenant;
127
138
  return {
@@ -249,6 +260,11 @@ export function refusal(role, input, { tmp = tmpdir(), describe = ticketDescript
249
260
  }
250
261
  return sansArchitecture(id, description);
251
262
  }
263
+ if (role === 'direct') {
264
+ // The agent of a direct writes tests and code together; the envelope of its plan (`horsDuPlan`)
265
+ // bounds its writes, and its ticket needs no « ## Architecture » section.
266
+ return null;
267
+ }
252
268
  return `Rôle inconnu du verrou : ${role}.`;
253
269
  }
254
270