ASELSANMicrokernel
S419 · SOURCE-BOUND GATE EVIDENCE

S419 · Handshake terminal journal

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

S419Focused kod testiOperations id exactsource SHA exacttest target exact

operation: g8l-s419-handshake-terminal-journal-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–L187
kernel/src/g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s419_handshake_terminal_journal.rs::S419 handshake terminal journal implementation
#![allow(unexpected_cfgs)]

//! S419 one-slot journal for terminal S416 handshake outcomes.
//!
//! CPU1 records either successful ACK-bound release or bounded timeout release
//! for CPU0 reconciliation. Exact replay is idempotent; a different terminal
//! result cannot overwrite an unconsumed record. Journal records are metadata,
//! never authority or exclusion proof.

use crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s418_cpu0_partial_state_reconciliation::{
    S418_DIRECT_SCHEDULER_ACCESS_SITES, S418_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES,
    S418_SOURCE_AUDIT_UNITS, S418_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES,
    S418_UNROUTED_DIRECT_ACCESS_SITES,
};

pub const S419_SOURCE_AUDIT_UNITS: usize = S418_SOURCE_AUDIT_UNITS;
pub const S419_DIRECT_SCHEDULER_ACCESS_SITES: usize = S418_DIRECT_SCHEDULER_ACCESS_SITES;
pub const S419_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES: usize =
    S418_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES;
pub const S419_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES: usize =
    S418_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES;
pub const S419_UNROUTED_DIRECT_ACCESS_SITES: usize = S418_UNROUTED_DIRECT_ACCESS_SITES;
pub const S419_TERMINAL_JOURNAL_CAPACITY: usize = 1;
pub const S419_PRODUCTION_PUBLICATION_CALLSITES: usize = 1;
pub const S419_HANDSHAKE_TERMINAL_JOURNAL_COMPLETE: bool = true;
pub const S419_CPU0_RECONCILIATION_COMPLETE: bool = false;

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum G8lS419HandshakeTerminalKind {
    Completed,
    TimedOutReleased,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct G8lS419HandshakeTerminalRecord {
    pub kind: G8lS419HandshakeTerminalKind,
    pub attempt_id: u64,
    pub provider_request_id: u64,
    pub exclusive_token: u64,
    pub polls: usize,
    pub source_cpu: usize,
    pub target_cpu: usize,
    pub is_authority: bool,
}

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

impl G8lS419HandshakeTerminalJournalState {
    pub const fn new() -> Self {
        Self { pending: None }
    }
    pub const fn pending(&self) -> bool {
        self.pending.is_some()
    }
    pub fn pending_record(
        &self,
        caller_cpu: usize,
    ) -> Result<Option<G8lS419HandshakeTerminalRecord>, G8lS419HandshakeTerminalJournalError> {
        if caller_cpu != 0 {
            return Err(G8lS419HandshakeTerminalJournalError::WrongConsumerCpu);
        }
        Ok(self.pending)
    }
    pub fn take(
        &mut self,
        caller_cpu: usize,
    ) -> Result<Option<G8lS419HandshakeTerminalRecord>, G8lS419HandshakeTerminalJournalError> {
        if caller_cpu != 0 {
            return Err(G8lS419HandshakeTerminalJournalError::WrongConsumerCpu);
        }
        Ok(self.pending.take())
    }
}

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

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum G8lS419HandshakeTerminalJournalError {
    WrongProducerCpu,
    WrongConsumerCpu,
    BindingDrift,
    SlotOccupied,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum G8lS419HandshakeTerminalJournalOutcome {
    Idle,
    Published(G8lS419HandshakeTerminalRecord),
    Pending(G8lS419HandshakeTerminalRecord),
}

pub fn service_s419_model_handshake_terminal_journal(
    state: &mut G8lS419HandshakeTerminalJournalState,
    caller_cpu: usize,
    kind: G8lS419HandshakeTerminalKind,
    attempt_id: u64,
    provider_request_id: u64,
    exclusive_token: u64,
    polls: usize,
) -> Result<G8lS419HandshakeTerminalJournalOutcome, G8lS419HandshakeTerminalJournalError> {
    if caller_cpu != 1 {
        return Err(G8lS419HandshakeTerminalJournalError::WrongProducerCpu);
    }
    if attempt_id == 0 || provider_request_id == 0 || exclusive_token == 0 || polls == 0 {
        return Err(G8lS419HandshakeTerminalJournalError::BindingDrift);
    }
    let record = G8lS419HandshakeTerminalRecord {
        kind,
        attempt_id,
        provider_request_id,
        exclusive_token,
        polls,
        source_cpu: 1,
        target_cpu: 0,
        is_authority: false,
    };
    if let Some(existing) = state.pending {
        return if existing == record {
            Ok(G8lS419HandshakeTerminalJournalOutcome::Pending(existing))
        } else {
            Err(G8lS419HandshakeTerminalJournalError::SlotOccupied)
        };
    }
    state.pending = Some(record);
    Ok(G8lS419HandshakeTerminalJournalOutcome::Published(record))
}

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

#[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
pub fn service_s419_handshake_terminal_journal_on_cpu1(
    outcome: crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s416_production_exclusion_handshake_invocation::G8lS416ProductionExclusionHandshakeOutcome,
) -> Result<G8lS419HandshakeTerminalJournalOutcome, G8lS419HandshakeTerminalJournalError> {
    use crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s416_production_exclusion_handshake_invocation::G8lS416ProductionExclusionHandshakeOutcome;
    match outcome {
        G8lS416ProductionExclusionHandshakeOutcome::Idle => {
            Ok(G8lS419HandshakeTerminalJournalOutcome::Idle)
        }
        G8lS416ProductionExclusionHandshakeOutcome::Completed { receipt, polls } => {
            service_s419_model_handshake_terminal_journal(
                &mut S419_PRODUCTION_TERMINAL_JOURNAL.lock(),
                1,
                G8lS419HandshakeTerminalKind::Completed,
                receipt.attempt_id(),
                receipt.provider_request_id(),
                receipt.exclusive_token(),
                polls,
            )
        }
        G8lS416ProductionExclusionHandshakeOutcome::TimedOutReleased {
            attempt_id,
            provider_request_id,
            exclusive_token,
            polls,
        } => service_s419_model_handshake_terminal_journal(
            &mut S419_PRODUCTION_TERMINAL_JOURNAL.lock(),
            1,
            G8lS419HandshakeTerminalKind::TimedOutReleased,
            attempt_id,
            provider_request_id,
            exclusive_token,
            polls,
        ),
    }
}

#[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
pub fn inspect_s419_handshake_terminal_record_on_cpu0(
) -> Result<Option<G8lS419HandshakeTerminalRecord>, G8lS419HandshakeTerminalJournalError> {
    S419_PRODUCTION_TERMINAL_JOURNAL.lock().pending_record(0)
}

#[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
pub fn take_s419_handshake_terminal_record_on_cpu0(
) -> Result<Option<G8lS419HandshakeTerminalRecord>, G8lS419HandshakeTerminalJournalError> {
    S419_PRODUCTION_TERMINAL_JOURNAL.lock().take(0)
}
snippet sha256: 0b1fc476924efile sha256: 0b1fc476924e
02 · Doğrulayan test kodu

Operations komutuna bağlı focused test

tam dosyaL1–L178
simulation/tests/g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s419_handshake_terminal_journal.rs::S419 handshake terminal journal focused tests
use aselsan_microkernel_simulation::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s419_handshake_terminal_journal::*;

#[test]
fn constants_define_single_cpu1_to_cpu0_terminal_slot() {
    assert_eq!(S419_TERMINAL_JOURNAL_CAPACITY, 1);
    assert_eq!(S419_PRODUCTION_PUBLICATION_CALLSITES, 1);
    assert!(S419_HANDSHAKE_TERMINAL_JOURNAL_COMPLETE);
    assert!(!S419_CPU0_RECONCILIATION_COMPLETE);
}

#[test]
fn completed_and_timeout_results_remain_distinct() {
    let mut state = G8lS419HandshakeTerminalJournalState::new();
    let completed = service_s419_model_handshake_terminal_journal(
        &mut state,
        1,
        G8lS419HandshakeTerminalKind::Completed,
        7,
        8,
        9,
        3,
    )
    .unwrap();
    let G8lS419HandshakeTerminalJournalOutcome::Published(record) = completed else {
        panic!("published")
    };
    assert_eq!(record.kind, G8lS419HandshakeTerminalKind::Completed);
    assert_eq!(record.polls, 3);
    assert!(!record.is_authority);
    assert_eq!(state.take(0).unwrap(), Some(record));
    let timeout = service_s419_model_handshake_terminal_journal(
        &mut state,
        1,
        G8lS419HandshakeTerminalKind::TimedOutReleased,
        10,
        11,
        12,
        4096,
    )
    .unwrap();
    assert!(
        matches!(timeout, G8lS419HandshakeTerminalJournalOutcome::Published(r) if r.kind == G8lS419HandshakeTerminalKind::TimedOutReleased)
    );
}

#[test]
fn exact_replay_is_idempotent_and_drift_backpressures() {
    let mut state = G8lS419HandshakeTerminalJournalState::new();
    service_s419_model_handshake_terminal_journal(
        &mut state,
        1,
        G8lS419HandshakeTerminalKind::Completed,
        7,
        8,
        9,
        3,
    )
    .unwrap();
    let record = state.pending_record(0).unwrap().unwrap();
    assert_eq!(
        service_s419_model_handshake_terminal_journal(
            &mut state,
            1,
            G8lS419HandshakeTerminalKind::Completed,
            7,
            8,
            9,
            3
        ),
        Ok(G8lS419HandshakeTerminalJournalOutcome::Pending(record))
    );
    assert_eq!(
        service_s419_model_handshake_terminal_journal(
            &mut state,
            1,
            G8lS419HandshakeTerminalKind::Completed,
            70,
            8,
            9,
            3
        ),
        Err(G8lS419HandshakeTerminalJournalError::SlotOccupied)
    );
}

#[test]
fn zero_binding_wrong_cpu_and_zero_poll_fail_without_publish() {
    let mut state = G8lS419HandshakeTerminalJournalState::new();
    assert_eq!(
        service_s419_model_handshake_terminal_journal(
            &mut state,
            0,
            G8lS419HandshakeTerminalKind::Completed,
            7,
            8,
            9,
            1
        ),
        Err(G8lS419HandshakeTerminalJournalError::WrongProducerCpu)
    );
    assert_eq!(
        service_s419_model_handshake_terminal_journal(
            &mut state,
            1,
            G8lS419HandshakeTerminalKind::Completed,
            0,
            8,
            9,
            1
        ),
        Err(G8lS419HandshakeTerminalJournalError::BindingDrift)
    );
    assert_eq!(
        service_s419_model_handshake_terminal_journal(
            &mut state,
            1,
            G8lS419HandshakeTerminalKind::Completed,
            7,
            8,
            9,
            0
        ),
        Err(G8lS419HandshakeTerminalJournalError::BindingDrift)
    );
    assert!(!state.pending());
}

#[test]
fn cpu0_take_is_one_shot() {
    let mut state = G8lS419HandshakeTerminalJournalState::new();
    service_s419_model_handshake_terminal_journal(
        &mut state,
        1,
        G8lS419HandshakeTerminalKind::Completed,
        7,
        8,
        9,
        1,
    )
    .unwrap();
    assert_eq!(
        state.take(1),
        Err(G8lS419HandshakeTerminalJournalError::WrongConsumerCpu)
    );
    assert!(state.take(0).unwrap().is_some());
    assert!(state.take(0).unwrap().is_none());
}

#[test]
fn production_adapter_maps_both_s416_terminal_variants() {
    let source = include_str!("../../kernel/src/g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s419_handshake_terminal_journal.rs");
    assert!(source.contains("G8lS416ProductionExclusionHandshakeOutcome::Completed"));
    assert!(source.contains("G8lS416ProductionExclusionHandshakeOutcome::TimedOutReleased"));
    assert!(source.contains("G8lS416ProductionExclusionHandshakeOutcome::Idle"));
}

#[test]
fn timer_chain_journals_s416_result_before_s402_fallback() {
    let source = include_str!("../../kernel/src/arch/aarch64/exceptions.rs");
    let s416 = source
        .find("service_s416_production_exclusion_handshake_on_cpu1")
        .unwrap();
    let s419 = source
        .find("service_s419_handshake_terminal_journal_on_cpu1")
        .unwrap();
    let s402 = source
        .find("service_s402_provider_invocation_observation_publication_on_cpu1")
        .unwrap();
    assert!(s416 < s419 && s419 < s402);
}

#[test]
fn s419_is_registered_separately() {
    let name = "g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s419_handshake_terminal_journal";
    assert!(include_str!("../../kernel/src/main.rs").contains(&format!("mod {name};")));
    assert!(include_str!("../src/lib.rs").contains(&format!("pub mod {name};")));
}
snippet sha256: 010526d17b79file sha256: 010526d17b79
03 · Kapı kimlik kaydı

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

tam Operations kaydıL406–L422
website/src/lib/operations.ts::g8l-s419-handshake-terminal-journal-partial
  {
    id: "g8l-s419-handshake-terminal-journal-partial",
    sequence: 419,
    slug: "handshake_terminal_journal",
    title: "Handshake terminal journal",
    focusedTests: 8,
    sourceBytes: 7092,
    sourceSha256:
      "0b1fc476924e0404e1ee93ace07023ff29b60d54613f9259b7e2718543f85c5a",
    testBytes: 5466,
    testSha256:
      "010526d17b79113e35a34c51982ecb0e351d295fa36c262635007aad521f9dec",
    acceptance:
      "CPU1 uzlaştırılmış success/timeout/error terminal sonucunu exact request/attempt/poll metadata'sıyla capacity-one journal'a yayımlar.",
    retainedBoundary:
      "CPU0 terminal reconciliation ve ACK üretimi bu kapıda tamamlanmış sayılmaz.",
  },
snippet sha256: bc75946a5f8bfile 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_s419_handshake_terminal_journal -- --test-threads=1
proof: docs/M8.1-RPi5-G8l-S419-Handshake-Terminal-Journal-Proof.md
Registry schema v5 · generator website/scripts/generate-code-gates.mjs · Tam SHA-256: 91d38c7b6222f0b4c117be786454853543da55a160e543d9b951057cc20dcc06