ASELSANMicrokernel
S426 · SOURCE-BOUND GATE EVIDENCE

S426 · S210 completion reconciliation

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

S426Focused kod testiOperations id exactsource SHA exacttest target exact

operation: g8l-s426-s210-completion-reconciliation-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–L250
kernel/src/g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s426_s210_completion_reconciliation.rs::S426 s210 completion reconciliation implementation
#![allow(unexpected_cfgs)]

//! S426 terminal software-lifecycle reconciliation with the real S210 result.
//!
//! S425 proves that S212 consumed the migration tuple and published S211's
//! request. S426 requires the same IRQ's S210 service to return its exact
//! non-Copy acknowledged handoff before consuming S425 and publishing one
//! terminal software receipt. Runtime/profile and physical observations remain
//! explicitly zero.

use crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s425_s212_consumption_reconciliation::{
    G8lS425S212Completion, G8lS425S212CompletionState,
    G8lS425S212ConsumptionReconciliationError, S425_DIRECT_SCHEDULER_ACCESS_SITES,
    S425_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES, S425_SOURCE_AUDIT_UNITS,
    S425_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES, S425_UNROUTED_DIRECT_ACCESS_SITES,
};

pub const S426_SOURCE_AUDIT_UNITS: usize = S425_SOURCE_AUDIT_UNITS;
pub const S426_DIRECT_SCHEDULER_ACCESS_SITES: usize = S425_DIRECT_SCHEDULER_ACCESS_SITES;
pub const S426_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES: usize =
    S425_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES;
pub const S426_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES: usize =
    S425_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES;
pub const S426_UNROUTED_DIRECT_ACCESS_SITES: usize = S425_UNROUTED_DIRECT_ACCESS_SITES;
pub const S426_TERMINAL_COMPLETION_SLOT_CAPACITY: usize = 1;
pub const S426_PRODUCTION_RECONCILIATION_CALLSITES: usize = 1;
pub const S426_S210_COMPLETION_RECONCILIATION_COMPLETE: bool = true;
pub const S426_MAIN_SOFTWARE_LIFECYCLE_COMPLETE: bool = true;
pub const S426_SUPPORTED_PROFILE_RUNTIME_OBSERVATIONS: usize = 0;

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct G8lS426TerminalCompletionReceipt {
    pub attempt_id: u64,
    pub provider_request_id: u64,
    pub exclusive_token: u64,
    pub s212_reconciled: bool,
    pub s210_completed: bool,
    pub return_handoff_acknowledged: bool,
    pub supported_profile_runtime_observed: bool,
    pub physical_observed: bool,
}

#[derive(Debug)]
pub struct G8lS426TerminalCompletionState {
    pending: Option<G8lS426TerminalCompletionReceipt>,
}

impl G8lS426TerminalCompletionState {
    pub const fn new() -> Self {
        Self { pending: None }
    }
    pub const fn pending(&self) -> bool {
        self.pending.is_some()
    }
    pub fn pending_receipt(
        &self,
        caller_cpu: usize,
    ) -> Result<Option<G8lS426TerminalCompletionReceipt>, G8lS426S210CompletionReconciliationError>
    {
        if caller_cpu != 1 {
            return Err(G8lS426S210CompletionReconciliationError::WrongCpu);
        }
        Ok(self.pending)
    }
    fn publish(
        &mut self,
        receipt: G8lS426TerminalCompletionReceipt,
    ) -> Result<(), G8lS426S210CompletionReconciliationError> {
        if self.pending.is_some() {
            return Err(G8lS426S210CompletionReconciliationError::TerminalSlotOccupied);
        }
        self.pending = Some(receipt);
        Ok(())
    }
    pub fn take(
        &mut self,
        caller_cpu: usize,
    ) -> Result<Option<G8lS426TerminalCompletionReceipt>, G8lS426S210CompletionReconciliationError>
    {
        if caller_cpu != 1 {
            return Err(G8lS426S210CompletionReconciliationError::WrongCpu);
        }
        Ok(self.pending.take())
    }
}

