Skip to content

feat(config): migrate config file to config.yaml with automatic migra…#4

Merged
dkmnx merged 2 commits intomainfrom
refactor/add-config-extension
Jan 20, 2026
Merged

feat(config): migrate config file to config.yaml with automatic migra…#4
dkmnx merged 2 commits intomainfrom
refactor/add-config-extension

Conversation

@dkmnx
Copy link
Owner

@dkmnx dkmnx commented Jan 20, 2026

Summary

  • Change config filename from config to config.yaml for better format recognition and editor support
  • Implement automatic migration from old format to new format
  • Add comprehensive safety checks and rollback mechanisms

Changes

Core Implementation

  • internal/config/loader.go: Added migrateConfigFile() function with automatic migration in LoadConfig()
    • YAML validation before migration
    • Backup file creation (config.backup)
    • Permission preservation
    • Atomic operation with rollback on failure

Safety Guarantees

  • No data loss: Original file backed up as config.backup (never deleted)
  • No corruption: YAML validation before attempting migration
  • No overwrites: Won't replace existing config.yaml
  • Atomic operation: Rollback if any step fails

Test Coverage

  • Added 7 comprehensive test cases for migration scenarios
  • All 26 config package tests passing
  • All 25 audit package tests passing
  • Edge cases covered:
    • No migration when old config doesn't exist
    • Successful migration with backup verification
    • No migration when new config already exists
    • Graceful failure with invalid YAML
    • Permission preservation (Unix)

Documentation

  • Updated README.md to reflect config.yaml filename
  • Added LogMigration() method to audit logger for future use

Migration Behavior

When a user with an old config file runs any Kairo command:

  1. System detects old format automatically
  2. Validates YAML content
  3. Writes new config.yaml file
  4. Renames old file to config.backup
  5. Continues normal operation

No user intervention required - migration is transparent and automatic.

Test plan

  • Migration tests pass (7/7)
  • Config package tests pass (26/26)
  • Audit package tests pass (25/25)
  • Crypto package tests pass (all)
  • Manual testing with old config format
  • Manual testing with new config format
  • Manual testing migration scenarios

Checklist

  • Tests pass locally
  • Code follows project style guidelines
  • Documentation updated
  • No sensitive data exposed
  • Backward compatible (automatic migration)

dkmnx added 2 commits January 20, 2026 15:40
…tion

- Change config filename from "config" to "config.yaml" for better format recognition
- Implement automatic migration from old "config" to new "config.yaml" format
- Add safety checks: YAML validation, backup creation, permission preservation
- Migration only occurs when old file exists and new file doesn't exist
- Old config file is backed up as "config.backup" (never deleted)
- Add comprehensive test coverage for migration scenarios (26 tests pass)
- Add LogMigration() method to audit logger for future use
- Update README.md to reflect config.yaml filename

Migration guarantees:
- No data loss (backup file preserved)
- No corruption (YAML validation before migration)
- No overwrites (won't replace existing config.yaml)
- Atomic operation (rollback on failure)
@dkmnx dkmnx merged commit 8a4d8c9 into main Jan 20, 2026
16 checks passed
@dkmnx dkmnx deleted the refactor/add-config-extension branch January 20, 2026 07:59
dkmnx added a commit that referenced this pull request Jan 30, 2026
Changed logAuditEvent to return errors instead of silently failing
to stderr. This allows callers to decide whether audit failures
should be warnings or fatal errors. All 7 callers now handle
audit errors with ui.PrintWarn() to inform users without
blocking the main operation.

- Changed logAuditEvent signature to return error
- Added defer logger.Close() for resource cleanup
- Updated all callers with error handling pattern
- Updated TestAuditLoggerErrorHandling for new behavior
- Removed unused imports from test file

Fixes: code review issue #4 (Low priority)
dkmnx added a commit that referenced this pull request Jan 30, 2026
- Update coverage metrics: cmd package at 53.4%, overall at 79.5%
- Document why original 70% target was not achievable
- Add comprehensive analysis of coverage gaps and integration test coverage
- Add resolution summary showing all high/medium priority issues RESOLVED
- Document new tests: cmd/audit_helpers_test.go (343 lines, 6 functions)

High and medium priority security issues (#1, #2, #3, #4, #5, #10) are now RESOLVED.
dkmnx added a commit that referenced this pull request Feb 9, 2026
feat(config): migrate config file to config.yaml with automatic migra…
dkmnx added a commit that referenced this pull request Feb 9, 2026
Changed logAuditEvent to return errors instead of silently failing
to stderr. This allows callers to decide whether audit failures
should be warnings or fatal errors. All 7 callers now handle
audit errors with ui.PrintWarn() to inform users without
blocking the main operation.

- Changed logAuditEvent signature to return error
- Added defer logger.Close() for resource cleanup
- Updated all callers with error handling pattern
- Updated TestAuditLoggerErrorHandling for new behavior
- Removed unused imports from test file

Fixes: code review issue #4 (Low priority)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant