Lock File Health Checks
The Rhema health command now includes comprehensive lock file consistency checks to ensure your project’s dependency state is valid and up-to-date.
Overview
Lock file health checks verify the integrity and consistency of your rhema.lock file against the current state of your project. These checks help identify issues that could lead to dependency conflicts, build failures, or inconsistent behavior.
Health Checks Performed
1. Lock File Existence and Validity
Check: Verifies that the lock file exists and can be parsed correctly.
Issues Detected:
- Missing lock file (
rhema.lock) - Invalid YAML syntax
- Corrupted file structure
Example Output:
🔒 Checking lock file health...
⚠️ Found 1 lock file issue(s):
• Lock file does not exist (rhema.lock)2. Lock File Checksum Validation
Check: Validates the SHA-256 checksum of the lock file to ensure it hasn’t been corrupted.
Issues Detected:
- Checksum mismatch indicating file corruption
- Invalid checksum format
Example Output:
🔒 Checking lock file health...
⚠️ Found 1 lock file issue(s):
• Lock file checksum is invalid - file may be corrupted3. Scope Consistency
Check: Ensures that all scopes in the lock file correspond to actual scopes in your project.
Issues Detected:
- Locked scopes that no longer exist
- Current scopes that aren’t locked
- Missing scope definitions
Example Output:
🔒 Checking lock file health...
⚠️ Found 2 lock file issue(s):
• Locked scope no longer exists: old-service
• Scope not locked: new-service4. Dependency Version Mismatches
Check: Compares locked dependency versions with current scope definitions.
Issues Detected:
- Scope version mismatches
- Dependency type inconsistencies
- Missing or extra dependencies
- Dependencies that no longer exist
Example Output:
🔒 Checking lock file health...
⚠️ Found 2 lock file issue(s):
• Scope version mismatch for user-service: locked=1.0.0, current=2.0.0
• Dependency not locked: ../shared-lib in user-service5. Lock File Staleness
Check: Determines if the lock file is outdated and needs regeneration.
Issues Detected:
- Lock file older than 30 days
- Source files modified after lock file generation
- Outdated dependency information
Example Output:
🔒 Checking lock file health...
⚠️ Found 1 lock file issue(s):
• Lock file is stale (45 days old) - consider regenerating6. Checksum Validation
Check: Validates individual scope and dependency checksums to ensure file integrity.
Issues Detected:
- Scope source checksum mismatches
- Dependency checksum mismatches
- File content changes not reflected in lock file
Example Output:
🔒 Checking lock file health...
⚠️ Found 1 lock file issue(s):
• Scope checksum mismatch for user-service: expected=abc123, current=def456Running Health Checks
Check All Scopes and Lock Files
rhema healthCheck Specific Scope
rhema health --scope crates/user-serviceInterpreting Results
Healthy State
When all checks pass, you’ll see:
🔒 Checking lock file health...
✅ Lock file is healthy
📊 Health Summary:
📁 Total scopes: 5
✅ Healthy scopes: 5
⚠️ Total issues: 0
🎉 All scopes and lock files are healthy!Issues Found
When issues are detected:
🔒 Checking lock file health...
⚠️ Found 3 lock file issue(s):
• Lock file is stale (45 days old) - consider regenerating
• Scope version mismatch for user-service: locked=1.0.0, current=2.0.0
• Dependency not locked: ../shared-lib in user-service
📊 Health Summary:
📁 Total scopes: 5
✅ Healthy scopes: 3
⚠️ Total issues: 5
🔧 Consider running 'rhema validate' for detailed validationResolving Issues
Missing Lock File
If the lock file doesn’t exist, generate it:
rhema lock generateStale Lock File
If the lock file is outdated, regenerate it:
rhema lock regenerateVersion Mismatches
If scope versions don’t match:
- Update the scope version in
rhema.yaml - Regenerate the lock file
- Or update the lock file to match current versions
Missing Dependencies
If dependencies are missing from the lock file:
- Add the dependency to the scope’s
rhema.yaml - Regenerate the lock file
Checksum Mismatches
If checksums don’t match:
- Check if files have been modified
- Regenerate the lock file to update checksums
- Verify file integrity
Best Practices
- Regular Health Checks: Run
rhema healthregularly to catch issues early - CI/CD Integration: Include health checks in your CI/CD pipeline
- Lock File Management: Keep lock files up-to-date with project changes
- Version Control: Commit lock files to version control for reproducible builds
- Documentation: Document any manual lock file modifications
Configuration
Health check behavior can be configured through environment variables:
RHEMA_LOCK_MAX_AGE_DAYS: Maximum age for lock files (default: 30)RHEMA_HEALTH_STRICT_MODE: Enable strict validation (default: false)
Troubleshooting
Common Issues
- False Positives: Some checks may report issues that are intentional
- Performance: Large projects may take longer to validate
- File Permissions: Ensure read access to all scope directories
Debug Mode
For detailed debugging information:
RHEMA_LOG=debug rhema healthThis will show additional information about each check performed.
Integration with Other Commands
The health command integrates with other Rhema commands:
- Validate:
rhema validateprovides detailed validation - Lock:
rhema lockcommands for lock file management - Sync:
rhema syncto synchronize dependencies
Future Enhancements
Planned improvements to lock file health checks:
- Performance optimizations for large projects
- Custom validation rules
- Integration with external dependency scanners
- Automated issue resolution suggestions
- Historical health trend analysis