impl Default for G8lS426TerminalCompletionState {
    fn default() -> Self {
        Self::new()
    }
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum G8lS426S210CompletionReconciliationOutcome {
    Idle,
    AwaitingS210Completion,
    TerminalPublished(G8lS426TerminalCompletionReceipt),
    TerminalPending(G8lS426TerminalCompletionReceipt),
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum G8lS426S210CompletionReconciliationError {
    WrongCpu,
    S425(G8lS425S212ConsumptionReconciliationError),
    S425BindingDrift,
    UnboundS210Completion,
    S210AcknowledgementDrift,
    S425Disappeared,
    S425Drift,
    TerminalSlotOccupied,
}

fn terminal_from_s425(
    completion: G8lS425S212Completion,
) -> Result<G8lS426TerminalCompletionReceipt, G8lS426S210CompletionReconciliationError> {
    if completion.attempt_id == 0
        || completion.provider_request_id == 0
        || completion.exclusive_token == 0
        || !completion.s212_tuple_consumed
        || !completion.s211_request_published
        || completion.s210_completed
        || completion.runtime_observed
    {
        return Err(G8lS426S210CompletionReconciliationError::S425BindingDrift);
    }
    Ok(G8lS426TerminalCompletionReceipt {
        attempt_id: completion.attempt_id,
        provider_request_id: completion.provider_request_id,
        exclusive_token: completion.exclusive_token,
        s212_reconciled: true,
        s210_completed: true,
        return_handoff_acknowledged: true,
        supported_profile_runtime_observed: false,
        physical_observed: false,
    })
}

/// Focused model adapter: it accepts only the exact S425 shape and routes it
/// through S425's private one-slot publisher. It creates no authority.
pub fn seed_s426_model_exact_s425_completion(
    state: &mut G8lS425S212CompletionState,
    completion: G8lS425S212Completion,
) -> Result<(), G8lS426S210CompletionReconciliationError> {
    terminal_from_s425(completion)?;
    state
        .publish(completion)
        .map_err(G8lS426S210CompletionReconciliationError::S425)
}

pub fn service_s426_model_s210_completion_reconciliation(
    s425: &mut G8lS425S212CompletionState,
    terminal: &mut G8lS426TerminalCompletionState,
    caller_cpu: usize,
    s210_completed: bool,
    s210_acknowledged: bool,
) -> Result<G8lS426S210CompletionReconciliationOutcome, G8lS426S210CompletionReconciliationError> {
    if caller_cpu != 1 {
        return Err(G8lS426S210CompletionReconciliationError::WrongCpu);
    }
    if let Some(existing) = terminal.pending_receipt(caller_cpu)? {
        return Ok(G8lS426S210CompletionReconciliationOutcome::TerminalPending(
            existing,
        ));
    }
    let completion = s425
        .pending_completion(caller_cpu)
        .map_err(G8lS426S210CompletionReconciliationError::S425)?;
    if !s210_completed {
        return Ok(if completion.is_some() {
            G8lS426S210CompletionReconciliationOutcome::AwaitingS210Completion
        } else {
            G8lS426S210CompletionReconciliationOutcome::Idle
        });
    }
    let completion =
        completion.ok_or(G8lS426S210CompletionReconciliationError::UnboundS210Completion)?;
    if !s210_acknowledged {
        return Err(G8lS426S210CompletionReconciliationError::S210AcknowledgementDrift);
    }
    let terminal_receipt = terminal_from_s425(completion)?;
    let taken = s425
        .take(caller_cpu)
        .map_err(G8lS426S210CompletionReconciliationError::S425)?
        .ok_or(G8lS426S210CompletionReconciliationError::S425Disappeared)?;
    if taken != completion {
        return Err(G8lS426S210CompletionReconciliationError::S425Drift);
    }
    terminal.publish(terminal_receipt)?;
    Ok(G8lS426S210CompletionReconciliationOutcome::TerminalPublished(terminal_receipt))
}

#[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
static S426_PRODUCTION_TERMINAL: spin::Mutex<G8lS426TerminalCompletionState> =
    spin::Mutex::new(G8lS426TerminalCompletionState::new());

#[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
pub fn service_s426_s210_completion_reconciliation_on_cpu1(
    outcome: crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_current_task_runtime_owned_caller::G8lRuntimeOwnedCurrentTaskOwnerServiceOutcome,
) -> Result<G8lS426S210CompletionReconciliationOutcome, G8lS426S210CompletionReconciliationError> {
    use crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_current_task_runtime_owned_caller::G8lRuntimeOwnedCurrentTaskOwnerServiceOutcome;
    if let Some(existing) = S426_PRODUCTION_TERMINAL.lock().pending_receipt(1)? {
        return Ok(G8lS426S210CompletionReconciliationOutcome::TerminalPending(
            existing,
        ));
    }
    let completion = crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s425_s212_consumption_reconciliation::inspect_s425_s212_completion_on_cpu1()
        .map_err(G8lS426S210CompletionReconciliationError::S425)?;
    let acknowledgement = match outcome {
        G8lRuntimeOwnedCurrentTaskOwnerServiceOutcome::Idle => {
            return Ok(if completion.is_some() {
                G8lS426S210CompletionReconciliationOutcome::AwaitingS210Completion
            } else {
                G8lS426S210CompletionReconciliationOutcome::Idle
            });
        }
        G8lRuntimeOwnedCurrentTaskOwnerServiceOutcome::Completed(acknowledgement) => {
            acknowledgement
        }
    };
    let completion =
        completion.ok_or(G8lS426S210CompletionReconciliationError::UnboundS210Completion)?;
    if !acknowledgement.acknowledged()
        || !acknowledgement.acknowledgement_wired()
        || acknowledgement.production_scheduler_mutated()
    {
        return Err(G8lS426S210CompletionReconciliationError::S210AcknowledgementDrift);
    }
    let terminal_receipt = terminal_from_s425(completion)?;
    let taken = crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s425_s212_consumption_reconciliation::take_s425_s212_completion_on_cpu1()
        .map_err(G8lS426S210CompletionReconciliationError::S425)?
        .ok_or(G8lS426S210CompletionReconciliationError::S425Disappeared)?;
    if taken != completion {
        return Err(G8lS426S210CompletionReconciliationError::S425Drift);
    }
    S426_PRODUCTION_TERMINAL.lock().publish(terminal_receipt)?;
    Ok(G8lS426S210CompletionReconciliationOutcome::TerminalPublished(terminal_receipt))
}

#[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
pub fn inspect_s426_terminal_completion_on_cpu1(
) -> Result<Option<G8lS426TerminalCompletionReceipt>, G8lS426S210CompletionReconciliationError> {
    S426_PRODUCTION_TERMINAL.lock().pending_receipt(1)
}

#[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
pub fn take_s426_terminal_completion_on_cpu1(
) -> Result<Option<G8lS426TerminalCompletionReceipt>, G8lS426S210CompletionReconciliationError> {
    S426_PRODUCTION_TERMINAL.lock().take(1)
}
snippet sha256: d37f9cb96e4cfile sha256: d37f9cb96e4c
02 · Doğrulayan test kodu

Operations komutuna bağlı focused test

tam dosyaL1–L136
simulation/tests/g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s426_s210_completion_reconciliation.rs::S426 s210 completion reconciliation focused tests
use aselsan_microkernel_simulation::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s425_s212_consumption_reconciliation::{G8lS425S212Completion, G8lS425S212CompletionState};
use aselsan_microkernel_simulation::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s426_s210_completion_reconciliation::*;

fn s425() -> G8lS425S212CompletionState {
    let mut state = G8lS425S212CompletionState::new();
    // Public state publication is intentionally unavailable; build the exact
    // predecessor through the S426 model adapter used for focused fixtures.
    seed_s426_model_exact_s425_completion(
        &mut state,
        G8lS425S212Completion {
            attempt_id: 7,
            provider_request_id: 8,
            exclusive_token: 9,
            s212_tuple_consumed: true,
            s211_request_published: true,
            s210_completed: false,
            runtime_observed: false,
        },
    )
    .unwrap();
    state
}

#[test]
fn constants_define_terminal_software_completion_slot() {
    assert_eq!(S426_TERMINAL_COMPLETION_SLOT_CAPACITY, 1);
    assert_eq!(S426_PRODUCTION_RECONCILIATION_CALLSITES, 1);
    assert!(S426_S210_COMPLETION_RECONCILIATION_COMPLETE);
    assert!(S426_MAIN_SOFTWARE_LIFECYCLE_COMPLETE);
    assert_eq!(S426_SUPPORTED_PROFILE_RUNTIME_OBSERVATIONS, 0);
}

#[test]
fn exact_s425_and_acknowledged_s210_publish_terminal_receipt() {
    let mut s425 = s425();
    let mut terminal = G8lS426TerminalCompletionState::new();
    let outcome =
        service_s426_model_s210_completion_reconciliation(&mut s425, &mut terminal, 1, true, true)
            .unwrap();
    let G8lS426S210CompletionReconciliationOutcome::TerminalPublished(receipt) = outcome else {
        panic!("terminal")
    };
    assert_eq!(
        (
            receipt.attempt_id,
            receipt.provider_request_id,
            receipt.exclusive_token
        ),
        (7, 8, 9)
    );
    assert!(
        receipt.s212_reconciled && receipt.s210_completed && receipt.return_handoff_acknowledged
    );
    assert!(!receipt.supported_profile_runtime_observed && !receipt.physical_observed);
    assert!(!s425.pending() && terminal.pending());
}

#[test]
fn idle_s210_preserves_s425_completion() {
    let mut s425 = s425();
    let mut terminal = G8lS426TerminalCompletionState::new();
    assert_eq!(
        service_s426_model_s210_completion_reconciliation(
            &mut s425,
            &mut terminal,
            1,
            false,
            false
        )
        .unwrap(),
        G8lS426S210CompletionReconciliationOutcome::AwaitingS210Completion
    );
    assert!(s425.pending());
}

#[test]
fn unacknowledged_or_unbound_s210_completion_fails_closed() {
    let mut s425 = s425();
    let mut terminal = G8lS426TerminalCompletionState::new();
    assert_eq!(
        service_s426_model_s210_completion_reconciliation(&mut s425, &mut terminal, 1, true, false),
        Err(G8lS426S210CompletionReconciliationError::S210AcknowledgementDrift)
    );
    let mut empty = G8lS425S212CompletionState::new();
    assert_eq!(
        service_s426_model_s210_completion_reconciliation(&mut empty, &mut terminal, 1, true, true),
        Err(G8lS426S210CompletionReconciliationError::UnboundS210Completion)
    );
}

#[test]
fn occupied_terminal_slot_preserves_next_s425() {
    let mut first = s425();
    let mut terminal = G8lS426TerminalCompletionState::new();
    service_s426_model_s210_completion_reconciliation(&mut first, &mut terminal, 1, true, true)
        .unwrap();
    let pending = terminal.pending_receipt(1).unwrap().unwrap();
    let mut next = s425();
    assert_eq!(
        service_s426_model_s210_completion_reconciliation(&mut next, &mut terminal, 1, true, true)
            .unwrap(),
        G8lS426S210CompletionReconciliationOutcome::TerminalPending(pending)
    );
    assert!(next.pending());
}

#[test]
fn production_validates_exact_noncopy_s210_ack_before_s425_take() {
    let source = include_str!("../../kernel/src/g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s426_s210_completion_reconciliation.rs");
    let start = source
        .find("service_s426_s210_completion_reconciliation_on_cpu1")
        .unwrap();
    let body = &source[start..];
    let inspect = body.find("inspect_s425_s212_completion_on_cpu1").unwrap();
    let ack = body.find("acknowledged()").unwrap();
    let wired = body.find("acknowledgement_wired()").unwrap();
    let take = body.find("take_s425_s212_completion_on_cpu1").unwrap();
    assert!(inspect < ack && ack < wired && wired < take);
}

#[test]
fn timer_orders_s210_then_s426_before_scheduler_dispatch() {
    let source = include_str!("../../kernel/src/arch/aarch64/exceptions.rs");
    let s210 = source
        .find("service_runtime_owned_current_task_owner_invocation")
        .unwrap();
    let s426 = source
        .find("service_s426_s210_completion_reconciliation_on_cpu1")
        .unwrap();
    let scheduler = source.find("rpi5_g7d::on_timer_irq").unwrap();
    assert!(s210 < s426 && s426 < scheduler);
    let name = "g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s426_s210_completion_reconciliation";
    assert!(include_str!("../../kernel/src/main.rs").contains(&format!("mod {name};")));
    assert!(include_str!("../src/lib.rs").contains(&format!("pub mod {name};")));
}
snippet sha256: 8fe14c771a56file sha256: 8fe14c771a56
03 · Kapı kimlik kaydı

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

tam Operations kaydıL525–L541
website/src/lib/operations.ts::g8l-s426-s210-completion-reconciliation-partial
  {
    id: "g8l-s426-s210-completion-reconciliation-partial",
    sequence: 426,
    slug: "s210_completion_reconciliation",
    title: "S210 completion reconciliation",
    focusedTests: 7,
    sourceBytes: 10443,
    sourceSha256:
      "d37f9cb96e4c42b930cb67b411f8086fac122783a1ba41756f7bcb6d0c0d68d8",
    testBytes: 5451,
    testSha256:
      "8fe14c771a56863ea5394afe5bdc6275d3b24de54659de3d805037303d34025f",
    acceptance:
      "S425 completion exact S210 terminal state ile uzlaştırılır; final typed receipt ana migration-lifecycle software zincirini kaynak düzeyinde kapatır.",
    retainedBoundary:
      "Main software lifecycle complete olsa da supported-profile runtime observation sıfırdır.",
  },
snippet sha256: 0d00a3c5cc24file 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_s426_s210_completion_reconciliation -- --test-threads=1
proof: docs/M8.1-RPi5-G8l-S426-S210-Completion-Reconciliation-Proof.md
Registry schema v5 · generator website/scripts/generate-code-gates.mjs · Tam SHA-256: 3050638b71a684d8f8f947a8a6faa237a17fa8db5dc0db04fb207b668b462af9