@roomi-fields/grillhouse 0.24.11 → 0.24.13

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.
@@ -77,6 +77,9 @@ const ESSAIS_PAR_BRANCHE = 5;
77
77
  // The variable in which bd reads the author of a comment, and the queue's author.
78
78
  const ACTEUR = 'BEADS_ACTOR';
79
79
  export const AUTEUR_DE_LA_FILE = 'file';
80
+ // The reason of the closure of a ticket the queue brought onto main, before its commit, which the
81
+ // circuit reads to name that commit (scripts/circuit.mjs, the tri of the discoveries).
82
+ export const INTEGRE = 'intégré : ';
80
83
  // How long the queue looks for the run of the CI, then waits for it.
81
84
  const RECHERCHE_CI_MS = 2 * 60 * 1000;
82
85
  const ATTENTE_CI_MS = 30 * 60 * 1000;
@@ -302,7 +305,7 @@ function main(argv) {
302
305
  const entrer = (entree, nouveau) => {
303
306
  const court = nouveau.slice(0, 7);
304
307
  bd('update', entree.ticket, '--remove-label', 'en-file');
305
- bd('close', entree.ticket, '--reason', `intégré : ${court}`);
308
+ bd('close', entree.ticket, '--reason', `${INTEGRE}${court}`);
306
309
  rmSync(path.join(racine, '.claude', 'worktrees', `${entree.ticket}.travail`), {
307
310
  recursive: true,
308
311
  force: true,
@@ -0,0 +1,41 @@
1
+ // From 0.24.12 the circuit sorts the discoveries of a ticket once its lot is on main (step 5.3, the
2
+ // tri of the discoveries, grillhouse-0yu.5): each one receives its verdict at its ticket, and an
3
+ // `a-porter` or a `non-confirmee` reopens under `a-valider`. A project's `docs/agents/issue-tracker.md`
4
+ // is its own since 0.23.0, and its template's rule said a discovery « reopens on the owner's
5
+ // word », the supervisor bringing those that touch a real use: a rule the frame no longer holds.
6
+ //
7
+ // - Each of the two sentences of that rule, when the file holds it as the template wrote it,
8
+ // becomes the rule of the tri, as the template now writes it; nothing else of the file changes.
9
+ // - A file without them (already migrated, or rewritten by the project) is not written; a project
10
+ // without the file neither.
11
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
12
+ import path from 'node:path';
13
+
14
+ export const version = '0.24.12';
15
+ export const nom = 'tri des découvertes';
16
+
17
+ const FICHIER = path.join('docs', 'agents', 'issue-tracker.md');
18
+ // Each former sentence, and the sentence of the tri that replaces it.
19
+ const REMPLACEMENTS = [
20
+ [
21
+ "; it reopens on the owner's word. A discovery that blocks stops the agent, and its handoff names it. The supervisor brings to the owner the discoveries that touch a real use.",
22
+ ". Once the ticket's lot is on main, the tri of the discoveries (step 5.3, the `explorateur`) gives each one its verdict at its ticket, with its piece, as a label: `traitee`, `doublon` or `sans-suite` leave it closed; `a-porter` (a defect of the actual use) or `non-confirmee` (no proof played again, what lacks written) reopen it under `a-valider`, for the owner. A discovery that blocks stops the agent, and its handoff names it.",
23
+ ],
24
+ [
25
+ "`decouverte` (a discovery recorded closed; it reopens on the owner's word),",
26
+ '`decouverte` (a discovery recorded closed; the tri reopens it under `a-valider` when its verdict is `a-porter` or `non-confirmee`), `traitee`, `doublon`, `sans-suite`, `a-porter`, `non-confirmee` (the verdict of the tri of a discovery),',
27
+ ],
28
+ ];
29
+
30
+ /** Brings the rule of the tri to the project's issue-tracker.md; returns what it did. */
31
+ export function migrer(projet) {
32
+ const fichier = path.join(projet, FICHIER);
33
+ if (!existsSync(fichier)) return [];
34
+ const texte = readFileSync(fichier, 'utf8');
35
+ const neuf = REMPLACEMENTS.reduce((t, [ancien, nouveau]) => t.replace(ancien, nouveau), texte);
36
+ if (neuf === texte) return [];
37
+ writeFileSync(fichier, neuf);
38
+ return [
39
+ `${FICHIER} : une découverte reçoit son verdict au tri des découvertes, en fin de ticket, au lieu de se rouvrir sur le mot du responsable`,
40
+ ];
41
+ }
@@ -29,6 +29,7 @@ import * as apiExtractorDuPaquet from './migrations/0.24.2-api-extractor-du-paqu
29
29
  import * as nomsDeclaresInutilises from './migrations/0.24.4-noms-declares-inutilises.mjs';
30
30
  import * as lignesMalFormees from './migrations/0.24.6-lignes-mal-formees.mjs';
31
31
  import * as matiereDansLesTests from './migrations/0.24.7-matiere-dans-les-tests.mjs';
32
+ import * as triDesDecouvertes from './migrations/0.24.12-tri-des-decouvertes.mjs';
32
33
 
33
34
  /** The migrations of the package. */
34
35
  export const MIGRATIONS = [
@@ -42,6 +43,7 @@ export const MIGRATIONS = [
42
43
  nomsDeclaresInutilises,
43
44
  lignesMalFormees,
44
45
  matiereDansLesTests,
46
+ triDesDecouvertes,
45
47
  ];
46
48
 
47
49
  /**
package/scripts/nuit.sh CHANGED
@@ -5,8 +5,12 @@
5
5
  # to the files changed since the last green (scripts/integration/integrer.mjs,
6
6
  # scripts/dernier-vert.mjs).
7
7
  #
8
- # npx grillhouse nuit from the root of the project, by the crontab of the machine, e.g.
9
- # « 0 3 * * * cd <root> && node_modules/.bin/grillhouse nuit »
8
+ # npx grillhouse nuit from the root of the project, by the crontab of the machine, as the
9
+ # session start proposes it, with the directory of its Node, e.g.
10
+ # « 0 3 * * * export PATH=<node dir>:$PATH; cd <root> &&
11
+ # node_modules/.bin/grillhouse nuit »
12
+ # npx grillhouse nuit --help the usage on the output (also -h), exit 0; any other argument is
13
+ # refused, the usage on the error stream, exit 2: nothing runs.
10
14
  #
11
15
  # - It plays main's HEAD in its own clean copy (.claude/worktrees/nuit): detached, every untracked
12
16
  # file removed, its submodules set at the commit of HEAD (scripts/sous-modules.sh, a local
@@ -18,8 +22,10 @@
18
22
  # played for real (`--force`, no log replayed from the cache, no measure against the last
19
23
  # green: the complete pass, scripts/verifier.mjs), its result written to the cache again; green,
20
24
  # its tree becomes the last green of the day's passes.
21
- # A full pass « à repasser » (75, scripts/verifier.mjs: a failure of duration under load, which
22
- # found no rest in its bound) makes the night « à repasser », below.
25
+ # Its three steps (the full pass, the night tests, the project's night script) each play even
26
+ # when one before is red, as a CI plays its independent jobs; the night is red when one of them
27
+ # is. A full pass « à repasser » (75, scripts/verifier.mjs: a failure of duration under load,
28
+ # which found no rest in its bound) ends the night there, « à repasser », below.
23
29
  # An existing copy that does not get ready (its move onto HEAD, its cleaning or the setting of
24
30
  # its submodules fails) is removed by `scripts/retirer-copie.sh --jetable` (local work does not
25
31
  # hold it, a lock does) and created again, once; a copy that does not get ready the second time
@@ -29,17 +35,17 @@
29
35
  # read-only, its working tree and its git repository (the list the preparation's pose printed,
30
36
  # whatever a command rewrites afterwards): a write into it fails. With a shared submodule and no possible mount (bwrap absent
31
37
  # or refused), the night turns red, the log saying so, before any command runs.
32
- # - The night tests: after a green full pass, the files `*.nuit.test.*`, `*.nuit.spec.*`,
38
+ # - The night tests: after the full pass, the files `*.nuit.test.*`, `*.nuit.spec.*`,
33
39
  # `*.budget.test.*` and `*.budget.spec.*` of the copy (outside node_modules, dist and .git): the
34
40
  # night tests and the time budget benches, which `npm test` and the integration leave out
35
41
  # (the package @roomi-fields/grillhouse/vitest-config, scripts/vitest-config/, which every day configuration
36
42
  # extends), run by Vitest with the frame's configuration (scripts/vitest.nuit.config.mjs, beside
37
43
  # this script), bench or night test alone as well. A red turns the night red, with a log line that says so, and the
38
- # project's night script does not run. A copy with neither plays none. A run « à repasser » (75:
44
+ # project's night script still plays. A copy with neither plays none. A run « à repasser » (75:
39
45
  # every failure depended on a duration, one under load, scripts/vitest-config/duree.reporter.mjs)
40
46
  # waits for rest (`npx grillhouse pression attendre`, bound 15 min) and plays
41
47
  # once more; green then, the night goes on; à repasser again, or no rest in the bound, the night
42
- # is « à repasser ».
48
+ # ends there, « à repasser », red if the full pass is.
43
49
  # - « À repasser » (exit 75): neither green nor red. The last green stays, no ticket opens, nothing
44
50
  # is pushed, the log says so; the next night plays again.
45
51
  # - The project's night script: `grillhouse.nuit` in the package.json of the commit it plays names
@@ -57,19 +63,47 @@
57
63
  # keys are read as written, before any work: a grillhouse.poussee that is neither null nor an
58
64
  # object, or a grillhouse.poussee.nuit that is not a non-blank string, turns the night red with
59
65
  # a log line that cites it, one line per faulty key. A refused push keeps the last green, opens
60
- # (or completes) the night ticket « La poussée de la nuit est refusée sur <commit> », and exits
61
- # 1; a remote already at the commit accepts the push.
66
+ # the night ticket « La poussée de la nuit est refusée sur <commit> vers « origin/<branch> » »
67
+ # (or comments the open one that names « origin/<branch> »), and exits 1; a remote already at
68
+ # the commit accepts the push.
62
69
  # - It takes no lock of the integration or of the queue (scripts/integration/file.mjs): an
63
70
  # integration and the queue run during the night, each in its own copy.
64
71
  # - Its log is <git common dir>/nuit/<date>.log. Green: HEAD becomes the last green commit
65
- # (<git common dir>/nuit/dernier-vert). Red: a ticket labelled `nuit`, with the commits since the
66
- # last green, where `git bisect` looks for the culprit; an open one gets a comment instead.
67
- # With a last green, each red task of the full pass (the file GRILLHOUSE_ROUGES names, which
68
- # scripts/verifier.mjs writes: `<package>#<task>` per line, no task à repasser among them) gets
69
- # its line, the command that looks for the culprit with that task alone:
72
+ # (<git common dir>/nuit/dernier-vert). Red: the red tasks, each grouped by its cause as an
73
+ # alerting system groups by fingerprint: each red task of the full pass (the file
74
+ # GRILLHOUSE_ROUGES names, which scripts/verifier.mjs writes: `<package>#<task>` per line, no
75
+ # task à repasser among them), else the full pass by its command, the night tests, the project's
76
+ # night script by its command, or the preparation when the night is red before any step. Each
77
+ # red task comments the open ticket labelled `nuit` whose title names it (« <task> »), once per
78
+ # ticket, or opens its own, « La nuit est rouge sur « <task> » depuis la nuit du <date> ». The
79
+ # text, the same for each, gives the commits since the last green, where `git bisect` looks for
80
+ # the culprit, each red step and each red task, with or without a last green, then the end of
81
+ # the log. With a last green, each red task of the full pass gets the command that looks for the
82
+ # culprit with that task alone:
70
83
  # `git bisect start <head> <last green> && git bisect run npx turbo run <task> --filter=<package>`
71
84
  # (`--filter=//` for the root), Turborepo's hash replaying at each step only what changed.
72
85
  set -u
86
+ usage() {
87
+ echo "Usage : grillhouse nuit"
88
+ echo "La nuit : la passe complète jouée pour de vrai, puis les tests de nuit et les bancs de budget,"
89
+ echo "sur le HEAD de main, dans sa copie (.claude/worktrees/nuit). Se lance depuis la racine du projet."
90
+ echo "Options :"
91
+ echo " -h, --help affiche cette aide, sans lancer la nuit"
92
+ }
93
+ for argument in "$@"; do
94
+ case "$argument" in
95
+ -h | --help) ;;
96
+ *)
97
+ echo "⛔ grillhouse nuit : argument inconnu : $argument" >&2
98
+ usage >&2
99
+ exit 2
100
+ ;;
101
+ esac
102
+ done
103
+ if [ $# -gt 0 ]; then
104
+ usage
105
+ exit 0
106
+ fi
73
107
  # The project is the working directory; the frame's scripts are this one's neighbours.
74
108
  racine="$PWD"
75
109
  ici="$(cd "$(dirname "$0")" && pwd)"
@@ -84,6 +118,11 @@ rm -f "$rouges"
84
118
  tete="$(git -C "$racine" rev-parse HEAD)"
85
119
  copie="$racine/.claude/worktrees/nuit"
86
120
  branche=
121
+ # The red steps of the night, and its red tasks: those of the full pass (turbo 1, which a bisect
122
+ # replays alone), then a step red without a task of its own, named by its command (turbo 0).
123
+ etapes=()
124
+ taches=()
125
+ turbo=()
87
126
  # Gets the copy ready on HEAD: detached, cleaned, its submodules set; `partages` holds the list the
88
127
  # pose fixes, which every mount gets. Prints the reason on failure.
89
128
  partages=
@@ -162,15 +201,31 @@ jouer() {
162
201
  monter npm --prefix "$copie" ci --no-audit --no-fund --silent || return 1
163
202
  cp "$copie/package-lock.json" "$copie/node_modules/.nuit-lock"
164
203
  fi
165
- # The full pass, played for real: the night replays no log of the cache.
166
- local code
204
+ # The full pass, played for real: the night replays no log of the cache. Each step plays even
205
+ # when one before it is red; a step à repasser ends the night there, red if a step before it is.
206
+ local code tache avant
167
207
  GRILLHOUSE_ROUGES="$rouges" monter npm --prefix "$copie" run verifier -- --force
168
208
  code=$?
169
209
  if [ "$code" -eq 75 ]; then
170
210
  echo "⏱ la passe complète est à repasser (code 75) : un échec de durée sous charge, sans repos dans la borne."
171
211
  return 75
172
212
  fi
173
- [ "$code" -eq 0 ] || return 1
213
+ if [ "$code" -ne 0 ]; then
214
+ echo "✗ la passe complète (npm run verifier -- --force) a échoué."
215
+ etapes+=("la passe complète (npm run verifier -- --force)")
216
+ avant=${#taches[@]}
217
+ if [ -s "$rouges" ]; then
218
+ while IFS= read -r tache; do
219
+ [ -n "$tache" ] || continue
220
+ taches+=("$tache")
221
+ turbo+=(1)
222
+ done < "$rouges"
223
+ fi
224
+ if [ "${#taches[@]}" -eq "$avant" ]; then
225
+ taches+=("npm run verifier -- --force")
226
+ turbo+=(0)
227
+ fi
228
+ fi
174
229
  if [ -n "$(find "$copie" \( -name node_modules -o -name dist -o -name .git \) -prune -o \
175
230
  -type f -regextype posix-extended -regex '.*\.(nuit|budget)\.(test|spec)\.(c|m)?[jt]sx?' -print -quit)" ]; then
176
231
  bancs() { (cd "$copie" && monter npx --no-install vitest run --root "$copie" \
@@ -181,25 +236,36 @@ jouer() {
181
236
  echo "⏱ les bancs de temps ou les tests de nuit sont à repasser (code 75) : attente du repos, puis une relance."
182
237
  if ! node "$ici/vitest-config/pression.mjs" attendre; then
183
238
  echo "⏱ à repasser : pas de repos dans la borne."
184
- return 75
239
+ fin 75
240
+ return
185
241
  fi
186
242
  bancs
187
243
  code=$?
188
244
  if [ "$code" -eq 75 ]; then
189
245
  echo "⏱ à repasser : les bancs échouent encore sous charge après la relance."
190
- return 75
246
+ fin 75
247
+ return
191
248
  fi
192
249
  fi
193
250
  if [ "$code" -ne 0 ]; then
194
251
  echo "✗ les bancs de temps ou les tests de nuit (*.budget.*, *.nuit.*) ont échoué."
195
- return 1
252
+ etapes+=("les bancs de temps et les tests de nuit (*.budget.*, *.nuit.*)")
253
+ taches+=("les bancs de temps et les tests de nuit")
254
+ turbo+=(0)
196
255
  fi
197
256
  fi
198
- [ -n "$nuit" ] || return 0
199
- if ! monter npm --prefix "$copie" run "$nuit"; then
257
+ if [ -n "$nuit" ] && ! monter npm --prefix "$copie" run "$nuit"; then
200
258
  echo "✗ le script de nuit du projet \`npm run $nuit\` (grillhouse.nuit) a échoué."
201
- return 1
259
+ etapes+=("le script de nuit du projet (npm run $nuit, grillhouse.nuit)")
260
+ taches+=("npm run $nuit")
261
+ turbo+=(0)
202
262
  fi
263
+ fin 0
264
+ }
265
+ # The night's verdict once its steps are played: red when a step is red, else <code>.
266
+ fin() {
267
+ [ "${#etapes[@]}" -eq 0 ] || return 1
268
+ return "$1"
203
269
  }
204
270
  jouer >> "$journal" 2>&1
205
271
  verdict=$?
@@ -209,19 +275,30 @@ if [ "$verdict" -eq 75 ]; then
209
275
  exit 75
210
276
  fi
211
277
 
212
- # Opens the night ticket (subject « number — subject — parent », the number being the id without the
213
- # project's prefix as `bd config get issue_prefix` gives it), or comments the open one; prints its id.
278
+ # The open night tickets, read once; a ticket names a cause when its title holds « <cause> ».
279
+ ouverts=
280
+ commentes=" "
281
+ # Reports one cause: comments the open night ticket whose title names it (once a night), or opens
282
+ # its own (title « number — subject — parent », the number being the id without the project's
283
+ # prefix as `bd config get issue_prefix` gives it, the subject naming « <cause> »); its id goes to
284
+ # `numero`.
214
285
  signaler() {
215
- local sujet="$1" texte="$2" ouvert neuf= prefixe
216
- ouvert="$(cd "$racine" && bd list --status open --label nuit --json 2>/dev/null | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{try{const l=JSON.parse(s);process.stdout.write(l[0]?.id??"")}catch{}})')"
286
+ local cause="$1" sujet="$2" texte="$3" ouvert neuf= prefixe
287
+ [ -n "$ouverts" ] || ouverts="$(cd "$racine" && bd list --status open --label nuit --json 2>/dev/null)"
288
+ ouvert="$(printf '%s' "$ouverts" | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{try{const c=`« ${process.argv[1]} »`;process.stdout.write(JSON.parse(s).find(t=>String(t.title??"").includes(c))?.id??"")}catch{}})' "$cause")"
217
289
  if [ -n "$ouvert" ]; then
218
- (cd "$racine" && bd comments add "$ouvert" "$texte" >/dev/null)
290
+ case "$commentes" in
291
+ *" $ouvert "*) ;;
292
+ *)
293
+ (cd "$racine" && bd comments add "$ouvert" "$texte" >/dev/null)
294
+ commentes="$commentes$ouvert " ;;
295
+ esac
219
296
  else
220
297
  neuf="$(cd "$racine" && bd create "$sujet" -t bug -p 1 -l nuit -d "$texte" --silent)"
221
298
  prefixe="$(cd "$racine" && bd config get issue_prefix 2>/dev/null)"
222
299
  [ -n "$neuf" ] && (cd "$racine" && bd update "$neuf" --title "${neuf#"$prefixe"-} — $sujet — parent" >/dev/null)
223
300
  fi
224
- echo "${ouvert:-$neuf}"
301
+ numero="${ouvert:-$neuf}"
225
302
  }
226
303
 
227
304
  if [ "$verdict" -eq 0 ]; then
@@ -237,7 +314,7 @@ Le dernier vert reste ${tete:0:7}.
237
314
  Journal : $journal
238
315
  Fin du journal :
239
316
  $(tail -40 "$journal")"
240
- numero="$(signaler "La poussée de la nuit est refusée sur ${tete:0:7}" "$texte")"
317
+ signaler "origin/$branche" "La poussée de la nuit est refusée sur ${tete:0:7} vers « origin/$branche »" "$texte"
241
318
  echo "✗ vert, poussée refusée : ticket ${numero:-neuf} (étiquette nuit)." >> "$journal"
242
319
  exit 1
243
320
  fi
@@ -247,23 +324,39 @@ fi
247
324
 
248
325
  vert="$(cat "$dossier/dernier-vert" 2>/dev/null || true)"
249
326
  intervalle="${vert:+${vert:0:7}..}${tete:0:7}"
250
- bissections=
251
- if [ -n "$vert" ] && [ -s "$rouges" ]; then
252
- bissections="Pour chaque tâche rouge, la commande qui cherche le commit fautif :"
253
- while IFS= read -r tache; do
254
- [ -n "$tache" ] || continue
255
- bissections="$bissections
256
- - $tache : git bisect start ${tete:0:7} ${vert:0:7} && git bisect run npx turbo run ${tache#*#} --filter=${tache%%#*}"
257
- done < "$rouges"
258
- bissections="$bissections
259
- "
327
+ # A red before any step (the copy, its mount, the keys, the installation) is the preparation's.
328
+ if [ "${#etapes[@]}" -eq 0 ]; then
329
+ etapes=("la préparation (la copie, ses sous-modules, les clés grillhouse, l'installation)")
330
+ taches=("la préparation")
331
+ turbo=(0)
260
332
  fi
333
+ liste="Étapes rouges :"
334
+ for e in "${etapes[@]}"; do
335
+ liste="$liste
336
+ - $e"
337
+ done
338
+ liste="$liste
339
+ Tâches rouges"
340
+ [ -n "$vert" ] && liste="$liste, avec pour une tâche de la passe complète la commande qui cherche le commit fautif"
341
+ liste="$liste :"
342
+ for i in "${!taches[@]}"; do
343
+ tache="${taches[$i]}"
344
+ if [ -n "$vert" ] && [ "${turbo[$i]}" -eq 1 ]; then
345
+ tache="$tache : git bisect start ${tete:0:7} ${vert:0:7} && git bisect run npx turbo run ${tache#*#} --filter=${tache%%#*}"
346
+ fi
347
+ liste="$liste
348
+ - $tache"
349
+ done
261
350
  texte="La nuit du $(date +%Y-%m-%d) est rouge sur ${tete:0:7}.
262
351
  Commits à chercher (git bisect) : $intervalle.
263
- ${bissections}Journal : $journal
352
+ $liste
353
+ Journal : $journal
264
354
  Fin du journal :
265
355
  $(tail -40 "$journal")"
266
- # A night ticket is the mother of its fixes.
267
- numero="$(signaler "La nuit est rouge depuis la nuit du $(date +%Y-%m-%d)" "$texte")"
268
- echo "✗ rouge : ticket ${numero:-neuf} (étiquette nuit)." >> "$journal"
356
+ # Each red task reports on the night ticket that names it, else on its own; a night ticket is the
357
+ # mother of its fixes.
358
+ for tache in "${taches[@]}"; do
359
+ signaler "$tache" "La nuit est rouge sur « $tache » depuis la nuit du $(date +%Y-%m-%d)" "$texte"
360
+ echo "✗ rouge : ticket ${numero:-neuf} (étiquette nuit) sur « $tache »." >> "$journal"
361
+ done
269
362
  exit 1