@roomi-fields/grillhouse 0.50.0 → 0.50.2
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/CHANGELOG.md +16 -0
- package/docs/ARCHITECTURE.md +9 -3
- package/docs/architecture/circuit.md +1 -0
- package/docs/architecture/entree.md +1 -1
- package/docs/architecture/machine.md +1 -1
- package/hooks/crochet.mjs +3 -1
- package/package.json +1 -1
- package/scripts/activites.mjs +18 -8
- package/scripts/attente-a-l-arret.mjs +7 -8
- package/scripts/attente-au-tour.mjs +2 -2
- package/scripts/bilan.mjs +39 -61
- package/scripts/cadre.mjs +25 -6
- package/scripts/circuit.mjs +28 -4
- package/scripts/commande-du-plan.mjs +15 -0
- package/scripts/crochet.mjs +1 -0
- package/scripts/dette.mjs +84 -7
- package/scripts/direct.mjs +64 -5
- package/scripts/droits.mjs +13 -7
- package/scripts/engendres.mjs +32 -0
- package/scripts/enveloppe/travail-de-la-copie.mjs +6 -1
- package/scripts/etapes.mjs +8 -0
- package/scripts/integration/file.mjs +25 -24
- package/scripts/integration/integrer.mjs +31 -30
- package/scripts/integration/rejeu.mjs +4 -4
- package/scripts/langages/cargo/sccache.mjs +42 -6
- package/scripts/langages/typescript/titres-de-tests.mjs +27 -10
- package/scripts/ligne-etat/defaut.sh +2 -1
- package/scripts/ligne-etat/ligne-etat.mjs +1 -0
- package/scripts/messages-non-lus.mjs +2 -4
- package/scripts/newday.mjs +2 -2
- package/scripts/registre.mjs +14 -16
- package/scripts/reponses-du-circuit.mjs +5 -0
- package/scripts/resultats.mjs +11 -2
- package/scripts/session-start.sh +33 -46
- package/scripts/sigle-du-projet.mjs +1 -2
- package/scripts/structure-guard.sh +2 -1
- package/scripts/suiveur.mjs +1 -1
- package/scripts/superviseur.mjs +36 -55
- package/scripts/tableau.mjs +78 -121
- package/skills/explorateur/SKILL.md +5 -1
- package/types/index.d.ts +3 -0
package/scripts/dette.mjs
CHANGED
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
// its types in ./dette.d.ts (docs/ARCHITECTURE.md, the package's named entries).
|
|
34
34
|
//
|
|
35
35
|
// The mechanism: docs/architecture/tests.md §2.6, §4.1 and §5.5.
|
|
36
|
-
import {
|
|
36
|
+
import { spawnSync } from 'node:child_process';
|
|
37
|
+
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
38
|
+
import { tmpdir } from 'node:os';
|
|
37
39
|
import path from 'node:path';
|
|
38
40
|
import { pathToFileURL } from 'node:url';
|
|
39
41
|
import { paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
|
|
40
|
-
import { A_ELAGUER, A_INSCRIRE, ecrireSarif } from './resultats.mjs';
|
|
42
|
+
import { A_DEPLACER, A_ELAGUER, A_INSCRIRE, ecrireSarif } from './resultats.mjs';
|
|
41
43
|
|
|
42
44
|
// The environment variable that names the guards of the lot's base (main), a JSON list.
|
|
43
45
|
export const BASE = 'GRILLHOUSE_GARDES_DE_LA_BASE';
|
|
@@ -241,7 +243,7 @@ export function trancher(
|
|
|
241
243
|
}));
|
|
242
244
|
ecrireSarif({
|
|
243
245
|
garde,
|
|
244
|
-
constats: [...refus, ...notes, ...aInscrire(garde, refus, lEnv)],
|
|
246
|
+
constats: [...refus, ...notes, ...aInscrire(racine, garde, refus, lEnv)],
|
|
245
247
|
racine,
|
|
246
248
|
env: lEnv,
|
|
247
249
|
});
|
|
@@ -259,11 +261,32 @@ function gardesDeLaBase(env) {
|
|
|
259
261
|
}
|
|
260
262
|
}
|
|
261
263
|
|
|
264
|
+
// Whether <script>, the one that runs a guard (`argv[1]`), is a file of the project that HEAD holds: a
|
|
265
|
+
// guard of the project (its script `gardes`, which imports `trancher`) is a guard of main though
|
|
266
|
+
// the circuit's list of names, read from the frame's guards, never names it. A script out of the
|
|
267
|
+
// project, or one HEAD does not hold, says nothing.
|
|
268
|
+
export function scriptDeLaBase(racine, script, env = process.env) {
|
|
269
|
+
if (!script) {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
const rel = path.relative(path.resolve(racine), path.resolve(script));
|
|
273
|
+
if (rel.startsWith('..') || path.isAbsolute(rel) || rel.split(path.sep).includes('node_modules')) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
return (
|
|
277
|
+
spawnSync('git', ['-C', racine, 'cat-file', '-e', `HEAD:${rel.split(path.sep).join('/')}`], {
|
|
278
|
+
env,
|
|
279
|
+
stdio: 'ignore',
|
|
280
|
+
}).status === 0
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
|
|
262
284
|
// The notes « to inscribe » of <garde> when the base does not hold it: one per file and rule of
|
|
263
|
-
// its refusals, with its count. None for a guard of main
|
|
264
|
-
|
|
285
|
+
// its refusals, with its count. None for a guard of main (its name in the base's list, or its
|
|
286
|
+
// script in HEAD), nor without a base to compare with.
|
|
287
|
+
function aInscrire(racine, garde, refus, env) {
|
|
265
288
|
const base = gardesDeLaBase(env);
|
|
266
|
-
if (!base || base.includes(garde)) {
|
|
289
|
+
if (!base || base.includes(garde) || scriptDeLaBase(racine, process.argv[1], env)) {
|
|
267
290
|
return [];
|
|
268
291
|
}
|
|
269
292
|
const out = [];
|
|
@@ -292,14 +315,68 @@ function ecrire(racine, dette) {
|
|
|
292
315
|
writeFileSync(path.join(racine, FICHIER), `${JSON.stringify(triee, null, 2)}\n`);
|
|
293
316
|
}
|
|
294
317
|
|
|
318
|
+
// The files the working copy at <racine> renames or moves against HEAD, `{ nouveau: ancien }`, as
|
|
319
|
+
// git detects them (`-M`, half the content kept) on a throwaway index that holds the new files too:
|
|
320
|
+
// the lot as the circuit commits it. `{}` when git fails (not a repository, no commit).
|
|
321
|
+
export function renommesDuCommit(racine) {
|
|
322
|
+
const dossier = mkdtempSync(path.join(tmpdir(), 'dette-index-'));
|
|
323
|
+
try {
|
|
324
|
+
const env = { ...process.env, GIT_INDEX_FILE: path.join(dossier, 'index') };
|
|
325
|
+
const git = (...a) =>
|
|
326
|
+
spawnSync('git', ['-C', racine, ...a], { encoding: 'utf8', env, maxBuffer: 256 * 1024 * 1024 });
|
|
327
|
+
if (git('read-tree', 'HEAD').status !== 0 || git('add', '-A').status !== 0) {
|
|
328
|
+
return {};
|
|
329
|
+
}
|
|
330
|
+
const r = git('diff', '--cached', '-M', '--name-status', '-z', 'HEAD');
|
|
331
|
+
if (r.status !== 0) {
|
|
332
|
+
return {};
|
|
333
|
+
}
|
|
334
|
+
const out = {};
|
|
335
|
+
const t = r.stdout.split('\0');
|
|
336
|
+
for (let i = 0; i < t.length; i++) {
|
|
337
|
+
if (t[i].startsWith('R')) {
|
|
338
|
+
out[t[i + 2]] = t[i + 1];
|
|
339
|
+
i += 2;
|
|
340
|
+
} else if (t[i]) {
|
|
341
|
+
i += 1;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return out;
|
|
345
|
+
} finally {
|
|
346
|
+
rmSync(dossier, { recursive: true, force: true });
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// <dette> with the keys of each moved file (`{ nouveau: ancien }`) carried to its new path, in every
|
|
351
|
+
// guard: the debt of the former name is the new one's, added to what it already holds.
|
|
352
|
+
export function deplacer(dette, renommes) {
|
|
353
|
+
for (const section of Object.values(dette)) {
|
|
354
|
+
for (const [nouveau, ancien] of Object.entries(renommes)) {
|
|
355
|
+
if (!section[ancien]) {
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
const cible = (section[nouveau] ??= {});
|
|
359
|
+
for (const [regle, { count }] of Object.entries(section[ancien])) {
|
|
360
|
+
cible[regle] = { count: count + (cible[regle]?.count ?? 0) };
|
|
361
|
+
}
|
|
362
|
+
delete section[ancien];
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return dette;
|
|
366
|
+
}
|
|
367
|
+
|
|
295
368
|
// The debt at <racine> lowered by <notes>, each `{ garde, fichier, regle, trouve }` (the notes
|
|
296
369
|
// `a-elaguer` of a pass, scripts/resultats.mjs): each key named comes down to what its guard
|
|
297
370
|
// found, and leaves at zero; a count never rises, no key is added. Written when it changes;
|
|
298
371
|
// returns whether it did.
|
|
299
372
|
export function abaisser(racine, notes) {
|
|
300
373
|
const avant = lire(racine);
|
|
301
|
-
|
|
374
|
+
// The keys of the files the lot moves come first, so that the notes find them at their new path.
|
|
375
|
+
const dette = deplacer(JSON.parse(JSON.stringify(avant)), renommesDuCommit(racine));
|
|
302
376
|
for (const { garde, fichier, regle, trouve, genre } of notes) {
|
|
377
|
+
if (genre === A_DEPLACER) {
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
303
380
|
if (genre === A_INSCRIRE) {
|
|
304
381
|
if (fichier && regle && Number.isInteger(trouve) && trouve > 0) {
|
|
305
382
|
dette[garde] ??= {};
|
package/scripts/direct.mjs
CHANGED
|
@@ -30,8 +30,10 @@
|
|
|
30
30
|
// Exit code: 0 for an ACCEPTÉ lot, 1 for a RENDU lot (the same command resumes the agent), 2 for a
|
|
31
31
|
// usage fault or a refusal, 3 for a stop that goes up to the supervisor.
|
|
32
32
|
import { spawnSync } from 'node:child_process';
|
|
33
|
-
import { existsSync } from 'node:fs';
|
|
33
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
34
|
+
import path from 'node:path';
|
|
34
35
|
import { pathToFileURL } from 'node:url';
|
|
36
|
+
import { ecritPar, preparer } from './enveloppe/travail-de-la-copie.mjs';
|
|
35
37
|
import { prendreUnePlace, VARIABLE_TENUE } from './places-de-la-machine.mjs';
|
|
36
38
|
import { bloquantsDeLaFiche } from './resultats.mjs';
|
|
37
39
|
import { consigne } from './seances.mjs';
|
|
@@ -106,6 +108,34 @@ export function decisionDuDirect(fiches, lot) {
|
|
|
106
108
|
|
|
107
109
|
const RAISON_DU_VERROU = "copie d'un ticket direct : son lot n'est pas encore sur main";
|
|
108
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Whether git holds the copy <copie> locked, read on its stable output (`git worktree list
|
|
113
|
+
* --porcelain`, a `locked` line in the block of the copy), never on a message git translates.
|
|
114
|
+
* @param {string} copie
|
|
115
|
+
* @param {(...args: string[]) => { status: number, stdout: string, stderr: string }} git
|
|
116
|
+
*/
|
|
117
|
+
function estVerrouillee(copie, git) {
|
|
118
|
+
const r = git('worktree', 'list', '--porcelain');
|
|
119
|
+
if (r.status !== 0) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
const chemins = new Set([path.resolve(copie)]);
|
|
123
|
+
if (existsSync(copie)) {
|
|
124
|
+
chemins.add(realpathSync(copie));
|
|
125
|
+
}
|
|
126
|
+
return String(r.stdout)
|
|
127
|
+
.split(/\n\s*\n/)
|
|
128
|
+
.some(bloc => {
|
|
129
|
+
const lignes = bloc.split('\n');
|
|
130
|
+
const chemin = lignes.find(l => l.startsWith('worktree '))?.slice('worktree '.length);
|
|
131
|
+
return (
|
|
132
|
+
chemin !== undefined &&
|
|
133
|
+
chemins.has(chemin) &&
|
|
134
|
+
lignes.some(l => l === 'locked' || l.startsWith('locked '))
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
109
139
|
/**
|
|
110
140
|
* Locks the copy <copie> against the cleaning of the circuit, which removes a copy identical to
|
|
111
141
|
* main (`git worktree lock`, <git> its runner); a copy already locked stays so.
|
|
@@ -114,7 +144,7 @@ const RAISON_DU_VERROU = "copie d'un ticket direct : son lot n'est pas encore su
|
|
|
114
144
|
*/
|
|
115
145
|
export function verrouillerLaCopie(copie, git) {
|
|
116
146
|
const r = git('worktree', 'lock', '--reason', RAISON_DU_VERROU, copie);
|
|
117
|
-
if (r.status !== 0 &&
|
|
147
|
+
if (r.status !== 0 && !estVerrouillee(copie, git)) {
|
|
118
148
|
throw new Error(`la copie ${copie} ne se verrouille pas : ${r.stderr}`.trim());
|
|
119
149
|
}
|
|
120
150
|
}
|
|
@@ -133,7 +163,7 @@ export function deverrouillerLaCopie(copie, git) {
|
|
|
133
163
|
|
|
134
164
|
/**
|
|
135
165
|
* The command: the agent, then the reviewer, and it stops. <ports> are what it launches
|
|
136
|
-
* (`copie`, `verrouiller`, `fiches`, `lot`, `resoudre`, `seance`, `relecture`); <options> the paths
|
|
166
|
+
* (`copie`, `verrouiller`, `avancer`, `fiches`, `lot`, `resoudre`, `seance`, `relecture`); <options> the paths
|
|
137
167
|
* `--paquet` adds to the plan.
|
|
138
168
|
* @param {{ id: string, ticket: { title?: string, labels?: string[] }, options?: string[], ports: any }} o
|
|
139
169
|
* @returns {Promise<{ verdict?: string, copie?: string, constats?: object[], arret?: boolean, statut?: string, rendus?: number, fiche?: object }>}
|
|
@@ -170,7 +200,10 @@ export async function lancerLeDirect({ id, ticket, options = [], ports }) {
|
|
|
170
200
|
// its review; given back at the end, whatever the end.
|
|
171
201
|
const rendre = ports.place();
|
|
172
202
|
try {
|
|
173
|
-
|
|
203
|
+
// The copy moves onto main before the session: the files its work meets in conflict go to the
|
|
204
|
+
// agent, who writes them all, as the author of a lot resolves his own rebase.
|
|
205
|
+
const { fichiers = [] } = (await ports.avancer(copie)) ?? {};
|
|
206
|
+
const fiche = await ports.seance('direct', { constats, paquets: plan, conflits: fichiers });
|
|
174
207
|
if (fiche?.statut && fiche.statut !== 'FAIT') {
|
|
175
208
|
return { arret: true, statut: fiche.statut, fiche, copie };
|
|
176
209
|
}
|
|
@@ -181,6 +214,18 @@ export async function lancerLeDirect({ id, ticket, options = [], ports }) {
|
|
|
181
214
|
}
|
|
182
215
|
}
|
|
183
216
|
|
|
217
|
+
/**
|
|
218
|
+
* What the agent of a direct reads of the files its work meets in conflict with main (« aucun »
|
|
219
|
+
* without any).
|
|
220
|
+
* @param {string[]} fichiers
|
|
221
|
+
* @returns {string}
|
|
222
|
+
*/
|
|
223
|
+
export function rapportDuConflit(fichiers) {
|
|
224
|
+
return fichiers.length
|
|
225
|
+
? `L'avance de la copie sur main a laissé ces fichiers en conflit avec ton travail : ${fichiers.join(', ')}. Les marques de conflit sont dans la copie (\`<<<<<<<\`, \`=======\`, \`>>>>>>>\`) : tu résous chaque fichier, marques retirées ; un fichier du lot gardé (\`grillhouse-travail.patch\`, dans le dossier git de la copie) se reprend à la main dans la copie.`
|
|
226
|
+
: 'aucun';
|
|
227
|
+
}
|
|
228
|
+
|
|
184
229
|
// The task the agent of a direct reads at the head of its instruction.
|
|
185
230
|
const TACHE_DU_DIRECT =
|
|
186
231
|
"Ce ticket est mené en direct, hors du circuit : tu écris ses tests et son code ensemble, dans les paquets de ton plan. Un défaut corrigé porte un test qui le reproduit. Aucune preuve du rouge ni aucun contrôle du circuit ne suit ta séance : un relecteur juge ton lot, puis le superviseur le vérifie. Les constats ci-dessous, s'il y en a, viennent de ce relecteur.";
|
|
@@ -239,7 +284,20 @@ async function portsDuProjet(id, { contexteDuSuperviseur }) {
|
|
|
239
284
|
fiches: () =>
|
|
240
285
|
lesFiches(ctx).map(e => (e.role === 'relecteur' ? { ...e, lot: e.lot?.arbre } : e)),
|
|
241
286
|
lot: () => arbreDeLaCopie(ctx),
|
|
242
|
-
|
|
287
|
+
// The advance of the copy onto the tip of main, as the launcher plays it: `{ fichiers }`, the
|
|
288
|
+
// files in conflict or kept in the lot, which the agent of a direct writes (`ecritPar`).
|
|
289
|
+
avancer: copie => {
|
|
290
|
+
const tete = git('rev-parse', 'HEAD');
|
|
291
|
+
if (tete.status !== 0) {
|
|
292
|
+
return { fichiers: [] };
|
|
293
|
+
}
|
|
294
|
+
const r = preparer(copie, String(tete.stdout).trim(), {
|
|
295
|
+
ecrit: ecritPar('direct', () => false),
|
|
296
|
+
sortie: 1,
|
|
297
|
+
});
|
|
298
|
+
return { fichiers: [...(r.conflits ?? []), ...(r.enAttente ?? [])] };
|
|
299
|
+
},
|
|
300
|
+
seance: async (_role, { constats, paquets, conflits = [] }) => {
|
|
243
301
|
ctx.paquets = paquets;
|
|
244
302
|
ctx.contexte = ctx.contexteDuDirect;
|
|
245
303
|
const r = await seance(ctx, 'direct', {
|
|
@@ -249,6 +307,7 @@ async function portsDuProjet(id, { contexteDuSuperviseur }) {
|
|
|
249
307
|
evenement: 'neuve',
|
|
250
308
|
fiche: 'developpeur',
|
|
251
309
|
constats: ouverts(constats),
|
|
310
|
+
rapport: conflits.length ? rapportDuConflit(conflits) : undefined,
|
|
252
311
|
lectures: { lots: () => [], references: () => [] },
|
|
253
312
|
});
|
|
254
313
|
return r.fiche;
|
package/scripts/droits.mjs
CHANGED
|
@@ -29,8 +29,9 @@
|
|
|
29
29
|
// hooks and servers are not the role's), save the frame's (`grillhouse@…`), which carries the
|
|
30
30
|
// role's agent, its skills and the frame's hooks: Claude Code applies no `skillOverrides` to the
|
|
31
31
|
// skills of a plugin, and the role's agent preloads its own (`skills` of its definition);
|
|
32
|
-
// the background tasks off (`env`,
|
|
33
|
-
// it launches, and its session ends with its sheet
|
|
32
|
+
// the background tasks off and Code Mode on (`env`, ENV_DES_SEANCES: a role waits in the
|
|
33
|
+
// foreground for what it launches, and its session ends with its sheet; `claude -p` gets Code
|
|
34
|
+
// Mode, the REPL, only from this block); for a role that writes, its locks as hooks (PreToolUse: verrous/verrou.mjs on the tools of
|
|
34
35
|
// writing, verrous/commande.mjs on Bash), since the hooks of an agent's definition do not run in
|
|
35
36
|
// a folder Claude Code has not trusted, as the copy of a ticket.
|
|
36
37
|
// - `--tools <list>`: the tools its work uses; Edit and Write for a role that writes alone, the
|
|
@@ -82,10 +83,15 @@ const ECRIRE_AU_TICKET = [
|
|
|
82
83
|
'Bash(bd delete*)',
|
|
83
84
|
'Bash(npx grillhouse ticket*)',
|
|
84
85
|
];
|
|
85
|
-
// The
|
|
86
|
-
// `run_in_background`, the background agents): `claude -p` waits for them
|
|
87
|
-
// session ends with its sheet only without them.
|
|
88
|
-
|
|
86
|
+
// The variables of the env block of every session. One turns off the background tasks of Claude
|
|
87
|
+
// Code (the Bash tool's `run_in_background`, the background agents): `claude -p` waits for them
|
|
88
|
+
// before it ends, so a session ends with its sheet only without them. The other turns on Code Mode
|
|
89
|
+
// (the REPL): `claude -p` gets it only from the env block of `--settings`; the hooks and the
|
|
90
|
+
// permissions of the role apply to the tools the REPL calls.
|
|
91
|
+
const ENV_DES_SEANCES = {
|
|
92
|
+
CLAUDE_CODE_DISABLE_BACKGROUND_TASKS: '1',
|
|
93
|
+
CLAUDE_CODE_EXPERIMENTAL_CODE_MODE: '1',
|
|
94
|
+
};
|
|
89
95
|
|
|
90
96
|
// The reads of git in the copy, by its path (`git -C <copie> …`), which Claude Code does not let
|
|
91
97
|
// through without a rule, as it does `git status` in the working directory.
|
|
@@ -369,7 +375,7 @@ function reglagesDuRole(role, { racine, copie = racine, ticket, home }) {
|
|
|
369
375
|
.filter(g => !g.startsWith(GREFFON_DU_CADRE))
|
|
370
376
|
.map(g => [g, false])
|
|
371
377
|
),
|
|
372
|
-
env:
|
|
378
|
+
env: ENV_DES_SEANCES,
|
|
373
379
|
};
|
|
374
380
|
// The write lock runs the frame of the main tree, never the copy's; a copy that is the root keeps
|
|
375
381
|
// the project's own command.
|
package/scripts/engendres.mjs
CHANGED
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
// (scripts/integration/file.mjs) and the move of a copy onto main
|
|
23
23
|
// (scripts/enveloppe/travail-de-la-copie.mjs) call it on the tree where they applied the lot,
|
|
24
24
|
// main's version of each file taken.
|
|
25
|
+
// - `installerEtRegenerer` orders that play around the install of the copy, as Bazel builds an
|
|
26
|
+
// output before what reads it: first the references that write `package-lock.json`, from the
|
|
27
|
+
// manifests of the lot (`npm install --package-lock-only`, as Renovate writes a lock again),
|
|
28
|
+
// then the install, which reads that file, then the other references, which may need what it
|
|
29
|
+
// installed. The integration and the queue play it.
|
|
25
30
|
// - `encoreDeclares` keeps the generated files the tree where the lot is applied still declares, by
|
|
26
31
|
// their names: as a genrule of Bazel removed with its output in one change plays no more, the
|
|
27
32
|
// one a lot removes from the key is not played, and its files follow the lot, their deletion
|
|
@@ -30,6 +35,9 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
|
30
35
|
import path from 'node:path';
|
|
31
36
|
import { arbrePrincipal } from './outils-cles.mjs';
|
|
32
37
|
|
|
38
|
+
// The lock file `npm ci` installs from, at the root of the tree.
|
|
39
|
+
const VERROU = 'package-lock.json';
|
|
40
|
+
|
|
33
41
|
/**
|
|
34
42
|
* Whether one of <motifs> covers the file <fichier>, both from the root of the copy, as the inputs
|
|
35
43
|
* of Turborepo read them: a path names that file, a directory every file under it, a glob pattern
|
|
@@ -311,3 +319,27 @@ export function regenerer({ refs, lancer, dansCopie, ecrire = s => process.stdou
|
|
|
311
319
|
}
|
|
312
320
|
return null;
|
|
313
321
|
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* The install of a tree where a lot is applied, between the regenerations of <refs>: those that
|
|
325
|
+
* write the lock file `npm ci` reads play before <installer> (main's version of the lock file does
|
|
326
|
+
* not know the manifests of the lot), the others after it (see the header). `{}`, or
|
|
327
|
+
* `{ installation }`, the refusal of <installer>, or `{ refus }`, the one of a regeneration.
|
|
328
|
+
* @param {Parameters<typeof regenerer>[0] & { installer: () => string | null }} o
|
|
329
|
+
* @returns {{ installation?: string, refus?: string }}
|
|
330
|
+
*/
|
|
331
|
+
export function installerEtRegenerer({ installer, refs, ...o }) {
|
|
332
|
+
const avant = refs.filter(r => couvertPar(r.fichiers, VERROU));
|
|
333
|
+
const apres = refs.filter(r => !avant.includes(r));
|
|
334
|
+
const jouer = les => (les.length ? regenerer({ ...o, refs: les }) : null);
|
|
335
|
+
const refusAvant = jouer(avant);
|
|
336
|
+
if (refusAvant) {
|
|
337
|
+
return { refus: refusAvant };
|
|
338
|
+
}
|
|
339
|
+
const installation = installer();
|
|
340
|
+
if (installation) {
|
|
341
|
+
return { installation };
|
|
342
|
+
}
|
|
343
|
+
const refus = jouer(apres);
|
|
344
|
+
return refus ? { refus } : {};
|
|
345
|
+
}
|
|
@@ -335,11 +335,16 @@ export function rolesDuConflit(fichiers, estUnTest) {
|
|
|
335
335
|
|
|
336
336
|
/**
|
|
337
337
|
* Whether the role <role> writes a file, as a function of the file: the testwriter those
|
|
338
|
-
* <estUnTest> judges, the developpeur the others,
|
|
338
|
+
* <estUnTest> judges, the developpeur the others, the agent of a direct (`direct`) every file, any
|
|
339
|
+
* other role none (undefined).
|
|
339
340
|
* @param {string} role
|
|
340
341
|
* @param {(fichier: string) => unknown} estUnTest
|
|
341
342
|
*/
|
|
342
343
|
export function ecritPar(role, estUnTest) {
|
|
344
|
+
if (role === 'direct') {
|
|
345
|
+
// The agent of a direct writes tests and code together: every file is its own.
|
|
346
|
+
return () => true;
|
|
347
|
+
}
|
|
343
348
|
if (role === 'testwriter') {
|
|
344
349
|
return f => Boolean(estUnTest(f));
|
|
345
350
|
}
|
package/scripts/etapes.mjs
CHANGED
|
@@ -224,6 +224,14 @@ export const GESTES = [
|
|
|
224
224
|
'un rouge des contrôles du plan ou de la passe finale est celui d’une référence, même mêlé à d’autres : une que le projet déclare (`grillhouse.references`), ou un fichier que le cadre engendre (l’index des interfaces, les fichiers que le module du langage engendre) ; ou la passe abaisse la dette des gardes (`dette.mjs --abaisser`, depuis ses notes)',
|
|
225
225
|
cas: 'BP 320.9 : 292 min autour des références, dont 163 min d’attente pour régénérer à la main l’index des interfaces, le plafond et l’empreinte, des rouges de références mêlés à d’autres ; BP 320.3.9 : le plafond rouge aux contrôles, laissé à une passe finale qui rejoue les mêmes tests sur le même arbre (6,1 min) ; BP 320.6.5 : un test qui lit les références des paquets, rouge à côté de leur garde, envoyé au développeur, qui n’a rien à livrer puis ne peut pas les écrire',
|
|
226
226
|
},
|
|
227
|
+
{
|
|
228
|
+
genre: 'rejeu-des-engendres',
|
|
229
|
+
geste:
|
|
230
|
+
'avant la preuve du rouge, les contrôles et la passe finale, la commande de chaque fichier engendré (`grillhouse.engendres`) dont un motif `lit` couvre un fichier que le lot change, jouée dans la copie ; ses fichiers entrent au lot comme ceux de 4.2',
|
|
231
|
+
regle:
|
|
232
|
+
'un fichier engendré se construit avant les tests qui le lisent, et le graphe le rejoue quand ses entrées changent (Bazel, Nx, Turborepo) : aucun test du lot ne lit un fichier engendré périmé',
|
|
233
|
+
cas: 'OSD-sf1.25.8 : un ticket qui ajoute des cas de conformité rougit au test qui lit les sommes engendrées, sans-livraison ; OSD-sf1.25.13 : la commande jouée à la main deux fois',
|
|
234
|
+
},
|
|
227
235
|
{
|
|
228
236
|
genre: 'rien-a-livrer',
|
|
229
237
|
geste: 'aux contrôles, qui jugent le lot',
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
// the replaced commit, the candidate. A generated file the project declares
|
|
19
19
|
// (`grillhouse.engendres`, scripts/engendres.mjs, read from the main tree, a faulty key keeping
|
|
20
20
|
// the branch in the queue, named) is never merged, as npm writes package-lock.json again after
|
|
21
|
-
// a merge: a conflict on such files only takes main's version, and once the branch is replaced
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
21
|
+
// a merge: a conflict on such files only takes main's version, and once the branch is replaced,
|
|
22
|
+
// the command of each one whose files, or the files it reads, the branch touches writes it
|
|
23
|
+
// again, one that writes package-lock.json before the install and the others after it
|
|
24
|
+
// (`installerEtRegenerer`), with the tools of the project, and what it writes enters the
|
|
25
|
+
// branch's commit; a command that fails makes the branch leave the queue, the command and its
|
|
26
|
+
// output named;
|
|
26
27
|
// - a branch with nothing ahead of main does not enter: it leaves the queue, its ticket loses
|
|
27
28
|
// `en-file` and takes a comment, and stays as it is;
|
|
28
29
|
// - a branch that does not replace (the files in conflict) leaves the queue: its ticket loses
|
|
@@ -80,7 +81,7 @@ import {
|
|
|
80
81
|
encoreDeclares,
|
|
81
82
|
engendresDe,
|
|
82
83
|
prendreLesEngendres,
|
|
83
|
-
|
|
84
|
+
installerEtRegenerer,
|
|
84
85
|
} from '../engendres.mjs';
|
|
85
86
|
import { arbreEstJuge, garderLArbreJuge } from '../arbres-juges.mjs';
|
|
86
87
|
import { A_REPASSER } from '../codes-de-sortie.mjs';
|
|
@@ -296,10 +297,6 @@ function remplacer(o, tip, tete) {
|
|
|
296
297
|
}
|
|
297
298
|
rebase = dansCopie('-c', 'core.editor=true', 'rebase', '--continue');
|
|
298
299
|
}
|
|
299
|
-
const installation = installer();
|
|
300
|
-
if (installation) {
|
|
301
|
-
return { sortie: [installation, "Le verrou de la branche replacée ne s'installe pas."] };
|
|
302
|
-
}
|
|
303
300
|
const touches = aRejouer(
|
|
304
301
|
engendres,
|
|
305
302
|
copie,
|
|
@@ -307,21 +304,25 @@ function remplacer(o, tip, tete) {
|
|
|
307
304
|
.stdout.split('\0')
|
|
308
305
|
.filter(Boolean)
|
|
309
306
|
);
|
|
307
|
+
const { installation, refus } = installerEtRegenerer({
|
|
308
|
+
refs: touches.map(e => ({ ...e, cadre: false })),
|
|
309
|
+
installer,
|
|
310
|
+
dansCopie,
|
|
311
|
+
lancer: commande =>
|
|
312
|
+
spawnSync('bash', monter('sh', '-c', commande), {
|
|
313
|
+
cwd: copie,
|
|
314
|
+
encoding: 'utf8',
|
|
315
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
316
|
+
env,
|
|
317
|
+
}),
|
|
318
|
+
});
|
|
319
|
+
if (installation) {
|
|
320
|
+
return { sortie: [installation, "Le verrou de la branche replacée ne s'installe pas."] };
|
|
321
|
+
}
|
|
322
|
+
if (refus) {
|
|
323
|
+
return { sortie: ['ses fichiers engendrés ne se régénèrent pas sur main.', refus] };
|
|
324
|
+
}
|
|
310
325
|
if (touches.length) {
|
|
311
|
-
const refus = regenerer({
|
|
312
|
-
refs: touches.map(e => ({ ...e, cadre: false })),
|
|
313
|
-
dansCopie,
|
|
314
|
-
lancer: commande =>
|
|
315
|
-
spawnSync('bash', monter('sh', '-c', commande), {
|
|
316
|
-
cwd: copie,
|
|
317
|
-
encoding: 'utf8',
|
|
318
|
-
maxBuffer: 256 * 1024 * 1024,
|
|
319
|
-
env,
|
|
320
|
-
}),
|
|
321
|
-
});
|
|
322
|
-
if (refus) {
|
|
323
|
-
return { sortie: ['ses fichiers engendrés ne se régénèrent pas sur main.', refus] };
|
|
324
|
-
}
|
|
325
326
|
if (dansCopie('diff', '--cached', '--quiet').status !== 0) {
|
|
326
327
|
const corrige = dansCopie('commit', '-q', '--amend', '--no-edit', '--no-verify');
|
|
327
328
|
if (corrige.status !== 0) {
|
|
@@ -35,10 +35,11 @@
|
|
|
35
35
|
// 5. the lots, applied in three ways in the copy, tests first, without the files a reference
|
|
36
36
|
// writes in full; the files of the lot in the
|
|
37
37
|
// ticket's copy are compared with the copy's own base plus the lot, not with the integration
|
|
38
|
-
// copy. Once the lots are in the copy, the
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
// then the references
|
|
38
|
+
// copy. Once the lots are in the copy, the references that write package-lock.json regenerate
|
|
39
|
+
// (below), then the replay makes the dependencies agree with the lock file and the manifests
|
|
40
|
+
// of the copy (`npm ci`, as the continuous integration runs it); an install that fails refuses
|
|
41
|
+
// the lot, « Les dépendances de la copie ne s'installent pas. »; then the other references
|
|
42
|
+
// regenerate (`installerEtRegenerer` of scripts/engendres.mjs);
|
|
42
43
|
// 6. the commit in the copy, its hooks included, under GRILLHOUSE_INTEGRATION=1: a pre-commit
|
|
43
44
|
// hook that plays the guards skips them, as the final pass plays them; nothing is verified
|
|
44
45
|
// here: the queue lays the branch on the tip of main, and its final pass judges the lot before
|
|
@@ -59,9 +60,10 @@
|
|
|
59
60
|
// scripts/engendres.mjs reads them). As a genrule of Bazel writes its output again on the merged
|
|
60
61
|
// tree, and npm install writes package-lock.json again after a merge, a file of the lot a reference
|
|
61
62
|
// writes in full is not applied: main's version stays, and each reference whose files or reads the
|
|
62
|
-
// lot touches plays in the copy, on main of the moment,
|
|
63
|
-
//
|
|
64
|
-
//
|
|
63
|
+
// lot touches plays in the copy, on main of the moment, before the commit, through the mounts, with
|
|
64
|
+
// the tools of the project, and what it writes enters the commit (`regenerer` of
|
|
65
|
+
// scripts/engendres.mjs): one that writes package-lock.json before the install, the others after it
|
|
66
|
+
// (`installerEtRegenerer`). A command of the project at another code than 0, one of
|
|
65
67
|
// the frame on a real failure (126, 127, a signal), or a file it changes that its `fichiers` do not
|
|
66
68
|
// cover, refuses the lot, the command, its code and its output named. A conflict on any other file
|
|
67
69
|
// refuses it, as the three-way application says. A generated file of the project the lot removes
|
|
@@ -89,9 +91,9 @@ import { arbitrageTranche, estArbitrage } from '../arbitrages.mjs';
|
|
|
89
91
|
import {
|
|
90
92
|
couvertPar,
|
|
91
93
|
engendresDe,
|
|
94
|
+
installerEtRegenerer,
|
|
92
95
|
partDesLots,
|
|
93
96
|
poserLesRetires,
|
|
94
|
-
regenerer,
|
|
95
97
|
touchesPar,
|
|
96
98
|
} from '../engendres.mjs';
|
|
97
99
|
import { langageDe } from '../langages.mjs';
|
|
@@ -320,7 +322,7 @@ function differents(copieTicket, lots, fichiers, tmp) {
|
|
|
320
322
|
return r.stdout.split('\0').filter(Boolean);
|
|
321
323
|
}
|
|
322
324
|
|
|
323
|
-
function main(argv) {
|
|
325
|
+
export function main(argv, ou = process.cwd()) {
|
|
324
326
|
const o = lire(argv);
|
|
325
327
|
if ('faute' in o) {
|
|
326
328
|
process.stderr.write(
|
|
@@ -331,6 +333,7 @@ function main(argv) {
|
|
|
331
333
|
}
|
|
332
334
|
// The main tree, from git's common directory: run from a copy, the integration still works on it.
|
|
333
335
|
const commun = spawnSync('git', ['rev-parse', '--path-format=absolute', '--git-common-dir'], {
|
|
336
|
+
cwd: ou,
|
|
334
337
|
encoding: 'utf8',
|
|
335
338
|
}).stdout.trim();
|
|
336
339
|
const racine = path.dirname(commun);
|
|
@@ -484,8 +487,9 @@ function main(argv) {
|
|
|
484
487
|
}
|
|
485
488
|
const { dansCopie, monter, installer } = ouverte;
|
|
486
489
|
|
|
487
|
-
// 5. The lots, applied in the copy without the files a reference writes in full
|
|
488
|
-
//
|
|
490
|
+
// 5. The lots, applied in the copy without the files a reference writes in full; then the
|
|
491
|
+
// references that write the lock file (regenerated from the lots' manifests), then the
|
|
492
|
+
// installation that follows that lock file, then the other references regenerated.
|
|
489
493
|
const sansEntiers = entiers.map(f => `--exclude=${f}`);
|
|
490
494
|
for (const p of lots) {
|
|
491
495
|
const r = dansCopie('apply', '--3way', '--index', ...sansEntiers, p);
|
|
@@ -512,27 +516,24 @@ function main(argv) {
|
|
|
512
516
|
);
|
|
513
517
|
}
|
|
514
518
|
dire('✓ lots appliqués');
|
|
515
|
-
const installation = installer();
|
|
516
|
-
if (installation) {
|
|
517
|
-
return refuser(installation);
|
|
518
|
-
}
|
|
519
519
|
const aRejouer = part.rejouees;
|
|
520
|
+
const env = avecLesDonnees(donnees, avecLesOutils(outils, process.env, empreintes));
|
|
521
|
+
const { installation, refus } = installerEtRegenerer({
|
|
522
|
+
refs: aRejouer,
|
|
523
|
+
installer,
|
|
524
|
+
dansCopie,
|
|
525
|
+
lancer: commande =>
|
|
526
|
+
spawnSync('bash', monter('sh', '-c', commande), {
|
|
527
|
+
cwd: copie,
|
|
528
|
+
encoding: 'utf8',
|
|
529
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
530
|
+
env,
|
|
531
|
+
}),
|
|
532
|
+
});
|
|
533
|
+
if (installation || refus) {
|
|
534
|
+
return refuser(installation ?? refus);
|
|
535
|
+
}
|
|
520
536
|
if (aRejouer.length) {
|
|
521
|
-
const env = avecLesDonnees(donnees, avecLesOutils(outils, process.env, empreintes));
|
|
522
|
-
const refus = regenerer({
|
|
523
|
-
refs: aRejouer,
|
|
524
|
-
dansCopie,
|
|
525
|
-
lancer: commande =>
|
|
526
|
-
spawnSync('bash', monter('sh', '-c', commande), {
|
|
527
|
-
cwd: copie,
|
|
528
|
-
encoding: 'utf8',
|
|
529
|
-
maxBuffer: 256 * 1024 * 1024,
|
|
530
|
-
env,
|
|
531
|
-
}),
|
|
532
|
-
});
|
|
533
|
-
if (refus) {
|
|
534
|
-
return refuser(refus);
|
|
535
|
-
}
|
|
536
537
|
dire(`✓ références régénérées sur main à jour : ${aRejouer.map(r => r.nom).join(', ')}`);
|
|
537
538
|
}
|
|
538
539
|
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
// the manifests (every `package.json` git tracks) with the key
|
|
21
21
|
// `node_modules/.integration-lock`, runs `npm ci` when they differ and writes the key again; a
|
|
22
22
|
// failing install gives `DEPENDANCES_REFUSEES`, the one form of that refusal. It runs at the
|
|
23
|
-
// opening, and the consumer calls `installer` once the lot is in the copy
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
// manifest).
|
|
23
|
+
// opening, and the consumer calls `installer` once the lot is in the copy and the commands that
|
|
24
|
+
// write the lock file have played (`installerEtRegenerer` of scripts/engendres.mjs): a lot that
|
|
25
|
+
// changes the lock file or a manifest is installed as the continuous integration installs it
|
|
26
|
+
// (`npm ci` refuses a lock file in disagreement with its manifest).
|
|
27
27
|
// - Every command of the project run in the copy (`lancer`: the install) leaves the
|
|
28
28
|
// index of its copy up to date, green or red: the consumers that apply a lot with `--index` (the
|
|
29
29
|
// integration, the queue) read an index that matches the files the command touched, and none
|