@eldrforge/kodrdriv 1.2.29 → 1.2.123
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/dist/application.js +16 -13
- package/dist/application.js.map +1 -1
- package/dist/arguments.js +5 -5
- package/dist/arguments.js.map +1 -1
- package/dist/commands/audio-review.js +2 -5
- package/dist/commands/audio-review.js.map +1 -1
- package/dist/commands/clean.js +2 -4
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/commit.js +3 -6
- package/dist/commands/commit.js.map +1 -1
- package/dist/commands/development.js +7 -7
- package/dist/commands/development.js.map +1 -1
- package/dist/commands/link.js +3 -7
- package/dist/commands/link.js.map +1 -1
- package/dist/commands/precommit.js +99 -0
- package/dist/commands/precommit.js.map +1 -0
- package/dist/commands/publish.js +47 -32
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/release.js +3 -7
- package/dist/commands/release.js.map +1 -1
- package/dist/commands/review.js +4 -6
- package/dist/commands/review.js.map +1 -1
- package/dist/commands/tree.js +213 -84
- package/dist/commands/tree.js.map +1 -1
- package/dist/commands/unlink.js +3 -7
- package/dist/commands/unlink.js.map +1 -1
- package/dist/commands/updates.js +2 -4
- package/dist/commands/updates.js.map +1 -1
- package/dist/commands/versions.js +3 -7
- package/dist/commands/versions.js.map +1 -1
- package/dist/constants.js +4 -2
- package/dist/constants.js.map +1 -1
- package/dist/content/files.js +2 -4
- package/dist/content/files.js.map +1 -1
- package/dist/execution/CommandValidator.js +33 -1
- package/dist/execution/CommandValidator.js.map +1 -1
- package/dist/execution/ResourceMonitor.js +26 -1
- package/dist/execution/ResourceMonitor.js.map +1 -1
- package/dist/execution/TreeExecutionAdapter.js +2 -2
- package/dist/execution/TreeExecutionAdapter.js.map +1 -1
- package/dist/util/checkpointManager.js +2 -4
- package/dist/util/checkpointManager.js.map +1 -1
- package/dist/util/dependencyGraph.js +2 -4
- package/dist/util/dependencyGraph.js.map +1 -1
- package/dist/util/general.js +7 -107
- package/dist/util/general.js.map +1 -1
- package/dist/util/gitMutex.js +63 -18
- package/dist/util/gitMutex.js.map +1 -1
- package/dist/util/precommitOptimizations.js +310 -0
- package/dist/util/precommitOptimizations.js.map +1 -0
- package/dist/util/storageAdapter.js +2 -6
- package/dist/util/storageAdapter.js.map +1 -1
- package/dist/utils/branchState.js +178 -45
- package/dist/utils/branchState.js.map +1 -1
- package/package.json +6 -5
- package/AI-FRIENDLY-LOGGING-GUIDE.md +0 -237
- package/AI-LOGGING-MIGRATION-COMPLETE.md +0 -371
- package/ALREADY-PUBLISHED-PACKAGES-FIX.md +0 -264
- package/AUDIT-BRANCHES-PROGRESS-FIX.md +0 -90
- package/AUDIT-EXAMPLE-OUTPUT.md +0 -113
- package/CHECKPOINT-RECOVERY-FIX.md +0 -450
- package/LOGGING-MIGRATION-STATUS.md +0 -186
- package/MONOREPO-PUBLISH-IMPROVEMENTS.md +0 -281
- package/PARALLEL-EXECUTION-FIXES.md +0 -132
- package/PARALLEL-PUBLISH-DEBUGGING-GUIDE.md +0 -441
- package/PARALLEL-PUBLISH-FIXES-IMPLEMENTED.md +0 -405
- package/PARALLEL-PUBLISH-IMPROVEMENTS-IMPLEMENTED.md +0 -439
- package/PARALLEL-PUBLISH-LOGGING-FIXES.md +0 -274
- package/PARALLEL-PUBLISH-QUICK-REFERENCE.md +0 -375
- package/PARALLEL_EXECUTION_FIX.md +0 -146
- package/PUBLISH_IMPROVEMENTS_IMPLEMENTED.md +0 -294
- package/RECOVERY-FIXES.md +0 -72
- package/SUBMODULE-LOCK-FIX.md +0 -132
- package/VERSION-AUDIT-FIX.md +0 -333
- package/WORKFLOW-PRECHECK-IMPLEMENTATION.md +0 -239
- package/WORKFLOW-SKIP-SUMMARY.md +0 -121
- package/dist/util/safety.js +0 -166
- package/dist/util/safety.js.map +0 -1
- package/dist/util/stdin.js +0 -133
- package/dist/util/stdin.js.map +0 -1
- package/dist/util/storage.js +0 -187
- package/dist/util/storage.js.map +0 -1
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
# Parallel Publish Quick Reference Guide
|
|
2
|
-
|
|
3
|
-
## 🚨 When Parallel Publish Fails
|
|
4
|
-
|
|
5
|
-
### Scenario 1: Target Branch Out of Sync
|
|
6
|
-
|
|
7
|
-
**Error**: `❌ Target branch 'main' is not in sync with remote`
|
|
8
|
-
|
|
9
|
-
**Solution**:
|
|
10
|
-
```bash
|
|
11
|
-
# Run audit to see which packages have sync issues
|
|
12
|
-
kodrdriv tree publish --audit-branches
|
|
13
|
-
|
|
14
|
-
# Follow the "SYNC TARGET BRANCHES" instructions, e.g.:
|
|
15
|
-
cd ~/gitw/getfjell/logging
|
|
16
|
-
git checkout main
|
|
17
|
-
git reset --hard origin/main # or git pull origin main if can fast-forward
|
|
18
|
-
git checkout working
|
|
19
|
-
|
|
20
|
-
# Repeat for each package with sync issues
|
|
21
|
-
# Then retry publish
|
|
22
|
-
kodrdriv tree publish --parallel --model "gpt-5-mini"
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
### Scenario 2: npm Install Race Condition
|
|
28
|
-
|
|
29
|
-
**Error**: `npm error code ENOTEMPTY` or `directory not empty` during parallel publish
|
|
30
|
-
|
|
31
|
-
**Solution**:
|
|
32
|
-
```bash
|
|
33
|
-
# Clean and reinstall in the affected package
|
|
34
|
-
cd ~/gitw/getfjell/<failed-package>
|
|
35
|
-
rm -rf node_modules
|
|
36
|
-
npm install
|
|
37
|
-
git add package-lock.json
|
|
38
|
-
git commit -m "Fix lockfile after npm install"
|
|
39
|
-
git push origin working
|
|
40
|
-
|
|
41
|
-
# Then publish with dependency updates
|
|
42
|
-
kodrdriv publish --update-deps @fjell --model "gpt-5-mini"
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
### Scenario 3: Package Failed, Need to Publish Manually
|
|
48
|
-
|
|
49
|
-
**⚠️ CRITICAL**: Don't just run `kodrdriv publish` - it will skip dependency updates!
|
|
50
|
-
|
|
51
|
-
**Wrong**:
|
|
52
|
-
```bash
|
|
53
|
-
cd ~/gitw/getfjell/cache
|
|
54
|
-
kodrdriv publish --model "gpt-5-mini"
|
|
55
|
-
# ❌ Publishes with OLD dependency versions
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
**Correct**:
|
|
59
|
-
```bash
|
|
60
|
-
cd ~/gitw/getfjell/cache
|
|
61
|
-
kodrdriv publish --update-deps @fjell --model "gpt-5-mini"
|
|
62
|
-
# ✅ Updates dependencies, then publishes
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
### Scenario 4: Multiple Packages Failed
|
|
68
|
-
|
|
69
|
-
**Option A**: Update all dependencies, then retry
|
|
70
|
-
```bash
|
|
71
|
-
cd ~/gitw/getfjell
|
|
72
|
-
kodrdriv tree updates --inter-project @fjell
|
|
73
|
-
kodrdriv tree publish --continue
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
**Option B**: Fall back to serial mode
|
|
77
|
-
```bash
|
|
78
|
-
cd ~/gitw/getfjell
|
|
79
|
-
kodrdriv tree publish --model "gpt-5-mini"
|
|
80
|
-
# Slow but reliable
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
## 🔍 Pre-Flight Checklist
|
|
86
|
-
|
|
87
|
-
Before running parallel publish:
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
# 1. Run enhanced audit
|
|
91
|
-
kodrdriv tree publish --audit-branches
|
|
92
|
-
|
|
93
|
-
# 2. Check for critical issues:
|
|
94
|
-
# - 🚨 Target branch sync issues
|
|
95
|
-
# - ⚠️ Merge conflicts
|
|
96
|
-
# - 📋 Existing PRs
|
|
97
|
-
# - ⚠️ Version consistency issues
|
|
98
|
-
|
|
99
|
-
# 3. Fix all issues (follow audit output)
|
|
100
|
-
|
|
101
|
-
# 4. Re-run audit to verify
|
|
102
|
-
kodrdriv tree publish --audit-branches
|
|
103
|
-
# Should show: "✅ All X package(s) are in good state!"
|
|
104
|
-
|
|
105
|
-
# 5. Run parallel publish
|
|
106
|
-
kodrdriv tree publish --parallel --model "gpt-5-mini"
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
## 📋 New Commands Reference
|
|
112
|
-
|
|
113
|
-
### Update Inter-Project Dependencies
|
|
114
|
-
|
|
115
|
-
```bash
|
|
116
|
-
# Update dependencies in current package
|
|
117
|
-
kodrdriv updates --inter-project @fjell
|
|
118
|
-
|
|
119
|
-
# Update dependencies across all packages in tree
|
|
120
|
-
kodrdriv tree updates --inter-project @fjell
|
|
121
|
-
|
|
122
|
-
# Publish with dependency update
|
|
123
|
-
kodrdriv publish --update-deps @fjell --model "gpt-5-mini"
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Enhanced Audit
|
|
127
|
-
|
|
128
|
-
```bash
|
|
129
|
-
# Run comprehensive audit (now includes target branch sync check)
|
|
130
|
-
kodrdriv tree publish --audit-branches
|
|
131
|
-
|
|
132
|
-
# Audit output now shows:
|
|
133
|
-
# - ✅ Good State packages
|
|
134
|
-
# - 🚨 Target Branch Sync Issues (NEW)
|
|
135
|
-
# - ⚠️ Version Issues
|
|
136
|
-
# - 🚨 CRITICAL ISSUES (conflicts, PRs, sync)
|
|
137
|
-
# - 📝 RECOMMENDED WORKFLOW (step-by-step fixes)
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
## 🎯 Recommended Workflow
|
|
143
|
-
|
|
144
|
-
### For Clean Releases (No Issues)
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
cd ~/gitw/getfjell
|
|
148
|
-
|
|
149
|
-
# 1. Audit
|
|
150
|
-
kodrdriv tree publish --audit-branches
|
|
151
|
-
|
|
152
|
-
# 2. Parallel publish
|
|
153
|
-
kodrdriv tree publish --parallel --model "gpt-5-mini"
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### For Releases with Issues
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
cd ~/gitw/getfjell
|
|
160
|
-
|
|
161
|
-
# 1. Audit
|
|
162
|
-
kodrdriv tree publish --audit-branches
|
|
163
|
-
|
|
164
|
-
# 2. Fix issues (follow numbered steps in audit output)
|
|
165
|
-
# Priority order:
|
|
166
|
-
# 1️⃣ SYNC TARGET BRANCHES (most critical)
|
|
167
|
-
# 2️⃣ RESOLVE MERGE CONFLICTS
|
|
168
|
-
# 3️⃣ FIX VERSION ISSUES
|
|
169
|
-
# 4️⃣ SYNC WITH REMOTE
|
|
170
|
-
# 5️⃣ PUSH LOCAL COMMITS
|
|
171
|
-
|
|
172
|
-
# 3. Re-audit to verify
|
|
173
|
-
kodrdriv tree publish --audit-branches
|
|
174
|
-
|
|
175
|
-
# 4. Parallel publish
|
|
176
|
-
kodrdriv tree publish --parallel --model "gpt-5-mini"
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### Recovery from Failed Parallel Publish
|
|
180
|
-
|
|
181
|
-
```bash
|
|
182
|
-
cd ~/gitw/getfjell
|
|
183
|
-
|
|
184
|
-
# Option 1: Update all deps and retry
|
|
185
|
-
kodrdriv tree updates --inter-project @fjell
|
|
186
|
-
kodrdriv tree publish --continue
|
|
187
|
-
|
|
188
|
-
# Option 2: Manual publish with dep updates
|
|
189
|
-
cd <failed-package>
|
|
190
|
-
kodrdriv publish --update-deps @fjell --model "gpt-5-mini"
|
|
191
|
-
|
|
192
|
-
# Option 3: Serial fallback
|
|
193
|
-
kodrdriv tree publish --model "gpt-5-mini"
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
---
|
|
197
|
-
|
|
198
|
-
## 🔧 Troubleshooting
|
|
199
|
-
|
|
200
|
-
### "All packages in good state" but parallel publish still fails
|
|
201
|
-
|
|
202
|
-
This shouldn't happen with the new audit, but if it does:
|
|
203
|
-
|
|
204
|
-
1. Check if main branches are EXACTLY in sync:
|
|
205
|
-
```bash
|
|
206
|
-
cd <package>
|
|
207
|
-
git fetch origin
|
|
208
|
-
git rev-parse main
|
|
209
|
-
git rev-parse origin/main
|
|
210
|
-
# These should match exactly
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
2. If they don't match:
|
|
214
|
-
```bash
|
|
215
|
-
git checkout main
|
|
216
|
-
git reset --hard origin/main
|
|
217
|
-
git checkout working
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
### Checkpoint shows old failures after manual fix
|
|
221
|
-
|
|
222
|
-
```bash
|
|
223
|
-
# Mark packages as completed
|
|
224
|
-
kodrdriv tree publish --continue --mark-completed "pkg1,pkg2"
|
|
225
|
-
|
|
226
|
-
# Or reset checkpoint and start fresh
|
|
227
|
-
rm .kodrdriv-checkpoint.json
|
|
228
|
-
kodrdriv tree publish --parallel --model "gpt-5-mini"
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
### Package published but checkpoint still shows failure
|
|
232
|
-
|
|
233
|
-
This is a known issue. Workarounds:
|
|
234
|
-
|
|
235
|
-
```bash
|
|
236
|
-
# Option 1: Mark as completed
|
|
237
|
-
kodrdriv tree publish --continue --mark-completed "<package-name>"
|
|
238
|
-
|
|
239
|
-
# Option 2: Skip and continue
|
|
240
|
-
kodrdriv tree publish --continue --skip-packages "<package-name>"
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
---
|
|
244
|
-
|
|
245
|
-
## ⚡ Performance Tips
|
|
246
|
-
|
|
247
|
-
### Speed Up Audit
|
|
248
|
-
|
|
249
|
-
```bash
|
|
250
|
-
# Audit is now ~2-3 seconds slower per package due to target branch sync check
|
|
251
|
-
# For large repos (50+ packages), this adds ~2-3 minutes
|
|
252
|
-
# This is acceptable given the failures it prevents
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
### Speed Up Parallel Publish
|
|
256
|
-
|
|
257
|
-
```bash
|
|
258
|
-
# Pre-build all packages first (avoids build races)
|
|
259
|
-
kodrdriv tree run "npm run build"
|
|
260
|
-
|
|
261
|
-
# Then publish without build
|
|
262
|
-
kodrdriv tree publish --parallel --model "gpt-5-mini"
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
### When to Use Serial Mode
|
|
266
|
-
|
|
267
|
-
Use serial mode (`kodrdriv tree publish`) when:
|
|
268
|
-
- Critical production release (can't afford failures)
|
|
269
|
-
- First time publishing a new monorepo
|
|
270
|
-
- Packages have complex interdependencies
|
|
271
|
-
- You don't have time to babysit parallel mode
|
|
272
|
-
|
|
273
|
-
Use parallel mode when:
|
|
274
|
-
- Development/testing releases
|
|
275
|
-
- Packages are mostly independent
|
|
276
|
-
- You're available to handle failures
|
|
277
|
-
- Time savings matter (30-60 min vs 60-120 min)
|
|
278
|
-
|
|
279
|
-
---
|
|
280
|
-
|
|
281
|
-
## 📊 Success Indicators
|
|
282
|
-
|
|
283
|
-
### Audit Should Show
|
|
284
|
-
|
|
285
|
-
```
|
|
286
|
-
╔══════════════════════════════════════════════════════════════╗
|
|
287
|
-
║ Branch State Audit (16 packages)
|
|
288
|
-
║ All packages on: working
|
|
289
|
-
╠══════════════════════════════════════════════════════════════╣
|
|
290
|
-
|
|
291
|
-
✅ Good State (16 packages):
|
|
292
|
-
@fjell/logging (v4.4.65-dev.0)
|
|
293
|
-
@fjell/common-config (v1.1.38-dev.0)
|
|
294
|
-
...
|
|
295
|
-
|
|
296
|
-
✅ All 16 package(s) are in good state!
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
### Parallel Publish Should Complete
|
|
300
|
-
|
|
301
|
-
```
|
|
302
|
-
📦 Executing 16 packages in parallel
|
|
303
|
-
|
|
304
|
-
[1/16] ✅ @fjell/logging
|
|
305
|
-
[2/16] ✅ @fjell/common-config
|
|
306
|
-
...
|
|
307
|
-
[16/16] ✅ @fjell/sample-app
|
|
308
|
-
|
|
309
|
-
✨ Parallel execution completed in 45s
|
|
310
|
-
|
|
311
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
312
|
-
📊 Publish Summary
|
|
313
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
314
|
-
|
|
315
|
-
✅ Published (16):
|
|
316
|
-
- @fjell/logging
|
|
317
|
-
- @fjell/common-config
|
|
318
|
-
...
|
|
319
|
-
|
|
320
|
-
Total time: 45s
|
|
321
|
-
Success rate: 100% (16/16 packages processed)
|
|
322
|
-
Peak concurrency: 4 packages
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
---
|
|
326
|
-
|
|
327
|
-
## 🆘 When All Else Fails
|
|
328
|
-
|
|
329
|
-
```bash
|
|
330
|
-
# Nuclear option: Reset everything and use serial mode
|
|
331
|
-
cd ~/gitw/getfjell
|
|
332
|
-
|
|
333
|
-
# 1. Sync all main branches
|
|
334
|
-
for dir in */; do
|
|
335
|
-
cd "$dir"
|
|
336
|
-
git checkout main
|
|
337
|
-
git reset --hard origin/main
|
|
338
|
-
git checkout working
|
|
339
|
-
cd ..
|
|
340
|
-
done
|
|
341
|
-
|
|
342
|
-
# 2. Update all dependencies
|
|
343
|
-
kodrdriv tree updates --inter-project @fjell
|
|
344
|
-
|
|
345
|
-
# 3. Serial publish (slow but reliable)
|
|
346
|
-
kodrdriv tree publish --model "gpt-5-mini"
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
---
|
|
350
|
-
|
|
351
|
-
## 📞 Getting Help
|
|
352
|
-
|
|
353
|
-
If you encounter issues not covered here:
|
|
354
|
-
|
|
355
|
-
1. Run audit with verbose output:
|
|
356
|
-
```bash
|
|
357
|
-
kodrdriv tree publish --audit-branches --verbose
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
2. Check the checkpoint file:
|
|
361
|
-
```bash
|
|
362
|
-
cat .kodrdriv-checkpoint.json | jq
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
3. Review the implementation report:
|
|
366
|
-
```bash
|
|
367
|
-
cat PARALLEL-PUBLISH-FIXES-IMPLEMENTED.md
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
4. File an issue with:
|
|
371
|
-
- Audit output
|
|
372
|
-
- Error messages
|
|
373
|
-
- Checkpoint state
|
|
374
|
-
- Steps to reproduce
|
|
375
|
-
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
# Parallel Execution Freeze Fix
|
|
2
|
-
|
|
3
|
-
## Problem
|
|
4
|
-
|
|
5
|
-
When running `kodrdriv tree publish --parallel`, the execution would freeze because:
|
|
6
|
-
|
|
7
|
-
1. **Multiple child processes** were spawned (one per package)
|
|
8
|
-
2. All packages were in the **same git repository** (`~gitw/calenvarek`)
|
|
9
|
-
3. Each child process had its own **in-memory mutex** (SimpleMutex)
|
|
10
|
-
4. In-memory mutexes **cannot coordinate across separate processes**
|
|
11
|
-
5. Multiple processes tried to run git operations concurrently
|
|
12
|
-
6. Git created `.git/index.lock` files, causing conflicts and hangs
|
|
13
|
-
|
|
14
|
-
## Root Cause
|
|
15
|
-
|
|
16
|
-
The `SimpleMutex` class in `src/util/mutex.ts` was designed for **single-process** synchronization. It uses in-memory state that cannot be shared between separate Node.js processes.
|
|
17
|
-
|
|
18
|
-
When `kodrdriv tree publish --parallel` spawns child processes using `exec()`, each child process:
|
|
19
|
-
- Gets its own memory space
|
|
20
|
-
- Creates its own `RepositoryMutexManager` singleton
|
|
21
|
-
- Has no way to coordinate with other processes
|
|
22
|
-
|
|
23
|
-
## Solution
|
|
24
|
-
|
|
25
|
-
Implemented a **file-based locking mechanism** in `src/util/fileLock.ts`:
|
|
26
|
-
|
|
27
|
-
### Key Features
|
|
28
|
-
|
|
29
|
-
1. **Cross-Process Safety**: Uses atomic file operations (`wx` flag) that work across processes
|
|
30
|
-
2. **Exponential Backoff**: Retries lock acquisition with increasing delays (100ms → 2000ms max)
|
|
31
|
-
3. **Stale Lock Detection**: Automatically removes locks older than 30 seconds
|
|
32
|
-
4. **Automatic Cleanup**: Releases locks on process exit (normal, SIGINT, SIGTERM, uncaughtException)
|
|
33
|
-
5. **Per-Repository Locking**: Creates `.git/kodrdriv.lock` file in each repository
|
|
34
|
-
|
|
35
|
-
### Implementation Details
|
|
36
|
-
|
|
37
|
-
#### FileLock Class
|
|
38
|
-
```typescript
|
|
39
|
-
class FileLock {
|
|
40
|
-
async lock(): Promise<void> {
|
|
41
|
-
// Attempts to create lock file atomically with 'wx' flag
|
|
42
|
-
// Retries with exponential backoff if file exists
|
|
43
|
-
// Detects and removes stale locks (>30 seconds old)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
unlock(): void {
|
|
47
|
-
// Removes lock file
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
#### RepositoryFileLockManager Class
|
|
53
|
-
```typescript
|
|
54
|
-
class RepositoryFileLockManager {
|
|
55
|
-
getRepositoryLock(repoPath: string): FileLock {
|
|
56
|
-
// Returns file lock for .git/kodrdriv.lock
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async withGitLock<T>(repoPath, operation, operationName): Promise<T> {
|
|
60
|
-
// Acquires lock, executes operation, releases lock
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Changes Made
|
|
66
|
-
|
|
67
|
-
1. **Created** `src/util/fileLock.ts` - New file-based locking implementation
|
|
68
|
-
2. **Modified** `src/util/gitMutex.ts` - Now uses FileLock instead of SimpleMutex
|
|
69
|
-
3. **No Breaking Changes** - API remains the same, only implementation changed
|
|
70
|
-
|
|
71
|
-
### How It Works
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
Parent Process (kodrdriv tree publish --parallel)
|
|
75
|
-
├── Spawns: kodrdriv publish [git-tools]
|
|
76
|
-
│ └── Tries to acquire .git/kodrdriv.lock
|
|
77
|
-
│ ✓ Success! Executes git operations
|
|
78
|
-
│ ✓ Releases lock
|
|
79
|
-
├── Spawns: kodrdriv publish [ai-service]
|
|
80
|
-
│ └── Tries to acquire .git/kodrdriv.lock
|
|
81
|
-
│ ⏳ Waits... lock file exists
|
|
82
|
-
│ ✓ Previous process released lock
|
|
83
|
-
│ ✓ Acquires lock, executes, releases
|
|
84
|
-
├── Spawns: kodrdriv publish [github-tools]
|
|
85
|
-
│ └── (same pattern)
|
|
86
|
-
└── Spawns: kodrdriv publish [kodrdriv]
|
|
87
|
-
└── (same pattern)
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Testing
|
|
91
|
-
|
|
92
|
-
- ✅ All 283 existing tests pass
|
|
93
|
-
- ✅ Build succeeds with no linter errors
|
|
94
|
-
- ✅ Lock files are automatically cleaned up on exit
|
|
95
|
-
- ✅ Stale locks (>30s) are automatically removed
|
|
96
|
-
|
|
97
|
-
## Usage
|
|
98
|
-
|
|
99
|
-
No changes needed! The fix is transparent:
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
# This now works without freezing
|
|
103
|
-
kodrdriv tree publish --parallel
|
|
104
|
-
|
|
105
|
-
# Same for other commands that use git operations
|
|
106
|
-
kodrdriv tree commit --parallel
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
## Lock File Location
|
|
110
|
-
|
|
111
|
-
Lock files are created at:
|
|
112
|
-
```
|
|
113
|
-
/path/to/repo/.git/kodrdriv.lock
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
These files:
|
|
117
|
-
- Are automatically created/removed
|
|
118
|
-
- Are gitignored (in .git directory)
|
|
119
|
-
- Are safe to manually delete if stale
|
|
120
|
-
- Contain diagnostic info (PID, timestamp, hostname)
|
|
121
|
-
|
|
122
|
-
## Performance Impact
|
|
123
|
-
|
|
124
|
-
- **Minimal overhead**: File operations are fast (microseconds)
|
|
125
|
-
- **Better than deadlock**: Small delay is better than infinite freeze
|
|
126
|
-
- **Automatic backoff**: Reduces contention with exponential delays
|
|
127
|
-
- **Stale lock cleanup**: Prevents indefinite blocking
|
|
128
|
-
|
|
129
|
-
## Future Improvements
|
|
130
|
-
|
|
131
|
-
Potential enhancements:
|
|
132
|
-
1. Make lock timeout configurable
|
|
133
|
-
2. Add lock health monitoring/metrics
|
|
134
|
-
3. Implement lock priority/queueing
|
|
135
|
-
4. Add verbose lock acquisition logging
|
|
136
|
-
|
|
137
|
-
## Verification
|
|
138
|
-
|
|
139
|
-
To verify the fix works:
|
|
140
|
-
```bash
|
|
141
|
-
cd ~gitw/calenvarek/kodrdriv
|
|
142
|
-
npm run build
|
|
143
|
-
kodrdriv tree publish --parallel --dry-run
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
The parallel execution should now proceed without freezing.
|