S418 · SOURCE-BOUND GATE EVIDENCE
S418 · CPU0 partial-state reconciliation
tam S418 implementation modülü → Operations --test hedefi ile bağlı tam focused test → ayrı Operations kaydı Bu sayfa yalnız S418 kapısına aittir; komşu kapıların kaynakları bu kabulün içine katılmaz.
S418Focused kod testiOperations id exactsource SHA exacttest target exact
operation: g8l-s418-cpu0-partial-state-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–L180
kernel/src/g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s418_cpu0_partial_state_reconciliation.rs::S418 cpu0 partial state reconciliation implementation
#![allow(unexpected_cfgs)]
//! S418 CPU0 stale partial-state reconciliation.
//!
//! Before another attempt, CPU0 inspects the mutually exclusive S409 receipt,
//! S410 candidate, and S411 admission slots. A value bound to the active S247
//! token is preserved. A value whose lease has ended (or whose token differs
//! from the current lease) is taken and dropped exactly once. The successful
//! S243/S187 handoff slot is never inspected or consumed here.
use crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s417_handshake_attempt_reconciliation::{
S417_DIRECT_SCHEDULER_ACCESS_SITES, S417_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES,
S417_SOURCE_AUDIT_UNITS, S417_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES,
S417_UNROUTED_DIRECT_ACCESS_SITES,
};
pub const S418_SOURCE_AUDIT_UNITS: usize = S417_SOURCE_AUDIT_UNITS;
pub const S418_DIRECT_SCHEDULER_ACCESS_SITES: usize = S417_DIRECT_SCHEDULER_ACCESS_SITES;
pub const S418_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES: usize =
S417_SOURCE_MODEL_COVERED_DIRECT_ACCESS_SITES;
pub const S418_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES: usize =
S417_PRODUCTION_GUARDED_DIRECT_ACCESS_SITES;
pub const S418_UNROUTED_DIRECT_ACCESS_SITES: usize = S417_UNROUTED_DIRECT_ACCESS_SITES;
pub const S418_RECONCILED_PARTIAL_STAGE_COUNT: usize = 3;
pub const S418_PRODUCTION_RECONCILIATION_CALLSITES: usize = 1;
pub const S418_CPU0_PARTIAL_STATE_RECONCILIATION_COMPLETE: bool = true;
pub const S418_S243_S187_HANDOFF_PRESERVED: bool = true;
pub const S418_CPU1_S187_HANDOFF_CONSUMPTION_COMPLETE: bool = false;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum G8lS418Cpu0PartialStage {
S409DeliveryReceipt,
S410Candidate,
S411Admission,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct G8lS418Cpu0PartialStateView {
pub stage: G8lS418Cpu0PartialStage,
pub attempt_id: u64,
pub provider_request_id: u64,
pub exclusive_token: u64,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum G8lS418Cpu0PartialStateReconciliationOutcome {
Clean,
HandshakeActive(G8lS418Cpu0PartialStateView),
DiscardStale(G8lS418Cpu0PartialStateView),
Discarded(G8lS418Cpu0PartialStateView),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum G8lS418Cpu0PartialStateReconciliationError {
WrongCpu,
MultiplePendingStages,
BindingDrift,
UpstreamInspection,
TakeDisappeared,
TakeDrift,
}
pub fn preflight_s418_cpu0_partial_state_reconciliation(
caller_cpu: usize,
active_exclusive_token: Option<u64>,
delivery: Option<G8lS418Cpu0PartialStateView>,
candidate: Option<G8lS418Cpu0PartialStateView>,
admission: Option<G8lS418Cpu0PartialStateView>,
) -> Result<G8lS418Cpu0PartialStateReconciliationOutcome, G8lS418Cpu0PartialStateReconciliationError>
{
if caller_cpu != 0 {
return Err(G8lS418Cpu0PartialStateReconciliationError::WrongCpu);
}
let pending_count =
delivery.is_some() as usize + candidate.is_some() as usize + admission.is_some() as usize;
if pending_count > 1 {
return Err(G8lS418Cpu0PartialStateReconciliationError::MultiplePendingStages);
}
let Some(partial) = delivery.or(candidate).or(admission) else {
return Ok(G8lS418Cpu0PartialStateReconciliationOutcome::Clean);
};
if partial.attempt_id == 0 || partial.provider_request_id == 0 || partial.exclusive_token == 0 {
return Err(G8lS418Cpu0PartialStateReconciliationError::BindingDrift);
}
if active_exclusive_token == Some(partial.exclusive_token) {
Ok(G8lS418Cpu0PartialStateReconciliationOutcome::HandshakeActive(partial))
} else {
Ok(G8lS418Cpu0PartialStateReconciliationOutcome::DiscardStale(
partial,
))
}
}
#[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
pub fn service_s418_cpu0_partial_state_reconciliation_on_cpu0(
) -> Result<G8lS418Cpu0PartialStateReconciliationOutcome, G8lS418Cpu0PartialStateReconciliationError>
{
use crate::g8l_runtime_contract::CPU0;
if crate::percpu::try_current_cpu_id() != Some(CPU0) {
return Err(G8lS418Cpu0PartialStateReconciliationError::WrongCpu);
}
let delivery = crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s409_live_offer_sgi_delivery::inspect_s409_live_offer_sgi_delivery_receipt_on_cpu0()
.map_err(|_| G8lS418Cpu0PartialStateReconciliationError::UpstreamInspection)?
.map(|view| G8lS418Cpu0PartialStateView {
stage: G8lS418Cpu0PartialStage::S409DeliveryReceipt,
attempt_id: view.attempt_id(),
provider_request_id: view.provider_request_id(),
exclusive_token: view.exclusive_token(),
});
let candidate = crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s410_exclusion_admission_candidate_publication::inspect_s410_exclusion_admission_candidate_on_cpu0()
.map_err(|_| G8lS418Cpu0PartialStateReconciliationError::UpstreamInspection)?
.map(|view| G8lS418Cpu0PartialStateView {
stage: G8lS418Cpu0PartialStage::S410Candidate,
attempt_id: view.attempt_id,
provider_request_id: view.provider_request_id,
exclusive_token: view.exclusive_token,
});
let admission = crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s411_ephemeral_exclusion_admission_constructor::inspect_s411_ephemeral_exclusion_admission_on_cpu0()
.map_err(|_| G8lS418Cpu0PartialStateReconciliationError::UpstreamInspection)?
.map(|view| G8lS418Cpu0PartialStateView {
stage: G8lS418Cpu0PartialStage::S411Admission,
attempt_id: view.attempt_id,
provider_request_id: view.provider_request_id,
exclusive_token: view.exclusive_token,
});
let active_token = crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s246_whole_scheduler_read_access_guard::S247_PRODUCTION_WHOLE_SCHEDULER_ACCESS_GATE
.active_exclusive_token();
let outcome = preflight_s418_cpu0_partial_state_reconciliation(
CPU0,
active_token,
delivery,
candidate,
admission,
)?;
let G8lS418Cpu0PartialStateReconciliationOutcome::DiscardStale(expected) = outcome else {
return Ok(outcome);
};
let taken = match expected.stage {
G8lS418Cpu0PartialStage::S409DeliveryReceipt => {
let value = crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s409_live_offer_sgi_delivery::take_s409_live_offer_sgi_delivery_receipt_on_cpu0()
.map_err(|_| G8lS418Cpu0PartialStateReconciliationError::UpstreamInspection)?
.ok_or(G8lS418Cpu0PartialStateReconciliationError::TakeDisappeared)?;
G8lS418Cpu0PartialStateView {
stage: expected.stage,
attempt_id: value.attempt_id(),
provider_request_id: value.provider_request_id(),
exclusive_token: value.exclusive_token(),
}
}
G8lS418Cpu0PartialStage::S410Candidate => {
let value = crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s410_exclusion_admission_candidate_publication::take_s410_exclusion_admission_candidate_on_cpu0()
.map_err(|_| G8lS418Cpu0PartialStateReconciliationError::UpstreamInspection)?
.ok_or(G8lS418Cpu0PartialStateReconciliationError::TakeDisappeared)?;
G8lS418Cpu0PartialStateView {
stage: expected.stage,
attempt_id: value.attempt_id(),
provider_request_id: value.provider_request_id(),
exclusive_token: value.exclusive_token(),
}
}
G8lS418Cpu0PartialStage::S411Admission => {
let value = crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s411_ephemeral_exclusion_admission_constructor::take_s411_ephemeral_exclusion_admission_on_cpu0()
.map_err(|_| G8lS418Cpu0PartialStateReconciliationError::UpstreamInspection)?
.ok_or(G8lS418Cpu0PartialStateReconciliationError::TakeDisappeared)?;
G8lS418Cpu0PartialStateView {
stage: expected.stage,
attempt_id: value.attempt_id(),
provider_request_id: value.provider_request_id(),
exclusive_token: value.exclusive_token(),
}
}
};
if taken != expected {
return Err(G8lS418Cpu0PartialStateReconciliationError::TakeDrift);
}
Ok(G8lS418Cpu0PartialStateReconciliationOutcome::Discarded(
taken,
))
}
snippet sha256: 3b3eaefec1fc…file sha256: 3b3eaefec1fc…
02 · Doğrulayan test kodu
Operations komutuna bağlı focused test
tam dosyaL1–L129
simulation/tests/g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s418_cpu0_partial_state_reconciliation.rs::S418 cpu0 partial state reconciliation focused tests
use aselsan_microkernel_simulation::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s418_cpu0_partial_state_reconciliation::*;
fn view(stage: G8lS418Cpu0PartialStage, token: u64) -> G8lS418Cpu0PartialStateView {
G8lS418Cpu0PartialStateView {
stage,
attempt_id: 7,
provider_request_id: 8,
exclusive_token: token,
}
}
#[test]
fn constants_limit_cleanup_to_pre_s243_partial_states() {
assert_eq!(S418_RECONCILED_PARTIAL_STAGE_COUNT, 3);
assert_eq!(S418_PRODUCTION_RECONCILIATION_CALLSITES, 1);
assert!(S418_CPU0_PARTIAL_STATE_RECONCILIATION_COMPLETE);
assert!(S418_S243_S187_HANDOFF_PRESERVED);
assert!(!S418_CPU1_S187_HANDOFF_CONSUMPTION_COMPLETE);
}
#[test]
fn empty_partial_surfaces_are_clean() {
assert_eq!(
preflight_s418_cpu0_partial_state_reconciliation(0, None, None, None, None),
Ok(G8lS418Cpu0PartialStateReconciliationOutcome::Clean)
);
}
#[test]
fn live_matching_partial_state_is_preserved() {
let admission = view(G8lS418Cpu0PartialStage::S411Admission, 9);
assert_eq!(
preflight_s418_cpu0_partial_state_reconciliation(0, Some(9), None, None, Some(admission)),
Ok(G8lS418Cpu0PartialStateReconciliationOutcome::HandshakeActive(admission))
);
}
#[test]
fn released_token_marks_each_possible_stage_for_exact_discard() {
for stage in [
G8lS418Cpu0PartialStage::S409DeliveryReceipt,
G8lS418Cpu0PartialStage::S410Candidate,
G8lS418Cpu0PartialStage::S411Admission,
] {
let partial = view(stage, 9);
let args = match stage {
G8lS418Cpu0PartialStage::S409DeliveryReceipt => (Some(partial), None, None),
G8lS418Cpu0PartialStage::S410Candidate => (None, Some(partial), None),
G8lS418Cpu0PartialStage::S411Admission => (None, None, Some(partial)),
};
assert_eq!(
preflight_s418_cpu0_partial_state_reconciliation(0, None, args.0, args.1, args.2),
Ok(G8lS418Cpu0PartialStateReconciliationOutcome::DiscardStale(
partial
))
);
}
}
#[test]
fn multiple_pending_stages_fail_closed() {
assert_eq!(
preflight_s418_cpu0_partial_state_reconciliation(
0,
None,
Some(view(G8lS418Cpu0PartialStage::S409DeliveryReceipt, 9)),
Some(view(G8lS418Cpu0PartialStage::S410Candidate, 9)),
None,
),
Err(G8lS418Cpu0PartialStateReconciliationError::MultiplePendingStages)
);
}
#[test]
fn invalid_binding_and_wrong_cpu_fail_closed() {
assert_eq!(
preflight_s418_cpu0_partial_state_reconciliation(
0,
None,
None,
Some(view(G8lS418Cpu0PartialStage::S410Candidate, 0)),
None
),
Err(G8lS418Cpu0PartialStateReconciliationError::BindingDrift)
);
assert_eq!(
preflight_s418_cpu0_partial_state_reconciliation(1, None, None, None, None),
Err(G8lS418Cpu0PartialStateReconciliationError::WrongCpu)
);
}
#[test]
fn production_inspects_all_three_then_takes_only_selected_stage() {
let source = include_str!("../../kernel/src/g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s418_cpu0_partial_state_reconciliation.rs");
let start = source
.find("service_s418_cpu0_partial_state_reconciliation_on_cpu0")
.unwrap();
let body = &source[start..];
for marker in [
"inspect_s409_live_offer_sgi_delivery_receipt_on_cpu0",
"inspect_s410_exclusion_admission_candidate_on_cpu0",
"inspect_s411_ephemeral_exclusion_admission_on_cpu0",
"take_s409_live_offer_sgi_delivery_receipt_on_cpu0",
"take_s410_exclusion_admission_candidate_on_cpu0",
"take_s411_ephemeral_exclusion_admission_on_cpu0",
] {
assert!(
body.contains(marker),
"missing exact stage surface: {marker}"
);
}
assert!(!body.contains("take_s243_deferred_s187_handoff_on_cpu1"));
}
#[test]
fn cpu0_timer_runs_s418_before_historical_s244_service() {
let source = include_str!("../../kernel/src/arch/aarch64/exceptions.rs");
let s418 = source
.find("service_s418_cpu0_partial_state_reconciliation_on_cpu0")
.unwrap();
let s244 = source
.find("service_s244_whole_scheduler_exclusion_admission_on_cpu0")
.unwrap();
assert!(s418 < s244);
let name = "g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s418_cpu0_partial_state_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: caf48a2ad298…file sha256: caf48a2ad298…
03 · Kapı kimlik kaydı
Operations sıra, kimlik ve başlık bağı
tam Operations kaydıL389–L405
website/src/lib/operations.ts::g8l-s418-cpu0-partial-state-reconciliation-partial
{
id: "g8l-s418-cpu0-partial-state-reconciliation-partial",
sequence: 418,
slug: "cpu0_partial_state_reconciliation",
title: "CPU0 partial-state reconciliation",
focusedTests: 8,
sourceBytes: 8848,
sourceSha256:
"3b3eaefec1fcf45fe602795220ed75d58eee157b3d4fab63b5b930309608e288",
testBytes: 4800,
testSha256:
"caf48a2ad2985f37a3a4f339df89390d37fa11003b1231aa50d1f561e1c7d476",
acceptance:
"CPU0 candidate, ephemeral admission ve join-ACK olmak üzere üç kısmi aşamayı exact attempt kimliğiyle uzlaştırır; S243 S187 handoff korunur.",
retainedBoundary:
"CPU1 S187 consumption hâlâ yapılmaz; terminal attempt kaydı S419'da yayımlanır.",
},snippet sha256: a9be53a51000…file 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_s418_cpu0_partial_state_reconciliation -- --test-threads=1proof: docs/M8.1-RPi5-G8l-S418-CPU0-Partial-State-Reconciliation-Proof.md
Registry schema v5 · generator
website/scripts/generate-code-gates.mjs · Tam SHA-256: 3050638b71a684d8f8f947a8a6faa237a17fa8db5dc0db04fb207b668b462af9