Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)

Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
  nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-17 12:37:52 +01:00
parent e37a0deba9
commit 7c1c6dfa8d
10306 changed files with 748026 additions and 748088 deletions

View File

@@ -0,0 +1,83 @@
//! Admits registered Core only from the service's installed package version and
//! prevents legacy setup from replacing accounts owned by a registered runtime.
use std::os::windows::io::AsRawHandle;
use anyhow::Context;
use anyhow::Result;
use anyhow::bail;
use akode_windows_sandbox::SetupRuntime;
use windows_sys::Win32::System::Threading;
use super::AuthorizedClientProcess;
use crate::ipc::ServiceRequest;
pub(crate) fn authorize_setup_runtime(
process: &AuthorizedClientProcess,
request: &ServiceRequest,
) -> Result<SetupRuntime> {
match request {
ServiceRequest::ProvisionSandbox(request) if request.registered_core => {
authorize_runtime_client_process(process)?;
Ok(SetupRuntime::Registered)
}
ServiceRequest::ProvisionSandbox(_) => {
anyhow::ensure!(
crate::installation_record::load_runtime()?.is_none(),
"registered Core owns these sandbox accounts; legacy provisioning is not permitted"
);
Ok(SetupRuntime::Legacy)
}
ServiceRequest::RegisterInstallation { .. } => Ok(SetupRuntime::Legacy),
}
}
fn authorize_runtime_client_process(process: &AuthorizedClientProcess) -> Result<()> {
let client_family =
unsafe { akode_windows_sandbox::process_package_family(process.handle.as_raw_handle()) }
.context("read runtime registration client package family")?;
let service_family =
unsafe { akode_windows_sandbox::process_package_family(Threading::GetCurrentProcess()) }
.context("read runtime registration service package family")?;
require_runtime_package_family(client_family.as_deref(), service_family.as_deref())?;
let mut image = [0u16; 32768];
let mut length = image.len() as u32;
if unsafe {
Threading::QueryFullProcessImageNameW(
process.handle.as_raw_handle(),
0,
image.as_mut_ptr(),
&mut length,
)
} == 0
{
return Err(std::io::Error::last_os_error()).context("read provisioning client image");
}
let image = std::path::PathBuf::from(String::from_utf16(&image[..length as usize])?);
let image = image.canonicalize()?;
let service = std::env::current_exe()?.canonicalize()?;
let directory = service.parent().context("service image has no directory")?;
anyhow::ensure!(
["akode.exe", "akode-code-mode-host.exe"]
.iter()
.any(|name| {
image
.as_os_str()
.eq_ignore_ascii_case(directory.join(name).as_os_str())
}),
"registered Core caller is not from this installed service version"
);
Ok(())
}
pub(crate) fn require_runtime_package_family(
client: Option<&str>,
service: Option<&str>,
) -> Result<()> {
match (client, service) {
(Some(client), Some(service)) if client == service => Ok(()),
_ => bail!(
"runtime registration requires a client in the service's installed package family"
),
}
}