## Database Command Reorganization
- Add new db-prefixed commands: db-query, db-schema, db-delete, db-status
- Maintain backward compatibility with deprecation warnings for query/schema commands
- Implement lazy database initialization to reduce CLI coupling
- Add command-specific --database options for flexibility
## Legacy Compatibility Framework
- Create comprehensive legacy compatibility system in markitect/legacy_compat.py
- Support versioned legacy switches (--legacy-v39-pre) for smooth transitions
- Implement git commit binding for version tracking (Issue #39: v39-pre → 3168de4)
- Add environment-based legacy mode detection for test environments
- Create graduated deprecation warning system (DEPRECATED → LEGACY → SUNSET)
## Legacy Agent System
- Implement intelligent legacy lifecycle management agent
- Add 8 CLI commands for legacy interface management (status, analyze, migrate, cleanup, etc.)
- Create automated maintenance with usage analytics and data-driven decisions
- Provide comprehensive safety features with backup and rollback capabilities
## Test Architecture Enhancement
- Add 18 comprehensive tests for Issue #39 functionality (16 passing, 2 skipped by design)
- Configure pytest.ini with MARKITECT_LEGACY_MODE=39-pre for automatic legacy support
- Update test count to 466 total tests across 7 architectural layers
- Identify 5 legacy interface tests for future recreation without legacy dependencies
## Documentation & Roadmap Updates
- Update NEXT.md with completed Issues #39 and #40
- Document failing tests requiring recreation with pure db- commands
- Add comprehensive legacy agent documentation
- Update development priorities and capability descriptions
## Architecture Achievements
- Simplified CLI architecture with reduced coupling between commands and global state
- Created reusable legacy compatibility framework for future breaking changes
- Established systematic approach to interface deprecation and migration
- Maintained 461/466 tests passing (5 legacy interface tests flagged for recreation)
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
8.6 KiB
Legacy Agent - Comprehensive Legacy Interface Management
Overview
The Legacy Agent is a comprehensive system for managing legacy interface compatibility and lifecycle in the MarkiTect project. Built on top of the existing legacy compatibility system from Issue #39, it provides intelligent automation for deprecation management, migration assistance, and cleanup operations.
Architecture
The legacy agent system consists of several interconnected components:
Core Components
-
LegacyRegistry (
markitect/legacy/registry.py)- Central registry for all legacy interfaces and versions
- Tracks git commit bindings, deprecation status, and timelines
- Maintains SQLite database for persistence
- Records usage statistics for informed decision making
-
LegacyAgent (
markitect/legacy/agent.py)- Intelligent automation engine for legacy lifecycle management
- Handles deprecation progression, cleanup scheduling, and notifications
- Configurable automation policies
- Task queue system for scheduled operations
-
LegacySwitch System (
markitect/legacy/switches.py)- CLI switch management (
--legacy-v1,--legacy-v2, etc.) - Automatic switch generation based on registry
- Deprecation warning integration
- Legacy routing to appropriate implementations
- CLI switch management (
-
DeprecationManager (
markitect/legacy/deprecation.py)- Graduated deprecation warning system
- Timeline-based status progression
- User notification management
-
GitStateTracker (
markitect/legacy/git_tracker.py)- Binds legacy versions to specific git commits
- Enables precise version restoration
- Validates compatibility snapshots
CLI Interface
The legacy agent exposes comprehensive CLI commands under the markitect legacy namespace:
Core Commands
markitect legacy status
Shows status of all legacy interfaces with comprehensive metadata:
# Table view (default)
markitect legacy status
# JSON output
markitect legacy status --format json
# Include removed interfaces
markitect legacy status --include-removed
markitect legacy analyze
Performs intelligent analysis of legacy interfaces:
# Analyze all interfaces
markitect legacy analyze
# Analyze specific command
markitect legacy analyze query
# Analyze specific version
markitect legacy analyze query v1.0
markitect legacy migrate
Provides migration guidance with breaking change documentation:
# Get migration guide
markitect legacy migrate query v1.0
# Migrate to specific version
markitect legacy migrate query v1.0 --to-version v2.0
markitect legacy cleanup
Safely removes legacy interfaces with backup options:
# Interactive cleanup
markitect legacy cleanup query v1.0
# Force cleanup without confirmation
markitect legacy cleanup query v1.0 --force
# Cleanup without backup
markitect legacy cleanup query v1.0 --no-backup
Agent Management
markitect legacy agent-run
Executes automated maintenance cycles:
# Run maintenance
markitect legacy agent-run
# Preview mode (dry run)
markitect legacy agent-run --dry-run
markitect legacy agent-status
Shows agent configuration and task queue status:
# Table view
markitect legacy agent-status
# JSON output
markitect legacy agent-status --format json
Analytics & Reporting
markitect legacy usage-stats
Displays usage patterns for informed decision making:
# All interfaces (30 days)
markitect legacy usage-stats
# Specific command
markitect legacy usage-stats --command query
# Extended period
markitect legacy usage-stats --days 90
markitect legacy generate-guide
Creates detailed migration documentation:
# Output to stdout
markitect legacy generate-guide query v1.0
# Save to file
markitect legacy generate-guide query v1.0 --output migration_guide.md
Legacy Interface Lifecycle
The system manages interfaces through a comprehensive lifecycle:
Status Progression
- CURRENT - Active implementation
- DEPRECATED - Marked for eventual removal, warnings shown
- LEGACY - Requires explicit
--legacy-vXflag - SUNSET - Final warning phase, scheduled for removal
- REMOVED - No longer available
Automated Progression
The agent can automatically progress interfaces based on:
- Time-based rules (e.g., deprecated → legacy after 90 days)
- Usage patterns (e.g., unused interfaces move to sunset)
- Manual scheduling
- Policy configuration
Agent Configuration
The agent behavior is configurable via AgentConfig:
config = AgentConfig(
auto_progression=True, # Auto-progress deprecations
cleanup_unused_days=180, # Cleanup after 6 months unused
migration_guide_auto_generation=True, # Auto-generate guides
notification_threshold_days=30, # Notify 30 days before removal
max_concurrent_migrations=3, # Limit concurrent operations
backup_before_cleanup=True # Always backup before removal
)
Integration with Existing Legacy System
The agent builds on the foundation from Issue #39:
Existing Components (Issue #39)
markitect/legacy_compat.py- Basic legacy switches and warningsLegacyVersionsregistry with git commit bindingLegacyModestate management- Environment-based test detection
New Agent Components
- Advanced registry with database persistence
- Intelligent lifecycle automation
- Comprehensive CLI interface
- Usage analytics and reporting
- Migration assistance tools
Compatibility
The new system is fully backward compatible with existing legacy switches:
--legacy-v39-precontinues to work as before- Existing deprecation warnings are preserved
- Test environment detection still functions
Usage Examples
Setting Up Legacy Interface
from markitect.legacy import LegacyRegistry, LegacyStatus
registry = LegacyRegistry()
# Register a legacy version
registry.register_legacy_interface(
command='query',
version='v1.0',
git_commit='a1b2c3d4',
status=LegacyStatus.DEPRECATED,
deprecated_date='2025-09-30',
removal_date='2025-12-30',
breaking_changes=['Parameter renamed', 'Output format changed'],
description='Legacy query with old parameter names'
)
Adding Legacy Support to CLI Command
from markitect.legacy import legacy_option, with_legacy_support
@click.command()
@click.argument('sql', type=str)
@legacy_option('v1.0', 'Use v1.0 legacy behavior')
@with_legacy_support('query')
def query_command(sql, legacy_v1_0=False):
# Modern implementation - legacy routing is automatic
return execute_modern_query(sql)
Running Maintenance
# Check what would be done
markitect legacy agent-run --dry-run
# Execute maintenance
markitect legacy agent-run
# Check results
markitect legacy agent-status
Benefits
- Automated Management - Reduces manual overhead of legacy maintenance
- Data-Driven Decisions - Usage analytics inform deprecation timelines
- User Experience - Clear migration paths and gradual warnings
- Safety - Backup and rollback capabilities
- Comprehensive Tracking - Complete audit trail of all operations
- Policy Enforcement - Consistent application of deprecation policies
Technical Implementation
Database Schema
The registry uses SQLite with tables for:
legacy_interfaces- Interface definitions and metadatalegacy_usage- Usage tracking for analytics
Task System
The agent uses a persistent task queue for:
- Scheduled deprecation progressions
- Cleanup operations
- Notification delivery
- Migration guide generation
Git Integration
Version bindings enable:
- Precise restoration of legacy behavior
- Validation of compatibility snapshots
- Audit trail of changes
Future Enhancements
- Integration with CI/CD - Automated testing of legacy interfaces
- User Notification System - Email/webhook notifications
- Migration Assistance - Interactive migration wizards
- Advanced Analytics - Usage heat maps and trend analysis
- Policy Templates - Pre-configured deprecation policies
- Cross-Project Support - Legacy management across multiple projects
Getting Started
-
Check Current Status:
markitect legacy status -
Run Analysis:
markitect legacy analyze -
Configure Agent:
markitect legacy agent-status -
Run Maintenance:
markitect legacy agent-run --dry-run markitect legacy agent-run
The legacy agent provides a complete solution for managing the entire lifecycle of deprecated interfaces, ensuring smooth transitions while maintaining backward compatibility.