diff --git a/CI_REPORT.md b/CI_REPORT.md deleted file mode 100644 index ff23cb1b..00000000 --- a/CI_REPORT.md +++ /dev/null @@ -1,93 +0,0 @@ -# CI/CD Report - PR #1242: GH#1224 Fix - -## PR Overview -- **Number**: #1242 -- **Branch**: `fix/gh1224-wsl2-sqlite-wal` -- **Changes**: 421 additions, 9 deletions across 5 files -- **Status**: ✅ READY FOR REVIEW - -## Test Results Summary - -### ✅ Passed Tests (Our Changes) -| Test | Duration | Status | -|------|----------|--------| -| Test (ubuntu-latest) | 4m37s | **PASSED** ✅ | -| Test (macos-latest) | 3m34s | **PASSED** ✅ | -| Test Nix Flake | 3m4s | **PASSED** ✅ | -| Check version consistency | 7s | **PASSED** ✅ | -| Check for .beads changes | 11s | **PASSED** ✅ | - -### ⚠️ Pre-existing Failures (Unrelated) -| Test | Duration | Status | Root Cause | -|------|----------|--------|-----------| -| Test (Windows - smoke) | 2m14s | **FAILED** ❌ | Dolt module bug in `internal/storage/dolt/server.go` | -| Lint | 30s | **FAILED** ❌ | Pre-existing linting issues in other modules | - -## Detailed Analysis - -### Our Changes Impact -Our changes are isolated to the SQLite storage module: -- **Modified**: `internal/storage/sqlite/store.go` -- **New Tests**: `internal/storage/sqlite/store_wsl_test.go` -- **Integration Tests**: `test_issue_gh1224.sh`, `test_wsl2_wal.sh` - -All tests related to SQLite storage **PASSED** with no regressions. - -### Windows Build Failure -``` -Unknown field Setpgid in struct literal of type "syscall".SysProcAttr -Location: internal/storage/dolt/server.go#111 -``` -This is a pre-existing issue in the Dolt module (unrelated to our SQLite changes). - -### Lint Failures -Pre-existing issues in unrelated files: -- `cmd/bd/federation.go` - unconvert warning -- `internal/storage/dolt/server.go` - gosec warnings -- `internal/storage/dolt/credentials.go` - errcheck warnings - -Our SQLite code passes local formatting checks: ✅ - -## Test Coverage Verification - -### Unit Tests -- ✅ WSL2 Windows path detection (`/mnt/c/`, `/mnt/d/`) -- ✅ Docker Desktop bind mount detection (`/mnt/wsl/*`) -- ✅ Native WSL2 path handling (`/home/`, `/tmp/`) -- ✅ Journal mode selection logic -- ✅ Edge case handling - -All tests pass on Linux and macOS runners. - -### Daemon Tests -- ✅ acquireStartLock bounded retry loop (maxRetries=3) -- ✅ No infinite recursion when lock removal fails -- ✅ Socket readiness and health checks -- ✅ Daemon lifecycle management - -### Integration Tests -- ✅ Database creation on native filesystems -- ✅ Path detection for problematic filesystems -- ✅ Journal mode fallback mechanism - -## Conclusion - -**✅ Our implementation is correct and passes all relevant CI tests.** - -The fix successfully addresses GH#1224 by: -1. Detecting Docker Desktop bind mounts (`/mnt/wsl/*` paths) -2. Falling back to DELETE journal mode on these paths -3. Preventing WAL mode initialization failures - -The Windows and Lint failures are pre-existing issues in the Dolt module and unrelated to our changes. - -### Ready for Merge -Once the pre-existing Windows/Lint issues are resolved in separate PRs, this fix can be merged immediately as it: -- ✅ Passes all core platform tests (Linux, macOS, Nix) -- ✅ Has comprehensive test coverage -- ✅ Introduces no regressions -- ✅ Solves the reported issue - ---- -**Report Generated**: 2026-01-21 -**Tested By**: @ampcode diff --git a/FIX_SUMMARY.md b/FIX_SUMMARY.md deleted file mode 100644 index be6e8dac..00000000 --- a/FIX_SUMMARY.md +++ /dev/null @@ -1,122 +0,0 @@ -# Fix Summary: GH#1224 - Stack Overflow in bd on WSL2 with SQLite WAL Locking Error - -## Issue Description -The `bd` CLI tool crashed with a stack overflow error when running on WSL2 with a repository located on a Docker Desktop bind mount (`/mnt/wsl/docker-desktop-bind-mounts/...`). The crash occurred due to: - -1. **SQLite WAL Mode Incompatibility**: WAL mode fails with "sqlite3: locking protocol" error on network filesystems like Docker Desktop bind mounts -2. **Infinite Recursion**: When WAL mode failed, the daemon's `acquireStartLock` function could theoretically enter infinite recursion - -## Root Cause Analysis - -### Primary Issue: WAL Mode on Network Filesystems -SQLite's Write-Ahead Logging (WAL) mode requires specific filesystem semantics (especially shared memory locking) that are not available on network filesystems. The existing code detected WSL2 Windows paths (`/mnt/[a-zA-Z]/`) but did not detect Docker Desktop bind mounts (`/mnt/wsl/*`), which are also network filesystems with the same limitations. - -### Secondary Issue: Bounded Recursion -The current code in `acquireStartLock` (line 267 of daemon_autostart.go) already has proper bounds checking with `maxRetries = 3`, preventing infinite recursion. This fix was already in place. - -## Solution - -### 1. Enhanced Path Detection (internal/storage/sqlite/store.go) -- Added `wslNetworkPathPattern` regex to detect `/mnt/wsl/*` paths (Docker Desktop bind mounts) -- Expanded `isWSL2WindowsPath()` function to check for both: - - Windows filesystem mounts: `/mnt/[a-zA-Z]/` - - Network filesystem mounts: `/mnt/wsl/*` -- Optimized logic to check WSL2 environment once (cheaper /proc/version check) before path matching - -### 2. Added Comprehensive Tests -Created `internal/storage/sqlite/store_wsl_test.go` with tests for: -- Windows filesystem detection (`/mnt/c/`, `/mnt/d/`, etc.) -- Docker Desktop bind mount detection (`/mnt/wsl/docker-desktop-bind-mounts/`) -- Native WSL2 filesystem paths (allow WAL mode) -- Edge cases and path pattern matching -- Journal mode selection logic - -### 3. Integration Test -Created `test_issue_gh1224.sh` to verify: -- Database creation on native WSL2 filesystem -- Proper handling of Windows paths (when available) -- Proper handling of Docker bind mount paths (when available) - -## Changes Made - -### Modified Files -1. **internal/storage/sqlite/store.go** - - Added `wslNetworkPathPattern` regex variable - - Updated `isWSL2WindowsPath()` function - - Updated documentation with GH#1224 reference - -### New Files -1. **internal/storage/sqlite/store_wsl_test.go** - - Unit tests for WSL2 path detection - - Tests for journal mode selection - - Edge case tests - -2. **test_issue_gh1224.sh** - - Integration test script for manual verification - -3. **test_wsl2_wal.sh** - - Diagnostic script for WAL mode testing (requires sqlite3 CLI) - -## Verification - -### Test Results -- All existing tests pass (13.2s runtime for cmd/bd tests) -- New WSL2 detection tests pass (3/3) -- Docker bind mount detection tests pass -- Journal mode selection tests pass -- Daemon autostart tests confirm bounded recursion (maxRetries=3) - -### Build Status -- Successfully builds: `go build ./cmd/bd` -- No syntax errors or regressions - -## How the Fix Works - -### Before -``` -User on WSL2 with Docker bind mount (/mnt/wsl/docker-desktop-bind-mounts/...) - ↓ -bd init / bd ready / bd sync - ↓ -Database initialization (sqlite/store.go:NewWithTimeout) - ↓ -isWSL2WindowsPath() → false (only checked /mnt/[a-zA-Z]/) - ↓ -WAL mode enabled (PRAGMA journal_mode=WAL) - ↓ -Database connection fails: "sqlite3: locking protocol" - ↓ -Daemon retry loop (eventually bounded by maxRetries) - ↓ -Stack overflow / Timeout (user sees warning) -``` - -### After -``` -User on WSL2 with Docker bind mount (/mnt/wsl/docker-desktop-bind-mounts/...) - ↓ -bd init / bd ready / bd sync - ↓ -Database initialization (sqlite/store.go:NewWithTimeout) - ↓ -isWSL2WindowsPath() → true (detects /mnt/wsl/ pattern) - ↓ -WAL mode disabled (PRAGMA journal_mode=DELETE) - ↓ -Database connection succeeds - ↓ -Command executes normally -``` - -## References -- GH#1224: Stack Overflow in bd on WSL2 with SQLite WAL Locking Error -- GH#920: SQLite WAL mode on Windows filesystem mounts in WSL2 -- SQLite WAL Limitations: https://www.sqlite.org/wal.html#nfs - -## Testing Recommendations for Review -1. Run tests locally in WSL2: `go test -v ./internal/storage/sqlite -run TestIsWSL2WindowsPath` -2. Test database creation in different paths: - - Native WSL2: `/home/user/project/.beads/` - - Windows: `/mnt/c/Users/.beads/` (if available) - - Docker bind mount: `/mnt/wsl/docker-desktop-bind-mounts/.../` (if available) -3. Verify daemon starts without stack overflow or excessive retries