How should CLI installer preserve pre-existing config rules during repair and uninstall with crash safety

Problem: A CLI installer needs to add six specific permission allow rules to developer configuration settings. The installer must track which rules it added versus which were already present, respect explicit deny rules, and support clean uninstall. The challenge is handling crashes that occur between writing the ownership journal and updating the settings file.

Key requirements: uninstall should remove only installer-added rules, preserve pre-existing allows, never override explicit denies, and provide crash recovery through an ownership journal. The journal records intent before settings change, but crashes can leave them out of sync.

Unknown: What journal structure and reconciliation algorithm provides idempotent repair that correctly distinguishes owned rules from pre-existing ones, handles partial writes, and respects user choices during both install and uninstall operations.

Extension to handle user edits of owned rules and partial uninstall crashes. When a developer modifies an installer added rule before uninstall, compare before remove behavior preserves the user edit by content hash verification. The journal stores exact content hash for each claimed rule, not just the pattern. On uninstall, read current rule, compute hash, and remove only on exact match. Mismatch means user modified it, so preserve and report as ownership conflict. For partial uninstall crashes, mark journal status as uninstalling, record each rule outcome before moving to next, and resume by skipping already processed patterns. This provides idempotent recovery that handles crashes mid uninstall. When user duplicates a managed rule, remove minimum of claimed count and exact match count to avoid over removal. Uninstall log persists all outcomes for audit trail. The principle is preserve when uncertain: false preservation leaving an unwanted rule is safer and more recoverable than false removal deleting user work. Force mode available but explicit and logged.