@roomi-fields/grillhouse 0.29.0 → 0.31.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 (263) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +769 -0
  3. package/agents/developpeur.md +0 -1
  4. package/agents/explorateur.md +0 -1
  5. package/agents/questionneur.md +0 -1
  6. package/agents/testwriter.md +0 -1
  7. package/bin/grillhouse.mjs +79 -18
  8. package/cadre/templates/projet/.github/workflows/ci.yml +2 -13
  9. package/cadre/templates/projet/CLAUDE.md +5 -1
  10. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  11. package/cadre/templates/projet/package.json +2 -2
  12. package/charte.md +24 -0
  13. package/dist/temporal/acte.d.ts +24 -0
  14. package/dist/temporal/acte.js +139 -0
  15. package/dist/temporal/acte.js.map +1 -0
  16. package/dist/temporal/attributs.d.ts +6 -0
  17. package/dist/temporal/attributs.js +15 -0
  18. package/dist/temporal/attributs.js.map +1 -0
  19. package/dist/temporal/circuit/activites.d.ts +13 -0
  20. package/dist/temporal/circuit/activites.js +33 -0
  21. package/dist/temporal/circuit/activites.js.map +1 -0
  22. package/dist/temporal/circuit/client.d.ts +72 -0
  23. package/dist/temporal/circuit/client.js +247 -0
  24. package/dist/temporal/circuit/client.js.map +1 -0
  25. package/dist/temporal/circuit/commande.d.ts +2 -0
  26. package/dist/temporal/circuit/commande.js +238 -0
  27. package/dist/temporal/circuit/commande.js.map +1 -0
  28. package/dist/temporal/circuit/contrat.d.ts +305 -0
  29. package/dist/temporal/circuit/contrat.js +30 -0
  30. package/dist/temporal/circuit/contrat.js.map +1 -0
  31. package/dist/temporal/circuit/deroule.d.ts +3 -0
  32. package/dist/temporal/circuit/deroule.js +540 -0
  33. package/dist/temporal/circuit/deroule.js.map +1 -0
  34. package/dist/temporal/client.d.ts +47 -0
  35. package/dist/temporal/client.js +69 -0
  36. package/dist/temporal/client.js.map +1 -0
  37. package/dist/temporal/commande.d.ts +2 -0
  38. package/dist/temporal/commande.js +94 -0
  39. package/dist/temporal/commande.js.map +1 -0
  40. package/dist/temporal/deroules.d.ts +5 -0
  41. package/dist/temporal/deroules.js +10 -0
  42. package/dist/temporal/deroules.js.map +1 -0
  43. package/dist/temporal/etat.d.ts +33 -0
  44. package/dist/temporal/etat.js +59 -0
  45. package/dist/temporal/etat.js.map +1 -0
  46. package/dist/temporal/file/activites.d.ts +10 -0
  47. package/dist/temporal/file/activites.js +25 -0
  48. package/dist/temporal/file/activites.js.map +1 -0
  49. package/dist/temporal/file/client.d.ts +4 -0
  50. package/dist/temporal/file/client.js +6 -0
  51. package/dist/temporal/file/client.js.map +1 -0
  52. package/dist/temporal/file/contrat.d.ts +158 -0
  53. package/dist/temporal/file/contrat.js +14 -0
  54. package/dist/temporal/file/contrat.js.map +1 -0
  55. package/dist/temporal/file/deroule.d.ts +15 -0
  56. package/dist/temporal/file/deroule.js +235 -0
  57. package/dist/temporal/file/deroule.js.map +1 -0
  58. package/dist/temporal/installation.d.ts +120 -0
  59. package/dist/temporal/installation.js +386 -0
  60. package/dist/temporal/installation.js.map +1 -0
  61. package/dist/temporal/places/activites.d.ts +8 -0
  62. package/dist/temporal/places/activites.js +13 -0
  63. package/dist/temporal/places/activites.js.map +1 -0
  64. package/dist/temporal/places/client.d.ts +28 -0
  65. package/dist/temporal/places/client.js +64 -0
  66. package/dist/temporal/places/client.js.map +1 -0
  67. package/dist/temporal/places/contrat.d.ts +106 -0
  68. package/dist/temporal/places/contrat.js +21 -0
  69. package/dist/temporal/places/contrat.js.map +1 -0
  70. package/dist/temporal/places/deroule.d.ts +3 -0
  71. package/dist/temporal/places/deroule.js +198 -0
  72. package/dist/temporal/places/deroule.js.map +1 -0
  73. package/dist/temporal/sonde/activites.d.ts +6 -0
  74. package/dist/temporal/sonde/activites.js +52 -0
  75. package/dist/temporal/sonde/activites.js.map +1 -0
  76. package/dist/temporal/sonde/contrat.d.ts +35 -0
  77. package/dist/temporal/sonde/contrat.js +10 -0
  78. package/dist/temporal/sonde/contrat.js.map +1 -0
  79. package/dist/temporal/sonde/deroule.d.ts +3 -0
  80. package/dist/temporal/sonde/deroule.js +39 -0
  81. package/dist/temporal/sonde/deroule.js.map +1 -0
  82. package/dist/temporal/tickets/activites.d.ts +7 -0
  83. package/dist/temporal/tickets/activites.js +81 -0
  84. package/dist/temporal/tickets/activites.js.map +1 -0
  85. package/dist/temporal/tickets/client.d.ts +10 -0
  86. package/dist/temporal/tickets/client.js +31 -0
  87. package/dist/temporal/tickets/client.js.map +1 -0
  88. package/dist/temporal/tickets/contrat.d.ts +56 -0
  89. package/dist/temporal/tickets/contrat.js +13 -0
  90. package/dist/temporal/tickets/contrat.js.map +1 -0
  91. package/dist/temporal/tickets/deroule.d.ts +3 -0
  92. package/dist/temporal/tickets/deroule.js +94 -0
  93. package/dist/temporal/tickets/deroule.js.map +1 -0
  94. package/dist/temporal/travailleur.d.ts +2 -0
  95. package/dist/temporal/travailleur.js +69 -0
  96. package/dist/temporal/travailleur.js.map +1 -0
  97. package/docs/ARCHITECTURE.md +646 -87
  98. package/docs/CADRE.md +27 -0
  99. package/docs/INTERFACE.md +139 -42
  100. package/hooks/crochet.mjs +19 -2
  101. package/hooks/hooks.json +11 -0
  102. package/package.json +16 -4
  103. package/scripts/activites.mjs +2255 -0
  104. package/scripts/aiguillage.d.mts +37 -0
  105. package/scripts/aiguillage.mjs +40 -14
  106. package/scripts/avancement.mjs +155 -26
  107. package/scripts/bilan.mjs +137 -43
  108. package/scripts/cadre.mjs +16 -4
  109. package/scripts/circuit.mjs +993 -4075
  110. package/scripts/circuits-cles.d.mts +4 -0
  111. package/scripts/circuits-cles.mjs +21 -0
  112. package/scripts/circuits-du-serveur.mjs +105 -0
  113. package/scripts/codes-de-sortie.mjs +9 -0
  114. package/scripts/commandes-composees.mjs +45 -41
  115. package/scripts/commandes-du-path.d.mts +7 -0
  116. package/scripts/commandes-du-path.mjs +25 -0
  117. package/scripts/composants-affectes.mjs +64 -21
  118. package/scripts/composition-des-langages.mjs +18 -12
  119. package/scripts/conformite.mjs +56 -28
  120. package/scripts/copies-finies.mjs +52 -47
  121. package/scripts/depart-du-ticket.d.mts +53 -0
  122. package/scripts/depart-du-ticket.mjs +124 -0
  123. package/scripts/dependances-internes.mjs +121 -0
  124. package/scripts/dernier-vert.mjs +61 -34
  125. package/scripts/dette.mjs +32 -11
  126. package/scripts/donnees-cles.mjs +244 -0
  127. package/scripts/droits.mjs +51 -16
  128. package/scripts/effets.mjs +352 -0
  129. package/scripts/empreinte-d-etape.mjs +17 -0
  130. package/scripts/engendres.mjs +15 -5
  131. package/scripts/enveloppe/enveloppe.mjs +259 -55
  132. package/scripts/enveloppe/lancer.sh +14 -18
  133. package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
  134. package/scripts/enveloppe/travail-de-la-copie.mjs +41 -13
  135. package/scripts/etapes.mjs +5 -2
  136. package/scripts/faits-du-circuit.mjs +493 -0
  137. package/scripts/file-des-tickets.d.mts +21 -0
  138. package/scripts/file-des-tickets.mjs +58 -0
  139. package/scripts/flux-des-paquets.mjs +201 -0
  140. package/scripts/gardes-du-cadre.mjs +21 -5
  141. package/scripts/init.mjs +11 -4
  142. package/scripts/integration/file.mjs +544 -434
  143. package/scripts/integration/integrer.mjs +87 -43
  144. package/scripts/integration/rejeu.mjs +45 -13
  145. package/scripts/jointure.d.ts +151 -28
  146. package/scripts/langages/cargo/commandes.mjs +383 -124
  147. package/scripts/langages/cargo/composants.mjs +154 -42
  148. package/scripts/langages/cargo/exemples.mjs +12 -21
  149. package/scripts/langages/cargo/index.mjs +22 -8
  150. package/scripts/langages/cargo/sccache.mjs +8 -14
  151. package/scripts/langages/cargo/tests-de-head.mjs +25 -9
  152. package/scripts/langages/python/commandes.mjs +218 -100
  153. package/scripts/langages/python/composants.mjs +53 -21
  154. package/scripts/langages/python/exemples.mjs +6 -16
  155. package/scripts/langages/python/index.mjs +28 -8
  156. package/scripts/langages/python/lot.mjs +1 -36
  157. package/scripts/langages/typescript/chemins-des-tests.mjs +6 -2
  158. package/scripts/langages/typescript/composants.mjs +9 -3
  159. package/scripts/langages/typescript/consommateurs-arbitres.mjs +40 -14
  160. package/scripts/langages/typescript/consommateurs.mjs +39 -14
  161. package/scripts/langages/typescript/construire.mjs +6 -163
  162. package/scripts/langages/typescript/elements-du-lot.mjs +36 -12
  163. package/scripts/langages/typescript/exemples.mjs +3 -11
  164. package/scripts/langages/typescript/frontieres.mjs +66 -22
  165. package/scripts/langages/typescript/index-interfaces.mjs +36 -13
  166. package/scripts/langages/typescript/index.mjs +50 -61
  167. package/scripts/langages/typescript/interfaces-contre-code.mjs +113 -45
  168. package/scripts/langages/typescript/lecteurs.mjs +36 -11
  169. package/scripts/langages/typescript/migrations/0.23.0-config-vitest.mjs +15 -5
  170. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +6 -2
  171. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +6 -2
  172. package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
  173. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +33 -0
  174. package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
  175. package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
  176. package/scripts/langages/typescript/parcours.mjs +12 -4
  177. package/scripts/langages/typescript/regle-des-tests.mjs +9 -3
  178. package/scripts/langages/typescript/resumes.mjs +9 -3
  179. package/scripts/langages/typescript/tailles-des-tests.mjs +93 -20
  180. package/scripts/langages/typescript/tests-de-nuit.mjs +15 -10
  181. package/scripts/langages/typescript/tests.mjs +40 -15
  182. package/scripts/langages/typescript/titres-de-tests.mjs +320 -0
  183. package/scripts/langages/typescript/turbo-des-paquets.mjs +327 -81
  184. package/scripts/langages/typescript/verdict.mjs +4 -2
  185. package/scripts/langages/typescript/verifier.mjs +58 -20
  186. package/scripts/langages/typescript/vitest-config/avancement.reporter.mjs +15 -5
  187. package/scripts/langages/typescript/vitest-config/base.mjs +29 -3
  188. package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
  189. package/scripts/langages/typescript/vitest-config/changements.mjs +21 -8
  190. package/scripts/langages/typescript/vitest-config/cibles.mjs +36 -14
  191. package/scripts/langages/typescript/vitest-config/delais.mjs +60 -0
  192. package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
  193. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +108 -0
  194. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +56 -59
  195. package/scripts/langages/typescript/vitest-config/lances.mjs +83 -27
  196. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +10 -0
  197. package/scripts/langages/typescript/vitest-config/resultats.mjs +3 -1
  198. package/scripts/langages/typescript/vitest.nuit.config.mjs +4 -0
  199. package/scripts/lint-des-scripts.mjs +58 -0
  200. package/scripts/mesure/base-de-passe.mjs +117 -25
  201. package/scripts/mesure/pression.mjs +12 -6
  202. package/scripts/mesure-de-la-machine.d.mts +21 -0
  203. package/scripts/mesure-de-la-machine.mjs +76 -0
  204. package/scripts/migrations/0.23.0-charte-importee.mjs +6 -2
  205. package/scripts/migrations/0.23.0-crochets-de-seance.mjs +25 -8
  206. package/scripts/migrations/0.23.0-marche-du-projet.mjs +18 -6
  207. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +56 -18
  208. package/scripts/migrations/0.24.12-tri-des-decouvertes.mjs +6 -2
  209. package/scripts/migrations/0.25.0-script-des-tests.mjs +15 -5
  210. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +124 -0
  211. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
  212. package/scripts/migrations.mjs +5 -0
  213. package/scripts/nuit.sh +25 -3
  214. package/scripts/outil.mjs +3 -1
  215. package/scripts/outils-cles.d.mts +24 -0
  216. package/scripts/outils-cles.mjs +18 -8
  217. package/scripts/paquet-npm.mjs +157 -0
  218. package/scripts/paquet.mjs +73 -4
  219. package/scripts/paquets.mjs +46 -10
  220. package/scripts/passe-de-la-machine.mjs +71 -0
  221. package/scripts/places-de-la-machine.mjs +414 -0
  222. package/scripts/places-du-serveur.mjs +170 -0
  223. package/scripts/prefixe-des-tickets.mjs +68 -0
  224. package/scripts/preparation.mjs +25 -8
  225. package/scripts/registre.mjs +9 -4
  226. package/scripts/regles-des-places.d.mts +36 -0
  227. package/scripts/regles-des-places.mjs +70 -0
  228. package/scripts/reponses-du-circuit.d.mts +6 -0
  229. package/scripts/reponses-du-circuit.mjs +28 -0
  230. package/scripts/reprise.mjs +66 -0
  231. package/scripts/resultats.mjs +112 -46
  232. package/scripts/retirer-les-copies-finies.mjs +25 -0
  233. package/scripts/sans-reponse.d.mts +4 -0
  234. package/scripts/sans-reponse.mjs +13 -0
  235. package/scripts/seances.mjs +936 -0
  236. package/scripts/services-du-noyau.mjs +27 -8
  237. package/scripts/session-start.sh +2 -2
  238. package/scripts/sortie.mjs +3 -3
  239. package/scripts/sous-commandes.mjs +41 -10
  240. package/scripts/style-a-l-ecriture.mjs +260 -0
  241. package/scripts/superviseur.mjs +122 -111
  242. package/scripts/tableau.mjs +180 -117
  243. package/scripts/taches-du-graphe.mjs +348 -0
  244. package/scripts/ticket-du-circuit.mjs +216 -0
  245. package/scripts/transitions.d.mts +148 -0
  246. package/scripts/transitions.mjs +1018 -0
  247. package/scripts/verrou-de-fichier.mjs +8 -4
  248. package/scripts/verrou-de-machine.mjs +150 -51
  249. package/scripts/verrous/commande.mjs +50 -17
  250. package/scripts/verrous/ticket-du-sous-agent.mjs +9 -3
  251. package/scripts/verrous/verrou.mjs +42 -14
  252. package/skills/explorateur/SKILL.md +9 -2
  253. package/skills/grill/SKILL.md +1 -1
  254. package/skills/mesure/SKILL.md +3 -0
  255. package/skills/pitmaster/SKILL.md +17 -18
  256. package/skills/pitmaster/references/consigne-agent.md +5 -1
  257. package/skills/release/SKILL.md +3 -3
  258. package/skills/relecteur/SKILL.md +5 -3
  259. package/skills/testwriter/SKILL.md +49 -31
  260. package/scripts/demon.mjs +0 -251
  261. package/scripts/integration/file-attente.mjs +0 -61
  262. package/scripts/langages/cargo/touches.mjs +0 -93
  263. package/scripts/langages/typescript/script-des-tests.mjs +0 -6
