Blueprint section 10: a first-class plugin ABI independent of the legacy MARQDO_ABI_VERSION=2, with a C ABI that is explicitly not a sandbox. - include/marqdo_plugin_abi_v1.h: frozen stable-layout C contract with documented buffer ownership/lifetimes, size limits, NULL/zero-length semantics, single-threaded invocation, no hot-unload policy, version negotiation and target-triple requirements. - marqdo-plugin-abi (host side): repr(C) mirrors with compile-time layout assertions, major/minor negotiation (wrong major fails, minor clamps), plugin.yaml parsing/validation, target selection and sha256 artifact verification, wire_version 1 typed JSON request/response envelopes, structured PluginError, and a libloading-based loader with host alloc/free, export registration and runtime ABI re-negotiation. - marqdo-plugin-sdk (plugin side): mq_plugin_entry! macro, panic containment, safe byte-buffer wrappers, capability/logging context and JSON helpers; it depends only on the shared ABI crate. - examples/plugin-demo: dependency-free C plugin (solver.add), manifest, build.sh that refreshes the artifact hash, README explaining that install, inspect and load are three different trust decisions. - Tests: C plugin cross-compiled with cc and loaded, plus wrong ABI major, missing symbol/artifact, hash mismatch and malformed manifest cases.
23 lines
882 B
Bash
Executable File
23 lines
882 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build the example C plugin and refresh the sha256 in plugin.yaml.
|
|
#
|
|
# The artifact is intentionally NOT committed: installing/inspecting a package
|
|
# never implies trusting or loading its native code, and the manifest must
|
|
# describe the artifact you actually build on your machine.
|
|
set -euo pipefail
|
|
here="$(cd "$(dirname "$0")" && pwd)"
|
|
repo="$(cd "$here/../.." && pwd)"
|
|
cd "$repo"
|
|
cc -shared -fPIC -I include -o "$here/solver.so" "$here/solver.c"
|
|
hash="$(sha256sum "$here/solver.so" | cut -d' ' -f1)"
|
|
python3 - "$here/plugin.yaml" "$hash" <<'PY'
|
|
import sys, re, pathlib
|
|
path, digest = sys.argv[1], sys.argv[2]
|
|
p = pathlib.Path(path)
|
|
text = p.read_text()
|
|
text = re.sub(r'(?m)^(\s*sha256:\s*")[0-9a-fA-F]{64}(")', r'\g<1>' + digest + r'\g<2>', text)
|
|
p.write_text(text)
|
|
PY
|
|
echo "built $here/solver.so (sha256 $hash)"
|
|
echo "now run: marqdo plugin inspect $here"
|