fix: repair proven unsent sync chain with signed archived receipt
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-13 17:43:38 +01:00
parent 998f16fde4
commit 359233c64d
21 changed files with 3030 additions and 30 deletions
+47 -9
View File
@@ -38,6 +38,35 @@ fn response(messages: Vec<Envelope>) -> Response {
)
.into_response()
}
async fn append_work(
s: &crate::State,
tenant: Uuid,
agent: Uuid,
source: &Envelope,
payload: Payload,
generation: u64,
replies: &mut Vec<Envelope>,
) -> anyhow::Result<()> {
let reply = crate::agent_service::reply(source, payload, generation);
// Preserve the protocol's 16-envelope response limit. An offer that cannot
// fit twice is delivered normally without consuming the optional fault.
let claim = if replies.len() <= 14 {
crate::gateway::dev_delivery_faults::duplicate_offer(
&s.pool, tenant, agent, &reply, "https",
)
.await?
} else {
None
};
if claim.is_some() {
replies.push(reply.clone());
}
replies.push(reply);
if let Some(claim) = claim {
crate::gateway::dev_delivery_faults::duplicate_emitted(&s.pool, claim).await?;
}
Ok(())
}
pub async fn messages(
State(s): State<crate::State>,
Extension(peer): Extension<crate::Peer>,
@@ -83,13 +112,21 @@ pub async fn messages(
}
.map_err(|_| StatusCode::CONFLICT)?;
generation = reply.connection_generation;
replies.push(reply);
if !crate::gateway::dev_delivery_faults::after_ingest(&s.pool, t, a, &e, &reply, "https")
.await
.map_err(|_| StatusCode::SERVICE_UNAVAILABLE)?
{
replies.push(reply);
}
}
if let Some(work) = crate::job_gateway::next(&s, t, a, generation)
.await
.map_err(|_| StatusCode::SERVICE_UNAVAILABLE)?
if replies.len() < 16
&& let Some(work) = crate::job_gateway::next(&s, t, a, generation)
.await
.map_err(|_| StatusCode::SERVICE_UNAVAILABLE)?
{
replies.push(crate::agent_service::reply(&last, work, generation));
append_work(&s, t, a, &last, work, generation, &mut replies)
.await
.map_err(|_| StatusCode::SERVICE_UNAVAILABLE)?;
}
Ok(response(replies))
}
@@ -119,10 +156,11 @@ pub async fn poll(
.await
.map_err(|_| StatusCode::SERVICE_UNAVAILABLE)?
{
return Ok(response(vec![
ack,
crate::agent_service::reply(&e, work, e.connection_generation),
]));
let mut replies = vec![ack];
append_work(&s, t, a, &e, work, e.connection_generation, &mut replies)
.await
.map_err(|_| StatusCode::SERVICE_UNAVAILABLE)?;
return Ok(response(replies));
}
if tokio::time::Instant::now() >= deadline {
return Ok(response(vec![ack]));