refactor: extract neutral host contract and decouple plugin ABI (issue #13)
ci/woodpecker/pr/main Pipeline is pending
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:35:31 +08:00
1 parent 4bbefc9244
commit d713aa068a
89 files changed
+3490 -545

No files matched your search

+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 |