@roomi-fields/grillhouse 0.34.2 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +33 -13
- package/cadre/templates/cargo/package.json +4 -2
- package/cadre/templates/projet/.claude/settings.json +0 -1
- package/cadre/templates/projet/CLAUDE.md +5 -0
- package/cadre/templates/python/package.json +4 -2
- package/charte.md +4 -4
- package/dist/temporal/file/contrat.d.ts +3 -1
- package/dist/temporal/file/deroule.js +2 -2
- package/dist/temporal/file/deroule.js.map +1 -1
- package/dist/temporal/places/contrat.d.ts +12 -0
- package/dist/temporal/places/deroule.js +2 -0
- package/dist/temporal/places/deroule.js.map +1 -1
- package/dist/temporal/tickets/activites.js +30 -3
- package/dist/temporal/tickets/activites.js.map +1 -1
- package/docs/ARCHITECTURE.md +37 -10
- package/docs/INTERFACE.md +6 -5
- package/hooks/crochet.mjs +0 -6
- package/package.json +1 -1
- package/scripts/activites.mjs +41 -7
- package/scripts/attente-a-l-arret.mjs +1 -1
- package/scripts/attente-au-tour.mjs +1 -1
- package/scripts/circuit.mjs +10 -2
- package/scripts/enveloppe/enveloppe.mjs +44 -14
- package/scripts/enveloppe/lancer.sh +5 -1
- package/scripts/enveloppe/paquets-du-plan.mjs +3 -0
- package/scripts/file-des-tickets.d.mts +23 -1
- package/scripts/file-des-tickets.mjs +94 -3
- package/scripts/flux-des-paquets.mjs +22 -8
- package/scripts/gabarit-absent.mjs +30 -0
- package/scripts/grillhouse-maj.mjs +77 -1
- package/scripts/groupe-cles.d.mts +25 -0
- package/scripts/groupe-cles.mjs +73 -0
- package/scripts/integration/file.mjs +30 -5
- package/scripts/jointure.d.ts +11 -0
- package/scripts/langages/cargo/index.mjs +3 -2
- package/scripts/langages/cargo/mise-a-jour.mjs +17 -0
- package/scripts/langages/python/index.mjs +3 -1
- package/scripts/langages/python/mise-a-jour.mjs +22 -5
- package/scripts/langages/typescript/mise-a-jour.mjs +8 -20
- package/scripts/mesure/base-de-passe.mjs +7 -0
- package/scripts/migrations/0.35.0-greffon-mattpocock-retire.mjs +41 -0
- package/scripts/migrations.mjs +2 -0
- package/scripts/places-de-la-machine.mjs +15 -5
- package/scripts/places-du-serveur.mjs +12 -2
- package/scripts/regles-des-places.d.mts +7 -0
- package/scripts/regles-des-places.mjs +46 -4
- package/scripts/seances.mjs +24 -2
- package/scripts/services-du-noyau.mjs +2 -1
- package/scripts/sigle-du-projet.mjs +49 -0
- package/scripts/superviseur.mjs +37 -19
- package/scripts/tableau.mjs +115 -15
- package/scripts/verrous/verrou.mjs +7 -0
- package/skills/codebase-design/DEEPENING.md +37 -0
- package/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
- package/skills/codebase-design/SKILL.md +114 -0
- package/skills/domain-modeling/ADR-FORMAT.md +47 -0
- package/skills/domain-modeling/GLOSSARY-FORMAT.md +60 -0
- package/skills/domain-modeling/SKILL.md +74 -0
- package/skills/grill/SKILL.md +4 -5
- package/skills/grilling/SKILL.md +30 -0
- package/skills/pitmaster/SKILL.md +4 -3
- package/skills/pitmaster/references/cadre.md +1 -1
- package/skills/redacteur/SKILL.md +1 -1
- package/skills/testwriter/SKILL.md +7 -4
- package/skills/writing-for-agents/SKILL-MECHANICS.md +22 -0
- package/skills/writing-for-agents/SKILL.md +81 -0
package/scripts/tableau.mjs
CHANGED
|
@@ -129,8 +129,14 @@ import {
|
|
|
129
129
|
circuitsDuServeur,
|
|
130
130
|
nuitDuServeur,
|
|
131
131
|
} from './circuits-du-serveur.mjs';
|
|
132
|
-
import {
|
|
132
|
+
import {
|
|
133
|
+
attendDeLAutreProjet,
|
|
134
|
+
enFileSansArchitecture,
|
|
135
|
+
lireLesExternes,
|
|
136
|
+
} from './file-des-tickets.mjs';
|
|
133
137
|
import { etatDesPlaces } from './places-de-la-machine.mjs';
|
|
138
|
+
import { prefixe as prefixeDeLaRacine } from './prefixe-des-tickets.mjs';
|
|
139
|
+
import { sigleDuProjet } from './sigle-du-projet.mjs';
|
|
134
140
|
import { vivant } from './mesure/base-de-passe.mjs';
|
|
135
141
|
|
|
136
142
|
const MINUTE = 60_000;
|
|
@@ -807,11 +813,12 @@ export function lecture(t, prefix) {
|
|
|
807
813
|
* other fault of that reading, said in the first alert as it is; `echecPrefixe`, the cause of a
|
|
808
814
|
* ticket prefix that did not read, named in an alert; `voies`, the way of each circuit done
|
|
809
815
|
* (`voiesDesCircuits`), whose sign FAITS AUJOURD'HUI shows.
|
|
810
|
-
* @param {{ tous: any[], prefix?: string, registre: any[], vivants: any[],
|
|
811
|
-
* maintenant: number, jour: number,
|
|
816
|
+
* @param {{ tous: any[], prefix?: string, racine?: string | null, registre: any[], vivants: any[],
|
|
817
|
+
* circuits?: any[], maintenant: number, jour: number,
|
|
812
818
|
* machine?: Machine | null, outil?: { version: string, raison: string } | null,
|
|
813
819
|
* places?: { prises: number, plafond: number, faute?: string | null, charge: number,
|
|
814
|
-
* coeurs: number, memoireGo: number, memoireTotaleGo: number,
|
|
820
|
+
* coeurs: number, memoireGo: number, memoireTotaleGo: number,
|
|
821
|
+
* tenues?: { ticket: string | null, racine?: string | null }[], attentes: { ticket: string,
|
|
815
822
|
* depuis: number, disque?: string | null }[] } | null,
|
|
816
823
|
* nuit?: { racine: string, depuis: number | null } | null, muet?: boolean, faute?: string | null,
|
|
817
824
|
* echecPrefixe?: string | null, voies?: Record<string, 'complet' | 'court'> }} lu
|
|
@@ -819,6 +826,7 @@ export function lecture(t, prefix) {
|
|
|
819
826
|
export function assembler({
|
|
820
827
|
tous,
|
|
821
828
|
prefix = '',
|
|
829
|
+
racine = null,
|
|
822
830
|
registre: lignesDuRegistre,
|
|
823
831
|
vivants,
|
|
824
832
|
circuits = [],
|
|
@@ -835,6 +843,7 @@ export function assembler({
|
|
|
835
843
|
attenteVivante: attenteQuiVit = true,
|
|
836
844
|
voies = {},
|
|
837
845
|
superviseur = {},
|
|
846
|
+
externes,
|
|
838
847
|
}) {
|
|
839
848
|
// A circuit's lines are its steps, no agent's passage.
|
|
840
849
|
const etapesFinies = lignesDuRegistre.filter(r => r.role === ROLE_DU_CIRCUIT);
|
|
@@ -858,7 +867,13 @@ export function assembler({
|
|
|
858
867
|
// Ready: open, every ticket that blocks it closed (Beads' own rule, without a second call).
|
|
859
868
|
const blocages = t =>
|
|
860
869
|
(t.dependencies ?? []).filter(d => d.type === 'blocks' && ouvert(d.depends_on_id));
|
|
861
|
-
|
|
870
|
+
// What a ticket waits for from another project, « <project>:<capability> » (the capability not
|
|
871
|
+
// delivered by the provider, or its project not resolved: `externes`, the tickets of each other
|
|
872
|
+
// project by its name in Beads' `external_projects`).
|
|
873
|
+
const attentesExternes = t => attendDeLAutreProjet(t, externes).map(a => a.attend);
|
|
874
|
+
const prets = tous.filter(
|
|
875
|
+
t => t.status === 'open' && blocages(t).length === 0 && attentesExternes(t).length === 0
|
|
876
|
+
);
|
|
862
877
|
const aValider = tous.filter(
|
|
863
878
|
t => t.status !== 'closed' && (t.labels ?? []).includes('a-valider')
|
|
864
879
|
);
|
|
@@ -892,7 +907,7 @@ export function assembler({
|
|
|
892
907
|
(!enfants.has(t.id) || t.status === 'in_progress' || actifs.has(t.id) || travailles.has(t.id));
|
|
893
908
|
const pret = new Set(prets.map(t => t.id));
|
|
894
909
|
const avalider = new Set(aValider.map(t => t.id));
|
|
895
|
-
const bloquePar = t => blocages(t).map(d => numero(d.depends_on_id));
|
|
910
|
+
const bloquePar = t => [...blocages(t).map(d => numero(d.depends_on_id)), ...attentesExternes(t)];
|
|
896
911
|
// The owner's go: the label `circuit`, set on his word.
|
|
897
912
|
const circuit = t => (t.labels ?? []).includes('circuit');
|
|
898
913
|
// A ticket's state: done, in progress, deferred, awaiting validation; else, with the owner's go,
|
|
@@ -1360,7 +1375,10 @@ export function assembler({
|
|
|
1360
1375
|
agents: blocs,
|
|
1361
1376
|
maintenant,
|
|
1362
1377
|
machine,
|
|
1363
|
-
places: placesDeLaMachine
|
|
1378
|
+
places: placesDeLaMachine && {
|
|
1379
|
+
...placesDeLaMachine,
|
|
1380
|
+
noms: nommerLesPrises(placesDeLaMachine.tenues ?? [], { racine, prefix }),
|
|
1381
|
+
},
|
|
1364
1382
|
nuit: nuitEnCours,
|
|
1365
1383
|
faitsDuJour,
|
|
1366
1384
|
etats,
|
|
@@ -1498,6 +1516,30 @@ const signeDe = a => a.signe ?? '⚠';
|
|
|
1498
1516
|
// project's prefix, which the line already names, « bp-mono-vbwf.320.11 » → « vbwf.320.11 »,
|
|
1499
1517
|
// « SH-ae6.5 » → « ae6.5 ».
|
|
1500
1518
|
const courtDuTicket = id => id.slice(id.lastIndexOf('-') + 1);
|
|
1519
|
+
|
|
1520
|
+
// Who holds each place of the machine, in the order of the places: the project of the board (the
|
|
1521
|
+
// root <racine> of its main tree, its ticket prefix <prefix>) by the short number of its ticket,
|
|
1522
|
+
// another project by « <sigle> <short number> » (its sigle and its prefix read from its own root),
|
|
1523
|
+
// a place with no ticket « passe »; a place with no root (a state of before) is the board's.
|
|
1524
|
+
function nommerLesPrises(tenues, { racine, prefix }) {
|
|
1525
|
+
return tenues.map(({ ticket, racine: deLaPrise }) => {
|
|
1526
|
+
const ici = !deLaPrise || (racine && path.resolve(deLaPrise) === path.resolve(racine));
|
|
1527
|
+
let prefixeDuProjet = prefix;
|
|
1528
|
+
if (!ici) {
|
|
1529
|
+
try {
|
|
1530
|
+
prefixeDuProjet = prefixeDeLaRacine(deLaPrise);
|
|
1531
|
+
} catch {
|
|
1532
|
+
prefixeDuProjet = '';
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
const numero = !ticket
|
|
1536
|
+
? 'passe'
|
|
1537
|
+
: prefixeDuProjet && ticket.startsWith(`${prefixeDuProjet}-`)
|
|
1538
|
+
? ticket.slice(prefixeDuProjet.length + 1)
|
|
1539
|
+
: courtDuTicket(ticket);
|
|
1540
|
+
return ici ? numero : `${sigleDuProjet(deLaPrise).sigle ?? path.basename(deLaPrise)} ${numero}`;
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1501
1543
|
// The board's lines, `largeur` columns wide, each with its tone (titre, alerte, attention, actif,
|
|
1502
1544
|
// discret, or none), its section (`section`: agents, chantier or faits, in that order) and, for a
|
|
1503
1545
|
// ticket's line, its id (`ticket`), which the pane makes selectable; an epic's line is marked
|
|
@@ -1525,7 +1567,9 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
|
|
|
1525
1567
|
const colonneDe = etiquette => `[${etiquette}]`.padEnd(large);
|
|
1526
1568
|
L(nom.toUpperCase(), TONS.titre);
|
|
1527
1569
|
if (plusieurs) {
|
|
1528
|
-
//
|
|
1570
|
+
// The three lines of states of each project, as one project's board says them: the first
|
|
1571
|
+
// under its label, the two others aligned below it; or the fault that keeps its board out.
|
|
1572
|
+
const retrait = ' '.repeat(large);
|
|
1529
1573
|
for (const p of t.projets) {
|
|
1530
1574
|
if (p.erreur) {
|
|
1531
1575
|
L(cadre(`${colonneDe(p.etiquette)}⚠ ${p.erreur}`, '', largeur), TONS.panne);
|
|
@@ -1534,11 +1578,26 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
|
|
|
1534
1578
|
const c = p.compteurs;
|
|
1535
1579
|
L(
|
|
1536
1580
|
cadre(
|
|
1537
|
-
`${colonneDe(p.etiquette)}▶ ${c.enCours} en cours ·
|
|
1581
|
+
`${colonneDe(p.etiquette)}▶ ${c.enCours} en cours · ${c.bloques ?? 0} bloqués · ${c.fermes} faits`,
|
|
1582
|
+
'',
|
|
1583
|
+
largeur
|
|
1584
|
+
)
|
|
1585
|
+
);
|
|
1586
|
+
L(
|
|
1587
|
+
cadre(
|
|
1588
|
+
`${retrait}⏭ file : ${c.enAttente} en circuit · ${c.fileDirecte ?? 0} en direct`,
|
|
1538
1589
|
'',
|
|
1539
1590
|
largeur
|
|
1540
1591
|
)
|
|
1541
1592
|
);
|
|
1593
|
+
L(
|
|
1594
|
+
cadre(
|
|
1595
|
+
`${retrait}${c.sansGo ?? 0} sans go · ${c.aValider ?? 0} à valider · ${c.reportes ?? 0} reportés`,
|
|
1596
|
+
'',
|
|
1597
|
+
largeur
|
|
1598
|
+
),
|
|
1599
|
+
c.sansGo ? TONS.sansGo : c.aValider ? TONS.aValider : TONS.reportes
|
|
1600
|
+
);
|
|
1542
1601
|
}
|
|
1543
1602
|
// The discoveries of the day, summed across the projects (grillhouse-3uv.96, criterion 14).
|
|
1544
1603
|
const d96 = t.decouvertes ?? { new: 0, check: 0, rejetes: 0, valides: 0 };
|
|
@@ -1608,12 +1667,26 @@ export function lignes(t, nom, largeur = LARGEUR, groupes = {}) {
|
|
|
1608
1667
|
const p = t.places;
|
|
1609
1668
|
if (p) {
|
|
1610
1669
|
const nb = n => (Number.isInteger(n) ? String(n) : n.toFixed(1).replace('.', ','));
|
|
1670
|
+
// Who holds each place stands between the count and the load: the most names that keep the
|
|
1671
|
+
// line within the width, the others counted « +n ».
|
|
1672
|
+
const noms = p.noms ?? [];
|
|
1673
|
+
const suite = p.faute
|
|
1674
|
+
? `plafond refusé : ${p.faute}`
|
|
1675
|
+
: `charge ${nb(p.charge)}/${p.coeurs} · mémoire ${p.memoireGo}/${p.memoireTotaleGo} Go`;
|
|
1676
|
+
const ligne = k =>
|
|
1677
|
+
`Places ${p.prises}/${p.plafond} · ${
|
|
1678
|
+
noms.length
|
|
1679
|
+
? `${[noms.slice(0, k).join(', '), ...(k < noms.length ? [`+${noms.length - k}`] : [])]
|
|
1680
|
+
.filter(Boolean)
|
|
1681
|
+
.join(' ')} · `
|
|
1682
|
+
: ''
|
|
1683
|
+
}${suite}`;
|
|
1684
|
+
let k = noms.length;
|
|
1685
|
+
while (k > 0 && colonnes(ligne(k)) > largeur) {
|
|
1686
|
+
k--;
|
|
1687
|
+
}
|
|
1611
1688
|
poser({
|
|
1612
|
-
texte: cadre(
|
|
1613
|
-
`Places ${p.prises}/${p.plafond} · ${p.faute ? `plafond refusé : ${p.faute}` : `charge ${nb(p.charge)}/${p.coeurs} · mémoire ${p.memoireGo}/${p.memoireTotaleGo} Go`}`,
|
|
1614
|
-
'',
|
|
1615
|
-
largeur
|
|
1616
|
-
),
|
|
1689
|
+
texte: cadre(ligne(k), '', largeur),
|
|
1617
1690
|
ton: p.faute ? TONS.plafondRefuse : p.charge >= p.coeurs ? TONS.machineChargee : TONS.mesure,
|
|
1618
1691
|
});
|
|
1619
1692
|
// A ticket that waits for the disk of its project's copies: what holds it, the ticket named.
|
|
@@ -2372,6 +2445,7 @@ function lire(
|
|
|
2372
2445
|
const t = assembler({
|
|
2373
2446
|
tous,
|
|
2374
2447
|
prefix,
|
|
2448
|
+
racine: commun ? path.dirname(commun) : racine,
|
|
2375
2449
|
registre,
|
|
2376
2450
|
vivants,
|
|
2377
2451
|
circuits,
|
|
@@ -2388,6 +2462,7 @@ function lire(
|
|
|
2388
2462
|
remontees: lireLesRemontees(racine, maintenant),
|
|
2389
2463
|
attenteVivante: attenteVivante(racine),
|
|
2390
2464
|
superviseur,
|
|
2465
|
+
externes: lireLesExternes(racine, tous),
|
|
2391
2466
|
});
|
|
2392
2467
|
return { t, prefix, tous, vivants, commun };
|
|
2393
2468
|
}
|
|
@@ -2556,7 +2631,32 @@ export async function tableau(
|
|
|
2556
2631
|
}),
|
|
2557
2632
|
};
|
|
2558
2633
|
const lus = [ici, ...autres];
|
|
2559
|
-
|
|
2634
|
+
// A project is labelled by its sigle (scripts/sigle-du-projet.mjs: the key `grillhouse.sigle`, else
|
|
2635
|
+
// its ticket prefix), as the line of the places names it; a project with neither keeps its
|
|
2636
|
+
// folder's name. A faulty key is said in an alert, the prefix staying the sigle; two projects of
|
|
2637
|
+
// the board with one sigle are said, both named.
|
|
2638
|
+
const sigles = new Map(lus.map(l => [l, sigleDuProjet(l.dossier)]));
|
|
2639
|
+
const etiquette = l => sigles.get(l).sigle || l.prefix || path.basename(l.dossier);
|
|
2640
|
+
const alerteDeSigle = (l, texte) =>
|
|
2641
|
+
(l.t ?? ici.t).alertes.push({ etat: 'panne', ton: TONS.panne, texte });
|
|
2642
|
+
for (const l of lus) {
|
|
2643
|
+
const { faute } = sigles.get(l);
|
|
2644
|
+
if (faute) {
|
|
2645
|
+
alerteDeSigle(l, `Sigle illisible : ${faute}`);
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
const memeSigle = new Map();
|
|
2649
|
+
for (const l of lus) {
|
|
2650
|
+
memeSigle.set(etiquette(l), [...(memeSigle.get(etiquette(l)) ?? []), l]);
|
|
2651
|
+
}
|
|
2652
|
+
for (const [sigle, deux] of memeSigle) {
|
|
2653
|
+
if (deux.length > 1) {
|
|
2654
|
+
alerteDeSigle(
|
|
2655
|
+
ici,
|
|
2656
|
+
`Sigle « ${sigle} » porté par ${deux.map(l => path.basename(l.dossier)).join(' et ')}`
|
|
2657
|
+
);
|
|
2658
|
+
}
|
|
2659
|
+
}
|
|
2560
2660
|
// The lock of the machine names each project of the board as the board does: the session's by
|
|
2561
2661
|
// its folder, another by its label; the root of its main tree, its common git directory's parent.
|
|
2562
2662
|
ici.t.machine = nommerLesProjets(
|
|
@@ -40,6 +40,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
40
40
|
import {
|
|
41
41
|
ecritsDuPlan,
|
|
42
42
|
MARQUE_HORS_PLAN,
|
|
43
|
+
MARQUE_HORS_PLAN_FAIT,
|
|
43
44
|
paquetQuiTient,
|
|
44
45
|
paquetsDeLEnveloppe,
|
|
45
46
|
paquetsDuLangage,
|
|
@@ -125,6 +126,8 @@ export function horsDuPlan(input, { tmp = tmpdir(), env = process.env, role = nu
|
|
|
125
126
|
const paquet = tenant === '.' ? 'la racine du dépôt' : tenant;
|
|
126
127
|
return {
|
|
127
128
|
paquet,
|
|
129
|
+
chemin: rel,
|
|
130
|
+
racine: tenant === '.',
|
|
128
131
|
raison: `⛔ hors-plan — ${rel} est dans ${paquet}, hors des paquets du plan (${plan.join(', ')}) : ta séance s'arrête là, et le superviseur étend le plan ou refuse l'écriture.`,
|
|
129
132
|
};
|
|
130
133
|
}
|
|
@@ -267,6 +270,10 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
|
267
270
|
// The mark for the circuit; the stop below is the hook's answer, mark or not.
|
|
268
271
|
try {
|
|
269
272
|
writeFileSync(path.join(tmpdir(), MARQUE_HORS_PLAN), stop.raison);
|
|
273
|
+
writeFileSync(
|
|
274
|
+
path.join(tmpdir(), MARQUE_HORS_PLAN_FAIT),
|
|
275
|
+
JSON.stringify({ chemin: stop.chemin, paquet: stop.paquet, racine: stop.racine })
|
|
276
|
+
);
|
|
270
277
|
} catch {
|
|
271
278
|
// A working directory gone leaves no mark; the session still stops.
|
|
272
279
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Deepening
|
|
2
|
+
|
|
3
|
+
How to deepen a cluster of shallow modules safely, given its dependencies. Assumes the vocabulary in [SKILL.md](SKILL.md): **module**, **interface**, **seam**, **adapter**.
|
|
4
|
+
|
|
5
|
+
## Dependency categories
|
|
6
|
+
|
|
7
|
+
When assessing a candidate for deepening, classify its dependencies. The category determines how the deepened module is tested across its seam.
|
|
8
|
+
|
|
9
|
+
### 1. In-process
|
|
10
|
+
|
|
11
|
+
Pure computation, in-memory state, no I/O. Always deepenable: merge the modules and test through the new interface directly. No adapter needed.
|
|
12
|
+
|
|
13
|
+
### 2. Local-substitutable
|
|
14
|
+
|
|
15
|
+
Dependencies that have local test stand-ins (PGLite for Postgres, in-memory filesystem). Deepenable if the stand-in exists. The deepened module is tested with the stand-in running in the test suite. The seam is internal; no port at the module's external interface.
|
|
16
|
+
|
|
17
|
+
### 3. Remote but owned (Ports & Adapters)
|
|
18
|
+
|
|
19
|
+
Your own services across a network boundary (microservices, internal APIs). Define a **port** (interface) at the seam. The deep module owns the logic; the transport is injected as an **adapter**. Tests use an in-memory adapter. Production uses an HTTP/gRPC/queue adapter.
|
|
20
|
+
|
|
21
|
+
Recommendation shape: _"Define a port at the seam, implement an HTTP adapter for production and an in-memory adapter for testing, so the logic sits in one deep module even though it's deployed across a network."_
|
|
22
|
+
|
|
23
|
+
### 4. True external (Mock)
|
|
24
|
+
|
|
25
|
+
Third-party services (Stripe, Twilio, etc.) you don't control. The deepened module takes the external dependency as an injected port; tests provide a mock adapter.
|
|
26
|
+
|
|
27
|
+
## Seam discipline
|
|
28
|
+
|
|
29
|
+
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a port unless at least two adapters are justified (typically production + test). A single-adapter seam is just indirection.
|
|
30
|
+
- **Internal seams vs external seams.** A deep module can have internal seams (private to its implementation, used by its own tests) as well as the external seam at its interface. Don't expose internal seams through the interface just because tests use them.
|
|
31
|
+
|
|
32
|
+
## Testing strategy: replace, don't layer
|
|
33
|
+
|
|
34
|
+
- Old unit tests on shallow modules become waste once tests at the deepened module's interface exist; delete them.
|
|
35
|
+
- Write new tests at the deepened module's interface. The **interface is the test surface**.
|
|
36
|
+
- Tests assert on observable outcomes through the interface, not internal state.
|
|
37
|
+
- Tests should survive internal refactors, since they describe behaviour, not implementation. If a test has to change when the implementation changes, it's testing past the interface.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Design It Twice
|
|
2
|
+
|
|
3
|
+
When the user wants to explore alternative interfaces for a chosen deepening candidate, use this parallel sub-agent pattern. Based on "Design It Twice" (Ousterhout): your first idea is unlikely to be the best.
|
|
4
|
+
|
|
5
|
+
Uses the vocabulary in [SKILL.md](SKILL.md): **module**, **interface**, **seam**, **adapter**, **leverage**.
|
|
6
|
+
|
|
7
|
+
## Process
|
|
8
|
+
|
|
9
|
+
### 1. Frame the problem space
|
|
10
|
+
|
|
11
|
+
Before spawning sub-agents, write a user-facing explanation of the problem space for the chosen candidate:
|
|
12
|
+
|
|
13
|
+
- The constraints any new interface would need to satisfy
|
|
14
|
+
- The dependencies it would rely on, and which category they fall into (see [DEEPENING.md](DEEPENING.md))
|
|
15
|
+
- A rough illustrative code sketch to ground the constraints, not a proposal, just a way to make the constraints concrete
|
|
16
|
+
|
|
17
|
+
Show this to the user, then immediately proceed to Step 2. The user reads and thinks while the sub-agents work in parallel.
|
|
18
|
+
|
|
19
|
+
### 2. Spawn sub-agents
|
|
20
|
+
|
|
21
|
+
Spawn 3+ sub-agents in parallel. Each must produce a **radically different** interface for the deepened module.
|
|
22
|
+
|
|
23
|
+
Prompt each sub-agent with a separate technical brief (file paths, coupling details, dependency category from [DEEPENING.md](DEEPENING.md), what sits behind the seam). The brief is independent of the user-facing problem-space explanation in Step 1. Give each agent a different design constraint:
|
|
24
|
+
|
|
25
|
+
- Agent 1: "Minimize the interface: aim for 1–3 entry points max. Maximise leverage per entry point."
|
|
26
|
+
- Agent 2: "Maximise flexibility: support many use cases and extension."
|
|
27
|
+
- Agent 3: "Optimise for the most common caller: make the default case trivial."
|
|
28
|
+
- Agent 4 (if applicable): "Design around ports & adapters for cross-seam dependencies."
|
|
29
|
+
|
|
30
|
+
Include both [SKILL.md](SKILL.md) vocabulary and GLOSSARY.md vocabulary in the brief so each sub-agent names things consistently with the architecture language and the project's domain language.
|
|
31
|
+
|
|
32
|
+
Each sub-agent outputs:
|
|
33
|
+
|
|
34
|
+
1. Interface (types, methods, params, plus invariants, ordering, error modes)
|
|
35
|
+
2. Usage example showing how callers use it
|
|
36
|
+
3. What the implementation hides behind the seam
|
|
37
|
+
4. Dependency strategy and adapters (see [DEEPENING.md](DEEPENING.md))
|
|
38
|
+
5. Trade-offs: where leverage is high, where it's thin
|
|
39
|
+
|
|
40
|
+
### 3. Present and compare
|
|
41
|
+
|
|
42
|
+
Present designs sequentially so the user can absorb each one, then compare them in prose. Contrast by **depth** (leverage at the interface), **locality** (where change concentrates), and **seam placement**.
|
|
43
|
+
|
|
44
|
+
After comparing, give your own recommendation: which design you think is strongest and why. If elements from different designs would combine well, propose a hybrid. Be opinionated: the user wants a strong read, not a menu.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codebase-design
|
|
3
|
+
description: Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Codebase Design
|
|
7
|
+
|
|
8
|
+
Design **deep modules**: a lot of behaviour behind a small interface, placed at a clean seam, testable through that interface. Use this language and these principles wherever code is being designed or restructured. The aim is leverage for callers, locality for maintainers, and testability for everyone.
|
|
9
|
+
|
|
10
|
+
## Glossary
|
|
11
|
+
|
|
12
|
+
Use these terms exactly: don't substitute "component," "service," "API," or "boundary." Consistent language is the whole point.
|
|
13
|
+
|
|
14
|
+
**Module**: anything with an interface and an implementation. Deliberately scale-agnostic: a function, class, package, or tier-spanning slice. _Avoid_: unit, component, service.
|
|
15
|
+
|
|
16
|
+
**Interface**: everything a caller must know to use the module correctly: the type signature, but also invariants, ordering constraints, error modes, required configuration, and performance characteristics. _Avoid_: API, signature (too narrow, they refer only to the type-level surface).
|
|
17
|
+
|
|
18
|
+
**Implementation**: what's inside a module, its body of code. Distinct from **Adapter**: a thing can be a small adapter with a large implementation (a Postgres repo) or a large adapter with a small implementation (an in-memory fake). Reach for "adapter" when the seam is the topic; "implementation" otherwise.
|
|
19
|
+
|
|
20
|
+
**Depth**: leverage at the interface. The amount of behaviour a caller (or test) can exercise per unit of interface they have to learn. A module is **deep** when a large amount of behaviour sits behind a small interface, **shallow** when the interface is nearly as complex as the implementation.
|
|
21
|
+
|
|
22
|
+
**Seam** _(Michael Feathers)_: a place where you can alter behaviour without editing in that place; the _location_ at which a module's interface lives. Where to put the seam is its own design decision, distinct from what goes behind it. _Avoid_: boundary (overloaded with DDD's bounded context).
|
|
23
|
+
|
|
24
|
+
**Adapter**: a concrete thing that satisfies an interface at a seam. Describes _role_ (what slot it fills), not substance (what's inside).
|
|
25
|
+
|
|
26
|
+
**Leverage**: what callers get from depth. More capability per unit of interface they learn. One implementation pays back across N call sites and M tests.
|
|
27
|
+
|
|
28
|
+
**Locality**: what maintainers get from depth. Change, bugs, knowledge, and verification concentrate in one place rather than spreading across callers. Fix once, fixed everywhere.
|
|
29
|
+
|
|
30
|
+
## Deep vs shallow
|
|
31
|
+
|
|
32
|
+
**Deep module** = small interface + lots of implementation:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
┌─────────────────────┐
|
|
36
|
+
│ Small Interface │ ← Few methods, simple params
|
|
37
|
+
├─────────────────────┤
|
|
38
|
+
│ │
|
|
39
|
+
│ Deep Implementation│ ← Complex logic hidden
|
|
40
|
+
│ │
|
|
41
|
+
└─────────────────────┘
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Shallow module** = large interface + little implementation (avoid):
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
┌─────────────────────────────────┐
|
|
48
|
+
│ Large Interface │ ← Many methods, complex params
|
|
49
|
+
├─────────────────────────────────┤
|
|
50
|
+
│ Thin Implementation │ ← Just passes through
|
|
51
|
+
└─────────────────────────────────┘
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
When designing an interface, ask:
|
|
55
|
+
|
|
56
|
+
- Can I reduce the number of methods?
|
|
57
|
+
- Can I simplify the parameters?
|
|
58
|
+
- Can I hide more complexity inside?
|
|
59
|
+
|
|
60
|
+
## Principles
|
|
61
|
+
|
|
62
|
+
- **Depth is a property of the interface, not the implementation.** A deep module can be internally composed of small, mockable, swappable parts; they just aren't part of the interface. A module can have **internal seams** (private to its implementation, used by its own tests) as well as the **external seam** at its interface.
|
|
63
|
+
- **The deletion test.** Imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.
|
|
64
|
+
- **The interface is the test surface.** Callers and tests cross the same seam. If you want to test _past_ the interface, the module is probably the wrong shape.
|
|
65
|
+
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a seam unless something actually varies across it.
|
|
66
|
+
|
|
67
|
+
## Designing for testability
|
|
68
|
+
|
|
69
|
+
Good interfaces make testing natural:
|
|
70
|
+
|
|
71
|
+
1. **Accept dependencies, don't create them.**
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
// Testable
|
|
75
|
+
function processOrder(order, paymentGateway) {}
|
|
76
|
+
|
|
77
|
+
// Hard to test
|
|
78
|
+
function processOrder(order) {
|
|
79
|
+
const gateway = new StripeGateway();
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
2. **Return results, don't produce side effects.**
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// Testable
|
|
87
|
+
function calculateDiscount(cart): Discount {}
|
|
88
|
+
|
|
89
|
+
// Hard to test
|
|
90
|
+
function applyDiscount(cart): void {
|
|
91
|
+
cart.total -= discount;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
3. **Small surface area.** Fewer methods = fewer tests needed. Fewer params = simpler test setup.
|
|
96
|
+
|
|
97
|
+
## Relationships
|
|
98
|
+
|
|
99
|
+
- A **Module** has exactly one **Interface** (the surface it presents to callers and tests).
|
|
100
|
+
- **Depth** is a property of a **Module**, measured against its **Interface**.
|
|
101
|
+
- A **Seam** is where a **Module**'s **Interface** lives.
|
|
102
|
+
- An **Adapter** sits at a **Seam** and satisfies the **Interface**.
|
|
103
|
+
- **Depth** produces **Leverage** for callers and **Locality** for maintainers.
|
|
104
|
+
|
|
105
|
+
## Rejected framings
|
|
106
|
+
|
|
107
|
+
- **Depth as ratio of implementation-lines to interface-lines** (Ousterhout): rewards padding the implementation. We use depth-as-leverage instead.
|
|
108
|
+
- **"Interface" as the TypeScript `interface` keyword or a class's public methods**: too narrow: interface here includes every fact a caller must know.
|
|
109
|
+
- **"Boundary"**: overloaded with DDD's bounded context. Say **seam** or **interface**.
|
|
110
|
+
|
|
111
|
+
## Going deeper
|
|
112
|
+
|
|
113
|
+
- **Deepening a cluster given its dependencies**, see [DEEPENING.md](DEEPENING.md): dependency categories, seam discipline, and replace-don't-layer testing.
|
|
114
|
+
- **Exploring alternative interfaces**, see [DESIGN-IT-TWICE.md](DESIGN-IT-TWICE.md): spin up parallel sub-agents to design the interface several radically different ways, then compare on depth, locality, and seam placement.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# ADR Format
|
|
2
|
+
|
|
3
|
+
ADRs live in `docs/adr/` and use sequential numbering: `0001-slug.md`, `0002-slug.md`, etc.
|
|
4
|
+
|
|
5
|
+
Create the `docs/adr/` directory lazily: only when the first ADR is needed.
|
|
6
|
+
|
|
7
|
+
## Template
|
|
8
|
+
|
|
9
|
+
```md
|
|
10
|
+
# {Short title of the decision}
|
|
11
|
+
|
|
12
|
+
{1-3 sentences: what's the context, what did we decide, and why.}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
That's it. An ADR can be a single paragraph. The value is in recording _that_ a decision was made and _why_, not in filling out sections.
|
|
16
|
+
|
|
17
|
+
## Optional sections
|
|
18
|
+
|
|
19
|
+
Only include these when they add genuine value. Most ADRs won't need them.
|
|
20
|
+
|
|
21
|
+
- **Status** frontmatter (`proposed | accepted | deprecated | superseded by ADR-NNNN`): useful when decisions are revisited
|
|
22
|
+
- **Considered Options**: only when the rejected alternatives are worth remembering
|
|
23
|
+
- **Consequences**: only when non-obvious downstream effects need to be called out
|
|
24
|
+
|
|
25
|
+
## Numbering
|
|
26
|
+
|
|
27
|
+
Scan `docs/adr/` for the highest existing number and increment by one.
|
|
28
|
+
|
|
29
|
+
## When to offer an ADR
|
|
30
|
+
|
|
31
|
+
All three of these must be true:
|
|
32
|
+
|
|
33
|
+
1. **Hard to reverse**: the cost of changing your mind later is meaningful
|
|
34
|
+
2. **Surprising without context**: a future reader will look at the code and wonder "why on earth did they do it this way?"
|
|
35
|
+
3. **The result of a real trade-off**: there were genuine alternatives and you picked one for specific reasons
|
|
36
|
+
|
|
37
|
+
If a decision is easy to reverse, skip it: you'll just reverse it. If it's not surprising, nobody will wonder why. If there was no real alternative, there's nothing to record beyond "we did the obvious thing."
|
|
38
|
+
|
|
39
|
+
### What qualifies
|
|
40
|
+
|
|
41
|
+
- **Architectural shape.** "We're using a monorepo." "The write model is event-sourced, the read model is projected into Postgres."
|
|
42
|
+
- **Integration patterns between contexts.** "Ordering and Billing communicate via domain events, not synchronous HTTP."
|
|
43
|
+
- **Technology choices that carry lock-in.** Database, message bus, auth provider, deployment target. Not every library: just the ones that would take a quarter to swap out.
|
|
44
|
+
- **Boundary and scope decisions.** "Customer data is owned by the Customer context; other contexts reference it by ID only." The explicit no-s are as valuable as the yes-s.
|
|
45
|
+
- **Deliberate deviations from the obvious path.** "We're using manual SQL instead of an ORM because X." Anything where a reasonable reader would assume the opposite. These stop the next engineer from "fixing" something that was deliberate.
|
|
46
|
+
- **Constraints not visible in the code.** "We can't use AWS because of compliance requirements." "Response times must be under 200ms because of the partner API contract."
|
|
47
|
+
- **Rejected alternatives when the rejection is non-obvious.** If you considered GraphQL and picked REST for subtle reasons, record it; otherwise someone will suggest GraphQL again in six months.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# GLOSSARY.md Format
|
|
2
|
+
|
|
3
|
+
## Structure
|
|
4
|
+
|
|
5
|
+
```md
|
|
6
|
+
# {Context Name}
|
|
7
|
+
|
|
8
|
+
{One or two sentence description of what this context is and why it exists.}
|
|
9
|
+
|
|
10
|
+
## Language
|
|
11
|
+
|
|
12
|
+
**Order**:
|
|
13
|
+
{A one or two sentence description of the term}
|
|
14
|
+
_Avoid_: Purchase, transaction
|
|
15
|
+
|
|
16
|
+
**Invoice**:
|
|
17
|
+
A request for payment sent to a customer after delivery.
|
|
18
|
+
_Avoid_: Bill, payment request
|
|
19
|
+
|
|
20
|
+
**Customer**:
|
|
21
|
+
A person or organization that places orders.
|
|
22
|
+
_Avoid_: Client, buyer, account
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Rules
|
|
26
|
+
|
|
27
|
+
- **Be opinionated.** When multiple words exist for the same concept, pick the best one and list the others under `_Avoid_`.
|
|
28
|
+
- **Keep definitions tight.** One or two sentences max. Define what it IS, not what it does.
|
|
29
|
+
- **Only include terms specific to this project's context.** General programming concepts (timeouts, error types, utility patterns) don't belong even if the project uses them extensively. Before adding a term, ask: is this a concept unique to this context, or a general programming concept? Only the former belongs.
|
|
30
|
+
- **Group terms under subheadings** when natural clusters emerge. If all terms belong to a single cohesive area, a flat list is fine.
|
|
31
|
+
|
|
32
|
+
## Single vs multi-context repos
|
|
33
|
+
|
|
34
|
+
**Single context (most repos):** One `GLOSSARY.md` at the repo root.
|
|
35
|
+
|
|
36
|
+
**Multiple contexts:** A `GLOSSARY-MAP.md` at the repo root lists the contexts, where they live, and how they relate to each other:
|
|
37
|
+
|
|
38
|
+
```md
|
|
39
|
+
# Glossary Map
|
|
40
|
+
|
|
41
|
+
## Contexts
|
|
42
|
+
|
|
43
|
+
- [Ordering](./src/ordering/GLOSSARY.md): receives and tracks customer orders
|
|
44
|
+
- [Billing](./src/billing/GLOSSARY.md): generates invoices and processes payments
|
|
45
|
+
- [Fulfillment](./src/fulfillment/GLOSSARY.md): manages warehouse picking and shipping
|
|
46
|
+
|
|
47
|
+
## Relationships
|
|
48
|
+
|
|
49
|
+
- **Ordering → Fulfillment**: Ordering emits `OrderPlaced` events; Fulfillment consumes them to start picking
|
|
50
|
+
- **Fulfillment → Billing**: Fulfillment emits `ShipmentDispatched` events; Billing consumes them to generate invoices
|
|
51
|
+
- **Ordering ↔ Billing**: Shared types for `CustomerId` and `Money`
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The skill infers which structure applies:
|
|
55
|
+
|
|
56
|
+
- If `GLOSSARY-MAP.md` exists, read it to find contexts
|
|
57
|
+
- If only a root `GLOSSARY.md` exists, single context
|
|
58
|
+
- If neither exists, create a root `GLOSSARY.md` lazily when the first term is resolved
|
|
59
|
+
|
|
60
|
+
When multiple contexts exist, infer which one the current topic relates to. If unclear, ask.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: domain-modeling
|
|
3
|
+
description: Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Domain Modeling
|
|
7
|
+
|
|
8
|
+
Actively build and sharpen the project's domain model as you design. This is the _active_ discipline: challenging terms, inventing edge-case scenarios, and writing the glossary and decisions down the moment they crystallise. (Merely _reading_ `GLOSSARY.md` for vocabulary is not this skill: that's a one-line habit any skill can do. This skill is for when you're changing the model, not just consuming it.)
|
|
9
|
+
|
|
10
|
+
## File structure
|
|
11
|
+
|
|
12
|
+
Most repos have a single context:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
/
|
|
16
|
+
├── GLOSSARY.md
|
|
17
|
+
├── docs/
|
|
18
|
+
│ └── adr/
|
|
19
|
+
│ ├── 0001-event-sourced-orders.md
|
|
20
|
+
│ └── 0002-postgres-for-write-model.md
|
|
21
|
+
└── src/
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
If a `GLOSSARY-MAP.md` exists at the root, the repo has multiple contexts. The map points to where each one lives:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
/
|
|
28
|
+
├── GLOSSARY-MAP.md
|
|
29
|
+
├── docs/
|
|
30
|
+
│ └── adr/ ← system-wide decisions
|
|
31
|
+
├── src/
|
|
32
|
+
│ ├── ordering/
|
|
33
|
+
│ │ ├── GLOSSARY.md
|
|
34
|
+
│ │ └── docs/adr/ ← context-specific decisions
|
|
35
|
+
│ └── billing/
|
|
36
|
+
│ ├── GLOSSARY.md
|
|
37
|
+
│ └── docs/adr/
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Create files lazily: only when you have something to write. If no `GLOSSARY.md` exists, create one when the first term is resolved. If no `docs/adr/` exists, create it when the first ADR is needed.
|
|
41
|
+
|
|
42
|
+
## During the session
|
|
43
|
+
|
|
44
|
+
### Challenge against the glossary
|
|
45
|
+
|
|
46
|
+
When the user uses a term that conflicts with the existing language in `GLOSSARY.md`, call it out immediately. "Your glossary defines 'cancellation' as X, but you seem to mean Y. Which is it?"
|
|
47
|
+
|
|
48
|
+
### Sharpen fuzzy language
|
|
49
|
+
|
|
50
|
+
When the user uses vague or overloaded terms, propose a precise canonical term. "You're saying 'account': do you mean the Customer or the User? Those are different things."
|
|
51
|
+
|
|
52
|
+
### Discuss concrete scenarios
|
|
53
|
+
|
|
54
|
+
When domain relationships are being discussed, stress-test them with specific scenarios. Invent scenarios that probe edge cases and force the user to be precise about the boundaries between concepts.
|
|
55
|
+
|
|
56
|
+
### Cross-reference with code
|
|
57
|
+
|
|
58
|
+
When the user states how something works, check whether the code agrees. If you find a contradiction, surface it: "Your code cancels entire Orders, but you just said partial cancellation is possible. Which is right?"
|
|
59
|
+
|
|
60
|
+
### Update GLOSSARY.md inline
|
|
61
|
+
|
|
62
|
+
When a term is resolved, update `GLOSSARY.md` right there. Don't batch these up: capture them as they happen. Use the format in [GLOSSARY-FORMAT.md](./GLOSSARY-FORMAT.md).
|
|
63
|
+
|
|
64
|
+
`GLOSSARY.md` should be totally devoid of implementation details. Do not treat `GLOSSARY.md` as a spec, a scratch pad, or a repository for implementation decisions. It is a glossary and nothing else.
|
|
65
|
+
|
|
66
|
+
### Offer ADRs sparingly
|
|
67
|
+
|
|
68
|
+
Only offer to create an ADR when all three are true:
|
|
69
|
+
|
|
70
|
+
1. **Hard to reverse**: the cost of changing your mind later is meaningful
|
|
71
|
+
2. **Surprising without context**: a future reader will wonder "why did they do it this way?"
|
|
72
|
+
3. **The result of a real trade-off**: there were genuine alternatives and you picked one for specific reasons
|
|
73
|
+
|
|
74
|
+
If any of the three is missing, skip the ADR. Use the format in [ADR-FORMAT.md](./ADR-FORMAT.md).
|