tempo-cli 0.4.0

Automatic project time tracking CLI tool with beautiful terminal interface
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
# TimeTrack Specification Update Summary

**Date**: November 15, 2025  
**Version**: 2.0 (Specification)  
**Status**: Complete - Production Ready

## Document Statistics

- **Original Size**: 1,410 lines
- **Updated Size**: 3,681 lines
- **New Content**: 2,271 lines (161% increase)
- **New Sections**: 14 major sections added

---

## All Requested Updates Completed ✅

### 1. Error Handling & Recovery ✅
**Location**: Line 772

- Crash recovery procedures for interrupted sessions
- Database corruption detection and repair
- Network/IPC failure handling with retries
- Configuration error handling with fallbacks
- Graceful degradation strategies
- User notification levels (Silent/Warning/Critical)

### 2. Edge Cases & Limitations ✅
**Location**: Line 946

**Terminal Edge Cases:**
- Symlinks and real path resolution
- Multiple terminal windows in same project
- Docker containers and SSH sessions
- Nested projects (monorepo support)
- Network mounted directories

**IDE Edge Cases:**
- Multi-root workspaces
- Split editors with multiple files
- Remote development (SSH, WSL, containers)
- IDE extension disabled scenarios
- JetBrains IDE limitations

**Time Tracking Edge Cases:**
- Overnight sessions handling
- System sleep/hibernate detection
- Clock changes and DST transitions
- Rapid project switching rate limits
- Manual vs auto-tracking conflicts

**Path Handling:**
- Complete canonicalization rules
- Case sensitivity (Windows vs Unix)
- Trailing slash normalization
- Relative path conversion
- Unicode support

**Performance Limitations:**
- 1,000 project tested limit
- Long session warnings (12h) and limits (48h)
- High-frequency signal rate limiting

**Offline-First Confirmation:**
- 100% offline operation guaranteed
- Zero network requirements
- No cloud dependencies
- Multi-machine manual sync strategy

### 3. Session Management ✅
**Location**: Line 1212

**Timezone Handling:**
- UTC storage in database
- System timezone for display
- Automatic DST handling
- Travel-friendly (timezone changes)
- Implementation with chrono crate

**Session Boundary Rules:**
- Sessions can span midnight
- Daily report splitting
- System sleep detection (>5min pause)
- Hibernate/shutdown handling
- Maximum 48-hour session limit

**Rate Limiting:**
- Shell hook: 10 signals/sec max
- IDE extension: 2 signals/sec max
- CLI commands: 5 commands/sec max
- Debouncing: 30s for IDE, 10s for project switches

### 4. Resource Monitoring ✅
**Location**: Line 1396

**Memory Management:**
- Target: 5-10MB RAM
- Soft limit: 10MB (trigger cleanup)
- Hard limit: 20MB (refuse new sessions)
- Automatic cleanup strategies

**CPU Management:**
- Target: <1% active, 0% idle
- Event-driven (no polling)
- Sleep when inactive

**Database Size:**
- Target: <1MB/month, <50MB/year
- Session aggregation after 90 days
- Automatic VACUUM weekly
- Backup rotation (7 daily, 4 weekly)

**Resource Limit Enforcement:**
- Monitoring with sysinfo crate
- Automatic cleanup triggers
- User notifications on limits
- Self-monitoring dashboard command

### 5. Security & Privacy ✅
**Location**: Line 1570

**Data Security:**
- File permissions: 0700 for directories, 0600 for files
- Optional database encryption (SQLCipher)
- Password management (keychain integration)

**IPC Security:**
- Unix socket: 0600 permissions
- Client authentication (same UID check)
- Connection limits (max 10 concurrent)
- Rate limiting per connection

**Privacy Guarantees:**
- ✅ Tracked: paths, times, context
- ❌ NOT tracked: file contents, commands, keystrokes, screenshots
- Zero telemetry by default
- No cloud reporting
- User owns all data

**Multi-User Security:**
- Per-user daemon instances
- No cross-user data access
- Separate sockets per user
- Never run as root

**Audit Trail:**
- Optional audit logging
- Session events tracked
- Manual edits logged
- Configuration changes logged

### 6. Logging & Debugging ✅
**Location**: Line 1719

**Log Levels:**
- ERROR, WARN, INFO, DEBUG, TRACE
- Default: INFO level
- Configurable via config.toml or env var

