@roomi-fields/grillhouse 0.50.3 → 0.51.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 +48 -0
- package/agents/developpeur.md +1 -1
- package/agents/direct.md +1 -1
- package/agents/explorateur.md +1 -1
- package/agents/questionneur.md +1 -1
- package/agents/relecteur.md +1 -1
- package/agents/testwriter.md +1 -1
- package/cadre/templates/c/package.json +1 -0
- package/cadre/templates/cargo/package.json +1 -0
- package/cadre/templates/python/package.json +1 -0
- package/charte.md +17 -12
- package/dist/machine/part-par-sorte.d.ts +16 -0
- package/dist/machine/part-par-sorte.js +36 -0
- package/dist/machine/part-par-sorte.js.map +1 -0
- package/dist/temporal/circuit/appel.js +1 -1
- package/dist/temporal/circuit/appel.js.map +1 -1
- package/dist/temporal/circuit/client.d.ts +5 -4
- package/dist/temporal/circuit/client.js +39 -16
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/circuit/contrat.d.ts +11 -7
- package/dist/temporal/circuit/contrat.js +5 -9
- package/dist/temporal/circuit/contrat.js.map +1 -1
- package/dist/temporal/circuit/deroule.js +18 -6
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/commande.js +12 -3
- package/dist/temporal/commande.js.map +1 -1
- package/dist/temporal/installation.d.ts +54 -3
- package/dist/temporal/installation.js +187 -17
- package/dist/temporal/installation.js.map +1 -1
- package/dist/temporal/places/client.d.ts +5 -1
- package/dist/temporal/places/client.js +23 -11
- package/dist/temporal/places/client.js.map +1 -1
- package/docs/ARCHITECTURE.md +23 -2700
- package/docs/INTERFACE.md +23 -8
- package/docs/architecture/circuit.md +59 -12
- package/docs/architecture/entree.md +20 -7
- package/docs/architecture/greffon.md +6 -2
- package/docs/architecture/installation.md +30 -11
- package/docs/architecture/machine.md +50 -37
- package/docs/architecture/tests.md +52 -14
- package/docs/lexique.md +154 -0
- package/hooks/register.tsx +1 -1
- package/package.json +1 -1
- package/scripts/activites.mjs +85 -60
- package/scripts/aiguillage.mjs +15 -7
- package/scripts/attente-de-la-machine.mjs +4 -8
- package/scripts/avancement.mjs +12 -8
- package/scripts/bilan.mjs +10 -7
- package/scripts/branche-de-nuit.mjs +2 -2
- package/scripts/ci-de-main.mjs +18 -21
- package/scripts/circuit.mjs +86 -43
- package/scripts/circuits-du-serveur.mjs +5 -5
- package/scripts/composants-affectes.mjs +30 -12
- package/scripts/composition-des-langages.mjs +5 -3
- package/scripts/conformite.mjs +1 -1
- package/scripts/consommation-des-passes.mjs +8 -6
- package/scripts/copies-finies.mjs +3 -14
- package/scripts/depart-du-ticket.d.mts +8 -2
- package/scripts/depart-du-ticket.mjs +26 -8
- package/scripts/direct.mjs +158 -72
- package/scripts/droits.mjs +63 -185
- package/scripts/engendres.mjs +3 -14
- package/scripts/enveloppe/enveloppe.mjs +75 -30
- package/scripts/enveloppe/lancer.sh +59 -45
- package/scripts/enveloppe/paquets-du-plan.mjs +38 -11
- package/scripts/enveloppe/travail-de-la-copie.mjs +115 -3
- package/scripts/etapes.mjs +84 -22
- package/scripts/faits-du-circuit.mjs +8 -2
- package/scripts/grillhouse-maj.mjs +43 -18
- package/scripts/groupe-cles.d.mts +15 -0
- package/scripts/groupe-cles.mjs +77 -2
- package/scripts/init.mjs +9 -2
- package/scripts/integration/rejeu.mjs +8 -1
- package/scripts/jointure.d.ts +22 -3
- package/scripts/langages/c/index.mjs +5 -2
- package/scripts/langages/cargo/commandes.mjs +35 -15
- package/scripts/langages/cargo/composants.mjs +45 -3
- package/scripts/langages/cargo/index.mjs +6 -3
- package/scripts/langages/python/index.mjs +5 -2
- package/scripts/langages/typescript/chemins-des-tests.mjs +1 -1
- package/scripts/langages/typescript/index.mjs +4 -2
- package/scripts/langages/typescript/mise-a-jour.mjs +1 -1
- package/scripts/langages/typescript/rapports-aux-lignes.mjs +74 -0
- package/scripts/langages/typescript/turbo-des-paquets.mjs +99 -36
- package/scripts/langages/typescript/verdict.mjs +29 -3
- package/scripts/langages/typescript/verifier.mjs +1 -1
- package/scripts/langages/typescript/vitest-config/changements.mjs +8 -6
- package/scripts/langages/typescript/vitest-config/lances.mjs +15 -32
- package/scripts/langages.mjs +54 -4
- package/scripts/matieres-lues.mjs +1 -1
- package/scripts/mesure/base-de-passe.mjs +32 -90
- package/scripts/migrations/serveurs-de-l-index.mjs +79 -0
- package/scripts/migrations.mjs +21 -7
- package/scripts/paquets.d.ts +3 -0
- package/scripts/paquets.mjs +88 -1
- package/scripts/passe-de-la-machine.mjs +109 -36
- package/scripts/places-de-la-machine.mjs +81 -29
- package/scripts/plafond-de-la-machine.d.mts +2 -5
- package/scripts/plafond-de-la-machine.mjs +9 -9
- package/scripts/reprise.mjs +42 -13
- package/scripts/resultats.mjs +76 -54
- package/scripts/retirer-les-copies-finies.mjs +1 -1
- package/scripts/seances.mjs +426 -115
- package/scripts/services-du-noyau.mjs +9 -1
- package/scripts/session-start.sh +14 -1
- package/scripts/sortie.mjs +37 -6
- package/scripts/sous-commandes.mjs +0 -2
- package/scripts/superviseur.mjs +33 -13
- package/scripts/tableau.mjs +61 -16
- package/scripts/transitions.d.mts +25 -2
- package/scripts/transitions.mjs +137 -29
- package/scripts/verrous/ecriture-hors-enveloppe.mjs +31 -9
- package/skills/codebase-design/DESIGN-IT-TWICE.md +1 -1
- package/skills/developpeur/SKILL.md +38 -15
- package/skills/direct/SKILL.md +29 -9
- package/skills/domain-modeling/GLOSSARY-FORMAT.md +9 -9
- package/skills/domain-modeling/SKILL.md +14 -12
- package/skills/explorateur/SKILL.md +30 -6
- package/skills/pitmaster/SKILL.md +12 -16
- package/skills/pitmaster/references/consigne-agent.md +12 -11
- package/skills/relecteur/SKILL.md +12 -5
- package/skills/systematic-debugging/SKILL.md +281 -0
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/skills/systematic-debugging/find-polluter.sh +72 -0
- package/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/skills/testwriter/SKILL.md +35 -29
- package/scripts/verrous/commande.mjs +0 -214
- package/scripts/verrous/verrou.mjs +0 -311
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Bisection script to find which test creates unwanted files/state
|
|
3
|
+
# Usage: ./find-polluter.sh <file_or_dir_to_check> <test_pattern>
|
|
4
|
+
# Example: ./find-polluter.sh '.git' 'src/**/*.test.ts'
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
if [ $# -ne 2 ]; then
|
|
9
|
+
echo "Usage: $0 <file_to_check> <test_pattern>"
|
|
10
|
+
echo "Example: $0 '.git' 'src/**/*.test.ts'"
|
|
11
|
+
exit 1
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
POLLUTION_CHECK="$1"
|
|
15
|
+
TEST_PATTERN="$2"
|
|
16
|
+
|
|
17
|
+
echo "🔍 Searching for test that creates: $POLLUTION_CHECK"
|
|
18
|
+
echo "Test pattern: $TEST_PATTERN"
|
|
19
|
+
echo ""
|
|
20
|
+
|
|
21
|
+
# Get list of test files (find . emits ./-prefixed paths, so accept the
|
|
22
|
+
# pattern written with or without a leading ./)
|
|
23
|
+
TEST_PATTERN="${TEST_PATTERN#./}"
|
|
24
|
+
# find -path can't match '**/' against zero directory levels, so a pattern
|
|
25
|
+
# like src/**/*.test.ts would skip src/top.test.ts; also try the pattern
|
|
26
|
+
# with '**/' collapsed to cover files directly under the base directory.
|
|
27
|
+
TEST_FILES=$(find . \( -path "./$TEST_PATTERN" -o -path "./${TEST_PATTERN//\*\*\//}" \) | sort -u)
|
|
28
|
+
if [ -z "$TEST_FILES" ]; then
|
|
29
|
+
TOTAL=0
|
|
30
|
+
else
|
|
31
|
+
TOTAL=$(printf '%s\n' "$TEST_FILES" | wc -l | tr -d ' ')
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
echo "Found $TOTAL test files"
|
|
35
|
+
echo ""
|
|
36
|
+
|
|
37
|
+
COUNT=0
|
|
38
|
+
for TEST_FILE in $TEST_FILES; do
|
|
39
|
+
COUNT=$((COUNT + 1))
|
|
40
|
+
|
|
41
|
+
# Skip if pollution already exists
|
|
42
|
+
if [ -e "$POLLUTION_CHECK" ]; then
|
|
43
|
+
echo "⚠️ Pollution already exists before test $COUNT/$TOTAL"
|
|
44
|
+
echo " Skipping: $TEST_FILE"
|
|
45
|
+
continue
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
echo "[$COUNT/$TOTAL] Testing: $TEST_FILE"
|
|
49
|
+
|
|
50
|
+
# Run the test
|
|
51
|
+
npm test "$TEST_FILE" > /dev/null 2>&1 || true
|
|
52
|
+
|
|
53
|
+
# Check if pollution appeared
|
|
54
|
+
if [ -e "$POLLUTION_CHECK" ]; then
|
|
55
|
+
echo ""
|
|
56
|
+
echo "🎯 FOUND POLLUTER!"
|
|
57
|
+
echo " Test: $TEST_FILE"
|
|
58
|
+
echo " Created: $POLLUTION_CHECK"
|
|
59
|
+
echo ""
|
|
60
|
+
echo "Pollution details:"
|
|
61
|
+
ls -la "$POLLUTION_CHECK"
|
|
62
|
+
echo ""
|
|
63
|
+
echo "To investigate:"
|
|
64
|
+
echo " npm test $TEST_FILE # Run just this test"
|
|
65
|
+
echo " cat $TEST_FILE # Review test code"
|
|
66
|
+
exit 1
|
|
67
|
+
fi
|
|
68
|
+
done
|
|
69
|
+
|
|
70
|
+
echo ""
|
|
71
|
+
echo "✅ No polluter found - all tests clean!"
|
|
72
|
+
exit 0
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Root Cause Tracing
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Bugs often manifest deep in the call stack (git init in wrong directory, file created in wrong location, database opened with wrong path). Your instinct is to fix where the error appears, but that's treating a symptom.
|
|
6
|
+
|
|
7
|
+
**Core principle:** Trace backward through the call chain until you find the original trigger, then fix at the source.
|
|
8
|
+
|
|
9
|
+
## When to Use
|
|
10
|
+
|
|
11
|
+
```dot
|
|
12
|
+
digraph when_to_use {
|
|
13
|
+
"Bug appears deep in stack?" [shape=diamond];
|
|
14
|
+
"Can trace backwards?" [shape=diamond];
|
|
15
|
+
"Fix at symptom point" [shape=box];
|
|
16
|
+
"Trace to original trigger" [shape=box];
|
|
17
|
+
"BETTER: Also add defense-in-depth" [shape=box];
|
|
18
|
+
|
|
19
|
+
"Bug appears deep in stack?" -> "Can trace backwards?" [label="yes"];
|
|
20
|
+
"Can trace backwards?" -> "Trace to original trigger" [label="yes"];
|
|
21
|
+
"Can trace backwards?" -> "Fix at symptom point" [label="no - dead end"];
|
|
22
|
+
"Trace to original trigger" -> "BETTER: Also add defense-in-depth";
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Use when:**
|
|
27
|
+
- Error happens deep in execution (not at entry point)
|
|
28
|
+
- Stack trace shows long call chain
|
|
29
|
+
- Unclear where invalid data originated
|
|
30
|
+
- Need to find which test/code triggers the problem
|
|
31
|
+
|
|
32
|
+
## The Tracing Process
|
|
33
|
+
|
|
34
|
+
### 1. Observe the Symptom
|
|
35
|
+
```
|
|
36
|
+
Error: git init failed in ~/project/packages/core
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 2. Find Immediate Cause
|
|
40
|
+
**What code directly causes this?**
|
|
41
|
+
```typescript
|
|
42
|
+
await execFileAsync('git', ['init'], { cwd: projectDir });
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 3. Ask: What Called This?
|
|
46
|
+
```typescript
|
|
47
|
+
WorktreeManager.createSessionWorktree(projectDir, sessionId)
|
|
48
|
+
→ called by Session.initializeWorkspace()
|
|
49
|
+
→ called by Session.create()
|
|
50
|
+
→ called by test at Project.create()
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 4. Keep Tracing Up
|
|
54
|
+
**What value was passed?**
|
|
55
|
+
- `projectDir = ''` (empty string!)
|
|
56
|
+
- Empty string as `cwd` resolves to `process.cwd()`
|
|
57
|
+
- That's the source code directory!
|
|
58
|
+
|
|
59
|
+
### 5. Find Original Trigger
|
|
60
|
+
**Where did empty string come from?**
|
|
61
|
+
```typescript
|
|
62
|
+
const context = setupCoreTest(); // Returns { tempDir: '' }
|
|
63
|
+
Project.create('name', context.tempDir); // Accessed before beforeEach!
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Adding Stack Traces
|
|
67
|
+
|
|
68
|
+
When you can't trace manually, add instrumentation:
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// Before the problematic operation
|
|
72
|
+
async function gitInit(directory: string) {
|
|
73
|
+
const stack = new Error().stack;
|
|
74
|
+
console.error('DEBUG git init:', {
|
|
75
|
+
directory,
|
|
76
|
+
cwd: process.cwd(),
|
|
77
|
+
nodeEnv: process.env.NODE_ENV,
|
|
78
|
+
stack,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
await execFileAsync('git', ['init'], { cwd: directory });
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Critical:** Use `console.error()` in tests (not logger - may not show)
|
|
86
|
+
|
|
87
|
+
**Run and capture:**
|
|
88
|
+
```bash
|
|
89
|
+
npm test 2>&1 | grep 'DEBUG git init'
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Analyze stack traces:**
|
|
93
|
+
- Look for test file names
|
|
94
|
+
- Find the line number triggering the call
|
|
95
|
+
- Identify the pattern (same test? same parameter?)
|
|
96
|
+
|
|
97
|
+
## Finding Which Test Causes Pollution
|
|
98
|
+
|
|
99
|
+
If something appears during tests but you don't know which test:
|
|
100
|
+
|
|
101
|
+
Use the bisection script `find-polluter.sh` in this directory:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
bash ./find-polluter.sh '.git' 'src/**/*.test.ts'
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Runs tests one-by-one, stops at first polluter. See script for usage.
|
|
108
|
+
|
|
109
|
+
## Real Example: Empty projectDir
|
|
110
|
+
|
|
111
|
+
**Symptom:** `.git` created in `packages/core/` (source code)
|
|
112
|
+
|
|
113
|
+
**Trace chain:**
|
|
114
|
+
1. `git init` runs in `process.cwd()` ← empty cwd parameter
|
|
115
|
+
2. WorktreeManager called with empty projectDir
|
|
116
|
+
3. Session.create() passed empty string
|
|
117
|
+
4. Test accessed `context.tempDir` before beforeEach
|
|
118
|
+
5. setupCoreTest() returns `{ tempDir: '' }` initially
|
|
119
|
+
|
|
120
|
+
**Root cause:** Top-level variable initialization accessing empty value
|
|
121
|
+
|
|
122
|
+
**Fix:** Made tempDir a getter that throws if accessed before beforeEach
|
|
123
|
+
|
|
124
|
+
**Also added defense-in-depth:**
|
|
125
|
+
- Layer 1: Project.create() validates directory
|
|
126
|
+
- Layer 2: WorkspaceManager validates not empty
|
|
127
|
+
- Layer 3: NODE_ENV guard refuses git init outside tmpdir
|
|
128
|
+
- Layer 4: Stack trace logging before git init
|
|
129
|
+
|
|
130
|
+
## Key Principle
|
|
131
|
+
|
|
132
|
+
```dot
|
|
133
|
+
digraph principle {
|
|
134
|
+
"Found immediate cause" [shape=ellipse];
|
|
135
|
+
"Can trace one level up?" [shape=diamond];
|
|
136
|
+
"Trace backwards" [shape=box];
|
|
137
|
+
"Is this the source?" [shape=diamond];
|
|
138
|
+
"Fix at source" [shape=box];
|
|
139
|
+
"Add validation at each layer" [shape=box];
|
|
140
|
+
"Bug impossible" [shape=doublecircle];
|
|
141
|
+
"NEVER fix just the symptom" [shape=octagon, style=filled, fillcolor=red, fontcolor=white];
|
|
142
|
+
|
|
143
|
+
"Found immediate cause" -> "Can trace one level up?";
|
|
144
|
+
"Can trace one level up?" -> "Trace backwards" [label="yes"];
|
|
145
|
+
"Can trace one level up?" -> "NEVER fix just the symptom" [label="no"];
|
|
146
|
+
"Trace backwards" -> "Is this the source?";
|
|
147
|
+
"Is this the source?" -> "Trace backwards" [label="no - keeps going"];
|
|
148
|
+
"Is this the source?" -> "Fix at source" [label="yes"];
|
|
149
|
+
"Fix at source" -> "Add validation at each layer";
|
|
150
|
+
"Add validation at each layer" -> "Bug impossible";
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**NEVER fix just where the error appears.** Trace back to find the original trigger.
|
|
155
|
+
|
|
156
|
+
## Stack Trace Tips
|
|
157
|
+
|
|
158
|
+
**In tests:** Use `console.error()` not logger - logger may be suppressed
|
|
159
|
+
**Before operation:** Log before the dangerous operation, not after it fails
|
|
160
|
+
**Include context:** Directory, cwd, environment variables, timestamps
|
|
161
|
+
**Capture stack:** `new Error().stack` shows complete call chain
|
|
162
|
+
|
|
163
|
+
## Real-World Impact
|
|
164
|
+
|
|
165
|
+
From debugging session (2025-10-03):
|
|
166
|
+
- Found root cause through 5-level trace
|
|
167
|
+
- Fixed at source (getter validation)
|
|
168
|
+
- Added 4 layers of defense
|
|
169
|
+
- 1847 tests passed, zero pollution
|
|
@@ -11,8 +11,8 @@ des fichiers de test et le paquet de la matière de test partagée (celui qui ex
|
|
|
11
11
|
`./test-fixtures`), en entier, son `package.json` et ses `docs/` compris, et ce dont tes tests
|
|
12
12
|
dépendent : les `devDependencies` du `package.json` d'un paquet du plan et `package-lock.json`, ou
|
|
13
13
|
les tables `[dev-dependencies]` (et `[target.<cible>.dev-dependencies]`) du `Cargo.toml` d'un
|
|
14
|
-
crate du plan et `Cargo.lock
|
|
15
|
-
|
|
14
|
+
crate du plan et `Cargo.lock`. Ton lot se juge à la fin de ta séance : tout autre fichier, et tout
|
|
15
|
+
autre changement d'un manifeste, te rendent l'étape, chaque fichier et chaque partie nommés ;
|
|
16
16
|
`npm test` met `Cargo.lock` d'accord. Dans un projet cargo, chaque crate a un seul exécutable de
|
|
17
17
|
tests par l'interface, `tests/it/main.rs` : un fichier de tests neuf est un module de `tests/it/`,
|
|
18
18
|
que tu déclares dans `tests/it/main.rs` (`mod <fichier>;`), et ta fiche nomme ce fichier du
|
|
@@ -22,14 +22,14 @@ sous `tests/` (sa dette inscrite) reçoit tes fichiers neufs sous `tests/it/` ;
|
|
|
22
22
|
leur module, sous `src/`, dans un fichier `tests.rs` ou un dossier `tests/`. Tu les déclares
|
|
23
23
|
toi-même dans le fichier de code du module, par la ligne `#[cfg(test)] mod tests;`, sans quoi
|
|
24
24
|
le test n'est jamais compilé ; un `#[cfg(test)] mod tests { … }` en ligne, tu le retires du
|
|
25
|
-
fichier de code et le déplaces dans `tests.rs`.
|
|
26
|
-
|
|
25
|
+
fichier de code et le déplaces dans `tests.rs`. Tout autre changement d'un fichier de code te
|
|
26
|
+
rend l'étape, la partie nommée. Un test de nuit Rust est un module de `tests/it_nuit/`, un
|
|
27
27
|
banc de temps un module de `tests/it_budget/`, chacun déclaré dans le `main.rs` de son dossier.
|
|
28
28
|
La matière partagée est le crate dont le manifeste dit `[package.metadata.grillhouse] matiere = true`.
|
|
29
29
|
Dans un paquet Python, tes tests sont les fichiers que pytest trouve, `test_*.py` ou `*_test.py`,
|
|
30
30
|
un test de nuit `*_nuit_test.py` ; leurs aides vont dans `conftest.py` et sous `tests/`. Ce dont
|
|
31
31
|
ils dépendent va dans le groupe `test` de `[dependency-groups]` du `pyproject.toml`, et
|
|
32
|
-
`uv.lock` suit ;
|
|
32
|
+
`uv.lock` suit ; toute autre partie du `pyproject.toml` que ton lot change te rend l'étape. Un dossier ou un
|
|
33
33
|
fichier temporaire se crée par `tempfile` (`TemporaryDirectory`, `NamedTemporaryFile`), jamais
|
|
34
34
|
par `mkdtemp` à la main : la passe échoue sur ce qu'un test laisse dans son dossier temporaire.
|
|
35
35
|
|
|
@@ -44,6 +44,12 @@ par `mkdtemp` à la main : la passe échoue sur ce qu'un test laisse dans son do
|
|
|
44
44
|
3. Lis ce que publient les fournisseurs des paquets du plan : leur ligne et leurs éléments dans
|
|
45
45
|
`docs/agents/index-des-interfaces.md`, puis la section d'un élément dans l'interface du
|
|
46
46
|
fournisseur, et la ligne « Déclaré pour » de sa section « Consommateurs ».
|
|
47
|
+
4. Lis le code que tes tests visent, **l'index d'abord** : avant toute recherche par le shell, tu
|
|
48
|
+
appelles `mcp__rtfm__rtfm_search` (`rtfm_search`, mode `hybrid`) pour le quoi, et
|
|
49
|
+
`mcp__rtfm__rtfm_expand` (`rtfm_expand`) lit en entier un résultat qu'elle rend ; l'appel se
|
|
50
|
+
cherche par `mcp__codegraph__codegraph_explore` (`codegraph_explore`), ou par
|
|
51
|
+
`codegraph explore <symboles>` ; le shell lit un fichier déjà nommé. Ainsi un test vise le code
|
|
52
|
+
tel qu'il est.
|
|
47
53
|
|
|
48
54
|
## Tes références, à lire au moment où elles servent
|
|
49
55
|
|
|
@@ -54,17 +60,13 @@ par `mkdtemp` à la main : la passe échoue sur ce qu'un test laisse dans son do
|
|
|
54
60
|
|
|
55
61
|
## Tes outils
|
|
56
62
|
|
|
57
|
-
**
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
**Tu prends l'outil que ton travail demande** : Write ou Edit, un script (python3, sed -i), une
|
|
64
|
+
redirection du shell, le client d'une base. Une substitution par script vérifie qu'elle a trouvé
|
|
65
|
+
son texte : `sed` qui ne trouve rien réussit sans rien changer. Un fichier temporaire va dans
|
|
66
|
+
`$TMPDIR`. Un fichier de tes tests se supprime par un script node que tu écris
|
|
60
67
|
dans `$TMPDIR` : il appelle `rmSync` de `node:fs` sur le chemin nommé et lu, et tu le lances par
|
|
61
68
|
`node $TMPDIR/<script>.mjs`. Les tests se lancent par `npm test -- <chemins>`, jamais par l'outil
|
|
62
|
-
de test directement. Ainsi
|
|
63
|
-
|
|
64
|
-
**L'index d'abord** : toute recherche commence par `rtfm_search` (mode `hybrid`) pour le quoi, et
|
|
65
|
-
`rtfm_expand` lit en entier un résultat qu'elle rend ; l'appel se cherche par
|
|
66
|
-
`codegraph explore <symboles>`, ou l'outil `codegraph_explore` ; le shell lit un fichier déjà
|
|
67
|
-
nommé. Ainsi un test vise le code tel qu'il est.
|
|
69
|
+
de test directement. Ainsi ton lot ne porte que ce que ton rôle écrit.
|
|
68
70
|
|
|
69
71
|
**Tu attends au premier plan ce que tu lances** : ta séance n'a aucune tâche de fond, et elle finit
|
|
70
72
|
avec ta fiche. Ainsi le circuit reprend dès ta fiche rendue.
|
|
@@ -166,17 +168,19 @@ tous les paquets du plan, et écrit au ticket les rouges, les verts non nommés
|
|
|
166
168
|
relecteur lit) et les tests nommés encore verts, qui sont un défaut : il te relance. Un test nommé
|
|
167
169
|
que HEAD tient déjà vert sous le même nom n'a rien à prouver. Les fichiers de ton lot que joue la
|
|
168
170
|
seule nuit (un test de nuit, un banc, un témoin de temps) sont mis de côté : ils ne sont ni exigés
|
|
169
|
-
rouges ni cause de refus. Sous un plan « comportement changé », la preuve
|
|
170
|
-
|
|
171
|
+
rouges ni cause de refus. Sous un plan « comportement changé », quand la preuve joue des
|
|
172
|
+
fichiers de ton lot, elle passe avec au moins un rouge du lot (dans un fichier que le lot change, ou
|
|
173
|
+
un test que ta fiche nomme) ou une construction rouge : des rouges existants seuls la refusent. Une
|
|
174
|
+
preuve refusée te relance deux fois, puis la question monte au superviseur. Ainsi la
|
|
171
175
|
preuve mesure le travail du ticket, et aucun test ne rougit pour la forme.
|
|
172
176
|
|
|
173
|
-
**Un rouge existant suffit** : sans fichier de ton lot
|
|
174
|
-
plan ; un test que HEAD tient et que le lot rougit (un lecteur dont le fournisseur a
|
|
175
|
-
type) est un rouge de la preuve, `rouge existant`, qui lance le développeur. Quand ces
|
|
176
|
-
couvrent les critères du ticket, tu n'écris aucun test neuf et ta passation le dit.
|
|
177
|
-
Sans fichier de ton lot ni rouge,
|
|
178
|
-
lot sont ceux que joue la nuit : elle passe. Ainsi le développeur du lecteur est lancé
|
|
179
|
-
ce que le lot casse.
|
|
177
|
+
**Un rouge existant suffit** : sans fichier de ton lot que la preuve joue, elle joue en entier les
|
|
178
|
+
paquets du plan ; un test que HEAD tient et que le lot rougit (un lecteur dont le fournisseur a
|
|
179
|
+
changé un type) est un rouge de la preuve, `rouge existant`, qui lance le développeur. Quand ces
|
|
180
|
+
rouges couvrent les critères du ticket, tu n'écris aucun test neuf et ta passation le dit.
|
|
181
|
+
Sans fichier de ton lot que la preuve joue ni rouge, elle échoue, sauf quand les seuls fichiers de
|
|
182
|
+
test de ton lot sont ceux que joue la nuit : elle passe. Ainsi le développeur du lecteur est lancé
|
|
183
|
+
sur ce que le lot casse.
|
|
180
184
|
|
|
181
185
|
**Un fichier entier se nomme sans `test`** : `portent_le_travail` porte `fichier` (depuis la
|
|
182
186
|
racine du dépôt) et, facultatif, `test` (son nom complet tel que le rapport de la preuve l'écrit,
|
|
@@ -208,7 +212,7 @@ de npm.
|
|
|
208
212
|
|
|
209
213
|
**Ce que tes tests lisent se nomme ou se déclare** : un test qui lance un script de son paquet,
|
|
210
214
|
ou en lit un fichier, écrit son chemin entier dans une chaîne
|
|
211
|
-
(`const SCRIPT = path.resolve(__dirname, '../scripts/
|
|
215
|
+
(`const SCRIPT = path.resolve(__dirname, '../scripts/droits.mjs')`), et le cadre le
|
|
212
216
|
rejoue quand ce script, ou ce qu'il importe, change ; un chemin construit à l'exécution
|
|
213
217
|
(`path.join(SCRIPTS, nom)`) est refusé par la garde des chemins des tests. Un test qui lit un
|
|
214
218
|
fichier hors de son paquet et de ses imports (des scènes, des paires de la matière, la trace d'un
|
|
@@ -274,11 +278,13 @@ tests arrivent au dépôt avec le code qui les rend verts.
|
|
|
274
278
|
**Ta séance finit sur ta fiche**, que ton schéma décrit et que le circuit lit seule :
|
|
275
279
|
|
|
276
280
|
- `statut` FAIT : tes tests sont écrits, et la preuve du rouge les juge ;
|
|
277
|
-
- `statut` BLOQUÉ, avec sa `raison` : ce qui reste est hors de ta portée (
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
plan
|
|
281
|
-
-
|
|
281
|
+
- `statut` BLOQUÉ, avec sa `raison` : ce qui reste est hors de ta portée (une décision hors de
|
|
282
|
+
ton rôle) ;
|
|
283
|
+
- `statut` BESOIN, avec sa `question` : une réponse te manque pour avancer ; hors des paquets du
|
|
284
|
+
plan et de la matière de test partagée, la copie est en lecture seule, une écriture y échoue
|
|
285
|
+
(« Read-only file system »), ta `question` nomme le paquet qui possède le fichier et ton champ
|
|
286
|
+
`manque` le fichier : un fichier que le ticket nomme, ou un fichier de test d'un paquet lecteur,
|
|
287
|
+
étend le plan et ta séance reprend ;
|
|
282
288
|
- `motif` `aucun-comportement`, sur BESOIN ou BLOQUÉ : aucun comportement n'est à tester, aucun
|
|
283
289
|
test honnête (qui échoue avant le lot et passe après) ne peut rougir ; ta question le dit et
|
|
284
290
|
propose au superviseur `--mecanique [<commande>]` (avec une commande vers 1.1, sans elle vers le
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// The lock of the commands of a role that writes (the testwriter, the developpeur): a PreToolUse hook
|
|
3
|
-
// on Bash, which the settings of its session declare (scripts/droits.mjs). It reads the hook's JSON
|
|
4
|
-
// on stdin and refuses, exit code 2 and its reason on stderr, a command whose shell writes a file
|
|
5
|
-
// out of the session's temporary directory: an output redirection (`>`, `>>`, `>|`, `&>`, `1>`…)
|
|
6
|
-
// or `tee`. A file of the repository is written by the tools of writing (Write, Edit), which the
|
|
7
|
-
// role's write lock (verrou.mjs) judges; a rule of Claude Code does not see a redirection, and a
|
|
8
|
-
// session in its envelope runs without the check of writes. Architecture:
|
|
9
|
-
// docs/architecture/machine.md (§3.1, §5.5 « Les verrous dans la séance »).
|
|
10
|
-
//
|
|
11
|
-
// - Allowed targets: the null and standard devices (`/dev/null`, `/dev/stdout`, `/dev/stderr`,
|
|
12
|
-
// `/dev/fd/…`), a duplication of a descriptor (`2>&1`, `>&2`), and a path under the temporary
|
|
13
|
-
// directory (`os.tmpdir()`, the envelope's TMPDIR), written plainly or by `$TMPDIR`/`${TMPDIR}`.
|
|
14
|
-
// A relative path is judged from the command's working directory (the input's `cwd`). A target
|
|
15
|
-
// that names any other variable or a substitution cannot be judged, and is refused.
|
|
16
|
-
// - What quotes hold, and the body of a here-document, is text: a `>` there redirects nothing.
|
|
17
|
-
// - An input it cannot read, or another tool, passes: a hook never stops the session on its own
|
|
18
|
-
// failure.
|
|
19
|
-
import { readFileSync } from 'node:fs';
|
|
20
|
-
import { tmpdir } from 'node:os';
|
|
21
|
-
import path from 'node:path';
|
|
22
|
-
import { pathToFileURL } from 'node:url';
|
|
23
|
-
|
|
24
|
-
const PERIPHERIQUES = /^\/dev\/(null|stdout|stderr|tty|fd\/\d+)$/;
|
|
25
|
-
|
|
26
|
-
// The targets of the files <commande> writes by the shell, `$TMPDIR` read as <tmp>: each
|
|
27
|
-
// `{ cible, brute }`, `cible` the word once its quotes are read, null when a variable or a
|
|
28
|
-
// substitution keeps it unknown.
|
|
29
|
-
function ecrituresDuShell(commande, tmp = tmpdir()) {
|
|
30
|
-
const out = [];
|
|
31
|
-
const n = commande.length;
|
|
32
|
-
let i = 0;
|
|
33
|
-
// The here-documents whose bodies start at the next line.
|
|
34
|
-
let documents = [];
|
|
35
|
-
// A word from <j>: its text with quotes read, whether it holds an expansion, and where it ends.
|
|
36
|
-
const mot = j => {
|
|
37
|
-
let texte = '';
|
|
38
|
-
let inconnu = false;
|
|
39
|
-
while (j < n && /\s/.test(commande[j]) && commande[j] !== '\n') {
|
|
40
|
-
j++;
|
|
41
|
-
}
|
|
42
|
-
while (j < n && !/[\s;&|<>()]/.test(commande[j])) {
|
|
43
|
-
const c = commande[j];
|
|
44
|
-
if (c === "'") {
|
|
45
|
-
const f = commande.indexOf("'", j + 1);
|
|
46
|
-
texte += commande.slice(j + 1, f < 0 ? n : f);
|
|
47
|
-
j = f < 0 ? n : f + 1;
|
|
48
|
-
} else if (c === '"') {
|
|
49
|
-
let k = j + 1;
|
|
50
|
-
while (k < n && commande[k] !== '"') {
|
|
51
|
-
if (commande[k] === '\\') {
|
|
52
|
-
k++;
|
|
53
|
-
} else if (commande[k] === '$' || commande[k] === '`') {
|
|
54
|
-
inconnu = true;
|
|
55
|
-
}
|
|
56
|
-
texte += commande[k] ?? '';
|
|
57
|
-
k++;
|
|
58
|
-
}
|
|
59
|
-
j = k + 1;
|
|
60
|
-
} else if (c === '\\') {
|
|
61
|
-
texte += commande[j + 1] ?? '';
|
|
62
|
-
j += 2;
|
|
63
|
-
} else {
|
|
64
|
-
if (c === '$' || c === '`') {
|
|
65
|
-
inconnu = true;
|
|
66
|
-
}
|
|
67
|
-
texte += c;
|
|
68
|
-
j++;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return { texte, inconnu, fin: j };
|
|
72
|
-
};
|
|
73
|
-
const cible = w => {
|
|
74
|
-
const variable = /^\$(\{TMPDIR\}|TMPDIR)(\/.*)?$/.exec(w.texte);
|
|
75
|
-
if (variable) {
|
|
76
|
-
return { cible: path.join(tmp, variable[2] ?? ''), brute: w.texte };
|
|
77
|
-
}
|
|
78
|
-
return { cible: w.inconnu ? null : w.texte, brute: w.texte };
|
|
79
|
-
};
|
|
80
|
-
while (i < n) {
|
|
81
|
-
const c = commande[i];
|
|
82
|
-
if (c === '\n' && documents.length) {
|
|
83
|
-
// The bodies of the here-documents opened on the line just ended.
|
|
84
|
-
let j = i + 1;
|
|
85
|
-
for (const fin of documents) {
|
|
86
|
-
while (j < n) {
|
|
87
|
-
const e = commande.indexOf('\n', j);
|
|
88
|
-
const ligne = commande.slice(j, e < 0 ? n : e);
|
|
89
|
-
j = e < 0 ? n : e + 1;
|
|
90
|
-
if (ligne.replace(/^\t+/, '') === fin) {
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
documents = [];
|
|
96
|
-
i = j;
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
if (c === "'") {
|
|
100
|
-
const f = commande.indexOf("'", i + 1);
|
|
101
|
-
i = f < 0 ? n : f + 1;
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
if (c === '"') {
|
|
105
|
-
let k = i + 1;
|
|
106
|
-
while (k < n && commande[k] !== '"') {
|
|
107
|
-
k += commande[k] === '\\' ? 2 : 1;
|
|
108
|
-
}
|
|
109
|
-
i = k + 1;
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
if (c === '\\') {
|
|
113
|
-
i += 2;
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
if (c === '<' && commande[i + 1] === '<' && commande[i + 2] !== '<') {
|
|
117
|
-
const w = mot(i + (commande[i + 2] === '-' ? 3 : 2));
|
|
118
|
-
if (w.texte) {
|
|
119
|
-
documents.push(w.texte);
|
|
120
|
-
}
|
|
121
|
-
i = w.fin;
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
if (c === '>') {
|
|
125
|
-
let j = i + 1;
|
|
126
|
-
if (commande[j] === '>' || commande[j] === '|') {
|
|
127
|
-
j++;
|
|
128
|
-
}
|
|
129
|
-
// A duplication of a descriptor, `>&2`, writes no file.
|
|
130
|
-
if (commande[j] === '&') {
|
|
131
|
-
i = j + 1;
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
const w = mot(j);
|
|
135
|
-
if (w.texte) {
|
|
136
|
-
out.push(cible(w));
|
|
137
|
-
}
|
|
138
|
-
i = w.fin;
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
if (c === '&' && commande[i + 1] === '>') {
|
|
142
|
-
const w = mot(i + (commande[i + 2] === '>' ? 3 : 2));
|
|
143
|
-
if (w.texte) {
|
|
144
|
-
out.push(cible(w));
|
|
145
|
-
}
|
|
146
|
-
i = w.fin;
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
// `tee` as a command word: each of its operands is a file it writes.
|
|
150
|
-
if (/[a-z]/.test(c) && (i === 0 || /[\s;&|(]/.test(commande[i - 1]))) {
|
|
151
|
-
const w = mot(i);
|
|
152
|
-
if (w.texte === 'tee') {
|
|
153
|
-
let j = w.fin;
|
|
154
|
-
for (;;) {
|
|
155
|
-
const a = mot(j);
|
|
156
|
-
if (!a.texte) {
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
if (!a.texte.startsWith('-')) {
|
|
160
|
-
out.push(cible(a));
|
|
161
|
-
}
|
|
162
|
-
j = a.fin;
|
|
163
|
-
}
|
|
164
|
-
i = j;
|
|
165
|
-
} else {
|
|
166
|
-
i = Math.max(w.fin, i + 1);
|
|
167
|
-
}
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
i++;
|
|
171
|
-
}
|
|
172
|
-
return out;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// The reason the command of this hook input is refused, or null when it passes.
|
|
176
|
-
export function refusDeCommande(input, { tmp = tmpdir() } = {}) {
|
|
177
|
-
if (input?.tool_name !== 'Bash') {
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
const commande = String(input.tool_input?.command ?? '');
|
|
181
|
-
const cwd = input.cwd ?? process.cwd();
|
|
182
|
-
const interieur = f => {
|
|
183
|
-
const rel = path.relative(path.resolve(tmp), f);
|
|
184
|
-
return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
|
|
185
|
-
};
|
|
186
|
-
const enTrop = ecrituresDuShell(commande, tmp).filter(({ cible }) => {
|
|
187
|
-
if (cible === null) {
|
|
188
|
-
return true;
|
|
189
|
-
}
|
|
190
|
-
if (PERIPHERIQUES.test(cible)) {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
const absolu = path.resolve(cwd, cible);
|
|
194
|
-
return !interieur(absolu);
|
|
195
|
-
});
|
|
196
|
-
if (!enTrop.length) {
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
return `Le shell n'écrit pas les fichiers du dépôt (${enTrop.map(e => e.brute).join(', ')}) : un fichier s'écrit par l'outil Write ou Edit, que le verrou de ton rôle juge ; un fichier temporaire va dans ${tmp}.`;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const direct = import.meta.url === pathToFileURL(process.argv[1] ?? '').href;
|
|
203
|
-
if (direct) {
|
|
204
|
-
let raison = null;
|
|
205
|
-
try {
|
|
206
|
-
raison = refusDeCommande(JSON.parse(readFileSync(0, 'utf8')));
|
|
207
|
-
} catch {
|
|
208
|
-
// An input it cannot read passes.
|
|
209
|
-
}
|
|
210
|
-
if (raison) {
|
|
211
|
-
process.stderr.write(`${raison}\n`);
|
|
212
|
-
process.exitCode = 2;
|
|
213
|
-
}
|
|
214
|
-
}
|