# Update Slots A/B Read-Only Version Slot Contract (`K2161–K2165`) 1. **Active Slot Read-Only Invariant (`Etkin yuva güncellemede yazılmaz`)**: - At any point in runtime, exactly one slot (`SlotId::A` or `SlotId::B`) is the active read-only running slot (`SlotRole::ActiveReadOnly`) and the opposite slot is the inactive staging target (`SlotRole::InactiveStaging`). - Any attempt to begin staging, write image chunks, truncate, abort, or Seal an update on the active slot (`target == active_slot`) is immediately refused with `Error::ActiveSlotReadOnly` before touching slot storage or advancing staging counters. - Throughout any update attempt (whether committed or rejected/aborted), the active slot's image bytes, version, entry address, and domain-separated `TurkOS/ELF-PROGRAM/v1\0` SHA-256 digest (`program_hash`) remain strictly immutable. 2. **Temporary Staging Disk Write to Inactive Slot B (`Geçici diskte B yeni imaj`)**: - Staging begins only on the inactive slot (`SlotId::B` when `SlotId::A` is active) with a strictly higher version (`version > active_version`), non-zero entry address, non-zero expected code/data sizes within `MAX_SLOT_BYTES`, and a non-zero expected `TurkOS/ELF-PROGRAM/v1\0` SHA-256 digest. - Image chunks are written sequentially into the temporary staging disk buffer of the inactive slot without overlap or gap (`offset == written_bytes`). - `finalize_staging` succeeds only when `written_bytes == expected_bytes` and the recomputed `TurkOS/ELF-PROGRAM/v1\0` SHA-256 digest over the staged code and data slices matches `expected_digest`, transitioning the inactive slot to `SlotPhase::StagedReady` while keeping the active slot `SlotId::A` read-only and unchanged. 3. **Incomplete Update & Active-Slot Write Refusal (`A üzerine incomplete update`)**: - Writing to `SlotId::A` while `SlotId::A` is active, attempting to finalize when `written_bytes < expected_bytes` (`Error::IncompleteUpdate`), writing past `expected_bytes` or at a non-contiguous offset (`Error::OffsetMismatch`), or finalizing with a digest mismatch (`Error::DigestMismatch`) is rejected and rolls back the staging lease (`staging_leases == 0`, inactive slot returned to `SlotPhase::Empty`, staging buffer zeroed), preserving the active slot's bytes and SHA-256 digest unchanged.