@roomi-fields/grillhouse 0.24.1 → 0.24.3
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.
- package/.claude-plugin/plugin.json +1 -1
- package/cadre/templates/projet/package.json +0 -1
- package/cadre/templates/projet/tsdoc.json +1 -1
- package/charte.md +6 -0
- package/docs/ARCHITECTURE.md +40 -8
- package/package.json +4 -2
- package/scripts/bilan.mjs +52 -13
- package/scripts/cadre.mjs +5 -2
- package/scripts/circuit.mjs +120 -42
- package/scripts/consommateurs-arbitres.mjs +75 -37
- package/scripts/consommateurs.mjs +1 -1
- package/scripts/demon.mjs +138 -0
- package/scripts/etapes.mjs +6 -0
- package/scripts/grillhouse-maj.mjs +13 -11
- package/scripts/migrations/0.23.2-copies-du-cadre.mjs +6 -12
- package/scripts/migrations/0.24.2-api-extractor-du-paquet.mjs +68 -0
- package/scripts/migrations.mjs +2 -0
- package/scripts/registre.mjs +38 -4
- package/scripts/resultats.mjs +13 -0
- package/scripts/sources.mjs +8 -1
- package/scripts/tableau.mjs +33 -24
- package/scripts/vitest-config/base-de-passe.mjs +20 -0
- package/skills/developpeur/SKILL.md +10 -1
- package/skills/explorateur/SKILL.md +9 -3
- package/skills/pitmaster/SKILL.md +21 -13
- package/skills/pitmaster/references/consigne-agent.md +11 -4
- package/skills/redacteur/references/documents-d-un-composant.md +5 -3
- package/skills/testwriter/SKILL.md +13 -4
- package/tsdoc-base.json +4 -0
package/scripts/circuit.mjs
CHANGED
|
@@ -25,6 +25,16 @@
|
|
|
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
|
|
@@ -43,12 +53,14 @@
|
|
|
43
53
|
// description and notes, the context), writes the plan in its sheet: its criteria, the packages
|
|
44
54
|
// to touch, and its open questions, each with its piece; it surveys the components the ticket
|
|
45
55
|
// 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,
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
//
|
|
56
|
+
// which the circuit plays no more as a step. A package the repository does not hold, one named
|
|
57
|
+
// twice, or a component of the survey of the plan (`releve`, which the circuit plays with no
|
|
58
|
+
// session to check the sheet) that the sheet neither puts in its packages nor sets apart with
|
|
59
|
+
// its reason (`ecartes`, written at the ticket) makes the sheet out of conformity. The circuit
|
|
60
|
+
// writes the plan at the ticket (`bd update --title -d`): the packages end its title, the list the envelope of every later
|
|
61
|
+
// session writes; the criteria already written stay as they are, the owner's decision, and the
|
|
62
|
+
// criteria of the sheet, those the plan adds, follow them, numbered after them (a change or a
|
|
63
|
+
// removal of a criterion written is an open question of the sheet); the open questions a section
|
|
52
64
|
// « Questions ouvertes » after them. Each writing starts again from the description before the
|
|
53
65
|
// plan. Then one session of the questionneur out of the envelope, read-only (no tool of
|
|
54
66
|
// writing, every write of bd refused, scripts/droits.mjs), as Amazon's bar raiser, a cockpit's
|
|
@@ -66,12 +78,12 @@
|
|
|
66
78
|
// question the explorateur leaves without an answer) stops at « questionnement », the open questions as its piece, a
|
|
67
79
|
// question for the supervisor: he changes the plan (`bd update`) or keeps it, then
|
|
68
80
|
// `--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
|
|
70
|
-
// since, passes with no session
|
|
81
|
+
// passes (`plan`, its fingerprint: its title and its criteria); a plan that passed, its title
|
|
82
|
+
// and criteria unchanged since, passes with no session, whatever else of its description
|
|
83
|
+
// changed.
|
|
71
84
|
// - Each session is a launch of scripts/enveloppe/lancer.sh, a child process the circuit waits
|
|
72
85
|
// for, in its own process group, its errors written to a file: a session outlives the death of
|
|
73
|
-
// its circuit
|
|
74
|
-
// runs. Its plan, the packages it writes (`--paquets`, the envelope's list), is the plan of the
|
|
86
|
+
// 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
87
|
// ticket, the whole copy in sight, the session at the root (`.`); lancer.sh builds the packages
|
|
76
88
|
// of the plan and what they read before it opens. A session its lock stops on a write out of
|
|
77
89
|
// the plan ends the circuit at « hors-plan », a question for the supervisor, the write as its
|
|
@@ -81,8 +93,11 @@
|
|
|
81
93
|
// section absent without notes), both read with `bd show` at the session's launch, the report of
|
|
82
94
|
// the step before (the proof, the reds of a check), the findings of the reviewer still open, the
|
|
83
95
|
// 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),
|
|
85
|
-
// `--contexte`, for each agent of the run
|
|
96
|
+
// of the testwriter, else « aucune » (no verdict), the line `CONTEXTE :`: the text of
|
|
97
|
+
// `--contexte`, for each agent of the run, and the references 4.2 regenerates, each with its
|
|
98
|
+
// files (`lesReferences`), so that no session stops on what the circuit writes itself (BP
|
|
99
|
+
// 320.8: a developpeur, code and tests green, stopped on a ceiling, the debt and the index).
|
|
100
|
+
// The session's own exit code is the one lancer.sh
|
|
86
101
|
// writes to `.claude/worktrees/<ticket>.fin`; a launch that leaves none stopped before its
|
|
87
102
|
// session.
|
|
88
103
|
// - Each session of the explorateur, the questionneur, the testwriter, the developpeur and the
|
|
@@ -347,8 +362,9 @@
|
|
|
347
362
|
// live in the base of the run (scripts/vitest-config/base-de-passe.mjs), removed at its end.
|
|
348
363
|
// - The state is `.claude/worktrees/<ticket>.circuit.json`, written again at each step and at the
|
|
349
364
|
// 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
|
|
365
|
+
// seance, question, questionnement, processus, depart, paquets, constats, verifie, mene, reprise,
|
|
366
|
+
// journal }`; `processus` the process of the circuit that writes it, `depart` its start (field
|
|
367
|
+
// 22 of /proc/<pid>/stat), which together name it, a number alone being reused; `questionnement` the work
|
|
352
368
|
// on the plan under way (`{ objet, role, seance }`: the plan, the explorateur or the
|
|
353
369
|
// questionneur, its session), null otherwise; `etape` is the state's name of a numbered step of
|
|
354
370
|
// the process (scripts/etapes.mjs: testwriter 2, preuve 2.1, developpeur 3, controles 3.1, or 4.1
|
|
@@ -365,7 +381,7 @@
|
|
|
365
381
|
// itself while it runs, null otherwise; `reprise` the session of the testwriter or developpeur
|
|
366
382
|
// its relaunches resume, `{ agent, seance }`, null before any.
|
|
367
383
|
// - `--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
|
|
384
|
+
// after any stop, the death of the circuit included. A session the state names
|
|
369
385
|
// that still runs is waited for first, and stopped when it stands still as long as a motionless
|
|
370
386
|
// session. On a stop « questionnement », it lets the plan pass as it is then (the supervisor
|
|
371
387
|
// changed it or kept it), from the testwriter.
|
|
@@ -380,9 +396,10 @@
|
|
|
380
396
|
// package of the plan that depends on it (its package.json), else at its end, said at the ticket
|
|
381
397
|
// (`Circuit · plan : le superviseur étend le plan à …`); then the step under way resumes as
|
|
382
398
|
// after `--reprendre`, on the plan extended, the question as its context with the text of
|
|
383
|
-
// `--contexte
|
|
384
|
-
//
|
|
385
|
-
//
|
|
399
|
+
// `--contexte`; a stop « sans-livraison » on the developpeur's sending to the testwriter
|
|
400
|
+
// resumes at the testwriter, the role it names. The plan so extended has passed (`plan`, its
|
|
401
|
+
// fingerprint): neither the explorateur nor the questionneur works on it again. A package the
|
|
402
|
+
// repository does not hold is refused, exit 2.
|
|
386
403
|
// - `--arreter` stops the circuit on the supervisor's word, as a pipeline cancelled: a circuit
|
|
387
404
|
// running on the ticket (the state's `processus`, alive) stops, SIGTERM then SIGKILL, and so does
|
|
388
405
|
// the session it led (`seance`); the state keeps its step, its stop « arrete », its question
|
|
@@ -473,6 +490,7 @@ import {
|
|
|
473
490
|
SUPERVISEUR,
|
|
474
491
|
} from './etapes.mjs';
|
|
475
492
|
import { paquets } from './paquets.mjs';
|
|
493
|
+
import { releve } from './composants-affectes.mjs';
|
|
476
494
|
import { ecrire as ecrireAuRegistre, ligneDEtape, transcriptionsDeLaCopie } from './registre.mjs';
|
|
477
495
|
import { FICHIER as DETTE } from './dette.mjs';
|
|
478
496
|
import {
|
|
@@ -497,14 +515,18 @@ import { AVANCEMENT } from './vitest-config/avancement.mjs';
|
|
|
497
515
|
import { NOMS_DES_GARDES } from './gardes-du-cadre.mjs';
|
|
498
516
|
import { isTesterFile } from './verrous/verrou.mjs';
|
|
499
517
|
import { A_REPASSER } from './vitest-config/pression.mjs';
|
|
500
|
-
import { ouvrirBase, vivant } from './vitest-config/base-de-passe.mjs';
|
|
518
|
+
import { departDe, leMemeVivant, ouvrirBase, vivant } from './vitest-config/base-de-passe.mjs';
|
|
501
519
|
import { GREFFON } from './cadre.mjs';
|
|
520
|
+
import { executerEnDemon } from './demon.mjs';
|
|
502
521
|
|
|
503
522
|
// The time a session's transcripts may stand still before the circuit stops it.
|
|
504
523
|
export const IMMOBILE_MS = 20 * 60 * 1000;
|
|
505
524
|
// The exit code of each stop, from the list of the steps and stops.
|
|
506
525
|
export { ARRETS };
|
|
507
526
|
const CODE_USAGE = 2;
|
|
527
|
+
// The start of this process (departDe), which the state writes beside its number: a number alone
|
|
528
|
+
// may name another process once reused.
|
|
529
|
+
const DEPART = departDe(process.pid);
|
|
508
530
|
// The bounded loops, each declared with its step (scripts/etapes.mjs, `boucles`): the testwriter is
|
|
509
531
|
// relaunched twice at most after a failed proof (three sessions); the developpeur has three
|
|
510
532
|
// sessions, the last on the strong model; the third RENDU of one ticket stops the circuit.
|
|
@@ -903,6 +925,7 @@ function ecrireEtat(ctx, etat) {
|
|
|
903
925
|
avancement: null,
|
|
904
926
|
...etat,
|
|
905
927
|
processus: process.pid,
|
|
928
|
+
depart: DEPART,
|
|
906
929
|
paquets: ctx.paquets,
|
|
907
930
|
constats: ctx.constats ?? [],
|
|
908
931
|
verifie: ctx.verifie ?? null,
|
|
@@ -1202,6 +1225,9 @@ async function seance(ctx, role, { tentative, rapport, fort, derniere }) {
|
|
|
1202
1225
|
rapport: rapport ?? 'aucun',
|
|
1203
1226
|
constats,
|
|
1204
1227
|
passation: passation?.text ?? 'aucune',
|
|
1228
|
+
references: lesReferences(ctx)
|
|
1229
|
+
.map(r => `- ${r.nom} : ${r.fichiers.map(f => `\`${f}\``).join(', ')}`)
|
|
1230
|
+
.join('\n'),
|
|
1205
1231
|
};
|
|
1206
1232
|
return await jusquALaFiche(ctx, role, consigne(valeurs), { fort, neuve: role });
|
|
1207
1233
|
}
|
|
@@ -1609,7 +1635,8 @@ function laPasseFinale(ctx) {
|
|
|
1609
1635
|
// (REFERENCES_DU_CADRE, `cadre`), each but one whose first file a reference of the project covers,
|
|
1610
1636
|
// which replaces it.
|
|
1611
1637
|
function lesReferences(ctx) {
|
|
1612
|
-
const l = lireJson(path.join(ctx.copie, 'package.json'))
|
|
1638
|
+
const l = lireJson(path.join(existsSync(ctx.copie) ? ctx.copie : ctx.racine, 'package.json'))
|
|
1639
|
+
?.grillhouse?.references;
|
|
1613
1640
|
const duProjet = (Array.isArray(l) ? l : [])
|
|
1614
1641
|
.filter(
|
|
1615
1642
|
r =>
|
|
@@ -3224,9 +3251,19 @@ function rubrique(ctx, titre) {
|
|
|
3224
3251
|
// The meta-frame, the frame's plugin's, read at the plugin's root (scripts/cadre.mjs).
|
|
3225
3252
|
const METACADRE = path.join(GREFFON, 'METACADRE.md');
|
|
3226
3253
|
|
|
3227
|
-
// The fingerprint of a plan, its title and its
|
|
3228
|
-
|
|
3229
|
-
|
|
3254
|
+
// The fingerprint of a plan, its title and its section of criteria, each line without its blank
|
|
3255
|
+
// lines: the rest of the description (an answer of the supervisor, the open questions, its notes)
|
|
3256
|
+
// is not the plan, as a CI replays a job only when its inputs move.
|
|
3257
|
+
const empreinteDuPlan = ({ titre, description }) => {
|
|
3258
|
+
const criteres = sectionsDe(description)
|
|
3259
|
+
.filter(deCriteres)
|
|
3260
|
+
.flatMap(s => [s.tete, ...s.lignes])
|
|
3261
|
+
.map(l => l.trim())
|
|
3262
|
+
.filter(Boolean);
|
|
3263
|
+
return createHash('sha256')
|
|
3264
|
+
.update([titre, ...criteres].join('\n'))
|
|
3265
|
+
.digest('hex');
|
|
3266
|
+
};
|
|
3230
3267
|
|
|
3231
3268
|
// Whether the plan of fingerprint <empreinte> has passed: a plan whose questioning left no
|
|
3232
3269
|
// question open, or the supervisor's resumption of its stop.
|
|
@@ -3315,26 +3352,47 @@ function ecrireLePlan(ctx, plan, description = null) {
|
|
|
3315
3352
|
}
|
|
3316
3353
|
|
|
3317
3354
|
// 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,
|
|
3319
|
-
// (by its name and by its path)
|
|
3320
|
-
|
|
3321
|
-
|
|
3355
|
+
// package that names neither a package nor a path of the repository, one package named twice
|
|
3356
|
+
// (by its name and by its path), or a component of the survey of the plan's description
|
|
3357
|
+
// <description> (scripts/composants-affectes.mjs, `releve`, played by the circuit with no
|
|
3358
|
+
// session, as it checks the packages) that the sheet neither puts in its packages nor sets apart
|
|
3359
|
+
// with its reason (`ecartes`). A session that writes one is resumed once (`jusquALaFiche`).
|
|
3360
|
+
function fautesDesPaquets(ctx, fiche, description) {
|
|
3361
|
+
const dossier = p => {
|
|
3322
3362
|
try {
|
|
3323
3363
|
return ctx.resoudre(p);
|
|
3324
3364
|
} catch {
|
|
3325
3365
|
return null;
|
|
3326
3366
|
}
|
|
3327
|
-
}
|
|
3367
|
+
};
|
|
3368
|
+
const dossiers = fiche.paquets.map(dossier);
|
|
3328
3369
|
const inconnus = fiche.paquets.filter((p, i) => dossiers[i] === null);
|
|
3329
3370
|
if (inconnus.length) {
|
|
3330
3371
|
return `paquets : ${inconnus.join(', ')} ne nomme ni un paquet ni un chemin du dépôt`;
|
|
3331
3372
|
}
|
|
3332
3373
|
const doubles = fiche.paquets.filter((p, i) => dossiers.indexOf(dossiers[i]) !== i);
|
|
3333
|
-
|
|
3334
|
-
|
|
3374
|
+
if (doubles.length) {
|
|
3375
|
+
return `paquets : ${doubles.join(', ')} nomme un paquet déjà nommé dans le plan`;
|
|
3376
|
+
}
|
|
3377
|
+
const tenus = [...dossiers, ...(fiche.ecartes ?? []).map(e => dossier(e.composant))];
|
|
3378
|
+
const couvre = (d, c) => d === '.' || c === d || c.startsWith(`${d}/`);
|
|
3379
|
+
const racine = existsSync(ctx.copie) ? ctx.copie : ctx.racine;
|
|
3380
|
+
const absents = releve(racine, description).composants.filter(c => {
|
|
3381
|
+
const d = dossier(c);
|
|
3382
|
+
return d !== null && !tenus.some(t => t !== null && couvre(t, d));
|
|
3383
|
+
});
|
|
3384
|
+
return absents.length
|
|
3385
|
+
? `paquets : ${absents.join(', ')}, que le relevé nomme, n'est ni dans les paquets ni dans les écartés (ecartes, avec sa raison)`
|
|
3335
3386
|
: null;
|
|
3336
3387
|
}
|
|
3337
3388
|
|
|
3389
|
+
// The components the sheet <fiche> of the explorateur sets apart, each with its reason, as the
|
|
3390
|
+
// circuit writes them at the ticket; empty without one.
|
|
3391
|
+
const ecartsDe = fiche =>
|
|
3392
|
+
(fiche.ecartes ?? []).length
|
|
3393
|
+
? ` ; écartés : ${fiche.ecartes.map(e => `${e.composant} (${e.raison})`).join(' ; ')}`
|
|
3394
|
+
: '';
|
|
3395
|
+
|
|
3338
3396
|
// The plan of the ticket (step 1 of scripts/etapes.mjs) before its testwriter, as an RFC: its
|
|
3339
3397
|
// author writes it after surveying what exists, a review reads it once,
|
|
3340
3398
|
// the author answers once, and what stays open goes to who decides. One session of the
|
|
@@ -3345,8 +3403,8 @@ function fautesDesPaquets(ctx, fiche) {
|
|
|
3345
3403
|
// question it leaves without an answer stays open with its own. Each session's work is named in
|
|
3346
3404
|
// the state while it runs (`questionnement`); the exchange is written at the ticket and its end
|
|
3347
3405
|
// kept with the circuit's results (`questionnement`, which the bilan counts). A plan that has
|
|
3348
|
-
// passed, its title and
|
|
3349
|
-
// plan passes, kept as `plan`); else the exit code of the question it goes up with,
|
|
3406
|
+
// passed, its title and criteria unchanged since (`empreinteDuPlan`), passes. Null when nothing
|
|
3407
|
+
// stays open (the plan passes, kept as `plan`); else the exit code of the question it goes up with,
|
|
3350
3408
|
// « questionnement », the open questions as its piece, or the stop of a session that cannot end.
|
|
3351
3409
|
async function lePlan(ctx) {
|
|
3352
3410
|
if (planPasse(ctx, empreinteDuPlan(leTicket(ctx)))) return null;
|
|
@@ -3368,10 +3426,12 @@ async function lePlan(ctx) {
|
|
|
3368
3426
|
ecrireEtat(ctx, etat());
|
|
3369
3427
|
return fiche;
|
|
3370
3428
|
};
|
|
3429
|
+
// The description before the plan, from which each sheet's plan is written.
|
|
3430
|
+
const avant = leTicket(ctx).description;
|
|
3371
3431
|
const explorateur = {
|
|
3372
3432
|
droits: horsDeLEnveloppe(ctx, EXPLORATEUR, 'sonnet'),
|
|
3373
3433
|
id: randomUUID(),
|
|
3374
|
-
valider: f => fautesDesPaquets(ctx, f),
|
|
3434
|
+
valider: f => fautesDesPaquets(ctx, f, decrireLePlan(avant, f.criteres, f.questions)),
|
|
3375
3435
|
};
|
|
3376
3436
|
try {
|
|
3377
3437
|
const t = leTicket(ctx);
|
|
@@ -3399,7 +3459,7 @@ async function lePlan(ctx) {
|
|
|
3399
3459
|
const ouvertesDuPlan = plan.questions.length ? `\n${lignesOuvertes(plan.questions)}` : 'aucune';
|
|
3400
3460
|
dire(
|
|
3401
3461
|
'plan',
|
|
3402
|
-
`l'explorateur écrit le plan — paquets : ${plan.paquets.join(', ')} ; ${plan.criteres.length} critère(s) ajouté(s) ; questions ouvertes : ${ouvertesDuPlan}`
|
|
3462
|
+
`l'explorateur écrit le plan — paquets : ${plan.paquets.join(', ')}${ecartsDe(plan)} ; ${plan.criteres.length} critère(s) ajouté(s) ; questions ouvertes : ${ouvertesDuPlan}`
|
|
3403
3463
|
);
|
|
3404
3464
|
const ecrit = leTicket(ctx);
|
|
3405
3465
|
const lu = await session(
|
|
@@ -3451,7 +3511,10 @@ async function lePlan(ctx) {
|
|
|
3451
3511
|
);
|
|
3452
3512
|
reponses = plan.reponses ?? [];
|
|
3453
3513
|
const lignes = reponses.map(r => `${r.numero}. ${r.reponse} — ${r.texte}`).join('\n');
|
|
3454
|
-
dire(
|
|
3514
|
+
dire(
|
|
3515
|
+
'questionnement',
|
|
3516
|
+
`la réponse de l'explorateur${ecartsDe(plan)} :\n${lignes || 'aucune'}`
|
|
3517
|
+
);
|
|
3455
3518
|
}
|
|
3456
3519
|
// What stays open: the plan's own questions, then each question left without an answer.
|
|
3457
3520
|
const ouvertes = [
|
|
@@ -3537,7 +3600,7 @@ async function terminer(cible) {
|
|
|
3537
3600
|
// it, its session gone.
|
|
3538
3601
|
async function arreterLeCircuit(ctx, e) {
|
|
3539
3602
|
const pid = e.processus;
|
|
3540
|
-
if (
|
|
3603
|
+
if (pid !== process.pid && leMemeVivant(pid, e.depart)) {
|
|
3541
3604
|
commenter(
|
|
3542
3605
|
ctx,
|
|
3543
3606
|
'arret',
|
|
@@ -3581,8 +3644,11 @@ async function arreter(ctx, e) {
|
|
|
3581
3644
|
// name of the repository, else a Usage): each one enters the title before the first package of
|
|
3582
3645
|
// the plan whose package.json depends on it, else at its end, written by bd and said at the
|
|
3583
3646
|
// 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;
|
|
3585
|
-
//
|
|
3647
|
+
// question of the stop and the text of `--contexte` as the context of its sessions; a stop
|
|
3648
|
+
// « sans-livraison » whose developpeur's last sheet sends the red to the testwriter (`renvoi`,
|
|
3649
|
+
// twice in a row) resumes at the step of the role it names, the testwriter's, as a retry plays the
|
|
3650
|
+
// job that failed. Without a state, it starts on the plan extended. The state the run resumes
|
|
3651
|
+
// from.
|
|
3586
3652
|
function etendre(ctx, e) {
|
|
3587
3653
|
const gagnes = [...new Set(ctx.etendre.map(ctx.resoudre))].filter(c => !ctx.paquets.includes(c));
|
|
3588
3654
|
const liste = paquets(existsSync(ctx.copie) ? ctx.copie : ctx.racine);
|
|
@@ -3610,12 +3676,17 @@ function etendre(ctx, e) {
|
|
|
3610
3676
|
'plan',
|
|
3611
3677
|
`le superviseur étend le plan à ${ctx.etendre.join(', ')} : ${titre.split(' — ').at(-1)}.`
|
|
3612
3678
|
);
|
|
3613
|
-
if (!e) return;
|
|
3679
|
+
if (!e) return e;
|
|
3614
3680
|
ctx.contexte =
|
|
3615
3681
|
[e.question ? `${e.question.fait}\n\n${e.question.piece}` : null, ctx.contexte]
|
|
3616
3682
|
.filter(Boolean)
|
|
3617
3683
|
.join('\n\n') || null;
|
|
3618
3684
|
ctx.reprendre = true;
|
|
3685
|
+
const renvoi =
|
|
3686
|
+
e.etape === CODE && e.raison === 'sans-livraison'
|
|
3687
|
+
? fichesDe(ctx, 'developpeur').at(-1)?.renvoi
|
|
3688
|
+
: null;
|
|
3689
|
+
return renvoi?.role === 'testwriter' ? { ...e, etape: TESTS } : e;
|
|
3619
3690
|
}
|
|
3620
3691
|
|
|
3621
3692
|
export async function main(argv) {
|
|
@@ -3623,7 +3694,7 @@ export async function main(argv) {
|
|
|
3623
3694
|
try {
|
|
3624
3695
|
ctx = contexte(lireArguments(argv));
|
|
3625
3696
|
mkdirSync(path.dirname(ctx.copie), { recursive: true });
|
|
3626
|
-
|
|
3697
|
+
let e = existsSync(ctx.etat) ? JSON.parse(readFileSync(ctx.etat, 'utf8')) : null;
|
|
3627
3698
|
// The findings of the reviewer still open, the lot the whole final pass verified, the session a
|
|
3628
3699
|
// relaunch resumes, and the references a regeneration has to run, kept from one run to the next.
|
|
3629
3700
|
ctx.constats = [...(e?.constats ?? [])];
|
|
@@ -3632,10 +3703,16 @@ export async function main(argv) {
|
|
|
3632
3703
|
ctx.aRegenerer = e?.aRegenerer ?? null;
|
|
3633
3704
|
// The supervisor's answers to a question: stop the circuit, or extend its plan and resume.
|
|
3634
3705
|
if (ctx.arreter) return await arreter(ctx, e);
|
|
3706
|
+
// A circuit that outlives its caller is still the ticket's: no second run beside it.
|
|
3707
|
+
if (e && e.processus !== process.pid && leMemeVivant(e.processus, e.depart)) {
|
|
3708
|
+
throw new Usage(
|
|
3709
|
+
`un circuit tourne déjà sur ${ctx.ticket} (processus ${e.processus}) : il mène le ticket à sa fin, \`--arreter\` l'arrête.`
|
|
3710
|
+
);
|
|
3711
|
+
}
|
|
3635
3712
|
if (ctx.etendre) {
|
|
3636
3713
|
if (e?.etape === 'integre')
|
|
3637
3714
|
throw new Usage(`--etendre : le lot de ${ctx.ticket} est intégré.`);
|
|
3638
|
-
etendre(ctx, e);
|
|
3715
|
+
e = etendre(ctx, e);
|
|
3639
3716
|
}
|
|
3640
3717
|
// The supervisor's resumption of the questioning lets the plan pass as it is now.
|
|
3641
3718
|
if (ctx.reprendre && e?.raison === 'questionnement') {
|
|
@@ -3669,6 +3746,7 @@ export async function main(argv) {
|
|
|
3669
3746
|
}
|
|
3670
3747
|
}
|
|
3671
3748
|
|
|
3749
|
+
// The entry: the run as a daemon (scripts/demon.mjs), apart from its caller.
|
|
3672
3750
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
3673
|
-
process.exitCode = await
|
|
3751
|
+
process.exitCode = await executerEnDemon(import.meta.filename, process.argv.slice(2), main);
|
|
3674
3752
|
}
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
// judge (`aVerifier` of scripts/interfaces-contre-code.mjs; in an envelope,
|
|
10
10
|
// `GRILLHOUSE_ENVELOPPE`, the components of its plan), each list line (`- …`) of the
|
|
11
11
|
// `## Consommateurs` section of its `docs/INTERFACE.md` in the working tree that the section of
|
|
12
|
-
// HEAD does not hold is a changed line (an interface absent from HEAD: all its lines).
|
|
12
|
+
// HEAD does not hold is a changed line (an interface absent from HEAD: all its lines). The
|
|
13
|
+
// section is read out of the generated part (between the marks of
|
|
14
|
+
// scripts/interfaces-contre-code.mjs): a bullet of an element's entry is no consumer. Out of a
|
|
13
15
|
// branch `agent/…` (main, the detached copy of the integration, the CI, the night), there is no
|
|
14
16
|
// lot: nothing is judged.
|
|
15
17
|
// - With a changed line, the comments of the ticket are read (`bd comments <ticket> --json`, run
|
|
@@ -18,20 +20,24 @@
|
|
|
18
20
|
// `estArbitrage`, its verdict « tranché » or the owner's answer after it) names its consumer, the first
|
|
19
21
|
// name between backquotes of the line, found as it is in the comment's text. Without a changed
|
|
20
22
|
// line, bd is not called.
|
|
21
|
-
// - A changed line no arbitrage settles passes too when the
|
|
22
|
-
//
|
|
23
|
-
// next heading of its level or above
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
23
|
+
// - A changed line no arbitrage settles passes too when the ticket's plan (`bd show <ticket>
|
|
24
|
+
// --json`: its title, and the sections « Architecture » and « Noms publiés » of its description,
|
|
25
|
+
// each from its heading to the next heading of its level or above; never the rest of the
|
|
26
|
+
// description, where a question or a criterion can name what the ticket keeps out) names its
|
|
27
|
+
// consumer and each name the lot adds to the line, word for word (`nonNommes`): the names HEAD's
|
|
28
|
+
// section already gives that consumer were settled before. The plan fixed them before the lot,
|
|
29
|
+
// as a code owner's approval covers what it reviewed. The plan is read only for such a line; one
|
|
30
|
+
// that cannot be read refuses, as the comments do.
|
|
31
|
+
// - A refusal names `<INTERFACE.md> § Consommateurs`, the line and the names the plan misses; a
|
|
32
|
+
// refusal inscribed in the project's debt (`grillhouse-dette.json`, see `dette.mjs`) passes,
|
|
33
|
+
// keyed by the interface and `consommateur-sans-arbitrage`. Comments that cannot be read refuse,
|
|
34
|
+
// never inscribed.
|
|
29
35
|
import { spawnSync } from 'node:child_process';
|
|
30
36
|
import { existsSync, readFileSync } from 'node:fs';
|
|
31
37
|
import path from 'node:path';
|
|
32
38
|
import { pathToFileURL } from 'node:url';
|
|
33
39
|
import { trancher } from './dette.mjs';
|
|
34
|
-
import { aVerifier } from './interfaces-contre-code.mjs';
|
|
40
|
+
import { aVerifier, marques } from './interfaces-contre-code.mjs';
|
|
35
41
|
|
|
36
42
|
const REGLE = 'consommateur-sans-arbitrage';
|
|
37
43
|
|
|
@@ -40,60 +46,72 @@ const REGLE = 'consommateur-sans-arbitrage';
|
|
|
40
46
|
// règles »).
|
|
41
47
|
export const estArbitrage = text => /^\s*## Arbitrage\b/.test(String(text ?? ''));
|
|
42
48
|
|
|
49
|
+
// True when the text <text> of a comment is the owner's answer, « ## Réponse du responsable — <la
|
|
50
|
+
// question> », as the supervisor writes it (the skill pitmaster).
|
|
51
|
+
export const estReponseDuResponsable = text =>
|
|
52
|
+
/^\s*## Réponse du responsable\b/.test(String(text ?? ''));
|
|
53
|
+
|
|
43
54
|
// True when the arbitrage <a> of <comments> (Beads' JSON, in their order) is settled: a line
|
|
44
55
|
// `### Verdict — tranché`, or a « ## Réponse du responsable » comment after it.
|
|
45
56
|
export function arbitrageTranche(comments, a) {
|
|
46
57
|
const tranche = /^### Verdict\s*—\s*tranché/m.test(a.text);
|
|
47
58
|
return (
|
|
48
|
-
tranche ||
|
|
49
|
-
comments
|
|
50
|
-
.slice(comments.indexOf(a) + 1)
|
|
51
|
-
.some(c => /^\s*## Réponse du responsable\b/.test(c.text))
|
|
59
|
+
tranche || comments.slice(comments.indexOf(a) + 1).some(c => estReponseDuResponsable(c.text))
|
|
52
60
|
);
|
|
53
61
|
}
|
|
54
62
|
|
|
55
|
-
// The list lines of the section `## Consommateurs` of <texte>, trimmed
|
|
63
|
+
// The list lines of the section `## Consommateurs` of <texte>, trimmed, read out of its generated
|
|
64
|
+
// part (`marques`, scripts/interfaces-contre-code.mjs): a bullet the generator writes there (a
|
|
65
|
+
// parameter, a member, a fault) is never a consumer.
|
|
56
66
|
function lignesConsommateurs(texte) {
|
|
67
|
+
const m = marques(texte);
|
|
68
|
+
const ecrites =
|
|
69
|
+
m.etat === 'ok' ? [...m.lignes.slice(0, m.debut), ...m.lignes.slice(m.fin + 1)] : m.lignes;
|
|
57
70
|
const out = [];
|
|
58
71
|
let dedans = false;
|
|
59
|
-
for (const l of
|
|
72
|
+
for (const l of ecrites) {
|
|
60
73
|
if (/^##\s/.test(l)) dedans = /^##\s+Consommateurs\s*$/.test(l);
|
|
61
74
|
else if (dedans && /^\s*-\s+\S/.test(l)) out.push(l.trim());
|
|
62
75
|
}
|
|
63
76
|
return out;
|
|
64
77
|
}
|
|
65
78
|
|
|
66
|
-
// The section
|
|
67
|
-
//
|
|
68
|
-
function
|
|
79
|
+
// The section of the ticket's description <description> whose heading's text <titre> matches:
|
|
80
|
+
// its lines from its heading to the next heading of its level or above, or '' without one.
|
|
81
|
+
function section(description, titre) {
|
|
69
82
|
const out = [];
|
|
70
83
|
let niveau = 0;
|
|
71
84
|
for (const l of String(description ?? '').split('\n')) {
|
|
72
|
-
const
|
|
73
|
-
if (niveau &&
|
|
85
|
+
const t = /^(#{1,6})\s+(.*)$/.exec(l);
|
|
86
|
+
if (niveau && t && t[1].length <= niveau) break;
|
|
74
87
|
if (niveau) out.push(l);
|
|
75
|
-
else if (
|
|
88
|
+
else if (t && titre.test(t[2].trim())) niveau = t[1].length;
|
|
76
89
|
}
|
|
77
90
|
return out.join('\n');
|
|
78
91
|
}
|
|
79
92
|
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
// backquotes.
|
|
84
|
-
function nommeParLArchitecture(texte, ligne) {
|
|
93
|
+
// The consumer and the names of the `## Consommateurs` line <ligne>
|
|
94
|
+
// (``- `<consommateur>` : <nom>, <nom>``), or null for a line of another form.
|
|
95
|
+
function lireLigne(ligne) {
|
|
85
96
|
const m = /^[-*]\s+`?([^`:\s]+)`?\s*:\s*(.+)$/.exec(ligne);
|
|
86
|
-
if (!m) return
|
|
97
|
+
if (!m) return null;
|
|
87
98
|
const noms = m[2]
|
|
88
99
|
.split(',')
|
|
89
100
|
.map(s => s.replace(/`/g, '').trim())
|
|
90
101
|
.filter(Boolean);
|
|
102
|
+
return { consommateur: m[1], noms };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// The names of <noms> the text <texte> does not name word for word: each one whole, with no
|
|
106
|
+
// character of a name (a letter, a digit, `_`, `$`, `-`) beside it; `*`, a namespace, between
|
|
107
|
+
// backquotes.
|
|
108
|
+
function nonNommes(texte, noms) {
|
|
91
109
|
const echappe = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
92
110
|
const nomme = nom =>
|
|
93
111
|
nom === '*'
|
|
94
112
|
? texte.includes('`*`')
|
|
95
113
|
: new RegExp(`(?<![\\w$-])${echappe(nom)}(?![\\w$-])`).test(texte);
|
|
96
|
-
return
|
|
114
|
+
return noms.filter(n => !nomme(n));
|
|
97
115
|
}
|
|
98
116
|
|
|
99
117
|
const git = (racine, ...a) => spawnSync('git', ['-C', racine, ...a], { encoding: 'utf8' });
|
|
@@ -115,9 +133,19 @@ export function verifier(racine, env = process.env) {
|
|
|
115
133
|
if (!existsSync(iface)) continue;
|
|
116
134
|
const rel = path.relative(racine, iface);
|
|
117
135
|
const head = git(racine, 'show', `HEAD:${rel}`);
|
|
118
|
-
const
|
|
136
|
+
const lignesAvant = head.status === 0 ? lignesConsommateurs(head.stdout) : [];
|
|
137
|
+
const avant = new Set(lignesAvant);
|
|
138
|
+
// The names each consumer of HEAD's section reads.
|
|
139
|
+
const nomsAvant = new Map();
|
|
140
|
+
for (const l of lignesAvant.map(lireLigne).filter(Boolean)) {
|
|
141
|
+
nomsAvant.set(l.consommateur, new Set([...(nomsAvant.get(l.consommateur) ?? []), ...l.noms]));
|
|
142
|
+
}
|
|
119
143
|
for (const ligne of lignesConsommateurs(readFileSync(iface, 'utf8'))) {
|
|
120
|
-
if (
|
|
144
|
+
if (avant.has(ligne)) continue;
|
|
145
|
+
const lue = lireLigne(ligne);
|
|
146
|
+
const deja = lue && nomsAvant.get(lue.consommateur);
|
|
147
|
+
const ajoutes = lue ? lue.noms.filter(n => !deja?.has(n)) : null;
|
|
148
|
+
changees.push({ rel, ligne, lue, ajoutes });
|
|
121
149
|
}
|
|
122
150
|
}
|
|
123
151
|
if (changees.length === 0) return [];
|
|
@@ -145,18 +173,24 @@ export function verifier(racine, env = process.env) {
|
|
|
145
173
|
({ ligne }) => !arbitrages.some(a => a.text.includes(consommateurDe(ligne)))
|
|
146
174
|
);
|
|
147
175
|
if (restantes.length === 0) return [];
|
|
148
|
-
// The lines no arbitrage settles: the
|
|
176
|
+
// The lines no arbitrage settles: the ticket's plan, its title and its sections « Architecture »
|
|
177
|
+
// and « Noms publiés ».
|
|
149
178
|
const show = spawnSync('bd', ['show', ticket, '--json'], {
|
|
150
179
|
cwd: principal,
|
|
151
180
|
encoding: 'utf8',
|
|
152
181
|
maxBuffer: 256 * 1024 * 1024,
|
|
153
182
|
});
|
|
154
|
-
let
|
|
183
|
+
let plan;
|
|
155
184
|
try {
|
|
156
185
|
if (show.status !== 0) {
|
|
157
186
|
throw new Error(show.stderr || show.error?.message || `code ${show.status}`);
|
|
158
187
|
}
|
|
159
|
-
|
|
188
|
+
const t = JSON.parse(show.stdout || '[]')?.[0];
|
|
189
|
+
plan = [
|
|
190
|
+
t?.title ?? '',
|
|
191
|
+
section(t?.description, /^Architecture\b/),
|
|
192
|
+
section(t?.description, /^Noms publiés\b/),
|
|
193
|
+
].join('\n');
|
|
160
194
|
} catch (e) {
|
|
161
195
|
return [
|
|
162
196
|
{
|
|
@@ -165,13 +199,17 @@ export function verifier(racine, env = process.env) {
|
|
|
165
199
|
];
|
|
166
200
|
}
|
|
167
201
|
const constats = [];
|
|
168
|
-
for (const { rel, ligne } of restantes) {
|
|
169
|
-
|
|
202
|
+
for (const { rel, ligne, lue, ajoutes } of restantes) {
|
|
203
|
+
const manquants = lue ? nonNommes(plan, [lue.consommateur, ...ajoutes]) : null;
|
|
204
|
+
if (manquants?.length === 0) continue;
|
|
170
205
|
const consommateur = consommateurDe(ligne);
|
|
206
|
+
const dit = manquants
|
|
207
|
+
? ` ; le plan ne nomme pas ${manquants.map(n => `\`${n}\``).join(', ')}`
|
|
208
|
+
: '';
|
|
171
209
|
constats.push({
|
|
172
210
|
fichier: rel,
|
|
173
211
|
regle: REGLE,
|
|
174
|
-
message: `${rel} § Consommateurs : la ligne « ${ligne} » change sans arbitrage tranché au ticket ${ticket} qui nomme \`${consommateur}\`, ni section « Architecture
|
|
212
|
+
message: `${rel} § Consommateurs : la ligne « ${ligne} » change sans arbitrage tranché au ticket ${ticket} qui nomme \`${consommateur}\`, ni plan du ticket (son titre, sa section « Architecture », sa section « Noms publiés ») qui nomme ce consommateur et chaque nom que le lot ajoute à la ligne${dit} ; une dépendance entre composants se décide avant de s'écrire : un commentaire « ## Arbitrage » tranché au ticket qui nomme ce consommateur, ou le plan du ticket qui la fixe.`,
|
|
175
213
|
});
|
|
176
214
|
}
|
|
177
215
|
return constats;
|
|
@@ -307,7 +307,7 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
|
307
307
|
for (const l of lignes) process.stderr.write(`${l}\n`);
|
|
308
308
|
if (refus.length) {
|
|
309
309
|
process.stderr.write(
|
|
310
|
-
"Une consommation nouvelle se décide (
|
|
310
|
+
"Une consommation nouvelle se décide (le titre du ticket, sa section « Architecture » ou sa section « Noms publiés » qui la nomment, sinon l'arbitrage du superviseur), puis entre dans la section « Consommateurs » de l'interface du fournisseur.\n"
|
|
311
311
|
);
|
|
312
312
|
process.exitCode = 1;
|
|
313
313
|
}
|