@@ -0,0 +1,21 @@
1
+ // The contract of the workflow of the machine, which holds its places (grillhouse-4nr.7,
2
+ // decision D2): its type, its update, its signals and its queries by their names, its id, its state
3
+ // and what its callers send and receive. The workflow, its activities and their clients share it
4
+ // without importing each other.
5
+ /** The workflow's type. */
6
+ export const PLACES = 'placesDeLaMachine';
7
+ /** The id of the one workflow of the machine. */
8
+ export const ID_DES_PLACES = 'grillhouse-places-de-la-machine';
9
+ /** The update that asks for a place: it records the request and returns at once. */
10
+ export const PRENDRE = 'prendre';
11
+ /** The update that draws the next rank of arrival of the machine, which a circuit keeps. */
12
+ export const TIRER_UN_RANG = 'tirerUnRang';
13
+ /** The signal that gives a place back, or withdraws a request that waits. */
14
+ export const RENDRE = 'rendre';
15
+ /** The signal that names the process that holds a place or a request. */
16
+ export const RATTACHER = 'rattacher';
17
+ /** The query of the places, which the board reads. */
18
+ export const LES_PLACES = 'lesPlaces';
19
+ /** The query of one request: given, waiting, or unknown (withdrawn, or its process gone). */
20
+ export const LA_DEMANDE = 'laDemande';
21
+ //# sourceMappingURL=contrat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contrat.js","sourceRoot":"","sources":["../../../src/temporal/places/contrat.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,oGAAoG;AACpG,iGAAiG;AACjG,gCAAgC;AAEhC,2BAA2B;AAC3B,MAAM,CAAC,MAAM,MAAM,GAAG,mBAAmB,CAAC;AAC1C,iDAAiD;AACjD,MAAM,CAAC,MAAM,aAAa,GAAG,iCAAiC,CAAC;AAC/D,oFAAoF;AACpF,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;AACjC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;AAC3C,6EAA6E;AAC7E,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC;AAC/B,yEAAyE;AACzE,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;AACrC,sDAAsD;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC;AACtC,6FAA6F;AAC7F,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type EntreeDesPlaces } from './contrat.js';
2
+ /** The places of the machine, until the next Continue-As-New. */
3
+ export declare function placesDeLaMachine(entree: EntreeDesPlaces): Promise<void>;
@@ -0,0 +1,198 @@
1
+ // The workflow of the machine, which holds its places (grillhouse-4nr.7, decision D2), as the job
2
+ // server of GNU make shares its slots between every make of a build, and as the semaphore of
3
+ // Temporal's samples (samples-typescript « mutex ») grants its leases: one workflow for the machine
4
+ // (ID_DES_PLACES), the one state of the places, which every pass and session of the machine reads
5
+ // (scripts/places-de-la-machine.mjs). A circuit draws its rank of arrival at its launch by the
6
+ // update TIRER_UN_RANG; a session asks for a place by the update PRENDRE, which records its request and returns at once;
7
+ // the main loop grants the places, and the session learns its grant by the query LA_DEMANDE, so no
8
+ // handler stays open while a request waits, and a request lives in the state a Continue-As-New
9
+ // carries. The signal RENDRE gives a place back or withdraws a request, RATTACHER names the process
10
+ // that holds a place; the query LES_PLACES gives the board the places and the requests that wait.
11
+ // A grant passes by the rule of the places (`refusDeLaPlace` of
12
+ // scripts/regles-des-places.mjs): a free place under the ceiling, the turn of its rank of arrival
13
+ // between projects, the admission at the load and the memory (measured by an activity, once per
14
+ // judgement and only when the place and the turn pass), the spacing of the starts. The requests
15
+ // are judged again at each change and every `veilleMs`; a place or a request whose process is gone
16
+ // (one activity for all of them) is removed for good then. Past its length of history
17
+ // (`continueAsNewSuggested`, or `limiteDHistoire`), the workflow continues as new with its state.
18
+ // Deterministic: it imports the workflow API, the contract and the pure rule.
19
+ import { allHandlersFinished, condition, continueAsNew, defineQuery, defineSignal, defineUpdate, proxyActivities, setHandler, workflowInfo, } from '@temporalio/workflow';
20
+ import { refusDeLaPlace } from '../../../scripts/regles-des-places.mjs';
21
+ import { LA_DEMANDE, LES_PLACES, PRENDRE, RATTACHER, RENDRE, TIRER_UN_RANG, } from './contrat.js';
22
+ const { mesurerLaMachine, processusVivants } = proxyActivities({
23
+ startToCloseTimeout: '30 seconds',
24
+ retry: { initialInterval: '1 second', maximumAttempts: 5 },
25
+ });
26
+ const prendre = defineUpdate(PRENDRE);
27
+ const tirerUnRang = defineUpdate(TIRER_UN_RANG);
28
+ const rendre = defineSignal(RENDRE);
29
+ const rattacher = defineSignal(RATTACHER);
30
+ const lesPlaces = defineQuery(LES_PLACES);
31
+ const laDemande = defineQuery(LA_DEMANDE);
32
+ // The measure the rule asks for, which the workflow reads by its activity.
33
+ class BesoinDeLaMesure extends Error {
34
+ }
35
+ const LIMITE_D_HISTOIRE = 2000;
36
+ /** The places of the machine, until the next Continue-As-New. */
37
+ export async function placesDeLaMachine(entree) {
38
+ const etat = entree.etat ?? { rang: 0, dernier: 0, prises: [], attentes: [] };
39
+ // Each change of the places, which wakes the main loop.
40
+ let version = 0;
41
+ const changer = () => {
42
+ version += 1;
43
+ };
44
+ // Removes the places and the requests whose process is gone, by one activity for all of them. A
45
+ // place or a request attached to another process while the lives are read (`rattacher`, handled
46
+ // during the await) is judged on that process at the next reading, not on the one read.
47
+ const purger = async () => {
48
+ const tous = [...etat.prises, ...etat.attentes].map(x => ({
49
+ id: x.id,
50
+ pid: x.pid,
51
+ depart: x.depart,
52
+ }));
53
+ if (!tous.length) {
54
+ return;
55
+ }
56
+ const vivants = await processusVivants(tous.map(x => ({ pid: x.pid, depart: x.depart })));
57
+ const actuel = new Map([...etat.prises, ...etat.attentes].map(x => [x.id, x]));
58
+ const morts = new Set(tous
59
+ .filter((x, i) => {
60
+ const a = actuel.get(x.id);
61
+ return vivants[i] === false && a?.pid === x.pid && a.depart === x.depart;
62
+ })
63
+ .map(x => x.id));
64
+ if (!morts.size) {
65
+ return;
66
+ }
67
+ etat.prises = etat.prises.filter(p => !morts.has(p.id));
68
+ etat.attentes = etat.attentes.filter(a => !morts.has(a.id));
69
+ changer();
70
+ };
71
+ // Grants the requests in their order of arrival, each by the rule; the machine measured at most
72
+ // once, when a request passes the place and the turn. A request withdrawn while the measure is
73
+ // read (the signal RENDRE, handled during its await) is judged no more.
74
+ const juger = async () => {
75
+ let mesure = entree.mesureFixe ?? null;
76
+ const encore = (id) => etat.attentes.some(x => x.id === id);
77
+ for (const a of [...etat.attentes].sort((x, y) => x.rang - y.rang)) {
78
+ if (!encore(a.id)) {
79
+ continue;
80
+ }
81
+ const regle = (m) => refusDeLaPlace(etat, {
82
+ id: a.id,
83
+ rang: a.rang,
84
+ plafond: entree.plafond,
85
+ espacementMs: entree.espacementMs,
86
+ maintenant: Date.now(),
87
+ mesurer: m,
88
+ });
89
+ let raison;
90
+ try {
91
+ raison = regle(() => {
92
+ if (mesure) {
93
+ return mesure;
94
+ }
95
+ throw new BesoinDeLaMesure();
96
+ });
97
+ }
98
+ catch (e) {
99
+ if (!(e instanceof BesoinDeLaMesure)) {
100
+ throw e;
101
+ }
102
+ mesure = await mesurerLaMachine();
103
+ if (!encore(a.id)) {
104
+ continue;
105
+ }
106
+ const m = mesure;
107
+ raison = regle(() => m);
108
+ }
109
+ if (raison === null) {
110
+ etat.attentes = etat.attentes.filter(x => x.id !== a.id);
111
+ etat.prises.push({
112
+ id: a.id,
113
+ pid: a.pid,
114
+ depart: a.depart,
115
+ ticket: a.ticket,
116
+ rang: a.rang,
117
+ depuis: Date.now(),
118
+ });
119
+ etat.dernier = Date.now();
120
+ changer();
121
+ }
122
+ else if (a.raison !== raison) {
123
+ a.raison = raison;
124
+ }
125
+ }
126
+ };
127
+ setHandler(prendre, demande => {
128
+ const connue = etat.prises.find(p => p.id === demande.id) ?? etat.attentes.find(a => a.id === demande.id);
129
+ if (connue) {
130
+ return { id: connue.id, rang: connue.rang };
131
+ }
132
+ const rang = demande.rang ?? etat.rang + 1;
133
+ etat.rang = Math.max(etat.rang, rang);
134
+ etat.attentes.push({
135
+ id: demande.id,
136
+ pid: demande.pid,
137
+ depart: demande.depart,
138
+ ticket: demande.ticket ?? null,
139
+ rang,
140
+ raison: 'pas encore jugée',
141
+ depuis: Date.now(),
142
+ });
143
+ changer();
144
+ return { id: demande.id, rang };
145
+ });
146
+ setHandler(tirerUnRang, () => {
147
+ etat.rang += 1;
148
+ return etat.rang;
149
+ });
150
+ setHandler(rendre, id => {
151
+ const n = etat.prises.length + etat.attentes.length;
152
+ etat.prises = etat.prises.filter(p => p.id !== id);
153
+ etat.attentes = etat.attentes.filter(a => a.id !== id);
154
+ if (etat.prises.length + etat.attentes.length !== n) {
155
+ changer();
156
+ }
157
+ });
158
+ setHandler(rattacher, ({ id, pid, depart }) => {
159
+ const p = etat.prises.find(x => x.id === id) ?? etat.attentes.find(x => x.id === id);
160
+ if (p) {
161
+ p.pid = pid;
162
+ p.depart = depart;
163
+ changer();
164
+ }
165
+ });
166
+ setHandler(lesPlaces, () => ({
167
+ plafond: entree.plafond,
168
+ prises: etat.prises,
169
+ attentes: [...etat.attentes].sort((a, b) => a.rang - b.rang),
170
+ }));
171
+ setHandler(laDemande, id => {
172
+ const p = etat.prises.find(x => x.id === id);
173
+ if (p) {
174
+ return { etat: 'donnee', rang: p.rang };
175
+ }
176
+ const a = etat.attentes.find(x => x.id === id);
177
+ return a ? { etat: 'attend', rang: a.rang, raison: a.raison } : { etat: 'inconnue' };
178
+ });
179
+ const limite = entree.limiteDHistoire ?? LIMITE_D_HISTOIRE;
180
+ const aContinuer = () => workflowInfo().continueAsNewSuggested || workflowInfo().historyLength >= limite;
181
+ // The version the last judgement started from: a change during it (a request, a place given
182
+ // back, its own grants) wakes the next one at once.
183
+ let jugee = -1;
184
+ for (;;) {
185
+ await condition(() => version !== jugee || aContinuer(), entree.veilleMs);
186
+ jugee = version;
187
+ if (etat.prises.length || etat.attentes.length) {
188
+ await purger();
189
+ await juger();
190
+ }
191
+ if (aContinuer()) {
192
+ // Every handler returns at once: none holds the run open.
193
+ await condition(allHandlersFinished);
194
+ await continueAsNew({ ...entree, etat });
195
+ }
196
+ }
197
+ }
198
+ //# sourceMappingURL=deroule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deroule.js","sourceRoot":"","sources":["../../../src/temporal/places/deroule.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,6FAA6F;AAC7F,oGAAoG;AACpG,kGAAkG;AAClG,+FAA+F;AAC/F,yHAAyH;AACzH,mGAAmG;AACnG,+FAA+F;AAC/F,oGAAoG;AACpG,kGAAkG;AAClG,gEAAgE;AAChE,kGAAkG;AAClG,gGAAgG;AAChG,gGAAgG;AAChG,mGAAmG;AACnG,sFAAsF;AACtF,kGAAkG;AAClG,8EAA8E;AAC9E,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,aAAa,EACb,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,UAAU,EACV,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExE,OAAO,EACL,UAAU,EACV,UAAU,EACV,OAAO,EACP,SAAS,EACT,MAAM,EACN,aAAa,GASd,MAAM,cAAc,CAAC;AAEtB,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,eAAe,CAAmB;IAC/E,mBAAmB,EAAE,YAAY;IACjC,KAAK,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,EAAE;CAC3D,CAAC,CAAC;AAEH,MAAM,OAAO,GAAG,YAAY,CAAgC,OAAO,CAAC,CAAC;AACrE,MAAM,WAAW,GAAG,YAAY,CAAa,aAAa,CAAC,CAAC;AAC5D,MAAM,MAAM,GAAG,YAAY,CAAW,MAAM,CAAC,CAAC;AAC9C,MAAM,SAAS,GAAG,YAAY,CAAiB,SAAS,CA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AAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/C,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IACvF,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,IAAI,iBAAiB,CAAC;IAC3D,MAAM,UAAU,GAAG,GAAG,EAAE,CACtB,YAAY,EAAE,CAAC,sBAAsB,IAAI,YAAY,EAAE,CAAC,aAAa,IAAI,MAAM,CAAC;IAClF,4FAA4F;IAC5F,oDAAoD;IACpD,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;IACf,SAAS,CAAC;QACR,MAAM,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,KAAK,KAAK,IAAI,UAAU,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1E,KAAK,GAAG,OAAO,CAAC;QAChB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YAC/C,MAAM,MAAM,EAAE,CAAC;YACf,MAAM,KAAK,EAAE,CAAC;QAChB,CAAC;QACD,IAAI,UAAU,EAAE,EAAE,CAAC;YACjB,0DAA0D;YAC1D,MAAM,SAAS,CAAC,mBAAmB,CAAC,CAAC;YACrC,MAAM,aAAa,CAA2B,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { ResultatDeLActivite } from './contrat.js';
2
+ /** Runs the sonde's process for <etapes> steps, <pauseMs> ms apart, from its last sign of life. */
3
+ export declare function lancerLaSonde({ etapes, pauseMs, }: {
4
+ etapes: number;
5
+ pauseMs: number;
6
+ }): Promise<ResultatDeLActivite>;
@@ -0,0 +1,52 @@
1
+ // The sonde's activity: it starts a process that does its steps one by one and says each on its
2
+ // standard output, and sends a sign of life to the server at each step (`heartbeat`, the steps
3
+ // done). When its worker dies, the server gives the activity again once its sign of life is late,
4
+ // and the new attempt starts its process from the last sign of life the server kept
5
+ // (`heartbeatDetails`). A cancellation (the worker stopping) ends the process.
6
+ import { spawn } from 'node:child_process';
7
+ import { createInterface } from 'node:readline';
8
+ import { Context } from '@temporalio/activity';
9
+ // The process: from the step argv[1] to argv[2], one step every argv[3] ms, each said `fait <n>`;
10
+ // its reader gone (its worker killed), it ends at its next step.
11
+ const PROCESSUS = `
12
+ process.stdout.on('error', () => process.exit(1));
13
+ const [depuis, etapes, pause] = process.argv.slice(1).map(Number);
14
+ let i = depuis;
15
+ const pas = () => {
16
+ if (i >= etapes) return;
17
+ i += 1;
18
+ process.stdout.write('fait ' + i + '\\n');
19
+ setTimeout(pas, pause);
20
+ };
21
+ setTimeout(pas, pause);
22
+ `;
23
+ /** Runs the sonde's process for <etapes> steps, <pauseMs> ms apart, from its last sign of life. */
24
+ export async function lancerLaSonde({ etapes, pauseMs, }) {
25
+ const ctx = Context.current();
26
+ const depuis = ctx.info.heartbeatDetails?.fait ?? 0;
27
+ const enfant = spawn(process.execPath, ['-e', PROCESSUS, String(depuis), String(etapes), String(pauseMs)], { stdio: ['ignore', 'pipe', 'inherit'] });
28
+ const arreter = () => enfant.kill('SIGTERM');
29
+ ctx.cancellationSignal.addEventListener('abort', arreter);
30
+ let fait = depuis;
31
+ ctx.heartbeat({ fait });
32
+ createInterface({ input: enfant.stdout }).on('line', l => {
33
+ const m = /^fait (\d+)$/.exec(l);
34
+ if (m) {
35
+ fait = Number(m[1]);
36
+ ctx.heartbeat({ fait });
37
+ }
38
+ });
39
+ const code = await new Promise((ok, ko) => {
40
+ enfant.once('error', ko);
41
+ enfant.once('close', ok);
42
+ });
43
+ ctx.cancellationSignal.removeEventListener('abort', arreter);
44
+ if (ctx.cancellationSignal.aborted) {
45
+ throw ctx.cancellationSignal.reason;
46
+ }
47
+ if (code !== 0) {
48
+ throw new Error(`le processus de la sonde sort en ${code}`);
49
+ }
50
+ return { fait, depuis, tentative: ctx.info.attempt, pid: enfant.pid ?? 0 };
51
+ }
52
+ //# sourceMappingURL=activites.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activites.js","sourceRoot":"","sources":["../../../src/temporal/sonde/activites.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,+FAA+F;AAC/F,kGAAkG;AAClG,oFAAoF;AACpF,+EAA+E;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,kGAAkG;AAClG,iEAAiE;AACjE,MAAM,SAAS,GAAG;;;;;;;;;;;CAWjB,CAAC;AAEF,mGAAmG;AACnG,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,EAClC,MAAM,EACN,OAAO,GAIR;IACC,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAC9B,MAAM,MAAM,GAAI,GAAG,CAAC,IAAI,CAAC,gBAA2C,EAAE,IAAI,IAAI,CAAC,CAAC;IAChF,MAAM,MAAM,GAAG,KAAK,CAClB,OAAO,CAAC,QAAQ,EAChB,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,EAClE,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,CACzC,CAAC;IACF,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7C,GAA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CAAC"}
@@ -0,0 +1,35 @@
1
+ /** The workflow's type. */
2
+ export declare const SONDE = "sonde";
3
+ /** The signal that ends the wait of the workflow. */
4
+ export declare const FINIR = "finir";
5
+ /** What the workflow receives. */
6
+ export interface EntreeDeLaSonde {
7
+ /** The ticket the workflow carries, its search attribute GrillhouseTicket. */
8
+ ticket: string;
9
+ /** The steps the activity's process does. */
10
+ etapes: number;
11
+ /** The pause of the process between two steps, in milliseconds. */
12
+ pauseMs: number;
13
+ /** Whether the workflow waits for the signal FINIR once its activity is done. */
14
+ attendreLeSignal: boolean;
15
+ }
16
+ /** The sign of life of the activity: the steps its process has done. */
17
+ export interface SigneDeVie {
18
+ fait: number;
19
+ }
20
+ /** What the activity gives back. */
21
+ export interface ResultatDeLActivite {
22
+ /** The steps done, all of them. */
23
+ fait: number;
24
+ /** The step the attempt started from: its last sign of life, 0 for a first attempt. */
25
+ depuis: number;
26
+ /** The attempt, from 1. */
27
+ tentative: number;
28
+ /** The process the attempt started. */
29
+ pid: number;
30
+ }
31
+ /** What the workflow gives back. */
32
+ export interface ResultatDeLaSonde {
33
+ ticket: string;
34
+ activite: ResultatDeLActivite;
35
+ }
@@ -0,0 +1,10 @@
1
+ // The contract of the sonde, which the workflow, its activity and their clients share without
2
+ // importing each other: the workflow's type and its signal by their names, what it receives, what
3
+ // it and its activity give back, and the sign of life the activity sends. The sonde proves the
4
+ // service: a workflow whose activity starts a process and sends its signs of life, which waits for
5
+ // a signal when asked, and upserts its step at each move.
6
+ /** The workflow's type. */
7
+ export const SONDE = 'sonde';
8
+ /** The signal that ends the wait of the workflow. */
9
+ export const FINIR = 'finir';
10
+ //# sourceMappingURL=contrat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contrat.js","sourceRoot":"","sources":["../../../src/temporal/sonde/contrat.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,kGAAkG;AAClG,+FAA+F;AAC/F,mGAAmG;AACnG,0DAA0D;AAE1D,2BAA2B;AAC3B,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC;AAE7B,qDAAqD;AACrD,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type EntreeDeLaSonde, type ResultatDeLaSonde } from './contrat.js';
2
+ /** The sonde: its activity, then the wait for FINIR when asked. */
3
+ export declare function sonde(entree: EntreeDeLaSonde): Promise<ResultatDeLaSonde>;
@@ -0,0 +1,39 @@
1
+ // The sonde's workflow, which the worker bundles (Worker.create, workflowsPath): it upserts its
2
+ // ticket and its step as search attributes, runs its activity (a process with its signs of life,
3
+ // started again from its last sign of life when its worker dies), waits for the signal FINIR when
4
+ // asked, and gives back what its activity did. Deterministic: it imports nothing but the workflow
5
+ // API, the search attributes and the contract.
6
+ import { condition, defineSignal, proxyActivities, setHandler, upsertSearchAttributes, workflowInfo, } from '@temporalio/workflow';
7
+ import { ATTRIBUT_ETAPE, ATTRIBUT_TICKET } from '../attributs.js';
8
+ import { FINIR } from './contrat.js';
9
+ // The activity: its sign of life awaited every 3 s, an attempt given again after 1 s.
10
+ const { lancerLaSonde } = proxyActivities({
11
+ startToCloseTimeout: '10 minutes',
12
+ heartbeatTimeout: '3 seconds',
13
+ retry: { initialInterval: '1 second', maximumAttempts: 5 },
14
+ });
15
+ const finir = defineSignal(FINIR);
16
+ // Upserts the step <etape>, and the ticket <ticket> when the workflow does not carry it yet.
17
+ function etape(etape, ticket) {
18
+ const attributs = [{ key: ATTRIBUT_ETAPE, value: etape }];
19
+ if (workflowInfo().typedSearchAttributes.get(ATTRIBUT_TICKET) !== ticket) {
20
+ attributs.push({ key: ATTRIBUT_TICKET, value: ticket });
21
+ }
22
+ upsertSearchAttributes(attributs);
23
+ }
24
+ /** The sonde: its activity, then the wait for FINIR when asked. */
25
+ export async function sonde(entree) {
26
+ let fini = false;
27
+ setHandler(finir, () => {
28
+ fini = true;
29
+ });
30
+ etape('activite', entree.ticket);
31
+ const activite = await lancerLaSonde({ etapes: entree.etapes, pauseMs: entree.pauseMs });
32
+ if (entree.attendreLeSignal) {
33
+ etape('attente', entree.ticket);
34
+ await condition(() => fini);
35
+ }
36
+ etape('fini', entree.ticket);
37
+ return { ticket: entree.ticket, activite };
38
+ }
39
+ //# sourceMappingURL=deroule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deroule.js","sourceRoot":"","sources":["../../../src/temporal/sonde/deroule.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,iGAAiG;AACjG,kGAAkG;AAClG,kGAAkG;AAClG,+CAA+C;AAC/C,OAAO,EACL,SAAS,EACT,YAAY,EACZ,eAAe,EACf,UAAU,EACV,sBAAsB,EACtB,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAAE,KAAK,EAAgD,MAAM,cAAc,CAAC;AAEnF,sFAAsF;AACtF,MAAM,EAAE,aAAa,EAAE,GAAG,eAAe,CAAmB;IAC1D,mBAAmB,EAAE,YAAY;IACjC,gBAAgB,EAAE,WAAW;IAC7B,KAAK,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,EAAE;CAC3D,CAAC,CAAC;AAEH,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;AAElC,6FAA6F;AAC7F,SAAS,KAAK,CAAC,KAAa,EAAE,MAAc;IAC1C,MAAM,SAAS,GAAG,CAAC,EAAE,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1D,IAAI,YAAY,EAAE,CAAC,qBAAqB,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,MAAM,EAAE,CAAC;QACzE,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1D,CAAC;IACD,sBAAsB,CAAC,SAAS,CAAC,CAAC;AACpC,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,MAAuB;IACjD,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE;QACrB,IAAI,GAAG,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IACzF,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC5B,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAChC,MAAM,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IACD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ActivitesDesTickets } from './contrat.js';
2
+ type Entree<K extends keyof ActivitesDesTickets> = Parameters<ActivitesDesTickets[K]>[0];
3
+ type Sortie<K extends keyof ActivitesDesTickets> = Awaited<ReturnType<ActivitesDesTickets[K]>>;
4
+ export declare function ticketsAPartir(e: Entree<'ticketsAPartir'>): Promise<Sortie<'ticketsAPartir'>>;
5
+ export declare function circuitsVivants(e: Entree<'circuitsVivants'>): Promise<string[]>;
6
+ export declare function circuitsNonIntegres(e: Entree<'circuitsNonIntegres'>): Promise<string[]>;
7
+ export {};
@@ -0,0 +1,81 @@
1
+ // The activities of the queue of the tickets of a project (./deroule.ts): the tickets that start,
2
+ // read from Beads in the main tree of the repository with the setting of its package.json, the
3
+ // circuits of the project alive and those not integrated, read from the server. A package.json that does not parse, or a Beads that fails, is a fault named, never a key
4
+ // absent nor an empty list.
5
+ import { readFileSync } from 'node:fs';
6
+ import path from 'node:path';
7
+ import { reglageDesCircuits } from '../../../scripts/circuits-cles.mjs';
8
+ import { lireLesTickets, ticketsAPartir as aPartir } from '../../../scripts/file-des-tickets.mjs';
9
+ import { ouvrirLeClient } from '../client.js';
10
+ import { lireLesCircuits } from '../circuit/client.js';
11
+ import { idDuCircuit } from '../circuit/contrat.js';
12
+ // The package.json of the project at <racine>: absent, null; one that does not parse throws.
13
+ function lePaquet(racine) {
14
+ let texte;
15
+ try {
16
+ texte = readFileSync(path.join(racine, 'package.json'), 'utf8');
17
+ }
18
+ catch {
19
+ return null;
20
+ }
21
+ try {
22
+ return JSON.parse(texte);
23
+ }
24
+ catch (e) {
25
+ throw new Error(`package.json ne se lit pas : ${e.message}`);
26
+ }
27
+ }
28
+ export function ticketsAPartir(e) {
29
+ const faute = (message) => Promise.resolve({ partir: [], max: null, faute: message });
30
+ let paquet;
31
+ try {
32
+ paquet = lePaquet(e.racine);
33
+ }
34
+ catch (x) {
35
+ return faute(x.message);
36
+ }
37
+ const reglage = reglageDesCircuits(paquet);
38
+ if (reglage.faute) {
39
+ return faute(reglage.faute);
40
+ }
41
+ let tickets;
42
+ try {
43
+ tickets = lireLesTickets(e.racine);
44
+ }
45
+ catch (x) {
46
+ return faute(x.message);
47
+ }
48
+ return Promise.resolve({
49
+ partir: aPartir(tickets, { enCours: new Set(e.enCours) }).map(t => t.id),
50
+ max: reglage.max,
51
+ faute: null,
52
+ });
53
+ }
54
+ export async function circuitsVivants(e) {
55
+ const prefixe = idDuCircuit(e.racine, '');
56
+ const c = ouvrirLeClient();
57
+ try {
58
+ const vivants = [];
59
+ for await (const w of c.client.workflow.list({
60
+ query: `WorkflowType = 'circuitDuTicket' AND ExecutionStatus = 'Running'`,
61
+ })) {
62
+ if (w.workflowId.startsWith(prefixe)) {
63
+ vivants.push(w.workflowId.slice(prefixe.length));
64
+ }
65
+ }
66
+ return vivants.sort();
67
+ }
68
+ finally {
69
+ await c.fermer();
70
+ }
71
+ }
72
+ export async function circuitsNonIntegres(e) {
73
+ const c = ouvrirLeClient();
74
+ try {
75
+ return (await lireLesCircuits(c.client, e.racine)).map(x => x.ticket).sort();
76
+ }
77
+ finally {
78
+ await c.fermer();
79
+ }
80
+ }
81
+ //# sourceMappingURL=activites.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activites.js","sourceRoot":"","sources":["../../../src/temporal/tickets/activites.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,+FAA+F;AAC/F,yKAAyK;AACzK,4BAA4B;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,uCAAuC,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMpD,6FAA6F;AAC7F,SAAS,QAAQ,CAAC,MAAc;IAC9B,IAAI,KAAa,CAAC;IAClB,IAAI,CAAC;QACH,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,gCAAiC,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC;AAED,MAAM,UAA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AAc,EAAE,CAAC;IAC3B,IAAI,CAAC;QACH,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,IAAI,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;YAC3C,KAAK,EAAE,kEAAkE;SAC1E,CAAC,EAAE,CAAC;YACH,IAAI,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;gBACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,CAAgC;IACxE,MAAM,CAAC,GAAG,cAAc,EAAE,CAAC;IAC3B,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,eAAe,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/E,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Client } from '@temporalio/client';
2
+ import { type EntreeDesTickets, type VueDesTickets } from './contrat.js';
3
+ /**
4
+ * Starts the queue of the tickets of <entree> on the task queue <file>, or leaves the one that
5
+ * runs; with <seance> (the supervisor's session that puts a ticket in it, or null), signals it to
6
+ * the queue, started if need be, which gives it to each circuit it starts then.
7
+ */
8
+ export declare function demarrerLesTickets(client: Client, entree: EntreeDesTickets, file: string, seance?: string | null): Promise<string>;
9
+ /** The queue of the tickets of the project at <racine>: its circuits alive, its fault. */
10
+ export declare function lireLaFileDesTickets(client: Client, racine: string): Promise<VueDesTickets>;
@@ -0,0 +1,31 @@
1
+ import { DES_TICKETS, idDesTickets, L_ETAT_DES_TICKETS, SEANCE_DU_SUPERVISEUR, } from './contrat.js';
2
+ /**
3
+ * Starts the queue of the tickets of <entree> on the task queue <file>, or leaves the one that
4
+ * runs; with <seance> (the supervisor's session that puts a ticket in it, or null), signals it to
5
+ * the queue, started if need be, which gives it to each circuit it starts then.
6
+ */
7
+ export async function demarrerLesTickets(client, entree, file, seance) {
8
+ const id = idDesTickets(entree.racine);
9
+ if (seance !== undefined) {
10
+ await client.workflow.signalWithStart(DES_TICKETS, {
11
+ workflowId: id,
12
+ taskQueue: file,
13
+ args: [entree],
14
+ signal: SEANCE_DU_SUPERVISEUR,
15
+ signalArgs: [seance],
16
+ });
17
+ return id;
18
+ }
19
+ await client.workflow.start(DES_TICKETS, {
20
+ workflowId: id,
21
+ taskQueue: file,
22
+ args: [entree],
23
+ workflowIdConflictPolicy: 'USE_EXISTING',
24
+ });
25
+ return id;
26
+ }
27
+ /** The queue of the tickets of the project at <racine>: its circuits alive, its fault. */
28
+ export async function lireLaFileDesTickets(client, racine) {
29
+ return client.workflow.getHandle(idDesTickets(racine)).query(L_ETAT_DES_TICKETS);
30
+ }
31
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/temporal/tickets/client.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,GAGtB,MAAM,cAAc,CAAC;AAEtB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAc,EACd,MAAwB,EACxB,IAAY,EACZ,MAAsB;IAEtB,MAAM,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,WAAW,EAAE;YACjD,UAAU,EAAE,EAAE;YACd,SAAS,EAAE,IAAI;YACf,IAAI,EAAE,CAAC,MAAM,CAAC;YACd,MAAM,EAAE,qBAAqB;YAC7B,UAAU,EAAE,CAAC,MAAM,CAAC;SACrB,CAAC,CAAC;QACH,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE;QACvC,UAAU,EAAE,EAAE;QACd,SAAS,EAAE,IAAI;QACf,IAAI,EAAE,CAAC,MAAM,CAAC;QACd,wBAAwB,EAAE,cAAc;KACzC,CAAC,CAAC;IACH,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,0FAA0F;AAC1F,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAAc,EAAE,MAAc;IACvE,OAAO,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAgB,kBAAkB,CAAC,CAAC;AAClG,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { EntreeDuCircuit } from '../circuit/contrat.js';
2
+ /** The workflow's type. */
3
+ export declare const DES_TICKETS = "ticketsDuProjet";
4
+ /** The id of the one queue of the tickets of the repository at <racine>. */
5
+ export declare const idDesTickets: (racine: string) => string;
6
+ /** The query of the queue: the circuits alive, and the fault of the setting. */
7
+ export declare const L_ETAT_DES_TICKETS = "etatDesTickets";
8
+ /**
9
+ * The signal by which `npx grillhouse circuit <ticket>` gives the queue the supervisor's session
10
+ * that put a ticket in it (a string, or null), which each circuit it starts then receives; it
11
+ * wakes the queue.
12
+ */
13
+ export declare const SEANCE_DU_SUPERVISEUR = "seanceDuSuperviseur";
14
+ /** What the queue receives. */
15
+ export interface EntreeDesTickets {
16
+ racine: string;
17
+ /** How often the queue wakes by itself, in ms: 60 s. */
18
+ reveilMs?: number;
19
+ /** What each circuit it starts receives besides its ticket (`repasserMs`, `ci`…). */
20
+ circuit?: Omit<EntreeDuCircuit, 'racine' | 'ticket' | 'suite'>;
21
+ }
22
+ /** The queue as its query gives it. */
23
+ export interface VueDesTickets {
24
+ /** The tickets whose circuit runs, as the queue last counted them. */
25
+ vivants: string[];
26
+ /** The fault that starts nothing (the setting, the package.json, Beads), by its name; null without one. */
27
+ faute: string | null;
28
+ }
29
+ export interface ActivitesDesTickets {
30
+ /**
31
+ * The tickets of the project that start now (`ticketsAPartir` of scripts/file-des-tickets.mjs,
32
+ * those of <enCours> aside), in their order, and the setting (`reglageDesCircuits` of
33
+ * scripts/circuits-cles.mjs): the number of circuits at once, or, with nothing to start, the
34
+ * fault by its name (the setting, a package.json that does not parse, a Beads that fails).
35
+ */
36
+ ticketsAPartir(e: {
37
+ racine: string;
38
+ enCours: string[];
39
+ }): Promise<{
40
+ partir: string[];
41
+ max: number | null;
42
+ faute: string | null;
43
+ }>;
44
+ /** The tickets of the project whose circuit runs, read from the server. */
45
+ circuitsVivants(e: {
46
+ racine: string;
47
+ }): Promise<string[]>;
48
+ /**
49
+ * The tickets of the project whose circuit the server holds, not integrated (`lireLesCircuits`
50
+ * of ../circuit/client.ts, one call): a circuit stopped on a question, its workflow running, or
51
+ * ended without its issue holds its ticket.
52
+ */
53
+ circuitsNonIntegres(e: {
54
+ racine: string;
55
+ }): Promise<string[]>;
56
+ }
@@ -0,0 +1,13 @@
1
+ /** The workflow's type. */
2
+ export const DES_TICKETS = 'ticketsDuProjet';
3
+ /** The id of the one queue of the tickets of the repository at <racine>. */
4
+ export const idDesTickets = (racine) => `tickets:${racine}`;
5
+ /** The query of the queue: the circuits alive, and the fault of the setting. */
6
+ export const L_ETAT_DES_TICKETS = 'etatDesTickets';
7
+ /**
8
+ * The signal by which `npx grillhouse circuit <ticket>` gives the queue the supervisor's session
9
+ * that put a ticket in it (a string, or null), which each circuit it starts then receives; it
10
+ * wakes the queue.
11
+ */
12
+ export const SEANCE_DU_SUPERVISEUR = 'seanceDuSuperviseur';
13
+ //# sourceMappingURL=contrat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contrat.js","sourceRoot":"","sources":["../../../src/temporal/tickets/contrat.ts"],"names":[],"mappings":"AAKA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAC7C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,WAAW,MAAM,EAAE,CAAC;AACpE,gFAAgF;AAChF,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AACnD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type EntreeDesTickets } from './contrat.js';
2
+ /** The queue of the tickets of the project at <racine>. */
3
+ export declare function ticketsDuProjet(entree: EntreeDesTickets): Promise<void>;