feat(m0.6-r6): release examples, public schemas and cross-platform CI
- add runnable examples for an unknown-name Tool, multi-export plugin, external kernel provider and same-name multi-version packages - add JSON Schemas for Analysis v1, Trace v1 and Tool v1 and validate them in CI - extend CI with protocol/consumer smoke tests and a Windows/macOS cargo check - add --kernel provider descriptors and R6 example integration tests - document the examples and update M0.6 status
This commit is contained in:
1 parent
54c7b43d15
commit
4ce37afb39
31 files changed
+537
-5
No files matched your search
@@ -40,6 +40,8 @@ pub struct SandboxSettings {
|
||||
pub trust_native_plugin: bool,
|
||||
/// Optional Trace v1 output path.
|
||||
pub trace_file: Option<PathBuf>,
|
||||
/// External foreign-kernel descriptor paths.
|
||||
pub kernels: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
impl SandboxSettings {
|
||||
@@ -698,6 +700,16 @@ pub fn execute(
|
||||
if let Some(timeout) = settings.timeout {
|
||||
host.budget.deadline = Some(Instant::now() + Duration::from_secs(timeout));
|
||||
}
|
||||
for kernel_path in &settings.kernels {
|
||||
if let Err(error) = load_kernel_descriptor(&mut host, kernel_path) {
|
||||
if json {
|
||||
output::print_json(&json!({"success": false, "error": error}));
|
||||
} else {
|
||||
eprintln!("error: {error}");
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
for plugin_path in &settings.plugins {
|
||||
if let Err(message) =
|
||||
load_plugin_into_host(&mut host, plugin_path, settings.trust_native_plugin)
|
||||
@@ -822,6 +834,36 @@ pub fn execute(
|
||||
}
|
||||
}
|
||||
|
||||
fn load_kernel_descriptor(host: &mut StdHost, path: &Path) -> Result<(), String> {
|
||||
let text = std::fs::read_to_string(path).map_err(|error| {
|
||||
format!(
|
||||
"cannot read kernel descriptor `{}`: {error}",
|
||||
path.display()
|
||||
)
|
||||
})?;
|
||||
let mut descriptor: marqdo_foreign::KernelDescriptor = serde_json::from_str(&text)
|
||||
.map_err(|error| format!("invalid kernel descriptor `{}`: {error}", path.display()))?;
|
||||
if descriptor.builtin {
|
||||
return Err("external kernel descriptors must not set `builtin: true`".to_string());
|
||||
}
|
||||
if descriptor.entrypoint.is_relative() {
|
||||
let base = path.parent().unwrap_or_else(|| Path::new("."));
|
||||
descriptor.entrypoint = base.join(&descriptor.entrypoint);
|
||||
}
|
||||
descriptor.entrypoint = descriptor
|
||||
.entrypoint
|
||||
.canonicalize()
|
||||
.map_err(|error| format!("cannot open kernel provider: {error}"))?;
|
||||
if !descriptor.entrypoint.is_file() {
|
||||
return Err(format!(
|
||||
"kernel provider executable `{}` does not exist",
|
||||
descriptor.entrypoint.display()
|
||||
));
|
||||
}
|
||||
host.register_kernel(descriptor)
|
||||
.map_err(|error| format!("{}: {}", error.code(), error.message))
|
||||
}
|
||||
|
||||
fn load_plugin_into_host(
|
||||
host: &mut StdHost,
|
||||
path: &Path,
|
||||
|
||||
@@ -101,6 +101,9 @@ struct SandboxArgs {
|
||||
/// Write a versioned Trace v1 file for this run.
|
||||
#[arg(long = "trace-file", value_name = "PATH")]
|
||||
trace_file: Option<PathBuf>,
|
||||
/// Register an external foreign-kernel provider (repeatable).
|
||||
#[arg(long = "kernel", value_name = "PATH")]
|
||||
kernel: Vec<PathBuf>,
|
||||
/// Explicitly trust in-process native plugin loading (unsafe by nature).
|
||||
#[arg(long = "trust-native-plugin")]
|
||||
trust_native_plugin: bool,
|
||||
@@ -121,6 +124,7 @@ impl SandboxArgs {
|
||||
plugins: self.plugin.clone(),
|
||||
trust_native_plugin: self.trust_native_plugin,
|
||||
trace_file: self.trace_file.clone(),
|
||||
kernels: self.kernel.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user