diff --git a/docs/VERIFICATION.md b/docs/VERIFICATION.md index 00f63c5..e5b101c 100644 --- a/docs/VERIFICATION.md +++ b/docs/VERIFICATION.md @@ -63,9 +63,14 @@ Observed while a user drove the live ISO by hand (run | U3 | An invalid model produced only `OpenCode message failed: HTTP 500` — opaque. | **Fixed in source**: the error now names `provider/model` and says to check the model exists and the credentials are valid. (Needs the next ISO.) | | U4 | At first boot the DMS app-launcher/overview overlay was open on top of the welcome window, hiding the primary action until dismissed. | **Open**: reproduced once; investigating whether it is a DMS first-run behaviour or a focus race. | | U5 | The OpenCode model default `deepseek-chat` is not present on every server, so the first attempt failed. | **Mitigated**: the picker now lists only real models. Considering defaulting the model to unset and requiring a pick. | +| U6 | **Showstopper.** A fully-validated OpenCode install was refused at the final step with *"installing Phoebus requires a successful, validated AI interaction"*. The validated state was cleared by **unrelated** configuration and secret changes (selecting a disk, typing the account password, setting the LUKS passphrase). | **Fixed**: the AI validation is now bound to a digest of only the AI connection settings; non-AI config changes preserve it, and only an AI provider/model/endpoint/server change or an AI credential change invalidates it. Regression tests: `a_non_ai_config_change_keeps_the_validated_interaction`, `an_account_secret_does_not_invalidate_but_an_ai_key_does`. | +| U7 | The account/encryption step required several attempts; the password/passphrase minimum was only revealed as a red error after pressing Next, and the offending fields could be scrolled off-screen. | **Mitigated**: password/passphrase fields now carry an "At least 8 characters" / "Repeat …" placeholder hint before submission. | -None of these blocked the installer; they are usability defects. U1–U3 are -implemented; U4–U5 are tracked. +U6 blocked a real install; U1–U3 and U6–U7 are implemented, U4 remains open. +The user's session reached the AI step, obtained and applied a validated +OpenCode proposal, selected the disk, completed the account step and the +review — and only then hit U6. Evidence: `/var/tmp/phoebus-vm/user-session3/` +(`shots/0008`–`0016`, `observations.log`). OpenCode protocol/transport tests: 26 executor unit tests + 7 real-HTTP integration tests + 2 live tests (skipped offline, real inference when diff --git a/installer-rs/crates/phoebus-installer/src/gui_bridge.rs b/installer-rs/crates/phoebus-installer/src/gui_bridge.rs index 1ef800e..c15f424 100644 --- a/installer-rs/crates/phoebus-installer/src/gui_bridge.rs +++ b/installer-rs/crates/phoebus-installer/src/gui_bridge.rs @@ -523,11 +523,15 @@ impl Bridge { // backend concerns and not user-selectable from the GUI. config.runtime.dry_run = self.installer.config.runtime.dry_run; + let ai_before = ai_digest(&self.installer.config); self.installer.reconfigure(config); self.approved_digest = None; - // A configuration change (provider, model, endpoint, server) invalidates - // any previous AI validation. - self.validated_ai = None; + // Only a change to the AI connection settings invalidates the AI + // validation. Choosing a disk, typing a hostname or similar must not + // throw away a successful model interaction. + if ai_digest(&self.installer.config) != ai_before { + self.validated_ai = None; + } let issues = self.installer.validate(); Ok(json!({ "accepted": true, @@ -574,18 +578,24 @@ impl Bridge { self.installer.exec.register_secret(&s); self.root_password = Some(s); } + let mut ai_credential_changed = false; if let Some(v) = &patch.ai_api_key { let s = SecretString::new(v.clone()); self.installer.exec.register_secret(&s); self.api_key = Some(s); + ai_credential_changed = true; } if let Some(v) = &patch.opencode_password { let s = SecretString::new(v.clone()); self.installer.exec.register_secret(&s); self.opencode_password = Some(s); + ai_credential_changed = true; + } + // Only an AI credential change invalidates the AI validation; account + // and disk secrets do not. + if ai_credential_changed { + self.validated_ai = None; } - // A credential change invalidates any previous AI validation. - self.validated_ai = None; // Report only presence, never values. Ok(json!({ "luks_set": self.luks.is_some(), @@ -620,7 +630,7 @@ impl Bridge { self.approved_digest = None; // Bind the validated interaction to the exact configuration it was // validated against; any later change clears it. - self.validated_ai = Some(self.plan_digest()); + self.validated_ai = Some(ai_digest(&self.installer.config)); Ok(value) } @@ -700,7 +710,7 @@ impl Bridge { review_proposal(config, exec.redactor(), facts, api_key_present, transport)? }; self.approved_digest = None; - self.validated_ai = Some(self.plan_digest()); + self.validated_ai = Some(ai_digest(&self.installer.config)); Ok(value) } @@ -772,7 +782,8 @@ impl Bridge { let break_glass = std::env::var("PHOEBUS_NO_AI") .map(|v| matches!(v.to_ascii_lowercase().as_str(), "1" | "yes" | "true")) .unwrap_or(false); - let validated = self.validated_ai.as_deref() == Some(current.as_str()); + let validated = + self.validated_ai.as_deref() == Some(ai_digest(&self.installer.config).as_str()); if !validated && !break_glass { return Err( "installing Phoebus requires a successful, validated AI interaction for \ @@ -1297,6 +1308,29 @@ fn review_opencode( ) } +/// A deterministic digest of only the AI connection settings. The mandatory-AI +/// validation is bound to this, so choosing a disk or typing an account +/// password does not discard a successful model interaction, while changing the +/// provider, model, endpoint or server does. +fn ai_digest(config: &InstallConfig) -> String { + use sha2::{Digest, Sha256}; + let ai = &config.ai; + let mut hasher = Sha256::new(); + for field in [ + ai.backend.as_str(), + ai.provider.as_str(), + ai.model.as_str(), + ai.endpoint.as_str(), + ai.opencode_server.as_str(), + ai.opencode_provider.as_str(), + ai.opencode_model.as_str(), + ] { + hasher.update(field.as_bytes()); + hasher.update([0u8]); + } + format!("{:x}", hasher.finalize()) +} + /// Parse the direct provider from the configuration, validate the connection /// and apply the reviewed proposal. This is the same `ai_guide` path the TUI /// uses. @@ -1934,6 +1968,68 @@ mod tests { .contains("validated AI interaction")); } + #[test] + fn a_non_ai_config_change_keeps_the_validated_interaction() { + // Choosing a disk or editing the account must not discard a successful + // model interaction: this was the bug that refused a fully-validated + // install at the final step. + let mut bridge = test_bridge_non_dry(); + set_valid_config(&mut bridge); + arm_ai(&mut bridge); + let mut c = config_json(&bridge); + c["system"]["hostname"] = json!("renamed-box"); + let _ = call( + &mut bridge, + &json!({ "id": 60, "op": "set_config", "config": c }).to_string(), + ); + let (digest, _) = approve(&mut bridge); + let resp = start(&mut bridge, &digest); + assert!( + !resp["error"] + .as_str() + .unwrap_or("") + .contains("validated AI interaction"), + "a non-AI change wrongly invalidated the interaction: {}", + resp["error"] + ); + } + + #[test] + fn an_account_secret_does_not_invalidate_but_an_ai_key_does() { + let mut bridge = test_bridge_non_dry(); + set_valid_config(&mut bridge); + arm_ai(&mut bridge); + let _ = call( + &mut bridge, + r#"{"id":61,"op":"set_secrets","secrets":{"user_password":"secret-pass-1","luks":"luks-pass-1234"}}"#, + ); + let (digest, _) = approve(&mut bridge); + let resp = start(&mut bridge, &digest); + assert!( + !resp["error"] + .as_str() + .unwrap_or("") + .contains("validated AI interaction"), + "an account secret wrongly invalidated the interaction: {}", + resp["error"] + ); + + // A changed AI credential must invalidate it. + let mut bridge = test_bridge_non_dry(); + set_valid_config(&mut bridge); + arm_ai(&mut bridge); + let _ = call( + &mut bridge, + r#"{"id":62,"op":"set_secrets","secrets":{"ai_api_key":"a-different-key"}}"#, + ); + let (digest, _) = approve(&mut bridge); + let resp = start(&mut bridge, &digest); + assert!(resp["error"] + .as_str() + .unwrap() + .contains("validated AI interaction")); + } + #[test] fn a_secret_change_invalidates_the_validated_interaction() { let mut bridge = test_bridge_non_dry(); diff --git a/installer/live/desktop/phoebus-install/shell.qml b/installer/live/desktop/phoebus-install/shell.qml index 3103745..b80f116 100644 --- a/installer/live/desktop/phoebus-install/shell.qml +++ b/installer/live/desktop/phoebus-install/shell.qml @@ -1014,15 +1014,15 @@ ShellRoot { PhoebusField { id: fullnameField; label: "Full name"; onEdited: value => shell.cfg.user.fullname = value; Component.onCompleted: inputItem.text = shell.cfg ? shell.cfg.user.fullname : "" } PhoebusField { id: userField; label: "Username"; placeholder: "lowercase"; error: shell.issueFor("username"); onEdited: value => shell.cfg.user.username = value; Component.onCompleted: inputItem.text = shell.cfg ? shell.cfg.user.username : "" } PhoebusField { id: hostField; label: "Computer name"; placeholder: "phoebus"; error: shell.issueFor("hostname"); onEdited: value => shell.cfg.system.hostname = value; Component.onCompleted: inputItem.text = shell.cfg ? shell.cfg.system.hostname : "" } - PhoebusField { id: pwField; label: "Password"; secret: true; error: shell.issueFor("password"); onEdited: value => shell.userPw = value } - PhoebusField { id: pw2Field; label: "Confirm password"; secret: true; error: shell.issueFor("password_confirm"); onEdited: value => shell.userPw2 = value } + PhoebusField { id: pwField; label: "Password"; secret: true; placeholder: "At least 8 characters"; error: shell.issueFor("password"); onEdited: value => shell.userPw = value } + PhoebusField { id: pw2Field; label: "Confirm password"; secret: true; placeholder: "Repeat the password"; error: shell.issueFor("password_confirm"); onEdited: value => shell.userPw2 = value } } PhoebusCard { width: parent.width Text { width: parent.width; text: "Disk encryption"; color: Theme.warmWhite; font.family: Theme.family; font.pixelSize: Theme.fontHeading; font.weight: Font.DemiBold } Text { width: parent.width; text: "LUKS2 whole-disk encryption protects your data at rest. Keep this passphrase safe: without it the disk cannot be unlocked."; color: Theme.muted; font.family: Theme.family; font.pixelSize: Theme.fontSmall; wrapMode: Text.WordWrap } - PhoebusField { id: luksField; label: "Encryption passphrase"; secret: true; error: shell.issueFor("passphrase"); onEdited: value => shell.luksPw = value } - PhoebusField { id: luks2Field; label: "Confirm passphrase"; secret: true; error: shell.issueFor("passphrase_confirm"); onEdited: value => shell.luksPw2 = value } + PhoebusField { id: luksField; label: "Encryption passphrase"; secret: true; placeholder: "At least 8 characters"; error: shell.issueFor("passphrase"); onEdited: value => shell.luksPw = value } + PhoebusField { id: luks2Field; label: "Confirm passphrase"; secret: true; placeholder: "Repeat the passphrase"; error: shell.issueFor("passphrase_confirm"); onEdited: value => shell.luksPw2 = value } } PhoebusCard { width: parent.width