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
@@ -0,0 +1,16 @@
|
||||
# External kernel provider example
|
||||
|
||||
`mocklang` is not built into `marqdo-foreign`. The descriptor registers it at
|
||||
run time without changing interpreter or host source:
|
||||
|
||||
```sh
|
||||
marqdo run examples/kernel-mock/demo.mq.md \
|
||||
--kernel examples/kernel-mock/kernel.json \
|
||||
--allow-foreign
|
||||
```
|
||||
|
||||
The `mocklang` executable receives the source file path as argv[1] and the
|
||||
versioned request envelope on stdin. For `foreign.call` it must print exactly
|
||||
one typed wire value on stdout. A missing provider or wire version is
|
||||
`kernel.unavailable`; the `Code` value itself remains inert until the explicit
|
||||
call.
|
||||
@@ -0,0 +1,11 @@
|
||||
## main
|
||||
|
||||
### 代码
|
||||
|
||||
```mocklang
|
||||
ignored by the mock provider
|
||||
```
|
||||
|
||||
**结果 = foreign.call(ref("#代码"), {})**
|
||||
|
||||
> 打印(结果)
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"provider_id": "mocklang",
|
||||
"languages": ["mocklang", "mock"],
|
||||
"wire_version": 1,
|
||||
"entrypoint": "./mocklang",
|
||||
"permissions_requested": []
|
||||
}
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Minimal external kernel provider: consume the request envelope, then emit one
|
||||
# typed wire value. The source file path is argv[1].
|
||||
cat >/dev/null
|
||||
printf '%s' '{"type":"int","decimal":"42"}'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Multi-version package example
|
||||
|
||||
Two directories declare the same package name `geometry` at versions `1.0.0`
|
||||
and `2.0.0`. They receive different package-instance ids and different
|
||||
`ModuleId`s; importing both aliases is not an implicit override.
|
||||
|
||||
```sh
|
||||
marqdo run examples/packages-multi-version/index.mq.md
|
||||
marqdo lock
|
||||
```
|
||||
|
||||
`marqdo lock` must be run from the example directory because it discovers the
|
||||
project from the current working directory:
|
||||
|
||||
```sh
|
||||
(cd examples/packages-multi-version && ../../target/debug/marqdo lock)
|
||||
```
|
||||
|
||||
The lock records both content-addressed instances; no version silently wins.
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
import:
|
||||
geometry_v1: "@geometry_v1"
|
||||
geometry_v2: "@geometry_v2"
|
||||
---
|
||||
|
||||
## main
|
||||
|
||||
**一 = geometry_v1.area()**
|
||||
|
||||
**二 = geometry_v2.area()**
|
||||
|
||||
> 打印(一)
|
||||
|
||||
> 打印(二)
|
||||
@@ -0,0 +1,8 @@
|
||||
project:
|
||||
name: multi-version
|
||||
version: 0.1.0
|
||||
dependencies:
|
||||
geometry_v1:
|
||||
path: ./packages/geometry-v1
|
||||
geometry_v2:
|
||||
path: ./packages/geometry-v2
|
||||
@@ -0,0 +1,3 @@
|
||||
## area
|
||||
|
||||
*1*
|
||||
@@ -0,0 +1,3 @@
|
||||
project:
|
||||
name: geometry
|
||||
version: 1.0.0
|
||||
@@ -0,0 +1,3 @@
|
||||
## area
|
||||
|
||||
*2*
|
||||
@@ -0,0 +1,3 @@
|
||||
project:
|
||||
name: geometry
|
||||
version: 2.0.0
|
||||
@@ -0,0 +1,17 @@
|
||||
# Multi-export plugin example
|
||||
|
||||
One native library exports two complete names: `solver.add` and `solver.neg`.
|
||||
Both are registered and callable; there is no "first prefix wins" namespace.
|
||||
|
||||
```sh
|
||||
./examples/plugin-multi-export/build.sh
|
||||
marqdo check examples/plugin-multi-export/plugin-call.mq.md \
|
||||
--plugin examples/plugin-multi-export
|
||||
marqdo run examples/plugin-multi-export/plugin-call.mq.md \
|
||||
--plugin examples/plugin-multi-export \
|
||||
--trust-native-plugin --allow-plugin demo.solver
|
||||
```
|
||||
|
||||
`check --plugin` validates both signatures without loading the library. The
|
||||
runtime still requires the explicit in-process trust decision; a C ABI is not a
|
||||
sandbox, and an isolated worker transport is not part of this build.
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
here="$(cd "$(dirname "$0")" && pwd)"
|
||||
repo="$(cd "$here/../.." && pwd)"
|
||||
cd "$repo"
|
||||
cc -std=c11 -O2 -shared -fPIC -I include -DMQ_SOLVER_MULTI_EXPORT \
|
||||
-o "$here/solver.so" examples/plugin-demo/solver.c
|
||||
hash="$(sha256sum "$here/solver.so" | cut -d' ' -f1)"
|
||||
python3 - "$here/plugin.yaml" "$hash" <<'PY'
|
||||
import pathlib, re, sys
|
||||
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"
|
||||
@@ -0,0 +1,9 @@
|
||||
## main
|
||||
|
||||
**和 = solver.add(a=20, b=22)**
|
||||
|
||||
**相反数 = solver.neg(a=7)**
|
||||
|
||||
> 打印(和)
|
||||
|
||||
> 打印(相反数)
|
||||
@@ -0,0 +1,18 @@
|
||||
# Two exports under different prefixes, built from the shared C demo with
|
||||
# -DMQ_SOLVER_MULTI_EXPORT. Installing grants nothing; loading requires trust.
|
||||
plugin:
|
||||
name: demo.solver
|
||||
version: 0.1.0
|
||||
abi: "^1.0"
|
||||
kind: native
|
||||
exports:
|
||||
- name: solver.add
|
||||
signature: "($a: Int, $b: Int) -> Int"
|
||||
- name: solver.neg
|
||||
signature: "($a: Int) -> Int"
|
||||
requires:
|
||||
- math.compute
|
||||
artifacts:
|
||||
- target: x86_64-unknown-linux-gnu
|
||||
file: solver.so
|
||||
sha256: "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
@@ -0,0 +1,19 @@
|
||||
# Unknown-name CLI tool example
|
||||
|
||||
This directory is a complete Tool Protocol v1 package. Nothing named
|
||||
`benchmark` exists in the Marqdo CLI source; after installation the unknown
|
||||
top-level command is dispatched by the registry.
|
||||
|
||||
```sh
|
||||
marqdo tool install examples/tool-unknown-name/tool.json
|
||||
marqdo tool list
|
||||
marqdo benchmark run . --some-tool-option
|
||||
marqdo tool remove benchmark
|
||||
```
|
||||
|
||||
The executable receives the remaining arguments verbatim, inherits stdio/cwd,
|
||||
and its exit code is propagated. `MARQDO_TOOL_PROTOCOL=1` and `MARQDO_BIN` are
|
||||
provided for tools that need `check --emit`/`run --trace-file`.
|
||||
|
||||
A Tool is a user-run native process. It is **not** a C ABI plugin, a foreign
|
||||
kernel, or a program inside the `.mq.md` sandbox.
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
# A deliberately tool-specific program: the Marqdo CLI knows no `benchmark`
|
||||
# command or its options.
|
||||
printf 'benchmark tool: protocol=%s\n' "${MARQDO_TOOL_PROTOCOL:-unset}"
|
||||
for argument in "$@"; do
|
||||
printf 'arg=%s\n' "$argument"
|
||||
done
|
||||
exit 0
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"schema": "marqdo.cli-tool",
|
||||
"schema_version": 1,
|
||||
"name": "demo.benchmark",
|
||||
"version": "0.1.0",
|
||||
"command": "benchmark",
|
||||
"entrypoint": "bin/marqdo-benchmark",
|
||||
"compatibility": {
|
||||
"marqdo": ">=0.1,<1"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user