fix: bind reboot success to independently received inventory within reserved deadline
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-13 19:49:12 +01:00
parent d8bf8e238b
commit b3a22d464b
9 changed files with 1048 additions and 27 deletions
+21 -1
View File
@@ -1,6 +1,6 @@
# Rust RMM: Architektur und Implementierungsspezifikation
Version 1.12 · 2026-11-13 · Sprache: Deutsch
Version 1.13 · 2026-11-13 · Sprache: Deutsch
**Zweck:** Vollständige, eigenständig nutzbare Grundlage für die Implementierung einer mandantenfähigen Plattform zur Inventarisierung, Überwachung und Fernadministration von Kundengeräten durch eine Coding-KI und ein Entwicklungsteam.
@@ -43,6 +43,26 @@ Version 1.12 · 2026-11-13 · Sprache: Deutsch
## 0 Auftrag und verbindliche Produktanforderungen
**Präzisierung Version1.13, begrenzte MVP-Nachbedingungen:** Ein bereits vor
einer Paketwirkung vorhandener Host-Neustartbedarf verhindert deren Erfolg
nicht, wenn sämtliche Paketnachbedingungen unabhängig vollständig nachgewiesen
sind. `no_reboot=true` verbietet den eigenmächtigen Neustart; das tatsächliche
Hostflag wird unverfälscht als `reboot_required` berichtet. Für die harmlosen
APT-Fixturerezepte muss derselbe gebundene Hostflagwert vor/nach der Wirkung
nachgewiesen sein; der private Sandboxwert ersetzt diese Hostbeobachtung nicht.
Fehlende historische Vorhermessungen werden nicht rückwirkend erfunden.
Beim festen Rebootjob beginnt die zentrale `reconnect_timeout_seconds`-Frist
konservativ an der dauerhaft gespeicherten serverseitigen Startreservierung
des gleichen Jobs/Versuchs/Grants. Ein späterer lokaler Start verlängert sie
nicht. Erstmaliger Erfolg braucht authentisierten Wiederkontakt mit neuer
Boot-ID sowie unabhängig gespeichertes Inventar, dessen Serverempfang nach
Reservierung und spätestens zur Frist liegt. Fehlender/verspäteter Nachweis
bleibt `unknown`. Späterer signierter Abgleich darf den ursprünglichen
rechtzeitigen Inventarbeleg erneut prüfen, aber keinen anderen verspäteten
Beleg unterschieben. Dies begrenzt die vorhandene Rebootabnahme und erlaubt
keinen zusätzlichen Reboot oder automatischen Wiederholungsversuch.
**Topologieoverride des Users vom 2026-11-13 (Version 1.6):** Der Entwickler-PC
wird nicht mehr als RMM-Server genutzt. Der dedizierte Internetserver übernimmt
Backend, Datenbank und TLS-Endpunkt; Agenten verbinden sich direkt ausgehend
+4 -7
View File
@@ -189,13 +189,10 @@ pub async fn event(
}
}
if matches!(payload.action, Action::Reboot { .. }) {
ensure!(
evidence.get("new_boot_id").and_then(Value::as_str)
== Some(e.boot_id.as_str()),
"new boot evidence required"
);
let old_boot=sqlx::query_scalar::<_,String>("SELECT data->>'boot_id' FROM audit_events WHERE event_type='start_reserved' AND data->>'job_id'=$1 ORDER BY created_at DESC LIMIT 1").bind(&r.job_id).fetch_one(&mut **tx).await?;
ensure!(old_boot != e.boot_id, "reboot needs new boot");
crate::synchronization::verify_reboot_success(
tx, tenant, agent, e, &payload, r, &evidence,
)
.await?;
}
}
sqlx::query("UPDATE jobs SET state=$2,revision=$3,result=$4 WHERE job_id=$1")
+501 -16
View File
@@ -67,6 +67,115 @@ fn previous_anchor(
last_applied
}
}
/// The server's durable grant reservation precedes the helper's saved start.
/// Using that trusted timestamp is conservative: no device clock or late
/// reconnect may extend the fixed, approved reconnect window.
fn reboot_deadline(
action: &Action,
reserved_at: Option<chrono::DateTime<Utc>>,
) -> Option<chrono::DateTime<Utc>> {
let Action::Reboot {
reconnect_timeout_seconds,
..
} = action
else {
return None;
};
if !action.validate() {
return None;
}
reserved_at?.checked_add_signed(Duration::seconds(i64::from(*reconnect_timeout_seconds)))
}
struct RebootWindow {
reserved_at: chrono::DateTime<Utc>,
deadline: chrono::DateTime<Utc>,
now: chrono::DateTime<Utc>,
require_fresh: bool,
}
async fn reboot_inventory(
tx: &mut Transaction<'_, Postgres>,
tenant: Uuid,
agent: Uuid,
boot: Uuid,
window: &RebootWindow,
existing_receipt: Option<Uuid>,
) -> Result<Option<(Uuid, chrono::DateTime<Utc>)>> {
// Already-persisted definitive success keeps its original receipt. It need
// not be younger than five minutes again, but its original server receipt
// time must still prove the approved reconnect window and current boot.
Ok(sqlx::query_as("SELECT message_id,received_at FROM observations WHERE tenant_id=$1 AND agent_id=$2 AND boot_id=$3 AND received_at>$4 AND received_at<=$5 AND (NOT $9::boolean OR received_at>$6) AND received_at<=$7 AND ($8::uuid IS NULL OR message_id=$8) ORDER BY received_at DESC LIMIT 1")
.bind(tenant).bind(agent).bind(boot).bind(window.reserved_at).bind(window.deadline).bind(window.now-Duration::minutes(5)).bind(window.now).bind(existing_receipt).bind(window.require_fresh)
.fetch_optional(&mut **tx).await?)
}
/// First ingress of success needs the same independent, timely receipt as an
/// authoritative Sync decision. Claimed deadlines/boot IDs alone grant nothing.
pub(crate) async fn verify_reboot_success(
tx: &mut Transaction<'_, Postgres>,
tenant: Uuid,
agent: Uuid,
envelope: &Envelope,
job: &JobPayload,
result: &JobResult,
evidence: &Value,
) -> Result<()> {
let boot = Uuid::parse_str(&envelope.boot_id)?;
let grant = Uuid::parse_str(&result.grant_id)?;
ensure!(
job.tenant_id == tenant
&& job.agent_id == agent
&& job.job_id.to_string() == result.job_id
&& job.attempt_id.to_string() == result.attempt_id
&& evidence["postconditions_passed"] == true
&& evidence["reconciled_after_reboot"] == true
&& evidence["new_boot_id"] == envelope.boot_id,
"REBOOT_RESULT_BINDING"
);
let reserved:chrono::DateTime<Utc>=sqlx::query_scalar("SELECT created_at FROM execution_permits WHERE tenant_id=$1 AND grant_id=$2 AND job_id=$3 AND attempt_id=$4")
.bind(tenant).bind(grant).bind(job.job_id).bind(job.attempt_id).fetch_optional(&mut **tx).await?.context("REBOOT_RESERVED_GRANT_REQUIRED")?;
let deadline =
reboot_deadline(&job.action, Some(reserved)).context("REBOOT_FIXED_DEADLINE_REQUIRED")?;
let original:Option<String>=sqlx::query_scalar("SELECT data->>'boot_id' FROM audit_events WHERE tenant_id=$1 AND event_type='start_reserved' AND data->>'job_id'=$2 AND data->>'grant_id'=$3 ORDER BY created_at DESC LIMIT 1")
.bind(tenant).bind(job.job_id.to_string()).bind(grant.to_string()).fetch_optional(&mut **tx).await?;
ensure!(
original
.as_deref()
.and_then(|v| Uuid::parse_str(v).ok())
.is_some_and(|old| !old.is_nil() && old != boot),
"REBOOT_ORIGINAL_BOOT_REQUIRED"
);
let receipt = evidence["inventory_message_id"]
.as_str()
.and_then(|v| Uuid::parse_str(v).ok())
.filter(|id| !id.is_nil())
.context("REBOOT_PERSISTED_INVENTORY_REQUIRED")?;
let (_, received) = reboot_inventory(
tx,
tenant,
agent,
boot,
&RebootWindow {
reserved_at: reserved,
deadline,
now: Utc::now(),
require_fresh: true,
},
Some(receipt),
)
.await?
.context("REBOOT_TIMELY_INVENTORY_REQUIRED")?;
for (key, actual) in [
("reboot_reserved_at", reserved),
("reconnect_deadline", deadline),
("inventory_received_at", received),
] {
ensure!(
serde_json::from_value::<chrono::DateTime<Utc>>(evidence[key].clone()).ok()
== Some(actual),
"REBOOT_SERVER_TIME_BINDING"
);
}
Ok(())
}
pub async fn reconcile(
state: &crate::State,
tx: &mut Transaction<'_, Postgres>,
@@ -335,7 +444,7 @@ pub async fn reconcile(
continue;
}
let grant = sqlx::query(
"SELECT grant_id,payload FROM execution_permits WHERE job_id=$1 AND attempt_id=$2",
"SELECT grant_id,payload,created_at FROM execution_permits WHERE job_id=$1 AND attempt_id=$2",
)
.bind(job_id)
.bind(attempt)
@@ -433,18 +542,53 @@ pub async fn reconcile(
// A reboot's postcondition is independently tied to persisted current-
// boot inventory and the original boot in the durable reservation audit.
let mut reboot_reconciled = false;
let mut reboot_witness = None;
if matches!(payload.action, Action::Reboot { .. })
&& grant_matches
&& matches!(local.state.as_str(), "awaiting_reboot" | "unknown")
{
let original:Option<String>=sqlx::query_scalar("SELECT data->>'boot_id' FROM audit_events WHERE event_type='start_reserved' AND data->>'job_id'=$1 ORDER BY created_at DESC LIMIT 1").bind(job_id.to_string()).fetch_optional(&mut **tx).await?;
let inventory:Option<Uuid>=sqlx::query_scalar("SELECT message_id FROM observations WHERE agent_id=$1 AND boot_id=$2 AND received_at>now()-interval '5 minutes' AND received_at>(SELECT created_at FROM execution_permits WHERE job_id=$3) ORDER BY received_at DESC LIMIT 1").bind(agent).bind(boot).bind(job_id).fetch_optional(&mut **tx).await?;
if let (Some(original), Some(inventory)) = (original, inventory)
let original:Option<String>=sqlx::query_scalar("SELECT data->>'boot_id' FROM audit_events WHERE tenant_id=$1 AND event_type='start_reserved' AND data->>'job_id'=$2 AND data->>'grant_id'=$3 ORDER BY created_at DESC LIMIT 1").bind(tenant).bind(job_id.to_string()).bind(&local.grant_id).fetch_optional(&mut **tx).await?;
let reserved_at = grant
.as_ref()
.map(|g| g.get::<chrono::DateTime<Utc>, _>("created_at"));
let deadline = reboot_deadline(&payload.action, reserved_at);
let inventory = if let (Some(reserved), Some(until)) = (reserved_at, deadline) {
let existing_receipt = if final_row.get::<String, _>("state") == "succeeded" {
final_row
.get::<Option<Value>, _>("result")
.and_then(|value| {
value["evidence"]["inventory_message_id"]
.as_str()
.and_then(|v| Uuid::parse_str(v).ok())
})
} else {
None
};
reboot_inventory(
tx,
tenant,
agent,
boot,
&RebootWindow {
reserved_at: reserved,
deadline: until,
now: Utc::now(),
require_fresh: existing_receipt.is_none(),
},
existing_receipt,
)
.await?
} else {
None
};
if let (Some(original), Some((inventory, received_at)), Some(reserved), Some(until)) =
(original, inventory, reserved_at, deadline)
&& original != e.boot_id
&& decision.original_boot_id == Some(Uuid::parse_str(&original)?)
{
reboot_witness = Some((original, inventory));
let revision = (final_row.get::<i64, _>("revision") as u64).max(local.revision) + 1;
let result=JobResult{job_id:local.job_id.clone(),attempt_id:local.attempt_id.clone(),revision,state:"succeeded".into(),grant_id:local.grant_id.clone(),stdout:vec![],stderr:vec![],output_truncated:false,reboot_required:false,exit_code:None,evidence_json:json!({"postconditions_passed":true,"new_boot_id":boot,"inventory_message_id":inventory,"reconciled_after_reboot":true}).to_string(),error_code:String::new()};
let result=JobResult{job_id:local.job_id.clone(),attempt_id:local.attempt_id.clone(),revision,state:"succeeded".into(),grant_id:local.grant_id.clone(),stdout:vec![],stderr:vec![],output_truncated:false,reboot_required:false,exit_code:None,evidence_json:json!({"postconditions_passed":true,"new_boot_id":boot,"inventory_message_id":inventory,"reconciled_after_reboot":true,"reboot_reserved_at":reserved,"reconnect_deadline":until,"inventory_received_at":received_at}).to_string(),error_code:String::new()};
let mut evidence = e.clone();
evidence.message_id = Uuid::new_v4().to_string();
evidence.payload = Some(Payload::JobResult(result));
@@ -465,18 +609,17 @@ pub async fn reconcile(
&& terminal == "succeeded"
&& matches!(local.state.as_str(), "awaiting_reboot" | "unknown")
&& let Some(value) = final_row.get::<Option<Value>, _>("result")
&& let Some((original, inventory)) = reboot_witness
&& Uuid::parse_str(&original).ok() == decision.original_boot_id
&& decision.original_boot_id.is_some()
&& value["evidence"]["postconditions_passed"] == json!(true)
&& value["evidence"]["reconciled_after_reboot"] == json!(true)
&& value["evidence"]["new_boot_id"]
.as_str()
.is_some_and(|id| id == e.boot_id)
&& value["evidence"]["inventory_message_id"] == json!(inventory)
{
let original:Option<String>=sqlx::query_scalar("SELECT data->>'boot_id' FROM audit_events WHERE event_type='start_reserved' AND data->>'job_id'=$1 ORDER BY created_at DESC LIMIT 1").bind(job_id.to_string()).fetch_optional(&mut **tx).await?;
if original.as_ref().and_then(|v| Uuid::parse_str(v).ok()) == decision.original_boot_id
&& decision.original_boot_id.is_some()
&& value["evidence"]["postconditions_passed"] == json!(true)
&& value["evidence"]["reconciled_after_reboot"] == json!(true)
&& value["evidence"]["new_boot_id"]
.as_str()
.is_some_and(|id| Some(id) != original.as_deref())
{
reboot_reconciled = true;
}
reboot_reconciled = true;
}
decision.revision = final_row.get::<i64, _>("revision") as u64;
decision.outcome_state = terminal.clone();
@@ -603,6 +746,348 @@ async fn mark_unknown(tx: &mut Transaction<'_, Postgres>, job: Uuid, reason: &st
mod tests {
use super::*;
#[test]
fn reboot_deadline_uses_only_the_fixed_plan_and_trusted_reservation() {
let reserved = Utc::now();
let action = Action::Reboot {
reason: "Explicit final Cloud VM acceptance".into(),
reconnect_timeout_seconds: 180,
dependency_group: "single-test-vm".into(),
};
assert_eq!(
reboot_deadline(&action, Some(reserved)),
Some(reserved + Duration::seconds(180))
);
assert_eq!(reboot_deadline(&action, None), None);
assert_eq!(
reboot_deadline(
&Action::Reboot {
reason: "test".into(),
reconnect_timeout_seconds: 0,
dependency_group: "single-test-vm".into()
},
Some(reserved)
),
None
);
assert_eq!(
reboot_deadline(&action, Some(chrono::DateTime::<Utc>::MAX_UTC)),
None
);
}
#[tokio::test]
#[ignore = "requires the existing dedicated isolated PostgreSQL harness"]
async fn reboot_inventory_requires_trusted_timely_same_identity_and_boot() {
let admin = sqlx::PgPool::connect(&std::env::var("RMM_TEST_REPAIR_ADMIN_URL").unwrap())
.await
.unwrap();
let app = sqlx::PgPool::connect(&std::env::var("RMM_TEST_REPAIR_APP_URL").unwrap())
.await
.unwrap();
rmm_persistence::verify_application_role(&app)
.await
.unwrap();
let tenant = Uuid::new_v4();
let asset = Uuid::new_v4();
let agent = Uuid::new_v4();
let boot = Uuid::new_v4();
sqlx::query("INSERT INTO tenants VALUES($1,'isolated reboot deadline test')")
.bind(tenant)
.execute(&admin)
.await
.unwrap();
sqlx::query("INSERT INTO assets VALUES($1,$2)")
.bind(tenant)
.bind(asset)
.execute(&admin)
.await
.unwrap();
sqlx::query("INSERT INTO agent_installations(tenant_id,agent_id,asset_id,certificate_sha256) VALUES($1,$2,$3,$4)")
.bind(tenant).bind(agent).bind(asset).bind(hash(agent.as_bytes())).execute(&admin).await.unwrap();
let now = Utc::now();
let reserved = now - Duration::seconds(200);
let deadline = reserved + Duration::seconds(180);
let window = RebootWindow {
reserved_at: reserved,
deadline,
now,
require_fresh: true,
};
let timely = Uuid::new_v4();
let late = Uuid::new_v4();
for (sequence, message, received) in [
(1, timely, deadline),
(2, late, deadline + Duration::microseconds(1)),
(3, Uuid::new_v4(), reserved),
] {
sqlx::query("INSERT INTO observations(tenant_id,agent_id,message_id,boot_id,sequence,observed_at,received_at,source_id,quality,completeness,snapshot_id,data,payload_sha256) VALUES($1,$2,$3,$4,$5,$6,$6,'linux.base','valid','partial',$7,'{}',$8)")
.bind(tenant).bind(agent).bind(message).bind(boot).bind(sequence).bind(received).bind(Uuid::new_v4()).bind("ab".repeat(32)).execute(&admin).await.unwrap();
}
let mut tx = rmm_persistence::tenant_tx(&app, tenant).await.unwrap();
assert_eq!(
reboot_inventory(&mut tx, tenant, agent, boot, &window, None)
.await
.unwrap()
.map(|v| v.0),
Some(timely)
);
assert!(
reboot_inventory(&mut tx, tenant, agent, boot, &window, Some(late))
.await
.unwrap()
.is_none()
);
assert!(
reboot_inventory(&mut tx, tenant, Uuid::new_v4(), boot, &window, None)
.await
.unwrap()
.is_none()
);
assert!(
reboot_inventory(&mut tx, Uuid::new_v4(), agent, boot, &window, None)
.await
.unwrap()
.is_none()
);
assert!(
reboot_inventory(&mut tx, tenant, agent, Uuid::new_v4(), &window, None)
.await
.unwrap()
.is_none()
);
let later = RebootWindow {
now: now + Duration::minutes(6),
..window
};
assert!(
reboot_inventory(&mut tx, tenant, agent, boot, &later, None)
.await
.unwrap()
.is_none()
);
// A terminal result reuses only its exact original timely receipt;
// later metadata cannot replace or extend that immutable proof.
let historical = RebootWindow {
require_fresh: false,
..later
};
assert_eq!(
reboot_inventory(&mut tx, tenant, agent, boot, &historical, Some(timely))
.await
.unwrap()
.map(|v| v.0),
Some(timely)
);
let before_return = RebootWindow {
now: deadline - Duration::microseconds(1),
..window
};
assert!(
reboot_inventory(&mut tx, tenant, agent, boot, &before_return, None)
.await
.unwrap()
.is_none()
);
tx.rollback().await.unwrap();
let effects:i64=sqlx::query_scalar("SELECT (SELECT count(*) FROM jobs WHERE tenant_id=$1)+(SELECT count(*) FROM outbox WHERE tenant_id=$1)+(SELECT count(*) FROM execution_permits WHERE tenant_id=$1)").bind(tenant).fetch_one(&admin).await.unwrap();
assert_eq!(effects, 0);
}
#[tokio::test]
#[ignore = "requires the existing dedicated isolated PostgreSQL harness"]
async fn reboot_success_ingress_rejects_forged_late_proof_and_preserves_exact_replay() {
let admin = sqlx::PgPool::connect(&std::env::var("RMM_TEST_REPAIR_ADMIN_URL").unwrap())
.await
.unwrap();
let app = sqlx::PgPool::connect(&std::env::var("RMM_TEST_REPAIR_APP_URL").unwrap())
.await
.unwrap();
rmm_persistence::verify_application_role(&app)
.await
.unwrap();
let tenant = Uuid::new_v4();
let asset = Uuid::new_v4();
let agent = Uuid::new_v4();
let boot = Uuid::new_v4();
let old = Uuid::new_v4();
let job = Uuid::new_v4();
let attempt = Uuid::new_v4();
let operation = Uuid::new_v4();
let plan = Uuid::new_v4();
let authorization = Uuid::new_v4();
let grant = Uuid::new_v4();
let now = chrono::DateTime::from_timestamp_micros(Utc::now().timestamp_micros()).unwrap();
let reserved = now - Duration::seconds(200);
let deadline = reserved + Duration::seconds(180);
let payload = JobPayload {
schema_version: 1,
tenant_id: tenant,
asset_id: asset,
agent_id: agent,
enrollment_generation: 1,
assignment_version: 1,
job_id: job,
attempt_id: attempt,
action: Action::Reboot {
reason: "Isolated postcondition test; no actual reboot".into(),
reconnect_timeout_seconds: 180,
dependency_group: "single-test-vm".into(),
},
execution_identity: "root".into(),
not_before: reserved,
start_before: now + Duration::minutes(5),
max_runtime_seconds: 240,
max_output_bytes: 65536,
};
let bytes = serde_json::to_vec(&payload).unwrap();
sqlx::query("INSERT INTO tenants VALUES($1,'isolated reboot ingress test')")
.bind(tenant)
.execute(&admin)
.await
.unwrap();
sqlx::query("INSERT INTO assets VALUES($1,$2)")
.bind(tenant)
.bind(asset)
.execute(&admin)
.await
.unwrap();
sqlx::query("INSERT INTO agent_installations(tenant_id,agent_id,asset_id,certificate_sha256) VALUES($1,$2,$3,$4)").bind(tenant).bind(agent).bind(asset).bind(hash(agent.as_bytes())).execute(&admin).await.unwrap();
sqlx::query("INSERT INTO operation_plans(tenant_id,plan_id,principal,payload,plan_hash,expires_at) VALUES($1,$2,'isolated-test',$3,$4,$5)").bind(tenant).bind(plan).bind(b"{}".as_slice()).bind("ab".repeat(32)).bind(now+Duration::minutes(10)).execute(&admin).await.unwrap();
sqlx::query("INSERT INTO approval_requests(tenant_id,operation_id,plan_id,principal,idempotency_key,request_hash,approval_state) VALUES($1,$2,$3,'isolated-test',$4,$5,'approved')").bind(tenant).bind(operation).bind(plan).bind(operation.to_string()).bind("cd".repeat(32)).execute(&admin).await.unwrap();
sqlx::query("INSERT INTO authorizations(tenant_id,authorization_id,operation_id,plan_id,plan_hash,principal,session_hash,approval_origin,testsimulation,policy_version) VALUES($1,$2,$3,$4,$5,'isolated-test',$6,'dev_test_browser_simulation',true,1)").bind(tenant).bind(authorization).bind(operation).bind(plan).bind("ab".repeat(32)).bind("ef".repeat(32)).execute(&admin).await.unwrap();
sqlx::query("INSERT INTO operations VALUES($1,$2,$3)")
.bind(tenant)
.bind(operation)
.bind(authorization)
.execute(&admin)
.await
.unwrap();
sqlx::query("INSERT INTO jobs(tenant_id,job_id,attempt_id,operation_id,agent_id,asset_id,payload,payload_hash,state,start_reserved,resource) VALUES($1,$2,$3,$4,$5,$6,$7,$8,'unknown',true,'device_execution')").bind(tenant).bind(job).bind(attempt).bind(operation).bind(agent).bind(asset).bind(&bytes).bind(hash(&bytes)).execute(&admin).await.unwrap();
sqlx::query("INSERT INTO execution_permits VALUES($1,$2,$3,$4,$5,$6,$7)")
.bind(tenant)
.bind(grant)
.bind(job)
.bind(attempt)
.bind(b"{}".as_slice())
.bind(vec![0u8; 64])
.bind(reserved)
.execute(&admin)
.await
.unwrap();
sqlx::query(
"INSERT INTO audit_events VALUES($1,$2,'isolated-test','start_reserved',$3,$4)",
)
.bind(tenant)
.bind(Uuid::new_v4())
.bind(json!({"job_id":job,"grant_id":grant,"boot_id":old}))
.bind(reserved)
.execute(&admin)
.await
.unwrap();
let timely = Uuid::new_v4();
let late = Uuid::new_v4();
for (sequence, message, received) in [
(1, timely, deadline),
(2, late, deadline + Duration::microseconds(1)),
] {
sqlx::query("INSERT INTO observations(tenant_id,agent_id,message_id,boot_id,sequence,observed_at,received_at,source_id,quality,completeness,snapshot_id,data,payload_sha256) VALUES($1,$2,$3,$4,$5,$6,$6,'linux.base','valid','partial',$7,'{}',$8)").bind(tenant).bind(agent).bind(message).bind(boot).bind(sequence).bind(received).bind(Uuid::new_v4()).bind("aa".repeat(32)).execute(&admin).await.unwrap();
}
let evidence = json!({"postconditions_passed":true,"reconciled_after_reboot":true,"new_boot_id":boot,"inventory_message_id":late,
"reboot_reserved_at":reserved,"reconnect_deadline":deadline,"inventory_received_at":deadline});
let mut result = JobResult {
job_id: job.to_string(),
attempt_id: attempt.to_string(),
grant_id: grant.to_string(),
revision: 1,
state: "succeeded".into(),
evidence_json: evidence.to_string(),
..Default::default()
};
let mut envelope = Envelope {
message_id: Uuid::new_v4().to_string(),
agent_id: agent.to_string(),
boot_id: boot.to_string(),
payload: Some(Payload::JobResult(result.clone())),
..Default::default()
};
let mut tx = rmm_persistence::tenant_tx(&app, tenant).await.unwrap();
assert!(
crate::job_gateway::event(&mut tx, tenant, agent, &envelope)
.await
.is_err()
);
assert_eq!(
sqlx::query_scalar::<_, String>("SELECT state FROM jobs WHERE job_id=$1")
.bind(job)
.fetch_one(&mut *tx)
.await
.unwrap(),
"unknown"
);
assert_eq!(
sqlx::query_scalar::<_, i64>("SELECT count(*) FROM job_receipts")
.fetch_one(&mut *tx)
.await
.unwrap(),
0
);
let mut good = evidence.clone();
good["inventory_message_id"] = json!(timely);
let mut false_clock = good.clone();
false_clock["reconnect_deadline"] = json!(now + Duration::days(1));
result.evidence_json = false_clock.to_string();
envelope.payload = Some(Payload::JobResult(result.clone()));
assert!(
crate::job_gateway::event(&mut tx, tenant, agent, &envelope)
.await
.is_err()
);
result.evidence_json = good.to_string();
envelope.payload = Some(Payload::JobResult(result.clone()));
crate::job_gateway::event(&mut tx, tenant, agent, &envelope)
.await
.unwrap();
assert_eq!(
sqlx::query_scalar::<_, String>("SELECT state FROM jobs WHERE job_id=$1")
.bind(job)
.fetch_one(&mut *tx)
.await
.unwrap(),
"succeeded"
);
// The original timely receipt survives later inventories and wall time.
let later = RebootWindow {
reserved_at: reserved,
deadline,
now: now + Duration::minutes(10),
require_fresh: false,
};
assert_eq!(
reboot_inventory(&mut tx, tenant, agent, boot, &later, Some(timely))
.await
.unwrap()
.map(|v| v.0),
Some(timely)
);
assert!(
reboot_inventory(&mut tx, tenant, agent, boot, &later, Some(late))
.await
.unwrap()
.is_none()
);
// Exact durable-message replay ACKs the existing receipt, without
// accepting a new result or extending its original evidence window.
crate::job_gateway::event(&mut tx, tenant, agent, &envelope)
.await
.unwrap();
assert_eq!(
sqlx::query_scalar::<_, i64>("SELECT count(*) FROM job_receipts")
.fetch_one(&mut *tx)
.await
.unwrap(),
1
);
tx.rollback().await.unwrap();
}
#[test]
fn uncertain_request_resolves_only_to_a_known_checkpoint_anchor() {
let applied = Uuid::new_v4();
let pending = Uuid::new_v4();
@@ -0,0 +1,94 @@
// Final single Cloud VM reboot: actual dev/test UI only, never API approval.
const fs = require('node:fs');
const path = require('node:path');
const crypto = require('node:crypto');
const { isDeepStrictEqual: equal } = require('node:util');
const { chromium } = require('../../web/node_modules/playwright');
const root = path.resolve(__dirname, '../..');
const reason = 'Explicit final Linux VM dev/test acceptance; reconnect within 180 seconds of the central start reservation';
const assert = value => { if (!value) throw new Error('Final reboot UI contract mismatch'); };
function readPrivate(file) {
const s = fs.lstatSync(file);
assert(s.isFile() && !s.isSymbolicLink() && s.uid === process.getuid() && (s.mode & 0o777) === 0o600 && s.size < 1048576);
return JSON.parse(fs.readFileSync(file, 'utf8'));
}
function checkPlan(plan, expected) {
assert(plan.jobs.length === 1 && plan.resolved_targets.length === 1
&& crypto.createHash('sha256').update(Buffer.from(plan.plan_payload_bytes)).digest('hex') === plan.plan_hash);
const p = plan.jobs[0].payload;
assert(p.tenant_id === expected.tenant_id && p.agent_id === expected.agent_id && p.asset_id === expected.asset_id
&& p.execution_identity === 'root' && p.max_runtime_seconds === 240 && p.max_output_bytes === 65536);
assert(equal(p.action, { action: 'reboot', reason, reconnect_timeout_seconds: 180, dependency_group: 'single-test-vm' }));
assert(Date.parse(p.start_before) > Date.now());
}
(async () => {
const file = path.resolve(process.argv[2]); const expected = readPrivate(file);
assert(expected.profile === 'dev/test' && expected.case === 'reboot_last'
&& ['prepare', 'approve'].includes(expected.phase) && expected.expected_principal === 'simulated-testprincipal-a');
const login = readPrivate(path.join(root, 'credentials/server-browser-login.json'));
const browsers = path.join(root, 'web/node_modules/.cache/playwright-browsers');
const version = fs.readdirSync(browsers).find(x => /^chromium-/.test(x));
const executablePath = ['chrome-linux/chrome', 'chrome-linux64/chrome'].map(x => path.join(browsers, version, x)).find(x => fs.existsSync(x));
const browser = await chromium.launch({ headless: true, executablePath,
env: { ...process.env, HOME: path.join(root, 'web/node_modules/.cache/cloud-acceptance/home') } });
try {
const page = await browser.newPage({ ignoreHTTPSErrors: false, timezoneId: 'UTC' }); page.setDefaultTimeout(15000);
let approvals = 0;
page.on('request', r => { if (new URL(r.url()).pathname.endsWith('/authorizations')) approvals++; });
await page.goto('https://localhost:18443/');
await page.getByLabel('Benutzername').fill(login.username); await page.getByLabel('Passwort', { exact: true }).fill(login.password);
const response = page.waitForResponse(r => new URL(r.url()).pathname === '/auth/session' && r.status() === 200);
await page.getByRole('button', { name: 'Anmelden', exact: true }).click();
const session = await (await response).json();
assert(session.testsimulation === true && session.approval_origin === 'dev_test_browser_simulation'
&& session.principal === expected.expected_principal);
await page.getByRole('status').filter({ hasText: 'SIMULIERT' }).waitFor();
assert(await page.getByLabel('Mandant', { exact: true }).inputValue() === expected.tenant_id);
const detail = page.locator('section').filter({ has: page.getByRole('heading', { name: 'Unveränderlicher Plan / Genehmigungsdetail', exact: true }) });
if (expected.phase === 'prepare') {
const request = expected.request;
assert(request.action === 'reboot' && request.reason === reason && equal(request.targets.asset_ids, [expected.asset_id])
&& equal(request.rollout, { max_parallel: 1, halt_after_failures: 1 })
&& equal(request.parameters, { reason, dependency_group: 'single-test-vm', reconnect_timeout_seconds: 180,
execution_identity: 'root', timeout_seconds: 240, max_output_bytes: 65536 }));
await page.getByRole('checkbox', { name: 'Ziel ' + expected.asset_id, exact: true }).check();
await page.getByLabel('Aktion', { exact: true }).selectOption('reboot');
await page.getByLabel('Aktionsparameter', { exact: true }).fill(JSON.stringify(request.parameters));
await page.getByLabel('Ausführungsidentität', { exact: true }).selectOption('root');
await page.getByLabel('Laufzeitlimit (s)', { exact: true }).fill('240');
await page.getByLabel('Ausgabelimit (Bytes)', { exact: true }).fill('65536');
await page.getByLabel('Frühester Start (lokale Zeit)', { exact: true }).fill(new Date(request.schedule.not_before).toISOString().slice(0, 16));
await page.getByLabel('Startfrist / Ablauf (lokale Zeit)', { exact: true }).fill(new Date(request.schedule.start_before).toISOString().slice(0, 16));
await page.getByLabel('Maximal parallel', { exact: true }).fill('1'); await page.getByLabel('Stopp nach Fehlern', { exact: true }).fill('1');
await page.getByLabel('Begründung', { exact: true }).fill(reason);
await page.getByRole('button', { name: 'Plan erstellen · noch keine Ausführung' }).click();
await detail.locator('pre').waitFor(); const plan = JSON.parse(await detail.locator('pre').innerText()); checkPlan(plan, expected);
await detail.getByRole('button', { name: 'Antrag absenden · pending_approval' }).click();
const operation = page.locator('section').filter({ has: page.getByRole('heading', { name: /^Antrag \/ Ausführung / }) });
await operation.locator('pre').first().filter({ hasText: '"job_count": 0' }).waitFor();
const pending = JSON.parse(await operation.locator('pre').first().innerText());
assert(pending.approval_state === 'pending_approval' && pending.execution_state === null && approvals === 0);
assert(path.dirname(path.resolve(expected.output_file)) === path.dirname(file));
fs.writeFileSync(expected.output_file, JSON.stringify({ plan, operation: pending }), { flag: 'wx', mode: 0o600 });
} else {
await page.getByRole('button', { name: expected.operation_id, exact: true }).click();
const operation = page.locator('section').filter({ has: page.getByRole('heading', { name: 'Antrag / Ausführung ' + expected.operation_id, exact: true }) });
const pending = JSON.parse(await operation.locator('pre').first().innerText());
assert(pending.approval_state === 'pending_approval' && pending.job_count === 0 && pending.execution_state === null);
await operation.getByRole('button', { name: 'Unveränderlichen Plan zur Prüfung öffnen', exact: true }).click();
const plan = JSON.parse(await detail.locator('pre').innerText()); checkPlan(plan, expected);
const { approval_state: currentState, ...actual } = plan;
const { approval_state: previousState, ...prepared } = expected.plan;
assert(currentState === 'pending_approval' && previousState === null && equal(actual, prepared)
&& equal(plan.jobs[0], expected.job));
const approve = detail.getByRole('button', { name: 'SIMULIERT: Diesen festen Plan ausdrücklich genehmigen', exact: true });
assert(await approve.isDisabled());
await detail.getByRole('checkbox', { name: 'Ich habe sämtliche festen Ziele', exact: false }).check(); await approve.click();
await operation.locator('p.warning').filter({ hasText: 'Antrag: approved' }).waitFor(); assert(approvals === 1);
}
await page.getByRole('button', { name: 'Abmelden', exact: true }).click();
} finally { await browser.close(); }
})().catch(error => {
const line = error.stack?.match(/cloud_reboot_acceptance\.cjs:(\d+):\d+/)?.[1] || 'unknown';
console.log('CLOUD_REBOOT_UI_INCOMPLETE:' + error.constructor.name + ':source_line=' + line); process.exitCode = 1;
});
+273
View File
@@ -0,0 +1,273 @@
#!/usr/bin/env python3
"""LAST Linux-MVP gate: one fixed WebUI-approved Cloud-VM reboot.
Bootstrap changes only the existing General policy/pin and an expiring central
reboot-only scope. Bootstrap never requests a reboot. Unknown means stop, never
retry; finish reads the same job and close restores the original policy/pin.
"""
import argparse
import datetime as dt
import hashlib
import json
import os
from pathlib import Path
import subprocess
import time
import uuid
import cloud_apt_recovery as apt
cloud=apt.cloud
require=cloud.contract.require
STATE=cloud.ROOT/'devstate/cloud-reboot'
REASON='Explicit final Linux VM dev/test acceptance; reconnect within 180 seconds of the central start reservation'
GATES=('apt_native_update','ensure_package','apply_updates','offline_wait','expired_offline','revoked_before_start','agent_crash','transport_fallback','mcp')
def vm_state(payload):
import sqlite3
root=Path('/var/lib/rmm-agent-remote');helper=Path('/var/lib/rmm-helper')
require(json.loads((root/'identity.json').read_text())['agent_id']==payload['agent_id'],'permanent Cloud identity')
for path,key in ((Path('/usr/local/libexec/rmm-agent-remote'),'agent_sha256'),(Path('/usr/local/libexec/rmm-privileged-helper'),'helper_sha256')):
require(not path.is_symlink() and hashlib.sha256(path.read_bytes()).hexdigest()==payload[key],'qualified current binaries')
require(hashlib.sha256(Path('/etc/systemd/system/rmm-helper-cloud.service').read_bytes()).hexdigest()==payload['general_unit_sha256'],'reviewed General D-Bus service profile with direct reboot syscalls denied')
services={}
for unit in ('rmm-agent-remote.service','rmm-helper-cloud.service','rmm-apt-helper.service'):
raw=subprocess.run(['systemctl','show',unit,'-p','ActiveState','-p','MainPID','-p','UnitFileState'],capture_output=True,check=True,timeout=10).stdout.decode()
services[unit]=dict(line.split('=',1) for line in raw.splitlines())
dropin=Path('/etc/systemd/system/rmm-agent-remote.service.d/30-cloud-root.conf')
require(not dropin.is_symlink() and 'RMM_APT_HELPER_' not in dropin.read_text() and services['rmm-apt-helper.service']['ActiveState']=='inactive','close APT endpoint before final reboot gate')
result=dict(boot_id=Path('/proc/sys/kernel/random/boot_id').read_text().strip(),services=services,root_rows={},database_inodes={})
for path in (root/'journal.sqlite',root/'consumption.sqlite',helper/'consumption.sqlite'):
s=path.stat();result['database_inodes'][str(path)]=[s.st_dev,s.st_ino]
with sqlite3.connect(path.as_uri()+'?mode=ro',uri=True) as db:
require(db.execute('PRAGMA integrity_check').fetchone()[0]=='ok','preserved database integrity')
if path==helper/'consumption.sqlite':
rows=db.execute('SELECT c.grant_id,c.agent,c.generation,c.job,c.attempt,c.result,e.start,e.outcome FROM consumed c LEFT JOIN execution_evidence e USING(grant_id) ORDER BY grant_id').fetchall()
for row in rows:
serial=[dict(sha256=hashlib.sha256(v).hexdigest(),size=len(v)) if isinstance(v,bytes) else v for v in row]
result['root_rows'][row[0]]=hashlib.sha256(json.dumps(serial,separators=(',',':')).encode()).hexdigest()
result['root_unresolved']=sum(row[5] is None for row in rows)
require(db.execute('SELECT count(*) FROM helper_sync_meta WHERE fault IS NOT NULL').fetchone()[0]==0,'no helper fault')
if payload.get('job_id'):
selected=[r for r in rows if r[3]==payload['job_id'] and r[4]==payload['attempt_id']]
result['selected_root_grants']=[r[0] for r in selected]
row=db.execute('SELECT response FROM helper_sync_decisions WHERE decision_id=(SELECT last_decision FROM helper_sync_meta WHERE id=1)').fetchone()
signed=json.loads(row[0]);decision=json.loads(bytes(signed['decision_bytes']))
result['signed_sync']=dict(decision_id=decision['decision_id'],ready=decision['ready'],helper_ready=decision['helper_ready'],boot_id=decision['boot_id'],
selected=[a for a in decision['attempts'] if a['job_id']==payload['job_id'] and a['attempt_id']==payload['attempt_id']])
elif path==root/'journal.sqlite':
require(db.execute('SELECT count(*) FROM reconcile_meta WHERE fault IS NOT NULL').fetchone()[0]==0,'no agent fault')
result['agent_last_decision']=db.execute('SELECT last_decision FROM reconcile_meta WHERE id=1').fetchone()[0]
if payload.get('job_id'):
result['other_unresolved']=db.execute("SELECT count(*) FROM job_attempts WHERE NOT(job=? AND attempt=?) AND state NOT IN ('succeeded','failed','cancelled','expired')",(payload['job_id'],payload['attempt_id'])).fetchone()[0]
else:result['other_unresolved']=db.execute("SELECT count(*) FROM job_attempts WHERE state NOT IN ('succeeded','failed','cancelled','expired')").fetchone()[0]
config=Path('/etc/rmm-remote/helper-general.json');pin=Path('/etc/rmm-remote/general-helper-proof.json')
result.update(config_sha256=hashlib.sha256(config.read_bytes()).hexdigest(),pin_sha256=hashlib.sha256(pin.read_bytes()).hexdigest(),general_pin=json.loads(pin.read_text()))
return result
def vm_policy(payload):
import fcntl
import sqlite3
os.umask(0o077)
state=Path('/var/lib/rmm-agent-remote');helper=Path('/var/lib/rmm-helper');config=Path('/etc/rmm-remote/helper-general.json');pin=Path('/etc/rmm-remote/general-helper-proof.json')
binary=Path('/usr/local/libexec/rmm-privileged-helper');agent=Path('/usr/local/libexec/rmm-agent-remote')
require(hashlib.sha256(binary.read_bytes()).hexdigest()==payload['helper_sha256'] and hashlib.sha256(agent.read_bytes()).hexdigest()==payload['agent_sha256'],'same qualified runtime')
require(json.loads((state/'identity.json').read_text())['agent_id']==payload['agent_id'],'same permanent identity')
require(not config.is_symlink() and not pin.is_symlink() and hashlib.sha256(config.read_bytes()).hexdigest()==payload['config_sha256'] and hashlib.sha256(pin.read_bytes()).hexdigest()==payload['pin_sha256'],'exact General policy/pin required')
enabled=payload['enabled'];require(type(enabled) is bool,'fixed policy direction')
current=json.loads(config.read_text());require(current['allow_reboot'] is (not enabled),'only one explicit policy transition')
backup=Path('/var/lib/rmm-bootstrap-history')/('cloud-reboot-'+str(uuid.UUID(payload['id']))+('-enable' if enabled else '-restore'));backup.mkdir(mode=0o700)
def create(path,raw,mode=0o600,gid=0):
fd=os.open(path,os.O_WRONLY|os.O_CREAT|os.O_EXCL|os.O_NOFOLLOW,mode)
with os.fdopen(fd,'wb') as f:f.write(raw);f.flush();os.fchown(f.fileno(),0,gid);os.fchmod(f.fileno(),mode);os.fsync(f.fileno())
def manifest(path):
result={}
for p in [path,*sorted(path.rglob('*'))]:
s=p.lstat();require(not p.is_symlink() and (p.is_file() or p.is_dir()),'preserved state must be regular')
result[str(p.relative_to(path))]=[s.st_dev,s.st_ino,hashlib.sha256(p.read_bytes()).hexdigest() if p.is_file() else None]
return result
subprocess.run(['systemctl','stop','rmm-agent-remote.service','rmm-helper-cloud.service'],capture_output=True,check=True,timeout=30)
lock=os.open(helper/'executor.lock',os.O_RDWR|os.O_NOFOLLOW);fcntl.flock(lock,fcntl.LOCK_EX|fcntl.LOCK_NB)
try:
with sqlite3.connect((helper/'consumption.sqlite').as_uri()+'?mode=ro',uri=True) as db:
require(db.execute('SELECT count(*) FROM consumed WHERE result IS NULL').fetchone()[0]==0 and db.execute('SELECT count(*) FROM helper_sync_meta WHERE fault IS NOT NULL').fetchone()[0]==0,'all Root effects closed')
preserved={str(p):manifest(p) for p in (state,helper,Path('/var/lib/rmm-apt-transaction'))}
old_config=config.read_bytes();old_pin=pin.read_bytes()
if enabled:
next_config=dict(current,allow_reboot=True)
else:
original=Path(payload['original_backup'])
require(original.parent==backup.parent and original.name=='cloud-reboot-'+payload['id']+'-enable','same versioned policy origin')
original_raw=(original/'general-before.json').read_bytes();next_config=json.loads(original_raw)
require(next_config==dict(current,allow_reboot=False),'restore only the exact original policy')
for p,name in ((config,'general-before.json'),(pin,'pin-before.json')):
require(p.stat().st_dev==backup.stat().st_dev,'same-filesystem versioned original')
os.rename(p,backup/name)
create(config,json.dumps(next_config).encode() if enabled else original_raw)
output=subprocess.run([str(binary),'--inspect-general-profile'],capture_output=True,check=True,timeout=15,env=dict(os.environ,RMM_HELPER_CONFIG=str(config))).stdout
new_pin=json.loads(output)
require(new_pin['identity']==json.loads(old_pin)['identity'],'helper identity unchanged')
if not enabled:require(new_pin==json.loads((Path(payload['original_backup'])/'pin-before.json').read_text()),'original pin restored')
create(pin,json.dumps(new_pin).encode() if enabled else (Path(payload['original_backup'])/'pin-before.json').read_bytes(),0o640,984)
require(all(manifest(Path(p))==v for p,v in preserved.items()),'journal/ledger/fixture/history bytes and inodes preserved before restart')
report=dict(enabled=enabled,backup=str(backup),preserved_state=True,config_sha256=hashlib.sha256(config.read_bytes()).hexdigest(),pin_sha256=hashlib.sha256(pin.read_bytes()).hexdigest(),general_pin=new_pin,reboot_requested=False)
create(backup/'report.json',json.dumps(report).encode())
finally:fcntl.flock(lock,fcntl.LOCK_UN);os.close(lock)
subprocess.run(['systemctl','start','rmm-helper-cloud.service','rmm-agent-remote.service'],capture_output=True,check=True,timeout=30)
return report
def server_policy(payload):
import datetime as dt
root=Path('/opt/rust-discovery');path=root/'devstate/root-policy/policy.json'
compose=['docker','compose','--env-file',str(root/'devstate/.env'),'-f',str(root/'deploy/server.compose.yaml')]
require(subprocess.run(compose+['exec','-T','gateway','printenv','RMM_PROFILE','RMM_DEV_AUTH'],capture_output=True,check=True,timeout=15).stdout.splitlines()==[b'development',b'true'],'actual development gateway only')
raw=path.read_bytes();policy=json.loads(raw);digest=hashlib.sha256(raw).hexdigest()
require(not path.is_symlink() and path.stat().st_uid==10001 and path.stat().st_mode&0o777==0o600,'private root policy')
if payload['action']=='state':return dict(policy_sha256=digest,closed=dt.datetime.fromisoformat(policy['expires_at'])<=dt.datetime.now(dt.timezone.utc))
require(digest==payload['previous_sha256'],'Root policy drift')
if payload['action']=='enable':
require(dt.datetime.fromisoformat(policy['expires_at'])<=dt.datetime.now(dt.timezone.utc),'previous policy must be closed')
updated=payload['policy'];require(len(updated['scopes'])==1,'one final Cloud VM scope')
scope=updated['scopes'][0]
now=dt.datetime.now(dt.timezone.utc)
require(updated['schema_version']==1 and updated['profile']=='development' and now<dt.datetime.fromisoformat(updated['expires_at'])<=now+dt.timedelta(minutes=31),'short development-only reboot policy')
require(set(scope)==set('tenant_id asset_id agent_id enrollment_generation assignment_version principals helper_policy_sha256 acceptance_evidence_id allowed_services allow_root_scripts allow_reboot'.split()),'no extra Root/APT/log scope')
require(scope['allow_reboot'] is True and scope['allow_root_scripts'] is False and scope['allowed_services']==[] and 'apt' not in scope and scope['principals']==['simulated-testprincipal-a'],'reboot only; no script/APT/service authority')
else:
require(payload['action']=='close','fixed policy action');updated=dict(policy,expires_at=dt.datetime.now(dt.timezone.utc).isoformat())
folder=root/'devstate'/('root-policy-bootstrap-reboot-'+str(uuid.UUID(payload['id']))+'-'+payload['action']);folder.mkdir(mode=0o700)
def create(p,data,uid):
fd=os.open(p,os.O_CREAT|os.O_EXCL|os.O_WRONLY|os.O_NOFOLLOW,0o600)
with os.fdopen(fd,'wb') as f:f.write(data);f.flush();os.fchown(f.fileno(),uid,uid);os.fsync(f.fileno())
create(folder/'previous-policy.json',raw,0);next_path=path.with_suffix('.reboot-next');create(next_path,json.dumps(updated).encode(),10001);os.replace(next_path,path)
return dict(policy_sha256=hashlib.sha256(path.read_bytes()).hexdigest(),backup=str(folder),closed=payload['action']=='close',approvals_created=False)
def server_boot_evidence(payload):
root=Path('/opt/rust-discovery');tenant=str(uuid.UUID(payload['tenant_id']));agent=str(uuid.UUID(payload['agent_id']))
job=str(uuid.UUID(payload['job_id']));receipt=str(uuid.UUID(payload['inventory_message_id']))
query=("SELECT json_build_object('new_boot_id',a.connection_boot_id,'generation',a.connection_generation,'sync_ready',a.sync_ready,'helper_ready',a.helper_sync_ready,"
"'restore_blocked',a.restore_blocked,'last_authenticated_at',a.last_authenticated_at,'grant_id',p.grant_id,'reserved_at',p.created_at,"
"'original_boot_id',(SELECT data->>'boot_id' FROM audit_events WHERE tenant_id=a.tenant_id AND event_type='start_reserved' AND data->>'job_id'='"+job+"' AND data->>'grant_id'=p.grant_id::text),"
"'inventory_message_id',o.message_id,'inventory_boot_id',o.boot_id,'inventory_received_at',o.received_at) FROM agent_installations a "
"JOIN execution_permits p ON p.tenant_id=a.tenant_id AND p.job_id='"+job+"' JOIN observations o ON o.tenant_id=a.tenant_id AND o.agent_id=a.agent_id AND o.message_id='"+receipt+"' "
"WHERE a.tenant_id='"+tenant+"' AND a.agent_id='"+agent+"';")
cmd=['docker','compose','--env-file',str(root/'devstate/.env'),'-f',str(root/'deploy/server.compose.yaml'),'exec','-T','postgres','psql','-X','-qAt','-v','ON_ERROR_STOP=1','-U','postgres','-d','rmm']
raw=subprocess.run(cmd,input=query.encode(),capture_output=True,check=True,timeout=15).stdout.strip();require(raw,'bound authenticated reboot/inventory evidence required')
return json.loads(raw)
def prerequisites(path,target):
m=cloud.contract;manifest=m.protected_json(Path(path));require(manifest['schema_version']==1 and manifest['target']==target and set(manifest['checks'])==set(GATES),'all earlier MVP gates for this permanent target')
selected={}
for name,item in manifest['checks'].items():
p=Path(item['path']).resolve();require(p.is_relative_to(cloud.ROOT/'devstate') and hashlib.sha256(p.read_bytes()).hexdigest()==item['sha256'],'exact protected native gate witness')
data=m.protected_json(p);require(data.get('verified') is True,'native gate not verified');selected[name]=data
for name in ('apt_native_update','ensure_package','apply_updates'):
result=selected[name]['result'];proof=result['result']['evidence']['apt']
require(result['state']=='succeeded' and proof['packages']==[dict(name='rmm-mvp-test',architecture='all',version='1.1')] and proof['fixture_payload_sha256']==hashlib.sha256(b'1.1\n').hexdigest(),'earlier approved stored fixture1.1 postcondition; no SSH package scan')
return dict(path=str(Path(path).resolve()),sha256=hashlib.sha256(Path(path).read_bytes()).hexdigest(),checks=manifest['checks'])
def fixed():
installed=cloud.contract.protected_json(cloud.ROOT/'devstate/remote-vm.json');runtime,_=apt.runtime_session()
return dict(tenant_id=cloud.TENANT,**installed['identity']),dict(agent_id=installed['identity']['agent_id'],agent_sha256=installed['binary_sha256'],helper_sha256=runtime['helper_sha256'],general_unit_sha256=hashlib.sha256((cloud.ROOT/'deploy/linux/rmm-helper-cloud.service').read_bytes()).hexdigest())
def evidence(target,kind,**extra):return cloud.bootstrap.rpc('server.conf',cloud.server,dict(kind=kind,tenant_id=target['tenant_id'],agent_id=target['agent_id'],**extra))
def browser(path):
cloud.prepare_browser();result=subprocess.run(['node',str(cloud.ROOT/'deploy/browser/cloud_reboot_acceptance.cjs'),str(path)],capture_output=True,timeout=120)
require(result.returncode==0,'actual reboot UI incomplete; retain fixed checkpoint, never repeat approval')
def enable(path):
m=cloud.contract;target,pins=fixed();gates=prerequisites(path,target)
require(evidence(target,'gate')['unresolved']==0,'no earlier unresolved work')
old=cloud.bootstrap.rpc('server.conf',server_policy,dict(action='state'));require(old['closed'],'all earlier Root scopes must be closed')
before=cloud.bootstrap.rpc('linux-vm.conf',vm_state,pins)
require(before['root_unresolved']==before['other_unresolved']==0,'healthy fully reconciled runtime')
for name in ('rmm-agent-remote.service','rmm-helper-cloud.service'):
require(before['services'][name]['ActiveState']=='active' and before['services'][name]['UnitFileState']=='enabled','agent and General helper must already autostart after boot')
ident=str(uuid.uuid4());folder=STATE/ident;folder.mkdir(mode=0o700,parents=True)
session=dict(id=ident,target=target,pins=pins,prerequisites=gates,before=before,old_boot_id=before['boot_id'])
m.write_private(folder/'before.json',session)
changed=cloud.bootstrap.rpc('linux-vm.conf',vm_policy,dict(pins,id=ident,enabled=True,config_sha256=before['config_sha256'],pin_sha256=before['pin_sha256']))
m.write_private(folder/'helper-enabled.json',changed)
scope={k:changed['general_pin']['identity'][k] for k in ('tenant_id','asset_id','agent_id','enrollment_generation','assignment_version')}
scope.update(principals=['simulated-testprincipal-a'],helper_policy_sha256=changed['general_pin']['policy_sha256'],acceptance_evidence_id='final-cloud-reboot:'+ident,allowed_services=[],allow_root_scripts=False,allow_reboot=True)
policy=dict(schema_version=1,profile='development',expires_at=(m.now()+dt.timedelta(minutes=30)).isoformat(),scopes=[scope])
opened=cloud.bootstrap.rpc('server.conf',server_policy,dict(id=ident,action='enable',previous_sha256=old['policy_sha256'],policy=policy))
m.write_private(folder/'policy-open.json',dict(opened,policy=policy));print(dict(id=ident,reboot_requested=False,reboot_only_limits_enabled=True))
def accept(ident):
m=cloud.contract;folder=STATE/str(uuid.UUID(ident));session=m.protected_json(folder/'before.json');target=session['target'];pins=session['pins']
prerequisites(session['prerequisites']['path'],target)
require(not (folder/'prepare.json').exists() and evidence(target,'gate')['unresolved']==0,'one new fixed attempt only')
deadline=time.monotonic()+100
while True:
device=cloud.Backend().call('inventory.get_device',{k:target[k] for k in ('tenant_id','asset_id')})
if device['presence']=='online' and {'reboot','root:reboot'}<=set(device['capabilities']):break
require(time.monotonic()<deadline,'fresh measured reboot capability unavailable');time.sleep(2)
current=cloud.bootstrap.rpc('linux-vm.conf',vm_state,pins);require(current['boot_id']==session['old_boot_id'] and current['root_unresolved']==0,'preapproval originalboot and closedeffects')
start=dt.datetime.fromtimestamp((int(time.time())//60+1)*60,dt.timezone.utc)
request=dict(tenant_id=target['tenant_id'],action='reboot',targets=dict(asset_ids=[target['asset_id']]),parameters=dict(reason=REASON,dependency_group='single-test-vm',reconnect_timeout_seconds=180,execution_identity='root',timeout_seconds=240,max_output_bytes=65536),schedule=m.schedule(start,start+dt.timedelta(minutes=10)),rollout=dict(max_parallel=1,halt_after_failures=1),reason=REASON)
common=dict(profile='dev/test',case='reboot_last',expected_principal='simulated-testprincipal-a',**target,id=ident,old_boot_id=session['old_boot_id'])
m.write_private(folder/'prepare.json',dict(common,phase='prepare',request=request,output_file=str(folder/'prepared.json')));browser(folder/'prepare.json')
prepared=m.protected_json(folder/'prepared.json');plan=prepared['plan'];operation=prepared['operation'];require(len(plan['jobs'])==1 and hashlib.sha256(bytes(plan['plan_payload_bytes'])).hexdigest()==plan['plan_hash'],'immutable single reboot plan')
job=plan['jobs'][0];stored=cloud.Backend().call('jobs.get',dict(tenant_id=target['tenant_id'],operation_id=operation['operation_id']));counts=evidence(target,'gate',job_id=job['job_id'])
require(stored['approval_state']=='pending_approval' and stored['job_count']==0 and stored['execution_state'] is None and all(counts[k]==0 for k in ('jobs','outbox','permits')),'real pending0/0/0')
checkpoint=dict(common,plan=plan,job=job,request=request,operation_id=operation['operation_id'],preapproval=counts,stage='pending_approval');m.write_private(folder/'checkpoint.json',checkpoint)
now=cloud.bootstrap.rpc('linux-vm.conf',vm_state,pins);enabled=m.protected_json(folder/'helper-enabled.json')
require(now['boot_id']==session['old_boot_id'] and now['root_unresolved']==0 and now['root_rows']==session['before']['root_rows'] and now['config_sha256']==enabled['config_sha256'] and now['pin_sha256']==enabled['pin_sha256'],'no boot/effect/policy change before actual UI approval')
m.write_private(folder/'approve.json',dict(checkpoint,phase='approve'));browser(folder/'approve.json');finish(ident)
def finish(ident):
m=cloud.contract;folder=STATE/str(uuid.UUID(ident));session=m.protected_json(folder/'before.json');checkpoint=m.protected_json(folder/'checkpoint.json');target=session['target'];job=checkpoint['job'];deadline=time.monotonic()+420
while True:
result=cloud.Backend().call('jobs.get',dict(tenant_id=target['tenant_id'],job_id=job['job_id']))
if result['state'] in m.TERMINAL:break
# awaiting_reboot / unknown remain fenced while the SAME attempt's
# normal outgoing reconnect/inventory/signed Sync can prove completion.
require(time.monotonic()<deadline,'reboot unproven; preserve unknown and do not repeat');time.sleep(3)
require(result['state']=='succeeded','single reboot did not prove success; no retry')
post=result['result']['evidence'];require(post['postconditions_passed'] is True and post['reconciled_after_reboot'] is True and post['new_boot_id']!=session['old_boot_id'],'actual newboot postcondition')
central=cloud.bootstrap.rpc('server.conf',server_boot_evidence,dict(target,job_id=job['job_id'],inventory_message_id=post['inventory_message_id']))
require(central['new_boot_id']==central['inventory_boot_id']==post['new_boot_id'] and central['original_boot_id']==session['old_boot_id'] and central['sync_ready'] and central['helper_ready'] and not central['restore_blocked'],'actual outgoing authenticated currentboot, persisted inventory and fresh signed Sync')
reserved=m.timestamp(central['reserved_at']);received=m.timestamp(central['inventory_received_at'])
require(reserved<received<=reserved+dt.timedelta(seconds=180) and m.timestamp(post['reboot_reserved_at'])==reserved and m.timestamp(post['reconnect_deadline'])==reserved+dt.timedelta(seconds=180),'original central deadline and timely independent receipt')
native=cloud.bootstrap.rpc('linux-vm.conf',vm_state,dict(session['pins'],job_id=job['job_id'],attempt_id=job['attempt_id']))
sync=native['signed_sync'];require(native['boot_id']==post['new_boot_id'] and native['root_unresolved']==native['other_unresolved']==0 and native['database_inodes']==session['before']['database_inodes'] and len(native['root_rows'])==len(session['before']['root_rows'])+1 and all(native['root_rows'].get(k)==v for k,v in session['before']['root_rows'].items()),'preserved oldledgers/inodes and closedexactreboot')
require(sync['ready'] and sync['helper_ready'] and sync['boot_id']==post['new_boot_id'] and native['agent_last_decision']==sync['decision_id'] and len(native['selected_root_grants'])==1 and native['selected_root_grants']==[result['result']['grant_id']],'same consumed grant and applied normal signed Sync')
require(len(sync['selected'])==1 and sync['selected'][0]['grant_id']==result['result']['grant_id'] and sync['selected'][0]['outcome_state']=='succeeded','same signed reboot result')
counts=evidence(target,'gate',job_id=job['job_id']);audit=evidence(target,'audit',operation_id=checkpoint['operation_id'])
require([counts[k] for k in ('jobs','outbox','permits')]==[1,1,1] and audit==dict(origin='dev_test_browser_simulation',simulation=True,principal='simulated-testprincipal-a',plan_hash=checkpoint['plan']['plan_hash']),'one actual simulated UI approval and one job/outbox/grant')
m.write_private(folder/'result.json',dict(verified=True,result=result,central=central,native=native,postapproval=counts,audit=audit));print(dict(verified=True,single_native_reboot=True,new_boot_proven=True,old_state_preserved=True,id=ident))
def close(ident):
m=cloud.contract;folder=STATE/str(uuid.UUID(ident));require(m.protected_json(folder/'result.json')['verified'],'normal verified reconnect required before rollback')
session=m.protected_json(folder/'before.json');target=session['target'];opened=m.protected_json(folder/'policy-open.json');enabled=m.protected_json(folder/'helper-enabled.json')
require(evidence(target,'gate')['unresolved']==0,'all effects closed')
closed=cloud.bootstrap.rpc('server.conf',server_policy,dict(id=ident,action='close',previous_sha256=opened['policy_sha256']))
m.write_private(folder/'policy-closed.json',closed)
restored=cloud.bootstrap.rpc('linux-vm.conf',vm_policy,dict(session['pins'],id=ident,enabled=False,config_sha256=enabled['config_sha256'],pin_sha256=enabled['pin_sha256'],original_backup=enabled['backup']))
require(restored['general_pin']==session['before']['general_pin'] and restored['config_sha256']==session['before']['config_sha256'] and restored['pin_sha256']==session['before']['pin_sha256'] and restored['preserved_state'] and not restored['reboot_requested'],'original non-reboot policy/pin bytes restored without another reboot')
m.write_private(folder/'closed.json',dict(verified=True,policy=closed,helper=restored));print('Final reboot limits closed; exact original General policy/pin restored; no second reboot')
def main():
parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('action',choices=('enable','accept','finish','close'));parser.add_argument('--id');parser.add_argument('--prerequisites');args=parser.parse_args();os.umask(0o077)
if args.action=='enable':require(args.prerequisites,'explicit completed native prerequisite manifest required');enable(args.prerequisites)
else:require(args.id,'one existing bound reboot session required');{'accept':accept,'finish':finish,'close':close}[args.action](args.id)
if __name__=='__main__':
try:main()
except Exception as error:
message=str(error);print(message if message.startswith('remote bootstrap incomplete: ') else 'CLOUD_REBOOT_INCOMPLETE:'+type(error).__name__)
raise SystemExit(2) from None
+13
View File
@@ -1,5 +1,18 @@
# Übergabe / Entwicklungspause — 2026-11-12
**Aktuelle Fortsetzung2026-11-13:** Automatischer WSS→HTTPS-Fallback auf der
permanenten Cloud-VM bestanden; Hook wieder deaktiviert, WSS operativ
wiederhergestellt, keine neuen Jobs. Danach eigener Configureplan tatsächlich
einmal ausgeführt, APT0/dpkg installed1.0, aber Abnahme wegen globalem
Neustartmarker verweigert: Grant33775478-15b0-46ec-b059-44f500dbb0b6 unknown,
Rootverbrauch11. Fehlender Host-Vorherwert bleibt fehlend; keine rückwirkende
Acceptance. Rootpolicy deny-only geschlossen, kein Retry/Markerreset/Reboot.
Gebundener Readonly-Abgleich wird implementiert. Spec1.13 präzisiert getrennte
Host-/Sandboxbeobachtung und konservative zentrale Rebootfrist. Tatsächlicher
MCP-Lesebericht eines bestehenden Dienstplans bestanden, Idempotenz noch nicht
angehängt. Offline/Crash/APT1.1/Noops/finaler Reboot und Endaudit weiter offen.
Ältere Zustände unten bleiben historische Snapshots.
**Neuester aktiver Stand2026-11-13:** Scope-Replayfix und TLS-Lifecycle einschließlich
nativ abgelaufener Clientcerts bestanden. UI-Schema4 geprüft/publiziert;
Configure-only-Plan tatsächlich genehmigt, aber ohneOffer/Grant expired an
+7 -2
View File
@@ -121,8 +121,13 @@ gespeicherte MCP-Lesewerkzeuge, paginierte berechtigte Geräteliste, ausdrückli
festes Cloudziel, ursprüngliche verifizierte Checkpoints und deren aktuelle
Operationsaggregate. `--checkpoint` nimmt vorhandene Hello-/Inventur-/Dienst-
und später Rebootbelege an; `--output` verlangt eine neue private Datei unter
`devstate/`. Tatsächlich bisher nur Python-Syntaxprüfung und `--help`, **kein
MCP-Lauf**. Die optionale Idempotenzreceipt muss einen gesondert tatsächlich
`devstate/`. Nach Syntax-/Helpprüfung inzwischen tatsächlich rein lesend gegen
den endgültigen Server ausgeführt: gespeicherter Rootdienst-stop-Checkpoint,
berechtigte paginierte Geräteliste, exakt ein ausgewähltes Linuxziel und dessen
ursprüngliche Operation samt korrekter Aggregation bestanden. Privater Beleg
`devstate/cloud-mcp-reference-before-final.json`; Idempotenz bewusst
`not_attached`. Finaler Bericht mit späteren Offline-/Rebootbelegen bleibt offen.
Die optionale Idempotenzreceipt muss einen gesondert tatsächlich
beobachteten Submit desselben `offline_wait`-Plans mit exakt ursprünglichem
Nonce innerhalb der ursprünglichen Frist, dieselbe Operation und unveränderte
1Job/1Outbox/1Grant belegen. Der Report führt selbst keinen Submit aus; ohne
+17 -1
View File
@@ -1,6 +1,22 @@
# Verbindliche Projektentscheidungen
Stand: **2026-11-13**, Spezifikation **1.12** (`Rust_RMM_Implementierungsspezifikation.md`). Die ausdrücklichen normativen Entscheidungen in Kapitel 0 haben Vorrang vor früheren Architekturannahmen. Version 1.6 ersetzt die lokale Servertopologie durch den dedizierten Internetserver; Version 1.7 präzisiert das Notebook als reinen Entwicklungsrechner; Version 1.8 erlaubt vorgezogene parallele Windows-Entwicklung.
Stand: **2026-11-13**, Spezifikation **1.13** (`Rust_RMM_Implementierungsspezifikation.md`). Die ausdrücklichen normativen Entscheidungen in Kapitel 0 haben Vorrang vor früheren Architekturannahmen. Version 1.6 ersetzt die lokale Servertopologie durch den dedizierten Internetserver; Version 1.7 präzisiert das Notebook als reinen Entwicklungsrechner; Version 1.8 erlaubt vorgezogene parallele Windows-Entwicklung.
## Gebundene Paket- und Rebootnachbedingungen (Version1.13)
`no_reboot` verbietet einen ungeplanten Neustart, kein wahrheitsgemäßes
`reboot_required=true` bei vollständig verifiziertem Paket. Die harmlosen
APT-Fixturen müssen das Hostflag vor/nach der Wirkung unverändert nachweisen;
Sandbox-/Hostbeobachtung sind getrennt. Alte fehlende Vorhermessungen bleiben
fehlend, keine rückwirkende erfolgreiche Acceptance oder Markerbereinigung.
Die zentrale Rebootfrist beginnt konservativ an der dauerhaften
Startreservierung. Erfolg benötigt unabhängig empfangenes neues Bootinventar
innerhalb dieser Frist; Unknown bleibt bei fehlendem/verspätetem Nachweis.
Späterer signierter Sync verwendet ausschließlich den ursprünglichen
rechtzeitigen Erfolgsbeleg. Quelle: Spezifikation0 und
[Rebootvertrag samt tatsächlichen lokalen Prüfungen](reboot-acceptance.md).
Diese Präzisierung ist keine native Paket-/Rebootabnahme.
## Einzelner signierter APT-Wiederaufnahmeversuch (2026-11-13)
+118
View File
@@ -0,0 +1,118 @@
# Letzte Linux-Cloud-VM-Rebootabnahme
**Vorbereitet, noch kein nativer Reboot ausgeführt.** Dieser Schritt darf erst
nach den APT-, Offline-, Crash-/Redelivery-, Transportfallback- und MCP-Gates
folgen. Die frühere Autorisierung des einzelnen Test-VM-Reboots ersetzt keine
Genehmigung des neuen festen Jobs in der tatsächlichen WebUI.
## Verbindliche Bedeutung der Wiederverbindungsfrist
Der feste Reboot-Plan nennt `reconnect_timeout_seconds`. Seine zentrale Frist
beginnt bei `execution_permits.created_at`, der dauerhaft gespeicherten
serverseitigen Startreservierung des **gleichen Jobs, Versuchs und Grants**.
Dieser Zeitpunkt liegt vor dem tatsächlichen Helperstart. Die Verwendung ist
bewusst konservativ: Ein späterer lokaler Start oder lokal gespeicherter
`reconnect_deadline` verlängert die zentrale Frist nicht. Gerätezeitstempel,
neue Verbindungsversuche und neue Inventare verlängern sie ebenfalls nicht.
Erstmaliger Erfolg braucht einen tatsächlich gespeicherten Inventarbeleg
derselben Identität und des aktuellen neuen Boot-IDs. Dessen serverseitige
Empfangszeit muss **nach** der Startreservierung und **spätestens zur Frist**
liegen. Der Beleg muss bei erstmaliger Abnahme außerdem jünger als fünf Minuten
sein; die alte Boot-ID muss aus dem zum gleichen Grant gehörenden
`start_reserved`-Audit stammen und vom neuen Boot abweichen. Fehlende oder zu
späte Belege bleiben `unknown`; daraus entsteht weder ein geratenes `failed`
noch eine Wiederholungserlaubnis.
Ein bereits autoritativ bestätigter Erfolg behält seinen **ursprünglichen
konkreten Inventarbeleg**. Späterer RootSync darf dessen rechtzeitige, dauerhaft
gespeicherte Empfangszeit erneut prüfen, auch wenn die aktuelle Uhrzeit inzwischen
hinter der Frist liegt. Ein jüngeres, verspätetes Inventar darf diesen Beleg nicht
ersetzen. Neue Boot-ID und tatsächliche aktuelle Identität müssen weiter passen.
Exakte Nachrichtenwiederholung verwendet die bestehende Quittung.
Auch ein eingehendes Reboot-Erfolgsergebnis muss denselben unabhängigen
Grant-/Boot-/Inventar-/Fristnachweis besitzen. Vom Client gelieferte Zeitangaben
oder eine behauptete Inventar-ID reichen nicht. Die Ergebnisfelder
`reboot_reserved_at`, `reconnect_deadline` und `inventory_received_at` müssen zu
den tatsächlichen Datenbankzeitpunkten passen. Der unveränderte Helper prüft
weiter den signierten Abgleich und den tatsächlich neuen lokalen Boot-ID.
## Tatsächlich ausgeführte lokale Prüfung
Die gezielte Serverprüfung verwendete einen eigenen PostgreSQL-Container ohne
Netzwerkfreigabe, Migrationen 1–13 und die nicht privilegierte Anwendungsrolle
mit RLS. **Drei Tests bestanden**, keine ausgelassen:
- Frist ausschließlich aus gültigem festem Plan und vorhandener Reservierung;
fehlende Reservierung, ungültiger Timeout und Zeitüberlauf werden verweigert.
- Tatsächliche SQL-Auswahl: Grenze einschließlich akzeptiert, eine Mikrosekunde
zu spät verweigert; falscher Mandant/Agent/Boot, Belege vor Reservierung,
Zukunft und veraltete Erstabnahme verweigert. Der ursprüngliche rechtzeitige
Erfolgsbeleg bleibt später wiederverwendbar.
- Tatsächlicher Ergebnis-Ingress mit ausschließlich synthetischen isolierten
Datenbankzeilen: verspätete behauptete Erfolgsnachricht und erfundene Frist
zurückgewiesen, Job bleibt `unknown`, keine Quittung. Rechtzeitiger unabhängiger
Beleg akzeptiert; exakte Wiederholung erzeugt keine zweite Quittung.
Dies ist ein lokaler Server-/Datenbanknachweis und **keine native Rebootabnahme**.
Helper-/Providerartefakte, VM-/Serverlaufzeit und Systemuhren wurden für diese
Prüfung nicht verändert. Die einmalige echte positive Rebootabnahme folgt erst
nach den vorherigen MVP-Gates und ihrer eigenen WebUI-Genehmigung.
## Vorbereiteter Cloud-Runner, noch nicht ausgeführt
`deploy/cloud_reboot_acceptance.py` und
`deploy/browser/cloud_reboot_acceptance.cjs` bilden ausschließlich den letzten
einzelnen Reboot ab. Vorher müssen APT-Abnahme und beide 1.1-Noops, die drei
aktiven Offlinefälle, Crash-/Redelivery, tatsächlicher Transportfallback und
MCP-Isolation nativ bestanden sein. Ein geschütztes Manifest enthält
`schema_version:1`, den festen `target` und `checks` für `apt_native_update`,
`ensure_package`, `apply_updates`, `offline_wait`, `expired_offline`,
`revoked_before_start`, `agent_crash`, `transport_fallback`, `mcp`. Jeder Eintrag
bindet einen geschützten tatsächlich verifizierten Ergebnisbericht über `path`
und `sha256`. Fixture 1.1 wird aus den früher genehmigten gespeicherten
APT-Ergebnissen geprüft; keine neue SSH-Paketabfrage wird als Nachweis ausgegeben.
Vor der Vorbereitung müssen die dauerhaften Agent-/General-Helperdienste bereits
aktiv und dauerhaft `enabled` sein. Der Runner aktiviert keinen Autostart
stillschweigend. Der APT-Endpunkt muss nach dessen Abnahme wieder entfernt und
sein Dienst gestoppt sein. Die vorhandene General-Unit bleibt unverändert:
`systemctl reboot` verwendet den vorhandenen D-Bus-Provider, direkte
Reboot-Syscalls bleiben gesperrt. Diese Quellcodeprüfung ist noch kein nativer
Rebootnachweis.
Bootstrap ändert lediglich `allow_reboot` von false auf true und den zugehörigen
gemessenen General-Pin, unter gestoppten Diensten und Executor-Lock. Originale
werden versioniert; Identitäten, Journale, DB-Inodes, alte Grants und APT-Historie
bleiben vor Neustart bytegleich. Zentral gilt nur eine maximal 30 Minuten gültige
Scope für Reboot; Skripte, Dienste, APT und zusätzliche Logrechte sind verboten.
Bootstrap selbst ruft keinen Reboot auf.
**Geplant, nicht ausgeführt:**
```sh
python3 deploy/cloud_reboot_acceptance.py enable --prerequisites devstate/cloud-reboot/prerequisites.json
python3 deploy/cloud_reboot_acceptance.py accept --id <Lauf-ID>
python3 deploy/cloud_reboot_acceptance.py close --id <dieselbe-Lauf-ID>
```
`accept` erstellt und beantragt genau einen festen Root-Job über die tatsächliche
WebUI, beweist `pending_approval` mit **0/0/0** und öffnet erst danach eine eigene
WebUI-Genehmigungssitzung. Der Job nennt den ausdrücklichen Grund, Gruppe
`single-test-vm`, Parallelität 1, Laufzeit 240 s und Wiederverbindungsfrist 180 s
ab zentraler Startreservierung. Alte Boot-ID und unveränderlicher Plan werden
vor Genehmigung gespeichert. Kein SSH-Reboot oder direkter Freigabeaufruf existiert.
Erst tatsächliche ausgehende Wiederanmeldung, neuer Boot-ID, rechtzeitig
gespeichertes Inventar, angewandter signierter RootSync und terminaler Erfolg
bestätigen den gleichen Grant. Alte Ledgerzeilen und DB-Inodes müssen erhalten
sein; genau ein neuer Rootverbrauch sowie **1 Job / 1 Outbox / 1 Grant** sind
erforderlich. Unterbrochenes Warten darf ausschließlich `finish --id` für diesen
gleichen Versuch fortsetzen. Unknown oder Timeout erlauben keinen zweiten Reboot.
Nach normal bestätigter Rückkehr schließt `close` zuerst die zentrale Scope und
stellt dann die ursprünglichen Config-/Pinbytes mit `allow_reboot:false` wieder
her. Diese operative Rücknahme startet Agent und General-Helper neu, führt aber
keinen zweiten Reboot aus. Tatsächliche Durchführung bleibt bis zur Freigabe des
abschließenden Schritts ausdrücklich offen.