Skip to content

feat(init): add configuration drift detection and corruption reporting#56

Open
c-ferrier wants to merge 1 commit into
Ian-stetsenko:mainfrom
c-ferrier:feat/init-config-drift-detection
Open

feat(init): add configuration drift detection and corruption reporting#56
c-ferrier wants to merge 1 commit into
Ian-stetsenko:mainfrom
c-ferrier:feat/init-config-drift-detection

Conversation

@c-ferrier

@c-ferrier c-ferrier commented May 16, 2026

Copy link
Copy Markdown
Contributor

Description

This PR enhances the lore init command to be more helpful when re-run on an existing project. It introduces "gap detection" to identify missing configuration
options, "customization detection" to differentiate between default and user-modified settings, and "corruption reporting" for invalid TOML syntax.

Key Changes

  • Drift Detection: Compares existing .lore/config.toml against DEFAULT_CONFIG and lists missing sections/keys.
  • Customization Awareness: Distinguishes between projects using default values (Safe Reset) and those with custom settings (Manual Merge).
  • Corruption Handling: Catching TOML parsing errors and providing specific recovery hints (e.g., mv ... .corrupted && lore init).
  • Guidance: Provides clear instructions based on the user's state:
    • Safe Reset: Suggests simply deleting the default config and re-running init.
    • Manual Merge: Lists specific customized keys and suggests a backup-and-merge workflow.
  • Testing: Added a comprehensive unit test suite in tests/unit/commands/init.test.ts.

Strategic Questions for the Maintainer

  1. Config Drift Management: Is this "advisory" approach preferred for handling new configuration options, or should we consider a more automated "surgical" merge
    that interleaves missing options while preserving user comments?
  2. Overlap with lore doctor: lore doctor already checks for TOML corruption. Does it make sense to duplicate this check in init for better user guidance at
    the moment of initialization, or should we centralize this logic into a shared service?
  3. UX of Hints: Do you like the inclusion of specific shell command examples in the CLI output, or should we keep the output more descriptive?

@c-ferrier c-ferrier requested a review from Ian-stetsenko as a code owner May 16, 2026 15:03
Enhanced 'lore init' to proactively manage configuration evolution. The command now detects when an existing '.lore/config.toml' is missing new protocol options and distinguishes between projects using default values (suggesting a Safe Reset) and those with customizations (advising a Manual Merge). Additionally, it detects and reports TOML syntax corruption with specific recovery hints, using standardized error handling to ensure consistent CLI behavior.

Lore-id: 093537c0
Constraint: Must not destructively overwrite existing configurations
Constraint: Must use standardized LoreError for fatal parsing failures
Constraint: Must distinguish customizations from defaults to minimize user friction
Rejected: Surgical interleaving | High complexity, requires loss-less TOML parser to preserve comments
Rejected: Automated overwriting | Destructive to user-written notes and formatting
Tested: [Vitest] 6 unit tests verify fresh init, gaps, safe reset, manual merge, and corruption scenarios
Tested: Manual verification of recovery hints for corrupted TOML (exit code 1 verified)
Tested: Verified runtime fallback to defaults for missing keys via ConfigLoader
Tested: npm run typecheck and npm run build pass
Confidence: high
Scope-risk: narrow
Reversibility: clean
Assisted-by: Gemini:CLI [lore-protocol]
@c-ferrier c-ferrier force-pushed the feat/init-config-drift-detection branch from f96b398 to 3f0fcfa Compare May 16, 2026 15:41
@c-ferrier

Copy link
Copy Markdown
Contributor Author

Ready for Review.

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