The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(skills): bind the install acknowledgement to the scanned document's digest (#7082)
oxoxDev8e234615d5c9
diff --git a/crates/openhuman-core/src/skills/catalog/ops.rs b/crates/openhuman-core/src/skills/catalog/ops.rsindex ce5047ec24..5425e4271e 100644--- a/crates/openhuman-core/src/skills/catalog/ops.rs+++ b/crates/openhuman-core/src/skills/catalog/ops.rs@@ -350,8 +350,8 @@ impl std::fmt::Display for CatalogInstallError {////// The document goes through the supply-chain scan gate: a blocking scan or/// a failed fetch is retried once, and a document that still blocks comes-/// back as [`SkillInstallOutcome::ScanBlocked`] unless `acknowledgement` is-/// [`ScanAcknowledgement::ByUser`].+/// back as [`SkillInstallOutcome::ScanBlocked`] unless `acknowledgement` names+/// that document's digest.pub async fn install_from_catalog(workspace_dir: &Path,entry_id: &str,@@ -376,18 +376,18 @@ pub(crate) async fn install_from_catalog_in() -> Result<SkillInstallOutcome, CatalogInstallError> {tracing::info!(entry_id = %entry_id,- acknowledged = acknowledgement == ScanAcknowledgement::ByUser,+ acknowledged = acknowledgement.is_given(),"[skill_registry] installing from catalog");let key = EntryKey::new(entry_id);- let document = fetch_scanned(entry_id, acknowledgement, || registry.fetch_document(&key))+ let document = fetch_scanned(entry_id, &acknowledgement, || registry.fetch_document(&key)).await.map_err(|error| {observe("install", &error, false);crate::skills::ops_install::report_install_fetch_failure(&error, None);CatalogInstallError::Registry(error)})?;- gate_install(entry_id, acknowledgement, document, |document| {+ gate_install(entry_id, &acknowledgement, document, |document| {crate::skills::ops_install::install_validated_document(workspace_dir,home,diff --git a/crates/openhuman-core/src/skills/catalog/ops_install_tests.rs b/crates/openhuman-core/src/skills/catalog/ops_install_tests.rsindex b756eb63d9..8cad5bddf5 100644--- a/crates/openhuman-core/src/skills/catalog/ops_install_tests.rs+++ b/crates/openhuman-core/src/skills/catalog/ops_install_tests.rs@@ -214,36 +214,135 @@ async fn a_document_that_still_blocks_is_not_installed() {assert!(!installed_skill(home.path(), "poisoned").exists());}+async fn install_entry(+ registry: &SkillRegistry,+ home: &std::path::Path,+ entry_id: &str,+ acknowledgement: ScanAcknowledgement,+) -> SkillInstallOutcome {+ install_from_catalog_in(registry, home, Some(home), entry_id, acknowledgement)+ .await+ .expect("a scan block is an outcome, not an error")+}++fn blocked(outcome: SkillInstallOutcome) -> crate::skills::ops_install::ScanBlockedOutcome {+ match outcome {+ SkillInstallOutcome::ScanBlocked(blocked) => blocked,+ other => panic!("expected scan_blocked, got {other:?}"),+ }+}++fn by_user(digest: &str) -> ScanAcknowledgement {+ ScanAcknowledgement::ByUser {+ digest: digest.to_owned(),+ }+}+#[tokio::test]-async fn an_acknowledged_install_writes_the_blocked_document() {+async fn an_acknowledged_install_writes_the_blocked_document_the_user_saw() {let fixture = Fixture::start(vec![hermes_item("acknowledged", "built-in")]).await;fixture.blocked_documents.store(usize::MAX, Ordering::SeqCst);+ let registry = fixture.registry();let home = tempfile::tempdir().unwrap();- let outcome = install_from_catalog_in(- &fixture.registry(),+ let seen = blocked(+ install_entry(+ ®istry,+ home.path(),+ "acknowledged",+ ScanAcknowledgement::Absent,+ )+ .await,+ );+ assert_eq!(fixture.document_hits.load(Ordering::SeqCst), 2);++ let outcome = install_entry(+ ®istry,home.path(),- Some(home.path()),"acknowledged",- ScanAcknowledgement::ByUser,+ by_user(&seen.digest),).await- .expect("install").installed()- .expect("the user acknowledged the findings");+ .expect("the user acknowledged this document");assert_eq!(outcome.new_skills, ["acknowledged"]);assert_eq!(fixture.document_hits.load(Ordering::SeqCst),- 1,- "an acknowledged install does not refetch"+ 3,+ "a matching acknowledged document installs without a refetch");let written = std::fs::read_to_string(installed_skill(home.path(), "acknowledged")).unwrap();assert!(written.contains('\u{200b}'));}+#[tokio::test]+async fn a_stale_acknowledgement_does_not_install_a_changed_document() {+ let fixture = Fixture::start(vec![hermes_item("swapped", "built-in")]).await;+ fixture+ .blocked_documents+ .store(usize::MAX, Ordering::SeqCst);+ let registry = fixture.registry();+ let home = tempfile::tempdir().unwrap();++ let seen = blocked(+ install_entry(+ ®istry,+ home.path(),+ "swapped",+ ScanAcknowledgement::Absent,+ )+ .await,+ );+ fixture.blocked_variant.store(1, Ordering::SeqCst);++ let fresh =+ blocked(install_entry(®istry, home.path(), "swapped", by_user(&seen.digest)).await);++ assert_ne!(+ fresh.digest, seen.digest,+ "the refusal names the new document"+ );+ assert!(fresh+ .findings+ .iter()+ .any(|finding| finding.verdict == tinyskills::Verdict::Block));+ assert_eq!(+ fixture.document_hits.load(Ordering::SeqCst),+ 4,+ "the changed document is scanned twice like any unacknowledged one"+ );+ assert!(!installed_skill(home.path(), "swapped").exists());++ let installed = install_entry(®istry, home.path(), "swapped", by_user(&fresh.digest)).await;+ assert_eq!(installed.status(), "installed");+}++#[tokio::test]+async fn a_stale_acknowledgement_installs_a_changed_document_that_scans_clean() {+ let fixture = Fixture::start(vec![hermes_item("cleaned", "built-in")]).await;+ fixture.blocked_documents.store(2, Ordering::SeqCst);+ let registry = fixture.registry();+ let home = tempfile::tempdir().unwrap();++ let seen = blocked(+ install_entry(+ ®istry,+ home.path(),+ "cleaned",+ ScanAcknowledgement::Absent,+ )+ .await,+ );+ let outcome = install_entry(®istry, home.path(), "cleaned", by_user(&seen.digest)).await;++ assert_eq!(outcome.status(), "installed");+ let written = std::fs::read_to_string(installed_skill(home.path(), "cleaned")).unwrap();+ assert!(!written.contains('\u{200b}'));+}+#[tokio::test]async fn a_failed_document_fetch_is_retried_once() {let fixture = Fixture::start(vec![hermes_item("down", "built-in")]).await;diff --git a/crates/openhuman-core/src/skills/catalog/schemas/controller_schemas.rs b/crates/openhuman-core/src/skills/catalog/schemas/controller_schemas.rsindex 9292fcdea6..e9d3647f7e 100644--- a/crates/openhuman-core/src/skills/catalog/schemas/controller_schemas.rs+++ b/crates/openhuman-core/src/skills/catalog/schemas/controller_schemas.rs@@ -127,9 +127,9 @@ pub fn skill_registry_schemas(function: &str) -> ControllerSchema {required: true,},FieldSchema {- name: "acknowledge_scan_findings",- ty: TypeSchema::Bool,- comment: "Set by the Skills UI only after the user reviewed the scan findings and chose to install anyway. Agent tools cannot set it.",+ name: "acknowledged_digest",+ ty: TypeSchema::String,+ comment: "The `digest` of a `scan_blocked` result, sent by the Skills UI only after the user reviewed its findings and chose to install anyway. It installs that document only; a different document is scanned and refused afresh. Agent tools cannot set it.",required: false,},],@@ -244,6 +244,12 @@ pub(crate) fn install_outputs(new_field: &'static str) -> Vec<FieldSchema> {comment: "The install slug the blocked document would have used (scan_blocked).",required: false,},+ FieldSchema {+ name: "digest",+ ty: TypeSchema::String,+ comment: "Digest of the blocked document, to send back as `acknowledged_digest` (scan_blocked).",+ required: false,+ },FieldSchema {name: "findings",ty: TypeSchema::Array(Box::new(TypeSchema::Json)),diff --git a/crates/openhuman-core/src/skills/catalog/schemas/handlers.rs b/crates/openhuman-core/src/skills/catalog/schemas/handlers.rsindex b58acb3bcd..4bae8763db 100644--- a/crates/openhuman-core/src/skills/catalog/schemas/handlers.rs+++ b/crates/openhuman-core/src/skills/catalog/schemas/handlers.rs@@ -104,7 +104,7 @@ pub(super) fn handle_install(params: Map<String, Value>) -> ControllerFuture {let p = deserialize_params::<InstallParams>(params)?;tracing::info!(entry_id = %p.entry_id,- acknowledge_scan_findings = p.acknowledge_scan_findings,+ acknowledged = p.acknowledged_digest.is_some(),"[skill_registry][rpc] install");@@ -112,7 +112,7 @@ pub(super) fn handle_install(params: Map<String, Value>) -> ControllerFuture {let outcome: InstallResult = ops::install_from_catalog(&workspace,&p.entry_id,- ScanAcknowledgement::from_user_flag(p.acknowledge_scan_findings),+ ScanAcknowledgement::from_user_digest(p.acknowledged_digest.clone()),).await.map_err(|error| error.to_string())?;diff --git a/crates/openhuman-core/src/skills/catalog/schemas/wire_types.rs b/crates/openhuman-core/src/skills/catalog/schemas/wire_types.rsindex 6cf851bd15..eade11d4ce 100644--- a/crates/openhuman-core/src/skills/catalog/schemas/wire_types.rs+++ b/crates/openhuman-core/src/skills/catalog/schemas/wire_types.rs@@ -59,14 +59,14 @@ pub(super) struct EntryParams {pub(super) entry_id: String,}-/// `skill_registry_install` params. `acknowledge_scan_findings` is set only-/// by the Skills UI after the user chose to install a skill whose scan-/// blocked; agent tools have no way to pass it.+/// `skill_registry_install` params. `acknowledged_digest` is set only by the+/// Skills UI, to the `digest` of the blocked document the user chose to+/// install anyway.#[derive(Debug, Deserialize)]pub(super) struct InstallParams {pub(super) entry_id: String,#[serde(default)]- pub(super) acknowledge_scan_findings: bool,+ pub(super) acknowledged_digest: Option<String>,}#[derive(Debug, Deserialize)]diff --git a/crates/openhuman-core/src/skills/catalog/test_fixtures.rs b/crates/openhuman-core/src/skills/catalog/test_fixtures.rsindex 993e3f0491..ee53a7b5d6 100644--- a/crates/openhuman-core/src/skills/catalog/test_fixtures.rs+++ b/crates/openhuman-core/src/skills/catalog/test_fixtures.rs@@ -25,6 +25,8 @@ pub(crate) struct Fixture {/// How many of the next `SKILL.md` responses carry content the/// supply-chain scan blocks.pub(crate) blocked_documents: Arc<AtomicUsize>,+ /// Changes the text of a blocked document, and so its digest.+ pub(crate) blocked_variant: Arc<AtomicUsize>,}#[derive(Clone)]@@ -35,6 +37,7 @@ struct FixtureState {document_status: Arc<AtomicU16>,document_hits: Arc<AtomicUsize>,blocked_documents: Arc<AtomicUsize>,+ blocked_variant: Arc<AtomicUsize>,}/// A zero-width space: an invisible code point the scan blocks on.@@ -71,7 +74,12 @@ async fn document_route(left.checked_sub(1)}).is_ok();- let body = if blocked { SCAN_BLOCKING_TEXT } else { "" };+ let body = if blocked {+ let variant = state.blocked_variant.load(Ordering::SeqCst);+ format!("{SCAN_BLOCKING_TEXT} Variant {variant}.")+ } else {+ String::new()+ };format!("---\nname: {name}\ndescription: Fixture skill {name}.\n---\n\n# {name}\n{body}\n").into_response()}@@ -96,6 +104,7 @@ impl Fixture {document_status: Arc::new(AtomicU16::new(200)),document_hits: Arc::new(AtomicUsize::new(0)),blocked_documents: Arc::new(AtomicUsize::new(0)),+ blocked_variant: Arc::new(AtomicUsize::new(0)),};let app = Router::new().route("/skills.json", get(catalog_route))@@ -113,6 +122,7 @@ impl Fixture {document_status: state.document_status,document_hits: state.document_hits,blocked_documents: state.blocked_documents,+ blocked_variant: state.blocked_variant,}}diff --git a/crates/openhuman-core/src/skills/ops_install/fetch.rs b/crates/openhuman-core/src/skills/ops_install/fetch.rsindex 799c48a38a..0de2363420 100644--- a/crates/openhuman-core/src/skills/ops_install/fetch.rs+++ b/crates/openhuman-core/src/skills/ops_install/fetch.rs@@ -112,7 +112,7 @@ pub struct InstallWorkflowFromUrlOutcome {/// The fetched document goes through the supply-chain scan gate: a blocking/// scan or a failed fetch is retried once, and a document that still blocks/// is returned as [`SkillInstallOutcome::ScanBlocked`] unless `acknowledgement`-/// is [`ScanAcknowledgement::ByUser`].+/// names that document's digest.pub async fn install_workflow_from_url(workspace_dir: &Path,params: InstallWorkflowFromUrlParams,@@ -230,7 +230,7 @@ pub(crate) async fn install_workflow_from_url_with_home(limits.max_document_bytes = MAX_WORKFLOW_MD_BYTES as u64;let transport: Arc<ReqwestTransport> = Arc::new(ReqwestTransport::new());- let fetched = fetch_scanned(&raw_url, acknowledgement, || {+ let fetched = fetch_scanned(&raw_url, &acknowledgement, || {fetch_skill_document(transport.clone(),Arc::new(SystemResolver),@@ -243,7 +243,7 @@ pub(crate) async fn install_workflow_from_url_with_home(.await.map_err(|error| install_fetch_error(&error, &fetch_url, timeout_secs))?;- gate_install(&raw_url, acknowledgement, fetched, |document| {+ gate_install(&raw_url, &acknowledgement, fetched, |document| {install_validated_document(workspace_dir, home, &raw_url, &fetch_url, document.document)})}diff --git a/crates/openhuman-core/src/skills/ops_install/scan_gate.rs b/crates/openhuman-core/src/skills/ops_install/scan_gate.rsindex 490b0e5cbe..50a19c3882 100644--- a/crates/openhuman-core/src/skills/ops_install/scan_gate.rs+++ b/crates/openhuman-core/src/skills/ops_install/scan_gate.rs@@ -2,8 +2,8 @@//!//! A fetched `SKILL.md` whose scan blocks, or a fetch that fails, is fetched//! and scanned once more. A document that still blocks is not installed-//! unless the user acknowledged its findings in the Skills UI; the caller gets-//! a [`SkillInstallOutcome::ScanBlocked`] instead.+//! unless the user acknowledged that exact document (by its digest) in the+//! Skills UI; the caller gets a [`SkillInstallOutcome::ScanBlocked`] instead.use std::future::Future;@@ -14,23 +14,37 @@ use super::fetch::InstallWorkflowFromUrlOutcome;/// Whether the user has reviewed a blocking scan and chosen to install anyway.///-/// Only the Skills UI sets [`ScanAcknowledgement::ByUser`], through the-/// `acknowledge_scan_findings` JSON-RPC param. Agent tools always pass-/// [`ScanAcknowledgement::Absent`].-#[derive(Debug, Clone, Copy, PartialEq, Eq)]+/// The acknowledgement names the digest of the document the user was shown;+/// it covers that document only. Only the Skills UI sets+/// [`ScanAcknowledgement::ByUser`], through the `acknowledged_digest` JSON-RPC+/// param. Agent tools always pass [`ScanAcknowledgement::Absent`].+#[derive(Debug, Clone, PartialEq, Eq)]pub enum ScanAcknowledgement {/// Nobody acknowledged the findings: a blocking scan refuses the install.Absent,- /// The user acknowledged the findings and asked to install anyway.- ByUser,+ /// The user acknowledged the findings of the document with this digest.+ ByUser { digest: String },}impl ScanAcknowledgement {- pub fn from_user_flag(acknowledged: bool) -> Self {- if acknowledged {- Self::ByUser- } else {- Self::Absent+ /// The acknowledgement a caller-supplied digest stands for; a missing or+ /// blank digest acknowledges nothing.+ pub fn from_user_digest(digest: Option<String>) -> Self {+ match digest.map(|digest| digest.trim().to_owned()) {+ Some(digest) if !digest.is_empty() => Self::ByUser { digest },+ _ => Self::Absent,+ }+ }++ pub fn is_given(&self) -> bool {+ matches!(self, Self::ByUser { .. })+ }++ /// Whether this acknowledgement lets `document` install despite its scan.+ pub fn covers(&self, document: &RegistryDocument) -> bool {+ match self {+ Self::Absent => false,+ Self::ByUser { digest } => *digest == document.digest,}}}@@ -55,6 +69,9 @@ pub struct ScanBlockedOutcome {pub fetched_from: String,/// The install slug the document would have used.pub slug: String,+ /// The digest of the blocked document; sending it back as+ /// `acknowledged_digest` installs this document and no other.+ pub digest: String,pub findings: Vec<ScanFindingSummary>,pub message: String,}@@ -81,6 +98,7 @@ impl ScanBlockedOutcome {target: target.to_owned(),fetched_from: document.fetched_from.clone(),slug: document.document.slug.clone(),+ digest: document.digest.clone(),message: format!("The security scan blocked this skill and it was not installed: {}.",blocking.join("; ")@@ -133,11 +151,12 @@ pub(crate) fn fetch_error_is_retryable(error: &RegistryError) -> bool {}/// Fetch and scan a document, retrying once when the scan blocks or the-/// fetch fails with a retryable error. An acknowledged install takes the-/// first document as is.+/// fetch fails with a retryable error. A blocked document the user+/// acknowledged by its digest is taken as is; one whose digest differs from+/// the acknowledged one is treated as unacknowledged.pub(crate) async fn fetch_scanned<F, Fut>(target: &str,- acknowledgement: ScanAcknowledgement,+ acknowledgement: &ScanAcknowledgement,mut fetch: F,) -> Result<RegistryDocument, RegistryError>where@@ -146,21 +165,31 @@ where{match fetch().await {Ok(document) if !document.is_blocked() => return Ok(document),- Ok(document) if acknowledgement == ScanAcknowledgement::ByUser => {+ Ok(document) if acknowledgement.covers(&document) => {tracing::warn!(install_target = %target,fetched_from = %document.fetched_from,+ digest = %document.digest,findings = document.scan.findings.len(),"[skills] scan gate: blocked document installed on user acknowledgement");return Ok(document);}- Ok(document) => tracing::info!(- install_target = %target,- fetched_from = %document.fetched_from,- findings = document.scan.findings.len(),- "[skills] scan gate: scan blocked the document; fetching it once more"- ),+ Ok(document) => {+ if acknowledgement.is_given() {+ tracing::warn!(+ install_target = %target,+ digest = %document.digest,+ "[skills] scan gate: acknowledged digest does not match the fetched document"+ );+ }+ tracing::info!(+ install_target = %target,+ fetched_from = %document.fetched_from,+ findings = document.scan.findings.len(),+ "[skills] scan gate: scan blocked the document; fetching it once more"+ );+ }Err(error) if fetch_error_is_retryable(&error) => tracing::info!(install_target = %target,kind = error.kind().as_str(),@@ -174,6 +203,7 @@ whereOk(document) => tracing::info!(install_target = %target,blocked = document.is_blocked(),+ digest = %document.digest,"[skills] scan gate: retry fetched the document"),Err(error) => tracing::info!(@@ -186,21 +216,23 @@ where}/// Turn a scanned document into an install, or into a refusal when its scan-/// blocks and the user has not acknowledged it.+/// blocks and the user has not acknowledged this document's digest.pub(crate) fn gate_install(target: &str,- acknowledgement: ScanAcknowledgement,+ acknowledgement: &ScanAcknowledgement,document: RegistryDocument,install: impl FnOnce(RegistryDocument) -> Result<InstallWorkflowFromUrlOutcome, String>,) -> Result<SkillInstallOutcome, String> {- if document.is_blocked() && acknowledgement == ScanAcknowledgement::Absent {+ if document.is_blocked() && !acknowledgement.covers(&document) {let blocked = ScanBlockedOutcome::of(target, &document);tracing::warn!(install_target = %target,fetched_from = %blocked.fetched_from,slug = %blocked.slug,+ digest = %blocked.digest,+ acknowledged = acknowledgement.is_given(),findings = blocked.findings.len(),- "[skills] scan gate: refused install; scan still blocks after a retry"+ "[skills] scan gate: refused install; scan still blocks and the document is not acknowledged");return Ok(SkillInstallOutcome::ScanBlocked(blocked));}diff --git a/crates/openhuman-core/src/skills/ops_install/scan_gate_tests.rs b/crates/openhuman-core/src/skills/ops_install/scan_gate_tests.rsindex 5c4c4b71b1..83b979e31f 100644--- a/crates/openhuman-core/src/skills/ops_install/scan_gate_tests.rs+++ b/crates/openhuman-core/src/skills/ops_install/scan_gate_tests.rs@@ -4,15 +4,22 @@ use std::sync::atomic::{AtomicUsize, Ordering};use std::sync::Arc;#[test]-fn only_an_explicit_user_flag_acknowledges_findings() {+fn only_a_non_blank_digest_acknowledges_findings() {assert_eq!(- ScanAcknowledgement::from_user_flag(true),- ScanAcknowledgement::ByUser+ ScanAcknowledgement::from_user_digest(Some(" abc ".into())),+ ScanAcknowledgement::ByUser {+ digest: "abc".into()+ });assert_eq!(- ScanAcknowledgement::from_user_flag(false),+ ScanAcknowledgement::from_user_digest(Some(" ".into())),ScanAcknowledgement::Absent);+ assert_eq!(+ ScanAcknowledgement::from_user_digest(None),+ ScanAcknowledgement::Absent+ );+ assert!(!ScanAcknowledgement::Absent.is_given());}#[test]@@ -44,7 +51,7 @@ fn outages_and_bad_documents_are_retried_but_request_refusals_are_not() {async fn run_failing(error: fn() -> RegistryError) -> (usize, RegistryError) {let calls = Arc::new(AtomicUsize::new(0));let counted = Arc::clone(&calls);- let result = fetch_scanned("entry", ScanAcknowledgement::Absent, move || {+ let result = fetch_scanned("entry", &ScanAcknowledgement::Absent, move || {counted.fetch_add(1, Ordering::SeqCst);let error = error();async move { Err::<RegistryDocument, _>(error) }@@ -91,6 +98,7 @@ fn outcomes_serialize_with_a_status_tag() {target: "x".into(),fetched_from: "https://example.com/SKILL.md".into(),slug: "x".into(),+ digest: "d".into(),findings: vec![ScanFindingSummary {check: ScanCheck::InvisibleCodePoints,verdict: Verdict::Block,@@ -103,11 +111,14 @@ fn outcomes_serialize_with_a_status_tag() {assert_eq!(value["status"], "scan_blocked");assert_eq!(value["findings"][0]["check"], "invisible_code_points");assert_eq!(value["findings"][0]["verdict"], "block");+ assert_eq!(value["digest"], "d");assert_eq!(blocked.status(), "scan_blocked");}const BLOCKED_SKILL: &str ="---\nname: url-poisoned\ndescription: A pasted skill.\n---\n\n# Steps\nRun\u{200b} it.\n";+const OTHER_BLOCKED_SKILL: &str =+ "---\nname: url-poisoned\ndescription: A pasted skill.\n---\n\n# Steps\nRun\u{200b} it twice.\n";const CLEAN_SKILL: &str ="---\nname: url-poisoned\ndescription: A pasted skill.\n---\n\n# Steps\nRun it.\n";@@ -131,7 +142,7 @@ async fn serve(responses: &[(&'static str, u64)]) -> wiremock::MockServer {async fn install_url(server: &wiremock::MockServer,home: &std::path::Path,- acknowledgement: ScanAcknowledgement,+ acknowledgement: &ScanAcknowledgement,) -> SkillInstallOutcome {crate::skills::ops_install::install_workflow_from_url_with_home(home,@@ -141,7 +152,7 @@ async fn install_url(},Some(home),true,- acknowledgement,+ acknowledgement.clone(),).await.expect("install")@@ -156,7 +167,7 @@ async fn a_pasted_url_whose_scan_blocks_is_retried_and_refused() {let server = serve(&[(BLOCKED_SKILL, 2)]).await;let home = tempfile::tempdir().unwrap();- let outcome = install_url(&server, home.path(), ScanAcknowledgement::Absent).await;+ let outcome = install_url(&server, home.path(), &ScanAcknowledgement::Absent).await;let SkillInstallOutcome::ScanBlocked(blocked) = outcome else {panic!("expected scan_blocked, got {outcome:?}");@@ -173,7 +184,7 @@ async fn a_pasted_url_installs_when_the_retry_scans_clean() {let server = serve(&[(BLOCKED_SKILL, 1), (CLEAN_SKILL, 1)]).await;let home = tempfile::tempdir().unwrap();- let outcome = install_url(&server, home.path(), ScanAcknowledgement::Absent).await;+ let outcome = install_url(&server, home.path(), &ScanAcknowledgement::Absent).await;assert_eq!(outcome.status(), "installed");let written = std::fs::read_to_string(url_skill(home.path())).unwrap();@@ -181,12 +192,30 @@ async fn a_pasted_url_installs_when_the_retry_scans_clean() {server.verify().await;}+fn blocked_digest(outcome: SkillInstallOutcome) -> String {+ match outcome {+ SkillInstallOutcome::ScanBlocked(blocked) => {+ assert!(!blocked.digest.is_empty());+ blocked.digest+ }+ other => panic!("expected scan_blocked, got {other:?}"),+ }+}++fn acknowledge(digest: &str) -> ScanAcknowledgement {+ ScanAcknowledgement::ByUser {+ digest: digest.to_owned(),+ }+}+#[tokio::test]-async fn an_acknowledged_pasted_url_installs_the_blocked_document() {- let server = serve(&[(BLOCKED_SKILL, 1)]).await;+async fn an_acknowledged_pasted_url_installs_the_document_the_user_saw() {+ let server = serve(&[(BLOCKED_SKILL, 3)]).await;let home = tempfile::tempdir().unwrap();- let outcome = install_url(&server, home.path(), ScanAcknowledgement::ByUser).await;+ let digest =+ blocked_digest(install_url(&server, home.path(), &ScanAcknowledgement::Absent).await);+ let outcome = install_url(&server, home.path(), &acknowledge(&digest)).await;assert_eq!(outcome.status(), "installed");assert!(std::fs::read_to_string(url_skill(home.path()))@@ -194,3 +223,33 @@ async fn an_acknowledged_pasted_url_installs_the_blocked_document() {.contains('\u{200b}'));server.verify().await;}++#[tokio::test]+async fn a_changed_document_is_rescanned_and_refused_under_a_stale_acknowledgement() {+ let server = serve(&[(BLOCKED_SKILL, 2), (OTHER_BLOCKED_SKILL, 2)]).await;+ let home = tempfile::tempdir().unwrap();++ let seen =+ blocked_digest(install_url(&server, home.path(), &ScanAcknowledgement::Absent).await);+ let fresh = blocked_digest(install_url(&server, home.path(), &acknowledge(&seen)).await);++ assert_ne!(fresh, seen, "the refusal carries the new document's digest");+ assert!(!url_skill(home.path()).exists());+ server.verify().await;+}++#[tokio::test]+async fn a_changed_document_that_scans_clean_installs_under_a_stale_acknowledgement() {+ let server = serve(&[(BLOCKED_SKILL, 2), (CLEAN_SKILL, 1)]).await;+ let home = tempfile::tempdir().unwrap();++ let seen =+ blocked_digest(install_url(&server, home.path(), &ScanAcknowledgement::Absent).await);+ let outcome = install_url(&server, home.path(), &acknowledge(&seen)).await;++ assert_eq!(outcome.status(), "installed");+ assert!(!std::fs::read_to_string(url_skill(home.path()))+ .unwrap()+ .contains('\u{200b}'));+ server.verify().await;+}diff --git a/crates/openhuman-core/src/skills/schemas/controller_schemas.rs b/crates/openhuman-core/src/skills/schemas/controller_schemas.rsindex fbadcd987a..7eb702bca2 100644--- a/crates/openhuman-core/src/skills/schemas/controller_schemas.rs+++ b/crates/openhuman-core/src/skills/schemas/controller_schemas.rs@@ -308,9 +308,9 @@ pub fn skills_schemas(function: &str) -> ControllerSchema {required: false,},FieldSchema {- name: "acknowledge_scan_findings",- ty: TypeSchema::Bool,- comment: "Set by the Skills UI only after the user reviewed the scan findings and chose to install anyway. Agent tools cannot set it.",+ name: "acknowledged_digest",+ ty: TypeSchema::String,+ comment: "The `digest` of a `scan_blocked` result, sent by the Skills UI only after the user reviewed its findings and chose to install anyway. It installs that document only; a different document is scanned and refused afresh. Agent tools cannot set it.",required: false,},],diff --git a/crates/openhuman-core/src/skills/schemas/handlers.rs b/crates/openhuman-core/src/skills/schemas/handlers.rsindex f25a975d6e..c14cbf40d7 100644--- a/crates/openhuman-core/src/skills/schemas/handlers.rs+++ b/crates/openhuman-core/src/skills/schemas/handlers.rs@@ -285,12 +285,13 @@ pub(super) fn handle_skills_install_from_url(params: Map<String, Value>) -> Conttracing::debug!(url = %wire.url,timeout_secs = ?wire.timeout_secs,- acknowledge_scan_findings = wire.acknowledge_scan_findings,+ acknowledged = wire.acknowledged_digest.is_some(),"[skills][rpc] install_from_url");let config = resolve_config().await;let workspace = config.workspace_dir.clone();- let acknowledgement = ScanAcknowledgement::from_user_flag(wire.acknowledge_scan_findings);+ let acknowledgement =+ ScanAcknowledgement::from_user_digest(wire.acknowledged_digest.clone());let payload = wire.into();match install_workflow_from_url(workspace.as_path(), payload, acknowledgement).await {Ok(outcome) => {diff --git a/crates/openhuman-core/src/skills/schemas/wire_types.rs b/crates/openhuman-core/src/skills/schemas/wire_types.rsindex ed6f8100fe..1f8ae88a45 100644--- a/crates/openhuman-core/src/skills/schemas/wire_types.rs+++ b/crates/openhuman-core/src/skills/schemas/wire_types.rs@@ -83,10 +83,10 @@ pub(super) struct WorkflowsInstallFromUrlParamsWire {pub(super) url: String,#[serde(default)]pub(super) timeout_secs: Option<u64>,- /// Set only by the Skills UI after the user chose to install a skill- /// whose scan blocked.+ /// Set only by the Skills UI, to the `digest` of the blocked document the+ /// user chose to install anyway.#[serde(default)]- pub(super) acknowledge_scan_findings: bool,+ pub(super) acknowledged_digest: Option<String>,}impl From<WorkflowsInstallFromUrlParamsWire> for InstallWorkflowFromUrlParams {