ASELSANMicrokernel
S406 · SOURCE-BOUND GATE EVIDENCE

S406 · Scoped provider-authority constructor

tam S406 implementation modülü → Operations --test hedefi ile bağlı tam focused test → ayrı Operations kaydı Bu sayfa yalnız S406 kapısına aittir; komşu kapıların kaynakları bu kabulün içine katılmaz.

S406Focused kod testiOperations id exactsource SHA exacttest target exact

operation: g8l-s406-scoped-provider-authority-constructor-partial

uygulama/model · focused test · Operations · 3 exact excerpt

sequence-bound=true · implementation-bound=true
01 · Yürütme / doğrulama kodu

Kapının gerçek repository sözleşmesi

tam dosyaL1–L305
kernel/src/g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s406_scoped_provider_authority_constructor.rs::S406 scoped provider authority constructor implementation
#![allow(unexpected_cfgs)]

//! S406 scoped provider-authority constructor.
//!
//! S405 paired a pending S404 scoped request with the exact next S245 provider
//! request without consuming either. S406 first repeats that preflight, then
//! constructs S400's live provider authority, and only after exclusion is live
//! takes the exact S404 request. A failed exclusive acquire therefore preserves
//! both work descriptors.
//!
//! The resulting private, non-copyable value binds the S405 receipt, S404
//! request, and S400 authority. Its exclusion claim expires on release/drop.
//! The production constructor is exposed but remains outside the exception
//! chain at S406; admission publication and S243/S236 remain open.

use crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s244_whole_scheduler_exclusion_admission_request::{
    G8lS245WholeSchedulerExclusionAdmissionRequestState, S245_SOURCE_CPU0, S245_TARGET_CPU1,
};
use crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s246_whole_scheduler_read_access_guard::{
    G8lS247WholeSchedulerAccessError, G8lS247WholeSchedulerAccessGate,
};
use crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s400_whole_scheduler_provider_authority_constructor::{
    try_construct_s400_model_provider_authority, G8lS400ProviderAuthorityConstructorError,
    G8lS400WholeSchedulerProviderAuthority,
};
use crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s404_scoped_authority_request_publication::{
    G8lS404ScopedAuthorityRequest, G8lS404ScopedAuthorityRequestError,
    G8lS404ScopedAuthorityRequestReason, G8lS404ScopedAuthorityRequestState,
};
use crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s405_scoped_authority_provider_preflight::{
    preflight_s405_scoped_authority_provider,
    G8lS405ScopedAuthorityProviderPreflightError,
    G8lS405ScopedAuthorityProviderPreflightOutcome,
    G8lS405ScopedAuthorityProviderPreflightReceipt, S405_DIRECT_SCHEDULER_ACCESS_SITES,
    S405_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES, S405_SOURCE_AUDIT_UNITS,
    S405_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES, S405_UNROUTED_DIRECT_ACCESS_SITES,
};

pub const S406_SOURCE_AUDIT_UNITS: usize = S405_SOURCE_AUDIT_UNITS;
pub const S406_DIRECT_SCHEDULER_ACCESS_SITES: usize = S405_DIRECT_SCHEDULER_ACCESS_SITES;
pub const S406_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES: usize =
    S405_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES;
pub const S406_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES: usize =
    S405_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES;
pub const S406_UNROUTED_DIRECT_ACCESS_SITES: usize = S405_UNROUTED_DIRECT_ACCESS_SITES;
pub const S406_PRODUCTION_SCOPED_AUTHORITY_CONSTRUCTOR_SITES: usize = 1;
pub const S406_PRODUCTION_SCOPED_AUTHORITY_INVOCATION_CALLSITES: usize = 0;
pub const S406_PRODUCTION_ADMISSION_PUBLISHER_SITES: usize = 0;
pub const S406_SCOPED_PROVIDER_AUTHORITY_CONSTRUCTOR_COMPLETE: bool = true;
pub const S406_EXCLUSION_PROOF_AVAILABLE_WHILE_AUTHORITY_LIVE: bool = true;
pub const S406_END_TO_END_EXCLUSION_ADMISSION_COMPLETE: bool = false;

#[derive(Debug)]
pub struct G8lS406ScopedProviderAuthority<'a> {
    provider: G8lS400WholeSchedulerProviderAuthority<'a>,
    preflight: G8lS405ScopedAuthorityProviderPreflightReceipt,
    scoped_request: G8lS404ScopedAuthorityRequest,
}

impl G8lS406ScopedProviderAuthority<'_> {
    pub const fn attempt_id(&self) -> u64 {
        self.preflight.attempt_id()
    }

    pub const fn observed_request_id(&self) -> u64 {
        self.preflight.observed_request_id()
    }

    pub const fn prior_exclusive_token(&self) -> u64 {
        self.preflight.prior_exclusive_token()
    }

    pub const fn provider_request_id(&self) -> u64 {
        self.provider.request_id()
    }

    pub const fn exclusive_token(&self) -> u64 {
        self.provider.exclusive_token()
    }

    pub const fn scoped_request_consumed(&self) -> bool {
        self.scoped_request.attempt_id() == self.preflight.attempt_id()
    }

    pub const fn provider_request_consumed(&self) -> bool {
        self.provider.request_consumed()
    }

    pub const fn is_provider_authority(&self) -> bool {
        self.provider.is_provider_authority()
    }

    pub const fn whole_scheduler_exclusion_proven(&self) -> bool {
        self.provider.whole_scheduler_exclusion_proven()
    }

    pub const fn admission_published(&self) -> bool {
        false
    }

    pub fn release(
        self,
    ) -> Result<G8lS406ScopedProviderAuthorityReleaseReceipt, G8lS247WholeSchedulerAccessError>
    {
        let attempt_id = self.attempt_id();
        let provider_request_id = self.provider_request_id();
        let released = self.provider.release()?;
        Ok(G8lS406ScopedProviderAuthorityReleaseReceipt {
            attempt_id,
            provider_request_id,
            exclusive_token: released.exclusive_token(),
        })
    }
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct G8lS406ScopedProviderAuthorityReleaseReceipt {
    attempt_id: u64,
    provider_request_id: u64,
    exclusive_token: u64,
}

impl G8lS406ScopedProviderAuthorityReleaseReceipt {
    pub const fn attempt_id(&self) -> u64 {
        self.attempt_id
    }

    pub const fn provider_request_id(&self) -> u64 {
        self.provider_request_id
    }

    pub const fn exclusive_token(&self) -> u64 {
        self.exclusive_token
    }

    pub const fn is_provider_authority(&self) -> bool {
        false
    }

    pub const fn whole_scheduler_exclusion_proven(&self) -> bool {
        false
    }
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum G8lS406ScopedProviderAuthorityConstructorError {
    S405(G8lS405ScopedAuthorityProviderPreflightError),
    S400(G8lS400ProviderAuthorityConstructorError),
    S404(G8lS404ScopedAuthorityRequestError),
    ProviderAuthorityMissingAfterPreflight,
    ScopedRequestDisappearedAfterAuthority,
    BindingDrift,
}

fn binding_is_exact(
    preflight: &G8lS405ScopedAuthorityProviderPreflightReceipt,
    scoped: &G8lS404ScopedAuthorityRequest,
    provider_request_id: u64,
    exclusive_token: u64,
) -> bool {
    preflight.attempt_id() != 0
        && preflight.attempt_id() == scoped.attempt_id()
        && preflight.observed_request_id() == scoped.observed_request_id()
        && preflight.prior_exclusive_token() == scoped.prior_exclusive_token()
        && preflight.provider_request_id() == provider_request_id
        && scoped.source_cpu() == S245_SOURCE_CPU0
        && scoped.target_cpu() == S245_TARGET_CPU1
        && scoped.reason() == G8lS404ScopedAuthorityRequestReason::PostReleaseObservationVerified
        && !scoped.is_authority()
        && !scoped.whole_scheduler_exclusion_proven()
        && exclusive_token > preflight.prior_exclusive_token()
}

pub fn try_construct_s406_model_scoped_provider_authority<'a>(
    gate: &'a G8lS247WholeSchedulerAccessGate,
    provider_requests: &mut G8lS245WholeSchedulerExclusionAdmissionRequestState,
    scoped_requests: &mut G8lS404ScopedAuthorityRequestState,
    caller_cpu: usize,
) -> Result<
    Option<G8lS406ScopedProviderAuthority<'a>>,
    G8lS406ScopedProviderAuthorityConstructorError,
> {
    let preflight =
        preflight_s405_scoped_authority_provider(scoped_requests, provider_requests, caller_cpu)
            .map_err(G8lS406ScopedProviderAuthorityConstructorError::S405)?;
    let preflight = match preflight {
        G8lS405ScopedAuthorityProviderPreflightOutcome::Idle
        | G8lS405ScopedAuthorityProviderPreflightOutcome::AwaitingProviderRequest { .. } => {
            return Ok(None)
        }
        G8lS405ScopedAuthorityProviderPreflightOutcome::Ready(receipt) => receipt,
    };
    let provider = try_construct_s400_model_provider_authority(gate, provider_requests, caller_cpu)
        .map_err(G8lS406ScopedProviderAuthorityConstructorError::S400)?
        .ok_or(
            G8lS406ScopedProviderAuthorityConstructorError::ProviderAuthorityMissingAfterPreflight,
        )?;
    let scoped = scoped_requests
        .take(caller_cpu)
        .map_err(G8lS406ScopedProviderAuthorityConstructorError::S404)?
        .ok_or(
            G8lS406ScopedProviderAuthorityConstructorError::ScopedRequestDisappearedAfterAuthority,
        )?;
    if !binding_is_exact(
        &preflight,
        &scoped,
        provider.request_id(),
        provider.exclusive_token(),
    ) {
        return Err(G8lS406ScopedProviderAuthorityConstructorError::BindingDrift);
    }
    Ok(Some(G8lS406ScopedProviderAuthority {
        provider,
        preflight,
        scoped_request: scoped,
    }))
}

#[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
pub struct G8lS406ProductionScopedProviderAuthority {
    provider: crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s400_whole_scheduler_provider_authority_constructor::G8lS400ProductionWholeSchedulerProviderAuthority,
    preflight: G8lS405ScopedAuthorityProviderPreflightReceipt,
    scoped_request: G8lS404ScopedAuthorityRequest,
}

#[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
impl G8lS406ProductionScopedProviderAuthority {
    pub const fn attempt_id(&self) -> u64 {
        self.preflight.attempt_id()
    }

    pub const fn provider_request_id(&self) -> u64 {
        self.provider.request_id()
    }

    pub const fn exclusive_token(&self) -> u64 {
        self.provider.exclusive_token()
    }

    pub const fn is_provider_authority(&self) -> bool {
        self.provider.is_provider_authority()
    }

    pub const fn whole_scheduler_exclusion_proven(&self) -> bool {
        self.provider.whole_scheduler_exclusion_proven()
    }

    pub const fn admission_published(&self) -> bool {
        false
    }

    pub fn release(
        self,
    ) -> Result<G8lS406ScopedProviderAuthorityReleaseReceipt, G8lS247WholeSchedulerAccessError>
    {
        let attempt_id = self.attempt_id();
        let provider_request_id = self.provider_request_id();
        let released = self.provider.release()?;
        Ok(G8lS406ScopedProviderAuthorityReleaseReceipt {
            attempt_id,
            provider_request_id,
            exclusive_token: released.exclusive_token(),
        })
    }
}

#[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
pub fn try_construct_s406_production_scoped_provider_authority_on_cpu1() -> Result<
    Option<G8lS406ProductionScopedProviderAuthority>,
    G8lS406ScopedProviderAuthorityConstructorError,
> {
    let preflight = crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s405_scoped_authority_provider_preflight::service_s405_scoped_authority_provider_preflight_on_cpu1()
        .map_err(G8lS406ScopedProviderAuthorityConstructorError::S405)?;
    let preflight = match preflight {
        G8lS405ScopedAuthorityProviderPreflightOutcome::Idle
        | G8lS405ScopedAuthorityProviderPreflightOutcome::AwaitingProviderRequest { .. } => {
            return Ok(None)
        }
        G8lS405ScopedAuthorityProviderPreflightOutcome::Ready(receipt) => receipt,
    };
    let provider = crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s400_whole_scheduler_provider_authority_constructor::try_construct_s400_production_provider_authority_on_cpu1()
        .map_err(G8lS406ScopedProviderAuthorityConstructorError::S400)?
        .ok_or(
            G8lS406ScopedProviderAuthorityConstructorError::ProviderAuthorityMissingAfterPreflight,
        )?;
    let scoped = crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s404_scoped_authority_request_publication::take_s404_scoped_authority_request_on_cpu1()
        .map_err(G8lS406ScopedProviderAuthorityConstructorError::S404)?
        .ok_or(
            G8lS406ScopedProviderAuthorityConstructorError::ScopedRequestDisappearedAfterAuthority,
        )?;
    if !binding_is_exact(
        &preflight,
        &scoped,
        provider.request_id(),
        provider.exclusive_token(),
    ) {
        return Err(G8lS406ScopedProviderAuthorityConstructorError::BindingDrift);
    }
    Ok(Some(G8lS406ProductionScopedProviderAuthority {
        provider,
        preflight,
        scoped_request: scoped,
    }))
}
snippet sha256: 1a782625c55ffile sha256: 1a782625c55f
02 · Doğrulayan test kodu

Operations komutuna bağlı focused test

tam dosyaL1–L321
simulation/tests/g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s406_scoped_provider_authority_constructor.rs::S406 scoped provider authority constructor focused tests
#![recursion_limit = "256"]

use aselsan_microkernel_simulation::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s244_whole_scheduler_exclusion_admission_request::{
    service_s245_exclusion_admission_request, G8lS245ExclusionAdmissionRequestOutcome,
    G8lS245WholeSchedulerExclusionAdmissionRequestState, S245_SOURCE_CPU0, S245_TARGET_CPU1,
};
use aselsan_microkernel_simulation::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s246_whole_scheduler_read_access_guard::{
    G8lS247WholeSchedulerAccessError, G8lS247WholeSchedulerAccessGate,
};
use aselsan_microkernel_simulation::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s402_provider_invocation_observation_publication::{
    service_s402_model_provider_invocation_observation_publication,
    G8lS402ProviderInvocationObservationState,
};
use aselsan_microkernel_simulation::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s404_scoped_authority_request_publication::{
    service_s404_model_scoped_authority_request_publication,
    G8lS404ScopedAuthorityRequestState,
};
use aselsan_microkernel_simulation::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s405_scoped_authority_provider_preflight::{
    S405_DIRECT_SCHEDULER_ACCESS_SITES, S405_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES,
    S405_SOURCE_AUDIT_UNITS, S405_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES,
    S405_UNROUTED_DIRECT_ACCESS_SITES,
};
use aselsan_microkernel_simulation::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s406_scoped_provider_authority_constructor::*;

fn paired_states(
    first_request_id: u64,
) -> (
    G8lS247WholeSchedulerAccessGate,
    G8lS245WholeSchedulerExclusionAdmissionRequestState,
    G8lS404ScopedAuthorityRequestState,
) {
    let gate = G8lS247WholeSchedulerAccessGate::new();
    let mut providers =
        G8lS245WholeSchedulerExclusionAdmissionRequestState::with_next_request_id(first_request_id);
    assert!(matches!(
        service_s245_exclusion_admission_request(&mut providers, S245_SOURCE_CPU0, true, true),
        Ok(G8lS245ExclusionAdmissionRequestOutcome::RequestPublished(id)) if id == first_request_id
    ));
    let mut observations = G8lS402ProviderInvocationObservationState::new();
    service_s402_model_provider_invocation_observation_publication(
        &mut observations,
        &gate,
        &mut providers,
        S245_TARGET_CPU1,
    )
    .unwrap();
    let mut scoped = G8lS404ScopedAuthorityRequestState::new();
    service_s404_model_scoped_authority_request_publication(
        &mut scoped,
        &mut observations,
        S245_SOURCE_CPU0,
    )
    .unwrap();
    assert!(matches!(
        service_s245_exclusion_admission_request(&mut providers, S245_SOURCE_CPU0, true, true),
        Ok(G8lS245ExclusionAdmissionRequestOutcome::RequestPublished(id)) if id == first_request_id + 1
    ));
    (gate, providers, scoped)
}

