fix(assistant): explain external overlay install boundary
Some checks are pending
ci / test (push) Waiting to run
Some checks are pending
ci / test (push) Waiting to run
This commit is contained in:
parent
f0bf537be1
commit
db17694c86
5 changed files with 234 additions and 8 deletions
|
|
@ -5,6 +5,19 @@ this file is the curated, human-readable summary.
|
|||
|
||||
## Unreleased — Fast defaults with user-controlled source builds
|
||||
|
||||
- **GPO link handling (2026-10-03).** The Assistant now recognizes a GPO
|
||||
package URL, checks whether Portage can resolve that exact atom locally,
|
||||
and reports the external listing as an unverified lead when it cannot.
|
||||
It does not substitute a Snap package or offer an install approval for an
|
||||
unsynced overlay. A final plan containing only read-only actions now runs
|
||||
those checks and shows their results as information without an approval
|
||||
button. The running VM confirmed that GPO lists
|
||||
`app-misc/chatgpt-desktop`, while its configured Portage repositories do
|
||||
not resolve it and `eselect repository` is absent. After updating the
|
||||
user-local bridge, the exact GPO link produced an Information card with no
|
||||
approval button. Rust format, strict clippy, workspace tests, `make check`,
|
||||
and dynamic/static release builds pass.
|
||||
|
||||
- **Assistant plan details (2026-10-03).** Expanding a prepared plan now shows
|
||||
the selected package, reported version, source health evidence and limits,
|
||||
exact planned actions, expected package effects, rationale, alternatives,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,30 @@
|
|||
Rolling note between work sessions. **Update this file before you finish**, then
|
||||
commit it. It should be short and current; use `git log` for detail.
|
||||
|
||||
- **GPO link and read-only approval correction (2026-10-03):** The user's
|
||||
`https://gpo.zugaina.org/app-misc/chatgpt-desktop` follow-up was handled by
|
||||
the model as a general administration plan that offered approval to inspect
|
||||
an unrelated Snap candidate. The bridge now recognizes an exact GPO atom,
|
||||
checks configured Portage, and performs a bounded external GPO lookup; an
|
||||
unsynced lead returns information with no install approval. Final general
|
||||
plans made only of read-only checks also run and display those checks as
|
||||
information without approval. The running VM's deterministic search found
|
||||
the GPO lead but no configured Portage match
|
||||
(`/var/tmp/phoebus-vm/chatgpt-overlay-search.png`), and
|
||||
`eselect repository list -i` could not load the repository module. No
|
||||
overlay or package was added. The new user-local static `sys` is SHA-256
|
||||
`7ee56b9bdce504b4cfd4c6ada58ba8ce3b93ecd906edbc5a26e298c7d0bb1448`;
|
||||
after Assistant restart the exact link returned an Information card without
|
||||
approval (`/var/tmp/phoebus-vm/gpo-assistant-result.png`). Rust format,
|
||||
strict clippy, workspace tests, `make check`, and dynamic/static release
|
||||
builds pass. A fresh ISO remains gated by 8 GiB free versus 20 GiB required
|
||||
by `make doctor`. The upstream GPO page lists ruizhi-overlay,
|
||||
gentoo-zh and nest; gentoo-zh's current ebuild (observed separately) fetches
|
||||
a Debian artifact from an OpenAI-hosted URL and has a Manifest hash. That
|
||||
hash verifies fetched bytes against the overlay's manifest, not publisher
|
||||
trust. A repository trust choice, ebuild review, scoped `~amd64`, and
|
||||
repository registration still precede any install.
|
||||
|
||||
- **Assistant plan details (2026-10-03):** The Details button previously
|
||||
repeated the recommendation already shown at the top of the card. It now
|
||||
shows the selected package, source health evidence and limits, planned
|
||||
|
|
|
|||
|
|
@ -48,6 +48,26 @@ disposable VM; `serial-driver.py recovery` now automates the same check.
|
|||
|
||||
## Matrix
|
||||
|
||||
GPO package links and read-only Assistant results (2026-10-03): a GPO URL
|
||||
now triggers an exact Portage resolution check and a bounded external GPO
|
||||
lookup. If the atom is only an external lead, the Assistant explains that a
|
||||
repository must be reviewed, registered and synced before installation;
|
||||
it creates no install plan. Final AI plans with only read-only actions execute
|
||||
those checks as information instead of showing `Approve & Execute`. Unit
|
||||
tests cover both boundaries. The running VM's `sys search chatgpt-desktop
|
||||
--legacy --overlays --portage` showed the external
|
||||
`app-misc/chatgpt-desktop` lead and no configured Portage match
|
||||
(`/var/tmp/phoebus-vm/chatgpt-overlay-search.png`); `eselect repository
|
||||
list -i` reported that the repository module is absent. An overlay and this
|
||||
package have not been installed in the VM. The updated user-local static `sys`
|
||||
is SHA-256 `7ee56b9bdce504b4cfd4c6ada58ba8ce3b93ecd906edbc5a26e298c7d0bb1448`.
|
||||
After restarting the Assistant, the exact link returned an Information card
|
||||
with the overlay explanation and no approval button
|
||||
(`/var/tmp/phoebus-vm/gpo-assistant-result.png`). Rust format, strict clippy,
|
||||
workspace tests, `make check`, and dynamic/static release builds pass. A
|
||||
fresh ISO remains unverified; `make doctor` reports 8 GiB free against its
|
||||
20 GiB VM gate.
|
||||
|
||||
Assistant plan details (2026-10-03): the GUI review panel displays candidate
|
||||
identity and reported version, source-health status and evidence, planned
|
||||
actions, effects, rationale, alternatives, post-execution verification, and
|
||||
|
|
|
|||
|
|
@ -386,6 +386,10 @@ first, and accept `~amd64` only for a specific package if needed. The external
|
|||
lookup has an eight-second limit; a network failure leaves local results
|
||||
available. `--overlays` is restricted to deterministic `search --legacy` and
|
||||
cannot be combined with a non-Portage source flag.
|
||||
In the desktop Assistant, pasting a `https://gpo.zugaina.org/category/package`
|
||||
link checks that exact atom against configured Portage sources and the GPO
|
||||
index. An external-only match is reported as information, with no install
|
||||
approval: a reviewed repository must be registered and synced first.
|
||||
|
||||
AppImage searches include Phoebus-managed images and read-only leads from the
|
||||
AppImage project's community catalog when online. Leads show a catalog page
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use phoebus_executor::proactive;
|
|||
use phoebus_executor::probe;
|
||||
use phoebus_executor::transaction;
|
||||
use phoebus_executor::update::check_unified_updates;
|
||||
use phoebus_executor::{actions, Exec};
|
||||
use phoebus_executor::{actions, query, Exec};
|
||||
|
||||
use crate::ai_setup;
|
||||
use crate::conversation::{self, ConversationTurn, FollowupResolution};
|
||||
|
|
@ -272,21 +272,106 @@ fn plan_response(id: u64, kind: &str, plan: &PreparedPlan) -> BridgeResponse {
|
|||
)
|
||||
}
|
||||
|
||||
fn general_response(id: u64, plan: &PreparedPlan) -> BridgeResponse {
|
||||
if plan.actions.is_empty() {
|
||||
fn general_response(exec: &Exec, root: &Path, id: u64, plan: &PreparedPlan) -> BridgeResponse {
|
||||
if !plan.actions.iter().any(SystemAction::is_mutating) {
|
||||
let mut answer = plan.summary.clone();
|
||||
if !plan.actions.is_empty() {
|
||||
answer.push_str("\n\nRead-only results:");
|
||||
for action in &plan.actions {
|
||||
let phase = exec.progress_phase(&format!("Checking {}", action.describe()));
|
||||
let result = match actions::execute(exec, action, None, root) {
|
||||
Ok(outcome) => {
|
||||
phase.complete();
|
||||
exec.redactor().redact(&outcome.output)
|
||||
}
|
||||
Err(error) => format!("check failed: {error}"),
|
||||
};
|
||||
answer.push_str(&format!(
|
||||
"\n{}: {}",
|
||||
action.describe(),
|
||||
result.chars().take(4000).collect::<String>()
|
||||
));
|
||||
}
|
||||
}
|
||||
return BridgeResponse::ok(
|
||||
id,
|
||||
json!({
|
||||
"kind": "info",
|
||||
"state": "info",
|
||||
"summary": plan.summary,
|
||||
"recommendation": plan.recommendation,
|
||||
"summary": answer,
|
||||
"recommendation": answer,
|
||||
}),
|
||||
);
|
||||
}
|
||||
plan_response(id, "plan", plan)
|
||||
}
|
||||
|
||||
/// A GPO URL is an external catalogue reference, not an enabled Portage
|
||||
/// repository. Handle it deterministically so a model cannot turn the listing
|
||||
/// into an install plan or silently substitute a different package lane.
|
||||
fn gpo_atom_in(query: &str) -> Option<&str> {
|
||||
let after = query.split_once("https://gpo.zugaina.org/")?.1;
|
||||
let atom = after
|
||||
.split(|c: char| !(c.is_ascii_lowercase() || c.is_ascii_digit() || "+_.-/".contains(c)))
|
||||
.next()?;
|
||||
let (category, package) = atom.split_once('/')?;
|
||||
if !category.is_empty()
|
||||
&& !package.is_empty()
|
||||
&& !package.contains('/')
|
||||
&& !category.starts_with('-')
|
||||
&& !package.starts_with('-')
|
||||
{
|
||||
Some(atom)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn gpo_reference_response(exec: &Exec, root: &Path, id: u64, atom: &str) -> BridgeResponse {
|
||||
let local = chooser::resolve_for_backend(exec, root, Backend::PortageSource, atom);
|
||||
let summary = if local
|
||||
.candidates
|
||||
.iter()
|
||||
.any(|candidate| candidate.id == atom && candidate.available)
|
||||
{
|
||||
format!(
|
||||
"{atom} is available in a configured Portage repository. Ask to install {atom} \
|
||||
through Portage to review the exact candidate and source before approval."
|
||||
)
|
||||
} else {
|
||||
let phase = exec.progress_phase("Checking the external Portage overlay index");
|
||||
let lead = query::search_external_overlays(exec, root, atom);
|
||||
if lead.is_ok() {
|
||||
phase.complete();
|
||||
}
|
||||
match lead {
|
||||
Ok(leads) if leads.iter().any(|lead| lead.atom == atom) => format!(
|
||||
"GPO lists {atom} as an external overlay lead. `sys search {atom} --legacy \
|
||||
--overlays --portage` can find it, but Portage cannot resolve it under \
|
||||
the current repository and keyword settings. The GPO page does not \
|
||||
identify a trusted install source by itself. Choose and review a \
|
||||
repository and its ebuild, register and sync it if needed, and accept \
|
||||
~amd64 only for this package if required before requesting a Portage \
|
||||
install. Nothing was installed."
|
||||
),
|
||||
Ok(_) => format!(
|
||||
"Portage cannot resolve {atom} under its current settings, and the \
|
||||
external GPO search did not confirm this listing. Nothing was installed."
|
||||
),
|
||||
Err(reason) => format!(
|
||||
"Portage cannot resolve {atom} under its current settings. The \
|
||||
external GPO lookup failed: {reason}. Nothing was installed."
|
||||
),
|
||||
}
|
||||
};
|
||||
BridgeResponse::ok(
|
||||
id,
|
||||
json!({
|
||||
"kind": "info", "state": "info", "summary": summary, "recommendation": summary
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn handle_request(
|
||||
exec: &Exec,
|
||||
root: &Path,
|
||||
|
|
@ -426,6 +511,10 @@ pub fn handle_request(
|
|||
return BridgeResponse::err(id, "empty request");
|
||||
}
|
||||
|
||||
if let Some(atom) = gpo_atom_in(&query) {
|
||||
return gpo_reference_response(exec, root, id, atom);
|
||||
}
|
||||
|
||||
let conv_path = conversation::history_path();
|
||||
let history = conversation::load_history(&conv_path);
|
||||
let constrained_backend = req.backend.as_deref().and_then(Backend::parse);
|
||||
|
|
@ -533,7 +622,7 @@ pub fn handle_request(
|
|||
});
|
||||
match response {
|
||||
Ok(Ok(plan)) => {
|
||||
let informational = plan.actions.is_empty();
|
||||
let informational = !plan.actions.iter().any(SystemAction::is_mutating);
|
||||
record_turn(
|
||||
exec,
|
||||
&conv_path,
|
||||
|
|
@ -550,7 +639,7 @@ pub fn handle_request(
|
|||
rationale: plan.rationale.clone(),
|
||||
},
|
||||
);
|
||||
general_response(id, &plan)
|
||||
general_response(exec, root, id, &plan)
|
||||
}
|
||||
Ok(Err(e)) => BridgeResponse::err(id, e.to_string()),
|
||||
Err(e) => BridgeResponse::err(id, e),
|
||||
|
|
@ -1151,7 +1240,7 @@ mod tests {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
let response = general_response(5, &plan);
|
||||
let response = general_response(&exec, root.path(), 5, &plan);
|
||||
assert!(response.ok);
|
||||
let result = response.result.unwrap();
|
||||
assert_eq!(result["kind"], "info");
|
||||
|
|
@ -1165,6 +1254,43 @@ mod tests {
|
|||
assert!(result.get("digest").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn final_read_only_check_is_information_without_approval() {
|
||||
use phoebus_ai::provider::{chat_response, ProviderKind, ScriptedTransport};
|
||||
|
||||
let root = tempdir().unwrap();
|
||||
let exec = make_test_exec(root.path());
|
||||
let plans = PlanStore::with_dir(tempdir().unwrap().keep());
|
||||
let transport = ScriptedTransport::new(vec![chat_response(
|
||||
r#"{"version":1,"summary":"Checking the Portage lane.","actions":[{"action":"check_backend","backend":"portage-source"}],"rationale":[{"action":"check_backend","reason":"Verify the configured lane"}]}"#,
|
||||
)]);
|
||||
let ai = AiInstall {
|
||||
provider: ProviderKind::Local,
|
||||
endpoint: "http://127.0.0.1:11434/v1/chat/completions".into(),
|
||||
model: "m".into(),
|
||||
transport: &transport,
|
||||
limits: phoebus_ai::install::Limits::default(),
|
||||
};
|
||||
let plan = service::plan_general(
|
||||
&plans,
|
||||
&exec,
|
||||
root.path(),
|
||||
"check Portage",
|
||||
&SystemFacts::default(),
|
||||
&ai,
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
let response = general_response(&exec, root.path(), 5, &plan);
|
||||
let result = response.result.unwrap();
|
||||
assert_eq!(result["kind"], "info");
|
||||
assert!(result.get("plan_id").is_none());
|
||||
assert!(result["summary"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.contains("Read-only results"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn appimage_install_request_returns_catalog_information_without_a_plan() {
|
||||
let root = tempdir().unwrap();
|
||||
|
|
@ -1190,6 +1316,45 @@ mod tests {
|
|||
.contains("no verified artifact hash"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gpo_reference_without_a_configured_repository_has_no_install_approval() {
|
||||
assert_eq!(
|
||||
gpo_atom_in("what about https://gpo.zugaina.org/app-misc/chatgpt-desktop?"),
|
||||
Some("app-misc/chatgpt-desktop")
|
||||
);
|
||||
assert!(gpo_atom_in("https://gpo.zugaina.org/app-misc/../../passwd").is_none());
|
||||
|
||||
let root = tempdir().unwrap();
|
||||
let temp = tempdir().unwrap();
|
||||
let runner = RecordingRunner::new();
|
||||
runner.fail("emerge", "package unavailable");
|
||||
runner.fail("chroot", "package unavailable");
|
||||
let logger = Logger::open(temp.path().join("test.log"), Redactor::new(), false);
|
||||
let exec = Exec::new(
|
||||
Box::new(runner),
|
||||
logger,
|
||||
false,
|
||||
root.path().to_path_buf(),
|
||||
temp.path().to_path_buf(),
|
||||
);
|
||||
let plans = PlanStore::with_dir(temp.path().join("plans"));
|
||||
let mut req = request("ask");
|
||||
req.request = Some("what about https://gpo.zugaina.org/app-misc/chatgpt-desktop?".into());
|
||||
let response = handle_request(&exec, root.path(), &plans, req);
|
||||
assert!(response.ok, "{:?}", response.error);
|
||||
let result = response.result.unwrap();
|
||||
assert_eq!(result["kind"], "info");
|
||||
assert!(result.get("plan_id").is_none());
|
||||
assert!(result["summary"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.contains("cannot resolve"));
|
||||
assert!(result["summary"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.contains("Nothing was installed"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unavailable_install_is_information_without_approval_controls() {
|
||||
let root = tempdir().unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue