pushwork 2.0.0-a.sub.0 → 2.0.0-preview
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/branches.d.ts +19 -0
- package/dist/branches.d.ts.map +1 -0
- package/dist/branches.js +111 -0
- package/dist/branches.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +238 -272
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +17 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +84 -0
- package/dist/config.js.map +1 -0
- package/dist/fs-tree.d.ts +6 -0
- package/dist/fs-tree.d.ts.map +1 -0
- package/dist/fs-tree.js +99 -0
- package/dist/fs-tree.js.map +1 -0
- package/dist/ignore.d.ts +6 -0
- package/dist/ignore.d.ts.map +1 -0
- package/dist/ignore.js +74 -0
- package/dist/ignore.js.map +1 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -4
- package/dist/index.js.map +1 -1
- package/dist/log.d.ts +3 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +14 -0
- package/dist/log.js.map +1 -0
- package/dist/pushwork.d.ts +115 -0
- package/dist/pushwork.d.ts.map +1 -0
- package/dist/pushwork.js +918 -0
- package/dist/pushwork.js.map +1 -0
- package/dist/repo.d.ts +14 -0
- package/dist/repo.d.ts.map +1 -0
- package/dist/repo.js +60 -0
- package/dist/repo.js.map +1 -0
- package/dist/shapes/custom.d.ts +3 -0
- package/dist/shapes/custom.d.ts.map +1 -0
- package/dist/shapes/custom.js +57 -0
- package/dist/shapes/custom.js.map +1 -0
- package/dist/shapes/file.d.ts +20 -0
- package/dist/shapes/file.d.ts.map +1 -0
- package/dist/shapes/file.js +140 -0
- package/dist/shapes/file.js.map +1 -0
- package/dist/shapes/index.d.ts +10 -0
- package/dist/shapes/index.d.ts.map +1 -0
- package/dist/shapes/index.js +35 -0
- package/dist/shapes/index.js.map +1 -0
- package/dist/shapes/patchwork-folder.d.ts +3 -0
- package/dist/shapes/patchwork-folder.d.ts.map +1 -0
- package/dist/shapes/patchwork-folder.js +160 -0
- package/dist/shapes/patchwork-folder.js.map +1 -0
- package/dist/shapes/types.d.ts +37 -0
- package/dist/shapes/types.d.ts.map +1 -0
- package/dist/shapes/types.js +52 -0
- package/dist/shapes/types.js.map +1 -0
- package/dist/shapes/vfs.d.ts +3 -0
- package/dist/shapes/vfs.d.ts.map +1 -0
- package/dist/shapes/vfs.js +88 -0
- package/dist/shapes/vfs.js.map +1 -0
- package/dist/stash.d.ts +23 -0
- package/dist/stash.d.ts.map +1 -0
- package/dist/stash.js +118 -0
- package/dist/stash.js.map +1 -0
- package/flake.lock +128 -0
- package/flake.nix +66 -0
- package/package.json +15 -48
- package/patches/@automerge__automerge-repo@2.6.0-subduction.15.patch +26 -0
- package/pnpm-workspace.yaml +5 -0
- package/src/branches.ts +93 -0
- package/src/cli.ts +258 -408
- package/src/config.ts +64 -0
- package/src/fs-tree.ts +70 -0
- package/src/ignore.ts +33 -0
- package/src/index.ts +38 -4
- package/src/log.ts +8 -0
- package/src/pushwork.ts +1055 -0
- package/src/repo.ts +76 -0
- package/src/shapes/custom.ts +29 -0
- package/src/shapes/file.ts +115 -0
- package/src/shapes/index.ts +19 -0
- package/src/shapes/patchwork-folder.ts +156 -0
- package/src/shapes/types.ts +79 -0
- package/src/shapes/vfs.ts +93 -0
- package/src/stash.ts +106 -0
- package/test/integration/branches.test.ts +389 -0
- package/test/integration/pushwork.test.ts +547 -0
- package/test/setup.ts +29 -0
- package/test/unit/doc-shape.test.ts +612 -0
- package/tsconfig.json +2 -3
- package/vitest.config.ts +14 -0
- package/ARCHITECTURE-ACCORDING-TO-CLAUDE.md +0 -248
- package/CLAUDE.md +0 -141
- package/README.md +0 -221
- package/babel.config.js +0 -5
- package/dist/cli/commands.d.ts +0 -71
- package/dist/cli/commands.d.ts.map +0 -1
- package/dist/cli/commands.js +0 -794
- package/dist/cli/commands.js.map +0 -1
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -19
- package/dist/cli/index.js.map +0 -1
- package/dist/commands.d.ts +0 -61
- package/dist/commands.d.ts.map +0 -1
- package/dist/commands.js +0 -861
- package/dist/commands.js.map +0 -1
- package/dist/config/index.d.ts +0 -71
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -314
- package/dist/config/index.js.map +0 -1
- package/dist/core/change-detection.d.ts +0 -80
- package/dist/core/change-detection.d.ts.map +0 -1
- package/dist/core/change-detection.js +0 -523
- package/dist/core/change-detection.js.map +0 -1
- package/dist/core/config.d.ts +0 -81
- package/dist/core/config.d.ts.map +0 -1
- package/dist/core/config.js +0 -258
- package/dist/core/config.js.map +0 -1
- package/dist/core/index.d.ts +0 -6
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -6
- package/dist/core/index.js.map +0 -1
- package/dist/core/move-detection.d.ts +0 -34
- package/dist/core/move-detection.d.ts.map +0 -1
- package/dist/core/move-detection.js +0 -121
- package/dist/core/move-detection.js.map +0 -1
- package/dist/core/snapshot.d.ts +0 -105
- package/dist/core/snapshot.d.ts.map +0 -1
- package/dist/core/snapshot.js +0 -217
- package/dist/core/snapshot.js.map +0 -1
- package/dist/core/sync-engine.d.ts +0 -151
- package/dist/core/sync-engine.d.ts.map +0 -1
- package/dist/core/sync-engine.js +0 -1346
- package/dist/core/sync-engine.js.map +0 -1
- package/dist/types/config.d.ts +0 -99
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js +0 -5
- package/dist/types/config.js.map +0 -1
- package/dist/types/documents.d.ts +0 -88
- package/dist/types/documents.d.ts.map +0 -1
- package/dist/types/documents.js +0 -20
- package/dist/types/documents.js.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -4
- package/dist/types/index.js.map +0 -1
- package/dist/types/snapshot.d.ts +0 -64
- package/dist/types/snapshot.d.ts.map +0 -1
- package/dist/types/snapshot.js +0 -2
- package/dist/types/snapshot.js.map +0 -1
- package/dist/utils/content-similarity.d.ts +0 -53
- package/dist/utils/content-similarity.d.ts.map +0 -1
- package/dist/utils/content-similarity.js +0 -155
- package/dist/utils/content-similarity.js.map +0 -1
- package/dist/utils/content.d.ts +0 -10
- package/dist/utils/content.d.ts.map +0 -1
- package/dist/utils/content.js +0 -31
- package/dist/utils/content.js.map +0 -1
- package/dist/utils/directory.d.ts +0 -24
- package/dist/utils/directory.d.ts.map +0 -1
- package/dist/utils/directory.js +0 -52
- package/dist/utils/directory.js.map +0 -1
- package/dist/utils/fs.d.ts +0 -74
- package/dist/utils/fs.d.ts.map +0 -1
- package/dist/utils/fs.js +0 -248
- package/dist/utils/fs.js.map +0 -1
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -5
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/mime-types.d.ts +0 -13
- package/dist/utils/mime-types.d.ts.map +0 -1
- package/dist/utils/mime-types.js +0 -209
- package/dist/utils/mime-types.js.map +0 -1
- package/dist/utils/network-sync.d.ts +0 -36
- package/dist/utils/network-sync.d.ts.map +0 -1
- package/dist/utils/network-sync.js +0 -250
- package/dist/utils/network-sync.js.map +0 -1
- package/dist/utils/node-polyfills.d.ts +0 -9
- package/dist/utils/node-polyfills.d.ts.map +0 -1
- package/dist/utils/node-polyfills.js +0 -9
- package/dist/utils/node-polyfills.js.map +0 -1
- package/dist/utils/output.d.ts +0 -129
- package/dist/utils/output.d.ts.map +0 -1
- package/dist/utils/output.js +0 -368
- package/dist/utils/output.js.map +0 -1
- package/dist/utils/repo-factory.d.ts +0 -13
- package/dist/utils/repo-factory.d.ts.map +0 -1
- package/dist/utils/repo-factory.js +0 -46
- package/dist/utils/repo-factory.js.map +0 -1
- package/dist/utils/string-similarity.d.ts +0 -14
- package/dist/utils/string-similarity.d.ts.map +0 -1
- package/dist/utils/string-similarity.js +0 -39
- package/dist/utils/string-similarity.js.map +0 -1
- package/dist/utils/text-diff.d.ts +0 -37
- package/dist/utils/text-diff.d.ts.map +0 -1
- package/dist/utils/text-diff.js +0 -93
- package/dist/utils/text-diff.js.map +0 -1
- package/dist/utils/trace.d.ts +0 -19
- package/dist/utils/trace.d.ts.map +0 -1
- package/dist/utils/trace.js +0 -63
- package/dist/utils/trace.js.map +0 -1
- package/src/commands.ts +0 -1134
- package/src/core/change-detection.ts +0 -712
- package/src/core/config.ts +0 -313
- package/src/core/index.ts +0 -5
- package/src/core/move-detection.ts +0 -169
- package/src/core/snapshot.ts +0 -275
- package/src/core/sync-engine.ts +0 -1758
- package/src/types/config.ts +0 -111
- package/src/types/documents.ts +0 -91
- package/src/types/index.ts +0 -3
- package/src/types/snapshot.ts +0 -67
- package/src/utils/content.ts +0 -34
- package/src/utils/directory.ts +0 -73
- package/src/utils/fs.ts +0 -297
- package/src/utils/index.ts +0 -4
- package/src/utils/mime-types.ts +0 -244
- package/src/utils/network-sync.ts +0 -319
- package/src/utils/node-polyfills.ts +0 -8
- package/src/utils/output.ts +0 -450
- package/src/utils/repo-factory.ts +0 -73
- package/src/utils/string-similarity.ts +0 -54
- package/src/utils/text-diff.ts +0 -101
- package/src/utils/trace.ts +0 -70
- package/test/integration/README.md +0 -328
- package/test/integration/clone-test.sh +0 -310
- package/test/integration/conflict-resolution-test.sh +0 -309
- package/test/integration/debug-both-nested.sh +0 -74
- package/test/integration/debug-concurrent-nested.sh +0 -87
- package/test/integration/debug-nested.sh +0 -73
- package/test/integration/deletion-behavior-test.sh +0 -487
- package/test/integration/deletion-sync-test-simple.sh +0 -193
- package/test/integration/deletion-sync-test.sh +0 -297
- package/test/integration/exclude-patterns.test.ts +0 -144
- package/test/integration/full-integration-test.sh +0 -363
- package/test/integration/fuzzer.test.ts +0 -818
- package/test/integration/in-memory-sync.test.ts +0 -830
- package/test/integration/init-sync.test.ts +0 -89
- package/test/integration/manual-sync-test.sh +0 -84
- package/test/integration/sync-deletion.test.ts +0 -280
- package/test/integration/sync-flow.test.ts +0 -291
- package/test/jest.setup.ts +0 -34
- package/test/run-tests.sh +0 -225
- package/test/unit/deletion-behavior.test.ts +0 -249
- package/test/unit/enhanced-mime-detection.test.ts +0 -244
- package/test/unit/snapshot.test.ts +0 -404
- package/test/unit/sync-convergence.test.ts +0 -298
- package/test/unit/sync-timing.test.ts +0 -134
- package/test/unit/utils.test.ts +0 -366
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Conflict Resolution Test for Pushwork
|
|
4
|
-
# Tests CRDT text merging where both changes are preserved
|
|
5
|
-
|
|
6
|
-
set -e
|
|
7
|
-
|
|
8
|
-
# Colors for output
|
|
9
|
-
RED='\033[0;31m'
|
|
10
|
-
GREEN='\033[0;32m'
|
|
11
|
-
YELLOW='\033[1;33m'
|
|
12
|
-
BLUE='\033[0;34m'
|
|
13
|
-
NC='\033[0m'
|
|
14
|
-
|
|
15
|
-
# Test configuration
|
|
16
|
-
TEST_DIR="/tmp/pushwork-conflict-test"
|
|
17
|
-
PUSHWORK_CMD="node $(pwd)/dist/cli.js"
|
|
18
|
-
|
|
19
|
-
# Helper functions
|
|
20
|
-
log_info() {
|
|
21
|
-
echo -e "${BLUE}[INFO]${NC} $1"
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
log_success() {
|
|
25
|
-
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
log_error() {
|
|
29
|
-
echo -e "${RED}[ERROR]${NC} $1"
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
log_test() {
|
|
33
|
-
echo -e "${YELLOW}[TEST]${NC} $1"
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
# Cleanup function
|
|
37
|
-
cleanup() {
|
|
38
|
-
log_info "Cleaning up test directory..."
|
|
39
|
-
rm -rf "$TEST_DIR"
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
# Setup function
|
|
43
|
-
setup() {
|
|
44
|
-
log_info "Setting up conflict resolution test..."
|
|
45
|
-
|
|
46
|
-
# Build the project
|
|
47
|
-
log_info "Building pushwork..."
|
|
48
|
-
npm run build
|
|
49
|
-
|
|
50
|
-
# Clean up and create test directory
|
|
51
|
-
rm -rf "$TEST_DIR"
|
|
52
|
-
mkdir -p "$TEST_DIR"
|
|
53
|
-
cd "$TEST_DIR"
|
|
54
|
-
|
|
55
|
-
log_info "Test directory: $TEST_DIR"
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
# Create initial repository with a test file
|
|
59
|
-
create_initial_repo() {
|
|
60
|
-
log_info "=== Creating Initial Repository ==="
|
|
61
|
-
|
|
62
|
-
mkdir alice-repo
|
|
63
|
-
cd alice-repo
|
|
64
|
-
|
|
65
|
-
# Create a simple test file
|
|
66
|
-
cat > document.txt << EOF
|
|
67
|
-
Original content
|
|
68
|
-
This is the baseline version.
|
|
69
|
-
EOF
|
|
70
|
-
|
|
71
|
-
log_test "Initializing Alice's repository"
|
|
72
|
-
$PUSHWORK_CMD init .
|
|
73
|
-
|
|
74
|
-
cd ..
|
|
75
|
-
log_success "Alice's repository created"
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
# Clone the repository
|
|
79
|
-
clone_repository() {
|
|
80
|
-
log_info "=== Cloning Repository ==="
|
|
81
|
-
|
|
82
|
-
cd alice-repo
|
|
83
|
-
ROOT_URL=$($PUSHWORK_CMD url .)
|
|
84
|
-
cd ..
|
|
85
|
-
|
|
86
|
-
log_test "Cloning repository for Bob"
|
|
87
|
-
$PUSHWORK_CMD clone "$ROOT_URL" bob-repo
|
|
88
|
-
|
|
89
|
-
log_success "Repository cloned successfully"
|
|
90
|
-
|
|
91
|
-
# Verify initial content is identical
|
|
92
|
-
if cmp -s alice-repo/document.txt bob-repo/document.txt; then
|
|
93
|
-
log_success "Initial content is identical"
|
|
94
|
-
else
|
|
95
|
-
log_error "Initial content differs between repositories"
|
|
96
|
-
exit 1
|
|
97
|
-
fi
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
# Make conflicting edits
|
|
101
|
-
make_conflicting_edits() {
|
|
102
|
-
log_info "=== Making Conflicting Edits ==="
|
|
103
|
-
|
|
104
|
-
# Alice's changes
|
|
105
|
-
log_test "Alice adds her content"
|
|
106
|
-
cd alice-repo
|
|
107
|
-
cat >> document.txt << EOF
|
|
108
|
-
Alice's addition: New feature implementation
|
|
109
|
-
Alice's note: This adds user authentication
|
|
110
|
-
EOF
|
|
111
|
-
|
|
112
|
-
log_info "Alice's document:"
|
|
113
|
-
cat document.txt
|
|
114
|
-
echo ""
|
|
115
|
-
cd ..
|
|
116
|
-
|
|
117
|
-
# Bob's changes
|
|
118
|
-
log_test "Bob adds different content"
|
|
119
|
-
cd bob-repo
|
|
120
|
-
cat >> document.txt << EOF
|
|
121
|
-
Bob's addition: Performance optimization
|
|
122
|
-
Bob's note: This improves response time
|
|
123
|
-
EOF
|
|
124
|
-
|
|
125
|
-
log_info "Bob's document:"
|
|
126
|
-
cat document.txt
|
|
127
|
-
echo ""
|
|
128
|
-
cd ..
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
# Test conflict resolution
|
|
132
|
-
test_conflict_resolution() {
|
|
133
|
-
log_info "=== Testing CRDT Conflict Resolution ==="
|
|
134
|
-
|
|
135
|
-
# Alice syncs first
|
|
136
|
-
log_test "Alice syncs first"
|
|
137
|
-
cd alice-repo
|
|
138
|
-
$PUSHWORK_CMD sync
|
|
139
|
-
log_success "Alice's changes synced"
|
|
140
|
-
cd ..
|
|
141
|
-
|
|
142
|
-
# Bob syncs (this will merge with Alice's changes)
|
|
143
|
-
log_test "Bob syncs (CRDT merging will occur)"
|
|
144
|
-
cd bob-repo
|
|
145
|
-
$PUSHWORK_CMD sync
|
|
146
|
-
log_success "Bob's sync completed"
|
|
147
|
-
cd ..
|
|
148
|
-
|
|
149
|
-
# Multiple sync rounds needed for full CRDT convergence
|
|
150
|
-
log_test "Alice syncs again to get Bob's changes"
|
|
151
|
-
cd alice-repo
|
|
152
|
-
$PUSHWORK_CMD sync
|
|
153
|
-
cd ..
|
|
154
|
-
|
|
155
|
-
log_test "Bob syncs to pull merged result"
|
|
156
|
-
cd bob-repo
|
|
157
|
-
$PUSHWORK_CMD sync
|
|
158
|
-
cd ..
|
|
159
|
-
|
|
160
|
-
log_test "Alice syncs final time for convergence"
|
|
161
|
-
cd alice-repo
|
|
162
|
-
$PUSHWORK_CMD sync
|
|
163
|
-
cd ..
|
|
164
|
-
|
|
165
|
-
log_test "Bob syncs final time to ensure consistency"
|
|
166
|
-
cd bob-repo
|
|
167
|
-
$PUSHWORK_CMD sync
|
|
168
|
-
cd ..
|
|
169
|
-
|
|
170
|
-
log_success "All sync operations completed - CRDT convergence achieved"
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
# Verify conflict resolution results
|
|
174
|
-
verify_resolution_results() {
|
|
175
|
-
log_info "=== Verifying CRDT Merge Results ==="
|
|
176
|
-
|
|
177
|
-
# Check what Alice has
|
|
178
|
-
log_test "Alice's final content:"
|
|
179
|
-
ALICE_CONTENT=$(cat alice-repo/document.txt)
|
|
180
|
-
cat alice-repo/document.txt
|
|
181
|
-
echo ""
|
|
182
|
-
|
|
183
|
-
# Check what Bob has
|
|
184
|
-
log_test "Bob's final content:"
|
|
185
|
-
BOB_CONTENT=$(cat bob-repo/document.txt)
|
|
186
|
-
cat bob-repo/document.txt
|
|
187
|
-
echo ""
|
|
188
|
-
|
|
189
|
-
# Verify both users' changes are preserved somewhere
|
|
190
|
-
BOTH_ALICE_AND_BOB_PRESERVED=false
|
|
191
|
-
|
|
192
|
-
# Check if at least one repository has both Alice's and Bob's changes
|
|
193
|
-
if (echo "$ALICE_CONTENT" | grep -q "Alice's addition" && echo "$ALICE_CONTENT" | grep -q "Bob's addition") || \
|
|
194
|
-
(echo "$BOB_CONTENT" | grep -q "Alice's addition" && echo "$BOB_CONTENT" | grep -q "Bob's addition"); then
|
|
195
|
-
BOTH_ALICE_AND_BOB_PRESERVED=true
|
|
196
|
-
log_success "✅ Both Alice's and Bob's changes are preserved via CRDT merging"
|
|
197
|
-
fi
|
|
198
|
-
|
|
199
|
-
# Check if repositories eventually converge to the same state
|
|
200
|
-
if cmp -s alice-repo/document.txt bob-repo/document.txt; then
|
|
201
|
-
log_success "✅ Both repositories have converged to identical content"
|
|
202
|
-
if [ "$BOTH_ALICE_AND_BOB_PRESERVED" = true ]; then
|
|
203
|
-
log_success "✅ Perfect CRDT behavior: Both changes preserved and repositories consistent"
|
|
204
|
-
fi
|
|
205
|
-
else
|
|
206
|
-
log_error "❌ Repositories still have different content after multiple sync rounds"
|
|
207
|
-
echo "This indicates a sync propagation bug in pushwork"
|
|
208
|
-
echo ""
|
|
209
|
-
echo "Alice's content:"
|
|
210
|
-
cat alice-repo/document.txt
|
|
211
|
-
echo ""
|
|
212
|
-
echo "Bob's content:"
|
|
213
|
-
cat bob-repo/document.txt
|
|
214
|
-
echo ""
|
|
215
|
-
|
|
216
|
-
# Check if at least one has both changes
|
|
217
|
-
if [ "$BOTH_ALICE_AND_BOB_PRESERVED" = true ]; then
|
|
218
|
-
log_info "✅ CRDT merging is working (both changes preserved somewhere)"
|
|
219
|
-
log_info "❌ But sync propagation is incomplete - this is a bug to fix"
|
|
220
|
-
else
|
|
221
|
-
log_error "❌ Critical: Changes may have been lost completely"
|
|
222
|
-
exit 1
|
|
223
|
-
fi
|
|
224
|
-
fi
|
|
225
|
-
|
|
226
|
-
# Detailed verification
|
|
227
|
-
if echo "$ALICE_CONTENT" | grep -q "Alice's addition" || echo "$BOB_CONTENT" | grep -q "Alice's addition"; then
|
|
228
|
-
log_success "✅ Alice's changes preserved"
|
|
229
|
-
else
|
|
230
|
-
log_error "❌ Alice's changes lost"
|
|
231
|
-
exit 1
|
|
232
|
-
fi
|
|
233
|
-
|
|
234
|
-
if echo "$ALICE_CONTENT" | grep -q "Bob's addition" || echo "$BOB_CONTENT" | grep -q "Bob's addition"; then
|
|
235
|
-
log_success "✅ Bob's changes preserved"
|
|
236
|
-
else
|
|
237
|
-
log_error "❌ Bob's changes lost"
|
|
238
|
-
exit 1
|
|
239
|
-
fi
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
# Show final results
|
|
243
|
-
show_results() {
|
|
244
|
-
log_info "=== Final Results ==="
|
|
245
|
-
|
|
246
|
-
echo ""
|
|
247
|
-
echo "Alice's final document:"
|
|
248
|
-
echo "=============================="
|
|
249
|
-
cat alice-repo/document.txt
|
|
250
|
-
echo "=============================="
|
|
251
|
-
echo ""
|
|
252
|
-
|
|
253
|
-
echo "Bob's final document:"
|
|
254
|
-
echo "=============================="
|
|
255
|
-
cat bob-repo/document.txt
|
|
256
|
-
echo "=============================="
|
|
257
|
-
|
|
258
|
-
log_success "✅ CRDT conflict resolution test completed successfully!"
|
|
259
|
-
echo ""
|
|
260
|
-
echo "Key findings:"
|
|
261
|
-
echo "• Pushwork uses CRDT-based conflict resolution ✅"
|
|
262
|
-
echo "• Both users' changes are preserved through merging ✅"
|
|
263
|
-
echo "• No data loss occurs during conflicts ✅"
|
|
264
|
-
echo "• Text content is merged at the character level ✅"
|
|
265
|
-
echo "• Sync timing issue has been FIXED ✅"
|
|
266
|
-
echo ""
|
|
267
|
-
echo "Technical details:"
|
|
268
|
-
echo "• Fresh remote state detection after network sync ✅"
|
|
269
|
-
echo "• Proper CRDT merge propagation ✅"
|
|
270
|
-
echo "• Immediate convergence to consistent state ✅"
|
|
271
|
-
echo "• Both repositories end up identical ✅"
|
|
272
|
-
echo ""
|
|
273
|
-
echo "This demonstrates excellent collaborative editing capabilities!"
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
# Main test execution
|
|
277
|
-
main() {
|
|
278
|
-
echo "=========================================="
|
|
279
|
-
echo "Pushwork CRDT Conflict Resolution Test"
|
|
280
|
-
echo "=========================================="
|
|
281
|
-
echo ""
|
|
282
|
-
echo "This test validates that:"
|
|
283
|
-
echo "1. Multiple users can edit the same file simultaneously"
|
|
284
|
-
echo "2. Conflicts are resolved through CRDT merging"
|
|
285
|
-
echo "3. Both users' changes are preserved"
|
|
286
|
-
echo "4. No data loss occurs during conflict resolution"
|
|
287
|
-
echo "5. Repositories eventually reach consistent state"
|
|
288
|
-
echo ""
|
|
289
|
-
|
|
290
|
-
# Trap cleanup on exit
|
|
291
|
-
trap cleanup EXIT
|
|
292
|
-
|
|
293
|
-
# Run the test
|
|
294
|
-
setup
|
|
295
|
-
create_initial_repo
|
|
296
|
-
clone_repository
|
|
297
|
-
make_conflicting_edits
|
|
298
|
-
test_conflict_resolution
|
|
299
|
-
verify_resolution_results
|
|
300
|
-
show_results
|
|
301
|
-
|
|
302
|
-
echo ""
|
|
303
|
-
echo "=========================================="
|
|
304
|
-
echo "🎉 CRDT Conflict Resolution Test PASSED! 🎉"
|
|
305
|
-
echo "=========================================="
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
# Run the test
|
|
309
|
-
main "$@"
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
# Get absolute path to pushwork CLI
|
|
5
|
-
PUSHWORK_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
6
|
-
PUSHWORK_CLI="$PUSHWORK_ROOT/dist/cli.js"
|
|
7
|
-
|
|
8
|
-
echo "=== Creating test repos ==="
|
|
9
|
-
TESTDIR=$(mktemp -d)
|
|
10
|
-
REPO_A="$TESTDIR/repo-a"
|
|
11
|
-
REPO_B="$TESTDIR/repo-b"
|
|
12
|
-
mkdir -p "$REPO_A" "$REPO_B"
|
|
13
|
-
|
|
14
|
-
echo "=== Initializing repo A with a file ==="
|
|
15
|
-
echo "initial" > "$REPO_A/initial.txt"
|
|
16
|
-
cd "$REPO_A"
|
|
17
|
-
node "$PUSHWORK_CLI" init .
|
|
18
|
-
|
|
19
|
-
echo ""
|
|
20
|
-
echo "=== Cloning to repo B ==="
|
|
21
|
-
ROOT_URL=$(node "$PUSHWORK_CLI" url)
|
|
22
|
-
echo "Root URL: $ROOT_URL"
|
|
23
|
-
cd "$TESTDIR"
|
|
24
|
-
node "$PUSHWORK_CLI" clone "$ROOT_URL" "$REPO_B"
|
|
25
|
-
|
|
26
|
-
echo ""
|
|
27
|
-
echo "=== On A: Try to editAndRename non-existent file ==="
|
|
28
|
-
# This should be a no-op since tmjaz/namelye.txt doesn't exist
|
|
29
|
-
echo "(This is a no-op since source doesn't exist)"
|
|
30
|
-
|
|
31
|
-
echo ""
|
|
32
|
-
echo "=== On B: Create file in 2-level nested subdirectory ==="
|
|
33
|
-
mkdir -p "$REPO_B/rlpjug/ewsv"
|
|
34
|
-
echo "" > "$REPO_B/rlpjug/ewsv/sneked.txt"
|
|
35
|
-
|
|
36
|
-
echo ""
|
|
37
|
-
echo "=== Sync round 1: A ==="
|
|
38
|
-
cd "$REPO_A"
|
|
39
|
-
node "$PUSHWORK_CLI" sync
|
|
40
|
-
|
|
41
|
-
echo ""
|
|
42
|
-
echo "=== Sync round 1: B ==="
|
|
43
|
-
cd "$REPO_B"
|
|
44
|
-
node "$PUSHWORK_CLI" sync
|
|
45
|
-
|
|
46
|
-
echo ""
|
|
47
|
-
echo "=== Sync round 2: A ==="
|
|
48
|
-
cd "$REPO_A"
|
|
49
|
-
node "$PUSHWORK_CLI" sync
|
|
50
|
-
|
|
51
|
-
echo ""
|
|
52
|
-
echo "=== Sync round 2: B ==="
|
|
53
|
-
cd "$REPO_B"
|
|
54
|
-
node "$PUSHWORK_CLI" sync
|
|
55
|
-
|
|
56
|
-
echo ""
|
|
57
|
-
echo "=== Verification ==="
|
|
58
|
-
echo "Files in A:"
|
|
59
|
-
find "$REPO_A" -type f \( -name "*.txt" -o -name "*.md" \) | grep -v "\.pushwork" | sed "s|$REPO_A/||" | sort
|
|
60
|
-
|
|
61
|
-
echo ""
|
|
62
|
-
echo "Files in B:"
|
|
63
|
-
find "$REPO_B" -type f \( -name "*.txt" -o -name "*.md" \) | grep -v "\.pushwork" | sed "s|$REPO_B/||" | sort
|
|
64
|
-
|
|
65
|
-
echo ""
|
|
66
|
-
if [ -f "$REPO_A/rlpjug/ewsv/sneked.txt" ]; then
|
|
67
|
-
echo "✅ SUCCESS: B's nested file synced to A"
|
|
68
|
-
else
|
|
69
|
-
echo "❌ FAILURE: B's nested file did NOT sync to A"
|
|
70
|
-
fi
|
|
71
|
-
|
|
72
|
-
echo ""
|
|
73
|
-
echo "Test directory: $TESTDIR"
|
|
74
|
-
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
# Get absolute path to pushwork CLI
|
|
5
|
-
PUSHWORK_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
6
|
-
PUSHWORK_CLI="$PUSHWORK_ROOT/dist/cli.js"
|
|
7
|
-
|
|
8
|
-
echo "=== Creating test repos ==="
|
|
9
|
-
TESTDIR=$(mktemp -d)
|
|
10
|
-
REPO_A="$TESTDIR/repo-a"
|
|
11
|
-
REPO_B="$TESTDIR/repo-b"
|
|
12
|
-
mkdir -p "$REPO_A" "$REPO_B"
|
|
13
|
-
|
|
14
|
-
echo "=== Initializing repo A with a file ==="
|
|
15
|
-
echo "initial" > "$REPO_A/initial.txt"
|
|
16
|
-
cd "$REPO_A"
|
|
17
|
-
node "$PUSHWORK_CLI" init .
|
|
18
|
-
|
|
19
|
-
echo ""
|
|
20
|
-
echo "=== Cloning to repo B ==="
|
|
21
|
-
ROOT_URL=$(node "$PUSHWORK_CLI" url)
|
|
22
|
-
echo "Root URL: $ROOT_URL"
|
|
23
|
-
cd "$TESTDIR"
|
|
24
|
-
node "$PUSHWORK_CLI" clone "$ROOT_URL" "$REPO_B"
|
|
25
|
-
|
|
26
|
-
echo ""
|
|
27
|
-
echo "=== On A: Create file in nested directory dirA/subA ==="
|
|
28
|
-
mkdir -p "$REPO_A/dirA/subA"
|
|
29
|
-
echo "from A" > "$REPO_A/dirA/subA/fileA.txt"
|
|
30
|
-
|
|
31
|
-
echo ""
|
|
32
|
-
echo "=== On B: Create file in different nested directory dirB/subB ==="
|
|
33
|
-
mkdir -p "$REPO_B/dirB/subB"
|
|
34
|
-
echo "from B" > "$REPO_B/dirB/subB/fileB.txt"
|
|
35
|
-
|
|
36
|
-
echo ""
|
|
37
|
-
echo "=== Sync round 1: A (push A's nested file) ==="
|
|
38
|
-
cd "$REPO_A"
|
|
39
|
-
node "$PUSHWORK_CLI" sync
|
|
40
|
-
|
|
41
|
-
echo ""
|
|
42
|
-
echo "=== Sync round 1: B (push B's nested file, pull A's) ==="
|
|
43
|
-
cd "$REPO_B"
|
|
44
|
-
node "$PUSHWORK_CLI" sync
|
|
45
|
-
|
|
46
|
-
echo ""
|
|
47
|
-
echo "=== Sync round 2: A (pull B's nested file) ==="
|
|
48
|
-
cd "$REPO_A"
|
|
49
|
-
node "$PUSHWORK_CLI" sync
|
|
50
|
-
|
|
51
|
-
echo ""
|
|
52
|
-
echo "=== Sync round 2: B (confirm) ==="
|
|
53
|
-
cd "$REPO_B"
|
|
54
|
-
node "$PUSHWORK_CLI" sync
|
|
55
|
-
|
|
56
|
-
echo ""
|
|
57
|
-
echo "=== Verification ==="
|
|
58
|
-
echo "Files in A:"
|
|
59
|
-
find "$REPO_A" -type f \( -name "*.txt" -o -name "*.md" \) | grep -v "\.pushwork" | sed "s|$REPO_A/||" | sort
|
|
60
|
-
|
|
61
|
-
echo ""
|
|
62
|
-
echo "Files in B:"
|
|
63
|
-
find "$REPO_B" -type f \( -name "*.txt" -o -name "*.md" \) | grep -v "\.pushwork" | sed "s|$REPO_B/||" | sort
|
|
64
|
-
|
|
65
|
-
echo ""
|
|
66
|
-
echo "Checking convergence:"
|
|
67
|
-
A_HAS_A=$([ -f "$REPO_A/dirA/subA/fileA.txt" ] && echo YES || echo NO)
|
|
68
|
-
A_HAS_B=$([ -f "$REPO_A/dirB/subB/fileB.txt" ] && echo YES || echo NO)
|
|
69
|
-
B_HAS_A=$([ -f "$REPO_B/dirA/subA/fileA.txt" ] && echo YES || echo NO)
|
|
70
|
-
B_HAS_B=$([ -f "$REPO_B/dirB/subB/fileB.txt" ] && echo YES || echo NO)
|
|
71
|
-
|
|
72
|
-
echo " A has its own file (dirA/subA/fileA.txt): $A_HAS_A"
|
|
73
|
-
echo " A has B's file (dirB/subB/fileB.txt): $A_HAS_B"
|
|
74
|
-
echo " B has A's file (dirA/subA/fileA.txt): $B_HAS_A"
|
|
75
|
-
echo " B has its own file (dirB/subB/fileB.txt): $B_HAS_B"
|
|
76
|
-
|
|
77
|
-
if [ "$A_HAS_A" = "YES" ] && [ "$A_HAS_B" = "YES" ] && [ "$B_HAS_A" = "YES" ] && [ "$B_HAS_B" = "YES" ]; then
|
|
78
|
-
echo ""
|
|
79
|
-
echo "✅ SUCCESS: Both nested files synced correctly!"
|
|
80
|
-
else
|
|
81
|
-
echo ""
|
|
82
|
-
echo "❌ FAILURE: Not all files synced"
|
|
83
|
-
fi
|
|
84
|
-
|
|
85
|
-
echo ""
|
|
86
|
-
echo "Test directory: $TESTDIR"
|
|
87
|
-
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
# Get absolute path to pushwork CLI
|
|
5
|
-
PUSHWORK_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
6
|
-
PUSHWORK_CLI="$PUSHWORK_ROOT/dist/cli.js"
|
|
7
|
-
|
|
8
|
-
echo "=== Creating test repos ==="
|
|
9
|
-
TESTDIR=$(mktemp -d)
|
|
10
|
-
REPO_A="$TESTDIR/repo-a"
|
|
11
|
-
REPO_B="$TESTDIR/repo-b"
|
|
12
|
-
mkdir -p "$REPO_A" "$REPO_B"
|
|
13
|
-
|
|
14
|
-
echo "=== Initializing repo A with a file ==="
|
|
15
|
-
echo "initial" > "$REPO_A/initial.txt"
|
|
16
|
-
cd "$REPO_A"
|
|
17
|
-
node "$PUSHWORK_CLI" init .
|
|
18
|
-
|
|
19
|
-
echo ""
|
|
20
|
-
echo "=== Cloning to repo B ==="
|
|
21
|
-
ROOT_URL=$(node "$PUSHWORK_CLI" url)
|
|
22
|
-
echo "Root URL: $ROOT_URL"
|
|
23
|
-
cd "$TESTDIR"
|
|
24
|
-
node "$PUSHWORK_CLI" clone "$ROOT_URL" "$REPO_B"
|
|
25
|
-
|
|
26
|
-
echo ""
|
|
27
|
-
echo "=== On B: Create file in 2-level nested subdirectory ==="
|
|
28
|
-
mkdir -p "$REPO_B/rlpjug/ewsv"
|
|
29
|
-
echo "" > "$REPO_B/rlpjug/ewsv/sneked.txt"
|
|
30
|
-
|
|
31
|
-
echo ""
|
|
32
|
-
echo "=== Sync round 1: A (no changes) ==="
|
|
33
|
-
cd "$REPO_A"
|
|
34
|
-
node "$PUSHWORK_CLI" sync
|
|
35
|
-
|
|
36
|
-
echo ""
|
|
37
|
-
echo "=== Sync round 1: B (push new nested file) ==="
|
|
38
|
-
cd "$REPO_B"
|
|
39
|
-
node "$PUSHWORK_CLI" sync
|
|
40
|
-
|
|
41
|
-
echo ""
|
|
42
|
-
echo "=== Sync round 2: A (pull B's changes) ==="
|
|
43
|
-
cd "$REPO_A"
|
|
44
|
-
node "$PUSHWORK_CLI" sync
|
|
45
|
-
|
|
46
|
-
echo ""
|
|
47
|
-
echo "=== Sync round 2: B (confirm) ==="
|
|
48
|
-
cd "$REPO_B"
|
|
49
|
-
node "$PUSHWORK_CLI" sync
|
|
50
|
-
|
|
51
|
-
echo ""
|
|
52
|
-
echo "=== Verification ==="
|
|
53
|
-
echo "Files in A:"
|
|
54
|
-
find "$REPO_A" -type f \( -name "*.txt" -o -name "*.md" \) | grep -v "\.pushwork" | sed "s|$REPO_A/||" | sort
|
|
55
|
-
|
|
56
|
-
echo ""
|
|
57
|
-
echo "Files in B:"
|
|
58
|
-
find "$REPO_B" -type f \( -name "*.txt" -o -name "*.md" \) | grep -v "\.pushwork" | sed "s|$REPO_B/||" | sort
|
|
59
|
-
|
|
60
|
-
echo ""
|
|
61
|
-
if [ -f "$REPO_A/rlpjug/ewsv/sneked.txt" ]; then
|
|
62
|
-
echo "✅ SUCCESS: Nested file synced to A"
|
|
63
|
-
else
|
|
64
|
-
echo "❌ FAILURE: Nested file did NOT sync to A"
|
|
65
|
-
echo ""
|
|
66
|
-
echo "Let's check if directories exist:"
|
|
67
|
-
echo "A has rlpjug dir: $([ -d "$REPO_A/rlpjug" ] && echo YES || echo NO)"
|
|
68
|
-
echo "A has rlpjug/ewsv dir: $([ -d "$REPO_A/rlpjug/ewsv" ] && echo YES || echo NO)"
|
|
69
|
-
fi
|
|
70
|
-
|
|
71
|
-
echo ""
|
|
72
|
-
echo "Test directory: $TESTDIR"
|
|
73
|
-
|