ADR-011: ADR Timeline Tracking and Context-Aware Analysis
Statusโ
Accepted
Dateโ
2025-11-19
Contextโ
As our ADR analysis server matured, we identified several limitations in how we track and analyze architectural decisions:
- No Temporal Awareness: The system couldn't track when decisions were made or how long they've been in various states
- Missing Staleness Detection: No way to identify outdated or neglected ADRs that need attention
- Context-Agnostic Thresholds: Same staleness thresholds applied to all projects (startup vs. enterprise)
- Manual Action Planning: Users had to manually identify which ADRs need updates or implementation
- Performance Concerns: Extracting timeline data could be expensive without smart caching
Decisionโ
We implemented a comprehensive ADR Timeline Tracking system with the following components:
1. Timeline Extraction (src/utils/adr-timeline-extractor.ts)โ
Multi-Source Timeline Extraction:
- Git History (preferred): Extract creation/update dates from git log
- Content Parsing (fallback): Parse date fields from ADR content
- Filesystem (last resort): Use file modification times
Smart Conditional Logic:
- Only extract when necessary (no timestamp in content, file modified, cache miss)
- In-memory caching to avoid repeated expensive operations
- Configurable force-extract option for manual overrides
Timeline Data Structure:
interface BasicTimeline {
created_at: string; // ISO timestamp
updated_at: string; // ISO timestamp
age_days: number; // Days since creation
days_since_update: number; // Days since last modification
staleness_warnings: string[]; // Generated warnings
extraction_method: 'git' | 'content' | 'filesystem';
}
2. Project Context Detection (src/utils/adr-context-detector.ts)โ
Automatic Project Phase Detection:
- Startup: High commit rate (>50/week), frequent ADRs (>3/month)
- Growth: Moderate commits (20-50/week), regular ADRs (>1/month)
- Mature: Stable commits (5-20/week), occasional ADRs
- Maintenance: Low commits (
<5/week), rare ADRs (<0.5/month)
Adaptive Threshold Profiles:
THRESHOLD_PROFILES = {
startup: {
staleProposedDays: 14, // 2 weeks max
acceptedUnimplementedDays: 21,
outdatedAdrDays: 60,
rapidChangeDays: 3,
},
growth: {
staleProposedDays: 30, // 1 sprint cycle
acceptedUnimplementedDays: 45,
outdatedAdrDays: 90,
rapidChangeDays: 7,
},
mature: {
staleProposedDays: 90, // 1 quarter
acceptedUnimplementedDays: 90,
outdatedAdrDays: 180,
rapidChangeDays: 14,
},
maintenance: {
staleProposedDays: 180, // 6 months
acceptedUnimplementedDays: 180,
outdatedAdrDays: 365,
rapidChangeDays: 30,
},
};
ADR Type Modifiers:
- Infrastructure ADRs: 1.5x longer timelines (complex deployments)
- Security ADRs: 0.8x shorter timelines (urgent)
- Refactoring ADRs: 1.2x longer timelines (low priority)
- Feature ADRs: 1.0x baseline
3. Action Item Analyzer (src/utils/adr-action-analyzer.ts)โ
Automated Action Generation:
- Analyzes all ADRs with timeline data
- Generates prioritized action items based on:
- ADR status (proposed, accepted, deprecated)
- Age and staleness
- Implementation status
- Project context and thresholds
Action Urgency Levels:
- Critical (P0): Blocking issues, security risks
- High (P1): Stale proposed ADRs, long-unimplemented decisions
- Medium (P2): Outdated ADRs needing review
- Low (P3): Minor updates, documentation improvements
Work Queue Structure:
interface AdrWorkQueue {
summary: {
totalActions: number;
criticalCount: number;
highCount: number;
mediumCount: number;
lowCount: number;
};
actions: ActionItem[]; // Sorted by urgency
recommendations: string[];
}
4. Integrationโ
Enhanced ADR Discovery:
discoverAdrsInDirectory()now acceptsincludeTimelineoption- Timeline data automatically attached to each discovered ADR
- Optional action generation with
generateActionsflag
New MCP Tool (src/index.ts:6800-6950):
analyze_adr_timeline: Comprehensive timeline analysis with action items- Parameters:
adrDirectory: Directory to analyzegenerateActions: Enable action item generationthresholdProfile: Manual profile overrideautoDetectContext: Auto-select profile (default: true)
5. Cache Implementation Decisionโ
Problem: The existing cache.ts is designed for prompt-driven AI operations (returns prompts for AI to execute), but timeline extraction needs synchronous in-memory caching for performance.
Solution: Implemented a simple in-memory cache directly in adr-timeline-extractor.ts:
Map<string, CacheEntry>for O(1) lookup- TTL-based expiration
- Automatic cleanup on retrieval
- No external dependencies
Why Not Use cache.ts:
- cache.ts returns
{ prompt, instructions, context }for AI delegation - Timeline extractor needs immediate, synchronous cache access
- In-memory cache is simpler and more appropriate for this use case
Consequencesโ
Positiveโ
- Temporal Awareness: System now understands ADR lifecycles and aging
- Automated Action Planning: Generates prioritized todo lists automatically
- Context-Aware Analysis: Thresholds adapt to project phase and velocity
- Smart Performance: Conditional extraction minimizes expensive operations
- Type Safety: ADR type modifiers provide realistic timelines
- Better User Experience: Users get actionable insights, not just data
Negativeโ
- Increased Complexity: More code to maintain (4 new utility files)
- Git Dependency: Git extraction requires git to be available
- Cache Divergence: Two cache systems (prompt-driven and in-memory)
- Context Detection Accuracy: Auto-detection may misclassify edge-case projects
Neutralโ
- Breaking Change:
discoverAdrsInDirectory()signature changed from 3 params to 2 params + options object - Memory Usage: In-memory cache adds modest memory overhead
- Learning Curve: Users need to understand threshold profiles
Implementation Notesโ
Files Createdโ
src/utils/adr-timeline-extractor.ts- Multi-source timeline extractionsrc/utils/adr-context-detector.ts- Project context detectionsrc/utils/adr-action-analyzer.ts- Action item generationsrc/utils/adr-timeline-types.ts- Shared type definitions
Files Modifiedโ
src/utils/adr-discovery.ts- Added timeline integrationsrc/index.ts- Addedanalyze_adr_timelineMCP tool- 20+ files - Updated
discoverAdrsInDirectory()call sites
Testingโ
- Manual verification: Timeline extraction working correctly
- Git extraction: Successfully extracts from git history
- Fallback chain: Content โ filesystem fallback working
- Cache: In-memory cache functioning as expected
Future Enhancementsโ
- Persistent Cache: Move timeline cache to disk for cross-session persistence
- ML-Based Context Detection: Use machine learning to improve phase detection
- Custom Thresholds: Allow users to define custom threshold profiles
- Timeline Visualization: Generate charts showing ADR lifecycle trends
- Notification Integration: Alert users when ADRs become stale
- ADR Dependencies: Track dependencies between ADRs in timeline
Related ADRsโ
- ADR-003: Memory-Centric Architecture (cache system design)
- ADR-001: MCP Protocol Implementation (tool integration)
Referencesโ
- Git log extraction:
git log --follow --format="%ai" --diff-filter=A -- <file> - Context detection metrics: Commit frequency, ADR creation rate, team velocity
- Urgency scoring: Based on ADR status, age, and project context