Add gated agent update planning, preserved handoff and Linux worker ports
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-14 21:48:21 +01:00
parent dc9cb1b096
commit 1e89c4577f
82 changed files with 25052 additions and 69 deletions
@@ -0,0 +1,158 @@
//! Codec fixtures only: the synthetic signature is deliberately NOT release
//! authority. These payloads must never be enrolled, published or executed.
use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD};
use rmm_domain::{agent_update::*, jobs::*};
use serde_json::json;
use uuid::Uuid;
fn id(last: u32) -> Uuid {
Uuid::parse_str(&format!("11111111-1111-4111-8111-{last:012x}")).unwrap()
}
fn fixture(platform: Platform, full: bool) -> serde_json::Value {
let m = ReleaseManifest {
schema_version: 1,
release_id: id(10),
release_sequence: 2,
version: "0.1.1-test".into(),
platform,
published_at: 1_790_000_000,
expires_at: 2_000_000_000,
protocol_major: 1,
state_schema: 1,
minimum_updater_version: 1,
artifacts: [
ArtifactDescriptor {
role: ArtifactRole::Agent,
artifact_id: id(11),
sha256: "02".repeat(32),
bytes: 3_000_007,
},
ArtifactDescriptor {
role: ArtifactRole::Helper,
artifact_id: id(12),
sha256: "04".repeat(32),
bytes: 2_000_009,
},
],
};
let manifest = encode(&m).unwrap();
let envelope = ReleaseEnvelope {
schema_version: 1,
key_id: "aa".repeat(32),
payload_bytes: URL_SAFE_NO_PAD.encode(&manifest),
signature: URL_SAFE_NO_PAD.encode([1_u8; 64]),
};
let transition = match platform {
Platform::LinuxX64 if full => PeerPinTransition::LinuxGeneralFullV1 {
general_pin_sha256: "10".repeat(32),
full: LinuxFullTransition {
schema_version: 1,
old_config_sha256: "11".repeat(32),
new_config_sha256: "12".repeat(32),
old_pin_sha256: "13".repeat(32),
new_pin_sha256: "14".repeat(32),
old_policy_sha256: "15".repeat(32),
new_policy_sha256: "16".repeat(32),
old_helper_sha256: "03".repeat(32),
new_helper_sha256: "04".repeat(32),
effective_signing_key_id: "17".repeat(32),
},
},
Platform::LinuxX64 => PeerPinTransition::UnchangedGeneralPinV1 {
general_pin_sha256: "10".repeat(32),
},
Platform::WindowsX64 => PeerPinTransition::WindowsCodePairV1 {
old_settings_sha256: "11".repeat(32),
new_settings_sha256: "12".repeat(32),
old_pin_sha256: "13".repeat(32),
new_pin_sha256: "14".repeat(32),
},
};
let update = ResolvedAgentUpdate {
schema_version: 1,
profile: UpdateProfile::FixedCodePairV1,
release_envelope_sha256: envelope.sha256().unwrap(),
release_envelope: envelope,
manifest_sha256: hash(&manifest),
predecessor: Predecessor {
release_id: id(9),
release_sequence: 1,
manifest_sha256: "20".repeat(32),
installed_record_sha256: "21".repeat(32),
agent_sha256: "01".repeat(32),
helper_sha256: "03".repeat(32),
},
updater: UpdaterBinding {
binary_sha256: "30".repeat(32),
policy_sha256: "31".repeat(32),
keyring_generation: 1,
keyring_sha256: "32".repeat(32),
health_public_key_hex: "33".repeat(32),
health_key_pin_sha256: "34".repeat(32),
},
peer_pin_transition: transition,
recovery: Recovery::RestoreExactPredecessorOnce,
health_profile: HealthProfile::MtlsInventorySyncV1,
health_timeout_seconds: 180,
no_reboot: true,
};
assert!(update.validate());
let job = JobPayload {
schema_version: 1,
tenant_id: id(1),
asset_id: id(2),
agent_id: id(3),
enrollment_generation: 1,
assignment_version: 1,
job_id: id(4),
attempt_id: id(5),
action: Action::UpdateAgent {
update: Box::new(update),
},
execution_identity: match platform {
Platform::LinuxX64 => "root",
Platform::WindowsX64 => "system",
}
.into(),
not_before: "2030-01-01T12:00:00Z".parse().unwrap(),
start_before: "2030-01-01T12:10:00Z".parse().unwrap(),
max_runtime_seconds: 600,
max_output_bytes: 65536,
};
let job_hash = hash(&encode(&job).unwrap());
let plan = PlanPayload {
schema_version: 1,
plan_id: id(6),
tenant_id: id(1),
principal: "codec-fixture-only".into(),
reason: "Nur Codec: vollständiges Codepaar – keine Releasefreigabe".into(),
jobs: vec![PlannedJob {
payload: job.clone(),
job_payload_hash: job_hash.clone(),
script_sha256: None,
}],
max_parallel: 1,
halt_after_failures: 1,
recipe_references: Vec::new(),
artifact_references: m
.artifacts
.iter()
.map(|a| JobArtifactReference {
job_id: job.job_id,
attempt_id: job.attempt_id,
artifact: ArtifactReference {
artifact_id: a.artifact_id,
sha256: a.sha256.clone(),
size_bytes: a.bytes,
},
})
.collect(),
};
let raw = encode(&plan).unwrap();
json!({"fixture_kind":"codec_only_synthetic_signature_never_publish_or_execute","plan_id":plan.plan_id,"plan_hash":hash(&raw),"payload":plan,"plan_payload":plan,
"plan_payload_bytes":raw,"resolved_targets":[{"asset_id":job.asset_id,"agent_id":job.agent_id}],"excluded_targets":[],"jobs":[{"job_id":job.job_id,"attempt_id":job.attempt_id,"asset_id":job.asset_id,"agent_id":job.agent_id,"job_payload_hash":job_hash,"script_sha256":null,"payload":job}],
"authorization_status":"required","approval_state":"pending_approval","expires_at":job.start_before})
}
fn main() {
let fixtures = json!({"linux_general":fixture(Platform::LinuxX64,false),"linux_full":fixture(Platform::LinuxX64,true),"windows_pair":fixture(Platform::WindowsX64,false)});
println!("{}", serde_json::to_string_pretty(&fixtures).unwrap());
}