## Property-Based Test for NPK Installation Atomicity ## ## **Feature:** 01-nip-unified-storage-and-formats ## **Property 4:** Installation Atomicity ## **Validates:** Requirements 11.1, 11.2 ## ## **Property Statement:** ## For any package installation, either all chunks are stored OR none are (no partial state) ## ## **Test Strategy:** ## - Generate random package configurations ## - Simulate various failure scenarios ## - Verify complete rollback on failure ## - Verify complete installation on success ## - Check for no partial state in any case import std/[unittest, os, times, json, options, strutils, random] import nip/[npk, npk_manifest, npk_installer, manifest_parser, cas] # ============================================================================ # Property Test Generators # ============================================================================ proc generateRandomPackageName(): string = ## Generate random package name let prefixes = @["test", "demo", "sample", "example", "mock"] let suffixes = @["pkg", "app", "lib", "tool", "util"] result = prefixes[rand(prefixes.len - 1)] & "-" & suffixes[rand(suffixes.len - 1)] & "-" & $rand(1000) proc generateRandomVersion(): string = ## Generate random semantic version result = $rand(1..5) & "." & $rand(0..20) & "." & $rand(0..100) proc generateRandomChunks(count: int): seq[ChunkData] = ## Generate random chunk data result = @[] for i in 0..