Share helper reconciliation and verify Linux and Windows native fixtures
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
//! Call only while holding the existing agent.lock. HelperSnapshot must come
|
||||
//! from the independently authenticated root-helper IPC, never from the server.
|
||||
use crate::auth::Binding;
|
||||
pub use crate::auth::HelperIdentity;
|
||||
use crate::crypto::{DefaultVerifier, Ed25519Verifier};
|
||||
use anyhow::{Context, Result, ensure};
|
||||
use chrono::{DateTime, Utc};
|
||||
@@ -69,6 +70,7 @@ struct Gate {
|
||||
pub struct ClientSync<V = DefaultVerifier> {
|
||||
binding: Binding,
|
||||
verifier: V,
|
||||
helper_identity: HelperIdentity,
|
||||
pending: Option<PreparedSync>,
|
||||
channel: Option<Channel>,
|
||||
gate: Option<Gate>,
|
||||
@@ -84,11 +86,18 @@ impl<V: Ed25519Verifier> ClientSync<V> {
|
||||
Self {
|
||||
binding,
|
||||
verifier,
|
||||
helper_identity: HelperIdentity::Root,
|
||||
pending: None,
|
||||
channel: None,
|
||||
gate: None,
|
||||
}
|
||||
}
|
||||
/// Configure one explicit helper identity; changing it discards all leases.
|
||||
pub fn with_helper_identity(mut self, identity: HelperIdentity) -> Self {
|
||||
self.close();
|
||||
self.helper_identity = identity;
|
||||
self
|
||||
}
|
||||
/// Invoke on every authenticated/fenced ServerHello or transport loss.
|
||||
pub fn close(&mut self) {
|
||||
self.gate = None;
|
||||
@@ -204,7 +213,15 @@ impl<V: Ed25519Verifier> ClientSync<V> {
|
||||
ensure!(meta.helper_id.is_none(), "HELPER_JOURNAL_DISAPPEARED");
|
||||
}
|
||||
if let Some(h) = helper {
|
||||
ingest_helper(&tx, ledger, &self.binding, &channel, h, now)?;
|
||||
ingest_helper(
|
||||
&tx,
|
||||
ledger,
|
||||
&self.binding,
|
||||
&channel,
|
||||
h,
|
||||
now,
|
||||
self.helper_identity,
|
||||
)?;
|
||||
}
|
||||
archive_events(&tx)?;
|
||||
tx.execute(
|
||||
@@ -884,6 +901,7 @@ fn ingest_helper(
|
||||
channel: &Channel,
|
||||
helper: &HelperSnapshot,
|
||||
now: DateTime<Utc>,
|
||||
identity: HelperIdentity,
|
||||
) -> Result<()> {
|
||||
let mut statement = db.prepare("SELECT job,attempt,offer FROM job_attempts")?;
|
||||
for row in statement.query_map([], |r| {
|
||||
@@ -895,7 +913,7 @@ fn ingest_helper(
|
||||
})? {
|
||||
let (job, attempt, bytes) = row?;
|
||||
let offer = JobOffer::decode(bytes.as_slice())?;
|
||||
if binding.job(&offer.payload_bytes)?.execution_identity == "root" {
|
||||
if binding.job(&offer.payload_bytes)?.execution_identity == identity.as_str() {
|
||||
let consumed: bool = ledger.query_row(
|
||||
"SELECT EXISTS(SELECT 1 FROM consumed WHERE job=?1 AND attempt=?2)",
|
||||
params![job, attempt],
|
||||
@@ -928,7 +946,7 @@ fn ingest_helper(
|
||||
let offer = JobOffer::decode(bytes.as_slice())?;
|
||||
let job = binding.job(&offer.payload_bytes)?;
|
||||
ensure!(
|
||||
job.execution_identity == "root"
|
||||
job.execution_identity == identity.as_str()
|
||||
&& h.job_payload_hash == offer.job_payload_hash
|
||||
&& (grant.is_empty() || grant == h.grant_id),
|
||||
"HELPER_ATTEMPT_BINDING"
|
||||
|
||||
Reference in New Issue
Block a user