Files
marqdo-cli/tests/sdk-plugin/src/lib.rs
T
cflmy d713aa068a
ci/woodpecker/pr/main Pipeline is pending
ci/woodpecker/push/main Pipeline was canceled
refactor: extract neutral host contract and decouple plugin ABI (issue #13)
Implements the core M0-M3 boundary work from issue #13 / ADR-0071 without
changing language semantics or any public protocol:

- add marqdo-host-contract owning Host/HostOp/ExecutionContext/ResourceRead
  and the runtime observation facts; the engine depends on it only.
- marqdo-runtime no longer links marqdo-host; the native host implements the
  contract and has no reverse edge to runtime/frontend/IR.
- reduce marqdo-plugin-abi to the public C ABI/wire/error contract; move
  manifest/artifact/loader/worker execution into marqdo-host::plugin so the
  SDK carries no loader/worker/host dependency.
- add a real independent consumer (tests/embedding, own workspace+lock) that
  runs Markdown -> frontend -> IR -> runtime with bounded budgets and explicit
  effect refusal, plus differential CLI comparison.
- add an SDK-only third-party plugin fixture and real CLI invocation gate.
- replace the frozen-crate architecture test with a reviewed responsibility
  graph enforced from Cargo metadata, with negative unit cases.
- consolidate current docs/entry: ADR-0071, CURRENT responsibility map,
  developers/architecture indexes, historical banners, STATUS and evidence.
- record keep-in-workspace for Engine/Native Host; no empty candidate repo.

Evidence: docs/evidence/2026-11-26-issue-13-engine-host-boundary.md
Refs #13
2026-11-26 18:35:31 +08:00

34 lines
1.2 KiB
Rust

//! Minimal third-party plugin built only against the public Rust SDK.
//!
//! It exercises the typed wire helpers (`decode_request`, `int_arg`,
//! `success`) and a `Value::Int` result. Real negotiation, loading and
//! invocation are performed by the frozen CLI in
//! `tools/ci/check_plugin_sdk.py`.
use marqdo_plugin_sdk::wire;
use marqdo_plugin_sdk::{mq_plugin_entry, CallContext, PluginError, Value};
fn add(_ctx: &mut CallContext, args: &[u8]) -> Result<Vec<u8>, PluginError> {
let request = wire::decode_request(args)?;
let values = request.typed_args()?;
let a = wire::int_arg(&values, "a")?;
let b = wire::int_arg(&values, "b")?;
wire::success(Some(Value::Int((a + b).into())))
}
fn echo_text(_ctx: &mut CallContext, args: &[u8]) -> Result<Vec<u8>, PluginError> {
let request = wire::decode_request(args)?;
let values = request.typed_args()?;
let text = wire::text_arg(&values, "text")?;
wire::success(Some(Value::text(text)))
}
mq_plugin_entry! {
name: "sdk.demo",
version: "0.1.0",
exports: {
"sdk.add" => "($a: Int, $b: Int) -> Int" => add,
"sdk.echo" => "($text: Text) -> Text" => echo_text,
}
}