refactor: extract neutral host contract and decouple plugin ABI (issue #13)
ci/woodpecker/pr/main Pipeline was successful
ci/woodpecker/push/main Pipeline was canceled

Implements the core M0-M3 boundary work from issue #13 / ADR-0071 without
changing language semantics or any public protocol:

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

Evidence: docs/evidence/2026-11-26-issue-13-engine-host-boundary.md
Refs #13
This commit is contained in:
cflmy committed 2026-11-26 18:37:02 +08:00
1 parent 4bbefc9244
commit 9b4f0a0822
89 files changed
+3490 -545

No files matched your search

+9 -1
View File
@@ -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=签名)**已被废止,仅作为历史设计记录**。现行唯一语言语义权威是
+52 -2
View File
@@ -75,6 +75,55 @@ 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.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. Deliberately **UNVERIFIED**
here: minimum Rust 1.89, Windows/macOS native lanes, strict VM, WASM probe
(target std not installed; `E0463`, not a forbidden native dependency),
performance/RSS, frozen external conformance and release archive `G05`. The CI
lanes own those checks; none is claimed as PASS from this candidate. 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.10 Closed public Analysis boundary — issue #10 (RC.4 released)
The candidate replaces the program-only Analysis projection in place under
@@ -700,8 +749,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,156 @@
# ADR-0071 — Engine / Host Contract / Native Host / CLI boundaries
Status: **Accepted** for the pre-stable 3.0 line (2026-11-26).
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 is a follow-up: the contract is decoupled now,
and the move requires a clean-directory build against a fixed contract revision
(issue #13 S07/S08). 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.
+3
View File
@@ -70,3 +70,6 @@ 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.
+79 -10
View File
@@ -9,6 +9,51 @@ replace `spec/` or a recorded test log.
- 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-plugin-sdk` | Public contract consumer | Third-party plugin development helpers |
| `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 +201,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)
marqdo-plugin-sdk -> marqdo-plugin-abi (contract only)
marqdo-provider-worker -> marqdo-worker-ipc
```
@@ -170,10 +218,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 |
|---|---|---|---|
@@ -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` | Contract decoupled; physical move to an independent repository is a follow-up after the §6.3 external build and pinned-artifact mechanism | A clean-directory build against a fixed contract revision without the CLI checkout passes (S07/S08) |
| 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,9 @@ 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.
- [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 -1
View File
@@ -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,7 @@ 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, keep-in-workspace repository decision |
| 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 |
+4
View File
@@ -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,9 @@ 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)
check_plugin_sdk.py (real third-party SDK plugin via the real CLI)
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
View File
@@ -25,6 +25,11 @@ Foreign wire v1, Provider manifest v2, lock v4 and markdown profile
## 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
`python3 tools/ci/check_plugin_sdk.py` 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,91 @@
# 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 |
| 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.
## 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) | **UNVERIFIED in this candidate** | requires the frozen conformance repo/artifacts and a tagged candidate; RC.4 evidence is not reused |
| 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.