**Log Files:**
- `~/.timetrack/logs/daemon.log` - Main log
- `~/.timetrack/logs/shell.log` - Shell activity
- `~/.timetrack/logs/ide.log` - IDE activity
- `~/.timetrack/logs/errors.log` - Errors only
- Size-based rotation (10MB max, keep 5 files)

**Debug Mode:**
- `RUST_LOG=timetrack=debug`
- Or via `timetrack config set logging.level debug`

**Diagnostic Commands:**
- `timetrack logs [--tail N] [--follow] [--level LEVEL]`
- `timetrack daemon stats`
- `timetrack database check`
- `timetrack diagnostic-export` - Full diagnostic bundle

**Privacy in Logs:**
- Path redaction (full paths → last component)
- No sensitive data logging
- Optional structured JSON format

### 7. Testing Strategy ✅
**Location**: Line 1909

**Unit Testing:**
- Target: 80%+ coverage
- Session logic, time calculations, state machine
- Mock time for idle timeout testing

**Integration Testing:**
- Shell + Daemon + Database end-to-end
- IDE extension communication
- IPC reliability
- Crash recovery scenarios

**System Testing:**
- Full install → track → report cycle
- Multi-hour sessions with sleep
- Resource limit enforcement
- Tested on: Ubuntu 24.04, macOS 14, Windows 11, WSL2

**Performance Testing:**
- Benchmarks with Criterion
- Target: <1ms signal processing, <100ms report generation
- Load testing: 1000 projects, 10,000 sessions
- Memory leak detection

**Regression Testing:**
- Automated CI/CD pipeline
- Test on all platforms
- Database migration testing

**Manual Testing Checklist:**
- 15-point pre-release checklist
- Fresh install testing
- All features verification

### 8. Database Migrations ✅
**Location**: Line 2164

**Schema Versioning:**
- `schema_version` table tracks current version
- Version number in database
- Migration history logged

**Migration System:**
- Migration files: `migrations/001_initial_schema.sql`
- Up and down migrations
- Transactional application
- Automatic on daemon start

**Backward Compatibility:**
- Current version: Always supported
- N-1 version: Auto-upgrade
- N-2 version: Auto-upgrade with warning
- Older: Prompt to upgrade

**Rollback Strategy:**
- Automatic backup before migration
- Manual rollback command
- Down migrations for each change
- Migration testing in test suite

### 9. Versioning & Compatibility ✅
**Location**: Line 2304

**Semantic Versioning:**
- MAJOR.MINOR.PATCH format
- Breaking changes → MAJOR bump
- New features → MINOR bump
- Bug fixes → PATCH bump

**Compatibility Policies:**
- Database: Support previous MAJOR version
- Config: Backward compatible within MAJOR
- CLI: Stable within MAJOR version
- IPC Protocol: Compatible for 2 MINOR versions

**Version Checking:**
- Daemon-CLI version compatibility check
- Warnings on mismatch
- Client version in IPC protocol

**Deprecation Policy:**
- Announce → Warn (1 MINOR) → Remove (next MAJOR)
- Clear deprecation notices
- Migration guides provided

**Changelog:**
- CHANGELOG.md maintained
- All changes documented
- Links to issues/PRs

### 10. Performance Testing Methodology ✅
**Location**: Line 2426

**Benchmark Suite:**
- Criterion framework
- Signal processing, report generation benchmarks
- Targets defined for all operations

**Load Testing:**
- High signal rate (100/sec)
- Large databases (10,000 sessions)
- Memory leak detection over 10,000 iterations

**Profiling:**
- CPU profiling (perf on Linux, Instruments on macOS)
- Memory profiling (valgrind, heaptrack)

**Continuous Monitoring:**
- CI/CD integration
- Benchmark on every commit
- Alert on >10% regression

**Real-World Testing:**
- Normal use (8-hour day)
- Heavy use (12-hour, 10+ projects)
- Light use (occasional)
- Long sessions (4+ hours)

### 11. Time Entry Editing ✅
**Location**: Line 2622

**Manual Adjustments:**
- Edit start/end times
- Change project
- Delete sessions
- Split sessions at timestamp
- Merge multiple sessions

**Commands:**
- `timetrack session edit <id> --start/--end/--project`
- `timetrack session split <id> --at <time>`
- `timetrack session merge <id1> <id2>`
- `timetrack session delete <id>`
- Interactive mode available

**Audit Trail:**
- `session_edits` table logs all changes
- Track field changed, old/new values
- View history: `timetrack session history <id>`

