# CONFIGURATION PERSISTENCE CONTRACT (K2386–K2390) - **Move Range:** `K2386–K2390` - **Phase:** `Phase 18 — Daily Use Applications` - **Module:** `configuration.persistence` - **Title:** `Config atomik kalıcılık` - **Invariant:** `Ayar ya eski ya yeni geçerli kayıt olur` - **Positive Case:** `Geçici diskte write rename` (`k2390-cfgwriterename`) - **Counterexample:** `Commit sırasında süreç ölümü` (`k2390-cfgcommitkill`) - **Acceptance Criterion:** `Yeni boot geçerli bir sürüm seçer` - **Crate:** `os-configuration` (`src/persistence.rs`) - **Inspection Symbol:** `os_configuration_persistence` ## 1. Scope and Invariants 1. **Atomic Old-or-New Valid Record Invariant (`K2386–K2387`):** - Configuration persistence on scratch disk must guarantee that at every point either the previous valid record or the newly committed record is selected (`neither_old_nor_new_valid_record == false`, `torn_config_records == 0`), and that the next boot deterministically selects a valid configuration version (`next_boot_selects_valid_version == true`). - Any state that leaves neither old nor new valid record or allows an invalid boot selection is deterministically refused (`ConfigurationPersistenceError::NeitherOldNorNewValidRecord`, `ConfigurationPersistenceError::NextBootSelectedInvalidVersion`). 2. **Refusal of Process Death During Commit (`K2388`):** - If the writer process dies during commit before atomic rename completes (`process_killed_during_commit == true`, `k2390-cfgcommitkill`), the partial write is rejected (`ConfigurationPersistenceError::ProcessKilledDuringCommit`), leaving the existing valid configuration intact and `committed_receipt()` as `None`. 3. **Scratch Disk Write-and-Rename Atomic Persistence (`K2389–K2390`):** - The positive path (`k2390-cfgwriterename`) commits 2 scratch disk write-and-rename operations (`scratch_write_rename_ops == 2`) across 2 valid boot generations (`valid_boot_generations == 2`) with 2 atomic commit witnesses (`atomic_commit_witnesses == 2`) and 0 torn config records (`torn_config_records == 0`), bound by a monotonic `persistence_epoch` and FNV-1a digest (`compute_configuration_persistence_binding_digest`).