feat(host,runtime,cli): explicit plugin invocation from documents
Blueprint section 10 / P6: exports of an explicitly trusted plugin are callable from a `.mq.md` file through a bound namespace. - host: StdHost::load_plugin requires an explicit trust decision and a granted plugin capability, loads the native artifact through the ABI v1 loader with no capability handler (all plugin host-capability requests denied), and dispatches HostOp::PluginInvoke through the typed wire request/response. In-process native code is documented as sharing the host address space; no isolated worker transport exists in this build. - runtime: a qualified call whose base is not a local value, import alias or builtin namespace is routed to the plugin namespace; plugin calls take named arguments only and plugin values become Marqdo values (Unit when absent). - cli: run/call gain `--plugin <path>`, `--trust-native-plugin` and reuse `--allow-plugin <package>`; missing trust/grant/loaded namespace surface as structured errors. - frontend: member-call bases are namespaces (builtin/import/plugin), never inferred parameters, so `solver.add(...)` does not invent a parameter.
This commit is contained in:
1 parent
6f04c17f7a
commit
7fbd5e9ec1
7 files changed
+221
-12
No files matched your search
@@ -500,6 +500,34 @@ impl<'a> Interpreter<'a> {
|
||||
let args = self.eval_args(args, frame)?;
|
||||
return self.call_builtin(builtin, args, Some(span), frame);
|
||||
}
|
||||
if !frame.locals.contains_key(&alias.name) {
|
||||
// Not a local value or imported module: try an explicitly
|
||||
// trusted plugin namespace. Plugin calls take named
|
||||
// arguments only in this build.
|
||||
let evaluated = self.eval_args(args, frame)?;
|
||||
let mut named = std::collections::BTreeMap::new();
|
||||
for argument in evaluated {
|
||||
let Some(argument_name) = argument.name else {
|
||||
return Err(RuntimeError::new(
|
||||
ErrorCategory::Type,
|
||||
Some(argument.span),
|
||||
"plugin calls require named arguments",
|
||||
));
|
||||
};
|
||||
named.insert(argument_name, argument.value);
|
||||
}
|
||||
let module = frame.function.module.clone();
|
||||
return self.host_invoke(
|
||||
HostOp::PluginInvoke,
|
||||
vec![
|
||||
Value::Text(alias.name.clone()),
|
||||
Value::Text(name.clone()),
|
||||
Value::Map(named),
|
||||
],
|
||||
Some(span),
|
||||
&module,
|
||||
);
|
||||
}
|
||||
}
|
||||
let callee_value = self.eval_expr(callee, frame)?;
|
||||
let args = self.eval_args(args, frame)?;
|
||||
|
||||
Reference in new issue
Block a user