fn module_source() -> &'static str {
    include_str!("../../kernel/src/g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s406_scoped_provider_authority_constructor.rs")
}

fn exception_source() -> &'static str {
    include_str!("../../kernel/src/arch/aarch64/exceptions.rs")
}

fn kernel_main_source() -> &'static str {
    include_str!("../../kernel/src/main.rs")
}

fn simulation_lib_source() -> &'static str {
    include_str!("../src/lib.rs")
}

#[test]
fn constants_promote_only_the_scoped_live_authority_constructor() {
    assert_eq!(S406_SOURCE_AUDIT_UNITS, 7);
    assert_eq!(S406_DIRECT_SCHEDULER_ACCESS_SITES, 113);
    assert_eq!(S406_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES, 113);
    assert_eq!(S406_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES, 113);
    assert_eq!(S406_UNROUTED_DIRECT_ACCESS_SITES, 0);
    assert_eq!(S406_PRODUCTION_SCOPED_AUTHORITY_CONSTRUCTOR_SITES, 1);
    assert_eq!(S406_PRODUCTION_SCOPED_AUTHORITY_INVOCATION_CALLSITES, 0);
    assert_eq!(S406_PRODUCTION_ADMISSION_PUBLISHER_SITES, 0);
    assert!(S406_SCOPED_PROVIDER_AUTHORITY_CONSTRUCTOR_COMPLETE);
    assert!(S406_EXCLUSION_PROOF_AVAILABLE_WHILE_AUTHORITY_LIVE);
    assert!(!S406_END_TO_END_EXCLUSION_ADMISSION_COMPLETE);
}

#[test]
fn s405_is_the_exact_preflight_predecessor() {
    assert_eq!(S406_SOURCE_AUDIT_UNITS, S405_SOURCE_AUDIT_UNITS);
    assert_eq!(
        S406_DIRECT_SCHEDULER_ACCESS_SITES,
        S405_DIRECT_SCHEDULER_ACCESS_SITES
    );
    assert_eq!(
        S406_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES,
        S405_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES
    );
    assert_eq!(
        S406_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES,
        S405_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES
    );
    assert_eq!(
        S406_UNROUTED_DIRECT_ACCESS_SITES,
        S405_UNROUTED_DIRECT_ACCESS_SITES
    );
}

#[test]
fn exact_pair_constructs_one_live_scoped_provider_authority() {
    let (gate, mut providers, mut scoped) = paired_states(10);
    let authority = try_construct_s406_model_scoped_provider_authority(
        &gate,
        &mut providers,
        &mut scoped,
        S245_TARGET_CPU1,
    )
    .unwrap()
    .unwrap();
    assert_eq!(authority.attempt_id(), 10);
    assert_eq!(authority.observed_request_id(), 10);
    assert_eq!(authority.provider_request_id(), 11);
    assert_eq!(authority.prior_exclusive_token(), 1);
    assert_eq!(authority.exclusive_token(), 2);
    assert!(authority.scoped_request_consumed());
    assert!(authority.provider_request_consumed());
    assert!(authority.is_provider_authority());
    assert!(authority.whole_scheduler_exclusion_proven());
    assert!(!authority.admission_published());
    assert!(!providers.pending());
    assert!(!scoped.pending());
    assert_eq!(gate.active_exclusive_token(), Some(2));
}

