// K2406-K2410: acceptance_harness.zero_tests — Sıfır test başarı reddi // Invariant: Filtre sıfır test döndürürse kapı geçmez // Positive: Bir adlandırılmış Rust test // Counterexample: Yanlış filtreyle zero passed // Acceptance: Harness açık eksik test hatası verir pub const ACCEPTANCE_HARNESS_ZERO_TESTS_SCHEMA: &str = "turkos.os.acceptance_harness.zero_tests.v1"; pub const ACCEPTANCE_HARNESS_ZERO_TESTS_INVARIANT: &str = "Filtre sıfır test döndürürse kapı geçmez"; pub const ACCEPTANCE_HARNESS_ZERO_TESTS_POSITIVE: &str = "Bir adlandırılmış Rust test"; pub const ACCEPTANCE_HARNESS_ZERO_TESTS_COUNTEREXAMPLE: &str = "Yanlış filtreyle zero passed"; pub const ACCEPTANCE_HARNESS_ZERO_TESTS_ACCEPTANCE: &str = "Harness açık eksik test hatası verir"; pub const EXPECTED_NAMED_RUST_TESTS_EXECUTED: u32 = 1; pub const EXPECTED_EXACT_FILTER_MATCHES: u32 = 2; pub const EXPECTED_NONZERO_GATE_VERIFICATIONS: u32 = 2; pub const EXPECTED_ZERO_TEST_PASSES: u32 = 0; #[repr(u8)] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum AcceptanceHarnessZeroTestsError { WrongFilterZeroPassed = 1, ZeroTestFilterAllowedThroughGate = 2, MissingExplicitZeroTestError = 3, NamedRustTestsExecutedMismatch = 4, ExactFilterMatchesMismatch = 5, NonzeroGateVerificationsMismatch = 6, ZeroZeroTestsEpoch = 7, NonMonotonicZeroTestsEpoch = 8, ZeroFilterDigest = 9, UnboundAcceptanceHarnessZeroTestsDigest = 10, AlreadyCommitted = 11, } #[repr(C)] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct AcceptanceHarnessZeroTestsRequest { pub wrong_filter_zero_passed: bool, pub zero_test_filter_allowed_through_gate: bool, pub harness_emits_explicit_missing_test_error: bool, pub named_rust_tests_executed: u32, pub exact_filter_matches: u32, pub nonzero_gate_verifications: u32, pub zero_tests_epoch: u64, pub previous_zero_tests_epoch: u64, pub zero_tests_filter_digest: u64, pub zero_tests_binding_digest: u64, } #[repr(C)] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct AcceptanceHarnessZeroTestsReceipt { pub named_rust_tests_executed: u32, pub exact_filter_matches: u32, pub nonzero_gate_verifications: u32, pub zero_test_passes: u32, pub harness_emits_explicit_missing_test_error: bool, pub zero_tests_epoch: u64, pub zero_tests_filter_digest: u64, pub receipt_digest: u64, } pub const fn compute_acceptance_harness_zero_tests_binding_digest( named_rust_tests_executed: u32, exact_filter_matches: u32, nonzero_gate_verifications: u32, zero_test_passes: u32, zero_tests_epoch: u64, zero_tests_filter_digest: u64, ) -> u64 { let mut h: u64 = 0xcbf2_9ce4_8422_2325; h = (h ^ 0x2410_4148_5a54_5354).wrapping_mul(0x0000_0100_0000_01b3); h = (h ^ (named_rust_tests_executed as u64)).wrapping_mul(0x0000_0100_0000_01b3); h = (h ^ (exact_filter_matches as u64)).wrapping_mul(0x0000_0100_0000_01b3); h = (h ^ (nonzero_gate_verifications as u64)).wrapping_mul(0x0000_0100_0000_01b3); h = (h ^ (zero_test_passes as u64)).wrapping_mul(0x0000_0100_0000_01b3); h = (h ^ zero_tests_epoch).wrapping_mul(0x0000_0100_0000_01b3); h = (h ^ zero_tests_filter_digest).wrapping_mul(0x0000_0100_0000_01b3); h } pub struct AcceptanceHarnessZeroTestsCoordinator { committed: bool, committed_total: u64, rejected_total: u64, zero_test_gate_refusals: u64, zero_test_accounting_refusals: u64, committed_receipt: Option, } impl AcceptanceHarnessZeroTestsCoordinator { pub const fn new() -> Self { Self { committed: false, committed_total: 0, rejected_total: 0, zero_test_gate_refusals: 0, zero_test_accounting_refusals: 0, committed_receipt: None, } } pub fn is_committed(&self) -> bool { self.committed } pub fn committed_total(&self) -> u64 { self.committed_total } pub fn rejected_total(&self) -> u64 { self.rejected_total } pub fn zero_test_gate_refusals(&self) -> u64 { self.zero_test_gate_refusals } pub fn zero_test_accounting_refusals(&self) -> u64 { self.zero_test_accounting_refusals } pub fn committed_receipt(&self) -> Option { self.committed_receipt } pub fn commit_nonzero_test_gate( &mut self, req: &AcceptanceHarnessZeroTestsRequest, ) -> Result { if self.committed { self.rejected_total += 1; return Err(AcceptanceHarnessZeroTestsError::AlreadyCommitted); } if req.wrong_filter_zero_passed { self.rejected_total += 1; self.zero_test_gate_refusals += 1; return Err(AcceptanceHarnessZeroTestsError::WrongFilterZeroPassed); } if req.zero_test_filter_allowed_through_gate { self.rejected_total += 1; self.zero_test_gate_refusals += 1; return Err(AcceptanceHarnessZeroTestsError::ZeroTestFilterAllowedThroughGate); } if !req.harness_emits_explicit_missing_test_error { self.rejected_total += 1; self.zero_test_gate_refusals += 1; return Err(AcceptanceHarnessZeroTestsError::MissingExplicitZeroTestError); } if req.named_rust_tests_executed != EXPECTED_NAMED_RUST_TESTS_EXECUTED { self.rejected_total += 1; self.zero_test_accounting_refusals += 1; return Err(AcceptanceHarnessZeroTestsError::NamedRustTestsExecutedMismatch); } if req.exact_filter_matches != EXPECTED_EXACT_FILTER_MATCHES { self.rejected_total += 1; self.zero_test_accounting_refusals += 1; return Err(AcceptanceHarnessZeroTestsError::ExactFilterMatchesMismatch); } if req.nonzero_gate_verifications != EXPECTED_NONZERO_GATE_VERIFICATIONS { self.rejected_total += 1; self.zero_test_accounting_refusals += 1; return Err(AcceptanceHarnessZeroTestsError::NonzeroGateVerificationsMismatch); } if req.zero_tests_epoch == 0 { self.rejected_total += 1; return Err(AcceptanceHarnessZeroTestsError::ZeroZeroTestsEpoch); } if req.zero_tests_epoch <= req.previous_zero_tests_epoch { self.rejected_total += 1; return Err(AcceptanceHarnessZeroTestsError::NonMonotonicZeroTestsEpoch); } if req.zero_tests_filter_digest == 0 { self.rejected_total += 1; return Err(AcceptanceHarnessZeroTestsError::ZeroFilterDigest); } let expected_binding = compute_acceptance_harness_zero_tests_binding_digest( req.named_rust_tests_executed, req.exact_filter_matches, req.nonzero_gate_verifications, EXPECTED_ZERO_TEST_PASSES, req.zero_tests_epoch, req.zero_tests_filter_digest, ); if req.zero_tests_binding_digest != expected_binding { self.rejected_total += 1; self.zero_test_accounting_refusals += 1; return Err(AcceptanceHarnessZeroTestsError::UnboundAcceptanceHarnessZeroTestsDigest); } self.committed = true; self.committed_total += 1; let receipt = AcceptanceHarnessZeroTestsReceipt { named_rust_tests_executed: req.named_rust_tests_executed, exact_filter_matches: req.exact_filter_matches, nonzero_gate_verifications: req.nonzero_gate_verifications, zero_test_passes: EXPECTED_ZERO_TEST_PASSES, harness_emits_explicit_missing_test_error: true, zero_tests_epoch: req.zero_tests_epoch, zero_tests_filter_digest: req.zero_tests_filter_digest, receipt_digest: expected_binding ^ 0x2410_ACE0_5a54_5354, }; self.committed_receipt = Some(receipt); Ok(receipt) } }