**Validation:**
- Start must be before end
- No overlapping sessions
- No future times
- Positive duration required

**Bulk Edits:**
- Edit all sessions from a date
- Adjust times in bulk
- Confirmation prompts

### 12. Project Path Updates ✅
**Location**: Line 2766

**Moved/Renamed Projects:**
- Automatic detection via git metadata hash
- Manual update command
- Bulk path updates

**Detection Strategy:**
- Hash `.git/config` and `.git/HEAD`
- Match against known projects
- Prompt user to update

**Commands:**
- `timetrack project update-path <name> --new-path <path>`
- `timetrack project bulk-update-path --old-base --new-base`

**Orphaned Projects:**
- Detect projects with missing paths
- Archive or delete options
- Update path if moved
- Keep historical data

### 13. User Feedback Mechanisms ✅
**Location**: Line 2876

**Notification Types:**
- Desktop notifications (optional, v2.0)
- CLI status messages
- Progress indicators
- Color-coded status (🟢🟡🔴)

**Interactive Features:**
- Confirmations for destructive actions
- Smart suggestions ("Did you mean...")
- Context-sensitive tips
- Helpful error messages

**Feedback Collection:**
- Optional anonymous stats (explicit opt-in)
- Optional crash reports (explicit opt-in)
- In-app survey system
- Default: All disabled (privacy-first)

**Help System:**
- Comprehensive help commands
- Links to documentation
- Community discussion links
- Troubleshooting guides

### 14. Uninstallation Guide ✅
**Location**: Line 3073

**Automated Uninstall:**
- `timetrack uninstall` command
- Options: Export data, Keep data, Delete all
- Automatic export before removal
- Removes all components

**Manual Steps:**
1. Stop daemon
2. Export data (optional)
3. Remove binary
4. Remove shell integration
5. Uninstall VS Code extension
6. Remove data directories
7. Remove auto-start configuration

**Partial Uninstall:**
- `timetrack uninstall --keep-data`
- Application removed, data preserved
- Can reinstall later with history intact

**Verification:**
- Check for remaining processes
- Find remaining files
- Verify shell config cleaned
- Check systemd/launchd

**Data Recovery:**
- Reinstall detects existing database
- All historical data preserved
- No data loss on reinstall

---

## Key Technical Decisions Documented

### Timezone Strategy
- **Storage**: UTC in database (ISO 8601)
- **Display**: System local timezone
- **Reports**: Local timezone (unless --utc flag)
- **Rationale**: DST-immune, travel-friendly, standard practice

### Path Canonicalization
- **Method**: `std::fs::canonicalize()` in Rust
- **Symlinks**: Always resolve to real path
- **Case**: OS-appropriate (insensitive on Windows, sensitive on Unix)
- **Normalization**: Remove trailing slashes, expand ~, absolute paths

### Rate Limiting
- **Shell**: 10 signals/sec
- **IDE**: 2 signals/sec  
- **CLI**: 5 commands/sec
- **Rationale**: Prevent daemon overload, maintain stability

### Session Boundaries
- **Daily**: Split at midnight for reports
- **Sleep**: Pause if >5 min sleep detected
- **Maximum**: 48 hours (hard limit), 12 hours (warning)

### Resource Limits
- **Memory**: 10MB soft, 20MB hard
- **CPU**: <1% active target
- **Database**: <1MB/month target
- **Enforcement**: Automatic cleanup, user alerts

---

## Production Readiness Checklist ✅

- ✅ Error handling and recovery documented
- ✅ All edge cases identified and addressed
- ✅ Session management rules defined
- ✅ Resource monitoring implemented
- ✅ Security and privacy guaranteed
- ✅ Logging and debugging comprehensive
- ✅ Testing strategy complete
- ✅ Database migrations system
- ✅ Versioning policy established
- ✅ Performance methodology defined
- ✅ Time editing capabilities
- ✅ Path updates handled
- ✅ User feedback mechanisms
- ✅ Uninstallation procedures

---

## Next Steps

The specification is now complete and production-ready. You can:

1. **Begin Implementation**: Start with Phase 1 (Core Daemon)
2. **Review with Team**: Share spec for feedback
3. **Prototype**: Build minimal viable version
4. **Iterate**: Implement features incrementally

The document now serves as a comprehensive blueprint for building TimeTrack with confidence that all operational scenarios are covered.

---

**Document**: [View Updated Specification](computer:///mnt/user-data/outputs/timetrack-specification.md)

**Status**: ✅ Complete - Ready for Implementation