#[test]
fn explicit_release_returns_non_authoritative_bound_receipt() {
    let (gate, mut providers, mut scoped) = paired_states(1);
    let authority = try_construct_s406_model_scoped_provider_authority(
        &gate,
        &mut providers,
        &mut scoped,
        S245_TARGET_CPU1,
    )
    .unwrap()
    .unwrap();
    let receipt = authority.release().unwrap();
    assert_eq!(receipt.attempt_id(), 1);
    assert_eq!(receipt.provider_request_id(), 2);
    assert_eq!(receipt.exclusive_token(), 2);
    assert!(!receipt.is_provider_authority());
    assert!(!receipt.whole_scheduler_exclusion_proven());
    assert_eq!(gate.active_exclusive_token(), None);
}

#[test]
fn dropping_authority_releases_the_exact_gate() {
    let (gate, mut providers, mut scoped) = paired_states(3);
    let authority = try_construct_s406_model_scoped_provider_authority(
        &gate,
        &mut providers,
        &mut scoped,
        S245_TARGET_CPU1,
    )
    .unwrap()
    .unwrap();
    drop(authority);
    assert_eq!(gate.active_exclusive_token(), None);
}

#[test]
fn busy_reader_preserves_both_requests_for_retry() {
    let (gate, mut providers, mut scoped) = paired_states(5);
    let reader = gate.try_acquire_read(S245_SOURCE_CPU0).unwrap();
    assert!(matches!(
        try_construct_s406_model_scoped_provider_authority(
            &gate,
            &mut providers,
            &mut scoped,
            S245_TARGET_CPU1
        ),
        Err(G8lS406ScopedProviderAuthorityConstructorError::S400(
            aselsan_microkernel_simulation::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s400_whole_scheduler_provider_authority_constructor::G8lS400ProviderAuthorityConstructorError::Access(
                G8lS247WholeSchedulerAccessError::ExclusiveBusy {
                    active_readers: 1,
                    active_token: None
                }
            )
        ))
    ));
    assert_eq!(providers.pending_request_id(), Some(6));
    assert!(scoped.pending());
    drop(reader);
}

#[test]
fn missing_scoped_request_is_idle_and_preserves_provider_request() {
    let (_gate, mut providers, _scoped_from_pair) = paired_states(1);
    let gate = G8lS247WholeSchedulerAccessGate::new();
    let mut scoped = G8lS404ScopedAuthorityRequestState::new();
    assert!(try_construct_s406_model_scoped_provider_authority(
        &gate,
        &mut providers,
        &mut scoped,
        S245_TARGET_CPU1
    )
    .unwrap()
    .is_none());
    assert_eq!(providers.pending_request_id(), Some(2));
}

#[test]
fn wrong_cpu_preserves_both_requests_and_gate() {
    let (gate, mut providers, mut scoped) = paired_states(7);
    assert!(matches!(
        try_construct_s406_model_scoped_provider_authority(
            &gate,
            &mut providers,
            &mut scoped,
            S245_SOURCE_CPU0
        ),
        Err(G8lS406ScopedProviderAuthorityConstructorError::S405(
            aselsan_microkernel_simulation::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s405_scoped_authority_provider_preflight::G8lS405ScopedAuthorityProviderPreflightError::WrongCpu
        ))
    ));
    assert_eq!(providers.pending_request_id(), Some(8));
    assert!(scoped.pending());
    assert_eq!(gate.active_exclusive_token(), None);
}

#[test]
fn constructor_orders_s405_then_s400_then_scoped_take() {
    let source = module_source();
    let start = source
        .find("pub fn try_construct_s406_model_scoped_provider_authority")
        .unwrap();
    let function: String = source[start..].split_whitespace().collect();
    let preflight = function
        .find("preflight_s405_scoped_authority_provider")
        .unwrap();
    let provider = function
        .find("try_construct_s400_model_provider_authority")
        .unwrap();
    let scoped_take = function.find("scoped_requests.take(caller_cpu)").unwrap();
    assert!(preflight < provider && provider < scoped_take);
}

#[test]
fn scoped_authority_is_private_non_copy_non_clone_and_needs_drop() {
    assert!(core::mem::needs_drop::<
        G8lS406ScopedProviderAuthority<'static>,
    >());
    let source = module_source();
    let start = source
        .find("pub struct G8lS406ScopedProviderAuthority")
        .unwrap();
    let derive = source[..start].rfind("#[derive").unwrap();
    assert_eq!(source[derive..start].trim(), "#[derive(Debug)]");
    let body = &source[start..source[start..].find("}\n\nimpl").unwrap() + start];
    assert!(!body.contains("pub provider:"));
    assert!(!body.contains("pub scoped_request:"));
}

