M3.1: PHP detection and pinned Phpactor download

- crates/lsp toolchain: PHP from php.executable or PATH, `php -v` with a
  5 s timeout and capped output, version parsing (proptest), PHP >= 8.2.
- Pinned Phpactor 2026.06.25.0 (SHA-256 832510fe...59e9); newer releases
  need ext-posix and do not start on Windows.
- Download with ureq + rustls (ring, OS roots via rustls-native-certs):
  HTTPS only, 32 MiB cap, SHA-256 verified before an atomic write, retry
  with backoff. Tests use a local HTTP server only.
- Engine: settings php.executable, phpactor.path, phpactor.autoDownload
  (bool and string setting kinds), toolchain.status,
  toolchain.downloadPhpactor, toolchainChanged, notifications; worker
  thread off the engine lock, results via the pump. Downloads only after
  the host calls Engine::allow_downloads (the desktop does).
- Docs: architecture Toolchain section (network access, D15), G6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-10-18 11:25:20 +02:00
parent 78709dd76b
commit 50f36cce8b
23 changed files with 2577 additions and 10 deletions

View file

@ -34,15 +34,24 @@ pub enum Kind {
/// Largest allowed value.
max: i64,
},
/// `true` or `false`.
Bool,
/// Any string of at most `max_len` bytes, such as a file path.
Str {
/// Longest accepted value in bytes.
max_len: usize,
},
}
/// The default value of a setting.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DefaultValue {
/// A string, for [`Kind::Enum`].
/// A string, for [`Kind::Enum`] and [`Kind::Str`].
Str(&'static str),
/// An integer, for [`Kind::Int`].
Int(i64),
/// A boolean, for [`Kind::Bool`].
Bool(bool),
}
impl DefaultValue {
@ -51,6 +60,7 @@ impl DefaultValue {
match self {
Self::Str(s) => Value::from(s),
Self::Int(i) => Value::from(i),
Self::Bool(b) => Value::from(b),
}
}
}
@ -100,6 +110,17 @@ impl Def {
self.key
)),
},
Kind::Bool => match value {
Value::Bool(_) => Ok(()),
_ => Err(format!("{} must be true or false, got {value}", self.key)),
},
Kind::Str { max_len } => match value.as_str() {
Some(s) if s.len() <= max_len && !s.contains(char::from(0)) => Ok(()),
_ => Err(format!(
"{} must be a string of at most {max_len} bytes without NUL",
self.key
)),
},
}
}
@ -108,6 +129,8 @@ impl Def {
let (kind, enum_values, min, max) = match self.kind {
Kind::Enum(values) => ("enum", Some(values.to_vec()), None, None),
Kind::Int { min, max } => ("int", None, Some(min), Some(max)),
Kind::Bool => ("bool", None, None, None),
Kind::Str { .. } => ("string", None, None, None),
};
SettingInfo {
key: self.key,
@ -129,7 +152,7 @@ impl Def {
pub struct SettingInfo {
/// Dotted key.
pub key: &'static str,
/// `enum` or `int`.
/// `enum`, `int`, `bool` or `string`.
#[serde(rename = "type")]
pub kind: &'static str,
/// Default value.
@ -177,6 +200,30 @@ pub const DEFS: &[Def] = &[
description_key: "settings.ui.language.description",
section: "appearance",
},
Def {
key: "php.executable",
kind: Kind::Str { max_len: 4096 },
default: DefaultValue::Str(""),
label_key: "settings.php.executable.label",
description_key: "settings.php.executable.description",
section: "php",
},
Def {
key: "phpactor.path",
kind: Kind::Str { max_len: 4096 },
default: DefaultValue::Str(""),
label_key: "settings.phpactor.path.label",
description_key: "settings.phpactor.path.description",
section: "php",
},
Def {
key: "phpactor.autoDownload",
kind: Kind::Bool,
default: DefaultValue::Bool(true),
label_key: "settings.phpactor.autoDownload.label",
description_key: "settings.phpactor.autoDownload.description",
section: "php",
},
];
/// Looks a known setting up by key.