taskchampion-rb 0.2.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.
@@ -0,0 +1,482 @@
1
+ 🎯 Phase 3 Overview
2
+
3
+ With the core ThreadBound architecture working and clean compilation achieved, Phase 3 focuses on:
4
+
5
+ 1. Completing missing method registrations (mutable methods in Operations)
6
+ 2. Implementing missing classes (WorkingSet, DependencyMap, Status, AccessMode)
7
+ 3. Adding comprehensive method coverage for all classes
8
+ 4. Ensuring Ruby-idiomatic API design
9
+ 5. Basic integration testing
10
+
11
+ 3.1: Fix Remaining Method Registration Issues
12
+
13
+ Priority: HIGHTimeline: 1 dayCurrent Issue: Mutable methods in Operations class fail registration
14
+
15
+ 3.1.1: Resolve Mutable Method Registration
16
+
17
+ Problem: Methods like push and clear that take &mut self don't register with method! macro in Magnus 0.7.
18
+
19
+ Files Affected:
20
+ - ext/taskchampion/src/operations.rs - Lines 90-92, 101
21
+
22
+ Current Error Pattern:
23
+ error[E0599]: the method `call_handle_error` exists for fn item `fn(&mut Operations, &Operation) -> Result<(), Error>
24
+ {...::push}`, but its trait bounds were not satisfied
25
+
26
+ Research Tasks:
27
+ - Research Magnus 0.7 patterns for mutable methods
28
+ - Check if different trait imports are needed
29
+ - Investigate alternative registration approaches
30
+ - Test with simplified mutable method signatures
31
+
32
+ Fallback Strategy:
33
+ If mutable methods can't be registered directly:
34
+ - Create wrapper methods that return new instances instead of mutating
35
+ - Use internal mutability patterns with RefCell if needed
36
+ - Document limitations and plan for future Magnus versions
37
+
38
+ 3.1.2: Complete Operations API
39
+
40
+ Goal: Full Operations class functionality
41
+
42
+ Methods to implement:
43
+ operations = Operations.new
44
+ operations.push(operation) # Add operation
45
+ operations << operation # Alias for push
46
+ operations.clear # Clear all operations
47
+ operations.length # Count operations
48
+ operations[index] # Get operation by index
49
+ operations.each {|op| ... } # Iterate operations
50
+
51
+ Success Criteria:
52
+ - All Operations methods work without errors
53
+ - Ruby-idiomatic API (<<, each, [])
54
+ - Proper error handling for edge cases
55
+
56
+ 3.2: Implement Missing Core Classes
57
+
58
+ Priority: HIGHTimeline: 2-3 daysCurrent Status: Classes exist but not fully implemented
59
+
60
+ 3.2.1: Complete Status Class
61
+
62
+ Current File: ext/taskchampion/src/status.rsCurrent State: Basic enum, needs method registration
63
+
64
+ TaskChampion Status Values:
65
+ - Pending - Task is pending
66
+ - Completed - Task is completed
67
+ - Deleted - Task is deleted
68
+ - Recurring - Task is recurring
69
+
70
+ Ruby API Design:
71
+ # Class methods
72
+ Status.pending # => Status instance
73
+ Status.completed # => Status instance
74
+ Status.deleted # => Status instance
75
+
76
+ # Instance methods
77
+ status.pending? # => boolean
78
+ status.completed? # => boolean
79
+ status.to_s # => "pending"
80
+ status.inspect # => "#<Taskchampion::Status:pending>"
81
+
82
+ Implementation Tasks:
83
+ - Add constructor methods (pending, completed, etc.)
84
+ - Add predicate methods (pending?, completed?, etc.)
85
+ - Add string conversion methods
86
+ - Add equality and hash methods
87
+ - Register all methods properly
88
+
89
+ 3.2.2: Complete AccessMode Class
90
+
91
+ Current File: ext/taskchampion/src/access_mode.rsCurrent State: Basic enum, needs method registration
92
+
93
+ TaskChampion AccessMode Values:
94
+ - ReadOnly - Read-only access to replica
95
+ - ReadWrite - Read-write access to replica
96
+
97
+ Ruby API Design:
98
+ # Class methods
99
+ AccessMode.read_only # => AccessMode instance
100
+ AccessMode.read_write # => AccessMode instance
101
+
102
+ # Instance methods
103
+ mode.read_only? # => boolean
104
+ mode.read_write? # => boolean
105
+ mode.to_s # => "read_only"
106
+
107
+ Implementation Tasks:
108
+ - Add constructor methods
109
+ - Add predicate methods
110
+ - Add string conversion
111
+ - Register all methods
112
+
113
+ 3.2.3: Implement WorkingSet Class
114
+
115
+ Current File: Create ext/taskchampion/src/working_set.rsCurrent State: Missing - needs full implementation
116
+
117
+ TaskChampion WorkingSet: Manages the current set of tasks being worked on.
118
+
119
+ Ruby API Design:
120
+ working_set = replica.working_set
121
+ working_set.largest_index # => Integer
122
+ working_set.by_index(1) # => Task or nil
123
+ working_set.by_uuid(uuid) # => Integer or nil
124
+ working_set.renumber # Renumber tasks
125
+
126
+ Implementation Tasks:
127
+ - Create WorkingSet struct with ThreadBound wrapper
128
+ - Implement largest_index method
129
+ - Implement by_index method
130
+ - Implement by_uuid method
131
+ - Implement renumber method
132
+ - Add to module registration in lib.rs
133
+
134
+ 3.2.4: Implement DependencyMap Class
135
+
136
+ Current File: Create ext/taskchampion/src/dependency_map.rsCurrent State: Missing - needs full implementation
137
+
138
+ TaskChampion DependencyMap: Tracks task dependencies and relationships.
139
+
140
+ Ruby API Design:
141
+ dep_map = replica.dependency_map
142
+ dep_map.dependencies(uuid) # => Array of UUIDs
143
+ dep_map.dependents(uuid) # => Array of UUIDs
144
+ dep_map.has_dependency?(uuid) # => boolean
145
+
146
+ Implementation Tasks:
147
+ - Create DependencyMap struct with ThreadBound wrapper
148
+ - Implement dependencies method
149
+ - Implement dependents method
150
+ - Implement has_dependency? method
151
+ - Add to module registration in lib.rs
152
+
153
+ 3.3: Complete Existing Class APIs
154
+
155
+ Priority: MEDIUMTimeline: 2 daysCurrent State: Basic methods implemented, many missing
156
+
157
+ 3.3.1: Complete Task Class API
158
+
159
+ Current File: ext/taskchampion/src/task.rsCurrent State: Read methods implemented, mutation methods stubbed
160
+
161
+ Missing Methods:
162
+ # Task modification (these currently return NotImplementedError)
163
+ task.set_description(desc)
164
+ task.set_status(status, operations)
165
+ task.set_priority(priority, operations)
166
+ task.add_tag(tag, operations)
167
+ task.remove_tag(tag, operations)
168
+ task.add_annotation(annotation, operations)
169
+ task.set_due(datetime, operations)
170
+ task.set_value(property, value, operations)
171
+ task.set_uda(namespace, key, value, operations)
172
+ task.delete_uda(namespace, key, operations)
173
+
174
+ Implementation Strategy:
175
+ All mutation methods require Operations parameter since they modify task state.
176
+
177
+ Tasks:
178
+ - Implement set_description method
179
+ - Implement set_status method
180
+ - Implement set_priority method
181
+ - Implement tag manipulation methods
182
+ - Implement annotation methods
183
+ - Implement UDA (User Defined Attributes) methods
184
+ - Implement date/time property methods
185
+ - Add proper error handling and validation
186
+
187
+ 3.3.2: Complete Replica Class API
188
+
189
+ Current File: ext/taskchampion/src/replica.rsCurrent State: Basic methods implemented, sync methods missing
190
+
191
+ Missing Methods:
192
+ # Task manipulation
193
+ replica.create_task(uuid, operations) # Currently stubbed
194
+ replica.commit_operations(operations) # Missing
195
+
196
+ # Synchronization
197
+ replica.sync_to_local(server_dir, avoid_snapshots: false)
198
+ replica.sync_to_remote(url:, client_id:, encryption_secret:, avoid_snapshots: false)
199
+ replica.sync_to_gcp(bucket:, credential_path:, encryption_secret:, avoid_snapshots: false)
200
+
201
+ # Storage management
202
+ replica.rebuild_working_set # Missing
203
+ replica.num_local_operations # Missing
204
+ replica.num_undo_points # Missing
205
+
206
+ Tasks:
207
+ - Complete create_task implementation
208
+ - Implement commit_operations
209
+ - Implement sync methods (local, remote, GCP)
210
+ - Add storage management methods
211
+ - Add proper keyword argument handling for sync methods
212
+
213
+ 3.3.3: Enhance Operation Class API
214
+
215
+ Current File: ext/taskchampion/src/operation.rsCurrent State: Basic implementation, needs completion
216
+
217
+ Ruby API Design:
218
+ # Operation introspection
219
+ operation.operation_type # => Symbol (:create, :update, :delete)
220
+ operation.uuid # => String (task UUID)
221
+ operation.property # => String or nil
222
+ operation.value # => String or nil
223
+ operation.old_value # => String or nil
224
+ operation.timestamp # => Time
225
+
226
+ # String representation
227
+ operation.to_s # => Human readable string
228
+ operation.inspect # => Debug representation
229
+
230
+ Tasks:
231
+ - Add operation type detection
232
+ - Add property access methods
233
+ - Add timestamp conversion
234
+ - Improve string representations
235
+
236
+ 3.4: Ruby-Idiomatic API Polish
237
+
238
+ Priority: MEDIUMTimeline: 1 dayGoal: Ensure API follows Ruby conventions
239
+
240
+ 3.4.1: Method Naming Conventions
241
+
242
+ Ruby Conventions to Follow:
243
+ # Good Ruby API design
244
+ task.active? # not task.is_active
245
+ task.description # not task.get_description
246
+ task.uuid # not task.get_uuid
247
+ task.tags # not task.get_tags
248
+
249
+ # Mutation methods
250
+ task.description = "new desc" # Setter syntax
251
+ task.status = :completed # Using symbols
252
+
253
+ # Collection methods
254
+ operations.each {|op| ... } # Block iteration
255
+ operations.length # not operations.size_hint
256
+ operations[index] # Array-like access
257
+ operations << operation # Append operator
258
+
259
+ Tasks:
260
+ - Review all method names for Ruby conventions
261
+ - Add setter methods where appropriate
262
+ - Ensure predicate methods end with ?
263
+ - Add collection-style methods
264
+ - Use symbols for enums where appropriate
265
+
266
+ 3.4.2: Error Handling Improvements
267
+
268
+ Current State: Basic error mapping existsGoal: Comprehensive, helpful error messages
269
+
270
+ Error Classes Needed:
271
+ Taskchampion::Error # Base error
272
+ Taskchampion::ThreadError # ✅ Already implemented
273
+ Taskchampion::StorageError # File system issues
274
+ Taskchampion::ValidationError # Invalid input
275
+ Taskchampion::ConfigError # Configuration issues
276
+ Taskchampion::SyncError # Synchronization failures
277
+
278
+ Tasks:
279
+ - Ensure all error classes are properly defined
280
+ - Add helpful error messages with context
281
+ - Map all TaskChampion Rust errors to appropriate Ruby errors
282
+ - Add input validation with clear error messages
283
+
284
+ 3.4.3: Parameter Validation
285
+
286
+ Goal: Prevent invalid input with clear error messages
287
+
288
+ Validation Needed:
289
+ # UUID validation
290
+ replica.task("invalid-uuid") # Should raise ValidationError
291
+
292
+ # Status validation
293
+ task.set_status(:invalid_status, ops) # Should raise ValidationError
294
+
295
+ # Date validation
296
+ task.set_due("not-a-date", ops) # Should raise ValidationError
297
+
298
+ Tasks:
299
+ - Add UUID format validation
300
+ - Add enum value validation
301
+ - Add date/time format validation
302
+ - Add nil/empty string handling
303
+ - Provide helpful error messages
304
+
305
+ 3.5: Integration Testing
306
+
307
+ Priority: HIGHTimeline: 1 dayGoal: End-to-end functionality verification
308
+
309
+ 3.5.1: Comprehensive Test Suite
310
+
311
+ Test Structure:
312
+ test/
313
+ ├── integration/
314
+ │ ├── test_task_lifecycle.rb # Create → Modify → Complete workflow
315
+ │ ├── test_sync_operations.rb # Sync functionality
316
+ │ └── test_working_set.rb # Working set management
317
+ ├── unit/
318
+ │ ├── test_operations.rb # Operations class
319
+ │ ├── test_status.rb # Status enum
320
+ │ ├── test_access_mode.rb # AccessMode enum
321
+ │ └── test_error_handling.rb # Error scenarios
322
+ └── performance/
323
+ └── test_thread_safety.rb # Stress test ThreadBound
324
+
325
+ 3.5.2: Task Lifecycle Integration Test
326
+
327
+ Test Scenario: Complete task workflow
328
+ def test_complete_task_workflow
329
+ replica = Taskchampion::Replica.new_in_memory
330
+ operations = Taskchampion::Operations.new
331
+
332
+ # Create task
333
+ uuid = SecureRandom.uuid
334
+ task = replica.create_task(uuid, operations)
335
+
336
+ # Modify task
337
+ task.set_description("Buy groceries", operations)
338
+ task.set_status(Taskchampion::Status.pending, operations)
339
+ task.add_tag(Taskchampion::Tag.new("shopping"), operations)
340
+
341
+ # Commit changes
342
+ replica.commit_operations(operations)
343
+
344
+ # Verify changes
345
+ retrieved = replica.task(uuid)
346
+ assert_equal "Buy groceries", retrieved.description
347
+ assert retrieved.pending?
348
+ assert retrieved.has_tag?(Taskchampion::Tag.new("shopping"))
349
+ end
350
+
351
+ 3.5.3: Thread Safety Stress Test
352
+
353
+ Goal: Verify ThreadBound under concurrent load
354
+
355
+ Test Pattern:
356
+ def test_concurrent_access_stress
357
+ replica = Taskchampion::Replica.new_in_memory
358
+ errors = []
359
+
360
+ # Spawn 20 threads trying to access replica
361
+ threads = 20.times.map do
362
+ Thread.new do
363
+ 100.times do
364
+ begin
365
+ replica.task_uuids
366
+ errors << "No error raised in #{Thread.current}"
367
+ rescue Taskchampion::ThreadError
368
+ # Expected - this is correct
369
+ rescue => e
370
+ errors << "Wrong error: #{e.class} - #{e.message}"
371
+ end
372
+ end
373
+ end
374
+ end
375
+
376
+ threads.each(&:join)
377
+ assert errors.empty?, "Thread safety issues: #{errors.first(5)}"
378
+ end
379
+
380
+ 3.6: Documentation & Examples
381
+
382
+ Priority: LOWTimeline: 1 dayGoal: Usable documentation
383
+
384
+ 3.6.1: API Reference Documentation
385
+
386
+ Create Files:
387
+ - docs/API_REFERENCE.md - Complete method documentation
388
+ - docs/THREAD_SAFETY.md - ThreadBound usage guidelines
389
+ - examples/basic_usage.rb - Common patterns
390
+ - examples/sync_workflow.rb - Synchronization examples
391
+
392
+ 3.6.2: Usage Examples
393
+
394
+ Basic Usage Example:
395
+ # examples/basic_usage.rb
396
+ require 'taskchampion'
397
+
398
+ # Create task database
399
+ replica = Taskchampion::Replica.new_on_disk("/tmp/tasks", create_if_missing: true)
400
+ operations = Taskchampion::Operations.new
401
+
402
+ # Create and modify tasks
403
+ uuid1 = SecureRandom.uuid
404
+ task = replica.create_task(uuid1, operations)
405
+ task.set_description("Learn TaskChampion Ruby bindings", operations)
406
+ task.set_status(Taskchampion::Status.pending, operations)
407
+
408
+ # Commit changes
409
+ replica.commit_operations(operations)
410
+
411
+ # Query tasks
412
+ all_uuids = replica.task_uuids
413
+ puts "Total tasks: #{all_uuids.size}"
414
+
415
+ 🎯 Success Metrics
416
+
417
+ Phase 3 Completion Criteria
418
+
419
+ Technical Requirements:
420
+ - All classes implemented with full API coverage
421
+ - All method registrations working (including mutable methods)
422
+ - Ruby-idiomatic interface throughout
423
+ - Comprehensive error handling
424
+ - Integration tests passing
425
+
426
+ Quality Gates:
427
+ - No compilation errors or warnings
428
+ - All unit tests pass
429
+ - Integration test suite passes
430
+ - Thread safety stress tests pass
431
+ - Memory usage reasonable (no obvious leaks)
432
+
433
+ API Completeness:
434
+ - Operations: push, clear, iteration work
435
+ - Status: all enum values and predicates
436
+ - AccessMode: read_only/read_write modes
437
+ - WorkingSet: index-based task access
438
+ - DependencyMap: dependency relationships
439
+ - Task: full CRUD operations with Operations
440
+ - Replica: create, commit, sync, storage management
441
+
442
+ 🚀 Getting Started with Phase 3
443
+
444
+ Immediate Next Steps (Today)
445
+
446
+ 1. Start with 3.1.1: Research Magnus 0.7 mutable method patterns
447
+ cd /home/tcase/Sites/reference/taskchampion-rb
448
+ # Try enabling the commented-out methods one by one
449
+ # Research Magnus examples and documentation
450
+ 2. Focus on Operations class: Get push and clear methods working
451
+ 3. Test incrementally: Each method should compile before moving to next
452
+
453
+ Daily Progress Tracking
454
+
455
+ Create progress files:
456
+ - progress/phase3/2025-01-31.md - Document daily accomplishments
457
+ - Track method completion count
458
+ - Note any blockers or research needed
459
+
460
+ Research Resources
461
+
462
+ - Magnus 0.7 Documentation: https://docs.rs/magnus/0.7.1/magnus/
463
+ - Magnus Examples: Look for mutable method patterns
464
+ - TaskChampion API: https://docs.rs/taskchampion/2.0.2/taskchampion/
465
+ - Ruby Extension Patterns: Mutable object handling
466
+
467
+ 🎉 Phase 3 Impact
468
+
469
+ What Phase 3 Achieves:
470
+ - Complete API: Full TaskChampion functionality available in Ruby
471
+ - Production Ready: All major features implemented
472
+ - Ruby Native Feel: Idiomatic Ruby interface
473
+ - Robust Error Handling: Clear error messages and proper validation
474
+ - Integration Ready: Can be used in real Ruby applications
475
+
476
+ After Phase 3:
477
+ - Ruby developers can use TaskChampion naturally
478
+ - All major TaskChampion features accessible
479
+ - Thread safety is transparent and reliable
480
+ - Ready for community adoption and feedback
481
+
482
+ The foundation is solid - now we build the complete experience! 🏗️