Wire preserved update control, health evidence and record publication
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -791,6 +791,48 @@ impl<V: Ed25519Verifier> HelperSync<V> {
|
||||
boot: current_boot,
|
||||
}),
|
||||
)?;
|
||||
if decision
|
||||
.attempts
|
||||
.iter()
|
||||
.any(|d| d.update_inflight.is_some())
|
||||
{
|
||||
use prost::Message;
|
||||
let applied_at = clock.now()?;
|
||||
ensure!(
|
||||
applied_at >= now && applied_at < decision.valid_until,
|
||||
"UPDATE_SYNC_EXPIRED_BEFORE_APPLY"
|
||||
);
|
||||
let response_raw = rmm_protocol::SyncResponse {
|
||||
decision_bytes: response.decision_bytes.clone(),
|
||||
signature: response.signature.clone(),
|
||||
}
|
||||
.encode_to_vec();
|
||||
for decision_attempt in decision
|
||||
.attempts
|
||||
.iter()
|
||||
.filter(|d| d.update_inflight.is_some())
|
||||
{
|
||||
let row = after
|
||||
.iter()
|
||||
.find(|r| {
|
||||
r.job_id == decision_attempt.job_id
|
||||
&& r.attempt_id == decision_attempt.attempt_id
|
||||
&& !r.update_handoff_bytes.is_empty()
|
||||
})
|
||||
.context("UPDATE_APPLIED_ORIGINAL_ROW_REQUIRED")?;
|
||||
crate::update_handoff::record_applied_sync(
|
||||
&tx,
|
||||
&crate::update_handoff::AppliedUpdateSync {
|
||||
schema_version: 1,
|
||||
grant_id: row.grant_id,
|
||||
decision_id: decision.decision_id,
|
||||
request_sha256: hash(raw_request),
|
||||
response_protobuf_sha256: hash(&response_raw),
|
||||
applied_at,
|
||||
},
|
||||
)?;
|
||||
}
|
||||
}
|
||||
let fingerprint = ledger_fingerprint(&tx)?;
|
||||
tx.execute("INSERT INTO helper_sync_decisions(decision_id,checkpoint,response,request,fingerprint) VALUES(?1,?2,?3,?4,?5)",params![decision.decision_id.to_string(),decision.helper_checkpoint,serde_json::to_vec(response)?,raw_request,fingerprint])?;
|
||||
tx.execute("UPDATE helper_sync_meta SET last_decision=?1,fault=COALESCE(fault,?2),agent_journal_id=?3,agent_checkpoint=?4 WHERE id=1",params![decision.decision_id.to_string(),fault,decision.journal_id.to_string(),decision.checkpoint])?;
|
||||
@@ -1291,11 +1333,22 @@ fn ledger_fingerprint(db: &Connection) -> Result<String> {
|
||||
Ok((r.get(0)?, r.get(1)?, r.get(2)?, r.get(3)?, r.get(4)?))
|
||||
})?
|
||||
.collect::<rusqlite::Result<Vec<NativeObservationRow>>>()?;
|
||||
let mut applied=db.prepare("SELECT grant_id,decision_id,witness_sha256 FROM agent_update_sync_applied ORDER BY grant_id,decision_id")?;
|
||||
let applied = applied
|
||||
.query_map([], |r| {
|
||||
Ok((
|
||||
r.get::<_, String>(0)?,
|
||||
r.get::<_, String>(1)?,
|
||||
r.get::<_, String>(2)?,
|
||||
))
|
||||
})?
|
||||
.collect::<rusqlite::Result<Vec<_>>>()?;
|
||||
return Ok(hash(&serde_json::to_vec(&(
|
||||
rows,
|
||||
updates,
|
||||
claims,
|
||||
observations,
|
||||
applied,
|
||||
))?));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user