Reconcile a human closure when the helper has no result
Rust development slice / linux (push) Failing after 9s
Rust development slice / linux (push) Failing after 9s
This commit is contained in:
@@ -26,7 +26,7 @@ Kunden lassen sich in der WebUI anlegen und umbenennen. Beim Kundenwechsel erhä
|
||||
|
||||
Linux führt Shellskripte unter dem Dienstkonto oder über den eingerichteten Helper als root aus. Windows führt PowerShell unter LocalService oder über den Helper als SYSTEM aus. Neustart und Installation von Windows-Updates sind Skriptaufträge. Bei einem Neustart kann das Skript bereits vor dem Herunterfahren erfolgreich enden. Der Betriebsnachweis verbindet den neuen Bootbezug mit dem nächsten authentisierten Kontakt und einem Folgeauftrag. [Skriptbibliothek](crates/server/src/script_library.rs) · [Auftragsverarbeitung](crates/server/src/jobs.rs)
|
||||
|
||||
Ein Abbruchwunsch wird am Auftrag gespeichert. Bei unterbrochener Rückmeldung gleichen Server, Agent und gegebenenfalls Helper den gespeicherten Versuch ab. Bei `unknown` bleibt die Wirkung ungeklärt. Die WebUI kann einen solchen Fall dokumentiert abschließen. Dieser Abschluss erteilt keine Freigabe für einen weiteren Versuch.
|
||||
Ein Abbruchwunsch wird am Auftrag gespeichert. Bei unterbrochener Rückmeldung gleichen Server, Agent und gegebenenfalls Helper den gespeicherten Versuch ab. Bei `unknown` bleibt die Wirkung ungeklärt. Die WebUI kann einen solchen Fall dokumentiert abschließen. Agent und Helper übernehmen den Abschluss im signierten Abgleich auch dann, wenn der Agent den Abbruch seiner eigenen Ausführung protokolliert hat und im unabhängig gebundenen Verbrauchsjournal des Helpers ein Ergebnis fehlt. Beide bewahren die ursprünglichen Belege. Der Abschluss erteilt keine Freigabe für einen weiteren Versuch.
|
||||
|
||||
## Öffentliche Verwaltung und Berechtigungen
|
||||
|
||||
|
||||
@@ -782,10 +782,10 @@ impl<V: Ed25519Verifier> HelperSync<V> {
|
||||
let d = decisions
|
||||
.get(&id)
|
||||
.context("ROOT_ATTEMPT_OMITTED_FROM_DECISION")?;
|
||||
validate_summary(row, local)?;
|
||||
validate_decision(row, local, d)?;
|
||||
let unreported = validate_summary(row, local)?;
|
||||
validate_decision(row, local, d, unreported)?;
|
||||
if d.unlock {
|
||||
let bytes = unlock_outcome(row, d, current_boot)?;
|
||||
let bytes = unlock_outcome(row, d, current_boot, unreported.then_some(local))?;
|
||||
if d.outcome_state == "closed_unknown" {
|
||||
crate::ledger::retain_closure_original(
|
||||
&tx,
|
||||
@@ -1636,22 +1636,33 @@ fn definitive(row: &LocalAttempt) -> bool {
|
||||
"succeeded" | "failed" | "cancelled" | "expired" | "closed_unknown"
|
||||
) && !row.outcome_bytes.is_empty()
|
||||
}
|
||||
fn validate_summary(row: &LocalAttempt, a: &AttemptView) -> Result<()> {
|
||||
fn validate_summary(row: &LocalAttempt, a: &AttemptView) -> Result<bool> {
|
||||
let unreported = row.state == "unknown"
|
||||
&& row.outcome_sha256.is_empty()
|
||||
&& row.outcome_bytes.is_empty()
|
||||
&& row.update_handoff_bytes.is_empty()
|
||||
&& crate::reconcile::uncertain_agent_outcome(&a.state, &a.outcome_bytes, &a.outcome_sha256);
|
||||
ensure!(
|
||||
a.job_payload_hash == row.job_payload_hash
|
||||
&& a.grant_id == row.grant_id.to_string()
|
||||
&& a.consumption == "consumed"
|
||||
&& a.state == row.state
|
||||
&& a.revision >= row.revision
|
||||
&& a.original_boot_id == row.original_boot_id.to_string()
|
||||
&& a.outcome_sha256 == row.outcome_sha256
|
||||
&& a.update_handoff_bytes == row.update_handoff_bytes
|
||||
&& (a.outcome_bytes.is_empty() || a.outcome_bytes == row.outcome_bytes),
|
||||
&& (unreported
|
||||
|| (a.state == row.state
|
||||
&& a.outcome_sha256 == row.outcome_sha256
|
||||
&& (a.outcome_bytes.is_empty() || a.outcome_bytes == row.outcome_bytes))),
|
||||
"ROOT_SNAPSHOT_REQUEST_MISMATCH"
|
||||
);
|
||||
Ok(())
|
||||
Ok(unreported)
|
||||
}
|
||||
fn validate_decision(row: &LocalAttempt, a: &AttemptView, d: &AttemptDecision) -> Result<()> {
|
||||
fn validate_decision(
|
||||
row: &LocalAttempt,
|
||||
a: &AttemptView,
|
||||
d: &AttemptDecision,
|
||||
unreported: bool,
|
||||
) -> Result<()> {
|
||||
if !row.update_handoff_bytes.is_empty() {
|
||||
let proof =
|
||||
rmm_domain::agent_update::UpdateInflightProof::from_bytes(&row.update_handoff_bytes)
|
||||
@@ -1686,7 +1697,7 @@ fn validate_decision(row: &LocalAttempt, a: &AttemptView, d: &AttemptDecision) -
|
||||
&& d.original_boot_id == Some(row.original_boot_id)
|
||||
&& (d.revision >= a.revision || (!d.unlock && d.outcome_state == "unknown"))
|
||||
&& d.previous_outcome_sha256.as_deref()
|
||||
== (!row.outcome_sha256.is_empty()).then_some(row.outcome_sha256.as_str()),
|
||||
== (!a.outcome_sha256.is_empty()).then_some(a.outcome_sha256.as_str()),
|
||||
"ROOT_SIGNED_ATTEMPT_BINDING"
|
||||
);
|
||||
ensure!(
|
||||
@@ -1697,11 +1708,26 @@ fn validate_decision(row: &LocalAttempt, a: &AttemptView, d: &AttemptDecision) -
|
||||
),
|
||||
"UNKNOWN_CANNOT_UNLOCK"
|
||||
);
|
||||
ensure!(
|
||||
!unreported
|
||||
|| (!d.unlock && d.outcome_state == "unknown")
|
||||
|| (d.unlock
|
||||
&& d.outcome_state == "closed_unknown"
|
||||
&& d.reason == "OPERATOR_CLOSED_UNKNOWN"),
|
||||
"ROOT_UNREPORTED_OUTCOME_CLOSURE_REQUIRED"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
fn unlock_outcome(row: &LocalAttempt, d: &AttemptDecision, current_boot: Uuid) -> Result<Vec<u8>> {
|
||||
fn unlock_outcome(
|
||||
row: &LocalAttempt,
|
||||
d: &AttemptDecision,
|
||||
current_boot: Uuid,
|
||||
unreported: Option<&AttemptView>,
|
||||
) -> Result<Vec<u8>> {
|
||||
let bytes = if d.outcome_bytes.is_empty() {
|
||||
row.outcome_bytes.clone()
|
||||
unreported
|
||||
.map_or(&row.outcome_bytes, |a| &a.outcome_bytes)
|
||||
.clone()
|
||||
} else {
|
||||
d.outcome_bytes.clone()
|
||||
};
|
||||
@@ -1712,9 +1738,7 @@ fn unlock_outcome(row: &LocalAttempt, d: &AttemptDecision, current_boot: Uuid) -
|
||||
&& o.state == d.outcome_state,
|
||||
"ROOT_CANONICAL_UNLOCK_OUTCOME"
|
||||
);
|
||||
if bytes != row.outcome_bytes
|
||||
&& crate::reconcile::operator_closure(&d.reason, &row.state, &o)
|
||||
{
|
||||
if bytes != row.outcome_bytes && crate::reconcile::operator_closure(&d.reason, &row.state, &o) {
|
||||
return Ok(bytes);
|
||||
}
|
||||
if bytes != row.outcome_bytes {
|
||||
|
||||
@@ -1019,9 +1019,9 @@ impl<V: Ed25519Verifier> ClientSync<V> {
|
||||
} else {
|
||||
for d in decision.attempts.iter().filter(|d| d.unlock) {
|
||||
let grant = d.grant_id.context("UNLOCK_GRANT_MISSING")?;
|
||||
let (agent,generation,job,attempt,previous):(String,u64,String,String,Option<Vec<u8>>)=tx.query_row(
|
||||
"SELECT agent,generation,job,attempt,COALESCE((SELECT outcome FROM execution_evidence WHERE execution_evidence.grant_id=consumed.grant_id),result) FROM consumed WHERE grant_id=?1",
|
||||
[grant.to_string()],|r|Ok((r.get(0)?,r.get(1)?,r.get(2)?,r.get(3)?,r.get(4)?)))?;
|
||||
let (agent,generation,job,attempt,previous,start):(String,u64,String,String,Option<Vec<u8>>,Option<Vec<u8>>)=tx.query_row(
|
||||
"SELECT c.agent,c.generation,c.job,c.attempt,COALESCE(e.outcome,c.result),e.start FROM consumed c LEFT JOIN execution_evidence e USING(grant_id) WHERE c.grant_id=?1",
|
||||
[grant.to_string()],|r|Ok((r.get(0)?,r.get(1)?,r.get(2)?,r.get(3)?,r.get(4)?,r.get(5)?)))?;
|
||||
ensure!(
|
||||
agent == self.binding.agent_id.to_string()
|
||||
&& generation == self.binding.enrollment_generation
|
||||
@@ -1034,13 +1034,61 @@ impl<V: Ed25519Verifier> ClientSync<V> {
|
||||
Some(&self.binding),
|
||||
grant,
|
||||
)?;
|
||||
let previous = resolved
|
||||
.or(previous)
|
||||
.context("LOCAL_UNLOCK_PREVIOUS_OUTCOME_MISSING")?;
|
||||
let original = previous.clone();
|
||||
let prior = canonical_outcome_bytes(&serde_json::from_slice::<ReconciledOutcome>(
|
||||
&previous,
|
||||
)?)?;
|
||||
let previous = resolved.or(previous);
|
||||
let summary = gate
|
||||
.request
|
||||
.attempts
|
||||
.iter()
|
||||
.find(|a| a.job_id == job && a.attempt_id == attempt)
|
||||
.context("LOCAL_UNLOCK_ATTEMPT_MISSING")?;
|
||||
let closure = d.reason == "OPERATOR_CLOSED_UNKNOWN"
|
||||
&& d.outcome_state == "closed_unknown"
|
||||
&& summary.consumption == "consumed"
|
||||
&& uncertain_agent_outcome(
|
||||
&summary.state,
|
||||
&summary.outcome_bytes,
|
||||
&summary.outcome_sha256,
|
||||
);
|
||||
let prior = match &previous {
|
||||
Some(bytes) => {
|
||||
let canonical = canonical_outcome_bytes(&serde_json::from_slice(bytes)?)?;
|
||||
if closure
|
||||
&& summary.state == "closed_unknown"
|
||||
&& uncertain_agent_outcome("unknown", &canonical, &hash(&canonical))
|
||||
{
|
||||
summary.outcome_bytes.clone()
|
||||
} else {
|
||||
canonical
|
||||
}
|
||||
}
|
||||
None => {
|
||||
ensure!(closure, "LOCAL_UNLOCK_PREVIOUS_OUTCOME_MISSING");
|
||||
let start: serde_json::Value = serde_json::from_slice(
|
||||
&start.context("LOCAL_UNLOCK_ORIGINAL_START_MISSING")?,
|
||||
)?;
|
||||
let request: crate::auth::Request =
|
||||
serde_json::from_value(start["request"].clone())?;
|
||||
let permit: rmm_domain::jobs::ExecutionPermitPayload =
|
||||
serde_json::from_slice(&request.permit_bytes)?;
|
||||
let (original, permit) = self.binding.verify_with(
|
||||
&request,
|
||||
permit.not_before,
|
||||
&self.verifier,
|
||||
)?;
|
||||
ensure!(
|
||||
permit.grant_id == grant
|
||||
&& original.job_id == d.job_id
|
||||
&& original.attempt_id == d.attempt_id
|
||||
&& hash(&request.job_bytes) == d.job_payload_hash
|
||||
&& Some(permit.authorization_id) == d.authorization_id
|
||||
&& Some(permit.plan_hash.as_str()) == d.plan_hash.as_deref()
|
||||
&& start["previous_boot_id"].as_str()
|
||||
== d.original_boot_id.map(|id| id.to_string()).as_deref(),
|
||||
"LOCAL_UNLOCK_ORIGINAL_START_BINDING"
|
||||
);
|
||||
summary.outcome_bytes.clone()
|
||||
}
|
||||
};
|
||||
ensure!(
|
||||
d.previous_outcome_sha256.as_deref() == Some(hash(&prior).as_str()),
|
||||
"LOCAL_UNLOCK_PREVIOUS_OUTCOME_MISMATCH"
|
||||
@@ -1055,7 +1103,8 @@ impl<V: Ed25519Verifier> ClientSync<V> {
|
||||
terminal(&outcome.state)
|
||||
&& outcome.state == d.outcome_state
|
||||
&& canonical_outcome_bytes(&outcome)? == bytes
|
||||
&& d.outcome_sha256.as_deref() == Some(hash(&bytes).as_str()),
|
||||
&& d.outcome_sha256.as_deref() == Some(hash(&bytes).as_str())
|
||||
&& (previous.is_some() || operator_closure(&d.reason, "unknown", &outcome)),
|
||||
"LOCAL_UNLOCK_CANONICAL_OUTCOME"
|
||||
);
|
||||
let preserve = crate::windows_system_nonstart::preserve_original_unlock(
|
||||
@@ -1065,7 +1114,12 @@ impl<V: Ed25519Verifier> ClientSync<V> {
|
||||
&bytes,
|
||||
)?;
|
||||
if outcome.state == "closed_unknown" {
|
||||
crate::ledger::retain_closure_original(&tx, grant, &original, &bytes)?;
|
||||
crate::ledger::retain_closure_original(
|
||||
&tx,
|
||||
grant,
|
||||
previous.as_deref().unwrap_or_default(),
|
||||
&bytes,
|
||||
)?;
|
||||
}
|
||||
tx.execute(
|
||||
"UPDATE consumed SET result=?2 WHERE grant_id=?1",
|
||||
@@ -1304,6 +1358,32 @@ pub(crate) fn operator_closure(
|
||||
&& outcome.evidence["closed_by_human"] == true
|
||||
&& outcome.evidence["retry"] == false
|
||||
}
|
||||
|
||||
/// An interrupted agent can record its own uncertainty while the independently
|
||||
/// consumed helper grant has no result. Neither witness establishes an effect.
|
||||
pub(crate) fn uncertain_agent_outcome(state: &str, bytes: &[u8], digest: &str) -> bool {
|
||||
if bytes.is_empty() || hash(bytes) != digest {
|
||||
return false;
|
||||
}
|
||||
let Ok(outcome) = serde_json::from_slice::<ReconciledOutcome>(bytes) else {
|
||||
return false;
|
||||
};
|
||||
canonical_outcome_bytes(&outcome).is_ok_and(|canonical| canonical == bytes)
|
||||
&& outcome.state == state
|
||||
&& !outcome.output_truncated
|
||||
&& !outcome.reboot_required
|
||||
&& (operator_closure("OPERATOR_CLOSED_UNKNOWN", "unknown", &outcome)
|
||||
|| (state == "unknown"
|
||||
&& matches!(
|
||||
outcome.error_code.as_str(),
|
||||
"AGENT_PROCESS_INTERRUPTED" | "HELPER_TRANSPORT_EFFECT_UNKNOWN"
|
||||
)
|
||||
&& outcome.exit_code.is_none()
|
||||
&& outcome.stdout.is_empty()
|
||||
&& outcome.stderr.is_empty()
|
||||
&& outcome.evidence["postconditions_passed"] == false))
|
||||
}
|
||||
|
||||
fn optional_uuid(s: &str) -> Result<Option<Uuid>> {
|
||||
if s.is_empty() {
|
||||
Ok(None)
|
||||
@@ -1452,6 +1532,24 @@ fn attempts(db: &Connection, ledger: &Connection, binding: &Binding) -> Result<V
|
||||
result_envelope = Some(envelope);
|
||||
}
|
||||
}
|
||||
// The signed closure projection can commit before either consumption
|
||||
// ledger. A fresh signed check may then finish the remaining writes.
|
||||
if state == "closed_unknown"
|
||||
&& consumption == "consumed"
|
||||
&& (canonical.is_empty()
|
||||
|| uncertain_agent_outcome("unknown", &canonical, &hash(&canonical)))
|
||||
{
|
||||
let closed: Vec<u8> = db.query_row(
|
||||
"SELECT outcome FROM reconcile_outcomes WHERE job=?1 AND attempt=?2",
|
||||
params![offer.job_id, offer.attempt_id],
|
||||
|r| r.get(0),
|
||||
)?;
|
||||
ensure!(
|
||||
uncertain_agent_outcome(&state, &closed, &hash(&closed)),
|
||||
"LOCAL_CLOSURE_OUTCOME_MISMATCH"
|
||||
);
|
||||
canonical = closed;
|
||||
}
|
||||
if !canonical.is_empty() {
|
||||
let o: ReconciledOutcome = serde_json::from_slice(&canonical)?;
|
||||
ensure!(o.state == state, "LOCAL_OUTCOME_STATE_MISMATCH");
|
||||
@@ -1746,6 +1844,15 @@ fn merge_helper(local: &mut [SyncAttempt], helper: &HelperSnapshot) -> Result<()
|
||||
"HELPER_ATTEMPT_BINDING"
|
||||
);
|
||||
if h.consumption != "unconsumed" {
|
||||
let unreported = h.state == "unknown"
|
||||
&& h.consumption == "consumed"
|
||||
&& h.outcome_bytes.is_empty()
|
||||
&& h.outcome_sha256.is_empty()
|
||||
&& h.update_handoff_bytes.is_empty()
|
||||
&& a.consumption == "consumed"
|
||||
&& a.grant_id == h.grant_id
|
||||
&& a.original_boot_id == h.original_boot_id
|
||||
&& uncertain_agent_outcome(&a.state, &a.outcome_bytes, &a.outcome_sha256);
|
||||
if !h.update_handoff_bytes.is_empty() {
|
||||
ensure!(
|
||||
h.state == "running" && a.state == "running" && a.outcome_bytes.is_empty(),
|
||||
@@ -1756,7 +1863,7 @@ fn merge_helper(local: &mut [SyncAttempt], helper: &HelperSnapshot) -> Result<()
|
||||
a.grant_id = h.grant_id.clone();
|
||||
a.consumption = h.consumption.clone();
|
||||
ensure!(
|
||||
a.outcome_sha256 == h.outcome_sha256,
|
||||
a.outcome_sha256 == h.outcome_sha256 || unreported,
|
||||
"HELPER_OUTCOME_MISMATCH"
|
||||
);
|
||||
if a.original_boot_id.is_empty() {
|
||||
|
||||
@@ -1485,6 +1485,207 @@ fn persist_original_fixture_result(
|
||||
fn completion_outcome() -> rmm_agent_core::auth::Outcome {
|
||||
serde_json::from_slice(&canonical_outcome_bytes(&success()).unwrap()).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn human_closure_reconciles_agent_interruption_and_a_helper_without_result() {
|
||||
use rmm_agent_core::helper_reconcile::{self, BootSource, ExecutorLedgerGuard, HelperSync};
|
||||
|
||||
struct TestGuard;
|
||||
impl ExecutorLedgerGuard for TestGuard {
|
||||
fn check(&self, db: &Connection) -> anyhow::Result<()> {
|
||||
anyhow::ensure!(
|
||||
db.is_autocommit(),
|
||||
"fixture ledger must be outside a transaction"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
struct TestBoot(Uuid);
|
||||
impl BootSource for TestBoot {
|
||||
fn current_boot(&self) -> anyhow::Result<Uuid> {
|
||||
Ok(self.0)
|
||||
}
|
||||
}
|
||||
fn map(snapshot: &helper_reconcile::Snapshot) -> HelperSnapshot {
|
||||
HelperSnapshot {
|
||||
journal_id: snapshot.journal_id,
|
||||
checkpoint: snapshot.checkpoint,
|
||||
previous_decision_id: snapshot.previous_decision_id,
|
||||
attempts: snapshot
|
||||
.attempts
|
||||
.iter()
|
||||
.map(|a| SyncAttempt {
|
||||
job_id: a.job_id.to_string(),
|
||||
attempt_id: a.attempt_id.to_string(),
|
||||
job_payload_hash: a.job_payload_hash.clone(),
|
||||
grant_id: a.grant_id.to_string(),
|
||||
consumption: a.consumption.clone(),
|
||||
state: a.state.clone(),
|
||||
revision: a.revision,
|
||||
original_boot_id: a.original_boot_id.to_string(),
|
||||
outcome_sha256: a.outcome_sha256.clone(),
|
||||
outcome_bytes: a.outcome_bytes.clone(),
|
||||
..Default::default()
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
let closed = canonical_outcome_bytes(&ReconciledOutcome {
|
||||
state: "closed_unknown".into(),
|
||||
stdout: vec![],
|
||||
stderr: vec![],
|
||||
exit_code: None,
|
||||
output_truncated: false,
|
||||
reboot_required: false,
|
||||
evidence: serde_json::json!({
|
||||
"postconditions_passed":false,"effect":"unknown","closed_by_human":true,"retry":false
|
||||
}),
|
||||
error_code: "OPERATOR_CLOSED_UNKNOWN".into(),
|
||||
})
|
||||
.unwrap();
|
||||
for interrupt_after_projection in [false, true] {
|
||||
let mut f = Fixture::new();
|
||||
reconcile::initialize(&f.db).unwrap();
|
||||
let (offer, grant, _) = f.add(
|
||||
"running",
|
||||
true,
|
||||
None,
|
||||
Action::SetServiceState {
|
||||
unit: "rmm-acceptance.service".into(),
|
||||
state: "running".into(),
|
||||
},
|
||||
);
|
||||
let grant = grant.unwrap();
|
||||
let archive = persist_original_fixture_result(
|
||||
&mut f,
|
||||
&offer,
|
||||
&grant,
|
||||
rmm_agent_core::auth::Outcome::unknown("AGENT_PROCESS_INTERRUPTED"),
|
||||
);
|
||||
rmm_agent_core::jobs::ack(&mut f.db, &archive.message_id).unwrap();
|
||||
let start: Vec<u8> = f
|
||||
.ledger
|
||||
.query_row("SELECT start FROM execution_evidence", [], |row| row.get(0))
|
||||
.unwrap();
|
||||
let start: serde_json::Value = serde_json::from_slice(&start).unwrap();
|
||||
let request: Request = serde_json::from_value(start["request"].clone()).unwrap();
|
||||
let boot = TestBoot(f.channel.boot_id);
|
||||
let guard = TestGuard;
|
||||
let mut helper_db = Connection::open_in_memory().unwrap();
|
||||
rmm_agent_core::ledger::initialize_ledger(&helper_db).unwrap();
|
||||
rmm_agent_core::ledger::begin_execution(
|
||||
&mut helper_db,
|
||||
&grant,
|
||||
&request,
|
||||
boot.0,
|
||||
f.clock.now,
|
||||
)
|
||||
.unwrap();
|
||||
let mut helper = HelperSync::new(f.binding.clone(), &f.clock).unwrap();
|
||||
let mut client = f.client();
|
||||
|
||||
for round in 0..if interrupt_after_projection { 3 } else { 2 } {
|
||||
let snapshot = map(&helper
|
||||
.snapshot(
|
||||
&mut helper_db,
|
||||
&guard,
|
||||
f.channel.connection_generation,
|
||||
&f.clock,
|
||||
&boot,
|
||||
)
|
||||
.unwrap());
|
||||
assert_eq!(snapshot.attempts[0].state, "unknown");
|
||||
assert!(snapshot.attempts[0].outcome_bytes.is_empty());
|
||||
let prepared = client
|
||||
.prepare(
|
||||
&mut f.db,
|
||||
&f.ledger,
|
||||
f.channel.clone(),
|
||||
Some(&snapshot),
|
||||
&f.clock,
|
||||
)
|
||||
.unwrap();
|
||||
let agent_attempt = &prepared.request.attempts[0];
|
||||
assert!(!agent_attempt.outcome_bytes.is_empty());
|
||||
let mut d = f.decision(&prepared, round != 0);
|
||||
d.issued_at = f.clock.now;
|
||||
if round != 0 {
|
||||
let attempt = &mut d.attempts[0];
|
||||
attempt.revision = 3;
|
||||
attempt.outcome_state = "closed_unknown".into();
|
||||
attempt.reason = "OPERATOR_CLOSED_UNKNOWN".into();
|
||||
attempt.unlock = true;
|
||||
attempt.outcome_sha256 = Some(hash(&closed));
|
||||
if agent_attempt.state == "unknown" {
|
||||
attempt.outcome_bytes = closed.clone();
|
||||
}
|
||||
}
|
||||
let signed = f.sign(&d);
|
||||
client.apply(&mut f.db, &signed, &f.clock).unwrap();
|
||||
if interrupt_after_projection && round == 1 {
|
||||
client = f.client();
|
||||
continue;
|
||||
}
|
||||
client.apply_consumption(&mut f.ledger, &f.clock).unwrap();
|
||||
let raw = prepared.request.encode_to_vec();
|
||||
let response = helper_reconcile::SignedResponse {
|
||||
decision_bytes: signed.decision_bytes,
|
||||
signature: signed.signature,
|
||||
};
|
||||
let applied = helper
|
||||
.apply(&mut helper_db, &guard, &response, &raw, &f.clock, &boot)
|
||||
.unwrap();
|
||||
if round == 0 {
|
||||
assert!(!applied.ready && applied.unlocked_grants.is_empty());
|
||||
assert!(!client.can_start(&f.channel, false, &f.clock));
|
||||
} else {
|
||||
assert!(applied.ready);
|
||||
assert_eq!(applied.unlocked_grants, vec![grant.grant_id]);
|
||||
assert!(
|
||||
helper
|
||||
.apply(&mut helper_db, &guard, &response, &raw, &f.clock, &boot)
|
||||
.unwrap()
|
||||
.unlocked_grants
|
||||
.is_empty()
|
||||
);
|
||||
client.apply_consumption(&mut f.ledger, &f.clock).unwrap();
|
||||
client.confirm_helper(&map(&applied.snapshot)).unwrap();
|
||||
assert!(client.can_start(&f.channel, true, &f.clock));
|
||||
}
|
||||
}
|
||||
assert_eq!(
|
||||
f.db.query_row::<String, _, _>("SELECT state FROM job_attempts", [], |rec| rec.get(0))
|
||||
.unwrap(),
|
||||
"closed_unknown"
|
||||
);
|
||||
assert_eq!(
|
||||
f.db.query_row::<Vec<u8>, _, _>("SELECT envelope FROM reconcile_results", [], |rec| {
|
||||
rec.get(0)
|
||||
})
|
||||
.unwrap(),
|
||||
archive.encode_to_vec()
|
||||
);
|
||||
for ledger in [&f.ledger, &helper_db] {
|
||||
assert_eq!(
|
||||
ledger
|
||||
.query_row::<Vec<u8>, _, _>("SELECT result FROM consumed", [], |rec| rec.get(0))
|
||||
.unwrap(),
|
||||
closed
|
||||
);
|
||||
assert_eq!(
|
||||
ledger
|
||||
.query_row::<(Vec<u8>, Vec<u8>), _, _>(
|
||||
"SELECT original_outcome,closure_outcome FROM unknown_closure_originals",
|
||||
[],
|
||||
|rec| Ok((rec.get(0)?, rec.get(1)?))
|
||||
)
|
||||
.unwrap(),
|
||||
(vec![], closed.clone())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn crash_after_durable_outcome_before_result_recovers_original_then_signed_sync_closes() {
|
||||
let mut f = Fixture::new();
|
||||
|
||||
@@ -33,5 +33,6 @@ Alle acht Versuche lieferten Exitcode 0. Bei beiden Neustarts wurde die Wiederan
|
||||
| Frische Installation und periodisches Agentupdate | Beide VMs wurden über HTTPS aufgenommen und übernahmen anschließend ein signiertes Folgepaket mit derselben Geräteidentität. Auf Windows ist der öffentliche GNU-Kanal einschließlich Prüfung des offiziellen Schlüssels belegt. [Linux](evidence/linux-public-installer-update-20261117.json) · [Windows GNU](evidence/windows-gnu-official-vm-20261118.json). ARM64 erweitert denselben HTTPS-Installer mit automatischer Architekturerkennung. Release `0.1.0-arm64.1` ist veröffentlicht und als Starter verfügbar. Auf Ubuntu 22.04.5 ARM64 wurden die öffentlichen Downloads, die Signaturprüfung, die Ablehnung einer veränderten Agentdatei und der native Start aller drei Dateien im Prüfmodus beobachtet. OTRS ist mit Gerätezertifikat aufgenommen und meldet authentisierte Heartbeats. Die erste Kontaktprüfung wartet seit der Korrektur auf das Zertifikat. Der öffentliche Installer lief auf OTRS erneut ohne Traceback und ohne neuen Einmalcode. Der ARM64-Katalogabruf ist bestätigt. Ein späterer Versionswechsel auf ARM64 steht aus. [ARM64-Release](evidence/linux-arm64-installer-20261118.json) · [Geräteaufnahme und Nachtest](evidence/linux-arm64-enrollment-heartbeat-20261118.json) |
|
||||
| Betriebssystemupdate per PowerShell | Die Windows-Updatevorlage installierte KB890830 v5.147 als SYSTEM. Ergebnis und Windows-Ereignis 19 bestätigen die Installation. [Installationsbeleg](evidence/windows-update-installation-20261117.json) |
|
||||
| Wiederanlauf | Nach einem Gatewaywechsel wurde der Windows-Agent ohne manuellen Dienstneustart wieder bereit. Der Helper glich seine bereits quittierte Ergebnismeldung ab. [Gatewaywechsel](evidence/windows-gateway-clock-recovery-20261117.json) · [Helper-Abgleich](evidence/windows-helper-result-recovery-20261118.json) |
|
||||
| WebUI-Abschluss eines ungeklärten Versuchs | Auf OTRS ARM64 war derselbe Versuch zentral als `closed_unknown` abgeschlossen und lokal wegen unterschiedlicher Befunde noch blockiert. Der Agent hatte eine archivierte Unterbrechungsmeldung, beide Verbrauchsjournale hatten den ursprünglichen Start und kein Ergebnis. Die Regression prüft den signierten Abschluss in Agent und Helper, den Erhalt der Originale und den Wiederanlauf nach einer Unterbrechung zwischen den Journalaktualisierungen. Die Bereitstellung und der native Nachweis stehen aus. [Geräteabgleich](../crates/agent-core/tests/reconcile.rs) |
|
||||
|
||||
[Produktvertrag](../Rust_RMM_Implementierungsspezifikation.md) · [Übergabe für die Weiterentwicklung](handover.md)
|
||||
|
||||
Reference in New Issue
Block a user