Deploy reviewed Windows sync alignment with schema 20 server
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
Bind the administrative connection-205 review to original signed history and preserve closed readiness. Include the qualified server dependency closure, UI review, native ARM64 build provenance, and guarded deployment evidence. Migration, API/gateway replacement and TLS checks passed with unchanged job authority, protected mounts and time/database services; native Windows receipt application remains separate.
This commit is contained in:
@@ -19,6 +19,11 @@ pub use linux_full::{LinuxFullTransition, LinuxFullTransitionProof, render_linux
|
||||
pub const MAX_RECORD_BYTES: usize = 16 * 1024;
|
||||
pub const MAX_EVENT_BYTES: usize = 16 * 1024;
|
||||
pub const MAX_EVENTS: usize = 16;
|
||||
/// Only the explicit five-file Windows clock transition needs two additional
|
||||
/// ReplaceIntent/Replaced events. Historical profiles retain the 16-event cap.
|
||||
pub const MAX_WINDOWS_CLOCK_EVENTS: usize = 18;
|
||||
/// Explicit V2 allows one predecessor return under the original attempt.
|
||||
pub const MAX_V2_EVENTS: usize = 40;
|
||||
pub const HEALTH_DOMAIN: &[u8] = b"rmm.agent-update-health.v1\0";
|
||||
|
||||
/// All fields below are untrusted wire data, never authorization capabilities.
|
||||
@@ -123,7 +128,7 @@ pub struct Handoff {
|
||||
|
||||
impl Handoff {
|
||||
pub fn validate(&self) -> Result<()> {
|
||||
ensure!(self.schema_version == 1, "HANDOFF_SCHEMA");
|
||||
ensure!(matches!(self.schema_version, 1 | 2), "HANDOFF_SCHEMA");
|
||||
for id in [
|
||||
self.attempt.tenant_id,
|
||||
self.attempt.asset_id,
|
||||
@@ -373,10 +378,55 @@ pub enum Evidence {
|
||||
OutcomePersisted {
|
||||
outcome_sha256: String,
|
||||
},
|
||||
RollbackIntent {
|
||||
cause: RollbackCause,
|
||||
failure_observation_sha256: String,
|
||||
},
|
||||
RollbackStopped {
|
||||
process: Process,
|
||||
ledger_identity_sha256: String,
|
||||
observation_sha256: String,
|
||||
},
|
||||
RestoreIntent {
|
||||
role: FileRole,
|
||||
},
|
||||
CandidatePreserved {
|
||||
role: FileRole,
|
||||
observation_sha256: String,
|
||||
},
|
||||
PredecessorRestored {
|
||||
role: FileRole,
|
||||
observed_sha256: String,
|
||||
},
|
||||
PredecessorVerified {
|
||||
pair: CodePair,
|
||||
retained_state_sha256: String,
|
||||
predecessor_record_sha256: String,
|
||||
},
|
||||
RollbackLedgerReturnIntent,
|
||||
RollbackServicesStarted {
|
||||
services: Vec<StartedService>,
|
||||
ledger_identity_sha256: String,
|
||||
observation_sha256: String,
|
||||
},
|
||||
RollbackHealthVerified {
|
||||
receipt: SignedHealth,
|
||||
},
|
||||
RollbackOutcomePersisted {
|
||||
outcome_sha256: String,
|
||||
},
|
||||
Unknown {
|
||||
reason: UnknownReason,
|
||||
},
|
||||
}
|
||||
/// Native guards must independently attest the actual known failure. Missing
|
||||
/// replies, uncertain replacement, lost owner and persisted Unknown are denied.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(tag = "cause", rename_all = "snake_case", deny_unknown_fields)]
|
||||
pub enum RollbackCause {
|
||||
StartupFailed { service: Service },
|
||||
HealthRejected,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
@@ -415,6 +465,15 @@ pub enum Phase {
|
||||
LedgerReturnIntent,
|
||||
ServicesStarted,
|
||||
HealthVerified,
|
||||
RollbackIntent,
|
||||
RollbackStopped,
|
||||
RestoreIntent,
|
||||
CandidatePreserved,
|
||||
PredecessorRestored,
|
||||
PredecessorVerified,
|
||||
RollbackLedgerReturnIntent,
|
||||
RollbackServicesStarted,
|
||||
RollbackHealthVerified,
|
||||
OutcomePersisted,
|
||||
Unknown,
|
||||
}
|
||||
@@ -431,6 +490,9 @@ pub struct Journal {
|
||||
observed_at: u64,
|
||||
started: Option<(Vec<StartedService>, u64)>,
|
||||
health_key: VerifyingKey,
|
||||
updater: Option<Process>,
|
||||
original_start_at: Option<u64>,
|
||||
restored: usize,
|
||||
}
|
||||
|
||||
impl Journal {
|
||||
@@ -452,6 +514,9 @@ impl Journal {
|
||||
replaced: 0,
|
||||
started: None,
|
||||
health_key,
|
||||
updater: None,
|
||||
original_start_at: None,
|
||||
restored: 0,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -464,6 +529,20 @@ impl Journal {
|
||||
pub fn handoff_sha256(&self) -> &str {
|
||||
&self.handoff_hash
|
||||
}
|
||||
pub fn rollback_active(&self) -> bool {
|
||||
matches!(
|
||||
self.phase,
|
||||
Phase::RollbackIntent
|
||||
| Phase::RollbackStopped
|
||||
| Phase::RestoreIntent
|
||||
| Phase::CandidatePreserved
|
||||
| Phase::PredecessorRestored
|
||||
| Phase::PredecessorVerified
|
||||
| Phase::RollbackLedgerReturnIntent
|
||||
| Phase::RollbackServicesStarted
|
||||
| Phase::RollbackHealthVerified
|
||||
)
|
||||
}
|
||||
|
||||
/// Prepare exact bytes for a bounded append-only CAS transaction against
|
||||
/// `head_sha256`. Returning bytes is NOT proof that this transaction ran.
|
||||
@@ -491,8 +570,19 @@ impl Journal {
|
||||
if matches!(event.evidence, Evidence::Replaced { .. }) {
|
||||
self.replaced += 1;
|
||||
}
|
||||
if let Evidence::ServicesStarted { services, .. } = event.evidence {
|
||||
self.started = Some((services, event.observed_at));
|
||||
if matches!(event.evidence, Evidence::PredecessorRestored { .. }) {
|
||||
self.restored += 1;
|
||||
}
|
||||
if let Evidence::UpdaterOwnsLedger { ref process, .. } = event.evidence {
|
||||
self.updater = Some(process.clone());
|
||||
}
|
||||
if matches!(event.evidence, Evidence::LedgerReturnIntent) {
|
||||
self.original_start_at = Some(event.observed_at);
|
||||
}
|
||||
if let Evidence::ServicesStarted { ref services, .. }
|
||||
| Evidence::RollbackServicesStarted { ref services, .. } = event.evidence
|
||||
{
|
||||
self.started = Some((services.clone(), event.observed_at));
|
||||
}
|
||||
self.phase = next;
|
||||
self.observed_at = event.observed_at;
|
||||
@@ -506,7 +596,14 @@ impl Journal {
|
||||
event.schema_version == 1
|
||||
&& event.handoff_sha256 == self.handoff_hash
|
||||
&& event.sequence == self.count + 1
|
||||
&& (event.sequence as usize) <= MAX_EVENTS
|
||||
&& (event.sequence as usize)
|
||||
<= if self.handoff.schema_version == 2 {
|
||||
MAX_V2_EVENTS
|
||||
} else if self.handoff.pin_transition == PinTransition::WindowsCodePairClockV1 {
|
||||
MAX_WINDOWS_CLOCK_EVENTS
|
||||
} else {
|
||||
MAX_EVENTS
|
||||
}
|
||||
&& event.previous_sha256 == self.head_hash,
|
||||
"HANDOFF_EVENT_CHAIN"
|
||||
);
|
||||
@@ -642,11 +739,205 @@ impl Journal {
|
||||
digest(outcome_sha256)?;
|
||||
Phase::OutcomePersisted
|
||||
}
|
||||
(
|
||||
Phase::LedgerReturnIntent | Phase::ServicesStarted,
|
||||
Evidence::RollbackIntent {
|
||||
cause,
|
||||
failure_observation_sha256,
|
||||
},
|
||||
) => {
|
||||
self.rollback_window(event.observed_at)?;
|
||||
digest(failure_observation_sha256)?;
|
||||
match cause {
|
||||
RollbackCause::StartupFailed { service } => ensure!(
|
||||
self.phase == Phase::LedgerReturnIntent
|
||||
&& self.handoff.stop_set.contains(service),
|
||||
"HANDOFF_ROLLBACK_START_FAILURE"
|
||||
),
|
||||
RollbackCause::HealthRejected => ensure!(
|
||||
self.phase == Phase::ServicesStarted,
|
||||
"HANDOFF_ROLLBACK_HEALTH_FAILURE"
|
||||
),
|
||||
}
|
||||
Phase::RollbackIntent
|
||||
}
|
||||
(
|
||||
Phase::RollbackIntent,
|
||||
Evidence::RollbackStopped {
|
||||
process,
|
||||
ledger_identity_sha256,
|
||||
observation_sha256,
|
||||
},
|
||||
) => {
|
||||
self.rollback_window(event.observed_at)?;
|
||||
ensure!(
|
||||
self.updater.as_ref() == Some(process)
|
||||
&& ledger_identity_sha256 == &self.handoff.ledger_identity_sha256,
|
||||
"HANDOFF_ROLLBACK_ORIGINAL_OWNER"
|
||||
);
|
||||
digest(observation_sha256)?;
|
||||
Phase::RollbackStopped
|
||||
}
|
||||
(
|
||||
Phase::RollbackStopped | Phase::PredecessorRestored,
|
||||
Evidence::RestoreIntent { role },
|
||||
) => {
|
||||
self.rollback_window(event.observed_at)?;
|
||||
ensure!(
|
||||
self.handoff
|
||||
.files
|
||||
.iter()
|
||||
.rev()
|
||||
.nth(self.restored)
|
||||
.is_some_and(|f| f.role == *role),
|
||||
"HANDOFF_RESTORE_ORDER"
|
||||
);
|
||||
Phase::RestoreIntent
|
||||
}
|
||||
(
|
||||
Phase::RestoreIntent,
|
||||
Evidence::CandidatePreserved {
|
||||
role,
|
||||
observation_sha256,
|
||||
},
|
||||
) => {
|
||||
self.rollback_window(event.observed_at)?;
|
||||
ensure!(
|
||||
self.handoff
|
||||
.files
|
||||
.iter()
|
||||
.rev()
|
||||
.nth(self.restored)
|
||||
.is_some_and(|f| f.role == *role),
|
||||
"HANDOFF_RESTORE_ORDER"
|
||||
);
|
||||
digest(observation_sha256)?;
|
||||
Phase::CandidatePreserved
|
||||
}
|
||||
(
|
||||
Phase::CandidatePreserved,
|
||||
Evidence::PredecessorRestored {
|
||||
role,
|
||||
observed_sha256,
|
||||
},
|
||||
) => {
|
||||
self.rollback_window(event.observed_at)?;
|
||||
ensure!(
|
||||
self.handoff
|
||||
.files
|
||||
.iter()
|
||||
.rev()
|
||||
.nth(self.restored)
|
||||
.is_some_and(|f| f.role == *role && f.old_sha256 == *observed_sha256),
|
||||
"HANDOFF_RESTORE_PREDECESSOR_HASH"
|
||||
);
|
||||
Phase::PredecessorRestored
|
||||
}
|
||||
(
|
||||
Phase::PredecessorRestored,
|
||||
Evidence::PredecessorVerified {
|
||||
pair,
|
||||
retained_state_sha256,
|
||||
predecessor_record_sha256,
|
||||
},
|
||||
) => {
|
||||
self.rollback_window(event.observed_at)?;
|
||||
ensure!(
|
||||
self.restored == self.handoff.files.len()
|
||||
&& pair == &self.handoff.predecessor
|
||||
&& retained_state_sha256 == &self.handoff.retained_state_sha256
|
||||
&& predecessor_record_sha256 == &self.handoff.predecessor_record_sha256,
|
||||
"HANDOFF_RESTORE_PAIR_OR_STATE_CHANGED"
|
||||
);
|
||||
Phase::PredecessorVerified
|
||||
}
|
||||
(Phase::PredecessorVerified, Evidence::RollbackLedgerReturnIntent) => {
|
||||
self.rollback_window(event.observed_at)?;
|
||||
Phase::RollbackLedgerReturnIntent
|
||||
}
|
||||
(
|
||||
Phase::RollbackLedgerReturnIntent,
|
||||
Evidence::RollbackServicesStarted {
|
||||
services,
|
||||
ledger_identity_sha256,
|
||||
observation_sha256,
|
||||
},
|
||||
) => {
|
||||
self.rollback_window(event.observed_at)?;
|
||||
ensure!(
|
||||
ledger_identity_sha256 == &self.handoff.ledger_identity_sha256,
|
||||
"HANDOFF_LEDGER_IDENTITY_CHANGED"
|
||||
);
|
||||
let expected: Vec<_> = self
|
||||
.handoff
|
||||
.stop_set
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|s| *s != Service::LinuxAptHelper)
|
||||
.collect();
|
||||
ensure!(
|
||||
services.len() == expected.len(),
|
||||
"HANDOFF_STARTED_SERVICE_SET"
|
||||
);
|
||||
for (index, service) in services.iter().enumerate() {
|
||||
ensure!(
|
||||
service.service == expected[index],
|
||||
"HANDOFF_STARTED_SERVICE_SET"
|
||||
);
|
||||
service.process.validate(
|
||||
if matches!(service.service, Service::LinuxAgent | Service::WindowsAgent) {
|
||||
&self.handoff.predecessor.agent_sha256
|
||||
} else {
|
||||
&self.handoff.predecessor.helper_sha256
|
||||
},
|
||||
)?;
|
||||
ensure!(
|
||||
!services[..index]
|
||||
.iter()
|
||||
.any(|p| p.process.pid == service.process.pid),
|
||||
"HANDOFF_PROCESS_REUSE"
|
||||
);
|
||||
ensure!(
|
||||
self.started.as_ref().is_none_or(|(prior, _)| !prior
|
||||
.iter()
|
||||
.any(|p| p.process == service.process)),
|
||||
"HANDOFF_RESTORE_OLD_PROCESS_REUSED"
|
||||
);
|
||||
}
|
||||
digest(observation_sha256)?;
|
||||
Phase::RollbackServicesStarted
|
||||
}
|
||||
(Phase::RollbackServicesStarted, Evidence::RollbackHealthVerified { receipt }) => {
|
||||
self.rollback_window(event.observed_at)?;
|
||||
self.verify_health(receipt, event.observed_at)?;
|
||||
Phase::RollbackHealthVerified
|
||||
}
|
||||
(
|
||||
Phase::RollbackHealthVerified,
|
||||
Evidence::RollbackOutcomePersisted { outcome_sha256 },
|
||||
) => {
|
||||
self.rollback_window(event.observed_at)?;
|
||||
digest(outcome_sha256)?;
|
||||
Phase::OutcomePersisted
|
||||
}
|
||||
_ => anyhow::bail!("HANDOFF_PHASE_ORDER"),
|
||||
};
|
||||
Ok(next)
|
||||
}
|
||||
|
||||
fn rollback_window(&self, at: u64) -> Result<()> {
|
||||
ensure!(
|
||||
self.handoff.schema_version == 2
|
||||
&& self
|
||||
.original_start_at
|
||||
.and_then(|start| at.checked_sub(start))
|
||||
.is_some_and(|age| age < 180)
|
||||
&& at < self.handoff.finish_before,
|
||||
"HANDOFF_ROLLBACK_ORIGINAL_DEADLINE"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_health(&self, signed: &SignedHealth, at: u64) -> Result<()> {
|
||||
let receipt: HealthReceipt = canonical(&signed.payload, 4096)?;
|
||||
let signature =
|
||||
|
||||
Reference in New Issue
Block a user