// K2491-K2495: release_acceptance.external_signoff — İnsan ve bağımsız dış onay // Invariant: AI veya sahip beyanı review yerine geçmez // Positive: Gerçek güvenlik ve erişim incelemesi // Counterexample: Self review dış onay diye sayılır // Acceptance: Açık dış kapılar sürümde listelenir pub const RELEASE_ACCEPTANCE_EXTERNAL_SIGNOFF_SCHEMA: &str = "turkos.os.release_acceptance.external_signoff.v1"; pub const RELEASE_ACCEPTANCE_EXTERNAL_SIGNOFF_INVARIANT: &str = "AI veya sahip beyanı review yerine geçmez"; pub const RELEASE_ACCEPTANCE_EXTERNAL_SIGNOFF_POSITIVE: &str = "Gerçek güvenlik ve erişim incelemesi"; pub const RELEASE_ACCEPTANCE_EXTERNAL_SIGNOFF_COUNTEREXAMPLE: &str = "Self review dış onay diye sayılır"; pub const RELEASE_ACCEPTANCE_EXTERNAL_SIGNOFF_ACCEPTANCE: &str = "Açık dış kapılar sürümde listelenir"; pub const EXPECTED_INDEPENDENT_REVIEW_TRACKS: u32 = 2; pub const EXPECTED_LISTED_OPEN_EXTERNAL_GATES: u32 = 6; pub const EXPECTED_EXTERNAL_SIGNOFF_SURFACES: u32 = 2; pub const EXPECTED_SELF_OR_AI_EXTERNAL_CLAIMS: u32 = 0; #[repr(u8)] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum ReleaseAcceptanceExternalSignoffError { SelfReviewCountedAsExternalSignoff = 1, AiOrOwnerStatementSubstitutedForReview = 2, OpenExternalGatesOmittedFromRelease = 3, IndependentReviewTracksMismatch = 4, ListedOpenExternalGatesMismatch = 5, ExternalSignoffSurfacesMismatch = 6, ZeroExternalSignoffEpoch = 7, NonMonotonicExternalSignoffEpoch = 8, ZeroExternalSignoffGateDigest = 9, UnboundReleaseAcceptanceExternalSignoffDigest = 10, AlreadyCommitted = 11, } #[repr(C)] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct ReleaseAcceptanceExternalSignoffRequest { pub self_review_counted_as_external_signoff: bool, pub ai_or_owner_statement_substituted_for_review: bool, pub open_external_gates_listed_in_release: bool, pub independent_review_tracks: u32, pub listed_open_external_gates: u32, pub external_signoff_surfaces: u32, pub external_signoff_epoch: u64, pub previous_external_signoff_epoch: u64, pub external_signoff_gate_digest: u64, pub external_signoff_binding_digest: u64, } #[repr(C)] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct ReleaseAcceptanceExternalSignoffReceipt { pub independent_review_tracks: u32, pub listed_open_external_gates: u32, pub external_signoff_surfaces: u32, pub self_or_ai_external_claims: u32, pub open_external_gates_listed_in_release: bool, pub external_signoff_epoch: u64, pub external_signoff_gate_digest: u64, pub receipt_digest: u64, } pub const fn compute_release_acceptance_external_signoff_binding_digest( independent_review_tracks: u32, listed_open_external_gates: u32, external_signoff_surfaces: u32, self_or_ai_external_claims: u32, external_signoff_epoch: u64, external_signoff_gate_digest: u64, ) -> u64 { let mut h: u64 = 0xcbf2_9ce4_8422_2325; h = (h ^ 0x2495_524c_4558_5431).wrapping_mul(0x0000_0100_0000_01b3); h = (h ^ (independent_review_tracks as u64)).wrapping_mul(0x0000_0100_0000_01b3); h = (h ^ (listed_open_external_gates as u64)).wrapping_mul(0x0000_0100_0000_01b3); h = (h ^ (external_signoff_surfaces as u64)).wrapping_mul(0x0000_0100_0000_01b3); h = (h ^ (self_or_ai_external_claims as u64)).wrapping_mul(0x0000_0100_0000_01b3); h = (h ^ external_signoff_epoch).wrapping_mul(0x0000_0100_0000_01b3); h = (h ^ external_signoff_gate_digest).wrapping_mul(0x0000_0100_0000_01b3); h } pub struct ReleaseAcceptanceExternalSignoffCoordinator { committed: bool, committed_total: u64, rejected_total: u64, signoff_independence_refusals: u64, signoff_accounting_refusals: u64, committed_receipt: Option, } impl ReleaseAcceptanceExternalSignoffCoordinator { pub const fn new() -> Self { Self { committed: false, committed_total: 0, rejected_total: 0, signoff_independence_refusals: 0, signoff_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 signoff_independence_refusals(&self) -> u64 { self.signoff_independence_refusals } pub fn signoff_accounting_refusals(&self) -> u64 { self.signoff_accounting_refusals } pub fn committed_receipt(&self) -> Option { self.committed_receipt } pub fn commit_external_signoff( &mut self, req: &ReleaseAcceptanceExternalSignoffRequest, ) -> Result { if self.committed { self.rejected_total += 1; return Err(ReleaseAcceptanceExternalSignoffError::AlreadyCommitted); } if req.self_review_counted_as_external_signoff { self.rejected_total += 1; self.signoff_independence_refusals += 1; return Err(ReleaseAcceptanceExternalSignoffError::SelfReviewCountedAsExternalSignoff); } if req.ai_or_owner_statement_substituted_for_review { self.rejected_total += 1; self.signoff_independence_refusals += 1; return Err( ReleaseAcceptanceExternalSignoffError::AiOrOwnerStatementSubstitutedForReview, ); } if !req.open_external_gates_listed_in_release { self.rejected_total += 1; self.signoff_independence_refusals += 1; return Err(ReleaseAcceptanceExternalSignoffError::OpenExternalGatesOmittedFromRelease); } if req.independent_review_tracks != EXPECTED_INDEPENDENT_REVIEW_TRACKS { self.rejected_total += 1; self.signoff_accounting_refusals += 1; return Err(ReleaseAcceptanceExternalSignoffError::IndependentReviewTracksMismatch); } if req.listed_open_external_gates != EXPECTED_LISTED_OPEN_EXTERNAL_GATES { self.rejected_total += 1; self.signoff_accounting_refusals += 1; return Err(ReleaseAcceptanceExternalSignoffError::ListedOpenExternalGatesMismatch); } if req.external_signoff_surfaces != EXPECTED_EXTERNAL_SIGNOFF_SURFACES { self.rejected_total += 1; self.signoff_accounting_refusals += 1; return Err(ReleaseAcceptanceExternalSignoffError::ExternalSignoffSurfacesMismatch); } if req.external_signoff_epoch == 0 { self.rejected_total += 1; return Err(ReleaseAcceptanceExternalSignoffError::ZeroExternalSignoffEpoch); } if req.external_signoff_epoch <= req.previous_external_signoff_epoch { self.rejected_total += 1; return Err(ReleaseAcceptanceExternalSignoffError::NonMonotonicExternalSignoffEpoch); } if req.external_signoff_gate_digest == 0 { self.rejected_total += 1; return Err(ReleaseAcceptanceExternalSignoffError::ZeroExternalSignoffGateDigest); } let expected_binding = compute_release_acceptance_external_signoff_binding_digest( req.independent_review_tracks, req.listed_open_external_gates, req.external_signoff_surfaces, EXPECTED_SELF_OR_AI_EXTERNAL_CLAIMS, req.external_signoff_epoch, req.external_signoff_gate_digest, ); if req.external_signoff_binding_digest != expected_binding { self.rejected_total += 1; self.signoff_accounting_refusals += 1; return Err( ReleaseAcceptanceExternalSignoffError::UnboundReleaseAcceptanceExternalSignoffDigest, ); } self.committed = true; self.committed_total += 1; let receipt = ReleaseAcceptanceExternalSignoffReceipt { independent_review_tracks: req.independent_review_tracks, listed_open_external_gates: req.listed_open_external_gates, external_signoff_surfaces: req.external_signoff_surfaces, self_or_ai_external_claims: EXPECTED_SELF_OR_AI_EXTERNAL_CLAIMS, open_external_gates_listed_in_release: true, external_signoff_epoch: req.external_signoff_epoch, external_signoff_gate_digest: req.external_signoff_gate_digest, receipt_digest: expected_binding ^ 0x2495_ACE0_4558_5431, }; self.committed_receipt = Some(receipt); Ok(receipt) } }