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

@ -147,6 +147,7 @@ impl Engine {
cmd::search::pump(state);
cmd::goto::sync(state);
cmd::syntax::pump(state, std::time::Instant::now());
cmd::toolchain::pump(state);
Ok(())
})?;
Ok(state.take_events())
@ -219,6 +220,24 @@ impl Engine {
list
}
/// Allows the one network access Lutra makes: downloading the pinned
/// Phpactor release (owner decision D15, see [`cmd::toolchain`]). Without
/// this call the engine downloads nothing, which keeps tests offline.
///
/// # Errors
/// [`EngineError::Internal`] if the pinned hash is malformed.
pub fn allow_downloads(&mut self) -> Result<(), EngineError> {
let source = lutra_lsp::toolchain::phpactor::pinned().map_err(EngineError::Internal)?;
self.allow_downloads_from(source);
Ok(())
}
/// Allows Phpactor downloads from `source` instead of the pinned
/// release, for tests against a local server.
pub fn allow_downloads_from(&mut self, source: lutra_lsp::toolchain::download::Source) {
self.state.toolchain.allow_downloads(source);
}
/// Read access to the state.
pub fn state(&self) -> &State {
&self.state
@ -393,6 +412,8 @@ mod tests {
"test.disabled",
"theme.list",
"theme.systemPreference",
"toolchain.downloadPhpactor",
"toolchain.status",
"ui.registerCommands",
]
);