Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63d386defa | ||
|
|
2585915e16 | ||
|
|
e2162add22 | ||
|
|
9b4f0a0822 | ||
|
|
4bbefc9244 | ||
|
|
452e9a32bd | ||
|
|
63f62d5728 |
No files matched your search
@@ -39,6 +39,10 @@ jobs:
|
||||
run: cargo test -p marqdo-cli --test docs_consistency
|
||||
- name: Architecture boundaries
|
||||
run: cargo test -p marqdo-cli --test architecture_boundaries
|
||||
- name: Dependency-direction gate (Engine / Host Contract / Native Host)
|
||||
run: python3 tools/ci/check_dependency_boundaries.py
|
||||
- name: Engine independence and CLI differential execution
|
||||
run: python3 tools/ci/check_engine_boundary.py
|
||||
- name: CI evidence tool tests
|
||||
run: python3 -m unittest discover -s tools/ci -p "test_*.py"
|
||||
- name: Whole stdlib product tests
|
||||
|
||||
@@ -37,3 +37,8 @@ __pycache__/
|
||||
*.pyc
|
||||
.perf-out-*
|
||||
.perf-err-*
|
||||
|
||||
# Independent consumer/fixture build outputs and the local scratch dir
|
||||
/tests/embedding/target/
|
||||
/tests/sdk-plugin/target/
|
||||
/.tmp/
|
||||
@@ -15,6 +15,7 @@ steps:
|
||||
- apt-get update
|
||||
- apt-get install -y --no-install-recommends ca-certificates python3 python3-jsonschema
|
||||
- cargo build --locked -p marqdo-cli -p marqdo-provider-worker
|
||||
- python3 tools/ci/check_dependency_boundaries.py
|
||||
- |
|
||||
set -eux
|
||||
./target/debug/marqdo check tests/consumers/fixtures/observation/basic.mq.md --emit /tmp/analysis.json
|
||||
@@ -47,6 +48,8 @@ steps:
|
||||
- cargo test --workspace --locked
|
||||
- cargo test -p marqdo-cli --test docs_consistency
|
||||
- cargo test -p marqdo-cli --test architecture_boundaries
|
||||
- python3 tools/ci/check_dependency_boundaries.py
|
||||
- python3 tools/ci/check_engine_boundary.py
|
||||
- python3 -m unittest discover -s tools/ci -p "test_*.py"
|
||||
- cargo test -p marqdo-cli --test stdlib_product
|
||||
# Windows compile gate: runtime lanes are native on GitHub; this catches
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
# Marqdo CLI — Agent / Contributor Operating Rules
|
||||
|
||||
**Start here:** read `docs/architecture/RFC-LANG-0002-unified-semantics.md` — it is the single current language authority — and its normative summary `spec/mapping.md` + `spec/expression.ebnf`. Then read `docs/DEVELOPMENT_BLUEPRINT.md` (architecture baseline; its language-mapping sections are historical), `docs/STATUS.md` (what is actually implemented, including the landed RFC-LANG-0002 migration), the relevant `spec/` files, `docs/adr/` for decisions at their date, `docs/contributor-guide.md`, and `tests/README.md` plus the conformance fixtures. Do not assume any current implementation or legacy Marqdo syntax is authoritative.
|
||||
**Start here:** read `docs/architecture/RFC-LANG-0002-unified-semantics.md` — it is the single current language authority — and its normative summary `spec/mapping.md` + `spec/expression.ebnf`. Then read `docs/architecture/CURRENT.md` (the single current architecture overview, including the Engine / Host Contract / Native Host map), [ADR-0071](docs/adr/0071-engine-host-contract-boundary.md) (boundary rules and keep-in-workspace decision), `docs/STATUS.md` (what is actually implemented), the relevant `spec/` files, `docs/adr/` for decisions at their date, the developer entry point `docs/developers/README.md`, `docs/contributor-guide.md`, and `tests/README.md` plus the conformance fixtures. Do not assume any current implementation, legacy Marqdo syntax, historical planning document or old architecture gate is authoritative.
|
||||
|
||||
For next-phase work, the authoritative release policy for the current
|
||||
3.0 prerelease line is `docs/MARQDO_3_0_PRERELEASE_PLAN.md` (beta gates,
|
||||
REL-01..REL-05, version axes, LTS conditions). `docs/STABLE_RELEASE_IMPLEMENTATION.md`
|
||||
(stable gates G-A/G-B/G-C) is historical roadmap input for the later stable
|
||||
release; it does not override the 3.0 prerelease plan. Also read `docs/CORE_STABILIZATION_AND_ECOSYSTEM_GATE.md`
|
||||
(historical stabilization spec, baseline `0adebe4`), `docs/NEXT_PHASE_IMPLEMENTATION.md`
|
||||
(M0.6 plan), `docs/EXTENSIBILITY_AUDIT.md` (E01–E16), `COMPATIBILITY.md` and
|
||||
`docs/security-gate.md`. Older plans are historical input; the 3.0 prerelease plan is authoritative for
|
||||
current release decisions, and the stable-release spec applies only when the
|
||||
project moves from beta to stable.
|
||||
None describes implemented behavior; re-check against HEAD and tests. `strict`
|
||||
remains fail-closed until G-C passes.
|
||||
REL-01..REL-05, version axes, LTS conditions). The current architecture and
|
||||
dependency direction are owned by `docs/architecture/CURRENT.md` and
|
||||
[ADR-0071](docs/adr/0071-engine-host-contract-boundary.md). The historical plans
|
||||
(`DEVELOPMENT_BLUEPRINT.md`, `NEXT_PHASE_IMPLEMENTATION.md`,
|
||||
`STABLE_RELEASE_IMPLEMENTATION.md`, `CORE_STABILIZATION_AND_ECOSYSTEM_GATE.md`,
|
||||
`EXTENSIBILITY_AUDIT.md`, `NEXT_RELEASE_CI_CONVERGENCE.md`) are archived design
|
||||
history: read them with that status, do not use them as current requirements, and
|
||||
do not create a second running-status page. `COMPATIBILITY.md` and
|
||||
`docs/security-gate.md` remain current inputs. None describes implemented
|
||||
behavior; re-check against HEAD and tests. `strict` remains fail-closed until
|
||||
G-C passes.
|
||||
|
||||
The stable-release spec also governs scope: do not add a top-level CLI command,
|
||||
Knowledge/Proof/View special-casing, a second interpreter or a new package
|
||||
@@ -33,6 +34,8 @@ correctness and release evidence before expanding the surface.
|
||||
9. Side effects go through `CapabilityHost`; do not invent host bypasses for tests, plugins, math or foreign kernels. `check` and `inspect` cannot execute untrusted project code.
|
||||
10. Language semantics, package format, ABI, authorization defaults or public CLI behavior changes require an ADR + tests + spec updates.
|
||||
11. RFC-LANG-0002 is implemented by the frontend, `marqdo-expression`, IR lowering, runtime and the bundled stdlib. Keep `spec/`, implementation, fixtures, stdlib digest and docs in lockstep; there is no legacy mapper or per-file syntax switch to fall back to. Do not make a release claim beyond the evidence recorded in `docs/STATUS.md`.
|
||||
12. The language engine depends on the neutral `marqdo-host-contract` only; it must never link `marqdo-host`, the sandbox, foreign kernels, the plugin loader/worker, package or CLI in normal/build dependencies. `marqdo-host-contract` depends on `Value`/`Span` only. The native host implements the contract and must not depend back on the runtime/frontend/IR. The plugin ABI crate is a contract (no `dlopen`/worker/manifest execution); the standalone public SDK repository `cflmy/marqdo-plugin-sdk` consumes one pinned CLI contract revision and the CLI must not depend on it (ADR-0072). CLI is the one assembly point. This is enforced by `tools/ci/check_dependency_boundaries.py`, `tools/ci/check_engine_boundary.py` and `crates/cli/tests/architecture_boundaries.rs`; see ADR-0071/ADR-0072.
|
||||
13. Do not create empty candidate repositories (for example `marqdo-engine`/`marqdo-host`/`marqdo-cli-*`) to "solve" architecture. A repository split requires a separate accepted ADR with ownership/release evidence; "keep in workspace" is a valid recorded decision. The only split approved so far is the independent public SDK (ADR-0072); the SDK is pinned to a CLI contract `rev` and must not return as a workspace member or copied source. Do not add a second Host trait, Value encoding, wire/RPC engine protocol or compatibility re-export path.
|
||||
|
||||
## Pre-stable protocol changes
|
||||
|
||||
@@ -51,7 +54,7 @@ closing a protocol replacement issue.
|
||||
2. Update the normative spec **in place** first; there is never a second active syntax spec.
|
||||
3. Add a small `.mq.md` positive/negative conformance fixture and define the expected Markdown AST, execution IR and diagnostics.
|
||||
4. Implement only the smallest module that satisfies this fixture. Keep Markdown parser, semantic mapper, expression parser, runtime and host separated.
|
||||
5. Run formatting, clippy, unit tests, golden tests and relevant security/ABI compatibility tests (`cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo test --workspace`, `cargo test -p marqdo-cli`).
|
||||
5. Run formatting, clippy, unit tests, golden tests, the architecture/dependency gates and relevant security/ABI compatibility tests (`cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo test --workspace`, `cargo test -p marqdo-cli`, `python3 tools/ci/check_dependency_boundaries.py`, `python3 tools/ci/check_engine_boundary.py`).
|
||||
6. Write the tradeoff and state of completion in the PR. Never say a feature is finished because a design example looks executable. Update `spec/` and `docs/STATUS.md` when behavior or status changes; the docs describe what the code does and flag divergences explicitly.
|
||||
|
||||
## Unresolved design topics
|
||||
|
||||
+3
-2
@@ -14,11 +14,12 @@ separately and do not follow the product version. Dates use ISO 8601.
|
||||
Older sections are release records: a retired option or spec they name is
|
||||
available at its tagged commit, not in the current tree.
|
||||
|
||||
## 3.0.0-rc.4 (2026-11-25, candidate)
|
||||
## 3.0.0-rc.4 (2026-11-25)
|
||||
|
||||
- The Rust workspace, CLI version output and protocol producers report
|
||||
`3.0.0-rc.4`; the supported platform remains Linux x86_64 on glibc 2.39 and
|
||||
the locked Rust minimum remains 1.89.
|
||||
the locked Rust minimum remains 1.89. Released as tag `v3.0.0-rc.4` at
|
||||
`452e9a32bd9e40dba427d4180691c58bab74449e`.
|
||||
|
||||
### Closed public Analysis boundary — issue #10 (breaking in place)
|
||||
|
||||
|
||||
+6
-3
@@ -1,7 +1,10 @@
|
||||
# Compatibility and support matrix
|
||||
|
||||
Snapshot: product version **`3.0.0-rc.4`** (prerelease candidate, 2026-11-25).
|
||||
The previous release is `3.0.0-rc.3` at source SHA
|
||||
Snapshot: product version **`3.0.0-rc.4`** (prerelease, released 2026-11-25).
|
||||
Tag `v3.0.0-rc.4` at source SHA
|
||||
`452e9a32bd9e40dba427d4180691c58bab74449e`; release
|
||||
https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.4. The previous
|
||||
release is `3.0.0-rc.3` at source SHA
|
||||
`1e2a045cc78bf40972181abb44e7117c56cf4401`; its evidence remains under
|
||||
[`docs/evidence/`](docs/evidence/2026-11-24-rc.3-release.md). This file records
|
||||
what was actually verified and separates it from what is only implemented. The
|
||||
@@ -10,7 +13,7 @@ experimental and not claimed for this prerelease. Executed status and SHA-bound
|
||||
evidence are in [`docs/STATUS.md`](docs/STATUS.md) and
|
||||
[`docs/evidence/`](docs/evidence/).
|
||||
|
||||
The `3.0.0-rc.4` candidate includes the post-beta protocol convergence and the
|
||||
The `3.0.0-rc.4` release includes the post-beta protocol convergence and the
|
||||
closed public Analysis boundary below. See the
|
||||
[RC acceptance procedure](docs/releasing.md). The platform evidence table
|
||||
records the beta, rc.1/rc.2/rc.3 and rc.4 candidate verification.
|
||||
|
||||
Generated
+15
-15
@@ -420,6 +420,7 @@ dependencies = [
|
||||
"marqdo-foreign",
|
||||
"marqdo-frontend",
|
||||
"marqdo-host",
|
||||
"marqdo-host-contract",
|
||||
"marqdo-ir",
|
||||
"marqdo-markdown",
|
||||
"marqdo-package",
|
||||
@@ -485,8 +486,10 @@ dependencies = [
|
||||
"flate2",
|
||||
"getrandom 0.4.3",
|
||||
"glob",
|
||||
"hex",
|
||||
"libloading",
|
||||
"marqdo-foreign",
|
||||
"marqdo-host-contract",
|
||||
"marqdo-plugin-abi",
|
||||
"marqdo-sandbox",
|
||||
"marqdo-span",
|
||||
@@ -499,10 +502,20 @@ dependencies = [
|
||||
"rustls-pemfile",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"sha2",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-host-contract"
|
||||
version = "3.0.0-rc.4"
|
||||
dependencies = [
|
||||
"marqdo-span",
|
||||
"marqdo-value",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-ir"
|
||||
version = "3.0.0-rc.4"
|
||||
@@ -542,33 +555,19 @@ dependencies = [
|
||||
name = "marqdo-plugin-abi"
|
||||
version = "3.0.0-rc.4"
|
||||
dependencies = [
|
||||
"hex",
|
||||
"libloading",
|
||||
"marqdo-span",
|
||||
"marqdo-value",
|
||||
"marqdo-worker-ipc",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"sha2",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-plugin-sdk"
|
||||
version = "3.0.0-rc.4"
|
||||
dependencies = [
|
||||
"marqdo-plugin-abi",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-provider-worker"
|
||||
version = "3.0.0-rc.4"
|
||||
dependencies = [
|
||||
"libloading",
|
||||
"marqdo-host",
|
||||
"marqdo-host-contract",
|
||||
"marqdo-sandbox",
|
||||
"marqdo-value",
|
||||
"marqdo-worker-ipc",
|
||||
@@ -583,6 +582,7 @@ dependencies = [
|
||||
"marqdo-expression",
|
||||
"marqdo-frontend",
|
||||
"marqdo-host",
|
||||
"marqdo-host-contract",
|
||||
"marqdo-ir",
|
||||
"marqdo-sandbox",
|
||||
"marqdo-span",
|
||||
|
||||
+2
-1
@@ -11,8 +11,8 @@ members = [
|
||||
"crates/marqdo-plugin-abi",
|
||||
"crates/marqdo-provider-worker",
|
||||
"crates/marqdo-worker-ipc",
|
||||
"crates/marqdo-plugin-sdk",
|
||||
"crates/marqdo-host",
|
||||
"crates/marqdo-host-contract",
|
||||
"crates/marqdo-runtime",
|
||||
"crates/marqdo-package",
|
||||
"crates/marqdo-sandbox",
|
||||
@@ -38,6 +38,7 @@ marqdo-foreign = { path = "crates/marqdo-foreign" }
|
||||
marqdo-plugin-abi = { path = "crates/marqdo-plugin-abi" }
|
||||
marqdo-worker-ipc = { path = "crates/marqdo-worker-ipc" }
|
||||
marqdo-host = { path = "crates/marqdo-host" }
|
||||
marqdo-host-contract = { path = "crates/marqdo-host-contract" }
|
||||
marqdo-runtime = { path = "crates/marqdo-runtime" }
|
||||
marqdo-package = { path = "crates/marqdo-package" }
|
||||
marqdo-sandbox = { path = "crates/marqdo-sandbox" }
|
||||
|
||||
@@ -27,7 +27,10 @@ release policy.
|
||||
> [`docs/STATUS.md`](docs/STATUS.md) and
|
||||
> [`docs/migration/README.md`](docs/migration/README.md).
|
||||
|
||||
> **Published baseline: `3.0.0-beta.1` prerelease** —
|
||||
> **Current release: `3.0.0-rc.4` prerelease** —
|
||||
> [release](https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.4),
|
||||
> source `452e9a32bd9e40dba427d4180691c58bab74449e`, Linux x86_64. The previous
|
||||
> published baseline was `3.0.0-beta.1` —
|
||||
> [release](https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-beta.1),
|
||||
> source `2c7c4f31e7a388d3fcfa717a77067e696ed13854`. The public beta target is **Linux x86_64 (glibc)**; macOS and Windows are experimental and not claimed, and the
|
||||
> C ABI plugin/provider paths are Linux-only in this beta. The language
|
||||
@@ -46,8 +49,9 @@ release policy.
|
||||
CI: the source of truth is the Gitea remote
|
||||
[git.cflmy.cn/cflmy/marqdo-cli](https://git.cflmy.cn/cflmy/marqdo-cli) with
|
||||
Woodpecker at [ci.cflmy.cn](https://ci.cflmy.cn); [`.woodpecker/main.yml`](.woodpecker/main.yml)
|
||||
runs fmt, clippy, workspace tests with `--locked`, the Windows cross-target
|
||||
compile gate and a release build of both binaries. The strict OS-isolation lane
|
||||
runs fmt, clippy, workspace tests with `--locked`, the dependency-direction and
|
||||
engine-independence gates, the Windows
|
||||
cross-target compile gate and a release build of both binaries. The strict OS-isolation lane
|
||||
requires the disposable VM described in [docs/ci.md](docs/ci.md); a GitHub
|
||||
mirror is not used as the authoritative lane for this beta.
|
||||
|
||||
@@ -291,17 +295,18 @@ crates/marqdo-ir module/unit/function/statement IR, builtin table
|
||||
crates/marqdo-frontend heading scopes, mapping, inference, static calls
|
||||
crates/marqdo-foreign Python/Node one-shot kernel supervisor
|
||||
crates/marqdo-sandbox mode parsing + platform isolation detection
|
||||
crates/marqdo-plugin-abi C ABI v1 mirrors, manifest, artifacts, loader
|
||||
crates/marqdo-plugin-sdk Rust plugin SDK and entry macro
|
||||
crates/marqdo-host CapabilityHost, budgets, FS, foreign/plugin adapters, core resource kinds
|
||||
crates/marqdo-runtime tree-walk interpreter
|
||||
crates/marqdo-host-contract neutral Host trait, HostOp, context and runtime facts
|
||||
crates/marqdo-plugin-abi public C ABI v1 contract: layout, wire envelope, errors
|
||||
(the Rust SDK lives in cflmy/marqdo-plugin-sdk)
|
||||
crates/marqdo-host Native Host: capability, resources, OS, plugin loader/worker
|
||||
crates/marqdo-runtime tree-walk interpreter (depends only on the neutral contract)
|
||||
crates/marqdo-package marqdo.yaml / marqdo.lock / root discovery
|
||||
crates/cli CLI composition root (binary `marqdo`)
|
||||
include/ frozen plugin C ABI header
|
||||
spec/ normative language/format/ABI specs
|
||||
docs/ blueprint, ADRs, status, contributor guide
|
||||
examples/ runnable documents + multi-module + plugin demo
|
||||
tests/ conformance/negative corpus (see tests/README.md)
|
||||
tests/ conformance/negative corpus, embedding consumer and SDK fixture
|
||||
```
|
||||
|
||||
## Documentation index
|
||||
|
||||
@@ -18,6 +18,7 @@ marqdo-frontend = { workspace = true }
|
||||
marqdo-foreign = { workspace = true }
|
||||
marqdo-plugin-abi = { workspace = true }
|
||||
marqdo-host = { workspace = true }
|
||||
marqdo-host-contract = { workspace = true }
|
||||
marqdo-runtime = { workspace = true }
|
||||
marqdo-package = { workspace = true }
|
||||
marqdo-sandbox = { workspace = true }
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use marqdo_host::{Host, StdHost};
|
||||
use marqdo_host::StdHost;
|
||||
use marqdo_host_contract::Host;
|
||||
use marqdo_runtime::{run_with_limits, EvaluatedArg, MemoryLimits, RuntimeError, Value};
|
||||
use marqdo_sandbox::{PlatformCapabilities, SandboxMode, StrictOutcome};
|
||||
use marqdo_span::Span;
|
||||
@@ -270,12 +271,12 @@ fn load_plugin_into_host(
|
||||
.parent()
|
||||
.map(|parent| parent.to_path_buf())
|
||||
.unwrap_or_else(|| PathBuf::from("."));
|
||||
let manifest = marqdo_plugin_abi::PluginManifest::load(&manifest_path)
|
||||
let manifest = marqdo_host::plugin::PluginManifest::load(&manifest_path)
|
||||
.map_err(|error| format!("{}: {}", error.code, error.message))?;
|
||||
manifest
|
||||
.validate()
|
||||
.map_err(|error| format!("{}: {}", error.code, error.message))?;
|
||||
if manifest.plugin.kind == marqdo_plugin_abi::PluginKind::Native && !trusted {
|
||||
if manifest.plugin.kind == marqdo_host::plugin::PluginKind::Native && !trusted {
|
||||
return Err(format!(
|
||||
"loading `{}` in-process requires --trust-native-plugin; use `kind: worker` for crash isolation",
|
||||
manifest.plugin.name
|
||||
|
||||
@@ -274,7 +274,7 @@ pub fn execute(
|
||||
&& static_plugins
|
||||
.plugins
|
||||
.iter()
|
||||
.any(|plugin| plugin.kind == marqdo_plugin_abi::PluginKind::Native)
|
||||
.any(|plugin| plugin.kind == marqdo_host::plugin::PluginKind::Native)
|
||||
{
|
||||
return fail(
|
||||
stream,
|
||||
@@ -558,9 +558,9 @@ mod tests {
|
||||
base_dir: PathBuf::from("/fixtures/demo"),
|
||||
package: "demo.ext".into(),
|
||||
version: "0.1.0".into(),
|
||||
kind: marqdo_plugin_abi::PluginKind::Worker,
|
||||
kind: marqdo_host::plugin::PluginKind::Worker,
|
||||
manifest_sha256: format!("sha256:{}", "b".repeat(64)),
|
||||
artifact_target: marqdo_plugin_abi::HostTarget::current()
|
||||
artifact_target: marqdo_host::plugin::HostTarget::current()
|
||||
.triple()
|
||||
.to_string(),
|
||||
artifact_sha256: "a".repeat(64),
|
||||
|
||||
@@ -44,7 +44,7 @@ pub fn plugin_inspect(target: &Path, json: bool) -> i32 {
|
||||
.parent()
|
||||
.map(|parent| parent.to_path_buf())
|
||||
.unwrap_or_else(|| PathBuf::from("."));
|
||||
let manifest = match marqdo_plugin_abi::PluginManifest::load(&manifest_path) {
|
||||
let manifest = match marqdo_host::plugin::PluginManifest::load(&manifest_path) {
|
||||
Ok(manifest) => manifest,
|
||||
Err(error) => {
|
||||
report_plugin_error(&error, json);
|
||||
@@ -55,7 +55,7 @@ pub fn plugin_inspect(target: &Path, json: bool) -> i32 {
|
||||
report_plugin_error(&error, json);
|
||||
return 1;
|
||||
}
|
||||
let host_target = marqdo_plugin_abi::HostTarget::current();
|
||||
let host_target = marqdo_host::plugin::HostTarget::current();
|
||||
let artifact = match manifest.verify_artifact(&base_dir, &host_target) {
|
||||
Ok((path, artifact)) => {
|
||||
let abi = match manifest.abi_requirement() {
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
use std::collections::BTreeSet;
|
||||
use std::path::{Component, Path, PathBuf};
|
||||
|
||||
use marqdo_host::plugin::{HostTarget, PluginKind, PluginManifest};
|
||||
use marqdo_ir::callable::{CallableDescriptor, CallableId, CallableOrigin, CallableSignature};
|
||||
use marqdo_ir::SignatureKind;
|
||||
use marqdo_plugin_abi::{HostTarget, PluginKind, PluginManifest};
|
||||
use marqdo_span::Span;
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
|
||||
@@ -81,12 +81,12 @@ fn plugin_identity(extension: &ResolvedExtension) -> Result<LockedExtension, Pre
|
||||
),
|
||||
)
|
||||
})?;
|
||||
let manifest = marqdo_plugin_abi::PluginManifest::load(&extension.path)
|
||||
let manifest = marqdo_host::plugin::PluginManifest::load(&extension.path)
|
||||
.map_err(|error| PrepareError::option(error.code.clone(), error.message.clone()))?;
|
||||
manifest
|
||||
.validate()
|
||||
.map_err(|error| PrepareError::option(error.code.clone(), error.message.clone()))?;
|
||||
let host = marqdo_plugin_abi::HostTarget::current();
|
||||
let host = marqdo_host::plugin::HostTarget::current();
|
||||
let artifact = manifest
|
||||
.resolve_artifact(&host)
|
||||
.map_err(|error| PrepareError::option("ext.no_matching_artifact", error.message))?;
|
||||
@@ -161,7 +161,7 @@ fn provider_identity(extension: &ResolvedExtension) -> Result<LockedExtension, P
|
||||
format!("`{}` has no version", extension.path.display()),
|
||||
)
|
||||
})?;
|
||||
let target = marqdo_plugin_abi::HostTarget::current()
|
||||
let target = marqdo_host::plugin::HostTarget::current()
|
||||
.triple()
|
||||
.to_string();
|
||||
let artifacts = manifest
|
||||
@@ -293,7 +293,7 @@ fn kernel_identity(extension: &ResolvedExtension) -> Result<LockedExtension, Pre
|
||||
version: format!("wire:{wire_version}"),
|
||||
manifest_digest: hex(&Sha256::digest(&manifest_bytes)),
|
||||
artifact_digest: digest.to_ascii_lowercase(),
|
||||
selected_target: marqdo_plugin_abi::HostTarget::current()
|
||||
selected_target: marqdo_host::plugin::HostTarget::current()
|
||||
.triple()
|
||||
.to_string(),
|
||||
source: extension.from.clone(),
|
||||
|
||||
@@ -500,7 +500,7 @@ fn dispatch() -> i32 {
|
||||
},
|
||||
Command::External(args) => tool::dispatch(&args),
|
||||
Command::PluginWorker(args) => {
|
||||
marqdo_plugin_abi::worker::serve(&args.manifest, &args.base_dir)
|
||||
marqdo_host::plugin::worker::serve(&args.manifest, &args.base_dir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ use std::rc::Rc;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use marqdo_host::{
|
||||
FrameId, ObservationConfig, ObservationError, ObservationEvent, ObservationSink,
|
||||
ParameterSource, ValueState, DEFAULT_MAX_OBSERVATION_BYTES, DEFAULT_MAX_OBSERVATION_EVENTS,
|
||||
DEFAULT_MAX_VALUE_BYTES,
|
||||
ObservationConfig, ObservationError, ObservationEvent, ObservationSink, ValueState,
|
||||
DEFAULT_MAX_OBSERVATION_BYTES, DEFAULT_MAX_OBSERVATION_EVENTS, DEFAULT_MAX_VALUE_BYTES,
|
||||
};
|
||||
use marqdo_host_contract::{FrameId, ParameterSource};
|
||||
use marqdo_value::Value;
|
||||
use serde_json::{json, Value as Json};
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use marqdo_host::plugin::{HostTarget, TargetTriple};
|
||||
use marqdo_host::StdHost;
|
||||
use marqdo_plugin_abi::{HostTarget, TargetTriple};
|
||||
use serde::Deserialize;
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
@@ -577,7 +577,7 @@ fn is_lowercase_sha256(value: &str) -> bool {
|
||||
}
|
||||
|
||||
fn is_known_capability(name: &str) -> bool {
|
||||
marqdo_plugin_abi::KNOWN_CAPABILITIES.contains(&name)
|
||||
marqdo_host::plugin::KNOWN_CAPABILITIES.contains(&name)
|
||||
}
|
||||
|
||||
/// A dotted vendor capability proposal (validation only, never a grant).
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
//! Architecture boundary gate (review RFC-CM P0/P1).
|
||||
//!
|
||||
//! These checks pin the documented layering: the runtime depends on the host
|
||||
//! platform layer, the bundled stdlib stays in this repository, `std:` import
|
||||
//! targets resolve only inside the bundle, and the host keeps the documented
|
||||
//! stdio/file/TCP resource endpoints. They are source and digest checks, not an
|
||||
//! OS-sandbox proof.
|
||||
//! These checks pin the documented layering: the engine depends on the neutral
|
||||
//! Host contract (never the native host), the plugin ABI contract carries no
|
||||
//! loader/worker execution side, the bundled stdlib stays in this repository,
|
||||
//! `std:` import targets resolve only inside the bundle, and the host keeps the
|
||||
//! documented stdio/file/TCP resource endpoints. They are source and digest
|
||||
//! checks, not an OS-sandbox proof; `tools/ci/check_dependency_boundaries.py`
|
||||
//! adds the Cargo-metadata graph gate.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@@ -23,66 +25,114 @@ fn read(path: &Path) -> String {
|
||||
std::fs::read_to_string(path).unwrap_or_else(|error| panic!("read {}: {error}", path.display()))
|
||||
}
|
||||
|
||||
const WORKSPACE_CRATES: &[&str] = &[
|
||||
"marqdo-span",
|
||||
"marqdo-value",
|
||||
"marqdo-expression",
|
||||
"marqdo-markdown",
|
||||
"marqdo-ir",
|
||||
"marqdo-frontend",
|
||||
"marqdo-foreign",
|
||||
"marqdo-plugin-abi",
|
||||
"marqdo-provider-worker",
|
||||
"marqdo-worker-ipc",
|
||||
"marqdo-plugin-sdk",
|
||||
"marqdo-host",
|
||||
"marqdo-runtime",
|
||||
"marqdo-package",
|
||||
"marqdo-sandbox",
|
||||
"cli",
|
||||
];
|
||||
|
||||
/// Issue #13 / ADR-0071: the reviewed responsibility allowlist is the crate
|
||||
/// table in the single current architecture overview, not a frozen count. A new
|
||||
/// crate must be added there (and to the dependency gate's reviewed map) in the
|
||||
/// same change.
|
||||
#[test]
|
||||
fn workspace_crates_match_the_documented_layers() {
|
||||
let manifest = read(&repo_root().join("Cargo.toml"));
|
||||
fn workspace_crates_are_documented_responsibilities() {
|
||||
let root = repo_root();
|
||||
let manifest = read(&root.join("Cargo.toml"));
|
||||
let members = manifest
|
||||
.split("members = [")
|
||||
.nth(1)
|
||||
.and_then(|rest| rest.split(']').next())
|
||||
.expect("workspace members");
|
||||
let names: Vec<&str> = members
|
||||
let names: Vec<String> = members
|
||||
.split(',')
|
||||
.map(|item| item.trim().trim_matches('"'))
|
||||
.filter(|item| !item.is_empty())
|
||||
.map(|member| {
|
||||
let directory = member
|
||||
.strip_prefix("crates/")
|
||||
.expect("workspace members are crates/<name>");
|
||||
let manifest = read(&root.join(member).join("Cargo.toml"));
|
||||
manifest
|
||||
.lines()
|
||||
.find_map(|line| line.strip_prefix("name = "))
|
||||
.map(|name| name.trim().trim_matches('"').to_string())
|
||||
.unwrap_or_else(|| directory.to_string())
|
||||
})
|
||||
.collect();
|
||||
let expected: Vec<String> = WORKSPACE_CRATES
|
||||
.iter()
|
||||
.map(|name| format!("crates/{name}"))
|
||||
.collect();
|
||||
assert_eq!(
|
||||
names,
|
||||
expected.iter().map(String::as_str).collect::<Vec<_>>(),
|
||||
"workspace members drifted; update docs/architecture/CURRENT.md with the layer"
|
||||
);
|
||||
let current = read(&root.join("docs/architecture/CURRENT.md"));
|
||||
let responsibilities = current
|
||||
.split("## Workspace crate responsibility map")
|
||||
.nth(1)
|
||||
.expect("CURRENT.md must own the reviewed crate responsibility map")
|
||||
.split("\n## ")
|
||||
.next()
|
||||
.unwrap_or("");
|
||||
for name in &names {
|
||||
assert!(
|
||||
responsibilities.contains(&format!("`{name}`")),
|
||||
"workspace crate `{name}` has no documented responsibility in CURRENT.md"
|
||||
);
|
||||
}
|
||||
for name in [
|
||||
"marqdo-host-contract",
|
||||
"marqdo-host",
|
||||
"marqdo-plugin-abi",
|
||||
"marqdo-cli",
|
||||
] {
|
||||
assert!(
|
||||
names.iter().any(|crate_name| crate_name == name),
|
||||
"required layer crate `{name}` is missing from the workspace"
|
||||
);
|
||||
}
|
||||
assert!(
|
||||
!names.contains(&"crates/marqdo-stdlib"),
|
||||
"the stdlib must stay in this repository (ADR-0039), not become a crate"
|
||||
!names.iter().any(|name| name == "marqdo-stdlib"),
|
||||
"the stdlib is a Bundle input, not a workspace crate (ADR-0039/ADR-0070)"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_depends_on_the_host_platform_layer_without_a_cycle() {
|
||||
let runtime = read(&repo_root().join("crates/marqdo-runtime/Cargo.toml"));
|
||||
fn engine_depends_on_the_neutral_host_contract_only() {
|
||||
let root = repo_root();
|
||||
let runtime = read(&root.join("crates/marqdo-runtime/Cargo.toml"));
|
||||
let runtime_dependencies = runtime
|
||||
.split("[dependencies]")
|
||||
.nth(1)
|
||||
.expect("runtime dependencies")
|
||||
.split("[dev-dependencies]")
|
||||
.next()
|
||||
.expect("runtime normal dependencies");
|
||||
assert!(
|
||||
runtime
|
||||
runtime_dependencies
|
||||
.lines()
|
||||
.any(|line| line.trim() == "marqdo-host-contract = { workspace = true }"),
|
||||
"runtime must depend on the neutral marqdo-host-contract crate"
|
||||
);
|
||||
assert!(
|
||||
!runtime_dependencies
|
||||
.lines()
|
||||
.any(|line| line.trim() == "marqdo-host = { workspace = true }"),
|
||||
"runtime must keep the documented marqdo-runtime -> marqdo-host direction"
|
||||
"runtime normal/build dependencies must not link the native host"
|
||||
);
|
||||
let host = read(&repo_root().join("crates/marqdo-host/Cargo.toml"));
|
||||
let contract = read(&root.join("crates/marqdo-host-contract/Cargo.toml"));
|
||||
let contract_deps: Vec<&str> = contract
|
||||
.split("[dependencies]")
|
||||
.nth(1)
|
||||
.expect("contract dependencies")
|
||||
.lines()
|
||||
.filter_map(|line| line.split('=').next())
|
||||
.map(str::trim)
|
||||
.filter(|name| !name.is_empty() && !name.starts_with('['))
|
||||
.collect();
|
||||
assert_eq!(
|
||||
contract_deps,
|
||||
["marqdo-span", "marqdo-value"],
|
||||
"the host contract must stay platform neutral (value/span only)"
|
||||
);
|
||||
let host = read(&root.join("crates/marqdo-host/Cargo.toml"));
|
||||
for forbidden in ["marqdo-runtime", "marqdo-frontend", "marqdo-ir ="] {
|
||||
assert!(
|
||||
!host.contains(forbidden),
|
||||
"the native host must not depend back on `{forbidden}`"
|
||||
);
|
||||
}
|
||||
assert!(
|
||||
!host.contains("marqdo-runtime"),
|
||||
"marqdo-host must not depend back on marqdo-runtime"
|
||||
host.contains("marqdo-host-contract = { workspace = true }"),
|
||||
"the native host must implement the neutral contract crate"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -153,7 +203,6 @@ fn shared_worker_transport_is_neutral_and_not_duplicated() {
|
||||
}
|
||||
for user in [
|
||||
"crates/marqdo-host/Cargo.toml",
|
||||
"crates/marqdo-plugin-abi/Cargo.toml",
|
||||
"crates/marqdo-provider-worker/Cargo.toml",
|
||||
] {
|
||||
assert!(
|
||||
@@ -164,8 +213,8 @@ fn shared_worker_transport_is_neutral_and_not_duplicated() {
|
||||
// The four-byte length prefix and its bounds live in exactly one crate.
|
||||
for private in [
|
||||
"crates/marqdo-host/src/plugin_worker.rs",
|
||||
"crates/marqdo-host/src/plugin/worker.rs",
|
||||
"crates/marqdo-host/src/provider_worker.rs",
|
||||
"crates/marqdo-plugin-abi/src/worker.rs",
|
||||
"crates/marqdo-provider-worker/src/main.rs",
|
||||
] {
|
||||
let text = read(&root.join(private));
|
||||
@@ -409,12 +458,12 @@ fn builtin_names_and_aliases_are_reviewed() {
|
||||
}
|
||||
|
||||
// Exhaustive matches make a new HostOp or Value variant require review under ADR-0064.
|
||||
const _: fn(marqdo_host::HostOp) = |operation| match operation {
|
||||
marqdo_host::HostOp::ForeignRun
|
||||
| marqdo_host::HostOp::ForeignCall
|
||||
| marqdo_host::HostOp::FsRead
|
||||
| marqdo_host::HostOp::FsWrite
|
||||
| marqdo_host::HostOp::PluginInvoke => (),
|
||||
const _: fn(marqdo_host_contract::HostOp) = |operation| match operation {
|
||||
marqdo_host_contract::HostOp::ForeignRun
|
||||
| marqdo_host_contract::HostOp::ForeignCall
|
||||
| marqdo_host_contract::HostOp::FsRead
|
||||
| marqdo_host_contract::HostOp::FsWrite
|
||||
| marqdo_host_contract::HostOp::PluginInvoke => (),
|
||||
};
|
||||
|
||||
const _: fn(marqdo_value::Value) = |value| match value {
|
||||
@@ -565,6 +614,133 @@ fn domain_math_kernel_is_not_part_of_the_core() {
|
||||
}
|
||||
}
|
||||
|
||||
/// E02/E03: there is exactly one Host trait/HostOp definition and it belongs to
|
||||
/// the neutral contract; the native host only implements it.
|
||||
#[test]
|
||||
fn host_contract_is_the_single_side_effect_interface() {
|
||||
let root = repo_root();
|
||||
let mut host_traits = Vec::new();
|
||||
let mut host_ops = Vec::new();
|
||||
for source in walk_rs(&root.join("crates")) {
|
||||
let relative = source
|
||||
.strip_prefix(&root)
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
if relative.contains("/tests/") {
|
||||
continue;
|
||||
}
|
||||
let text = read(&source);
|
||||
if text.contains("pub trait Host {") {
|
||||
host_traits.push(relative.clone());
|
||||
}
|
||||
if text.contains("pub enum HostOp {") {
|
||||
host_ops.push(relative);
|
||||
}
|
||||
}
|
||||
assert_eq!(
|
||||
host_traits,
|
||||
["crates/marqdo-host-contract/src/host.rs"],
|
||||
"the Host trait must be defined once in the neutral contract"
|
||||
);
|
||||
assert_eq!(
|
||||
host_ops,
|
||||
["crates/marqdo-host-contract/src/host.rs"],
|
||||
"HostOp must be defined once in the neutral contract"
|
||||
);
|
||||
let runtime = read(&root.join("crates/marqdo-runtime/src/interpreter.rs"));
|
||||
assert!(
|
||||
runtime.contains("use marqdo_host_contract::{"),
|
||||
"the interpreter must consume the neutral contract"
|
||||
);
|
||||
let host = read(&root.join("crates/marqdo-host/src/host.rs"));
|
||||
assert!(
|
||||
host.contains("impl Host for StdHost"),
|
||||
"StdHost remains the single native host implementation"
|
||||
);
|
||||
}
|
||||
|
||||
/// A05/S01: the public ABI crate is a contract, not a loader; execution side
|
||||
/// lives in the native host and the SDK consumes only the contract.
|
||||
#[test]
|
||||
fn plugin_contract_carries_no_native_execution() {
|
||||
let root = repo_root();
|
||||
let abi = read(&root.join("crates/marqdo-plugin-abi/Cargo.toml"));
|
||||
for forbidden in ["libloading", "marqdo-worker-ipc", "serde_yaml", "sha2"] {
|
||||
assert!(
|
||||
!abi.contains(forbidden),
|
||||
"marqdo-plugin-abi must not depend on execution-side `{forbidden}`"
|
||||
);
|
||||
}
|
||||
for module in ["loader", "worker", "manifest", "artifact"] {
|
||||
assert!(
|
||||
!root
|
||||
.join(format!("crates/marqdo-plugin-abi/src/{module}.rs"))
|
||||
.exists(),
|
||||
"`{module}` is execution-side and belongs to the native host"
|
||||
);
|
||||
}
|
||||
for module in ["loader", "worker", "manifest", "artifact"] {
|
||||
assert!(
|
||||
root.join(format!("crates/marqdo-host/src/plugin/{module}.rs"))
|
||||
.exists(),
|
||||
"native host must own plugin `{module}`"
|
||||
);
|
||||
}
|
||||
// ADR-0072: the SDK is an independent repository pinned to a contract
|
||||
// revision. It must not be reintroduced as a second in-workspace copy.
|
||||
assert!(
|
||||
!root.join("crates/marqdo-plugin-sdk").exists(),
|
||||
"the plugin SDK moved to cflmy/marqdo-plugin-sdk (ADR-0072)"
|
||||
);
|
||||
let manifest = read(&root.join("Cargo.toml"));
|
||||
assert!(
|
||||
!manifest.contains("marqdo-plugin-sdk"),
|
||||
"the plugin SDK must not return as a CLI workspace member"
|
||||
);
|
||||
let current = read(&root.join("docs/architecture/CURRENT.md"));
|
||||
assert!(
|
||||
current.contains("cflmy/marqdo-plugin-sdk") && current.contains("ADR-0072"),
|
||||
"CURRENT.md must name the independent SDK repository decision"
|
||||
);
|
||||
}
|
||||
|
||||
/// E01/E04: the independent embedding consumer is a real package outside the
|
||||
/// workspace and depends only on engine crates.
|
||||
#[test]
|
||||
fn embedding_consumer_is_engine_only() {
|
||||
let root = repo_root();
|
||||
let consumer = read(&root.join("tests/embedding/Cargo.toml"));
|
||||
assert!(
|
||||
consumer.contains("[workspace]"),
|
||||
"the embedding consumer must be its own workspace to avoid feature unification"
|
||||
);
|
||||
assert!(
|
||||
consumer.contains("marqdo-runtime"),
|
||||
"the embedding consumer must execute through the real runtime"
|
||||
);
|
||||
for forbidden in [
|
||||
"marqdo-host",
|
||||
"marqdo-cli",
|
||||
"marqdo-sandbox",
|
||||
"marqdo-foreign",
|
||||
] {
|
||||
let dependency_line = format!("\n{forbidden} =");
|
||||
assert!(
|
||||
!consumer.contains(&dependency_line),
|
||||
"the embedding consumer must not depend on `{forbidden}`"
|
||||
);
|
||||
}
|
||||
assert!(
|
||||
root.join("tests/embedding/Cargo.lock").is_file(),
|
||||
"the independent consumer must pin its own lock file"
|
||||
);
|
||||
assert!(
|
||||
root.join("tools/ci/check_engine_boundary.py").is_file(),
|
||||
"the build-and-run engine gate must exist"
|
||||
);
|
||||
}
|
||||
|
||||
fn hex(bytes: &[u8]) -> String {
|
||||
let mut out = String::with_capacity(bytes.len() * 2);
|
||||
for byte in bytes {
|
||||
|
||||
@@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Output};
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
|
||||
use marqdo_plugin_abi::{sha256_file, HostTarget};
|
||||
use marqdo_host::plugin::{sha256_file, HostTarget};
|
||||
|
||||
static COUNTER: AtomicU32 = AtomicU32::new(0);
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use marqdo_host::{Capabilities, Host, StdHost};
|
||||
use marqdo_host::{Capabilities, StdHost};
|
||||
use marqdo_host_contract::Host;
|
||||
use marqdo_ir::{ModuleId, Program, ResolvedImport};
|
||||
use marqdo_runtime::{run, EvaluatedArg};
|
||||
use marqdo_sandbox::SandboxMode;
|
||||
|
||||
@@ -9,7 +9,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Output};
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
|
||||
use marqdo_plugin_abi::{sha256_file, HostTarget};
|
||||
use marqdo_host::plugin::{sha256_file, HostTarget};
|
||||
|
||||
static COUNTER: AtomicU32 = AtomicU32::new(0);
|
||||
|
||||
|
||||
@@ -783,7 +783,7 @@ fn lock_and_sync_locked_detect_dependency_tampering() {
|
||||
/// the Linux-only example manifest. This is what makes the integration test a
|
||||
/// real test on macOS/Windows rather than an accidental "no matching artifact".
|
||||
fn host_triple() -> String {
|
||||
marqdo_plugin_abi::artifact::current_target_triple()
|
||||
marqdo_host::plugin::artifact::current_target_triple()
|
||||
.as_str()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ fn native_plugin_is_fail_closed_in_event_mode() {
|
||||
let digest = hex::encode(sha2::Sha256::digest(fs::read(&artifact).unwrap()));
|
||||
let manifest = format!(
|
||||
"plugin:\n name: demo.solver\n version: 0.1.0\n abi: \"^1.0\"\n kind: native\n exports:\n - name: solver.add\n signature: \"($a: Int, $b: Int) -> Int\"\n requires:\n - math.compute\n artifacts:\n - target: {}\n file: solver.so\n sha256: \"{}\"\n",
|
||||
marqdo_plugin_abi::HostTarget::current().triple(),
|
||||
marqdo_host::plugin::HostTarget::current().triple(),
|
||||
digest
|
||||
);
|
||||
fs::write(plugin_dir.join("plugin.yaml"), manifest).unwrap();
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Output};
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
|
||||
use marqdo_plugin_abi::{sha256_file, HostTarget};
|
||||
use marqdo_host::plugin::{sha256_file, HostTarget};
|
||||
|
||||
static COUNTER: AtomicU32 = AtomicU32::new(0);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ use std::process::{Command, Output};
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use marqdo_plugin_abi::HostTarget;
|
||||
use marqdo_host::plugin::HostTarget;
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
const MARKER_ENV: &str = "MARQDO_TEST_PROVIDER_MARKER";
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "marqdo-host-contract"
|
||||
description = "Platform-neutral Host contract: the only side-effect boundary the runtime may know"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
[dependencies]
|
||||
marqdo-span = { workspace = true }
|
||||
marqdo-value = { workspace = true }
|
||||
File renamed without changes.
@@ -0,0 +1,194 @@
|
||||
//! The host boundary used by the interpreter and future frontends.
|
||||
//!
|
||||
//! The trait is implemented by the native CLI host, by the independent
|
||||
//! embedding/test host and by any future host. Implementations own effects,
|
||||
//! grants and budgets; the runtime only requests operations through this
|
||||
//! interface and never performs external I/O itself.
|
||||
|
||||
use marqdo_span::Span;
|
||||
use marqdo_value::{ErrorCategory, ResourceHandle, RuntimeError, Value};
|
||||
|
||||
use crate::context::ExecutionContext;
|
||||
use crate::observe::{FrameId, RuntimeObservation};
|
||||
use crate::resource::ResourceRead;
|
||||
|
||||
/// Host operations reachable from the language surface.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum HostOp {
|
||||
/// One-shot foreign execution.
|
||||
ForeignRun,
|
||||
/// Typed foreign call.
|
||||
ForeignCall,
|
||||
/// Read a project file.
|
||||
FsRead,
|
||||
/// Write a project file.
|
||||
FsWrite,
|
||||
/// Invoke a plugin export.
|
||||
PluginInvoke,
|
||||
}
|
||||
|
||||
impl HostOp {
|
||||
/// Stable operation name used in traces and diagnostics.
|
||||
pub const fn name(self) -> &'static str {
|
||||
match self {
|
||||
HostOp::ForeignRun => "foreign.run",
|
||||
HostOp::ForeignCall => "foreign.call",
|
||||
HostOp::FsRead => "fs.read",
|
||||
HostOp::FsWrite => "fs.write",
|
||||
HostOp::PluginInvoke => "plugin.invoke",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The host boundary used by the interpreter and future View/IDE frontends.
|
||||
pub trait Host {
|
||||
/// Invoke one operation with already-evaluated arguments.
|
||||
fn invoke(
|
||||
&mut self,
|
||||
op: HostOp,
|
||||
args: Vec<Value>,
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<Value, RuntimeError>;
|
||||
|
||||
/// Open a resource/stream by kind, descriptor and requested rights.
|
||||
///
|
||||
/// Default: unavailable. Only the standard host implements the first
|
||||
/// resource kinds (ADR-0025).
|
||||
fn resource_open(
|
||||
&mut self,
|
||||
_kind: &str,
|
||||
_descriptor: &str,
|
||||
_rights: &[String],
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<Value, RuntimeError> {
|
||||
Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceUnsupported,
|
||||
ctx.span,
|
||||
"this host does not provide resource streams",
|
||||
))
|
||||
}
|
||||
|
||||
/// Read up to `max_bytes` from a resource into host memory.
|
||||
fn resource_read(
|
||||
&mut self,
|
||||
_handle: ResourceHandle,
|
||||
_max_bytes: usize,
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<ResourceRead, RuntimeError> {
|
||||
Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceUnsupported,
|
||||
ctx.span,
|
||||
"this host does not provide resource streams",
|
||||
))
|
||||
}
|
||||
|
||||
/// Write bytes to a resource; returns the accepted count.
|
||||
fn resource_write(
|
||||
&mut self,
|
||||
_handle: ResourceHandle,
|
||||
_bytes: &[u8],
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<usize, RuntimeError> {
|
||||
Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceUnsupported,
|
||||
ctx.span,
|
||||
"this host does not provide resource streams",
|
||||
))
|
||||
}
|
||||
|
||||
/// Close a resource handle.
|
||||
fn resource_close(
|
||||
&mut self,
|
||||
_handle: ResourceHandle,
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<(), RuntimeError> {
|
||||
Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceUnsupported,
|
||||
ctx.span,
|
||||
"this host does not provide resource streams",
|
||||
))
|
||||
}
|
||||
|
||||
/// Accept one inbound TCP connection from a `tcp-listener` handle.
|
||||
///
|
||||
/// Default: unavailable. The standard host returns a new `Resource` in a
|
||||
/// recoverable `{ok,value}` map or `{ok:false,code:"tcp.timeout"}`.
|
||||
fn resource_accept(
|
||||
&mut self,
|
||||
_handle: ResourceHandle,
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<Value, RuntimeError> {
|
||||
Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceUnsupported,
|
||||
ctx.span,
|
||||
"this host does not provide tcp listeners",
|
||||
))
|
||||
}
|
||||
|
||||
/// Execute one non-streaming resource operation (ADR-0041).
|
||||
///
|
||||
/// Default: unavailable. The standard host implements the `fs.*` group;
|
||||
/// every call is capability-checked and project-mode only.
|
||||
fn resource_request(
|
||||
&mut self,
|
||||
_operation: &str,
|
||||
_args: Vec<Value>,
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<Value, RuntimeError> {
|
||||
Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceUnsupported,
|
||||
ctx.span,
|
||||
"this host does not provide resource operations",
|
||||
))
|
||||
}
|
||||
|
||||
/// Consume evaluation fuel.
|
||||
fn consume_fuel(&mut self, amount: u64, span: Option<Span>) -> Result<(), RuntimeError>;
|
||||
|
||||
/// Check call-stack depth.
|
||||
fn check_stack(&self, depth: usize, span: Option<Span>) -> Result<(), RuntimeError>;
|
||||
|
||||
/// Check the wall-clock deadline.
|
||||
fn check_deadline(&self, span: Option<Span>) -> Result<(), RuntimeError>;
|
||||
|
||||
/// Take the buffered program output.
|
||||
fn take_output(&mut self) -> Vec<u8>;
|
||||
|
||||
/// Whether the host has an installed observation sink.
|
||||
///
|
||||
/// The default host is inert; the interpreter uses this to skip building
|
||||
/// any observation event when there is no capture destination.
|
||||
fn observation_enabled(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// Announce a successfully bound call frame.
|
||||
///
|
||||
/// Returns the run-unique frame identity, or `None` when observation is
|
||||
/// disabled. Argument binding must have completed before this is called;
|
||||
/// a binding failure never produces a frame.
|
||||
fn observation_begin_frame(
|
||||
&mut self,
|
||||
_function_id: &str,
|
||||
_module_id: &str,
|
||||
_span: Option<Span>,
|
||||
) -> Result<Option<FrameId>, RuntimeError> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
/// Close a previously announced frame, including failure paths.
|
||||
fn observation_end_frame(
|
||||
&mut self,
|
||||
_frame_id: Option<FrameId>,
|
||||
_status: &str,
|
||||
_module_id: &str,
|
||||
_span: Option<Span>,
|
||||
) -> Result<(), RuntimeError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Emit one borrowed runtime observation event. Default: ignored.
|
||||
fn observe_runtime(&mut self, _event: RuntimeObservation<'_>) -> Result<(), RuntimeError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//! Platform-neutral Host contract.
|
||||
//!
|
||||
//! This crate owns the only side-effect interface the language engine knows:
|
||||
//! the [`Host`] trait, its [`HostOp`] surface, the per-call
|
||||
//! [`ExecutionContext`], the opaque resource read result and the runtime
|
||||
//! observation notifications. It is a Rust compile-time interface inside one
|
||||
//! codebase, not a wire protocol: there is no HTTP, RPC, C ABI or dynamic
|
||||
//! loading boundary here.
|
||||
//!
|
||||
//! The crate is deliberately neutral. It depends only on the language value
|
||||
//! and span types; it must never link the native host, the CLI, the sandbox,
|
||||
//! foreign kernels, the plugin loader or a project filesystem. Native and
|
||||
//! embedded hosts implement [`Host`] without re-implementing any language
|
||||
//! semantics. Authorization, budgets, resource identity and OS isolation stay
|
||||
//! owned by the trusted host implementation that consumes this contract.
|
||||
|
||||
pub mod context;
|
||||
pub mod host;
|
||||
pub mod observe;
|
||||
pub mod resource;
|
||||
|
||||
pub use context::ExecutionContext;
|
||||
pub use host::{Host, HostOp};
|
||||
pub use observe::{FrameId, LoopTransfer, ParameterSource, RuntimeObservation};
|
||||
pub use resource::ResourceRead;
|
||||
@@ -0,0 +1,118 @@
|
||||
//! Runtime observation facts shared by the interpreter and the host contract.
|
||||
//!
|
||||
//! Only the types the interpreter itself produces and hands to [`crate::Host`]
|
||||
//! live here. The host implementation keeps the concrete sink, redaction,
|
||||
//! encoding and budget state; the public Observation protocol remains the
|
||||
//! CLI's single producer. This module must not grow a second event vocabulary.
|
||||
|
||||
use marqdo_span::Span;
|
||||
use marqdo_value::Value;
|
||||
|
||||
/// Opaque run-scoped call-instance identity.
|
||||
///
|
||||
/// Not a function identity, not a source location and never a memory pointer.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct FrameId(pub u64);
|
||||
|
||||
impl FrameId {
|
||||
/// Stable wire form used by the public protocol (`f1`, `f2`, ...).
|
||||
pub fn as_wire(self) -> String {
|
||||
format!("f{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Where a bound parameter's value came from.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ParameterSource {
|
||||
/// Supplied by the caller (CLI `--arg` or a Marqdo call).
|
||||
Provided,
|
||||
/// Evaluated from the declared default expression.
|
||||
Default,
|
||||
}
|
||||
|
||||
impl ParameterSource {
|
||||
/// Stable wire name.
|
||||
pub const fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
ParameterSource::Provided => "provided",
|
||||
ParameterSource::Default => "default",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The action carried by a structured loop transfer observation.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum LoopTransfer {
|
||||
/// Exit the enclosing loop.
|
||||
Break,
|
||||
/// Proceed to the enclosing loop's next condition check.
|
||||
Continue,
|
||||
}
|
||||
|
||||
impl LoopTransfer {
|
||||
/// The event kind in Observation.
|
||||
pub fn event_kind(self) -> &'static str {
|
||||
match self {
|
||||
Self::Break => "control.break",
|
||||
Self::Continue => "control.continue",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Borrowed runtime notification accepted by [`crate::Host::observe_runtime`].
|
||||
///
|
||||
/// Value and control observations carry the owning call frame.
|
||||
#[derive(Debug)]
|
||||
pub enum RuntimeObservation<'a> {
|
||||
/// A local memory operation committed.
|
||||
Effect {
|
||||
operation: &'a str,
|
||||
module_id: &'a str,
|
||||
span: Option<Span>,
|
||||
},
|
||||
/// A `return` statement committed (before the call exits).
|
||||
Return {
|
||||
frame_id: Option<FrameId>,
|
||||
value_type: &'a str,
|
||||
module_id: &'a str,
|
||||
span: Option<Span>,
|
||||
},
|
||||
/// A branch condition evaluated.
|
||||
BranchEval {
|
||||
frame_id: Option<FrameId>,
|
||||
result: bool,
|
||||
module_id: &'a str,
|
||||
span: Option<Span>,
|
||||
},
|
||||
/// A loop condition evaluated.
|
||||
LoopIteration {
|
||||
frame_id: Option<FrameId>,
|
||||
decision: &'a str,
|
||||
module_id: &'a str,
|
||||
span: Option<Span>,
|
||||
},
|
||||
/// An explicit loop control statement executed.
|
||||
LoopTransfer {
|
||||
frame_id: Option<FrameId>,
|
||||
transfer: LoopTransfer,
|
||||
module_id: &'a str,
|
||||
span: Span,
|
||||
},
|
||||
/// A local variable assignment committed.
|
||||
VariableAssigned {
|
||||
frame_id: Option<FrameId>,
|
||||
name: &'a str,
|
||||
value: &'a Value,
|
||||
module_id: &'a str,
|
||||
span: Option<Span>,
|
||||
},
|
||||
/// A parameter was bound.
|
||||
ParameterBound {
|
||||
frame_id: Option<FrameId>,
|
||||
name: &'a str,
|
||||
source: ParameterSource,
|
||||
value: &'a Value,
|
||||
module_id: &'a str,
|
||||
span: Option<Span>,
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//! Values crossing the resource stream methods of [`crate::Host`].
|
||||
|
||||
/// Bytes returned by one stream read.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ResourceRead {
|
||||
/// Bytes actually read (may be empty at EOF).
|
||||
pub bytes: Vec<u8>,
|
||||
/// Whether the stream has reached EOF.
|
||||
pub eof: bool,
|
||||
}
|
||||
@@ -12,6 +12,7 @@ authors.workspace = true
|
||||
libloading = { workspace = true }
|
||||
rustls = { workspace = true }
|
||||
rustls-native-certs = { workspace = true }
|
||||
marqdo-host-contract = { workspace = true }
|
||||
marqdo-plugin-abi = { workspace = true }
|
||||
marqdo-worker-ipc = { workspace = true }
|
||||
flate2 = { workspace = true }
|
||||
@@ -23,6 +24,9 @@ marqdo-value = { workspace = true }
|
||||
marqdo-foreign = { workspace = true }
|
||||
marqdo-sandbox = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
sha2 = { workspace = true }
|
||||
hex = { workspace = true }
|
||||
serde_yaml = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
|
||||
+15
-194
@@ -9,27 +9,30 @@ use std::net::{TcpListener, TcpStream, ToSocketAddrs, UdpSocket};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Duration;
|
||||
|
||||
use marqdo_plugin_abi::{
|
||||
ErrorKind as PluginErrorKind, LoadedPlugin, PluginError, PluginKind, PluginManifest,
|
||||
use crate::plugin::{
|
||||
CapabilityHandler, HostTarget, LoadOptions, LoadedPlugin, PluginKind, PluginManifest,
|
||||
};
|
||||
use marqdo_host_contract::{
|
||||
ExecutionContext, FrameId, Host, HostOp, ResourceRead, RuntimeObservation,
|
||||
};
|
||||
use marqdo_plugin_abi::{ErrorKind as PluginErrorKind, PluginError};
|
||||
use marqdo_span::Span;
|
||||
use marqdo_value::{ErrorCategory, ResourceHandle, RuntimeError, Value};
|
||||
use rustls::pki_types::CertificateDer;
|
||||
|
||||
use crate::budget::Budget;
|
||||
use crate::capability::{Capabilities, CapabilityAudit, CapabilityBroker};
|
||||
use crate::context::ExecutionContext;
|
||||
use crate::fs::ProjectFs;
|
||||
use crate::handles::{contains_plugin_handle, PluginHandleTable};
|
||||
use crate::observe::{
|
||||
encode_value, estimate_event_bytes, FrameId, ObservationConfig, ObservationError,
|
||||
ObservationEvent, ObservationSink, ObservationState, RuntimeObservation,
|
||||
encode_value, estimate_event_bytes, ObservationConfig, ObservationError, ObservationEvent,
|
||||
ObservationSink, ObservationState,
|
||||
};
|
||||
use crate::plugin_worker::WorkerPlugin;
|
||||
use crate::provider_c::{load_package, CResourceProvider};
|
||||
use crate::provider_worker::WorkerResourceProvider;
|
||||
use crate::resource::{
|
||||
is_core_resource_kind, ResourceProvider, ResourceRead, ResourceTable, SharedResourceProvider,
|
||||
is_core_resource_kind, ResourceProvider, ResourceTable, SharedResourceProvider,
|
||||
};
|
||||
use marqdo_sandbox::{PlatformCapabilities, SandboxMode};
|
||||
|
||||
@@ -38,187 +41,6 @@ mod providers;
|
||||
mod resource_ops;
|
||||
mod resource_requests;
|
||||
|
||||
/// Host operations reachable from the language surface.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum HostOp {
|
||||
/// One-shot foreign execution.
|
||||
ForeignRun,
|
||||
/// Typed foreign call.
|
||||
ForeignCall,
|
||||
/// Read a project file.
|
||||
FsRead,
|
||||
/// Write a project file.
|
||||
FsWrite,
|
||||
/// Invoke a plugin export.
|
||||
PluginInvoke,
|
||||
}
|
||||
|
||||
impl HostOp {
|
||||
/// Stable operation name used in traces and diagnostics.
|
||||
pub const fn name(self) -> &'static str {
|
||||
match self {
|
||||
HostOp::ForeignRun => "foreign.run",
|
||||
HostOp::ForeignCall => "foreign.call",
|
||||
HostOp::FsRead => "fs.read",
|
||||
HostOp::FsWrite => "fs.write",
|
||||
HostOp::PluginInvoke => "plugin.invoke",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The host boundary used by the interpreter and future View/IDE frontends.
|
||||
pub trait Host {
|
||||
/// Invoke one operation with already-evaluated arguments.
|
||||
fn invoke(
|
||||
&mut self,
|
||||
op: HostOp,
|
||||
args: Vec<Value>,
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<Value, RuntimeError>;
|
||||
|
||||
/// Open a resource/stream by kind, descriptor and requested rights.
|
||||
///
|
||||
/// Default: unavailable. Only the standard host implements the first
|
||||
/// resource kinds (ADR-0025).
|
||||
fn resource_open(
|
||||
&mut self,
|
||||
_kind: &str,
|
||||
_descriptor: &str,
|
||||
_rights: &[String],
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<Value, RuntimeError> {
|
||||
Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceUnsupported,
|
||||
ctx.span,
|
||||
"this host does not provide resource streams",
|
||||
))
|
||||
}
|
||||
|
||||
/// Read up to `max_bytes` from a resource into host memory.
|
||||
fn resource_read(
|
||||
&mut self,
|
||||
_handle: ResourceHandle,
|
||||
_max_bytes: usize,
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<ResourceRead, RuntimeError> {
|
||||
Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceUnsupported,
|
||||
ctx.span,
|
||||
"this host does not provide resource streams",
|
||||
))
|
||||
}
|
||||
|
||||
/// Write bytes to a resource; returns the accepted count.
|
||||
fn resource_write(
|
||||
&mut self,
|
||||
_handle: ResourceHandle,
|
||||
_bytes: &[u8],
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<usize, RuntimeError> {
|
||||
Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceUnsupported,
|
||||
ctx.span,
|
||||
"this host does not provide resource streams",
|
||||
))
|
||||
}
|
||||
|
||||
/// Close a resource handle.
|
||||
fn resource_close(
|
||||
&mut self,
|
||||
_handle: ResourceHandle,
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<(), RuntimeError> {
|
||||
Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceUnsupported,
|
||||
ctx.span,
|
||||
"this host does not provide resource streams",
|
||||
))
|
||||
}
|
||||
|
||||
/// Accept one inbound TCP connection from a `tcp-listener` handle.
|
||||
///
|
||||
/// Default: unavailable. The standard host returns a new `Resource` in a
|
||||
/// recoverable `{ok,value}` map or `{ok:false,code:"tcp.timeout"}`.
|
||||
fn resource_accept(
|
||||
&mut self,
|
||||
_handle: ResourceHandle,
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<Value, RuntimeError> {
|
||||
Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceUnsupported,
|
||||
ctx.span,
|
||||
"this host does not provide tcp listeners",
|
||||
))
|
||||
}
|
||||
|
||||
/// Execute one non-streaming resource operation (ADR-0041).
|
||||
///
|
||||
/// Default: unavailable. The standard host implements the `fs.*` group;
|
||||
/// every call is capability-checked and project-mode only.
|
||||
fn resource_request(
|
||||
&mut self,
|
||||
_operation: &str,
|
||||
_args: Vec<Value>,
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<Value, RuntimeError> {
|
||||
Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceUnsupported,
|
||||
ctx.span,
|
||||
"this host does not provide resource operations",
|
||||
))
|
||||
}
|
||||
|
||||
/// Consume evaluation fuel.
|
||||
fn consume_fuel(&mut self, amount: u64, span: Option<Span>) -> Result<(), RuntimeError>;
|
||||
|
||||
/// Check call-stack depth.
|
||||
fn check_stack(&self, depth: usize, span: Option<Span>) -> Result<(), RuntimeError>;
|
||||
|
||||
/// Check the wall-clock deadline.
|
||||
fn check_deadline(&self, span: Option<Span>) -> Result<(), RuntimeError>;
|
||||
|
||||
/// Take the buffered program output.
|
||||
fn take_output(&mut self) -> Vec<u8>;
|
||||
|
||||
/// Whether the host has an installed observation sink.
|
||||
///
|
||||
/// The default host is inert; the interpreter uses this to skip building
|
||||
/// any observation event when there is no capture destination.
|
||||
fn observation_enabled(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// Announce a successfully bound call frame.
|
||||
///
|
||||
/// Returns the run-unique frame identity, or `None` when observation is
|
||||
/// disabled. Argument binding must have completed before this is called;
|
||||
/// a binding failure never produces a frame.
|
||||
fn observation_begin_frame(
|
||||
&mut self,
|
||||
_function_id: &str,
|
||||
_module_id: &str,
|
||||
_span: Option<Span>,
|
||||
) -> Result<Option<FrameId>, RuntimeError> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
/// Close a previously announced frame, including failure paths.
|
||||
fn observation_end_frame(
|
||||
&mut self,
|
||||
_frame_id: Option<FrameId>,
|
||||
_status: &str,
|
||||
_module_id: &str,
|
||||
_span: Option<Span>,
|
||||
) -> Result<(), RuntimeError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Emit one borrowed runtime observation event. Default: ignored.
|
||||
fn observe_runtime(&mut self, _event: RuntimeObservation<'_>) -> Result<(), RuntimeError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Default capability host implementation.
|
||||
pub struct StdHost {
|
||||
/// Requested sandbox mode.
|
||||
@@ -372,7 +194,7 @@ impl StdHost {
|
||||
exports.insert(export.name.clone(), export.signature.clone());
|
||||
}
|
||||
let artifact = manifest
|
||||
.resolve_artifact(&marqdo_plugin_abi::HostTarget::current())
|
||||
.resolve_artifact(&HostTarget::current())
|
||||
.map_err(map_plugin_error)?;
|
||||
let manifest_digest = artifact.sha256.clone();
|
||||
let transport = match manifest.plugin.kind {
|
||||
@@ -398,8 +220,8 @@ impl StdHost {
|
||||
broker.allow_vendor(capability.clone());
|
||||
}
|
||||
let package = manifest.plugin.name.clone();
|
||||
let options = marqdo_plugin_abi::LoadOptions {
|
||||
host_target: marqdo_plugin_abi::HostTarget::current(),
|
||||
let options = LoadOptions {
|
||||
host_target: HostTarget::current(),
|
||||
capability_handler: Some(Box::new(move |capability, request| {
|
||||
broker.execute(&package, capability, request)
|
||||
})),
|
||||
@@ -419,10 +241,9 @@ impl StdHost {
|
||||
broker.allow_vendor(capability.clone());
|
||||
}
|
||||
let package = manifest.plugin.name.clone();
|
||||
let handler: marqdo_plugin_abi::CapabilityHandler =
|
||||
Box::new(move |capability, request| {
|
||||
broker.execute(&package, capability, request)
|
||||
});
|
||||
let handler: CapabilityHandler = Box::new(move |capability, request| {
|
||||
broker.execute(&package, capability, request)
|
||||
});
|
||||
PluginTransport::Worker(
|
||||
WorkerPlugin::spawn(manifest, base_dir, Some(handler))
|
||||
.map_err(map_plugin_error)?,
|
||||
|
||||
@@ -11,8 +11,8 @@ use std::time::Duration;
|
||||
|
||||
use marqdo_value::{to_wire, ErrorCategory, RuntimeError, Value};
|
||||
|
||||
use crate::context::ExecutionContext;
|
||||
use crate::host::{HostOp, StdHost};
|
||||
use crate::host::StdHost;
|
||||
use marqdo_host_contract::{ExecutionContext, HostOp};
|
||||
|
||||
pub(crate) fn foreign(
|
||||
host: &mut StdHost,
|
||||
|
||||
@@ -1,17 +1,28 @@
|
||||
//! CapabilityHost: capability checks, resource budgets, observation and the
|
||||
//! only bridge to math, foreign kernels, files and plugins.
|
||||
//! Native Host: the one concrete implementation of the neutral
|
||||
//! [`marqdo_host_contract::Host`] boundary.
|
||||
//!
|
||||
//! Blueprint §9 and §7.3: every side effect goes through this boundary, checks
|
||||
//! happen at the point of execution, and host failures are structured errors.
|
||||
//! Every side effect goes through this crate, checks happen at the point of
|
||||
//! execution, and host failures are structured errors. The crate owns the OS
|
||||
//! adapters, capability grants, resource handles, observation sink and trusted
|
||||
//! extension execution; it never owns language semantics and never depends back
|
||||
//! on the runtime, frontend or IR.
|
||||
//!
|
||||
//! Responsibility map (ADR-0071):
|
||||
//! - [`capability`]/[`budget`]: grants, broker, audit, fuel/stack/deadline/output;
|
||||
//! - [`resource`], [`fs`], `process`: resource kinds, handles and OS effects;
|
||||
//! - [`plugin`], `plugin_worker`, `provider_c`, `provider_worker`, [`kernels`]:
|
||||
//! trusted plugin/provider/foreign execution (no second static binder);
|
||||
//! - [`observe`]: the runtime observation sink, redaction, budget and encoding;
|
||||
//! - [`host`]: `StdHost` assembly and the single dispatch table.
|
||||
|
||||
pub mod budget;
|
||||
pub mod capability;
|
||||
pub mod context;
|
||||
pub mod fs;
|
||||
pub mod handles;
|
||||
pub mod host;
|
||||
pub mod kernels;
|
||||
pub mod observe;
|
||||
pub mod plugin;
|
||||
mod plugin_worker;
|
||||
mod process;
|
||||
mod provider_c;
|
||||
@@ -23,18 +34,16 @@ pub use capability::{
|
||||
Capabilities, CapabilityAudit, CapabilityBroker, CapabilityHandler, CapabilityRequest,
|
||||
FsReadHandler, CORE_CAPABILITIES, RESERVED_HANDLER_PREFIXES,
|
||||
};
|
||||
pub use context::ExecutionContext;
|
||||
pub use fs::ProjectFs;
|
||||
pub use handles::{contains_plugin_handle, PluginHandleTable};
|
||||
pub use host::{arity, expect_text, Host, HostOp, StdHost};
|
||||
pub use host::{arity, expect_text, StdHost};
|
||||
pub use marqdo_sandbox::{PlatformCapabilities, SandboxMode, StrictIsolation};
|
||||
pub use observe::{
|
||||
encode_value, estimate_event_bytes, FrameId, LoopTransfer, ObservationConfig, ObservationError,
|
||||
ObservationEvent, ObservationSink, ObservedValue, ParameterSource, RuntimeObservation,
|
||||
ValueState, DEFAULT_MAX_OBSERVATION_BYTES, DEFAULT_MAX_OBSERVATION_EVENTS,
|
||||
DEFAULT_MAX_VALUE_BYTES, MAX_STREAM_CHUNK_BYTES,
|
||||
encode_value, estimate_event_bytes, ObservationConfig, ObservationError, ObservationEvent,
|
||||
ObservationSink, ObservedValue, ValueState, DEFAULT_MAX_OBSERVATION_BYTES,
|
||||
DEFAULT_MAX_OBSERVATION_EVENTS, DEFAULT_MAX_VALUE_BYTES, MAX_STREAM_CHUNK_BYTES,
|
||||
};
|
||||
pub use resource::{
|
||||
is_core_resource_kind, ResourceProvider, ResourceRead, ResourceTable, SharedResourceProvider,
|
||||
is_core_resource_kind, ResourceProvider, ResourceTable, SharedResourceProvider,
|
||||
CORE_RESOURCE_KINDS,
|
||||
};
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use marqdo_host_contract::{FrameId, LoopTransfer, ParameterSource};
|
||||
use marqdo_span::Span;
|
||||
use marqdo_value::{ErrorCategory, RuntimeError, Value};
|
||||
|
||||
@@ -24,38 +25,6 @@ pub const DEFAULT_MAX_VALUE_BYTES: usize = 256;
|
||||
/// Maximum committed stdio bytes carried by one chunk event.
|
||||
pub const MAX_STREAM_CHUNK_BYTES: usize = 64 * 1024;
|
||||
|
||||
/// Opaque run-scoped call-instance identity.
|
||||
///
|
||||
/// Not a function identity, not a source location and never a memory pointer.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct FrameId(pub u64);
|
||||
|
||||
impl FrameId {
|
||||
/// Stable wire form used by the public protocol (`f1`, `f2`, ...).
|
||||
pub fn as_wire(self) -> String {
|
||||
format!("f{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Where a bound parameter's value came from.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ParameterSource {
|
||||
/// Supplied by the caller (CLI `--arg` or a Marqdo call).
|
||||
Provided,
|
||||
/// Evaluated from the declared default expression.
|
||||
Default,
|
||||
}
|
||||
|
||||
impl ParameterSource {
|
||||
/// Stable wire name.
|
||||
pub const fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
ParameterSource::Provided => "provided",
|
||||
ParameterSource::Default => "default",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Observation policy for one run.
|
||||
///
|
||||
/// `structural` always implies frame identity; value events only exist for
|
||||
@@ -238,83 +207,6 @@ pub enum ObservationEvent<'a> {
|
||||
},
|
||||
}
|
||||
|
||||
/// The action carried by a structured loop transfer observation.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum LoopTransfer {
|
||||
/// Exit the enclosing loop.
|
||||
Break,
|
||||
/// Proceed to the enclosing loop's next condition check.
|
||||
Continue,
|
||||
}
|
||||
|
||||
impl LoopTransfer {
|
||||
/// The event kind in Observation.
|
||||
pub fn event_kind(self) -> &'static str {
|
||||
match self {
|
||||
Self::Break => "control.break",
|
||||
Self::Continue => "control.continue",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Borrowed runtime notification accepted by [`crate::Host::observe_runtime`].
|
||||
///
|
||||
/// Value and control observations carry the owning call frame.
|
||||
#[derive(Debug)]
|
||||
pub enum RuntimeObservation<'a> {
|
||||
/// A local memory operation committed.
|
||||
Effect {
|
||||
operation: &'a str,
|
||||
module_id: &'a str,
|
||||
span: Option<Span>,
|
||||
},
|
||||
/// A `return` statement committed (before the call exits).
|
||||
Return {
|
||||
frame_id: Option<FrameId>,
|
||||
value_type: &'a str,
|
||||
module_id: &'a str,
|
||||
span: Option<Span>,
|
||||
},
|
||||
/// A branch condition evaluated.
|
||||
BranchEval {
|
||||
frame_id: Option<FrameId>,
|
||||
result: bool,
|
||||
module_id: &'a str,
|
||||
span: Option<Span>,
|
||||
},
|
||||
/// A loop condition evaluated.
|
||||
LoopIteration {
|
||||
frame_id: Option<FrameId>,
|
||||
decision: &'a str,
|
||||
module_id: &'a str,
|
||||
span: Option<Span>,
|
||||
},
|
||||
/// An explicit loop control statement executed.
|
||||
LoopTransfer {
|
||||
frame_id: Option<FrameId>,
|
||||
transfer: LoopTransfer,
|
||||
module_id: &'a str,
|
||||
span: Span,
|
||||
},
|
||||
/// A local variable assignment committed.
|
||||
VariableAssigned {
|
||||
frame_id: Option<FrameId>,
|
||||
name: &'a str,
|
||||
value: &'a Value,
|
||||
module_id: &'a str,
|
||||
span: Option<Span>,
|
||||
},
|
||||
/// A parameter was bound.
|
||||
ParameterBound {
|
||||
frame_id: Option<FrameId>,
|
||||
name: &'a str,
|
||||
source: ParameterSource,
|
||||
value: &'a Value,
|
||||
module_id: &'a str,
|
||||
span: Option<Span>,
|
||||
},
|
||||
}
|
||||
|
||||
/// Sink installed by the composition root (the CLI JSONL writer in product
|
||||
/// builds, an in-memory recorder in tests).
|
||||
pub trait ObservationSink {
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ use std::path::Path;
|
||||
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
use crate::error::PluginError;
|
||||
use marqdo_plugin_abi::PluginError;
|
||||
|
||||
/// Length of a lowercase hexadecimal sha256 digest.
|
||||
pub const SHA256_HEX_LEN: usize = 64;
|
||||
@@ -16,16 +16,16 @@ use std::ptr;
|
||||
use libloading::{Library, Symbol};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::abi::{
|
||||
use super::artifact::HostTarget;
|
||||
use super::manifest::{PluginKind, PluginManifest};
|
||||
use marqdo_plugin_abi::abi::{
|
||||
check_host_api, negotiate, result, AbiVersion, MqBytes, MqCallContext, MqHostApi, MqOwnedBytes,
|
||||
MqPluginApi, MqPluginEntryV1, MqPluginInvoke, PluginMetadata, ABI_MAJOR, ABI_MINOR,
|
||||
ENTRY_SYMBOL, MAX_CAPABILITY_REPLY_BYTES, MAX_ERROR_WIRE_BYTES, MAX_EXPORT_NAME_BYTES,
|
||||
MAX_RESULT_WIRE_BYTES, MAX_SIGNATURE_WIRE_BYTES,
|
||||
};
|
||||
use crate::artifact::HostTarget;
|
||||
use crate::error::PluginError;
|
||||
use crate::manifest::{PluginKind, PluginManifest};
|
||||
use crate::wire::{WireRequest, WireResponse};
|
||||
use marqdo_plugin_abi::wire::{WireRequest, WireResponse};
|
||||
use marqdo_plugin_abi::PluginError;
|
||||
|
||||
/// A callback the host installs to answer capability requests from a plugin.
|
||||
///
|
||||
@@ -304,13 +304,13 @@ impl LoadedPlugin {
|
||||
/// This is primarily for ABI conformance tests; prefer
|
||||
/// [`LoadedPlugin::invoke`] for normal use.
|
||||
pub fn invoke_raw(&mut self, function: &str, args_wire: &[u8]) -> Result<Vec<u8>, PluginError> {
|
||||
if args_wire.len() > crate::abi::MAX_REQUEST_WIRE_BYTES {
|
||||
if args_wire.len() > marqdo_plugin_abi::abi::MAX_REQUEST_WIRE_BYTES {
|
||||
return Err(PluginError::wire(
|
||||
"request_too_large",
|
||||
format!(
|
||||
"request wire is {} bytes, limit is {}",
|
||||
args_wire.len(),
|
||||
crate::abi::MAX_REQUEST_WIRE_BYTES
|
||||
marqdo_plugin_abi::abi::MAX_REQUEST_WIRE_BYTES
|
||||
),
|
||||
));
|
||||
}
|
||||
+6
-6
@@ -10,12 +10,12 @@ use std::path::{Component, Path, PathBuf};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::abi::{
|
||||
use super::artifact::{is_valid_sha256_hex, TargetTriple};
|
||||
use super::artifact::{verify_sha256_file, HostTarget};
|
||||
use marqdo_plugin_abi::abi::{
|
||||
AbiVersion, ABI_MAJOR, ABI_MINOR, MAX_EXPORT_NAME_BYTES, MAX_SIGNATURE_WIRE_BYTES,
|
||||
};
|
||||
use crate::artifact::{is_valid_sha256_hex, TargetTriple};
|
||||
use crate::artifact::{verify_sha256_file, HostTarget};
|
||||
use crate::error::PluginError;
|
||||
use marqdo_plugin_abi::PluginError;
|
||||
|
||||
/// Maximum number of exports a single plugin may register.
|
||||
pub const MAX_EXPORTS: usize = 256;
|
||||
@@ -648,7 +648,7 @@ plugin:
|
||||
#[test]
|
||||
fn malformed_yaml_is_rejected() {
|
||||
let error = PluginManifest::parse_str("plugin: [unclosed").expect_err("must fail");
|
||||
assert_eq!(error.kind, crate::error::ErrorKind::Manifest);
|
||||
assert_eq!(error.kind, marqdo_plugin_abi::ErrorKind::Manifest);
|
||||
assert_eq!(error.code, "manifest_parse_failed");
|
||||
assert!(PluginManifest::parse_str("not_a_plugin: 1").is_err());
|
||||
}
|
||||
@@ -683,7 +683,7 @@ plugin:
|
||||
),
|
||||
Err(error) => assert_eq!(
|
||||
error.kind,
|
||||
crate::error::ErrorKind::Manifest,
|
||||
marqdo_plugin_abi::ErrorKind::Manifest,
|
||||
"`{field}` = `{value}` should fail manifest handling"
|
||||
),
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//! Execution side of the Callable Plugin ABI: manifest/artifact validation,
|
||||
//! native loading, invocation dispatch and the worker process.
|
||||
//!
|
||||
//! The public contract (C layout, wire envelope and protocol errors) lives in
|
||||
//! `marqdo-plugin-abi`; this module owns `dlopen`, process spawning, artifact
|
||||
//! file selection and trusted invocation. The CLI may consume the static
|
||||
//! descriptor types for `check`/`inspect` preparation, but preparation never
|
||||
//! loads a library or starts a process.
|
||||
//!
|
||||
//! The `include/marqdo_plugin_abi_v1.h` header and the Rust layout assertions
|
||||
//! in `marqdo_plugin_abi::abi` remain the single ABI authority.
|
||||
|
||||
pub mod artifact;
|
||||
pub mod loader;
|
||||
pub mod manifest;
|
||||
pub mod worker;
|
||||
|
||||
pub use artifact::{
|
||||
current_target_triple, is_valid_sha256_hex, sha256_bytes, sha256_file, verify_sha256_file,
|
||||
HostTarget, TargetTriple,
|
||||
};
|
||||
pub use loader::{CapabilityHandler, LoadOptions, LoadedPlugin, RegisteredExport};
|
||||
pub use manifest::{
|
||||
AbiRequirement, Artifact, Export, PackageVersion, PluginInfo, PluginKind, PluginManifest,
|
||||
KNOWN_CAPABILITIES,
|
||||
};
|
||||
@@ -13,10 +13,10 @@ use std::sync::{Arc, Mutex};
|
||||
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use crate::error::PluginError;
|
||||
use crate::loader::{LoadOptions, LoadedPlugin};
|
||||
use crate::manifest::{PluginKind, PluginManifest};
|
||||
use crate::wire::{WireRequest, WireResponse};
|
||||
use super::loader::{LoadOptions, LoadedPlugin};
|
||||
use super::manifest::{PluginKind, PluginManifest};
|
||||
use marqdo_plugin_abi::wire::{WireRequest, WireResponse};
|
||||
use marqdo_plugin_abi::PluginError;
|
||||
|
||||
/// Hidden CLI command name used to start a worker.
|
||||
pub const WORKER_COMMAND: &str = "__plugin-worker";
|
||||
@@ -91,7 +91,7 @@ pub fn serve(manifest_path: &Path, base_dir: &Path) -> i32 {
|
||||
let handler_stdout = Arc::clone(&stdout);
|
||||
let handler_ids = Arc::clone(&next_request_id);
|
||||
let handler_calls = Arc::clone(&capability_calls);
|
||||
let capability_handler: crate::loader::CapabilityHandler = Box::new(
|
||||
let capability_handler: super::loader::CapabilityHandler = Box::new(
|
||||
move |capability, request| {
|
||||
if handler_calls.fetch_add(1, Ordering::SeqCst) >= MAX_CAPABILITY_REQUESTS {
|
||||
return Err(PluginError::capability(
|
||||
@@ -185,7 +185,7 @@ pub fn serve(manifest_path: &Path, base_dir: &Path) -> i32 {
|
||||
},
|
||||
);
|
||||
let options = LoadOptions {
|
||||
host_target: crate::artifact::HostTarget::current(),
|
||||
host_target: super::artifact::HostTarget::current(),
|
||||
capability_handler: Some(capability_handler),
|
||||
};
|
||||
let mut plugin = match LoadedPlugin::open_with(&native_manifest, base_dir, options) {
|
||||
@@ -15,13 +15,12 @@ use std::path::Path;
|
||||
use std::process::{Child, Command, Stdio};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use marqdo_plugin_abi::worker::{
|
||||
use crate::plugin::worker::{
|
||||
response_from_frame, MAX_CAPABILITY_REQUESTS, MAX_CAPABILITY_REQUEST_BYTES, MAX_FRAME_BYTES,
|
||||
WORKER_COMMAND,
|
||||
};
|
||||
use marqdo_plugin_abi::{
|
||||
CapabilityHandler, PluginError, PluginManifest, WireRequest, WireResponse,
|
||||
};
|
||||
use crate::plugin::{CapabilityHandler, PluginManifest};
|
||||
use marqdo_plugin_abi::{PluginError, WireRequest, WireResponse};
|
||||
use marqdo_worker_ipc::{Connection, FrameError, TransportError};
|
||||
use serde_json::json;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use std::time::{Duration, Instant};
|
||||
|
||||
use marqdo_value::{ErrorCategory, RuntimeError, Value};
|
||||
|
||||
use crate::context::ExecutionContext;
|
||||
use marqdo_host_contract::ExecutionContext;
|
||||
|
||||
fn process_error(code: &str, message: &str) -> Value {
|
||||
let mut map = BTreeMap::new();
|
||||
|
||||
@@ -12,7 +12,8 @@ use libloading::Library;
|
||||
use marqdo_span::Span;
|
||||
use marqdo_value::{ErrorCategory, RuntimeError};
|
||||
|
||||
use crate::resource::{ResourceProvider, ResourceRead};
|
||||
use crate::resource::ResourceProvider;
|
||||
use marqdo_host_contract::ResourceRead;
|
||||
|
||||
const ABI_VERSION: u32 = 1;
|
||||
const ERROR_MAX: usize = 1024;
|
||||
|
||||
@@ -18,7 +18,8 @@ use marqdo_span::Span;
|
||||
use marqdo_worker_ipc::{Connection, FrameError, TransportError};
|
||||
use serde_json::{json, Value as Json};
|
||||
|
||||
use crate::resource::{ResourceProvider, ResourceRead};
|
||||
use crate::resource::ResourceProvider;
|
||||
use marqdo_host_contract::ResourceRead;
|
||||
use marqdo_value::{ErrorCategory, RuntimeError};
|
||||
|
||||
const MAX_FRAME_BYTES: usize = 1024 * 1024;
|
||||
|
||||
@@ -13,6 +13,7 @@ use rustls::{ClientConnection, StreamOwned};
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use marqdo_host_contract::ResourceRead;
|
||||
use marqdo_span::Span;
|
||||
use marqdo_value::{ErrorCategory, ResourceHandle, RuntimeError};
|
||||
|
||||
@@ -83,15 +84,6 @@ pub trait ResourceProvider: Send {
|
||||
/// Shared provider handle registered on the host.
|
||||
pub type SharedResourceProvider = Arc<Mutex<Box<dyn ResourceProvider>>>;
|
||||
|
||||
/// Bytes returned by one stream read.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ResourceRead {
|
||||
/// Bytes actually read (may be empty at EOF).
|
||||
pub bytes: Vec<u8>,
|
||||
/// Whether the stream has reached EOF.
|
||||
pub eof: bool,
|
||||
}
|
||||
|
||||
struct StdinCursor {
|
||||
bytes: Vec<u8>,
|
||||
position: usize,
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use marqdo_host::{Capabilities, Host, StdHost};
|
||||
use marqdo_host::{Capabilities, StdHost};
|
||||
use marqdo_host_contract::Host;
|
||||
use marqdo_sandbox::SandboxMode;
|
||||
use marqdo_value::ErrorCategory;
|
||||
|
||||
fn context() -> marqdo_host::ExecutionContext {
|
||||
marqdo_host::ExecutionContext::new("test".to_string(), None)
|
||||
fn context() -> marqdo_host_contract::ExecutionContext {
|
||||
marqdo_host_contract::ExecutionContext::new("test".to_string(), None)
|
||||
}
|
||||
|
||||
fn handle(value: marqdo_value::Value) -> marqdo_value::ResourceHandle {
|
||||
|
||||
@@ -5,8 +5,9 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
|
||||
use marqdo_host::{Capabilities, Host, HostOp, StdHost};
|
||||
use marqdo_plugin_abi::{sha256_file, HostTarget, PluginManifest};
|
||||
use marqdo_host::plugin::{sha256_file, HostTarget, PluginManifest};
|
||||
use marqdo_host::{Capabilities, StdHost};
|
||||
use marqdo_host_contract::{Host, HostOp};
|
||||
use marqdo_sandbox::SandboxMode;
|
||||
use marqdo_value::{ErrorCategory, Value};
|
||||
|
||||
|
||||
+3
-3
@@ -11,9 +11,9 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
|
||||
use marqdo_plugin_abi::{
|
||||
sha256_file, ErrorKind, HostTarget, LoadedPlugin, PluginManifest, Value, WireRequest,
|
||||
};
|
||||
use marqdo_host::plugin::{sha256_file, HostTarget, LoadedPlugin, PluginManifest};
|
||||
use marqdo_plugin_abi::{ErrorKind, WireRequest};
|
||||
use marqdo_value::Value;
|
||||
|
||||
static TEMP_COUNTER: AtomicU32 = AtomicU32::new(0);
|
||||
|
||||
@@ -8,10 +8,10 @@ use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use marqdo_host::{
|
||||
encode_value, Capabilities, ExecutionContext, FrameId, Host, ObservationConfig,
|
||||
ObservationError, ObservationEvent, ObservationSink, ParameterSource, RuntimeObservation,
|
||||
StdHost, ValueState,
|
||||
encode_value, Capabilities, ObservationConfig, ObservationError, ObservationEvent,
|
||||
ObservationSink, StdHost, ValueState,
|
||||
};
|
||||
use marqdo_host_contract::{ExecutionContext, FrameId, Host, ParameterSource, RuntimeObservation};
|
||||
use marqdo_sandbox::SandboxMode;
|
||||
use marqdo_value::{ErrorCategory, Value};
|
||||
|
||||
|
||||
@@ -6,8 +6,9 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
|
||||
use marqdo_host::{Capabilities, Host, HostOp, StdHost};
|
||||
use marqdo_plugin_abi::{sha256_file, HostTarget, PluginManifest};
|
||||
use marqdo_host::plugin::{sha256_file, HostTarget, PluginManifest};
|
||||
use marqdo_host::{Capabilities, StdHost};
|
||||
use marqdo_host_contract::{Host, HostOp};
|
||||
use marqdo_sandbox::SandboxMode;
|
||||
use marqdo_value::Value;
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use marqdo_host::{Capabilities, ExecutionContext, Host, HostOp, StdHost};
|
||||
use marqdo_host::{Capabilities, StdHost};
|
||||
use marqdo_host_contract::{ExecutionContext, Host, HostOp};
|
||||
use marqdo_sandbox::SandboxMode;
|
||||
use marqdo_value::{ErrorCategory, Value};
|
||||
|
||||
@@ -325,12 +326,12 @@ impl marqdo_host::ResourceProvider for MockProvider {
|
||||
token: u64,
|
||||
max_bytes: usize,
|
||||
_span: Option<marqdo_span::Span>,
|
||||
) -> Result<marqdo_host::ResourceRead, marqdo_value::RuntimeError> {
|
||||
) -> Result<marqdo_host_contract::ResourceRead, marqdo_value::RuntimeError> {
|
||||
assert_eq!(token, 7);
|
||||
let start = self.position;
|
||||
let end = start.saturating_add(max_bytes).min(self.data.len());
|
||||
self.position = end;
|
||||
Ok(marqdo_host::ResourceRead {
|
||||
Ok(marqdo_host_contract::ResourceRead {
|
||||
bytes: self.data[start..end].to_vec(),
|
||||
eof: end >= self.data.len(),
|
||||
})
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use marqdo_host::{Capabilities, Host, StdHost};
|
||||
use marqdo_host::{Capabilities, StdHost};
|
||||
use marqdo_host_contract::Host;
|
||||
use marqdo_sandbox::SandboxMode;
|
||||
use marqdo_value::ErrorCategory;
|
||||
|
||||
fn context() -> marqdo_host::ExecutionContext {
|
||||
marqdo_host::ExecutionContext::new("test".to_string(), None)
|
||||
fn context() -> marqdo_host_contract::ExecutionContext {
|
||||
marqdo_host_contract::ExecutionContext::new("test".to_string(), None)
|
||||
}
|
||||
|
||||
fn handle(value: marqdo_value::Value) -> marqdo_value::ResourceHandle {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "marqdo-plugin-abi"
|
||||
description = "Versioned C ABI v1 bindings, manifest validation and artifact loading"
|
||||
description = "Public plugin ABI v1 contract: C layout, wire envelope and protocol errors"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
@@ -9,13 +9,7 @@ repository.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
[dependencies]
|
||||
marqdo-span = { workspace = true }
|
||||
marqdo-value = { workspace = true }
|
||||
marqdo-worker-ipc = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
serde_yaml = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
libloading = { workspace = true }
|
||||
sha2 = { workspace = true }
|
||||
hex = { workspace = true }
|
||||
@@ -255,12 +255,17 @@ pub struct MqCallContext {
|
||||
|
||||
impl MqCallContext {
|
||||
/// Mint a context for a host invocation.
|
||||
pub(crate) fn new(host_data: *mut c_void) -> Self {
|
||||
///
|
||||
/// Host-side execution API: the native host owns the invocation lifetime
|
||||
/// and passes an opaque pointer the plugin never dereferences.
|
||||
pub fn new(host_data: *mut c_void) -> Self {
|
||||
Self { host_data }
|
||||
}
|
||||
|
||||
/// Opaque host data pointer carried by this context.
|
||||
pub(crate) fn host_data(&self) -> *mut c_void {
|
||||
///
|
||||
/// Host-side execution API; not part of the C layout exposed to plugins.
|
||||
pub fn host_data(&self) -> *mut c_void {
|
||||
self.host_data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,23 @@
|
||||
//! Versioned plugin C ABI v1 bindings, manifest validation and artifact
|
||||
//! loading (host side).
|
||||
//! Public contract for the versioned plugin C ABI v1.
|
||||
//!
|
||||
//! This crate is the host-side counterpart of
|
||||
//! `include/marqdo_plugin_abi_v1.h` (the frozen C ABI) and of the
|
||||
//! `marqdo-plugin-sdk` crate (the plugin-developer side). It implements the
|
||||
//! blueprint section 10 contract:
|
||||
//! This crate is the single normative Rust side of
|
||||
//! `include/marqdo_plugin_abi_v1.h`: the stable `#[repr(C)]` types with layout
|
||||
//! assertions and major/minor negotiation ([`abi`]), the `wire_version` 1
|
||||
//! JSON request/response envelope with typed value tags ([`wire`]), and the
|
||||
//! structured protocol [`PluginError`].
|
||||
//!
|
||||
//! - stable `#[repr(C)]` Rust mirrors of the C types, with compile-time layout
|
||||
//! assertions and major/minor negotiation ([`abi`]),
|
||||
//! - `plugin.yaml` parsing and validation ([`manifest`]),
|
||||
//! - target-triple artifact selection and sha256 verification ([`artifact`]),
|
||||
//! - `wire_version` 1 JSON request/response envelopes with typed value tags
|
||||
//! ([`wire`]),
|
||||
//! - a native loader/invocation bridge built on `libloading` ([`loader`]),
|
||||
//! - structured, serializable [`PluginError`]s ([`error`]).
|
||||
//! It is a contract crate, not a loader. Native loading (`dlopen`), artifact
|
||||
//! selection on disk, manifest file validation, worker process management and
|
||||
//! capability dispatch live in the native host (`marqdo-host::plugin`). The
|
||||
//! SDK consumes only this crate. There is no second wire encoding here: the
|
||||
//! wire envelope reuses the single [`marqdo_value`] encoding.
|
||||
//!
|
||||
//! A C ABI is not a sandbox: native plugins run in-process and require an
|
||||
//! explicit trust decision. This crate only validates and loads what the
|
||||
//! caller already decided to trust; it never grants capabilities.
|
||||
//! A C ABI is not a sandbox. A host that loads native code must separately make
|
||||
//! and enforce an explicit trust decision; this crate grants no capability.
|
||||
|
||||
pub mod abi;
|
||||
pub mod artifact;
|
||||
pub mod error;
|
||||
pub mod loader;
|
||||
pub mod manifest;
|
||||
pub mod wire;
|
||||
pub mod worker;
|
||||
|
||||
pub use abi::result as result_code;
|
||||
pub use abi::{
|
||||
@@ -33,16 +25,7 @@ pub use abi::{
|
||||
MqOwnedBytes, MqPluginApi, MqPluginEntryV1, MqPluginInvoke, MqRegisterFunctionFn,
|
||||
MqRequestCapabilityFn, PluginMetadata, ABI_MAJOR, ABI_MINOR, ABI_VERSION_STRING, ENTRY_SYMBOL,
|
||||
};
|
||||
pub use artifact::{
|
||||
current_target_triple, is_valid_sha256_hex, sha256_bytes, sha256_file, verify_sha256_file,
|
||||
HostTarget, TargetTriple,
|
||||
};
|
||||
pub use error::{ErrorKind, PluginError};
|
||||
pub use loader::{CapabilityHandler, LoadOptions, LoadedPlugin, RegisteredExport};
|
||||
pub use manifest::{
|
||||
AbiRequirement, Artifact, Export, PackageVersion, PluginInfo, PluginKind, PluginManifest,
|
||||
KNOWN_CAPABILITIES,
|
||||
};
|
||||
pub use marqdo_value::Value;
|
||||
pub use wire::{
|
||||
bool_from_value, int_from_value, text_from_value, to_wire_json, WireContext, WireErrorBody,
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
[package]
|
||||
name = "marqdo-plugin-sdk"
|
||||
description = "Rust SDK for writing Marqdo plugins against ABI v1"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
[dependencies]
|
||||
marqdo-plugin-abi = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
//! Safe wrappers around the raw `MqBytes` / `MqOwnedBytes` ABI buffers.
|
||||
//!
|
||||
//! Ownership rules (see the canonical header):
|
||||
//! - [`BytesRef`] is a borrowed, validated view of host input; it is only
|
||||
//! valid for the call that produced it.
|
||||
//! - [`HostBuffer`] is plugin output allocated with the host allocator and
|
||||
//! handed back to the host, which frees it after copying.
|
||||
|
||||
use std::ffi::c_void;
|
||||
use std::marker::PhantomData;
|
||||
use std::ptr;
|
||||
|
||||
use marqdo_plugin_abi::abi::{MqBytes, MqHostApi, MqOwnedBytes};
|
||||
|
||||
use crate::PluginError;
|
||||
|
||||
/// Validated borrowed view of an ABI byte buffer (`MqBytes`).
|
||||
pub struct BytesRef<'a> {
|
||||
raw: MqBytes,
|
||||
_marker: PhantomData<&'a [u8]>,
|
||||
}
|
||||
|
||||
impl<'a> BytesRef<'a> {
|
||||
/// Validate a raw borrowed buffer.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// If `raw.len > 0`, `raw.data` must point to `raw.len` initialized bytes
|
||||
/// that stay alive for `'a`. Within the ABI, `'a` must not outlive the
|
||||
/// call that produced the buffer.
|
||||
pub unsafe fn from_raw(raw: MqBytes) -> Result<Self, PluginError> {
|
||||
raw.validate()?;
|
||||
Ok(Self {
|
||||
raw,
|
||||
_marker: PhantomData,
|
||||
})
|
||||
}
|
||||
|
||||
/// The underlying raw ABI view.
|
||||
pub fn as_raw(&self) -> MqBytes {
|
||||
self.raw
|
||||
}
|
||||
|
||||
/// The bytes as a slice (valid for `'a`).
|
||||
pub fn as_slice(&self) -> &'a [u8] {
|
||||
if self.raw.len == 0 {
|
||||
return &[];
|
||||
}
|
||||
// SAFETY: `from_raw` validated the pointer/length pair and `'a` is
|
||||
// tied to the caller's borrow guarantee.
|
||||
unsafe { std::slice::from_raw_parts(self.raw.data, self.raw.len) }
|
||||
}
|
||||
|
||||
/// Length in bytes.
|
||||
pub fn len(&self) -> usize {
|
||||
self.raw.len
|
||||
}
|
||||
|
||||
/// Whether the buffer is empty.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.raw.len == 0
|
||||
}
|
||||
}
|
||||
|
||||
/// A byte buffer allocated with the host allocator and owned by the host.
|
||||
///
|
||||
/// The plugin writes its response/error wire into a [`HostBuffer`] and
|
||||
/// transfers ownership through the ABI output parameter. The plugin must
|
||||
/// never free this buffer itself; the host frees it after copying.
|
||||
pub struct HostBuffer {
|
||||
raw: MqOwnedBytes,
|
||||
}
|
||||
|
||||
impl HostBuffer {
|
||||
/// The empty buffer `{NULL, 0}`.
|
||||
pub fn empty() -> Self {
|
||||
Self {
|
||||
raw: MqOwnedBytes::EMPTY,
|
||||
}
|
||||
}
|
||||
|
||||
/// Allocate a host buffer and copy `bytes` into it.
|
||||
///
|
||||
/// `host` must be the host API table provided to the entry point (the SDK
|
||||
/// stores it for the plugin lifetime). Returns an out-of-memory error if
|
||||
/// the host allocator returns NULL.
|
||||
pub fn copy_from(host: &MqHostApi, bytes: &[u8]) -> Result<Self, PluginError> {
|
||||
if bytes.is_empty() {
|
||||
return Ok(Self::empty());
|
||||
}
|
||||
// SAFETY: host alloc/free pointers are non-NULL and valid for the
|
||||
// plugin lifetime (validated during the entry call).
|
||||
let pointer = unsafe { (host.alloc)(host.host_data, bytes.len()) };
|
||||
if pointer.is_null() {
|
||||
return Err(PluginError::invoke(
|
||||
"out_of_memory",
|
||||
"host allocator returned NULL for a plugin output buffer",
|
||||
));
|
||||
}
|
||||
// SAFETY: pointer has bytes.len() writable bytes and does not overlap
|
||||
// the source slice.
|
||||
unsafe {
|
||||
ptr::copy_nonoverlapping(bytes.as_ptr(), pointer as *mut u8, bytes.len());
|
||||
}
|
||||
Ok(Self {
|
||||
raw: MqOwnedBytes::new(pointer as *mut u8, bytes.len()),
|
||||
})
|
||||
}
|
||||
|
||||
/// The raw owner-transfer buffer.
|
||||
pub fn into_raw(self) -> MqOwnedBytes {
|
||||
self.raw
|
||||
}
|
||||
|
||||
/// Length in bytes.
|
||||
pub fn len(&self) -> usize {
|
||||
self.raw.len
|
||||
}
|
||||
|
||||
/// Whether the buffer is empty.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.raw.len == 0
|
||||
}
|
||||
}
|
||||
|
||||
/// Borrowed view of a capability reply or other host-allocated buffer.
|
||||
///
|
||||
/// The plugin copies what it needs and then must release the buffer with the
|
||||
/// host allocator; use [`release_host_buffer`].
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `buffer` must be a host-allocated buffer that is still alive; the returned
|
||||
/// slice must not outlive the release of that buffer.
|
||||
pub unsafe fn reply_slice<'a>(buffer: MqOwnedBytes) -> &'a [u8] {
|
||||
if buffer.len == 0 {
|
||||
return &[];
|
||||
}
|
||||
// SAFETY: host-allocated buffer is initialized for `buffer.len` bytes; the
|
||||
// caller must not retain the slice beyond the release point.
|
||||
unsafe { std::slice::from_raw_parts(buffer.data, buffer.len) }
|
||||
}
|
||||
|
||||
/// Release a host-allocated buffer through the host allocator.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `buffer.data` must be NULL or a pointer returned by the host allocator
|
||||
/// (`MqHostApi::alloc`) that has not been freed yet.
|
||||
pub unsafe fn release_host_buffer(host: &MqHostApi, buffer: MqOwnedBytes) {
|
||||
if buffer.data.is_null() {
|
||||
return;
|
||||
}
|
||||
// SAFETY: alloc/free pair and non-NULL pointer per the caller contract.
|
||||
unsafe { (host.free)(host.host_data, buffer.data as *mut c_void) };
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
//! Per-invocation context passed to plugin handlers.
|
||||
//!
|
||||
//! The context is valid only for the duration of one invocation. It exists to
|
||||
//! carry host capabilities into the plugin: capability requests are answered
|
||||
//! by the host's authorization layer and can never be escalated by plugin
|
||||
//! code. Do not cache this value, its raw pointer or any capability token.
|
||||
|
||||
use marqdo_plugin_abi::abi::{
|
||||
MqBytes, MqCallContext, MqHostApi, MqOwnedBytes, MAX_CAPABILITY_REPLY_BYTES,
|
||||
};
|
||||
use marqdo_plugin_abi::PluginError;
|
||||
|
||||
use crate::bytes;
|
||||
|
||||
/// Context for one plugin invocation.
|
||||
pub struct CallContext {
|
||||
raw: *mut MqCallContext,
|
||||
host: &'static MqHostApi,
|
||||
}
|
||||
|
||||
impl CallContext {
|
||||
/// Wrap the host-provided context pointer.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `raw` must be the context pointer provided by the host for the current
|
||||
/// invocation, and `host` must be the validated host API table.
|
||||
pub(crate) unsafe fn new(raw: *mut MqCallContext, host: &'static MqHostApi) -> Self {
|
||||
Self { raw, host }
|
||||
}
|
||||
|
||||
/// The host API table of this plugin instance.
|
||||
pub fn host(&self) -> &'static MqHostApi {
|
||||
self.host
|
||||
}
|
||||
|
||||
/// Request an already-authorized host capability for this call.
|
||||
///
|
||||
/// `request` is a UTF-8 JSON capability request; the reply is opaque bytes
|
||||
/// owned by the host. The SDK copies the reply and releases the host buffer.
|
||||
pub fn capability_request(
|
||||
&mut self,
|
||||
name: &str,
|
||||
request: &[u8],
|
||||
) -> Result<Vec<u8>, PluginError> {
|
||||
if self.raw.is_null() {
|
||||
return Err(PluginError::capability(
|
||||
"missing_call_context",
|
||||
"capability request requires an active invocation context",
|
||||
));
|
||||
}
|
||||
let mut reply = MqOwnedBytes::EMPTY;
|
||||
// SAFETY: raw context and host table are valid for this invocation.
|
||||
let code = unsafe {
|
||||
(self.host.request_capability)(
|
||||
self.raw,
|
||||
MqBytes::from_slice(name.as_bytes()),
|
||||
MqBytes::from_slice(request),
|
||||
&mut reply,
|
||||
)
|
||||
};
|
||||
// SAFETY: host-allocated reply is initialized for `reply.len` bytes.
|
||||
let reply_bytes = unsafe { reply.to_vec() };
|
||||
// SAFETY: the host allocated `reply` with its allocator for us; release
|
||||
// it exactly once after copying.
|
||||
unsafe { bytes::release_host_buffer(self.host, reply) };
|
||||
let reply_bytes = reply_bytes.map_err(|error| {
|
||||
PluginError::capability(
|
||||
"invalid_capability_reply",
|
||||
"host capability reply violates the buffer contract",
|
||||
)
|
||||
.with_detail(error.to_string())
|
||||
})?;
|
||||
if reply_bytes.len() > MAX_CAPABILITY_REPLY_BYTES {
|
||||
return Err(PluginError::capability(
|
||||
"capability_reply_too_large",
|
||||
format!(
|
||||
"capability reply is {} bytes, limit is {MAX_CAPABILITY_REPLY_BYTES}",
|
||||
reply_bytes.len()
|
||||
),
|
||||
));
|
||||
}
|
||||
if code != crate::result_code::OK {
|
||||
return Err(PluginError::capability(
|
||||
"capability_request_failed",
|
||||
format!("host rejected capability request `{name}`"),
|
||||
)
|
||||
.with_detail(format!(
|
||||
"result code `{}` ({code})",
|
||||
crate::result_code::name(code)
|
||||
)));
|
||||
}
|
||||
Ok(reply_bytes)
|
||||
}
|
||||
|
||||
/// Best-effort structured log through the `log` capability.
|
||||
pub fn log(&mut self, level: &str, message: &str) -> Result<(), PluginError> {
|
||||
let request = serde_json::json!({"level": level, "message": message});
|
||||
let request = serde_json::to_vec(&request).map_err(|error| {
|
||||
PluginError::capability("log_encode_failed", "could not encode log request")
|
||||
.with_detail(error.to_string())
|
||||
})?;
|
||||
let _ = self.capability_request("log", &request)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for CallContext {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("CallContext")
|
||||
.field("raw", &self.raw)
|
||||
.field("host", &(self.host as *const MqHostApi))
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
@@ -1,199 +0,0 @@
|
||||
//! Entry-point plumbing used by [`mq_plugin_entry!`](crate::mq_plugin_entry).
|
||||
//!
|
||||
//! These functions are the "runtime" of the SDK macro. They are public so the
|
||||
//! macro can reference them through `$crate` from a plugin crate, but they are
|
||||
//! not intended for direct use.
|
||||
|
||||
use std::panic::{catch_unwind, AssertUnwindSafe};
|
||||
use std::sync::atomic::{AtomicPtr, Ordering};
|
||||
|
||||
use marqdo_plugin_abi::abi::{
|
||||
check_host_api, result, MqBytes, MqCallContext, MqHostApi, MqOwnedBytes, MqPluginApi,
|
||||
MqPluginInvoke, ABI_MAJOR, ABI_MINOR, MAX_ERROR_WIRE_BYTES, MAX_EXPORT_NAME_BYTES,
|
||||
MAX_RESULT_WIRE_BYTES,
|
||||
};
|
||||
use marqdo_plugin_abi::{PluginError, WireResponse};
|
||||
|
||||
use crate::bytes::{release_host_buffer, HostBuffer};
|
||||
use crate::call::CallContext;
|
||||
use crate::HandlerFn;
|
||||
|
||||
/// Host API table captured by the entry point for the plugin lifetime.
|
||||
static CURRENT_HOST: AtomicPtr<MqHostApi> = AtomicPtr::new(std::ptr::null_mut());
|
||||
|
||||
/// The host API table captured at load time, if a plugin is loaded.
|
||||
pub(crate) fn current_host() -> Option<&'static MqHostApi> {
|
||||
let pointer = CURRENT_HOST.load(Ordering::SeqCst);
|
||||
if pointer.is_null() {
|
||||
return None;
|
||||
}
|
||||
// SAFETY: the pointer was stored from a validated host table and the host
|
||||
// guarantees it is valid for the plugin lifetime (single-threaded model).
|
||||
Some(unsafe { &*pointer })
|
||||
}
|
||||
|
||||
/// Initialize the ABI tables for the generated entry point.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `host` and `plugin` must be the pointers provided by the host to
|
||||
/// `mq_plugin_entry_v1` and must satisfy the header contract.
|
||||
pub unsafe fn initialize(
|
||||
host: *const MqHostApi,
|
||||
plugin: *mut MqPluginApi,
|
||||
metadata: &'static [u8],
|
||||
) -> i32 {
|
||||
if plugin.is_null() {
|
||||
return result::INVALID_ARGUMENT;
|
||||
}
|
||||
// SAFETY: host pointer comes from the host and is checked before use.
|
||||
let negotiated = match unsafe { check_host_api(host) } {
|
||||
Ok(version) => version,
|
||||
Err(_) => return result::ABI_MISMATCH,
|
||||
};
|
||||
if negotiated.major != ABI_MAJOR {
|
||||
return result::ABI_MISMATCH;
|
||||
}
|
||||
CURRENT_HOST.store(host as *mut MqHostApi, Ordering::SeqCst);
|
||||
// SAFETY: plugin table is host-provided, writable and valid for this call.
|
||||
unsafe {
|
||||
(*plugin).struct_size = std::mem::size_of::<MqPluginApi>() as u32;
|
||||
(*plugin).abi_major = ABI_MAJOR;
|
||||
(*plugin).abi_minor = ABI_MINOR;
|
||||
(*plugin).plugin_metadata_wire = MqBytes::from_slice(metadata);
|
||||
}
|
||||
result::OK
|
||||
}
|
||||
|
||||
/// Register one export through the host table.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `host` must be the table validated by [`initialize`]; both strings must be
|
||||
/// valid UTF-8 dotted export names/signatures declared in `plugin.yaml`.
|
||||
pub unsafe fn register_export(
|
||||
host: *const MqHostApi,
|
||||
name: &str,
|
||||
signature: &str,
|
||||
invoke: MqPluginInvoke,
|
||||
) -> i32 {
|
||||
if host.is_null() || name.is_empty() || name.len() > MAX_EXPORT_NAME_BYTES {
|
||||
return result::INVALID_ARGUMENT;
|
||||
}
|
||||
// SAFETY: host pointer is non-NULL and valid for the plugin lifetime.
|
||||
let host = unsafe { &*host };
|
||||
let signature_wire = match serde_json::to_vec(&serde_json::json!({"signature": signature})) {
|
||||
Ok(bytes) => bytes,
|
||||
Err(_) => return result::BAD_WIRE,
|
||||
};
|
||||
// SAFETY: host table was validated; strings outlive the call.
|
||||
unsafe {
|
||||
(host.register_function)(
|
||||
host.host_data,
|
||||
MqBytes::from_slice(name.as_bytes()),
|
||||
MqBytes::from_slice(&signature_wire),
|
||||
invoke,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Dispatch one invocation to a plugin handler and write the response.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Must be called as the body of a `MqPluginInvoke` callback with the buffers
|
||||
/// provided by the host for that invocation.
|
||||
pub unsafe fn dispatch(
|
||||
handler: HandlerFn,
|
||||
ctx: *mut MqCallContext,
|
||||
args: MqBytes,
|
||||
result_out: *mut MqOwnedBytes,
|
||||
error_out: *mut MqOwnedBytes,
|
||||
) -> i32 {
|
||||
if result_out.is_null() || error_out.is_null() {
|
||||
return result::INVALID_ARGUMENT;
|
||||
}
|
||||
// SAFETY: output pointers are non-NULL host-provided out-parameters.
|
||||
unsafe {
|
||||
*result_out = MqOwnedBytes::EMPTY;
|
||||
*error_out = MqOwnedBytes::EMPTY;
|
||||
}
|
||||
let Some(host) = current_host() else {
|
||||
return result::INTERNAL;
|
||||
};
|
||||
// SAFETY: borrowed request buffer is valid for this callback.
|
||||
let args_bytes = match unsafe { args.as_slice() } {
|
||||
Ok(bytes) => bytes.to_vec(),
|
||||
Err(_) => return result::INVALID_ARGUMENT,
|
||||
};
|
||||
|
||||
// SAFETY: context pointer is the host-minted context for this invocation.
|
||||
let mut context = unsafe { CallContext::new(ctx, host) };
|
||||
let outcome = catch_unwind(AssertUnwindSafe(|| handler(&mut context, &args_bytes)));
|
||||
let response = match outcome {
|
||||
Ok(Ok(bytes)) => Ok(bytes),
|
||||
Ok(Err(error)) => Err(error),
|
||||
Err(_) => Err(PluginError::invoke(
|
||||
"plugin_panic",
|
||||
"plugin handler panicked; the panic was caught at the ABI boundary",
|
||||
)),
|
||||
};
|
||||
|
||||
match response {
|
||||
Ok(bytes) => {
|
||||
if bytes.len() > MAX_RESULT_WIRE_BYTES {
|
||||
return write_error(
|
||||
host,
|
||||
error_out,
|
||||
&PluginError::wire(
|
||||
"result_too_large",
|
||||
format!(
|
||||
"plugin result is {} bytes, limit is {MAX_RESULT_WIRE_BYTES}",
|
||||
bytes.len()
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
match HostBuffer::copy_from(host, &bytes) {
|
||||
Ok(buffer) => {
|
||||
// SAFETY: result_out is a valid out-parameter.
|
||||
unsafe { *result_out = buffer.into_raw() };
|
||||
result::OK
|
||||
}
|
||||
Err(error) => write_error(host, error_out, &error),
|
||||
}
|
||||
}
|
||||
Err(error) => write_error(host, error_out, &error),
|
||||
}
|
||||
}
|
||||
|
||||
fn write_error(host: &'static MqHostApi, error_out: *mut MqOwnedBytes, error: &PluginError) -> i32 {
|
||||
let encoded = match WireResponse::from_error(error).to_json_bytes() {
|
||||
Ok(bytes) if bytes.len() <= MAX_ERROR_WIRE_BYTES => bytes,
|
||||
_ => br#"{"wire_version":1,"kind":"response","error":{"kind":"invoke","code":"plugin_error","message":"plugin failed with an unencodable error"}}"#.to_vec(),
|
||||
};
|
||||
let code = match error.kind {
|
||||
marqdo_plugin_abi::ErrorKind::Wire => result::BAD_WIRE,
|
||||
marqdo_plugin_abi::ErrorKind::Capability => result::CAPABILITY,
|
||||
marqdo_plugin_abi::ErrorKind::Unsupported => result::UNSUPPORTED,
|
||||
_ => result::INTERNAL,
|
||||
};
|
||||
match HostBuffer::copy_from(host, &encoded) {
|
||||
Ok(buffer) => {
|
||||
// SAFETY: error_out is a valid out-parameter.
|
||||
unsafe { *error_out = buffer.into_raw() };
|
||||
code
|
||||
}
|
||||
Err(_) => result::OUT_OF_MEMORY,
|
||||
}
|
||||
}
|
||||
|
||||
/// Free a host-owned buffer (used by generated code/tests).
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `buffer` must have been allocated by the host allocator and not freed yet.
|
||||
pub unsafe fn free_host_buffer(host: &MqHostApi, buffer: MqOwnedBytes) {
|
||||
// SAFETY: caller guarantees the alloc/free pair.
|
||||
unsafe { release_host_buffer(host, buffer) };
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
//! Rust SDK for writing Marqdo native plugins against plugin ABI v1.
|
||||
//!
|
||||
//! The SDK is the plugin-developer side of `include/marqdo_plugin_abi_v1.h`.
|
||||
//! It hides the raw C layout behind safe wrappers and provides the
|
||||
//! [`mq_plugin_entry!`] macro that exports the required
|
||||
//! `mq_plugin_entry_v1` symbol:
|
||||
//!
|
||||
//! ```
|
||||
//! use marqdo_plugin_sdk::{mq_plugin_entry, CallContext, PluginError, Value};
|
||||
//!
|
||||
//! fn add(_ctx: &mut CallContext, args: &[u8]) -> Result<Vec<u8>, PluginError> {
|
||||
//! let request = marqdo_plugin_sdk::wire::decode_request(args)?;
|
||||
//! let values = request.typed_args()?;
|
||||
//! let a = marqdo_plugin_sdk::wire::int_arg(&values, "a")?;
|
||||
//! let b = marqdo_plugin_sdk::wire::int_arg(&values, "b")?;
|
||||
//! marqdo_plugin_sdk::wire::success(Some(Value::Int((a + b).into())))
|
||||
//! }
|
||||
//!
|
||||
//! mq_plugin_entry! {
|
||||
//! name: "demo.solver",
|
||||
//! version: "0.1.0",
|
||||
//! exports: {
|
||||
//! "solver.add" => "($a: Int, $b: Int) -> Int" => add,
|
||||
//! }
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! The SDK never depends on host-only crates: it only uses the shared ABI
|
||||
//! types and the JSON wire envelope from `marqdo-plugin-abi`. Building a
|
||||
//! plugin does not grant it any capability; authorization is a separate host
|
||||
//! decision performed before loading.
|
||||
|
||||
#![deny(missing_docs)]
|
||||
|
||||
pub use marqdo_plugin_abi::abi::result as result_code;
|
||||
pub use marqdo_plugin_abi::abi::{
|
||||
MqBytes, MqCallContext, MqHostApi, MqOwnedBytes, MqPluginApi, MqPluginInvoke, ABI_MAJOR,
|
||||
ABI_MINOR, ABI_VERSION_STRING, ENTRY_SYMBOL,
|
||||
};
|
||||
pub use marqdo_plugin_abi::{PluginError, Value, WireRequest, WireResponse, WIRE_VERSION};
|
||||
|
||||
pub mod bytes;
|
||||
pub mod call;
|
||||
pub mod entry;
|
||||
pub mod wire;
|
||||
|
||||
pub use bytes::{BytesRef, HostBuffer};
|
||||
pub use call::CallContext;
|
||||
pub use wire::{
|
||||
bool_arg, decode_request, error_response, int_arg, response_value, success, success_raw,
|
||||
text_arg, value_arg,
|
||||
};
|
||||
|
||||
/// Plugin handler signature.
|
||||
///
|
||||
/// A handler receives the per-call context (for capability requests and
|
||||
/// logging) and the raw request envelope bytes, and returns the raw response
|
||||
/// envelope bytes on success.
|
||||
///
|
||||
/// Use [`wire::decode_request`] and [`wire::success`] to build the response;
|
||||
/// handlers should never panic: panics are caught by the SDK and converted
|
||||
/// into a structured error, but the plugin process stays healthy only if the
|
||||
/// panic does not corrupt plugin state.
|
||||
pub type HandlerFn = fn(&mut CallContext, &[u8]) -> Result<Vec<u8>, PluginError>;
|
||||
|
||||
/// Declare a plugin and export `mq_plugin_entry_v1`.
|
||||
///
|
||||
/// ```ignore
|
||||
/// marqdo_plugin_sdk::mq_plugin_entry! {
|
||||
/// name: "demo.solver",
|
||||
/// version: "0.1.0",
|
||||
/// exports: {
|
||||
/// "solver.add" => "($a: Int, $b: Int) -> Int" => add,
|
||||
/// "solver.echo" => "($text: Text) -> Text" => echo,
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Each handler is a path (or non-capturing closure) with the [`HandlerFn`]
|
||||
/// signature. The macro:
|
||||
/// - validates the host ABI table (major version and `struct_size`),
|
||||
/// - reports the plugin ABI version and a metadata envelope,
|
||||
/// - registers every export and fails the load if registration fails.
|
||||
#[macro_export]
|
||||
macro_rules! mq_plugin_entry {
|
||||
(
|
||||
name: $name:literal,
|
||||
version: $version:literal,
|
||||
exports: {
|
||||
$( $export_name:literal => $signature:literal => $handler:expr ),* $(,)?
|
||||
}
|
||||
) => {
|
||||
/// Marqdo plugin ABI v1 entry point (generated by the SDK macro).
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn mq_plugin_entry_v1(
|
||||
host: *const $crate::MqHostApi,
|
||||
plugin: *mut $crate::MqPluginApi,
|
||||
) -> i32 {
|
||||
const METADATA: &[u8] = concat!(
|
||||
"{\"name\":\"", $name, "\",\"version\":\"", $version, "\"}"
|
||||
)
|
||||
.as_bytes();
|
||||
let metadata: &'static [u8] = METADATA;
|
||||
// SAFETY: the host provides the ABI tables per the header contract.
|
||||
let init = unsafe { $crate::entry::initialize(host, plugin, metadata) };
|
||||
if init != 0 {
|
||||
return init;
|
||||
}
|
||||
$(
|
||||
{
|
||||
extern "C" fn invoke(
|
||||
ctx: *mut $crate::MqCallContext,
|
||||
args: $crate::MqBytes,
|
||||
result: *mut $crate::MqOwnedBytes,
|
||||
error: *mut $crate::MqOwnedBytes,
|
||||
) -> i32 {
|
||||
// Expand the user's handler expression in a safe
|
||||
// context (also required by `macro_metavars_in_unsafe`).
|
||||
let handler: $crate::HandlerFn = $handler;
|
||||
// SAFETY: the host owns the invocation buffers; the SDK
|
||||
// validates them and never retains them.
|
||||
unsafe {
|
||||
$crate::entry::dispatch(handler, ctx, args, result, error)
|
||||
}
|
||||
}
|
||||
let export_name: &str = $export_name;
|
||||
let signature: &str = $signature;
|
||||
// SAFETY: host table is valid for the plugin lifetime and
|
||||
// was validated by `initialize`.
|
||||
let code =
|
||||
unsafe { $crate::entry::register_export(host, export_name, signature, invoke) };
|
||||
if code != 0 {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
)*
|
||||
$crate::result_code::OK
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -1,245 +0,0 @@
|
||||
//! End-to-end SDK tests: run the macro-generated entry point against a tiny
|
||||
//! in-process host table and invoke the registered export.
|
||||
|
||||
use std::ffi::c_void;
|
||||
use std::ptr;
|
||||
|
||||
use marqdo_plugin_abi::abi::{
|
||||
result, MqBytes, MqCallContext, MqHostApi, MqOwnedBytes, MqPluginApi, MqPluginInvoke,
|
||||
ABI_MAJOR, ABI_MINOR,
|
||||
};
|
||||
|
||||
use crate::wire;
|
||||
use crate::{CallContext, PluginError, Value, WireRequest, WireResponse};
|
||||
|
||||
/// ABI v1 is single-threaded: the generated plugin stores the host table in a
|
||||
/// process-global. Serialize tests that call the entry point so they do not
|
||||
/// race (the SDK's own contract, not a test-only limitation).
|
||||
static ABI_TEST_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
|
||||
|
||||
fn abi_test_lock() -> std::sync::MutexGuard<'static, ()> {
|
||||
ABI_TEST_LOCK
|
||||
.lock()
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct TestHostState {
|
||||
registrations: Vec<(String, String, MqPluginInvoke)>,
|
||||
}
|
||||
|
||||
unsafe extern "C" fn test_alloc(_host_data: *mut c_void, size: usize) -> *mut c_void {
|
||||
const HEADER: usize = 16;
|
||||
if size == 0 {
|
||||
return ptr::null_mut();
|
||||
}
|
||||
let Ok(layout) = std::alloc::Layout::from_size_align(size + HEADER, 16) else {
|
||||
return ptr::null_mut();
|
||||
};
|
||||
// SAFETY: non-zero layout.
|
||||
let base = unsafe { std::alloc::alloc(layout) };
|
||||
if base.is_null() {
|
||||
return ptr::null_mut();
|
||||
}
|
||||
// SAFETY: allocation has room for the header.
|
||||
unsafe { (base as *mut usize).write(size) };
|
||||
// SAFETY: offset within the allocation.
|
||||
unsafe { base.add(HEADER) as *mut c_void }
|
||||
}
|
||||
|
||||
unsafe extern "C" fn test_free(_host_data: *mut c_void, pointer: *mut c_void) {
|
||||
const HEADER: usize = 16;
|
||||
if pointer.is_null() {
|
||||
return;
|
||||
}
|
||||
// SAFETY: only pointers from test_alloc are freed.
|
||||
unsafe {
|
||||
let base = (pointer as *mut u8).sub(HEADER);
|
||||
let size = (base as *const usize).read();
|
||||
std::alloc::dealloc(
|
||||
base,
|
||||
std::alloc::Layout::from_size_align_unchecked(size + HEADER, 16),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" fn test_register(
|
||||
host_data: *mut c_void,
|
||||
export_name: MqBytes,
|
||||
signature_wire: MqBytes,
|
||||
invoke: MqPluginInvoke,
|
||||
) -> i32 {
|
||||
if host_data.is_null() {
|
||||
return result::INVALID_ARGUMENT;
|
||||
}
|
||||
// SAFETY: host_data points at TestHostState for the test.
|
||||
let state = unsafe { &mut *(host_data as *mut TestHostState) };
|
||||
// SAFETY: buffers are valid for this callback.
|
||||
let name = match unsafe { export_name.as_slice() } {
|
||||
Ok(bytes) => String::from_utf8_lossy(bytes).into_owned(),
|
||||
Err(_) => return result::INVALID_ARGUMENT,
|
||||
};
|
||||
// SAFETY: buffers are valid for this callback.
|
||||
let signature = match unsafe { signature_wire.as_slice() } {
|
||||
Ok(bytes) => String::from_utf8_lossy(bytes).into_owned(),
|
||||
Err(_) => return result::INVALID_ARGUMENT,
|
||||
};
|
||||
state.registrations.push((name, signature, invoke));
|
||||
result::OK
|
||||
}
|
||||
|
||||
unsafe extern "C" fn test_capability(
|
||||
_ctx: *mut MqCallContext,
|
||||
_name: MqBytes,
|
||||
_request: MqBytes,
|
||||
reply: *mut MqOwnedBytes,
|
||||
) -> i32 {
|
||||
if !reply.is_null() {
|
||||
// SAFETY: output pointer is non-NULL.
|
||||
unsafe { *reply = MqOwnedBytes::EMPTY };
|
||||
}
|
||||
result::UNSUPPORTED
|
||||
}
|
||||
|
||||
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())))
|
||||
}
|
||||
|
||||
crate::mq_plugin_entry! {
|
||||
name: "sdk.test",
|
||||
version: "0.1.0",
|
||||
exports: {
|
||||
"test.add" => "($a: Int, $b: Int) -> Int" => add,
|
||||
}
|
||||
}
|
||||
|
||||
struct TestHost {
|
||||
_state: Box<TestHostState>,
|
||||
api: MqHostApi,
|
||||
}
|
||||
|
||||
fn test_host() -> TestHost {
|
||||
let mut state = Box::new(TestHostState::default());
|
||||
let api = MqHostApi {
|
||||
struct_size: std::mem::size_of::<MqHostApi>() as u32,
|
||||
abi_major: ABI_MAJOR,
|
||||
abi_minor: ABI_MINOR,
|
||||
host_data: (&mut *state) as *mut TestHostState as *mut c_void,
|
||||
alloc: test_alloc,
|
||||
free: test_free,
|
||||
register_function: test_register,
|
||||
request_capability: test_capability,
|
||||
};
|
||||
TestHost { _state: state, api }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn macro_exports_and_registers() {
|
||||
let _guard = abi_test_lock();
|
||||
let host = test_host();
|
||||
let mut plugin_api = MqPluginApi::host_initialized();
|
||||
// SAFETY: test host table follows the ABI contract.
|
||||
let code = unsafe { mq_plugin_entry_v1(&host.api as *const MqHostApi, &mut plugin_api) };
|
||||
assert_eq!(code, result::OK);
|
||||
assert_eq!(plugin_api.abi_major, ABI_MAJOR);
|
||||
assert_eq!(plugin_api.abi_minor, ABI_MINOR);
|
||||
// SAFETY: metadata is plugin static data valid during the entry call.
|
||||
let metadata = unsafe { plugin_api.plugin_metadata_wire.as_slice() }.expect("metadata");
|
||||
let metadata = String::from_utf8_lossy(metadata);
|
||||
assert!(metadata.contains("\"name\":\"sdk.test\""));
|
||||
assert_eq!(host._state.registrations.len(), 1);
|
||||
assert_eq!(host._state.registrations[0].0, "test.add");
|
||||
assert!(host._state.registrations[0]
|
||||
.1
|
||||
.contains("($a: Int, $b: Int) -> Int"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn registered_export_roundtrips_wire_request() {
|
||||
let _guard = abi_test_lock();
|
||||
let host = test_host();
|
||||
let mut plugin_api = MqPluginApi::host_initialized();
|
||||
// SAFETY: test host table follows the ABI contract.
|
||||
let code = unsafe { mq_plugin_entry_v1(&host.api as *const MqHostApi, &mut plugin_api) };
|
||||
assert_eq!(code, result::OK);
|
||||
|
||||
let request = WireRequest::new("test.add")
|
||||
.with_arg("a", &Value::Int(20_i64.into()))
|
||||
.with_arg("b", &Value::Int(22_i64.into()));
|
||||
let request_bytes = request.to_json_bytes().expect("request");
|
||||
let (_, _, invoke) = &host._state.registrations[0];
|
||||
let mut result_buffer = MqOwnedBytes::EMPTY;
|
||||
let mut error_buffer = MqOwnedBytes::EMPTY;
|
||||
// SAFETY: invoke is the SDK callback; null ctx is fine because the handler
|
||||
// does not request a capability. Buffers are valid out-parameters.
|
||||
let code = unsafe {
|
||||
invoke(
|
||||
ptr::null_mut(),
|
||||
MqBytes::from_slice(&request_bytes),
|
||||
&mut result_buffer,
|
||||
&mut error_buffer,
|
||||
)
|
||||
};
|
||||
assert_eq!(code, result::OK);
|
||||
assert!(error_buffer.is_empty());
|
||||
// SAFETY: result buffer was allocated by test_alloc for us.
|
||||
let response_bytes = unsafe { result_buffer.to_vec() }.expect("result");
|
||||
// SAFETY: allocated by test_alloc; release exactly once.
|
||||
unsafe { test_free(ptr::null_mut(), result_buffer.data as *mut c_void) };
|
||||
|
||||
let response = WireResponse::from_json_bytes(&response_bytes).expect("response");
|
||||
assert_eq!(
|
||||
response.typed_value().expect("typed"),
|
||||
Some(Value::Int(42_i64.into()))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn handler_error_is_written_as_error_envelope() {
|
||||
let _guard = abi_test_lock();
|
||||
let host = test_host();
|
||||
let mut plugin_api = MqPluginApi::host_initialized();
|
||||
// SAFETY: test host table follows the ABI contract.
|
||||
let code = unsafe { mq_plugin_entry_v1(&host.api as *const MqHostApi, &mut plugin_api) };
|
||||
assert_eq!(code, result::OK);
|
||||
|
||||
let request = WireRequest::new("test.add"); // missing arguments
|
||||
let request_bytes = request.to_json_bytes().expect("request");
|
||||
let (_, _, invoke) = &host._state.registrations[0];
|
||||
let mut result_buffer = MqOwnedBytes::EMPTY;
|
||||
let mut error_buffer = MqOwnedBytes::EMPTY;
|
||||
// SAFETY: invoke is the SDK callback with valid out-parameters.
|
||||
let code = unsafe {
|
||||
invoke(
|
||||
ptr::null_mut(),
|
||||
MqBytes::from_slice(&request_bytes),
|
||||
&mut result_buffer,
|
||||
&mut error_buffer,
|
||||
)
|
||||
};
|
||||
assert_ne!(code, result::OK);
|
||||
assert!(result_buffer.is_empty());
|
||||
// SAFETY: error buffer was allocated by test_alloc for us.
|
||||
let error_bytes = unsafe { error_buffer.to_vec() }.expect("error");
|
||||
// SAFETY: allocated by test_alloc; release exactly once.
|
||||
unsafe { test_free(ptr::null_mut(), error_buffer.data as *mut c_void) };
|
||||
let response = WireResponse::from_error_json_bytes(&error_bytes).expect("decode");
|
||||
let error = response.into_result().expect_err("error");
|
||||
assert_eq!(error.code, "missing_argument");
|
||||
assert_eq!(error.kind, marqdo_plugin_abi::ErrorKind::Invoke);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn initialization_rejects_bad_host_major() {
|
||||
let _guard = abi_test_lock();
|
||||
let mut host = test_host();
|
||||
host.api.abi_major = 2;
|
||||
let mut plugin_api = MqPluginApi::host_initialized();
|
||||
// SAFETY: intentionally inconsistent host table; entry must reject it.
|
||||
let code = unsafe { mq_plugin_entry_v1(&host.api as *const MqHostApi, &mut plugin_api) };
|
||||
assert_eq!(code, result::ABI_MISMATCH);
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
//! Wire envelope helpers for plugin handlers.
|
||||
//!
|
||||
//! The canonical envelope is defined by `marqdo-plugin-abi` and documented in
|
||||
//! `spec/value-wire.md`: UTF-8 JSON, `wire_version == 1`, type-tagged values.
|
||||
//! Handlers normally do:
|
||||
//!
|
||||
//! ```ignore
|
||||
//! fn add(ctx: &mut CallContext, args: &[u8]) -> Result<Vec<u8>, PluginError> {
|
||||
//! let request = decode_request(args)?;
|
||||
//! let values = request.typed_args()?;
|
||||
//! success(Some(Value::Int((int_arg(&values, "a")? + int_arg(&values, "b")?).into())))
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use marqdo_plugin_abi::{
|
||||
bool_from_value, int_from_value, text_from_value, PluginError, Value, WireRequest, WireResponse,
|
||||
};
|
||||
use serde_json::Value as Json;
|
||||
|
||||
/// Decode and validate a request envelope received from the host.
|
||||
pub fn decode_request(bytes: &[u8]) -> Result<WireRequest, PluginError> {
|
||||
WireRequest::from_json_bytes(bytes)
|
||||
}
|
||||
|
||||
/// Look up a typed argument by name.
|
||||
pub fn value_arg<'a>(
|
||||
values: &'a BTreeMap<String, Value>,
|
||||
name: &str,
|
||||
) -> Result<&'a Value, PluginError> {
|
||||
values.get(name).ok_or_else(|| {
|
||||
PluginError::invoke(
|
||||
"missing_argument",
|
||||
format!("required argument `{name}` is missing"),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/// Look up an integer argument (must fit in `i64`).
|
||||
pub fn int_arg(values: &BTreeMap<String, Value>, name: &str) -> Result<i64, PluginError> {
|
||||
let value = value_arg(values, name)?;
|
||||
int_from_value(value).ok_or_else(|| {
|
||||
PluginError::invoke(
|
||||
"invalid_argument_type",
|
||||
format!("argument `{name}` must be an Int"),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/// Look up a text argument.
|
||||
pub fn text_arg<'a>(
|
||||
values: &'a BTreeMap<String, Value>,
|
||||
name: &str,
|
||||
) -> Result<&'a str, PluginError> {
|
||||
let value = value_arg(values, name)?;
|
||||
text_from_value(value).ok_or_else(|| {
|
||||
PluginError::invoke(
|
||||
"invalid_argument_type",
|
||||
format!("argument `{name}` must be Text"),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/// Look up a boolean argument.
|
||||
pub fn bool_arg(values: &BTreeMap<String, Value>, name: &str) -> Result<bool, PluginError> {
|
||||
let value = value_arg(values, name)?;
|
||||
bool_from_value(value).ok_or_else(|| {
|
||||
PluginError::invoke(
|
||||
"invalid_argument_type",
|
||||
format!("argument `{name}` must be Bool"),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/// Encode a successful response envelope.
|
||||
pub fn success(value: Option<Value>) -> Result<Vec<u8>, PluginError> {
|
||||
success_raw(value.as_ref().map(marqdo_plugin_abi::to_wire_json))
|
||||
}
|
||||
|
||||
/// Encode a successful response with an already-encoded type-tagged value.
|
||||
pub fn success_raw(value: Option<Json>) -> Result<Vec<u8>, PluginError> {
|
||||
WireResponse::success_raw(value).to_json_bytes()
|
||||
}
|
||||
|
||||
/// Encode an error response envelope.
|
||||
///
|
||||
/// The SDK's dispatch layer uses this automatically when a handler returns an
|
||||
/// error; handlers may also build custom error responses with it.
|
||||
pub fn error_response(error: &PluginError) -> Result<Vec<u8>, PluginError> {
|
||||
WireResponse::from_error(error).to_json_bytes()
|
||||
}
|
||||
|
||||
/// Decode a response value back into a typed [`Value`] (useful in tests and
|
||||
/// plugins that compose calls).
|
||||
pub fn response_value(bytes: &[u8]) -> Result<Option<Value>, PluginError> {
|
||||
WireResponse::from_json_bytes(bytes)?.typed_value()
|
||||
}
|
||||
@@ -15,6 +15,7 @@ serde_json = { workspace = true }
|
||||
marqdo-worker-ipc = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
marqdo-host-contract = { workspace = true }
|
||||
marqdo-host = { path = "../marqdo-host" }
|
||||
marqdo-sandbox = { path = "../marqdo-sandbox" }
|
||||
marqdo-value = { path = "../marqdo-value" }
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
use marqdo_host::{Capabilities, Host, StdHost};
|
||||
use marqdo_host::{Capabilities, StdHost};
|
||||
use marqdo_host_contract::{ExecutionContext, Host};
|
||||
use marqdo_sandbox::SandboxMode;
|
||||
use marqdo_value::{ErrorCategory, Value};
|
||||
|
||||
fn context() -> marqdo_host::ExecutionContext {
|
||||
marqdo_host::ExecutionContext::new("test".to_string(), None)
|
||||
fn context() -> ExecutionContext {
|
||||
ExecutionContext::new("test".to_string(), None)
|
||||
}
|
||||
|
||||
fn handle(value: Value) -> marqdo_value::ResourceHandle {
|
||||
|
||||
@@ -13,7 +13,7 @@ marqdo-span = { workspace = true }
|
||||
marqdo-value = { workspace = true }
|
||||
marqdo-ir = { workspace = true }
|
||||
marqdo-expression = { workspace = true }
|
||||
marqdo-host = { workspace = true }
|
||||
marqdo-host-contract = { workspace = true }
|
||||
num-bigint = { workspace = true }
|
||||
num-rational = { workspace = true }
|
||||
num-traits = { workspace = true }
|
||||
@@ -21,6 +21,7 @@ thiserror = { workspace = true }
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
marqdo-host = { workspace = true }
|
||||
marqdo-frontend = { workspace = true }
|
||||
marqdo-sandbox = { workspace = true }
|
||||
tempfile = { workspace = true }
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use marqdo_host::{HostOp, ResourceRead};
|
||||
use marqdo_host_contract::{HostOp, ResourceRead};
|
||||
use marqdo_ir::builtins::Builtin;
|
||||
use marqdo_ir::Resource;
|
||||
use marqdo_span::Span;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use marqdo_expression::{BinaryOp, Expr, RecordEntry};
|
||||
use marqdo_host::{
|
||||
use marqdo_host_contract::{
|
||||
ExecutionContext, FrameId, Host, HostOp, LoopTransfer, ParameterSource, ResourceRead,
|
||||
RuntimeObservation,
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! The interpreter is Marqdo's own execution engine: expressions, scoping,
|
||||
//! calls, branches, loops and returns are evaluated here, never by translating
|
||||
//! to Python or another language. Every side effect goes through
|
||||
//! [`marqdo_host::Host`]; prose never reaches this layer because it is absent
|
||||
//! [`marqdo_host_contract::Host`]; prose never reaches this layer because it is absent
|
||||
//! from the IR.
|
||||
|
||||
mod builtins_impl;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//! End-to-end interpreter tests: Markdown source → frontend IR → execution.
|
||||
|
||||
use marqdo_host::{Capabilities, Host, StdHost};
|
||||
use marqdo_host::{Capabilities, StdHost};
|
||||
use marqdo_host_contract::Host;
|
||||
use marqdo_ir::{ModuleId, Program};
|
||||
use marqdo_runtime::{run, run_with_limits, EvaluatedArg, MemoryLimits, RuntimeError, Value};
|
||||
use marqdo_sandbox::SandboxMode;
|
||||
|
||||
@@ -8,9 +8,10 @@ use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use marqdo_host::{
|
||||
Capabilities, ObservationConfig, ObservationError, ObservationEvent, ObservationSink,
|
||||
ParameterSource, StdHost, ValueState,
|
||||
Capabilities, ObservationConfig, ObservationError, ObservationEvent, ObservationSink, StdHost,
|
||||
ValueState,
|
||||
};
|
||||
use marqdo_host_contract::ParameterSource;
|
||||
use marqdo_ir::{ModuleId, Program};
|
||||
use marqdo_runtime::run;
|
||||
use marqdo_sandbox::SandboxMode;
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
# Marqdo CLI:语言规范、架构与开发总纲
|
||||
|
||||
> **Historical planning input (not current requirements).** This blueprint is an
|
||||
> archived design baseline, not current architecture or status. The current
|
||||
> architecture and dependency rules are
|
||||
> [`architecture/CURRENT.md`](architecture/CURRENT.md) and
|
||||
> [ADR-0071](adr/0071-engine-host-contract-boundary.md); executed state is
|
||||
> [`STATUS.md`](STATUS.md). Do not derive a current gate or a crate split from
|
||||
> this file.
|
||||
>
|
||||
> **状态**:架构基线提案 M0.5 / 新仓库实施蓝图(不是已实现功能清单)
|
||||
> **面向**:语言设计者、编译器/运行时开发者、插件开发者、贡献者及自动化编码智能体
|
||||
> **日期**:2026-11-20
|
||||
> **建议仓库位置**:`docs/DEVELOPMENT_BLUEPRINT.md`
|
||||
> **优先阅读**:本文件 → `spec/` 形式规范 → `tests/conformance/` 金样 → 相关模块源码
|
||||
> **优先阅读(归档语境)**:本文件 → `spec/` 形式规范 → `tests/conformance/` 金样 → 相关模块源码。当前入口请改用 `docs/architecture/CURRENT.md`、`docs/architecture/RFC-LANG-0002-unified-semantics.md` 与 `docs/developers/README.md`。
|
||||
> **约定**:**[D]** 已确定的设计方向;**[P]** 本文提出的可实现细节,须经形式化测试和 ADR 批准后冻结;**[F]** 后期能力,不应阻塞首个独立运行版本。
|
||||
|
||||
> **语言映射状态(2026-11-21,必读)**:本文档原本是 M0.5/M0.6 期的架构蓝图,其中关于 Markdown 程序角色的描述(旧映射:`Strong`=执行、`Emph`=返回、有序列表=分支、无序列表=循环、引用块=调用、首个独立 CodeSpan=签名)**已被废止,仅作为历史设计记录**。现行唯一语言语义权威是
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
3. 冻结 CLI 的外部仓库黑盒验收在**发布 SHA**重新执行,至少 pure pinned-Git 包、Callable Worker、陌生 Foreign Kernel、Provider v2、Tool/Analysis/Trace、权限负例及工件改动负例全部 PASS;生成并校验 `docs/evidence/extension/<SHA>/manifest.json`。
|
||||
4. 冷安装、离线 `--version`/`--help`、`check/run/call`、lock/sync、Tool 安装与分发、Provider Worker 启动、错 SHA/错目标/未授权拒绝全部由发布归档中的**实际二进制**完成;不得依赖开发源码目录。
|
||||
5. **不得虚假宣传安全隔离。** 发布包若保留并开放 Linux `strict`,必须有该 SHA 的真实 G3 隔离负例证据;若暂无证据,需采用明确经过测试的 fail-closed 禁用方式并在公告中写 `strict: unsupported`。不允许仅改 README 却继续将未验证的 `strict` 描述为安全保障。Beta 的这一策略必须经维护者明确签字并由 CI 可复查。
|
||||
6. G4 基准不得造假;若当期固定节点仍是 WARN,可由维护者批准 **Beta-only WARN** 并公开环境和限制;必须通过 9 个正确性基准,不允许数值漂移或已确认的灾难性回退。
|
||||
6. G4 基准不得造假;若当期固定节点仍是 WARN,可由维护者批准 **Beta/RC-only WARN** 并公开环境和限制;必须通过正确性基准,不允许数值漂移或已确认的灾难性回退。RC 允许经维护者批准的共享节点 WARN;最终 stable/LTS 必须使用专用固定节点,该共享节点例外不延续到 LTS。
|
||||
7. 明确产品版本 `3.0.0-beta.1` 与协议独立版本;工具 SemVer 协商在真实测试版上可安装、拒绝不兼容范围、不会误把 `<1` 当成支持 3.x。
|
||||
8. `README`、`CHANGELOG`、`COMPATIBILITY`、`docs/STATUS`、`docs/releasing`、协议入口页、迁移说明,均更新至同一事实基线;无“未实现却声称已发布”或“已实现仍称 Proposed”的矛盾。
|
||||
9. 不发布未经实际构建/烟测的平台二进制;产物附 SHA256、SOURCE_SHA、构建工具链信息和已知限制。
|
||||
|
||||
+105
-25
@@ -1,7 +1,9 @@
|
||||
# Marqdo Implementation Status
|
||||
|
||||
Snapshot: **2026-11-25**, product version **`3.0.0-rc.4`** (prerelease
|
||||
candidate). The previous release is `3.0.0-rc.3` at source SHA
|
||||
Snapshot: **2026-11-25**, product version **`3.0.0-rc.4`** (prerelease,
|
||||
released). Tag `v3.0.0-rc.4` at source SHA
|
||||
**`452e9a32bd9e40dba427d4180691c58bab74449e`**; release:
|
||||
https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.4. The previous release is `3.0.0-rc.3` at source SHA
|
||||
**`1e2a045cc78bf40972181abb44e7117c56cf4401`**; release:
|
||||
https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.3. The supported
|
||||
platform is **Linux x86_64 (glibc 2.39)**. The rc.3 same-SHA gate aggregate is
|
||||
@@ -19,9 +21,11 @@ Authoritative release policy:
|
||||
evidence). Support matrix: [`../COMPATIBILITY.md`](../COMPATIBILITY.md).
|
||||
Developer entry point: [`developers/README.md`](developers/README.md).
|
||||
|
||||
This file records what was actually executed. "Implemented" does not mean
|
||||
"verified on every platform"; the evidence column says which commands were run
|
||||
and where. Status is generated from executed commands/logs; a gate row without a
|
||||
The rc.4 same-SHA gate aggregate is
|
||||
[`evidence/ci/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json`](evidence/ci/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json)
|
||||
(decision `RC_RELEASE_CANDIDATE`). This file records what was actually executed.
|
||||
"Implemented" does not mean "verified on every platform"; the evidence column
|
||||
says which commands were run and where. Status is generated from executed commands/logs; a gate row without a
|
||||
command, log or source path is a defect, not a state. Historical snapshots
|
||||
(including M0.5 and the pre-beta `0.1.0` candidate) are preserved under
|
||||
[`history/`](history/README.md) and [`evidence/`](evidence/) and must not be read
|
||||
@@ -30,12 +34,10 @@ as current status.
|
||||
## RC candidate
|
||||
|
||||
The workspace reports `3.0.0-rc.4` and declares Rust 1.89 as its locked
|
||||
minimum. Linux x86_64 on glibc 2.39 is the candidate platform. The
|
||||
[release procedure](releasing.md) requires a green manifest bound to the
|
||||
candidate SHA before publication. A candidate is not a release: it must not be
|
||||
tagged or announced until the same-SHA CI, archive-only cold install, frozen
|
||||
external conformance, strict VM and performance gates are executed for that
|
||||
SHA. The release records below refer to their tagged binaries.
|
||||
minimum. Linux x86_64 on glibc 2.39 is the supported platform. The rc.4
|
||||
manifest is green on its SHA with the documented strict-VM PASS and a
|
||||
maintainer-approved shared-node performance `WARN`; stable/LTS still requires a
|
||||
dedicated fixed node. The release records below refer to their tagged binaries.
|
||||
|
||||
## Current protocol integration
|
||||
|
||||
@@ -73,7 +75,83 @@ The `spec/` tree contains only current contracts; retired specifications are in
|
||||
Git history and tagged archives. The earlier release records below describe
|
||||
their tagged binaries and are not current protocol claims.
|
||||
|
||||
## 0.10 Closed public Analysis boundary — issue #10 (RC.4 candidate)
|
||||
## 0.12 Engine / Host Contract boundary — issue #13 (unreleased candidate)
|
||||
|
||||
This is an **internal architecture candidate**, not a release. The product
|
||||
version stays `3.0.0-rc.4`; no new tag or release claim is made. Baseline is
|
||||
`master` at `4bbefc92449ee480c8a2c89b0308feb4cda8d0e7`; the PR records the exact
|
||||
candidate SHA and evidence is
|
||||
[`evidence/2026-11-26-issue-13-engine-host-boundary.md`](evidence/2026-11-26-issue-13-engine-host-boundary.md).
|
||||
|
||||
Implemented in the candidate:
|
||||
|
||||
- `marqdo-host-contract` owns the only Host trait/HostOp/ExecutionContext/
|
||||
ResourceRead and runtime observation facts. `marqdo-runtime` depends on it,
|
||||
never on `marqdo-host` in normal/build edges. `marqdo-host` implements it and
|
||||
has no reverse dependency on runtime/frontend/IR.
|
||||
- `tests/embedding` is a real independent Cargo workspace/lock consumer that
|
||||
builds without the native host, executes the real Markdown→frontend→IR→runtime
|
||||
path with real fuel/stack/deadline/memory limits and explicit effect
|
||||
refusals, and matches a real CLI invocation on the same `.mq.md` for `Int` and
|
||||
structural values.
|
||||
- `marqdo-plugin-abi` is a contract crate only (C ABI, wire, errors);
|
||||
manifest/artifact validation, `dlopen` and worker process live in
|
||||
`marqdo-host::plugin`. `marqdo-plugin-sdk` transitively carries no loader,
|
||||
worker, host or sandbox dependency.
|
||||
- `tests/sdk-plugin` builds a third-party plugin with only the public SDK; the
|
||||
real CLI loads/invokes it with explicit trust/grant and rejects a tampered
|
||||
artifact digest.
|
||||
- Dependency direction is enforced from Cargo metadata by
|
||||
`tools/ci/check_dependency_boundaries.py` (with negative unit cases) and
|
||||
`cargo test -p marqdo-cli --test architecture_boundaries`.
|
||||
- The current architecture/developer entry and ADR-0071 record the
|
||||
**keep-in-workspace** repository decision; no empty candidate repository was
|
||||
created.
|
||||
|
||||
Executed in this environment (Linux x86_64, Rust 1.100): formatting, clippy,
|
||||
locked workspace tests (**636 passed / 0 failed / 2 ignored**;
|
||||
baseline `4bbefc9` 633 passed / 0 failed / 2 ignored, so no regression), docs/architecture gates, dependency gate, engine
|
||||
differential gate and SDK gate PASS. The Windows GNU cross-target compile check
|
||||
passes; it is not a native Windows runtime claim. Woodpecker PR pipeline #101
|
||||
for code SHA `9b4f0a0` is **success**, including the `build` step (release
|
||||
archive from that SHA, archive smoke, frozen external conformance) and the
|
||||
`minimum-rust` lane; that is same-candidate CI evidence, not a release tag.
|
||||
Deliberately **UNVERIFIED** here: Windows/macOS native lanes, strict VM, WASM
|
||||
probe (target std not installed; `E0463`, not a forbidden native dependency)
|
||||
and performance/RSS. RC.4 evidence is not reused.
|
||||
|
||||
Remaining, separately owned work: stdlib Bundle Phase B (issue #11/#12),
|
||||
SDK physical repository after S07/S08, regex/compression replacement under
|
||||
ADR-0062, foreign F-B (ADR-0063), platform and strict evidence, and the Engine/
|
||||
Native Host split only if the ADR-0071 reopening conditions appear.
|
||||
|
||||
## 0.13 Independent plugin SDK repository — issue #15 (unreleased candidate)
|
||||
|
||||
This is a repository-ownership/architecture change, not a new product release.
|
||||
The contract and plugin ABI behaviour are unchanged. Evidence:
|
||||
[`evidence/2026-11-26-issue-15-sdk-independent-repository.md`](evidence/2026-11-26-issue-15-sdk-independent-repository.md);
|
||||
decision: [ADR-0072](adr/0072-sdk-independent-repository.md).
|
||||
|
||||
- The Rust SDK moved to the public repository
|
||||
[`cflmy/marqdo-plugin-sdk`](https://git.cflmy.cn/cflmy/marqdo-plugin-sdk)
|
||||
(commit `b31187a`), with its own workspace/lock, AGENTS rules, README, license
|
||||
and Woodpecker pipeline definition.
|
||||
- It consumes `marqdo-plugin-abi` from the CLI repository at the exact
|
||||
`rev = 2585915e16906dac75f8571bed02e7f6f868c6bc`; it never uses a `../cli`
|
||||
path, a floating branch, a submodule or a copied ABI/Value Wire.
|
||||
- The CLI repository no longer contains `crates/marqdo-plugin-sdk`,
|
||||
`tests/sdk-plugin` or the CLI-side SDK gate; the SDK does not appear in the
|
||||
workspace or `Cargo.lock`. The CLI does not depend on the SDK.
|
||||
- Clean-clone SDK build/tests and a real integration against the frozen
|
||||
released `3.0.0-rc.4` CLI pass (`Int 42`, tampered digest rejected). CLI
|
||||
workspace tests: 631 passed / 0 failed / 0 ignored (the five SDK tests moved
|
||||
to the SDK repository). The SDK
|
||||
repository's CI repeats those checks; enabling the Woodpecker project for the
|
||||
new repository is an administrative follow-up, not a code claim.
|
||||
- Engine/Native Host remain in the CLI workspace under ADR-0071; no other
|
||||
repository split is approved by this change.
|
||||
|
||||
## 0.10 Closed public Analysis boundary — issue #10 (RC.4 released)
|
||||
|
||||
The candidate replaces the program-only Analysis projection in place under
|
||||
[ADR-0069](adr/0069-public-analysis-boundary.md): exact source and document
|
||||
@@ -107,17 +185,18 @@ Local development-container performance against the rc.3 archive binary on a
|
||||
`--emit` `1.210 / 1.186`, `--refs` `1.145 / 1.093`. These are smoke numbers,
|
||||
not a dedicated-node G4 result.
|
||||
|
||||
Same-SHA CI ([pipeline #89](https://ci.cflmy.cn/repos/1/pipeline/89)) is PASS
|
||||
for the candidate code SHA `e0645f3` on all four lanes, and the follow-up
|
||||
CI/tooling tree `b1fc211` is fully green in
|
||||
[pipeline #91](https://ci.cflmy.cn/repos/1/pipeline/91); its build lane packaged the archive, ran the
|
||||
archive smoke and the frozen extension suite 7/7. A local same-SHA archive
|
||||
passed smoke and the archive-only Ubuntu 24.04 cold-install container, and the
|
||||
frozen suite passed 7/7 from a clean worktree. The gate aggregate is
|
||||
[`evidence/ci/e0645f376b03e31e342a6d3fb749a335f0840d1b/manifest.json`](evidence/ci/e0645f376b03e31e342a6d3fb749a335f0840d1b/manifest.json)
|
||||
and decides `DO_NOT_RELEASE`: the RC profile still requires a same-SHA strict
|
||||
VM PASS and an approved G4 node result, neither of which is available here. The
|
||||
rc.3 rows below remain the last published release evidence.
|
||||
Same-SHA CI ([pipeline #94](https://ci.cflmy.cn/repos/1/pipeline/94)) is PASS
|
||||
for `452e9a3` on all four lanes; its build lane packaged the archive, ran smoke
|
||||
and the frozen extension suite 7/7. The local same-SHA archive passed smoke,
|
||||
the archive-only Ubuntu 24.04 cold-install container and frozen conformance
|
||||
7/7. Strict L1 PASS is recorded from a disposable QEMU/TCG VM as non-root
|
||||
`dev` (uid 1000), with the archived binary re-verified in that VM. Performance
|
||||
is a maintainer-approved shared-node `WARN` for this RC only; stable/LTS still
|
||||
requires a dedicated fixed node. The gate aggregate is
|
||||
[`evidence/ci/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json`](evidence/ci/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json)
|
||||
(`RC_RELEASE_CANDIDATE`). Release
|
||||
[notes and assets](https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.4).
|
||||
Downstream migration issues: `marqdo-view#6`, `marqdo-lint#4`.
|
||||
|
||||
## 0.9 Pre-stable protocol convergence — issue #8 (RC.3 candidate)
|
||||
|
||||
@@ -697,8 +776,9 @@ This is still a **local VM lane**, not a self-hosted GitHub Actions security URL
|
||||
- Test and documentation migration (review RFC-CM P0/P2):
|
||||
`crates/cli/tests/docs_consistency.rs` pins one current overview, the
|
||||
status/index links and SHA-pinned evidence; `crates/cli/tests/architecture_boundaries.rs`
|
||||
pins the workspace graph, `marqdo-runtime -> marqdo-host`, the bundled stdlib
|
||||
digest and the stdio/file/TCP endpoints; `crates/cli/tests/stdlib_product.rs`
|
||||
pins the workspace graph, `marqdo-runtime -> marqdo-host` (historical at that
|
||||
snapshot; the current edge is `marqdo-runtime -> marqdo-host-contract` under
|
||||
ADR-0071), the bundled stdlib digest and the stdio/file/TCP endpoints; `crates/cli/tests/stdlib_product.rs`
|
||||
runs every public stdlib module (`clock/compress/console/csv/datetime/demo/env/format/fs/http/io/json/path/process/random/regex/stream/table/text/utf8`)
|
||||
through `std:` imports over `stdlib/tests/*.mq.md`. `tools/pack-stdlib.py`
|
||||
now sorts `.mq.md` by the same relative path key as the CLI. Source/test baseline
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
# ADR-0071 — Engine / Host Contract / Native Host / CLI boundaries
|
||||
|
||||
Status: **Accepted** for the pre-stable 3.0 line (2026-11-26).
|
||||
The SDK portion of the repository decision was later implemented by
|
||||
[ADR-0072](0072-sdk-independent-repository.md) (independent public SDK
|
||||
repository pinned to this contract); the Engine/Native Host keep-in-workspace
|
||||
decision is unchanged.
|
||||
|
||||
Supersedes the historical review-RFC position that a Host contract crate is a
|
||||
second-step, optional move. It does not supersede the language contract
|
||||
(ADR-0052 / RFC-LANG-0002), the resource/operation ownership rules (ADR-0062),
|
||||
the foreign F-A boundary (ADR-0063), the single-contract policy (ADR-0068) or
|
||||
the explicit stdlib Bundle build input (ADR-0070 where landed). It replaces only
|
||||
the old architecture-gate constraints that asserted `marqdo-runtime ->
|
||||
marqdo-host` and a frozen crate count.
|
||||
|
||||
## Context
|
||||
|
||||
Issue #13 audited the tree at `4bbefc9…` and found:
|
||||
|
||||
- the runtime linked the native host (`marqdo-host`) even though the interpreter
|
||||
already accepted `&mut dyn Host`;
|
||||
- the `Host` trait, `HostOp` and `StdHost` lived in one module, and
|
||||
`ResourceRead` sat beside real file/TCP/TLS implementations;
|
||||
- the plugin ABI crate contained the C contract, the wire envelope, manifest
|
||||
validation, artifact selection, `dlopen` and the worker process, so the
|
||||
third-party SDK transitively carried execution-side dependencies;
|
||||
- old architecture gates froze sixteen crate names and the
|
||||
runtime-to-native-host edge, so the intended boundary could not be tested;
|
||||
- historical planning documents competed with the current overview as a source
|
||||
of truth.
|
||||
|
||||
The same audit fixed the scope: one language implementation, one contract per
|
||||
public boundary, no second interpreter, no new runtime protocol, no mandatory
|
||||
remote repository split, and no empty candidate repositories. Missing
|
||||
independent-consumer evidence means "keep in the workspace" is the correct
|
||||
repository decision.
|
||||
|
||||
## Decision
|
||||
|
||||
### Responsibilities
|
||||
|
||||
| Layer | Owns | Must not own |
|
||||
|---|---|---|
|
||||
| Engine | Span, Value, expression, the one Markdown profile, IR, frontend mapping/static binding, Runtime evaluation and `Memory`, and the neutral Host contract | concrete OS I/O, sandbox launch, plugin loading, project filesystem, CLI commands |
|
||||
| `marqdo-host-contract` | `Host` trait, `HostOp`, `ExecutionContext`, `ResourceRead`, `FrameId`, `ParameterSource`, `LoopTransfer`, `RuntimeObservation` | native implementation, grant policy, the public Observation wire encoding, any wire/RPC protocol |
|
||||
| Native Host (`marqdo-host` and its sandbox/foreign support crates) | capability broker, resources and handles, OS adapters, budgets/deadlines, observation sink, trusted plugin/provider/foreign execution | language parsing/evaluation, a second static binder, CLI projection |
|
||||
| `marqdo-plugin-abi` | C ABI v1 layout/assertions, wire envelope and protocol errors | `dlopen`, worker/process management, artifact/manifest file execution, capability grants |
|
||||
| `marqdo-host::plugin` | manifest/artifact validation, native loading, worker process, invocation dispatch | a second ABI or wire definition |
|
||||
| `marqdo-plugin-sdk` | third-party developer helpers over the public contract | host, loader, CLI, worker execution, sandbox |
|
||||
| CLI | arguments, single `project_prepare`, command routing, product Analysis/Observation projection, Tool install/dispatch, Host+Runtime assembly | language evaluation, domain algorithms, a second binding path |
|
||||
|
||||
### Dependency rules
|
||||
|
||||
- `marqdo-runtime -> marqdo-host-contract` only. The engine crates must not reach
|
||||
`marqdo-host`, sandbox, foreign, plugin ABI/SDK, worker, package, CLI,
|
||||
`libloading`, `rustls` or other native/domain dependencies on normal or build
|
||||
edges.
|
||||
- `marqdo-host-contract -> marqdo-value, marqdo-span` only.
|
||||
- The native host may implement the contract and consume the public ABI, but it
|
||||
must not depend back on runtime, frontend, IR or the CLI.
|
||||
- The CLI is the only composition root allowed to combine engine + native host +
|
||||
package. `check`/`inspect` never load a native library, start a worker or
|
||||
access the network.
|
||||
- `marqdo-plugin-sdk` consumes only `marqdo-plugin-abi`; it must not depend on a
|
||||
loader, host, worker process, sandbox or CLI.
|
||||
- There is no second `Host`/`HostOp`, no second Value encoding, no
|
||||
`EngineValue`/`HostValue`/`WireIR`, no HTTP/RPC/JSON handshake for the
|
||||
engine-to-host edge and no `legacy` feature. The Rust trait is an internal
|
||||
compile-time interface inside one codebase.
|
||||
|
||||
### Invariants preserved (not moved, not weakened)
|
||||
|
||||
- Fuel, stack depth, deadline, output budget and `Memory` limits stay owned and
|
||||
checked exactly where they were; replacing the host must not remove a check.
|
||||
The contract carries the calls, not platform-neutral defaults that silently
|
||||
grant unlimited budgets.
|
||||
- Capability grants, resource identity/handles, cleanup, provider registration,
|
||||
strict isolation, plugin trust, foreign supervision and observation privacy
|
||||
stay owned by the native host and CLI. `check`/`inspect` stay non-executing.
|
||||
- Static binding remains single: one registry, one `bind_program_calls`, one
|
||||
`CallBindingTable`; the runtime never re-resolves names.
|
||||
- Public protocols are unchanged: Analysis revision 3, Observation revision 1,
|
||||
Tool revision 1, Plugin ABI 1.0, Value Wire 1, Provider v2, lock v4. Moving
|
||||
Rust modules is not a protocol change.
|
||||
- Stdlib runtime contract is unchanged. Phase A/B of issue #11/#12 remain a
|
||||
separate delivery; the CLI does not gain a second Bundle format or a dev
|
||||
fallback authority.
|
||||
|
||||
### Repository decision
|
||||
|
||||
The Engine and Native Host stay in this workspace. Issue #13 §9.2 admission is
|
||||
not met: there is no real external Engine consumer or independent platform
|
||||
maintainer, and an empty candidate repository would be a prohibited boundary
|
||||
violation. This ADR records **keep in workspace** as the legal conclusion and
|
||||
names the reopening conditions in `docs/architecture/CURRENT.md` §7.
|
||||
|
||||
The plugin SDK's physical move landed as [ADR-0072](0072-sdk-independent-repository.md):
|
||||
a standalone public repository consumes this contract at one pinned CLI `rev`.
|
||||
The Engine and Native Host stay here; no gitlink/submodule or empty
|
||||
`marqdo-cli-*` repository is created by this ADR.
|
||||
|
||||
## Verification
|
||||
|
||||
The acceptance gates are executable, not documentary:
|
||||
|
||||
- `tools/ci/check_dependency_boundaries.py` reads Cargo metadata for the
|
||||
workspace and the independent consumer, checks the reviewed crate allowlist and
|
||||
the forbidden transitive edges, and is itself covered by
|
||||
`tools/ci/test_dependency_boundaries.py` negative cases.
|
||||
- `tests/embedding` is a separate workspace and lock file; it executes a real
|
||||
`.mq.md` through Markdown → frontend → static binding → runtime with a bounded
|
||||
test host, and rejects fuel/stack/deadline/memory/resource violations.
|
||||
- `tools/ci/check_engine_boundary.py` builds and runs that consumer, builds the
|
||||
real CLI, executes the same file and compares terminal Value Wire results, and
|
||||
checks the runtime build tree.
|
||||
- `tools/ci/check_plugin_sdk.py` builds the SDK fixture with the public SDK and
|
||||
loads it through the real CLI with explicit trust/grant, then rejects a
|
||||
tampered artifact digest.
|
||||
- `cargo test -p marqdo-cli --test architecture_boundaries` keeps the semantic
|
||||
gates (single Host trait, plugin contract split, engine-only consumer, reviewed
|
||||
HostOp/Value/builtin/resource-operation catalogues) and the existing security
|
||||
and product checks.
|
||||
- Evidence for the candidate commit lives in
|
||||
`docs/evidence/2026-11-26-issue-13-engine-host-boundary.md` and
|
||||
`docs/STATUS.md`. Platform lanes not executed here stay `UNVERIFIED`; no old
|
||||
release evidence is reused as a new PASS.
|
||||
|
||||
## Rejected alternatives
|
||||
|
||||
- **Create `marqdo-engine`/`marqdo-host` remote repositories now.** No real
|
||||
consumer, no ownership/release boundary, prohibited empty candidates; would
|
||||
also create a cross-repository atomic-semantics tax.
|
||||
- **Keep the runtime linked to `marqdo-host` and only rename the crate.** Does
|
||||
not close the dependency edge; an embedded consumer would still link native
|
||||
TLS, loading and process code.
|
||||
- **Move the whole `observe` module or CLI projection into the contract.** The
|
||||
interpreter needs only the emitted facts; the sink, redaction and public
|
||||
envelope belong to the host/CLI, and moving them would create a second
|
||||
protocol centre.
|
||||
- **Leave manifest/artifact in the ABI crate.** The SDK would transitively keep
|
||||
`serde_yaml`/digest/native-adjacent code and the contract crate would again own
|
||||
execution-side choices.
|
||||
- **Add a compatibility re-export of the old `marqdo_host::{Host, ...}` paths.**
|
||||
Creates a second active path; all in-tree consumers are updated atomically.
|
||||
- **Loosen the old gates instead of replacing them.** Security, product,
|
||||
protocol and negative tests are retained; only the frozen crate-name and
|
||||
runtime-to-native-host assertions are replaced by the responsibility graph.
|
||||
|
||||
## Consequences
|
||||
|
||||
- An independent consumer can build and compute without the native host or CLI.
|
||||
- Adding a host capability does not change engine code; adding an engine semantic
|
||||
change does not change host code.
|
||||
- The workspace gains one small contract crate and one plugin module move; crate
|
||||
count is explicitly not a KPI.
|
||||
- Unfinished ecosystem work (stdlib Phase B, SDK physical repository, regex/
|
||||
compression migration, foreign F-B, WASM probe, Windows/macOS/strict evidence)
|
||||
remains open and honestly recorded; none of it is required to close the core
|
||||
M0–M4 boundary work.
|
||||
@@ -0,0 +1,106 @@
|
||||
# ADR-0072 — Independent `marqdo-plugin-sdk` repository
|
||||
|
||||
Status: **Accepted** (2026-11-26).
|
||||
|
||||
Complements [ADR-0071](0071-engine-host-contract-boundary.md) and implements the
|
||||
SDK follow-up tracked by issue [#15](https://git.cflmy.cn/cflmy/marqdo-cli/issues/15)
|
||||
after the contract decoupling of issue #13.
|
||||
|
||||
## Context
|
||||
|
||||
Issue #13 / ADR-0071 separated the public plugin contract from its execution
|
||||
side:
|
||||
|
||||
- `marqdo-plugin-abi` (CLI repository) now contains only the C ABI v1 layout,
|
||||
the wire envelope and protocol errors;
|
||||
- `dlopen`, manifest/artifact file handling, worker management and invocation
|
||||
dispatch live in `marqdo-host::plugin`;
|
||||
- `marqdo-plugin-sdk` consumed only the contract and was verified by a real
|
||||
fixture loaded through the CLI.
|
||||
|
||||
The SDK is a leaf with a different consumer group (third-party plugin authors),
|
||||
a different change cadence and an independent release need. Keeping it in the
|
||||
CLI workspace made the architecture map imply that the CLI product owns SDK
|
||||
publication and forced every SDK change through the CLI build. Issue #15
|
||||
required either fixing the distribution input or recording a blocking ticket.
|
||||
The CLI repository is public, so a fixed Cargo git `rev` is a fetchable
|
||||
contract input; there is no need for a submodule, a vendored contract copy or a
|
||||
second wire implementation.
|
||||
|
||||
This is a **deliberate, narrow repository split**, not a mechanical projection
|
||||
of every crate: engine and native host remain in the CLI workspace (ADR-0071
|
||||
reopening conditions unchanged), and no empty candidate repository is created.
|
||||
|
||||
## Decision
|
||||
|
||||
### Topology
|
||||
|
||||
| Item | Decision |
|
||||
|---|---|
|
||||
| SDK repository | Public `cflmy/marqdo-plugin-sdk` (`main`), own Cargo workspace and lock |
|
||||
| Contract input | `marqdo-plugin-abi` from `https://git.cflmy.cn/cflmy/marqdo-cli.git` at exact `rev = 2585915e16906dac75f8571bed02e7f6f868c6bc` (the merge commit that landed ADR-0071) |
|
||||
| CLI dependency on SDK | **None**. CLI normal/build/test lanes do not fetch or build the SDK |
|
||||
| CLI workspace | `crates/marqdo-plugin-sdk` removed; the SDK is not a workspace member |
|
||||
| Submodule/gitlink | **Not used** for this split; the SDK leaf must not create a CLI↔SDK identity cycle |
|
||||
| Acceptance fixture | `tests/fixture` in the SDK repository only; real invocation uses a **frozen released CLI binary** via `tools/check_with_frozen_cli.py` |
|
||||
| Contract authority | Unchanged: CLI owns the C header, Rust layout, Value Wire and error encodings; the SDK never defines a second contract |
|
||||
| Publication | SDK releases are versioned independently against a contract generation; bumping the pinned CLI `rev` is a reviewed change |
|
||||
|
||||
### Rules
|
||||
|
||||
- The SDK repository must resolve and build from a clean clone without the CLI
|
||||
checkout; only its fixed git dependency may reach the CLI repository.
|
||||
- It must not depend on `libloading`, a native host, worker execution, sandbox
|
||||
or CLI code.
|
||||
- The SDK's fixture is a third-party plugin built with only the public SDK. It
|
||||
is verified against a frozen CLI archive (same ABI 1.0 contract), not against a
|
||||
locally rebuilt CLI.
|
||||
- The CLI repository must not reintroduce the SDK as a workspace member, a
|
||||
copied source tree or a compatibility path; `tools/ci/check_dependency_boundaries.py`
|
||||
and `architecture_boundaries.rs` fail if it does.
|
||||
- The CLI's public contract is authoritative; the SDK repository README and
|
||||
AGENTS rules point back to `include/marqdo_plugin_abi_v1.h`,
|
||||
`spec/plugin-abi.md` and the pinned commit.
|
||||
- The existing security statement remains: a C ABI is not a sandbox, and native
|
||||
loading requires explicit trust; the SDK grants no capability.
|
||||
|
||||
## Verification (candidate)
|
||||
|
||||
- SDK repository commit `b31187a` on `main`:
|
||||
- clean-clone `cargo build --locked` and `cargo test --locked` pass;
|
||||
- the fixture builds with only the SDK;
|
||||
- `tools/check_with_frozen_cli.py --marqdo-bin <released marqdo 3.0.0-rc.4>`
|
||||
returns `Int 42` and rejects a tampered artifact digest.
|
||||
- CLI candidate removes the SDK crate, fixture and CLI-side gate; workspace
|
||||
tests, architecture boundaries, docs consistency and dependency gates pass;
|
||||
the SDK no longer appears in the workspace or lock file.
|
||||
- Full evidence: `docs/evidence/2026-11-26-issue-15-sdk-independent-repository.md`.
|
||||
|
||||
## Rejected alternatives
|
||||
|
||||
- **Keep the SDK in the CLI workspace** while calling the contract "decoupled":
|
||||
leaves two release cadences and ownership in one repo; issue #15 cannot close.
|
||||
- **Git submodule/gitlink into the CLI repo**: CLI does not consume the SDK, so
|
||||
a submodule would create an unnecessary recursive identity and checkout
|
||||
failure mode.
|
||||
- **Relative path dependency `../cli`**: not an independent build; forbidden by
|
||||
issue #13 §6.2.
|
||||
- **Copy `marqdo-plugin-abi`/Value Wire into the SDK repo**: would create a
|
||||
second contract and wire encoder authority.
|
||||
- **Publish the contract to a registry first**: no registry/release channel is
|
||||
approved here; the public git `rev` is the available precise input. A future
|
||||
published artifact can replace the git `rev` without changing authority.
|
||||
|
||||
## Consequences and rollback
|
||||
|
||||
- The architecture map now shows one CLI contract producer and one independent
|
||||
SDK consumer; CLI CI no longer carries SDK-only checks, and SDK CI owns them.
|
||||
- The SDK remains pinned to a CLI merge commit. Changing the contract or
|
||||
advancing the pin is a deliberate cross-repository change with its own
|
||||
evidence; a contract change must land in the CLI first, then the SDK pin is
|
||||
bumped.
|
||||
- Rollback is a complete known-good combination: keep the CLI commit and the SDK
|
||||
pin that were verified together; do not restore a copied SDK or an old ABI.
|
||||
- External SDK consumers can fetch the public CLI contract today. If a
|
||||
registry-published contract or a different visibility policy is later chosen,
|
||||
that is a new ADR, not an implicit change.
|
||||
@@ -70,3 +70,9 @@ Files: `0001`–`0050`, plus:
|
||||
pre-stable public boundary, replaced in place;
|
||||
* [0069](0069-public-analysis-boundary.md) — one public Analysis projection for
|
||||
independent document, lint and knowledge consumers.
|
||||
* [0071](0071-engine-host-contract-boundary.md) — Engine / Host Contract /
|
||||
Native Host / CLI responsibilities, dependency rules, plugin ABI contract split
|
||||
and the keep-in-workspace repository decision.
|
||||
|
||||
* [0072](0072-sdk-independent-repository.md) — independent public
|
||||
`cflmy/marqdo-plugin-sdk` repository pinned to one CLI contract `rev`.
|
||||
@@ -4,11 +4,55 @@ Status: **current architecture overview**. This file summarises the tree as it
|
||||
is today. It is not a release promise, does not reopen a frozen ADR, and does not
|
||||
replace `spec/` or a recorded test log.
|
||||
|
||||
- Baseline: `1e2a045cc78bf40972181abb44e7117c56cf4401` (2026-11-24, tagged `v3.0.0-rc.3`; same-SHA evidence in `../STATUS.md` and `../evidence/ci/1e2a045cc78bf40972181abb44e7117c56cf4401/manifest.json`). The `3.0.0-rc.4` candidate state is recorded in `../STATUS.md` §0.10.
|
||||
- Baseline: `452e9a32bd9e40dba427d4180691c58bab74449e` (2026-11-25, tagged `v3.0.0-rc.4`; same-SHA evidence in `../STATUS.md` and `../evidence/ci/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json`).
|
||||
- Normative behavior: `spec/`; frozen decisions: `docs/adr/`; executed evidence: `docs/STATUS.md` and `docs/evidence/`.
|
||||
- This is the **single current overview**. Do not add a second running "current state" file;
|
||||
update this file, `docs/STATUS.md` and an evidence file together.
|
||||
|
||||
## Engine / Host Contract / Native Host boundary (issue #13, ADR-0071)
|
||||
|
||||
The language engine is independent of every concrete native platform
|
||||
implementation. `marqdo-host-contract` owns the only side-effect interface the
|
||||
runtime knows (`Host`, `HostOp`, `ExecutionContext`, `ResourceRead` and the
|
||||
runtime observation facts); `marqdo-host` implements it with capabilities,
|
||||
resources, OS adapters and trusted extension execution; `crates/cli` remains the
|
||||
single product assembly. The plugin ABI crate is a public contract only: native
|
||||
loading, artifact/manifest execution and worker processes live in
|
||||
`marqdo-host::plugin`. The SDK depends on the contract, not on a loader or a
|
||||
host.
|
||||
|
||||
The Engine and the Native Host stay in **this workspace**. Issue #13 §9.2
|
||||
admission for a separate repository is not met yet: there is no real external
|
||||
Engine consumer outside the in-repo acceptance fixture, and no independent
|
||||
platform maintainer. A candidate empty `marqdo-engine`/`marqdo-host` repository
|
||||
would violate the issue's boundary conditions. The decision and its reopening
|
||||
conditions are recorded in [ADR-0071](../adr/0071-engine-host-contract-boundary.md).
|
||||
|
||||
## Workspace crate responsibility map
|
||||
|
||||
This is the reviewed allowlist for workspace members. A new crate must be added
|
||||
here, in `tools/ci/check_dependency_boundaries.py`, and with its dependency edges
|
||||
in the same change.
|
||||
|
||||
| Crate | Layer | Responsibility |
|
||||
|---|---|---|
|
||||
| `marqdo-span` | Engine | UTF-8 position and diagnostic base types |
|
||||
| `marqdo-value` | Engine | `Value`, `RuntimeError`, the one Value Wire encoding |
|
||||
| `marqdo-expression` | Engine | Expression grammar |
|
||||
| `marqdo-markdown` | Engine | The only Markdown profile and AST |
|
||||
| `marqdo-ir` | Engine | IR, function/binding identity, builtin inventory |
|
||||
| `marqdo-frontend` | Engine | Document mapping, signatures, static binding |
|
||||
| `marqdo-runtime` | Engine | Evaluator, control flow and `Memory` |
|
||||
| `marqdo-host-contract` | Engine boundary | Neutral `Host` trait and runtime observation facts |
|
||||
| `marqdo-host` | Native Host | Capabilities, resources, OS adapters, plugin loader and trusted execution |
|
||||
| `marqdo-sandbox` | Native Host support | OS isolation probe and strict launch |
|
||||
| `marqdo-foreign` | Native Host support | Controlled one-shot foreign kernels (F-A) |
|
||||
| `marqdo-plugin-abi` | Public contract | C ABI v1 layout, wire envelope and protocol errors |
|
||||
| `marqdo-worker-ipc` | Shared plumbing | One bounded worker frame transport |
|
||||
| `marqdo-provider-worker` | Shipped worker | Provider helper process |
|
||||
| `marqdo-package` | Product support | Project manifest, lock and dependency resolution |
|
||||
| `marqdo-cli` | Composition root | Arguments, prepare, commands, product projection |
|
||||
|
||||
> **Language contract and implementation.** The language contract is
|
||||
> [RFC-LANG-0002](RFC-LANG-0002-unified-semantics.md) (adopted by ADR-0052) and
|
||||
> `spec/mapping.md`. The frontend, `marqdo-expression`, IR lowering, runtime and
|
||||
@@ -156,11 +200,14 @@ Layer rules:
|
||||
Current Rust dependency edges (documented, not proposed):
|
||||
|
||||
```text
|
||||
marqdo-cli -> marqdo-runtime -> marqdo-host
|
||||
marqdo-cli -> marqdo-package, marqdo-sandbox, marqdo-frontend, ...
|
||||
marqdo-cli -> marqdo-runtime -> marqdo-host-contract
|
||||
marqdo-cli -> marqdo-host, marqdo-package, marqdo-sandbox, marqdo-frontend, ...
|
||||
marqdo-runtime -> marqdo-ir, marqdo-expression, marqdo-value
|
||||
marqdo-host -> marqdo-plugin-abi, marqdo-foreign, marqdo-sandbox, marqdo-worker-ipc
|
||||
marqdo-plugin-abi -> marqdo-worker-ipc
|
||||
marqdo-host-contract -> marqdo-value, marqdo-span
|
||||
marqdo-host -> marqdo-host-contract, marqdo-plugin-abi, marqdo-foreign,
|
||||
marqdo-sandbox, marqdo-worker-ipc
|
||||
marqdo-plugin-abi -> marqdo-value, serde/serde_json (contract only)
|
||||
[cflmy/marqdo-plugin-sdk] -> cflmy/marqdo-cli#marqdo-plugin-abi @ pinned rev
|
||||
marqdo-provider-worker -> marqdo-worker-ipc
|
||||
```
|
||||
|
||||
@@ -170,10 +217,13 @@ copy of bounded worker framing, deadlines and process teardown
|
||||
host, the plugin ABI, or a worker binary; sharing plumbing must not share
|
||||
capabilities. Foreign kernels and CLI Tools stay outside it.
|
||||
|
||||
`marqdo-runtime -> marqdo-host` is the current direction. Do not add a second
|
||||
execution backend or a `marqdo-stdlib` crate by implication. A future embedded
|
||||
runtime or a second backend needs the thin `ExecutionPort` contract described in the
|
||||
review RFC, not a new crate per provider.
|
||||
`marqdo-runtime -> marqdo-host-contract` is the only engine-to-host edge. The
|
||||
engine must never link `marqdo-host`, sandbox, foreign, plugin loading or the
|
||||
CLI in normal/build dependencies. The native host must not depend back on the
|
||||
runtime/frontend/IR. `tools/ci/check_dependency_boundaries.py` enforces the
|
||||
transitive graph from Cargo metadata; `tests/embedding` proves a real
|
||||
platform-neutral consumer. Do not add a second execution backend, a per-provider
|
||||
crate, or a `marqdo-stdlib` crate by implication.
|
||||
|
||||
| Public contract | API (`.mq.md`) | State | Tests |
|
||||
|---|---|---|---|
|
||||
@@ -231,6 +281,7 @@ that a phase is complete.
|
||||
| P0 | **Language syntax migration**: RFC-LANG-0002 single contract | **closed at `9c1723d`**; implementation, stdlib digest, examples and fixtures green; platform/strict evidence remains separate |
|
||||
| P0 | Stdlib release is a bundle in this repo; extraction is deferred (ADR-0039) | accepted, keep in repo |
|
||||
| P0 | Documentation drift between `STATUS.md`, the architecture index and the evidence | being fixed by this migration and the docs gate |
|
||||
| P1 | Domain service ownership ledger (issue #13 §7): host-held `regex.*` and `compress.*` are ADR-0062 services, not a precedent for new domain operations | **DEFERRED** to the responsible `marqdo-ext-regex`/`marqdo-ext-archive` replacement issues; old entries stay until a real replacement passes authorization/negative tests |
|
||||
| P1 | `std:fs/file` read/write/copy, metadata/directory, append/read_at/walk are implemented; watch and binary offset reads remain open | open |
|
||||
| P1 | No file watch or binary `read_at` | open; future Resource Operation extension |
|
||||
| P1 | JSON/CSV product parsers are implemented with depth bound and multi-value/multi-row; no incremental streaming parser | open |
|
||||
@@ -268,7 +319,23 @@ that a phase is complete.
|
||||
current contract, replace in place, reject retired inputs, no compatibility
|
||||
path or version negotiation, and no version bump without a shape change.
|
||||
|
||||
## 7. References
|
||||
## 7. Repository decision and split admission
|
||||
|
||||
| Component | Decision for this round | Reopen condition (issue #13 §9.2) |
|
||||
|---|---|---|
|
||||
| Engine (`span`/`value`/`expression`/`markdown`/`ir`/`frontend`/`runtime`/`host-contract`) | **Keep in this workspace** as one atomic semantic-change domain | A real, non-in-repo consumer needs independent build/release, and the semantic change cost is acceptable |
|
||||
| Native Host (`host`/`sandbox`/`foreign`/plugin loader) | **Keep in this workspace**, dependent on the neutral contract | An independent platform maintainer or second product consumes it; security/conformance can be verified separately |
|
||||
| `marqdo-plugin-sdk` | **Moved to independent public repository** `cflmy/marqdo-plugin-sdk` ([ADR-0072](../adr/0072-sdk-independent-repository.md)) | Contract input is a pinned CLI git `rev`; clean-clone build + frozen-CLI integration are the SDK repository's gates. CLI must not depend on it or re-add a copy |
|
||||
| Stdlib | Separate issue #11/#12 (Phase A build input); runtime contract unchanged | Ecosystem-assembled Bundle and extension replacement accepted; then retire the in-repo source authority |
|
||||
| Regex/compression domain services | **DEFERRED** under ADR-0062 ownership; no new domain operation may be added | A separately installable extension replaces the host-held service and the old entries are removed atomically |
|
||||
| Foreign F-A | Retained; no F-B, session or new transport in this change | Separate ADR and milestone |
|
||||
|
||||
No candidate empty `marqdo-engine`, `marqdo-host` or `marqdo-cli-*` repository
|
||||
is created by this decision. Git repository boundaries are ownership and release
|
||||
boundaries, not a mechanical projection of Cargo crates. The engine and native
|
||||
host are one source tree until the reopening evidence above exists.
|
||||
|
||||
## 8. References
|
||||
|
||||
- [Architecture index](README.md) — RFC/ADR/evidence history.
|
||||
- [Protocol convergence policy](PROTOCOL_CONVERGENCE_POLICY.md) — one-contract rules, anti-patterns and review checklist.
|
||||
@@ -288,7 +355,11 @@ that a phase is complete.
|
||||
- [ADR-0050: host regex extension](../adr/0050-host-regex-extension.md) — accepted project-mode groups/alternation/captures.
|
||||
- [ADR-0052: byte-exact HTTP framing](../adr/0051-byte-exact-http-framing.md) — accepted byte-list HTTP/1.1 parser/builder.
|
||||
- [Compute-machine RFC-0001](../MARQDO_COMPUTE_MACHINE_RFC_0001.md) and [core/stdlib RFC-0002](../MARQDO_COMPUTE_CORE_STDLIB_MIGRATION_RFC_0002.md) — design input.
|
||||
- [Architecture audit and refactor RFC](Marqdo_CLI_Latest_Architecture_Audit_and_Refactor_RFC.md) — review input for this migration.
|
||||
- [Architecture audit and refactor RFC](Marqdo_CLI_Latest_Architecture_Audit_and_Refactor_RFC.md) — historical review input; the current boundary decision is ADR-0071.
|
||||
- [ADR-0071: Engine / Host Contract / Native Host boundaries](../adr/0071-engine-host-contract-boundary.md) — accepted responsibility split and keep-in-workspace decision for issue #13.
|
||||
- [ADR-0072: Independent `marqdo-plugin-sdk` repository](../adr/0072-sdk-independent-repository.md) — the one deliberate repository split (public SDK leaf pinned to the CLI contract).
|
||||
- [Issue #15 SDK split evidence](../evidence/2026-11-26-issue-15-sdk-independent-repository.md) — clean-clone build and frozen-CLI integration.
|
||||
- [Issue #13 engine/host evidence](../evidence/2026-11-26-issue-13-engine-host-boundary.md) — executed candidate commands and results.
|
||||
- [RFC-EXT-0001](RFC-EXT-0001.md) — extensibility closure task specification (implementation status tracked here and in STATUS).
|
||||
- [ADR-0054: single callable binding](../adr/0054-callable-binding-single-source.md) — one registry/binding pass, runtime dispatch by identity.
|
||||
- [ADR-0055: resource provider CLI v2](../adr/0055-resource-provider-cli-v2.md) — provider v2 manifest/worker CLI closure and trust boundary.
|
||||
|
||||
@@ -8,6 +8,12 @@ input and evidence. It is not a second running-status page.
|
||||
- Public-contract convergence rules and review checklist:
|
||||
[`PROTOCOL_CONVERGENCE_POLICY.md`](PROTOCOL_CONVERGENCE_POLICY.md)
|
||||
([ADR-0068](../adr/0068-single-current-public-contracts.md)).
|
||||
- **Current internal boundaries:** the Engine / Host Contract / Native Host /
|
||||
CLI responsibilities, dependency edges, plugin ABI contract split and the
|
||||
keep-in-workspace repository decision are in
|
||||
[ADR-0071](../adr/0071-engine-host-contract-boundary.md) and
|
||||
[`CURRENT.md`](CURRENT.md) §7. Issue #13 closure evidence lives in
|
||||
[`../evidence/2026-11-26-issue-13-engine-host-boundary.md`](../evidence/2026-11-26-issue-13-engine-host-boundary.md).
|
||||
- **Current language contract:**
|
||||
[`RFC-LANG-0002-unified-semantics.md`](RFC-LANG-0002-unified-semantics.md),
|
||||
adopted by [ADR-0052](../adr/0052-unified-markdown-semantics.md) and
|
||||
@@ -23,7 +29,7 @@ input and evidence. It is not a second running-status page.
|
||||
| Document | Status | What it is |
|
||||
|---|---|---|
|
||||
| [Unified semantics RFC-LANG-0002](RFC-LANG-0002-unified-semantics.md) | **Adopted and implemented** | Single syntax: heading modes, unified payloads, keyword control flow, breaking migration and acceptance gates. |
|
||||
| [Architecture audit and refactor RFC](Marqdo_CLI_Latest_Architecture_Audit_and_Refactor_RFC.md) | **Review input (historical)** | Responsibility convergence, stdio/file/stream correctness, CLI/Host split and the migration order at the time. Its language examples predate RFC-LANG-0002. |
|
||||
| [Architecture audit and refactor RFC](Marqdo_CLI_Latest_Architecture_Audit_and_Refactor_RFC.md) | **Review input (historical)** | Responsibility convergence, stdio/file/stream correctness, CLI/Host split and the migration order at the time. Its language examples predate RFC-LANG-0002 and its "contract crate only later" position is superseded by ADR-0071. |
|
||||
| [Runtime observability RFC-OBS-0001](RFC-OBS-0001-runtime-observability.md) | **Historical: superseded by Observation (ADR-0068)** | Its event vocabulary and privacy model fed the current [Observation](../../spec/observation.md) contract; the Execution Events v1 name/options are retired. |
|
||||
| [Compute machine RFC-0001](../MARQDO_COMPUTE_MACHINE_RFC_0001.md) | **Proposed** | Opaque `Memory`, addressable regions, wire/host rejection. Compute semantics are unchanged by the syntax rewrite; its `.mq.md` examples are historical spelling. |
|
||||
| [Core and stdlib migration RFC-0002](../MARQDO_COMPUTE_CORE_STDLIB_MIGRATION_RFC_0002.md) | **Proposed** | Minimum core, `.mq.md` stdlib and system-capability migration. The stdlib source migration is complete; current status is recorded in ../STATUS.md. |
|
||||
@@ -77,6 +83,8 @@ The implemented first slices of these RFCs are recorded in `CURRENT.md` and
|
||||
| Resource operations and core kinds | [0062](../adr/0062-resource-operation-ownership-and-core-kinds.md) | Accepted and implemented; architecture gate pins the reviewed lists |
|
||||
| Foreign F-A transition | [0063](../adr/0063-foreign-kernel-transition-fa.md) | Accepted: retained F-A primitive; F-B deferred |
|
||||
| Stable core inventory and external gate | [0064](../adr/0064-stable-core-extension-boundary.md) | Accepted and wired into Linux CI |
|
||||
| Engine / Host Contract / Native Host / CLI boundaries | [0071](../adr/0071-engine-host-contract-boundary.md) | Accepted and implemented by issue #13: runtime depends on the neutral contract, native host implements it, plugin ABI is contract-only, Engine/Native Host keep-in-workspace decision |
|
||||
| Independent plugin SDK repository | [0072](../adr/0072-sdk-independent-repository.md) | Accepted and implemented: public `cflmy/marqdo-plugin-sdk`, pinned to CLI contract commit, CLI does not depend on it |
|
||||
| Manifest-driven Resource Control | [0065](../adr/0065-resource-control-vnext.md) | Proposed |
|
||||
| Structured Tasks and Channels | [0066](../adr/0066-structured-tasks-v1.md) | Proposed |
|
||||
| Table physical storage (T1/T2/T3), strict stdin/stderr/file/network resources | — | **Not decided**; do not implement by implication |
|
||||
|
||||
@@ -24,6 +24,7 @@ contract (rust:1.100-bookworm, python3-jsonschema, both shipped binaries):
|
||||
analysis_consumer / observation_consumer / validate_protocols
|
||||
stream==snapshot assertion (tools/ci/verify_observation_stream.py)
|
||||
stale-Analysis rejection
|
||||
dependency-direction gate (tools/ci/check_dependency_boundaries.py)
|
||||
|
||||
test (rust:1.100-bookworm, clippy/rustfmt, Node.js 22, MinGW, both binaries):
|
||||
cargo fmt --all -- --check
|
||||
@@ -31,6 +32,8 @@ test (rust:1.100-bookworm, clippy/rustfmt, Node.js 22, MinGW, both binaries):
|
||||
cargo build --locked -p marqdo-provider-worker
|
||||
cargo test --workspace --locked
|
||||
docs_consistency / architecture_boundaries / stdlib_product
|
||||
check_dependency_boundaries.py (Cargo-metadata responsibility graph)
|
||||
check_engine_boundary.py (independent consumer build/run + CLI differential)
|
||||
python3 -m unittest discover -s tools/ci -p "test_*.py"
|
||||
rustup target add x86_64-pc-windows-gnu
|
||||
cargo check --workspace --all-targets --target x86_64-pc-windows-gnu
|
||||
|
||||
@@ -18,13 +18,18 @@ Foreign wire v1, Provider manifest v2, lock v4 and markdown profile
|
||||
|---|---|---|
|
||||
| AI/math/data/quantum/SKILL libraries, pure algorithms | `.mq.md` package | `index.mq.md`, `marqdo.yaml`, README, tests |
|
||||
| Knowledge/Proof/View/IDE/lint/analysis tools | CLI Tool protocol | standalone executable + `tool.json` + Analysis/Observation consumer |
|
||||
| High-performance native callable functions | Callable Plugin ABI v1 | `plugin.yaml`, host-targeted library, SDK/header |
|
||||
| High-performance native callable functions | Callable Plugin ABI v1 | `plugin.yaml`, host-targeted library, public SDK (`cflmy/marqdo-plugin-sdk`) + header |
|
||||
| New foreign language backend (R/Python/Julia/…) | Foreign Kernel | `kernel.json`, executable provider, pinned environment |
|
||||
| Hardware/device/external-stream resources | Resource Provider v2 | `provider.json`, C ABI library, worker helper |
|
||||
| Change `@exec` semantics, add keywords/types | **not** a third-party extension | core language RFC + migration + full conformance |
|
||||
|
||||
## Recommended reading order
|
||||
|
||||
0. [Current architecture](../architecture/CURRENT.md) and
|
||||
[ADR-0071](../adr/0071-engine-host-contract-boundary.md) — the Engine /
|
||||
Host Contract / Native Host / CLI responsibility map and dependency rules.
|
||||
Read this before touching a crate boundary; the historical plans are not
|
||||
current requirements.
|
||||
1. [quickstart.md](quickstart.md) — install the archive and run the first
|
||||
project.
|
||||
2. [libraries.md](libraries.md) — publish a pure `.mq.md` library and consume
|
||||
@@ -47,6 +52,19 @@ contracts are the pages above and `spec/`).
|
||||
Normative contracts live in [`../../spec/`](../../spec/); this directory is a
|
||||
task-oriented map, not a second specification.
|
||||
|
||||
## Internal boundary changes
|
||||
|
||||
This page is for third-party consumers. If you change Marqdo CLI itself, the
|
||||
internal boundary rules are in [ADR-0071](../adr/0071-engine-host-contract-boundary.md)
|
||||
and [CURRENT.md](../architecture/CURRENT.md) §7. In short: the engine depends
|
||||
only on `marqdo-host-contract`; the native host implements it; the plugin ABI
|
||||
crate is a contract (no loader/worker); the CLI is the only assembly point.
|
||||
Run `python3 tools/ci/check_dependency_boundaries.py`,
|
||||
`python3 tools/ci/check_engine_boundary.py` and
|
||||
the independent SDK repository's frozen-CLI check with the Rust suits. Do not create an
|
||||
empty candidate repository for a boundary; a split needs the evidence and a new
|
||||
ADR.
|
||||
|
||||
## Baseline repository
|
||||
|
||||
The current implementation and release entry point is
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
# Public Analysis consumers after issue #10
|
||||
|
||||
Applies to `marqdo.analysis` revision 3 as defined by
|
||||
[ADR-0069](../adr/0069-public-analysis-boundary.md), [spec/analysis.md](../../spec/analysis.md)
|
||||
and [the schema](../../spec/schemas/analysis.schema.json). This page is the
|
||||
integration guide for downstream static tools, in particular `marqdo-lint` and
|
||||
`marqdo-view`.
|
||||
|
||||
The revision number did not change, but the shape did. An old revision-3
|
||||
artifact is **not** accepted: current required fields are missing, and the
|
||||
current schema and consumer semantics reject it. Rebuild the artifact and
|
||||
update the consumer; do not add a compatibility reader or a second Analysis
|
||||
shape.
|
||||
|
||||
## 1. What the CLI already provides
|
||||
|
||||
Run one command per program entry:
|
||||
|
||||
```sh
|
||||
marqdo check path/to/index.mq.md --emit analysis.json
|
||||
```
|
||||
|
||||
The artifact contains everything a document/lint/knowledge reader needs, from
|
||||
the same static preparation as `check`, `inspect`, `run` and `call`:
|
||||
|
||||
- exact UTF-8 `modules[].source` and its SHA-256 `source_digest`;
|
||||
- the Markdown AST in `modules[].document`;
|
||||
- heading scopes in `modules[].units` and anchors in `modules[].anchors`;
|
||||
- functions, imports, calls and resources;
|
||||
- Markdown references with explicit resolution states;
|
||||
- project context: `entry_module_id`, `identity_kind`, `root_id`,
|
||||
`manifest_digest`, captured `lock_digest`, stdlib and extension identities;
|
||||
- deterministic diagnostics.
|
||||
|
||||
`inspect --ast` and `inspect --units` now project the **same** AST and unit
|
||||
shape. They remain human/debug selections; a machine consumer should read
|
||||
`check --emit` and stop running a second `inspect --ast` process per module.
|
||||
|
||||
## 2. Required consumer changes
|
||||
|
||||
### 2.1 Read the source from the artifact
|
||||
|
||||
`modules[].source` is the exact text the loader read. Every span is a half-open
|
||||
UTF-8 byte offset into that string.
|
||||
|
||||
- Do not reopen the file from `relative_path` for spans or digests; package
|
||||
caches, stdlib and dependencies have no stable consumer-facing physical path.
|
||||
- Verify `sha256(source.encode("utf-8")) == source_digest` before trusting a
|
||||
span.
|
||||
- `relative_path` remains package-relative and useful for display and project
|
||||
layout, not for reconstructing an absolute path.
|
||||
|
||||
### 2.2 Document AST
|
||||
|
||||
`modules[].document` is the public AST described by
|
||||
[`spec/markdown-profile.md`](../../spec/markdown-profile.md). Every node has
|
||||
`kind`, `span` and `children` (`[]` for leaves); attributes/literals follow the
|
||||
profile. The root `document` span now covers the whole source, including a BOM.
|
||||
|
||||
- Parse `document` directly; do not parse Markdown again for program
|
||||
annotations.
|
||||
- Renderers may keep their own rendering parser, but any *semantic* decision
|
||||
(executable region, heading scope, function ownership) must use Analysis.
|
||||
- Literal payloads are not guaranteed byte-equal to their span (entities,
|
||||
escapes and code whitespace are normalised).
|
||||
|
||||
### 2.3 Heading scope: `span` changed meaning
|
||||
|
||||
For every non-root unit:
|
||||
|
||||
| Field | Meaning |
|
||||
|---|---|
|
||||
| `heading_span` | The original heading AST node span. Use this to locate the heading itself. |
|
||||
| `span` | **Complete section range** from the heading through the next heading of the same or higher level, or EOF. It includes child headings. |
|
||||
| `path` | Canonical structured heading path. Do not split `id` to recover it. |
|
||||
| `parent_id` | Nearest real ancestor unit; root is `null`. |
|
||||
| `mode` | Effective `exec` or `knowledge`. |
|
||||
| `mode_origin` | `explicit` (ATX declaration), `inherited`, or `default` for the root. |
|
||||
| `mode_source_unit_id` | The unit that supplied the mode; self-or-ancestor. |
|
||||
| `kind` | `root`, `namespace`, `function`, `knowledge`, `section`. |
|
||||
| `function` | Owning function id for Exec sections; `null` otherwise. |
|
||||
|
||||
Do not infer section ends from the next heading's text or from the old
|
||||
short-span assumption. Use `heading_span` for heading UI; use `span` for the
|
||||
whole section body.
|
||||
|
||||
`anchors` is `[{anchor, unit_id}]`, sorted by anchor. Anchors are navigation
|
||||
names, not identities; a missing anchor is not a missing document.
|
||||
|
||||
### 2.4 References: boolean `resolved` is gone
|
||||
|
||||
`modules[].references[]` now always carries:
|
||||
|
||||
```json
|
||||
{
|
||||
"source": "root:x@0.1.0::index.mq.md",
|
||||
"source_unit": "root:x@0.1.0::index.mq.md#数学",
|
||||
"url": "./theory.mq.md#formula",
|
||||
"span": {"start": 20, "end": 50},
|
||||
"state": "not_loaded",
|
||||
"target_kind": null,
|
||||
"target_module": null,
|
||||
"target_unit": null,
|
||||
"candidate_package_instance_id": "root:x@0.1.0",
|
||||
"candidate_path": "theory.mq.md",
|
||||
"fragment": "formula",
|
||||
"candidates": []
|
||||
}
|
||||
```
|
||||
|
||||
| `state` | Consumer meaning |
|
||||
|---|---|
|
||||
| `resolved` | Exact module/unit or explicitly verified local file. `target_kind` is `module` or `file`. |
|
||||
| `not_loaded` | The loaded catalog did not cover the local candidate. It is **not** missing; do not auto-create it. |
|
||||
| `missing` | A known catalog module lacks the fragment, or explicit `--refs` verification proved absence. |
|
||||
| `ambiguous` | Multiple exact canonical-name candidates; `target_unit` is null and `candidates` lists them. Never choose the first. |
|
||||
| `external` | External URI scheme. No network access; not an error. |
|
||||
| `outside_scope` | Absolute/drive/UNC/file URI, or a package-root escape. Never read it. |
|
||||
| `invalid` | Malformed URI/percent encoding/unsupported address. |
|
||||
|
||||
Ordinary Analysis resolves only the loaded program. If a consumer needs to
|
||||
verify unimported local files, use the CLI's explicit check:
|
||||
|
||||
```sh
|
||||
marqdo check entry.mq.md --refs --json
|
||||
marqdo inspect entry.mq.md --refs --json
|
||||
```
|
||||
|
||||
Do not use the `--refs` artifact as the Observation binding input: `--refs`
|
||||
adds diagnostics and changes the exact bytes. Run/call bind to the ordinary
|
||||
`check --emit` bytes with the same static options.
|
||||
|
||||
### 2.5 Calls, functions and resources
|
||||
|
||||
- `functions[]` still has `id`, `unit_id`, `local_name`, `namespace`, `span`,
|
||||
`heading_span`, `signature`, `effects`, `body`.
|
||||
- `calls[]` now has `target_kind`, `target_owner` and `reason`. A plugin target
|
||||
names the static owner (package/digest); it is never a Marqdo function.
|
||||
`unresolved` with `reason: dynamic|unbound` is honest, not an error.
|
||||
- `resources[]` carries `display: null` for code and a boolean for formulas;
|
||||
verify its `content_digest` against the AST payload if you need integrity.
|
||||
- The schema is closed: unknown required kinds/fields must be rejected, not
|
||||
ignored.
|
||||
|
||||
### 2.6 Project context and freshness
|
||||
|
||||
- Load `project.entry_module_id`; it must occur once in `modules`.
|
||||
- `root_id` is a logical manifest identity or a content snapshot, not a
|
||||
cross-project permanent id.
|
||||
- `manifest_digest` and `lock_digest` are the captured bytes; a changed file on
|
||||
disk means a new check, not a retry of the old artifact.
|
||||
- Verify the exact bytes with the published JSON Schema + semantic checks; keep
|
||||
rejecting stale artifacts whose `source_digest` no longer matches the source
|
||||
you display.
|
||||
|
||||
## 3. `marqdo-view` integration
|
||||
|
||||
Current View behavior to replace:
|
||||
|
||||
1. It runs `check --json --emit` and separately calls `inspect --ast --json`
|
||||
per document. Replace the machine path with one `check --emit`; the AST is
|
||||
`modules[].document`. Keep `inspect` only for human debug output.
|
||||
2. It re-reads files and compares `source_digest`. Prefer `modules[].source`
|
||||
directly; if it must use its own file snapshot, compare the artifact digest
|
||||
and reject a mismatch.
|
||||
3. Its `RawProject` ignores new required fields. Make
|
||||
`entry_module_id`, `manifest_digest` and `extensions` required (or validate
|
||||
with the schema) and remove the v2 acceptance branch. View must accept only
|
||||
the current revision-3 shape.
|
||||
4. `RawUnit.span` now means the complete section. For annotation placement use
|
||||
`heading_span`; for source highlighting use the complete `span`.
|
||||
5. `RawReference` already reads `state`; remove any remaining `resolved`
|
||||
boolean mapping and map `not_loaded` as *unverified*, not as a broken link.
|
||||
For a local candidate the View catalog does not know, show "未加载/未核验";
|
||||
only `missing`/`ambiguous`/`invalid`/`outside_scope` are actionable errors.
|
||||
6. Keep validating `source.analysis_digest` for Observation binding. The digest
|
||||
remains SHA-256 of the exact `--emit` bytes; `--refs` diagnostics change it.
|
||||
|
||||
Suggested request/render flow:
|
||||
|
||||
```text
|
||||
check --emit -> verify schema + source_digest -> document AST
|
||||
-> units (complete span + heading_span) for annotations
|
||||
-> references (state) for link presentation
|
||||
-> calls/functions for executable markers
|
||||
run/call + observation -> verify analysis_digest == sha256(artifact bytes)
|
||||
```
|
||||
|
||||
## 4. `marqdo-lint` integration
|
||||
|
||||
Current Lint behavior to replace:
|
||||
|
||||
1. It performs one `inspect --ast` per module and then matches it with
|
||||
Analysis. Use `modules[].source` and `modules[].document` from the same
|
||||
`check --emit`; this removes a second process and any AST/span drift.
|
||||
2. Its `AnalysisModule` model only requires the old fields and silently ignores
|
||||
the new ones. Make `source`, `document`, `anchors` and the new unit fields
|
||||
required; reject old same-revision artifacts. Prefer generating types from
|
||||
the published schema rather than `Vec<Value>` for units/references.
|
||||
3. Heading-boundary rules must use `units[].span` as the complete section and
|
||||
`heading_span` as the heading itself. This is the authoritative range; do
|
||||
not infer boundaries from Markdown siblings.
|
||||
4. Link/reference lint: iterate `references[].state`. Report:
|
||||
- `missing`/`ambiguous`/`invalid`/`outside_scope` as errors with
|
||||
`source_unit` + `span`;
|
||||
- `not_loaded` as an honest "unverified" notice, not a broken reference;
|
||||
- `external` as informational.
|
||||
Use the explicit `check --refs --json` run only when the user asks to verify
|
||||
direct unimported targets.
|
||||
5. `calls[]` can report static call targets and dynamic/unbound reasons; do not
|
||||
infer a target from the display string. Plugin/builtin targets are not
|
||||
Marqdo functions.
|
||||
6. Continue using `--json` for diagnostic summaries; `--emit` is the only full
|
||||
Analysis producer.
|
||||
|
||||
Suggested lint flow:
|
||||
|
||||
```text
|
||||
check --emit -> verify schema + semantic invariants
|
||||
-> per module: document + units(full span/heading_span)
|
||||
-> rules: narrative/executable boundaries, calls, links, docs
|
||||
-> diagnostics projected from Analysis + local rules
|
||||
```
|
||||
|
||||
## 5. Shared rules for both consumers
|
||||
|
||||
- One current contract. Do not add a v2/v3 reader, field probing, fallback AST
|
||||
from a second parser, or `try old shape then new shape`.
|
||||
- Reject malformed/old artifacts with a corrective message: regenerate with the
|
||||
current CLI, reinstall the Tool manifest, rebuild the consumer.
|
||||
- Tool manifests keep `requires.analysis: 3`; the revision is unchanged, so
|
||||
reinstall/rebuild is required because the old same-revision bytes are
|
||||
rejected by the current schema.
|
||||
- No private Rust crate, no `inspect --ir`, no package-cache path, no writing
|
||||
to the analyzed project.
|
||||
- The source in Analysis may contain secrets from the document. Do not log or
|
||||
upload it by default; store artifacts with owner-only permissions.
|
||||
- Keep the three independent fixture flows green: document rendering, lint with
|
||||
diagnostics, and multi-entry knowledge linking.
|
||||
|
||||
## 6. Verification commands
|
||||
|
||||
On the current CLI:
|
||||
|
||||
```sh
|
||||
marqdo check entry.mq.md --emit analysis.json
|
||||
python3 tests/consumers/validate_protocols.py analysis.json observation.json tool.json
|
||||
python3 tests/consumers/analysis_consumer.py analysis.json
|
||||
marqdo inspect entry.mq.md --refs --json
|
||||
```
|
||||
|
||||
For a downstream checkout, pin the CLI archive and run its real fixtures
|
||||
against `MARQDO_BIN`; record the CLI SHA and the Analysis schema hash in the
|
||||
consumer's evidence. See the issue accompanying this document for the exact
|
||||
downstream acceptance items.
|
||||
@@ -10,7 +10,8 @@
|
||||
[ADR-0068](../adr/0068-single-current-public-contracts.md)
|
||||
- **Contract:** `spec/analysis.md`, `spec/schemas/analysis.schema.json`
|
||||
- **Gate manifest:** [`ci/e0645f376b03e31e342a6d3fb749a335f0840d1b/manifest.json`](ci/e0645f376b03e31e342a6d3fb749a335f0840d1b/manifest.json)
|
||||
(`DO_NOT_RELEASE`: strict VM UNVERIFIED and no approved G4 node)
|
||||
(`RC_RELEASE_CANDIDATE`: strict VM PASS; shared-node performance WARN
|
||||
approved for this RC only)
|
||||
|
||||
This document records commands actually executed on the candidate tree. The
|
||||
raw command log is
|
||||
@@ -107,15 +108,14 @@ numbers and must not be cited as the dedicated-node G4 result.
|
||||
|
||||
## Release decision
|
||||
|
||||
`DO_NOT_RELEASE` for rc.4. The code/contract/CI/archive/conformance gates pass,
|
||||
but the RC profile still requires a same-SHA strict-field PASS on a disposable
|
||||
VM (this development container cannot create namespaces) and an approved
|
||||
dedicated/shared-node G4 result. Neither is recorded for this SHA, so no tag,
|
||||
archive publication or release claim is made.
|
||||
`RC_RELEASE_CANDIDATE` for rc.4. A same-SHA disposable QEMU/TCG VM PASS
|
||||
(uid 1000, `container: none`) and a maintainer-approved shared-node
|
||||
performance `WARN` were recorded after this local gate. The tag and release are
|
||||
`v3.0.0-rc.4` at `452e9a32bd9e40dba427d4180691c58bab74449e`; see
|
||||
[`2026-11-25-rc.4-release.md`](2026-11-25-rc.4-release.md).
|
||||
|
||||
## Not claimed
|
||||
|
||||
- No disposable-VM strict L1 evidence for this SHA.
|
||||
- No approved dedicated-node G4 measurement (the local comparison above is
|
||||
smoke evidence only).
|
||||
- No dedicated-node G4 PASS; the shared-node WARN is RC-only and does not
|
||||
extend to stable/LTS.
|
||||
- No Windows/macOS support claim.
|
||||
@@ -1,10 +1,10 @@
|
||||
你好,Marqdo
|
||||
checked 2 module(s): ok
|
||||
checked 1 module(s): ok
|
||||
6
|
||||
warning[sem.inferred_signature]: /tmp/marqdo/marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu/examples/math-library/index.mq.md:5:1: function signature was inferred; declare it with `params(...)`
|
||||
## @exec 最大公约数
|
||||
^
|
||||
6
|
||||
warning[sem.inferred_signature]: /tmp/marqdo/marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu/examples/factorial.mq.md:3:1: function signature was inferred; declare it with `params(...)`
|
||||
## @exec 阶乘
|
||||
^
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
From https://git.cflmy.cn/cflmy/marqdo-extension-conformance
|
||||
* branch 015ff8ac15417b7ebbdb31ce2be2dab5362a1eba -> FETCH_HEAD
|
||||
frozen CLI: /tmp/tmp.4rCUTQwVeO/install/marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu/marqdo sha256 a7306962689c635445a59043971ea2eb09298e01feeee81f0ba07b1f3e10306e
|
||||
frozen CLI: /tmp/tmp.IyNn1tzjCW/install/marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu/marqdo sha256 a7306962689c635445a59043971ea2eb09298e01feeee81f0ba07b1f3e10306e
|
||||
[PASS] plugin_worker: plugin check is static and succeeds
|
||||
[PASS] plugin_worker: worker plugin executes three exports
|
||||
[PASS] callable_registry: missing plugin export is symbol.unknown
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"schema": "marqdo.extension-evidence",
|
||||
"schema_version": 1,
|
||||
"tested_sha": "e0645f376b03e31e342a6d3fb749a335f0840d1b",
|
||||
"tested_sha": "452e9a32bd9e40dba427d4180691c58bab74449e",
|
||||
"cli_binary_sha256": "a7306962689c635445a59043971ea2eb09298e01feeee81f0ba07b1f3e10306e",
|
||||
"fixture_repo_sha": "015ff8ac15417b7ebbdb31ce2be2dab5362a1eba",
|
||||
"os": "linux",
|
||||
@@ -16,7 +16,7 @@
|
||||
"negative_security": "PASS"
|
||||
},
|
||||
"commands": [
|
||||
"python3 /tmp/tmp.4rCUTQwVeO/fixtures/tests/run_all.py (cwd=/tmp/tmp.4rCUTQwVeO/fixtures)"
|
||||
"python3 /tmp/tmp.IyNn1tzjCW/fixtures/tests/run_all.py (cwd=/tmp/tmp.IyNn1tzjCW/fixtures)"
|
||||
],
|
||||
"failures": [],
|
||||
"unverified": [],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
rc.4 final local gate 2026-11-25T03:40:44Z
|
||||
source_sha: e0645f376b03e31e342a6d3fb749a335f0840d1b
|
||||
rc.4 final local gate 2026-11-25T06:15:34Z
|
||||
source_sha: 452e9a32bd9e40dba427d4180691c58bab74449e
|
||||
platform: Linux 7.0.0-43-generic x86_64
|
||||
rustc: rustc 1.100.0 (0ef1bc386 2026-11-09)
|
||||
|
||||
@@ -7,52 +7,14 @@ $ cargo fmt --all -- --check
|
||||
PASS
|
||||
|
||||
$ cargo clippy --workspace --all-targets -- -D warnings
|
||||
Compiling proc-macro2 v1.0.107
|
||||
Checking serde_core v1.0.229
|
||||
Checking zmij v1.0.23
|
||||
Checking num-traits v0.2.19
|
||||
Checking generic-array v0.14.7
|
||||
Checking libc v0.2.191
|
||||
Checking rustix v1.1.6
|
||||
Checking crc32fast v1.5.5
|
||||
Checking flate2 v1.1.11
|
||||
Compiling phf_generator v0.14.0
|
||||
Compiling quote v1.0.47
|
||||
Compiling phf_codegen v0.14.0
|
||||
Compiling comrak v1.0.0
|
||||
Compiling syn v3.0.10
|
||||
Checking block-buffer v0.10.4
|
||||
Checking crypto-common v0.1.7
|
||||
Checking num-integer v0.1.47
|
||||
Checking digest v0.10.7
|
||||
Checking sha2 v0.10.9
|
||||
Checking getrandom v0.4.3
|
||||
Checking getrandom v0.2.17
|
||||
Checking ring v0.17.14
|
||||
Checking tempfile v3.27.0
|
||||
Checking serde_json v1.0.154
|
||||
Checking rustls-webpki v0.103.17
|
||||
Checking rcgen v0.13.2
|
||||
Checking rustls v0.23.46
|
||||
Compiling serde_derive v1.0.229
|
||||
Compiling thiserror-impl v2.0.21
|
||||
Compiling fearless_simd_macros v0.1.0
|
||||
Compiling clap_derive v4.6.9
|
||||
Checking memchr-n v0.1.10
|
||||
Checking thiserror v2.0.21
|
||||
Checking marqdo-worker-ipc v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-worker-ipc)
|
||||
Checking marqdo-provider-worker v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-provider-worker)
|
||||
Checking clap v4.6.9
|
||||
Checking serde v1.0.229
|
||||
Checking marqdo-span v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-span)
|
||||
Checking num-bigint v0.4.8
|
||||
Checking serde_yaml v0.9.34+deprecated
|
||||
Checking marqdo-worker-ipc v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-worker-ipc)
|
||||
Checking marqdo-sandbox v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-sandbox)
|
||||
Checking marqdo-markdown v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-markdown)
|
||||
Checking marqdo-package v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-package)
|
||||
Checking marqdo-provider-worker v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-provider-worker)
|
||||
Checking marqdo-value v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-value)
|
||||
Checking marqdo-expression v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-expression)
|
||||
Checking num-rational v0.4.2
|
||||
Checking marqdo-markdown v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-markdown)
|
||||
Checking marqdo-plugin-abi v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-plugin-abi)
|
||||
Checking marqdo-foreign v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-foreign)
|
||||
Checking marqdo-ir v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-ir)
|
||||
@@ -61,7 +23,7 @@ $ cargo clippy --workspace --all-targets -- -D warnings
|
||||
Checking marqdo-frontend v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-frontend)
|
||||
Checking marqdo-runtime v3.0.0-rc.4 (/root/work/marqdo-cli/crates/marqdo-runtime)
|
||||
Checking marqdo-cli v3.0.0-rc.4 (/root/work/marqdo-cli/crates/cli)
|
||||
Finished `dev` profile [unoptimized + debuginfo] target(s) in 8.53s
|
||||
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.36s
|
||||
PASS
|
||||
|
||||
$ cargo test --workspace --locked
|
||||
@@ -73,26 +35,26 @@ test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fin
|
||||
$ cargo test -p marqdo-cli --test docs_consistency
|
||||
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
|
||||
$ cargo test -p marqdo-cli --test analysis_observation
|
||||
test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.34s
|
||||
test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.36s
|
||||
$ cargo test -p marqdo-cli --test observation
|
||||
test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 4.23s
|
||||
test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 4.31s
|
||||
$ cargo test -p marqdo-cli --test tool_protocol
|
||||
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 3.09s
|
||||
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.94s
|
||||
$ cargo test -p marqdo-cli --test callable_resolution
|
||||
test result: ok. 14 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.28s
|
||||
test result: ok. 14 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.27s
|
||||
$ cargo test -p marqdo-cli --test heading_inheritance
|
||||
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.07s
|
||||
$ cargo test -p marqdo-cli --test conformance_ast
|
||||
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s
|
||||
$ cargo test -p marqdo-cli --test conformance_semantics
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.69s
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.66s
|
||||
$ cargo test -p marqdo-cli --test analysis_boundary
|
||||
test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 4.97s
|
||||
test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 4.98s
|
||||
|
||||
$ python3 -m unittest discover -s tools/ci -p test_*.py
|
||||
Ran 43 tests in 0.092s
|
||||
|
||||
OK
|
||||
|
||||
$ cargo build --release --locked -p marqdo-cli -p marqdo-provider-worker
|
||||
Finished `release` profile [optimized] target(s) in 0.05s
|
||||
Finished `release` profile [optimized] target(s) in 0.24s
|
||||
PASS
|
||||
@@ -1,5 +1,5 @@
|
||||
smoke: verified stdlib 0.1.0 tree=sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713 aliases=sha256:5f513c0fdbb3c1e9829be3c9fa23a2d1e89cb8510073fb5eb1e8e2f5265a83bb files=42
|
||||
smoke: archive version 3.0.0-rc.4, source e0645f376b03e31e342a6d3fb749a335f0840d1b
|
||||
smoke: archive version 3.0.0-rc.4, source 452e9a32bd9e40dba427d4180691c58bab74449e
|
||||
smoke: bundled stdlib missing -> fail-closed OK
|
||||
smoke: strict unsupported on this host; fail-closed refused: {'reason': 'bubblewrap cannot create the required namespaces: bwrap: No permissions to create a new namespace, likely because the kernel does not allow non-privileged user namespaces. See <https://deb.li/bubblewrap> or <file:///usr/share/doc/bubblewrap/README.Debian.gz>.', 'state': 'unavailable'}
|
||||
smoke: PASS
|
||||
@@ -0,0 +1,62 @@
|
||||
# RC 3.0.0-rc.4 release evidence — 452e9a32bd9e40dba427d4180691c58bab74449e
|
||||
|
||||
- **Date:** 2026-11-25
|
||||
- **Product:** `3.0.0-rc.4` (prerelease; not stable, not LTS)
|
||||
- **Source SHA:** `452e9a32bd9e40dba427d4180691c58bab74449e` (tag `v3.0.0-rc.4`)
|
||||
- **Platform:** Linux x86_64, glibc 2.39 baseline; macOS/Windows UNSUPPORTED
|
||||
- **Release archive:** `marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu.tar.gz`
|
||||
sha256 `9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8`
|
||||
- **Gate manifest:**
|
||||
[`ci/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json`](ci/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json)
|
||||
(`RC_RELEASE_CANDIDATE`)
|
||||
- **Architecture:** [ADR-0069](../adr/0069-public-analysis-boundary.md),
|
||||
[spec/analysis.md](../../spec/analysis.md)
|
||||
- **Downstream guide:**
|
||||
[`docs/developers/analysis-consumers.md`](../developers/analysis-consumers.md)
|
||||
|
||||
## Gates executed on this SHA
|
||||
|
||||
| Gate | State | Evidence |
|
||||
|---|---|---|
|
||||
| Same-SHA CI (`contract`, `test`, `minimum-rust`, `build`) | PASS | [pipeline #94](https://ci.cflmy.cn/repos/1/pipeline/94) |
|
||||
| Frozen external conformance | PASS 7/7 | [`2026-11-25-rc.4-extension-manifest.json`](2026-11-25-rc.4-extension-manifest.json) |
|
||||
| Archive-only smoke | PASS | [`2026-11-25-rc.4-release-smoke.log`](2026-11-25-rc.4-release-smoke.log) |
|
||||
| Clean install: archive-only Ubuntu 24.04 container, non-root, no Cargo/network | PASS | [`2026-11-25-rc.4-cold-install.log`](2026-11-25-rc.4-cold-install.log) |
|
||||
| Strict L1: disposable QEMU/TCG VM, non-root `dev` (uid 1000), image sha256 `7b9059…ecab9` | PASS | [`2026-11-25-rc.4-strict-evidence.json`](2026-11-25-rc.4-strict-evidence.json), [lane log](2026-11-25-rc.4-strict-lane.log) |
|
||||
| Archived binary verified inside the same strict VM | PASS | [`2026-11-25-rc.4-strict-archive-verify.log`](2026-11-25-rc.4-strict-archive-verify.log) |
|
||||
| Version compatibility (Rust 1.89 minimum, CLI/product, prerelease ranges) | PASS | pipeline #94 test lane |
|
||||
| Shared-node performance | WARN (maintainer-approved for this RC only) | [`2026-11-25-rc.4-shared-node-performance.md`](2026-11-25-rc.4-shared-node-performance.md) |
|
||||
| Windows / macOS | UNSUPPORTED | Linux-only RC scope |
|
||||
|
||||
The same-SHA CI build lane packaged its own archive
|
||||
(`sha256 675ee7bdf4725e034f79ecf6d8609c1b667cb267f70df4ae686c023e8c5e3018`),
|
||||
ran smoke and the frozen extension suite 7/7, and recorded CLI
|
||||
`119b4d7d0431d8e958253add4b67a6ed826678b5254583d5320136b1b9a6e93b` and
|
||||
provider worker `4e64bec9376c27e1b36cde510fd06159a86ae5d10f82f98137c2b8ba6ee7d908`.
|
||||
|
||||
## Behaviour changes since rc.3
|
||||
|
||||
Issue [#10](https://git.cflmy.cn/cflmy/marqdo-cli/issues/10) replaced
|
||||
`marqdo.analysis` revision 3 **in place**:
|
||||
|
||||
- exact `source`/`source_digest`, public document AST, complete heading scopes
|
||||
and anchors, entry/manifest/lock/stdlib/extension identities;
|
||||
- one shared `document_refs` resolver used by Analysis, `check --refs` and
|
||||
`inspect --refs`, with `resolved/not_loaded/missing/ambiguous/external/
|
||||
outside_scope/invalid`;
|
||||
- removed the duplicate `commands.rs` resolver and the post-preparation lock
|
||||
re-read;
|
||||
- `--emit` writes owner-only exclusive bytes atomically and refuses inputs,
|
||||
directories, symlinks and hard links;
|
||||
- independent schema + semantic consumers and mutation fixtures; old
|
||||
same-revision artifacts are rejected.
|
||||
|
||||
Downstream `marqdo-view` and `marqdo-lint` must follow
|
||||
[`analysis-consumers.md`](../developers/analysis-consumers.md); their tracking
|
||||
issues are linked from the release announcement.
|
||||
|
||||
## What this evidence does not claim
|
||||
|
||||
Stable `3.0.0`, LTS, Windows/macOS support, strict L2, dedicated-node G4, or a
|
||||
publisher signature. Checksums are integrity only. The shared-node performance
|
||||
exception is scoped to this named RC and is not reusable for LTS.
|
||||
@@ -0,0 +1,53 @@
|
||||
# RC 3.0.0-rc.4 — shared-node performance evidence (WARN)
|
||||
|
||||
- **Date:** 2026-11-25
|
||||
- **Product:** `3.0.0-rc.4`
|
||||
- **Source SHA:** `452e9a32bd9e40dba427d4180691c58bab74449e`
|
||||
- **Class:** shared-node `WARN`, **not** a dedicated-node G4 PASS
|
||||
- **Approval:** the maintainer (`cflmy`) approved shared-node performance
|
||||
evidence for this named RC on 2026-11-25. This exception is RC-only; a
|
||||
stable/LTS release requires a dedicated fixed node.
|
||||
- **Evidence generation:** `docs/evidence/2026-11-25-rc.4-analysis-boundary.md`
|
||||
and the packed archives below.
|
||||
|
||||
## Environment
|
||||
|
||||
- Shared development host: Intel Core i7-8565U, 4 cores / 8 threads, 14 GiB RAM,
|
||||
`powersave` governor, Linux `7.0.0-43-generic` x86_64, load average
|
||||
`0.24 0.79 1.50` at sampling start.
|
||||
- The agent runs in a container (`systemd-detect-virt --container` =
|
||||
`container-other`); this is explicitly **not** a dedicated node and not a
|
||||
QEMU/TCG VM. Its times are not comparable with the release G4 node.
|
||||
- Baseline and candidate are the shipped release archives, five warmups and
|
||||
twenty samples per command, same cwd and same fixture.
|
||||
|
||||
## Fixture
|
||||
|
||||
101 `.mq.md` modules, 82,094 bytes, 903 units, 100 cross-module references,
|
||||
nested headings, paragraphs, formulas and code fences. The candidate emitted a
|
||||
2,739,388-byte Analysis; the schema validator and independent
|
||||
`analysis_consumer.py` accepted it (101 modules, 100 references).
|
||||
|
||||
## Results
|
||||
|
||||
| Command | rc.3 p50 / p95 (ms) | rc.4 p50 / p95 (ms) | p95 ratio | peak RSS ratio |
|
||||
|---|---|---|---|---|
|
||||
| `check index.mq.md --json` | 18.75 / 19.14 | 20.28 / 20.47 | 1.069 | 1.034 |
|
||||
| `check index.mq.md --emit out.json` | 36.45 / 37.23 | 50.15 / 51.55 | 1.385 | 1.225 |
|
||||
| `check index.mq.md --refs --json` | 20.07 / 20.33 | 23.65 / 24.05 | 1.183 | 1.107 |
|
||||
|
||||
Artifact size grew from 899,146 to 2,739,388 bytes because it now carries exact
|
||||
source and the document AST. `--emit` p95 and peak-RSS ratios remain below the
|
||||
issue's 2.5x budget; no-emit p95 is below 1.15x. `--refs` is a diagnostic
|
||||
extension, not the ordinary no-emit execution path.
|
||||
|
||||
The candidate binary in this measurement is the same shipped rc.4 archive
|
||||
(`sha256 9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8`)
|
||||
and the baseline is the published rc.3 archive. Correctness was verified before
|
||||
accepting the timings.
|
||||
|
||||
## Limits
|
||||
|
||||
This is a `WARN` on a shared host. It must not be cited as a dedicated-node G4
|
||||
PASS, and it does not extend to LTS. The RC gate manifest records the approval
|
||||
reference and the `WARN` state.
|
||||
@@ -0,0 +1,15 @@
|
||||
Warning: Permanently added '[127.0.0.1]:2222' (ED25519) to the list of known hosts.
|
||||
marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu.tar.gz: OK
|
||||
SOURCE_SHA=452e9a32bd9e40dba427d4180691c58bab74449e
|
||||
marqdo 3.0.0-rc.4
|
||||
available
|
||||
你好,Marqdo
|
||||
warning[sem.inferred_signature]: /home/dev/rc4-install/marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu/examples/factorial.mq.md:3:1: function signature was inferred; declare it with `params(...)`
|
||||
## @exec 阶乘
|
||||
^
|
||||
warning[sem.inferred_signature]: /project/factorial.mq.md:3:1: function signature was inferred; declare it with `params(...)`
|
||||
## @exec 阶乘
|
||||
^
|
||||
factorial=120
|
||||
checked 2 module(s): ok
|
||||
analysis=marqdo.analysis 3 3.0.0-rc.4
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"schema": "marqdo.strict-evidence.v1",
|
||||
"tested_sha": "452e9a32bd9e40dba427d4180691c58bab74449e",
|
||||
"tested_sha_source": "git-rev-parse",
|
||||
"tested_sha_verified": true,
|
||||
"source_archive_sha256": "sha256:3a6db40bb64779c932e101b97e83527669881a12a9c6639e9f694f71ec14fbcb",
|
||||
"run": {
|
||||
"command": "./tests/security/run-lane.sh",
|
||||
"outcome": "PASS",
|
||||
"runner_kind": "disposable-vm",
|
||||
"run_url": "",
|
||||
"runner_image_sha256": "sha256:7b90593f5532b49b7e3fe3d2743f0d1f0d822e5b07cebcd8e00c0df8069ecab9",
|
||||
"lane_log": "/home/dev/evidence-452e9a32bd9e40dba427d4180691c58bab74449e/gc-lane.log",
|
||||
"started_utc": "2026-11-25T06:03:57Z",
|
||||
"finished_utc": "2026-11-25T06:05:19Z"
|
||||
},
|
||||
"environment": {
|
||||
"uname": "Linux-7.0.0-43-generic-x86_64-with-glibc2.43",
|
||||
"kernel": "7.0.0-43-generic",
|
||||
"machine": "x86_64",
|
||||
"cgroup2": "cgroup2 cgroup2 rw,nsdelegate,memory_recursiveprot,memory_hugetlb_accounting",
|
||||
"container": "none",
|
||||
"uid": 1000,
|
||||
"user": "dev",
|
||||
"root": false,
|
||||
"bwrap_version": "bubblewrap 0.11.1",
|
||||
"rustc": "rustc 1.100.0 (0ef1bc386 2026-11-09)",
|
||||
"cargo": "cargo 1.100.0 (3acc79c0c 2026-11-05)",
|
||||
"python": "3.14.4",
|
||||
"cc": [
|
||||
"cc (Ubuntu 15.2.0-16ubuntu1) 15.2.0"
|
||||
],
|
||||
"source_archive_sha256_matches": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
== adversarial helper matrix ==
|
||||
Compiling marqdo-sandbox v3.0.0-rc.4 (/home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/crates/marqdo-sandbox)
|
||||
Finished `test` profile [unoptimized + debuginfo] target(s) in 7.92s
|
||||
Running tests/security_linux.rs (target/debug/build/marqdo-sandbox/05fde20fe9d1e50b/out/security_linux-05fde20fe9d1e50b)
|
||||
|
||||
running 7 tests
|
||||
test strict_child_cannot_escape_via_proc_or_privileges ... ok
|
||||
test strict_child_cannot_reach_the_network ... ok
|
||||
test strict_child_cannot_read_host_files_but_reads_the_project ... ok
|
||||
test strict_child_cannot_write_outside_or_into_the_project ... ok
|
||||
test strict_child_identity_is_unprivileged_and_namespaced ... ok
|
||||
test strict_supervisor_enforces_fd_and_process_limits ... ok
|
||||
test strict_supervisor_enforces_memory_cpu_and_output_limits ... ok
|
||||
|
||||
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 10.54s
|
||||
|
||||
== build CLI ==
|
||||
Compiling marqdo-span v3.0.0-rc.4 (/home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/crates/marqdo-span)
|
||||
Compiling marqdo-worker-ipc v3.0.0-rc.4 (/home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/crates/marqdo-worker-ipc)
|
||||
Compiling marqdo-sandbox v3.0.0-rc.4 (/home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/crates/marqdo-sandbox)
|
||||
Compiling marqdo-package v3.0.0-rc.4 (/home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/crates/marqdo-package)
|
||||
Compiling marqdo-value v3.0.0-rc.4 (/home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/crates/marqdo-value)
|
||||
Compiling marqdo-expression v3.0.0-rc.4 (/home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/crates/marqdo-expression)
|
||||
Compiling marqdo-markdown v3.0.0-rc.4 (/home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/crates/marqdo-markdown)
|
||||
Compiling marqdo-foreign v3.0.0-rc.4 (/home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/crates/marqdo-foreign)
|
||||
Compiling marqdo-plugin-abi v3.0.0-rc.4 (/home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/crates/marqdo-plugin-abi)
|
||||
Compiling marqdo-ir v3.0.0-rc.4 (/home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/crates/marqdo-ir)
|
||||
Compiling marqdo-host v3.0.0-rc.4 (/home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/crates/marqdo-host)
|
||||
Compiling marqdo-frontend v3.0.0-rc.4 (/home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/crates/marqdo-frontend)
|
||||
Compiling marqdo-runtime v3.0.0-rc.4 (/home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/crates/marqdo-runtime)
|
||||
Compiling marqdo-cli v3.0.0-rc.4 (/home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/crates/cli)
|
||||
Finished `dev` profile [unoptimized + debuginfo] target(s) in 34.76s
|
||||
strict mechanism: bubblewrap 0.11.1 (user/mount/PID/net/UTS/IPC namespaces + no-new-privs + rlimits)
|
||||
== positive CLI contract ==
|
||||
warning[sem.inferred_signature]: /home/dev/marqdo-452e9a32bd9e40dba427d4180691c58bab74449e/examples/factorial.mq.md:3:1: function signature was inferred; declare it with `params(...)`
|
||||
## @exec 阶乘
|
||||
^
|
||||
warning[sem.inferred_signature]: /project/factorial.mq.md:3:1: function signature was inferred; declare it with `params(...)`
|
||||
## @exec 阶乘
|
||||
^
|
||||
== strict language resources are console-only ==
|
||||
== external-execution surfaces are refused ==
|
||||
== @knowledge payloads stay inert under strict ==
|
||||
== forged active marker is rejected ==
|
||||
G-C security lane: PASS
|
||||
strict evidence: /home/dev/evidence-452e9a32bd9e40dba427d4180691c58bab74449e/strict-evidence.json
|
||||
strict evidence: /home/dev/evidence-452e9a32bd9e40dba427d4180691c58bab74449e/strict-evidence.json
|
||||
@@ -0,0 +1,107 @@
|
||||
# Evidence — issue #13 Engine / Host Contract boundary (candidate)
|
||||
|
||||
Date: 2026-11-26 (Asia/Shanghai)
|
||||
Issue: <https://git.cflmy.cn/cflmy/marqdo-cli/issues/13>
|
||||
Decision: [ADR-0071](../adr/0071-engine-host-contract-boundary.md)
|
||||
Branch: `architecture/issue-13-engine-host-boundary`
|
||||
Baseline: `master` at `4bbefc92449ee480c8a2c89b0308feb4cda8d0e7`
|
||||
Candidate: the merge candidate built from this branch; the PR records the exact
|
||||
source SHA. This file is not a release approval and does not reuse RC.4 evidence.
|
||||
|
||||
## Scope actually landed (M0–M3 core)
|
||||
|
||||
| Item | State |
|
||||
|---|---|
|
||||
| Neutral `marqdo-host-contract` crate (`Host`, `HostOp`, `ExecutionContext`, `ResourceRead`, `FrameId`, `ParameterSource`, `LoopTransfer`, `RuntimeObservation`) | **implemented** |
|
||||
| `marqdo-runtime` depends on the contract, not `marqdo-host` | **implemented** (runtime test `marqdo-host` remains a dev-dependency only) |
|
||||
| `marqdo-host` implements the contract; no reverse dependency on runtime/frontend/IR | **implemented** |
|
||||
| Independent real consumer `tests/embedding` (own workspace + lock), Markdown→frontend→IR→runtime, bounded test host | **implemented and executed** |
|
||||
| `marqdo-plugin-abi` reduced to the public contract (C ABI, wire, errors) | **implemented** |
|
||||
| Loader/worker/manifest/artifact moved to `marqdo-host::plugin` | **implemented** |
|
||||
| SDK consumes only the contract (no libloading/worker/host) | **implemented** |
|
||||
| Real SDK plugin built and invoked by the real CLI; tampered digest rejected | **implemented and executed** |
|
||||
| Dependency-direction gate from Cargo metadata + negative unit cases | **implemented** |
|
||||
| Current architecture/doc entry, ADR, historical banners, status | **implemented** |
|
||||
| New remote repository (`marqdo-cli-*`, engine/host) | **deliberately not created** — issue #13 §9.2 admission is not met; keep-in-workspace is recorded in ADR-0071/CURRENT.md §7 |
|
||||
| Stdlib Bundle Phase B, SDK physical migration, regex/compression migration, foreign F-B | **not in this candidate**; separate issues/decisions, listed in `docs/STATUS.md` |
|
||||
|
||||
## Commands and results
|
||||
|
||||
All commands were run in this checkout with the repository-local Rust toolchain
|
||||
(`rustc 1.100.0`, `cargo 1.100.0`) and `--offline` where the environment requires
|
||||
the warm cache. The candidate source SHA is on the PR; do not copy these results
|
||||
to a different commit.
|
||||
|
||||
| Gate | Command | Result |
|
||||
|---|---|---|
|
||||
| Formatting | `cargo fmt --all -- --check` | PASS |
|
||||
| Clippy | `cargo clippy --workspace --all-targets --locked -- -D warnings` | PASS |
|
||||
| Rust tests | `cargo test --workspace --locked --offline --no-fail-fast` | PASS — **636 passed / 0 failed / 2 ignored** across 74 test binaries (includes `docs_consistency`, `architecture_boundaries`, `stdlib_product`); baseline `4bbefc9` in a detached worktree is **633 passed / 0 failed / 2 ignored** (no regression; the candidate adds three architecture-boundary tests) |
|
||||
| Architecture boundaries | `cargo test -p marqdo-cli --test architecture_boundaries --locked` | PASS (15) |
|
||||
| Docs consistency | `cargo test -p marqdo-cli --test docs_consistency --locked` | PASS |
|
||||
| Dependency gate | `python3 tools/ci/check_dependency_boundaries.py` | PASS |
|
||||
| Dependency gate negative cases | `python3 -m unittest tools.ci.test_dependency_boundaries` / `python3 -m unittest discover -s tools/ci` | PASS (54 tool tests) |
|
||||
| Engine independence and differential execution | `python3 tools/ci/check_engine_boundary.py` | PASS |
|
||||
| Plugin SDK real consumption | `python3 tools/ci/check_plugin_sdk.py` | PASS at that candidate; the SDK and this gate moved to the independent repository under issue #15 / ADR-0072 (evidence: `2026-11-26-issue-15-sdk-independent-repository.md`) |
|
||||
| Existing product/conformance suites | included in workspace run; stdlib product suite additionally run | PASS |
|
||||
|
||||
Behavioral facts from the engine gate:
|
||||
|
||||
- the independent consumer returns `sum_to(10) = Int(55)` and a structural
|
||||
`types(7)` map whose terminal Value Wire bytes equal a real CLI `call
|
||||
--output json` on the same file;
|
||||
- the consumer rejects real fuel exhaustion, stack-depth exceedance, expired
|
||||
deadline, out-of-bounds `Memory` access, a host that grants no external effect
|
||||
(`permission.denied`), and a host with no resource implementation
|
||||
(`resource.unsupported`);
|
||||
- `cargo tree -p marqdo-runtime -e normal,build` in the consumer graph has no
|
||||
`marqdo-host`, sandbox, foreign or libloading/rustls dependency;
|
||||
- `marqdo-plugin-sdk` normal tree contains only `marqdo-plugin-abi`,
|
||||
`marqdo-value` and serialization primitives.
|
||||
|
||||
Behavioral facts from the SDK gate:
|
||||
|
||||
- `tests/sdk-plugin` builds with only `marqdo-plugin-sdk` as a path dependency;
|
||||
- the real CLI loads it with `--trust-native-plugin` and
|
||||
`--allow-plugin sdk.demo` and returns `Int 42`;
|
||||
- a tampered `sha256` in `plugin.yaml` is rejected with an artifact/sha256
|
||||
diagnostic.
|
||||
|
||||
## CI evidence (remote, same code SHA)
|
||||
|
||||
Woodpecker PR pipeline **#101** for commit
|
||||
`9b4f0a08228e9932bf3b0a8c5cf80e0d04626ccb` finished **success** with every step
|
||||
green: `clone`, `contract`, `test`, `minimum-rust`, `build`. The `build` step
|
||||
builds the release binaries, packages the deterministic archive for
|
||||
`$CI_COMMIT_SHA`, runs the from-archive smoke test and the frozen external
|
||||
conformance suite, so C11/G05 get same-candidate CI evidence rather than an old
|
||||
release claim. The first pipeline (#100) failed in one unrelated pre-existing
|
||||
`provider_cli` test with `ETXTBSY` while executing a freshly copied binary; the
|
||||
same tree passed on straight rerun (#101), so it is recorded as an environment
|
||||
flake, not a candidate defect.
|
||||
|
||||
This evidence file was updated by a docs-only commit after that code SHA; code
|
||||
and lock bytes are unchanged by it. The PR check list shows the final run.
|
||||
|
||||
## Not verified here (honest state)
|
||||
|
||||
| Item | State | Reason / owner |
|
||||
|---|---|---|
|
||||
| Minimum Rust 1.89 | **UNVERIFIED** locally | only Rust 1.100 is installed in this environment; the Woodpecker `minimum-rust` lane runs `cargo check --locked --workspace --all-targets` on `rust:1.89-bookworm` |
|
||||
| Windows GNU cross-target compile | **PASS (cross-check only)** | `cargo check --workspace --all-targets --locked --target x86_64-pc-windows-gnu` finished successfully (pre-existing unrelated warnings); native Windows runtime and the GitHub/Woodpecker native lanes remain the actual platform gate |
|
||||
| Windows/macOS native runtime | **UNVERIFIED** locally | no native runner here; existing GitHub/Woodpecker lanes remain the gate |
|
||||
| `wasm32-unknown-unknown` Engine probe (E12) | **UNVERIFIED** | target std not installed and no network here; `cargo check -p marqdo-runtime --target wasm32-unknown-unknown` fails with `E0463: can't find crate for core/std`, i.e. a missing target toolchain rather than a forbidden native dependency. E01 is green, so no P0 violation is implied, but this is not a PASS |
|
||||
| strict OS-isolation lane | **UNVERIFIED** | needs the disposable VM; `strict` remains fail-closed |
|
||||
| Performance/RSS budget (G06) | **UNVERIFIED** | shared-node measurement is not valid evidence; no performance claim is made |
|
||||
| Frozen external conformance / release archive (C11/G05) | **CI PASS at code SHA `9b4f0a0`** | Woodpecker pipeline #101 `build` step: release archive from that SHA, archive smoke, frozen external conformance, PASS. This is not a new release tag. |
|
||||
| SDK physical repository, stdlib Phase B, regex/compression migration | **DEFERRED** | separate issues; see `docs/STATUS.md` |
|
||||
|
||||
## Boundary confirmation
|
||||
|
||||
- No new top-level CLI command, no `HostOp`/builtin/Value variant, no second
|
||||
interpreter, no `legacy` feature, no compatibility re-export of removed
|
||||
`marqdo_host::{Host, HostOp, ...}` paths.
|
||||
- Public protocols and their revisions are unchanged. This evidence covers an
|
||||
internal Rust boundary change, not a protocol migration.
|
||||
- No remote repository was created or modified for this work beyond pushing the
|
||||
candidate branch and PR; no empty candidate repository exists.
|
||||
@@ -0,0 +1,78 @@
|
||||
# Evidence — issue #15 independent `marqdo-plugin-sdk` repository
|
||||
|
||||
Date: 2026-11-26 (Asia/Shanghai)
|
||||
Tracking issue: <https://git.cflmy.cn/cflmy/marqdo-cli/issues/15>
|
||||
Decision: [ADR-0072](../adr/0072-sdk-independent-repository.md)
|
||||
Parent: issue #13 / [ADR-0071](../adr/0071-engine-host-contract-boundary.md)
|
||||
|
||||
## Topology and identity
|
||||
|
||||
| Object | Exact identity |
|
||||
|---|---|
|
||||
| SDK repository | `cflmy/marqdo-plugin-sdk` (public), `main` at `b31187a` |
|
||||
| CLI contract input | `marqdo-plugin-abi` from `https://git.cflmy.cn/cflmy/marqdo-cli.git` `rev = 2585915e16906dac75f8571bed02e7f6f868c6bc` (merge of PR #14) |
|
||||
| CLI candidate | `architecture/sdk-independent-repository`; PR/CI SHA recorded by the PR |
|
||||
| Frozen CLI acceptance binary | `marqdo` 3.0.0-rc.4 Linux x86_64 release archive, SHA-256 from the release `.sha256` asset |
|
||||
| ABI | Plugin ABI 1.0 / Value Wire 1 / package + provider formats unchanged |
|
||||
|
||||
The SDK repository is its own Cargo workspace and lock. The CLI does not depend
|
||||
on it, and the SDK does not depend on the CLI checkout, the native host, a
|
||||
loader/worker, a sandbox or the CLI product.
|
||||
|
||||
## SDK repository verification (clean clone, independent of CLI checkout)
|
||||
|
||||
Commands run in a fresh `git clone https://git.cflmy.cn/cflmy/marqdo-plugin-sdk.git`
|
||||
outside this repository:
|
||||
|
||||
| Gate | Command | Result |
|
||||
|---|---|---|
|
||||
| Locked build | `cargo build --locked` | PASS (contract fetched from the pinned public CLI git `rev`) |
|
||||
| SDK tests | `cargo test --locked` | PASS (4 unit tests + 1 doc-test, 2 ignored doc examples) |
|
||||
| Third-party fixture | `cargo build --locked --manifest-path tests/fixture/Cargo.toml` | PASS (built only from the SDK) |
|
||||
| Frozen CLI invocation (S04/S07) | `python3 tools/check_with_frozen_cli.py --marqdo-bin frozen/marqdo` | PASS — real CLI returns `Int 42` |
|
||||
| Tampered artifact (S05/S06) | same script, `sha256` replaced | PASS — rejected with artifact/sha256 diagnostic |
|
||||
|
||||
The frozen binary was the released 3.0.0-rc.4 archive, not a locally rebuilt CLI;
|
||||
the plugin ABI is unchanged across the #13 decoupling, which is exactly the
|
||||
cross-repository compatibility being tested.
|
||||
|
||||
SDK repository CI (`.woodpecker/main.yml`) repeats the workspace checks, the
|
||||
fixture build and the frozen-CLI integration after downloading that released
|
||||
archive. Enabling the Woodpecker project/webhook for the new repository is a
|
||||
repository-administration step outside this change; the pipeline definition is
|
||||
checked in and the same commands were executed manually above.
|
||||
|
||||
## CLI repository verification (this change)
|
||||
|
||||
| Gate | Command | Result |
|
||||
|---|---|---|
|
||||
| Workspace resolution | `cargo check --workspace --locked` | PASS; `marqdo-plugin-sdk` no longer appears in `Cargo.lock` |
|
||||
| Formatting | `cargo fmt --all -- --check` | PASS |
|
||||
| Clippy | `cargo clippy --workspace --all-targets --locked -- -D warnings` | PASS |
|
||||
| Rust tests | `cargo test --workspace --locked --no-fail-fast` | PASS — 631 passed / 0 failed / 0 ignored (the removed SDK 4 unit + 1 doc test now run in the SDK repository; the two previously ignored SDK doc examples moved with them) |
|
||||
| Architecture boundaries | `cargo test -p marqdo-cli --test architecture_boundaries --locked` | PASS — SDK absence/moved-repository assertion |
|
||||
| Docs consistency | `cargo test -p marqdo-cli --test docs_consistency --locked` | PASS |
|
||||
| Dependency direction | `python3 tools/ci/check_dependency_boundaries.py` | PASS — SDK no longer a workspace member; negative case added |
|
||||
| Tools unit tests | `python3 -m unittest discover -s tools/ci -p "test_*.py"` | PASS |
|
||||
| Engine differential | `python3 tools/ci/check_engine_boundary.py` | PASS (unchanged) |
|
||||
|
||||
Removed from the CLI workspace/repository in the same integration:
|
||||
|
||||
- `crates/marqdo-plugin-sdk/` (moved to the independent repository);
|
||||
- `tests/sdk-plugin/` (fixture moved to `tests/fixture` in the SDK repository);
|
||||
- `tools/ci/check_plugin_sdk.py` (its superset lives in the SDK repository and
|
||||
uses a frozen CLI binary);
|
||||
- workspace/lock entry, architecture/layer docs, CI lane entries and current
|
||||
developer references.
|
||||
|
||||
## Not verified / follow-ups
|
||||
|
||||
- **Woodpecker activation** for the new public repository is administrative; the
|
||||
pipeline definition is committed, but no remote pipeline run is claimed here.
|
||||
- **Registry publication** of the contract crate is not introduced; the public
|
||||
CLI git `rev` is the precise, fetchable input. A future published artifact
|
||||
would be a new decision and would not change contract authority.
|
||||
- Engine/Native Host remain in the CLI workspace under ADR-0071; this split does
|
||||
not reopen that decision.
|
||||
- No second ABI, wire encoder, loader or host copy exists in the SDK repository;
|
||||
no compatibility/submodule path was added to the CLI repository.
|
||||
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"schema": "marqdo.release-gates.v1",
|
||||
"profile": "rc",
|
||||
"target_sha": "452e9a32bd9e40dba427d4180691c58bab74449e",
|
||||
"recorded_utc": "2026-11-25T06:13:39Z",
|
||||
"gates": {
|
||||
"linux": {
|
||||
"state": "PASS",
|
||||
"tested_sha": "452e9a32bd9e40dba427d4180691c58bab74449e",
|
||||
"run_url": "https://ci.cflmy.cn/repos/1/pipeline/94",
|
||||
"recorded_utc": "2026-11-25T06:13:39Z"
|
||||
},
|
||||
"extension": {
|
||||
"state": "PASS",
|
||||
"tested_sha": "452e9a32bd9e40dba427d4180691c58bab74449e",
|
||||
"run_url": "docs/evidence/2026-11-25-rc.4-extension-manifest.json",
|
||||
"recorded_utc": "2026-11-25T06:13:39Z"
|
||||
},
|
||||
"clean_install": {
|
||||
"state": "PASS",
|
||||
"tested_sha": "452e9a32bd9e40dba427d4180691c58bab74449e",
|
||||
"run_url": "docs/evidence/2026-11-25-rc.4-cold-install.log",
|
||||
"recorded_utc": "2026-11-25T06:13:39Z"
|
||||
},
|
||||
"version_compat": {
|
||||
"state": "PASS",
|
||||
"tested_sha": "452e9a32bd9e40dba427d4180691c58bab74449e",
|
||||
"run_url": "https://ci.cflmy.cn/repos/1/pipeline/94",
|
||||
"recorded_utc": "2026-11-25T06:13:39Z"
|
||||
},
|
||||
"windows": {
|
||||
"state": "UNSUPPORTED",
|
||||
"tested_sha": "452e9a32bd9e40dba427d4180691c58bab74449e",
|
||||
"run_url": "COMPATIBILITY.md",
|
||||
"recorded_utc": "2026-11-25T06:13:39Z"
|
||||
},
|
||||
"macos": {
|
||||
"state": "UNSUPPORTED",
|
||||
"tested_sha": "452e9a32bd9e40dba427d4180691c58bab74449e",
|
||||
"run_url": "COMPATIBILITY.md",
|
||||
"recorded_utc": "2026-11-25T06:13:39Z"
|
||||
},
|
||||
"strict_vm": {
|
||||
"state": "PASS",
|
||||
"tested_sha": "452e9a32bd9e40dba427d4180691c58bab74449e",
|
||||
"run_url": "docs/evidence/2026-11-25-rc.4-strict-evidence.json",
|
||||
"recorded_utc": "2026-11-25T06:13:39Z"
|
||||
},
|
||||
"performance": {
|
||||
"state": "WARN",
|
||||
"tested_sha": "452e9a32bd9e40dba427d4180691c58bab74449e",
|
||||
"run_url": "docs/evidence/2026-11-25-rc.4-shared-node-performance.md",
|
||||
"rc_shared_node_approval": "Maintainer cflmy approved shared-node performance WARN for v3.0.0-rc.4 on 2026-11-25; docs/evidence/2026-11-25-rc.4-shared-node-performance.md",
|
||||
"recorded_utc": "2026-11-25T06:13:39Z"
|
||||
}
|
||||
},
|
||||
"release_decision": "RC_RELEASE_CANDIDATE",
|
||||
"reasons": []
|
||||
}
|
||||
@@ -4,6 +4,15 @@ Status: the sampler and correctness corpus are implemented; **no release
|
||||
performance baseline exists yet**. Do not cite a development-container or
|
||||
TCG/QEMU number as a release gate.
|
||||
|
||||
## Release-class policy
|
||||
|
||||
- **RC candidates** may use a maintainer-approved shared node. The environment,
|
||||
load, limits, paired baseline/candidate comparison and approval are recorded
|
||||
in the release notes; the result remains `WARN`, never a dedicated-node PASS.
|
||||
- **Stable/LTS** releases require a dedicated fixed node and the full paired-run
|
||||
protocol. The shared-node exception is RC-only and must not be reused for
|
||||
LTS evidence.
|
||||
|
||||
## Three separate measurements
|
||||
|
||||
| Class | Goal | Host |
|
||||
|
||||
+13
-11
@@ -75,17 +75,19 @@ Use the frozen-SHA build and archive checks above. Additionally:
|
||||
|
||||
- Strict L1 requires a same-SHA PASS on a disposable VM as a non-root user.
|
||||
Record the strict evidence and verify the archived binary on that guest.
|
||||
- Measure the packaged CLI on a dedicated fixed node with 5 warmups and
|
||||
20 samples or more for each of the nine workloads. Compare against a
|
||||
correctness-verified baseline on the same node, CPU affinity, governor,
|
||||
kernel and toolchain. Record investigation and resolution for any p50
|
||||
increase of at least 15% or median peak RSS increase of at least 20%.
|
||||
A dedicated node is the default. For a prerelease approved by the
|
||||
maintainer to use a shared node, take at least three paired beta/RC runs
|
||||
under the same measured conditions and keep all reports. Verify all nine
|
||||
workloads and investigate threshold breaches or unstable samples before
|
||||
accepting a `WARN`. Record the approval, runner environment and limits in
|
||||
the release notes. This exception applies to the named RC only.
|
||||
- Measure the packaged CLI with 5 warmups and 20 samples or more for each of
|
||||
the nine workloads, or for the changed boundary's representative fixture when
|
||||
the gate is scoped by an accepted ADR. Compare against a correctness-verified
|
||||
baseline on the same node, CPU affinity, governor, kernel and toolchain.
|
||||
Record investigation and resolution for any p50 increase of at least 15% or
|
||||
median peak RSS increase of at least 20%.
|
||||
**RC candidates may use a shared node.** The maintainer approves the shared
|
||||
node for that named RC, the environment/load/limits and the comparison are
|
||||
recorded in the release notes, and the result stays a `WARN`; it is never
|
||||
promoted to a dedicated-node PASS. A final stable/LTS release requires a
|
||||
dedicated fixed node with the full paired-run protocol; the shared-node
|
||||
exception does not carry over to it. Verify correctness before timing and do
|
||||
not accept results from an unmeasured or unexplained environment.
|
||||
- Version compatibility covers the locked Rust minimum, CLI and Analysis
|
||||
product identity, Tool/project prerelease ranges, and beta migration.
|
||||
- Use Ubuntu 24.04 (glibc 2.39) for the independent archive-only runtime
|
||||
|
||||
@@ -91,7 +91,7 @@ wire response: {"wire_version":1,"kind":"response",
|
||||
```
|
||||
|
||||
The integration test
|
||||
`crates/marqdo-plugin-abi/tests/loader_unix.rs` compiles this exact
|
||||
`crates/marqdo-host/tests/loader_unix.rs` compiles this exact
|
||||
`solver.c` with `cc -shared -fPIC`, loads it with `libloading`, and round-trips
|
||||
the request. It duplicates the compilation with
|
||||
`-DMQ_SOLVER_REPORT_ABI_MAJOR=2` to prove that a wrong ABI major fails the
|
||||
|
||||
Loaded 100 of 113 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user