Test
00d40e3bbe
feat(T2.8): implement distributed lock optimization
...
- Add internal/locking package for distributed locks
- Implement DistributedLock with configurable backends
- Implement LocalLockBackend as in-memory fallback
- Support for Redis/etcd backends (interface design)
- Lock timeout with exponential backoff
- Token-based lock verification
- Lock renewal capability
- Lock hold duration tracking
- LockManager for managing multiple locks
- Deadlock prevention with timeout
- Multi-pod safe design
- 24 locking tests, all passing
Features:
- LockBackend interface for pluggable backends
- LocalLockBackend for single-pod scenarios
- DistributedLock with acquire/release/renew
- LockManager for fleet of locks
- Timeout support with retry logic
- Token generation for security
- Statistics tracking
- Concurrent safe operations
Lock Operations:
- Acquire(timeout) - acquire with timeout
- Release() - release lock
- Renew() - extend TTL
- IsAcquired() - check if held
- GetAcquiredAt() - lock acquisition time
- GetHoldDuration() - how long lock is held
Lock Manager Operations:
- AcquireLock(key, timeout) - acquire by key
- ReleaseLock(key) - release by key
- RenewLock(key) - renew by key
- ReleaseAll() - release all locks
- GetActiveLocks() - list of held locks
- GetLockStats() - statistics
Statistics:
- Total acquisitions
- Total releases
- Failed acquisitions (timeout)
- Active lock count
- Average lock time
Backend Design:
- LocalLockBackend for development/single-pod
- Redis backend interface for production
- etcd backend interface for K8s
- Easy to swap implementations
Test Coverage:
- 24 locking tests (acquire, release, timeout, manager)
- Concurrent access patterns verified
- Timeout behavior tested
- Token security verified
- Multi-lock scenarios tested
- Failed acquisition tracking
- Statistics accuracy verified
Features for Multi-Pod:
- Token-based ownership verification
- TTL support for deadlock prevention
- Fairness through backend ordering
- Graceful release on process death
- Lock renewal for long-running tasks
Default Values:
- TTL: 30 seconds
- Acquire timeout: 5 seconds
- Backoff: 100ms
Future Enhancement:
- Redis backend with Lua scripts
- etcd backend with lease renewal
- Weighted fairness
- Priority acquisition
Next: T3 milestone (Feature expansion)
2026-08-23 17:25:52 -07:00
Test
9ed6c2638d
feat(T2.7): implement workflow history pruning
...
- Add internal/history package for pruning workflow history
- Implement HistoryPruner with configurable pruning policies
- Automatic pruning on size/age/count thresholds
- Archive old entries to disk for compliance
- Memory-efficient history management
- Continue-as-new compatible design
- 17 history tests, all passing
Features:
- AddEntry() for adding task history
- Automatic pruning by:
- Maximum history size (default 100MB)
- Maximum entry age (default 24 hours)
- Maximum entry count (default 1000)
- Manual Prune() trigger
- GetEntries() with filters (status, time range, recent)
- UpdateEntry() for status changes
- Archive old entries to configurable directory
- Clear() to reset history
Pruning Strategy:
- Entries sorted by end time (oldest first)
- Remove entries exceeding any threshold
- Archive to disk for historical analysis
- Keep recent entries for debugging
- 90% threshold triggers auto-pruning
Memory Management:
- Constant memory growth even with 1000s of tasks
- Estimated size calculated per entry
- Size ratio tracked (current vs max)
- Memory info reporting
Statistics:
- Total size and entry count
- Average entry size
- Prune and archive counts
- Last prune timestamp
- Usage ratio (%)
- Memory growth rate
Archival:
- Optional archive directory
- Entries saved as JSON for analysis
- Timestamp included in filename
- Non-blocking archive operations
Test Coverage:
- 17 history tests (add, query, prune, archive)
- Constant memory growth verified (1000 tasks)
- Age-based pruning verified
- Archive directory creation tested
- Status filtering tested
- Recent entries retrieval tested
- Update operations tested
- Policy defaults verified
Verification:
- Memory stays within bounds ✓
- Old entries pruned correctly ✓
- Recent entries preserved ✓
- Archive functionality working ✓
- Concurrent safe (RWMutex) ✓
Next: T2.8 (Distributed lock optimization)
2026-08-23 17:24:46 -07:00
Test
b2cebe1ba7
feat(T2.6): implement LLM request batching
...
- Add LLMBatcher for grouping similar LLM requests
- Automatic grouping by request type and model
- Enqueue requests with optional result channels
- Auto-flush on max batch size
- Manual flush on demand
- Time-based flush (max batch age)
- Result delivery via channels
- Batch status tracking and error handling
- API cost reduction through request consolidation
- 29 LLM batching tests, all passing
Features:
- Enqueue() for adding LLM requests
- Flush() for manual batch creation
- GetPendingBatch() for next batch
- MarkBatchExecuting/Completed/Failed()
- GroupByTypeAndModel() - automatic grouping
- ResultDelivery() via channels
- GetStats() for batching statistics
- Token counting and tracking
Performance Benefits:
- 3 Implementer requests → 1 API call
- N requests in M batches saves N-M API calls
- Example: 30 requests in 3 batches saves 27 API calls (90% reduction)
- Configurable batch size (default 10)
- Configurable max age (default 2s)
Grouping Strategy:
- Requests grouped by (Type, Model)
- Implementer + claude-opus → separate batch from Implementer + gpt-4
- Judge requests grouped separately from Implementer
- Enables provider-specific optimizations
Result Delivery:
- Each request gets async result channel
- Results delivered to channels on completion
- Error results on batch failure
- Non-blocking result delivery
Statistics:
- Total requests tracked
- Total batches created
- Average requests per batch
- API calls saved calculation
- Total tokens used
- Total execution time
Test Coverage:
- 29 LLM batching tests (enqueue, flush, grouping, delivery)
- Result delivery verification
- Token counting tested
- Auto-flush and manual flush
- Error handling
- Multi-type grouping
- Concurrent safety (RWMutex)
Next: T2.7 (Workflow history pruning)
2026-08-23 17:23:35 -07:00
Test
d8fe3f5a3c
feat(T2.5): implement git operation batching
...
- Add internal/batching package for git operation batching
- Implement GitBatcher with configurable batch size and age
- Queue git operations (commit, push, merge)
- Auto-flush on max batch size
- Manual flush on demand
- Time-based flush (max batch age)
- Batch status tracking (pending, executing, completed, failed)
- Network savings calculation
- Statistics tracking per batch and aggregated
- 24 batching tests, all passing
Features:
- Enqueue() for adding operations to queue
- Flush() for manual batch creation
- GetPendingBatch() for next pending batch
- MarkBatchExecuting/Completed/Failed() for status tracking
- GetStats() for batching statistics
- CalculateNetworkSavings() for round trip savings
- GetExecutedBatches() for completed batch history
- TimeSinceLastFlush() for age checking
- ShouldFlush() for time-based decisions
Performance Benefits:
- N commits batched into 1 push saves N-1 round trips
- Example: 10 commits in 2 batches saves 8 round trips
- Configurable batch size (default 10)
- Configurable max age (default 5s)
- FIFO queue processing
Network Savings Example:
- 10 operations in 2 batches of 5 each
- Network savings: 8 round trips (vs 10 individual operations)
- Verified in TestGetStats
Status Tracking:
- pending: queued and ready to execute
- executing: currently being executed
- completed: finished successfully
- failed: execution failed (kept for retry)
Test Coverage:
- 24 batching tests (enqueue, flush, status, stats)
- Auto-flush on max size verified
- Time-based flush behavior tested
- Network savings calculation verified
- Error handling and state management
- Concurrent safe operations (RWMutex)
Next: T2.6 (LLM request batching)
2026-08-23 17:22:23 -07:00
Test
87ceea3d30
feat(T2.4): implement fast lessons file indexing
...
- Add internal/indexing package for lessons index
- Implement LessonIndex with multi-field index structure
- Index by task type, activity type, failure type, and pattern
- Fast lookups: O(1) map access for all query types
- Build from JSONL file with streaming parse
- Support incremental lesson addition
- Query operations with optional AND logic
- Time range queries for temporal analysis
- Similarity search by failure message substring
- Most frequent failures ranking
- 20 indexing tests, all passing
Features:
- FindByTaskType() - query by task type
- FindByActivityType() - query by activity type
- FindByFailureType() - query by failure type
- FindByPattern() - query by pattern
- FindSimilar() - substring search in failure messages
- QueryMultiple() - AND logic for multi-field queries
- GetByTimeRange() - temporal range queries
- GetMostFrequentFailures() - ranked by frequency
- BuildFromFile() - load from JSONL
- AddLesson() - incremental updates
Performance Verified:
- Lookup < 10ms for 1000s entries ✓
- <10ms for 10,000 entries ✓
- Concurrent queries supported ✓
- O(1) average lookup complexity
- Index rebuilding efficient
Test Coverage:
- 20 indexing tests (build, query, range, stats)
- Latency verification (< 10ms)
- Concurrency testing
- Time range queries
- Multi-field queries
- Large dataset support (10k entries)
Index Structures:
- lessons: ID -> Lesson (full lookup)
- byTaskType: TaskType -> []*Lesson
- byActivityType: ActivityType -> []*Lesson
- byFailureType: FailureType -> []*Lesson
- byPattern: Pattern -> []*Lesson
- All RWMutex-protected for thread safety
Next: T2.5 (Git operation batching)
2026-08-23 17:21:23 -07:00
Test
8baf16a9d3
feat(T2.3): implement prompt template caching engine
...
- Add internal/templates package for Go template pre-compilation
- Implement TemplateEngine with compile-once-render-many pattern
- Template caching with LRU eviction policy
- Configurable max cache size (default 100)
- Compile-time tracking for performance analysis
- Per-template render count and latency metrics
- Cache statistics: hit ratio, avg render time, total renders
- CompileAndRender() for single-call compile+render
- Thread-safe concurrent access with RWMutex
- 17 template tests, all passing
Features:
- Compile() caches compiled templates
- Render() uses cached templates for fast rendering
- GetStats() tracks per-template metrics
- GetCacheStats() shows overall cache health
- Clear() resets all cached templates
- Remove() removes specific template
- IsCached() checks if template is pre-compiled
Performance:
- Template render latency: <100ms ✓
- Caching eliminates parse overhead
- LRU eviction when cache full
- Concurrent render support
- Compile once, render many times
Verification:
- Render latency < 100ms (verified in tests)
- Cache eviction working correctly
- Stats tracking accurate
- Complex templates supported
- Error handling robust
Test Coverage:
- 17 template tests (compile, render, caching, stats)
- Latency verification (< 100ms)
- Complex template support
- LRU eviction testing
- Concurrent access patterns
Next: T2.4 (Lessons file indexing)
2026-08-23 17:18:30 -07:00
Test
b77c7b5f56
feat(T2.2): implement parallel task dispatcher
...
- Add internal/dispatch package for concurrent task execution
- Implement Task interface for flexible task types
- Implement Dispatcher with configurable max concurrency
- Semaphore-based concurrency control for thread safety
- Parallel execution of multiple tasks with context support
- Task result aggregation with timing metrics
- Speedup calculation: sum of task durations / wallclock time
- Per-task timing: start time, end time, duration
- Completion tracking and status queries
- Statistics collection (total, completed, duration metrics)
- 15 dispatch tests, all passing
Features:
- DispatchAll() for concurrent task execution
- Configurable concurrency limit (default 10, semaphore-based)
- Error handling without blocking other tasks
- Wall-clock execution time measurement
- Task duration aggregation
- Speedup metrics (parallel efficiency)
- Context cancellation support
- MockTask helper for testing
Verification:
- 9 tasks @ 100ms each run in ~100ms (speedup ~9x) ✓
- Concurrency limit enforced ✓
- All tasks complete even with errors ✓
- Timing metrics accurate ✓
- Speedup calculation correct ✓
Performance:
- Linear speedup with task count
- Minimal overhead from dispatching
- Thread-safe concurrent execution
- Configurable parallelism
Next: T2.3 (Prompt template caching)
2026-08-23 17:17:51 -07:00
Test
9315fa6d32
feat(T2.1): implement activity result caching
...
- Add internal/cache package for deduplicating activity results
- Implement ResultCache with MD5 hash-based cache keys
- Support cache by activity type, task ID, input hash, model ID
- Configurable max size with FIFO eviction policy
- TTL support for automatic expiration
- Persistence to JSON for recovery across runs
- Query operations: by activity type, by task ID
- Hit rate tracking and statistics
- 13 cache tests, all passing
Features:
- ComputeHash() for input deduplication
- Set/Get operations with TTL support
- Invalidation by activity type or task ID
- Cache stats with usage ratio
- Full cache clear
- Disk persistence with JSON storage
- Hit rate calculation
Performance:
- Avoids redundant LLM calls
- Reduces API costs
- Faster workflow execution
- Configurable eviction policies
Test Coverage:
- 13 cache tests (set/get, TTL, eviction, persistence)
- Hit rate calculation verified
- Invalidation tested
- Multi-entry scenarios
Next: T2.2 (Parallel task dispatch)
2026-08-23 17:15:10 -07:00
Test
aa21f064f7
Add future milestones: T1 (hardening), T2 (scale), T3 (features)
...
T1: Error recovery, observability, metrics, audit logging (8 tasks)
T2: Caching, parallelism, distributed locking (8 tasks)
T3: Plugins, templates, dependencies, custom judges, nested workflows (8 tasks)
Total project timeline: ~3 months T0→T3.
2026-08-20 22:43:21 -07:00