#[test]
fn production_constructor_uses_s405_s400_then_exact_s404_take() {
    let source = module_source();
    let start = source
        .find("pub fn try_construct_s406_production_scoped_provider_authority_on_cpu1")
        .unwrap();
    let function = &source[start..];
    let preflight = function
        .find("service_s405_scoped_authority_provider_preflight_on_cpu1")
        .unwrap();
    let provider = function
        .find("try_construct_s400_production_provider_authority_on_cpu1")
        .unwrap();
    let scoped = function
        .find("take_s404_scoped_authority_request_on_cpu1")
        .unwrap();
    assert!(preflight < provider && provider < scoped);
}

#[test]
fn production_constructor_is_exposed_but_not_invoked_by_exception_chain() {
    assert!(
        module_source().contains("try_construct_s406_production_scoped_provider_authority_on_cpu1")
    );
    assert!(!exception_source()
        .contains("try_construct_s406_production_scoped_provider_authority_on_cpu1"));
    assert_eq!(S406_PRODUCTION_SCOPED_AUTHORITY_INVOCATION_CALLSITES, 0);
}

#[test]
fn s406_does_not_publish_admission_or_enter_s243() {
    let source = module_source();
    for forbidden in [
        "publish_s244",
        "service_s243_deferred_authority_receipt_join",
        "addr_of!(",
        "addr_of_mut!(",
    ] {
        assert!(
            !source.contains(forbidden),
            "forbidden promotion: {forbidden}"
        );
    }
}

#[test]
fn s406_and_its_exact_s407_offer_publisher_are_registered_separately() {
    let s406 = "g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s406_scoped_provider_authority_constructor";
    let s407 = "g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s407_live_exclusion_offer_publication";
    assert!(kernel_main_source().contains(&format!("mod {s406};")));
    assert!(simulation_lib_source().contains(&format!("pub mod {s406};")));
    assert!(kernel_main_source().contains(&format!("mod {s407};")));
    assert!(simulation_lib_source().contains(&format!("pub mod {s407};")));
}
snippet sha256: ce7dccf40ad6file sha256: ce7dccf40ad6
03 · Kapı kimlik kaydı

Operations sıra, kimlik ve başlık bağı

tam Operations kaydıL185–L201
website/src/lib/operations.ts::g8l-s406-scoped-provider-authority-constructor-partial
  {
    id: "g8l-s406-scoped-provider-authority-constructor-partial",
    sequence: 406,
    slug: "scoped_provider_authority_constructor",
    title: "Scoped provider-authority constructor",
    focusedTests: 14,
    sourceBytes: 12468,
    sourceSha256:
      "1a782625c55f19c076d20ff0202844032324d43d9621a98be329de9b6d521d93",
    testBytes: 12604,
    testSha256:
      "ce7dccf40ad69477c03513830326469a19710a190e4405f94bea7a9dd4aadb98",
    acceptance:
      "S405 preflight sonrası shared S247 exclusive lease alınır; exact S245 ve S404 girdileri one-shot tüketilip live scoped provider authority'de birleştirilir.",
    retainedBoundary:
      "Constructor production'da exposed olsa da invocation callsite ve live offer publication bu kapıda yoktur.",
  },
snippet sha256: b5bae79cde9ffile sha256: 9726dbf00f84
Focused test komutu
CARGO_INCREMENTAL=0 cargo test -p aselsan_microkernel_simulation --test g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s406_scoped_provider_authority_constructor -- --test-threads=1
proof: docs/M8.1-RPi5-G8l-S406-Scoped-Provider-Authority-Constructor-Proof.md
Registry schema v5 · generator website/scripts/generate-code-gates.mjs · Tam SHA-256: 3050638b71a684d8f8f947a8a6faa237a17fa8db5dc0db04fb207b668b462af9