From c6665e550a7db704107a16cfc30b62987dac9358 Mon Sep 17 00:00:00 2001 From: Phoebus Date: Sun, 20 Sep 2026 05:04:12 -0700 Subject: [PATCH] fix(ai): refuse proposals that weaken required settings Deterministic review now rejects encryption=none, filesystem=ext4 and the aggressive kernel profile, so the LUKS2/Btrfs/stability posture cannot be traded for convenience. A live provider that returns an invalid proposal is reported and the installer continues with the proven defaults (the explicit --ai-proposal-file test path still fails loudly). --- installer-rs/crates/phoebus-ai/src/lib.rs | 55 ++++++++++++++++++- .../crates/phoebus-installer/src/main.rs | 8 ++- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/installer-rs/crates/phoebus-ai/src/lib.rs b/installer-rs/crates/phoebus-ai/src/lib.rs index fa48364..64fb5ee 100644 --- a/installer-rs/crates/phoebus-ai/src/lib.rs +++ b/installer-rs/crates/phoebus-ai/src/lib.rs @@ -321,9 +321,29 @@ impl ReviewOutcome { } } -/// Validate a proposal with mandatory evidence, reject conflicts, and apply it -/// atomically (fail closed). This is the path a guided install uses; the model -/// never reaches the executor without passing it. +/// Changes that would weaken a required, non-negotiable setting. +/// +/// Phoebus is a LUKS2 + Btrfs system; aggressive kernel profiles are +/// speculative. The model may propose these, but a deterministic check refuses +/// them so the proven security posture is never traded for convenience. +fn fixed_policy_violation(change: &ProposedChange) -> Option { + match change { + ProposedChange::SetEncryption { + value: Encryption::None, + } => Some("encryption must remain LUKS2".into()), + ProposedChange::SetFilesystem { + value: Filesystem::Ext4, + } => Some("the filesystem must remain Btrfs".into()), + ProposedChange::SetKernelProfile { + value: KernelProfile::Aggressive, + } => Some("aggressive kernel profiles are not accepted".into()), + _ => None, + } +} + +/// Validate a proposal with mandatory evidence, reject conflicts and unsafe +/// changes, and apply it atomically (fail closed). This is the path a guided +/// install uses; the model never reaches the executor without passing it. pub fn review(config: &mut InstallConfig, proposal: &AiProposal) -> Result { if proposal.version != 1 { return Err(AiError::UnsupportedVersion(proposal.version)); @@ -355,6 +375,12 @@ pub fn review(config: &mut InstallConfig, proposal: &AiProposal) -> Result println!("{}", outcome.render()), + Err(e) => eprintln!("AI proposal rejected; continuing with the proven defaults: {e}"), + } Ok(()) }