feat(m0.6-r2): explicit foreign kernel provider registry

- add KernelDescriptor/KernelRegistry with built-in Python/Node providers
- route run/call through the registry; external providers need an explicit
  executable and wire version
- expose provider registration on StdHost and use it in the foreign adapter
- add mocklang registration/call, duplicate-label, wire-version and timeout tests
- update spec/foreign.md and M0.6 progress
This commit is contained in:
cflmy committed 2026-11-20 11:39:14 +08:00
1 parent 4ecf537141
commit 21c1e50617
8 files changed
+370 -54

No files matched your search

+13
View File
@@ -107,6 +107,8 @@ pub struct StdHost {
pub foreign_timeout: Duration,
/// Maximum captured bytes per foreign stream.
pub foreign_output_limit: usize,
/// Registered foreign kernels (built-in Python/Node plus explicit providers).
pub kernel_registry: marqdo_foreign::KernelRegistry,
output: Vec<u8>,
trace_id: u64,
/// Explicitly trusted, in-process native plugins keyed by namespace.
@@ -141,6 +143,7 @@ impl StdHost {
trace: EffectTrace::default(),
foreign_timeout: Duration::from_secs(10),
foreign_output_limit: 1024 * 1024,
kernel_registry: marqdo_foreign::KernelRegistry::builtin(),
output: Vec::new(),
trace_id,
plugins: Vec::new(),
@@ -205,6 +208,16 @@ impl StdHost {
Ok(namespace)
}
/// Register an explicit external foreign-kernel provider.
pub fn register_kernel(
&mut self,
descriptor: marqdo_foreign::KernelDescriptor,
) -> Result<(), RuntimeError> {
self.kernel_registry.register(descriptor).map_err(|error| {
RuntimeError::new(ErrorCategory::KernelUnavailable, None, error.to_string())
})
}
/// Enable effect tracing.
pub fn with_trace(mut self) -> Self {
self.trace = EffectTrace::enabled();
+4 -4
View File
@@ -177,13 +177,13 @@ pub(crate) fn foreign(
};
match op {
HostOp::ForeignRun => {
let result =
marqdo_foreign::run(&request).map_err(|error| foreign_error(error, span))?;
let result = marqdo_foreign::run_with_registry(&request, &host.kernel_registry)
.map_err(|error| foreign_error(error, span))?;
Ok(foreign_result_map(result))
}
HostOp::ForeignCall => {
let result =
marqdo_foreign::call(&request).map_err(|error| foreign_error(error, span))?;
let result = marqdo_foreign::call_with_registry(&request, &host.kernel_registry)
.map_err(|error| foreign_error(error, span))?;
if result.status != marqdo_foreign::RunStatus::Success {
return Err(RuntimeError::new(
ErrorCategory::ForeignFailure,