refactor: extract neutral host contract and decouple plugin ABI (issue #13)
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:
1 parent
4bbefc9244
commit
9b4f0a0822
89 files changed
+3490
-545
No files matched your search
Generated
+543
@@ -0,0 +1,543 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "caseless"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b6fd507454086c8edfd769ca6ada439193cdb209c7681712ef6275cccbfe5d8"
|
||||
dependencies = [
|
||||
"unicode-normalization",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
||||
|
||||
[[package]]
|
||||
name = "comrak"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d981d666dca19afb3cc090dc7c381560cb8ba76582dda6e2c14686ff39fd547f"
|
||||
dependencies = [
|
||||
"caseless",
|
||||
"entities",
|
||||
"finl_unicode",
|
||||
"memchr-n",
|
||||
"phf",
|
||||
"phf_codegen",
|
||||
"rustc-hash",
|
||||
"smallvec",
|
||||
"typed-arena",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"crypto-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "entities"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
|
||||
|
||||
[[package]]
|
||||
name = "fearless_simd"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "629c9d6b6f30b5604089e0980f4d924a013aacb1654a6cdf5d3d852224f68651"
|
||||
|
||||
[[package]]
|
||||
name = "fearless_simd_macros"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3e91d94c6885390b81782d7ee60fd6583b33907333a8b340de25ccf468353315"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "finl_unicode"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ded33109e99472f809cb7495544506eea45e366725dacf2a383e184f660456"
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.17.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.191"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-embedding-consumer"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"marqdo-frontend",
|
||||
"marqdo-host-contract",
|
||||
"marqdo-ir",
|
||||
"marqdo-runtime",
|
||||
"marqdo-span",
|
||||
"marqdo-value",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-expression"
|
||||
version = "3.0.0-rc.4"
|
||||
dependencies = [
|
||||
"marqdo-span",
|
||||
"num-bigint",
|
||||
"serde",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-frontend"
|
||||
version = "3.0.0-rc.4"
|
||||
dependencies = [
|
||||
"marqdo-expression",
|
||||
"marqdo-ir",
|
||||
"marqdo-markdown",
|
||||
"marqdo-span",
|
||||
"marqdo-value",
|
||||
"sha2",
|
||||
"unicode-ident",
|
||||
"unicode-normalization",
|
||||
]
|
||||
|
||||
[[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"
|
||||
dependencies = [
|
||||
"marqdo-expression",
|
||||
"marqdo-span",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-markdown"
|
||||
version = "3.0.0-rc.4"
|
||||
dependencies = [
|
||||
"comrak",
|
||||
"marqdo-span",
|
||||
"serde",
|
||||
"serde_yaml",
|
||||
"unicode-normalization",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-runtime"
|
||||
version = "3.0.0-rc.4"
|
||||
dependencies = [
|
||||
"marqdo-expression",
|
||||
"marqdo-host-contract",
|
||||
"marqdo-ir",
|
||||
"marqdo-span",
|
||||
"marqdo-value",
|
||||
"num-bigint",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-span"
|
||||
version = "3.0.0-rc.4"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-value"
|
||||
version = "3.0.0-rc.4"
|
||||
dependencies = [
|
||||
"marqdo-span",
|
||||
"num-bigint",
|
||||
"num-traits",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
||||
|
||||
[[package]]
|
||||
name = "memchr-n"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f48c6352cc1185740af256ccc396af598d2366bfd90a34f5afe48744bf06a5b5"
|
||||
dependencies = [
|
||||
"fearless_simd",
|
||||
"fearless_simd_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367"
|
||||
dependencies = [
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "010378780309880b08997fae13be7834dba947d36393bd372f2b1556deb2a2f6"
|
||||
dependencies = [
|
||||
"phf_shared",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_codegen"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41b585a510fb76fdebead6897982ef2a03a21d8e6cbcca904999742a4afc6ffe"
|
||||
dependencies = [
|
||||
"phf_generator",
|
||||
"phf_shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_generator"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aeb62e0959d5a1bebc965f4d15d9e2b7cea002b6b0f5ba8cde6cc26738467100"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
"phf_shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_shared"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6fd9027e2d9319be6349febd1db4e8d02aa544921200c9b777720ac34a3aa89"
|
||||
dependencies = [
|
||||
"siphasher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.154"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"serde",
|
||||
"serde_core",
|
||||
"zmij",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_yaml"
|
||||
version = "0.9.34+deprecated"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
"unsafe-libyaml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.10.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.16.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3244542535d5de959d90ec55d1b5ff0fd2bb7b1310223907d5f11932847f7b59"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "3.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "2.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee"
|
||||
|
||||
[[package]]
|
||||
name = "typed-arena"
|
||||
version = "2.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.20.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
version = "0.1.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75cd3fb03d5288b3ba9a1ee103ac7e9cbb59f0b03d64f8ddfcc04dd42758a85d"
|
||||
dependencies = [
|
||||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unsafe-libyaml"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "zmij"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
||||
@@ -0,0 +1,24 @@
|
||||
[package]
|
||||
name = "marqdo-embedding-consumer"
|
||||
description = "Independent Engine consumer: Markdown -> Frontend -> IR -> Runtime without the native host"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
# A separate workspace: this consumer must resolve and build with its own
|
||||
# dependency graph so workspace feature unification cannot hide a native-host
|
||||
# dependency of the engine.
|
||||
[workspace]
|
||||
|
||||
[dependencies]
|
||||
marqdo-frontend = { path = "../../crates/marqdo-frontend" }
|
||||
marqdo-host-contract = { path = "../../crates/marqdo-host-contract" }
|
||||
marqdo-ir = { path = "../../crates/marqdo-ir" }
|
||||
marqdo-runtime = { path = "../../crates/marqdo-runtime" }
|
||||
marqdo-span = { path = "../../crates/marqdo-span" }
|
||||
marqdo-value = { path = "../../crates/marqdo-value" }
|
||||
serde_json = "1"
|
||||
|
||||
[[bin]]
|
||||
name = "embedding-consumer"
|
||||
path = "src/main.rs"
|
||||
@@ -0,0 +1,21 @@
|
||||
# Embedding consumer
|
||||
|
||||
This is a real, independent Cargo package, **not** a workspace member. It is
|
||||
the engine-side acceptance consumer for issue #13 / ADR-0071: it builds and
|
||||
executes the same `.mq.md` program through the real Markdown → frontend → IR →
|
||||
runtime path while depending only on the platform-neutral engine crates.
|
||||
|
||||
It must never depend on `marqdo-host`, `marqdo-sandbox`, `marqdo-foreign`,
|
||||
`marqdo-plugin-abi`, the CLI or a native loader. `tools/ci/check_engine_boundary.py`
|
||||
builds it with `--locked`, verifies its dependency tree and compares its
|
||||
results with a real CLI invocation on the same program.
|
||||
|
||||
The `TestHost` here is a bounded in-memory host for this consumer, not a
|
||||
published product host: it grants no external effect, and cannot be described
|
||||
as a sandbox or as equivalent to the CLI's `pure` mode.
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
cargo run --locked --manifest-path tests/embedding/Cargo.toml
|
||||
```
|
||||
@@ -0,0 +1,51 @@
|
||||
# Embedding
|
||||
|
||||
## @exec sum_to
|
||||
|
||||
`params(n: Int)`
|
||||
|
||||
`i = 0`
|
||||
|
||||
`total = 0`
|
||||
|
||||
`while i <= n`
|
||||
|
||||
`total = total + i`
|
||||
|
||||
`i = i + 1`
|
||||
|
||||
`end`
|
||||
|
||||
`return total`
|
||||
|
||||
## @exec types
|
||||
|
||||
`params(seed: Int)`
|
||||
|
||||
`record = {"i": seed, "b": true, "t": "héllo", "l": [1, 2, 3], "n": None}`
|
||||
|
||||
`return record`
|
||||
|
||||
## @exec recurse
|
||||
|
||||
`params(n: Int)`
|
||||
|
||||
`if n <= 0`
|
||||
|
||||
`return 0`
|
||||
|
||||
`end`
|
||||
|
||||
`return recurse(n=n - 1)`
|
||||
|
||||
## @exec oob
|
||||
|
||||
`m = memory.new(1, 1)`
|
||||
|
||||
`return m[70000]`
|
||||
|
||||
## @exec read_file
|
||||
|
||||
`r = resource.open("file", "embedding-probe.txt", ["read"])`
|
||||
|
||||
`return r`
|
||||
@@ -0,0 +1,400 @@
|
||||
//! Independent Engine consumer for issue #13 / ADR-0071.
|
||||
//!
|
||||
//! This binary is a real Cargo package outside the CLI workspace. It executes
|
||||
//! one Markdown program through the real Frontend, static call binding and
|
||||
//! Runtime and reports the result through the neutral Host contract. It never
|
||||
//! depends on the Native Host, the CLI, the sandbox or a plugin loader.
|
||||
//!
|
||||
//! Positive cases are compared against a real CLI invocation by
|
||||
//! `tools/ci/check_engine_boundary.py`. Negative cases use a bounded test host
|
||||
//! and assert the concrete error category; a no-op limit is not accepted.
|
||||
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use marqdo_frontend::analyze_source;
|
||||
use marqdo_host_contract::{ExecutionContext, Host, HostOp};
|
||||
use marqdo_ir::{ModuleId, Program};
|
||||
use marqdo_runtime::{run_with_limits, EvaluatedArg, MemoryLimits};
|
||||
use marqdo_span::Span;
|
||||
use marqdo_value::{ErrorCategory, RuntimeError, Value};
|
||||
|
||||
const MODULE_ID: &str = "program.mq.md";
|
||||
|
||||
/// A small bounded host. It implements real budgets and refuses every external
|
||||
/// effect; it is deliberately not a published product host or a sandbox.
|
||||
struct TestHost {
|
||||
fuel: u64,
|
||||
stack_limit: usize,
|
||||
deadline: Option<Instant>,
|
||||
output: Vec<u8>,
|
||||
}
|
||||
|
||||
impl TestHost {
|
||||
fn bounded() -> Self {
|
||||
Self {
|
||||
fuel: 5_000_000,
|
||||
stack_limit: 128,
|
||||
deadline: Some(Instant::now() + Duration::from_secs(30)),
|
||||
output: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn with_fuel(mut self, fuel: u64) -> Self {
|
||||
self.fuel = fuel;
|
||||
self
|
||||
}
|
||||
|
||||
fn with_stack_limit(mut self, limit: usize) -> Self {
|
||||
self.stack_limit = limit;
|
||||
self
|
||||
}
|
||||
|
||||
fn with_expired_deadline(mut self) -> Self {
|
||||
self.deadline = Some(Instant::now() - Duration::from_secs(1));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Host for TestHost {
|
||||
fn invoke(
|
||||
&mut self,
|
||||
op: HostOp,
|
||||
_args: Vec<Value>,
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<Value, RuntimeError> {
|
||||
Err(RuntimeError::new(
|
||||
ErrorCategory::PermissionDenied,
|
||||
ctx.span,
|
||||
format!(
|
||||
"embedding consumer grants no external effect for `{}`",
|
||||
op.name()
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
fn resource_open(
|
||||
&mut self,
|
||||
kind: &str,
|
||||
_descriptor: &str,
|
||||
_rights: &[String],
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<Value, RuntimeError> {
|
||||
Err(RuntimeError::new(
|
||||
ErrorCategory::PermissionDenied,
|
||||
ctx.span,
|
||||
format!("embedding consumer grants no `{kind}` resource"),
|
||||
))
|
||||
}
|
||||
|
||||
fn consume_fuel(&mut self, amount: u64, span: Option<Span>) -> Result<(), RuntimeError> {
|
||||
if amount > self.fuel {
|
||||
self.fuel = 0;
|
||||
return Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceExhausted,
|
||||
span,
|
||||
"embedding consumer evaluation fuel exhausted",
|
||||
));
|
||||
}
|
||||
self.fuel -= amount;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn check_stack(&self, depth: usize, span: Option<Span>) -> Result<(), RuntimeError> {
|
||||
if depth > self.stack_limit {
|
||||
return Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceExhausted,
|
||||
span,
|
||||
format!(
|
||||
"embedding consumer stack limit ({}) exceeded",
|
||||
self.stack_limit
|
||||
),
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn check_deadline(&self, span: Option<Span>) -> Result<(), RuntimeError> {
|
||||
if let Some(deadline) = self.deadline {
|
||||
if Instant::now() >= deadline {
|
||||
return Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceExhausted,
|
||||
span,
|
||||
"embedding consumer wall-clock deadline exceeded",
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn take_output(&mut self) -> Vec<u8> {
|
||||
std::mem::take(&mut self.output)
|
||||
}
|
||||
}
|
||||
|
||||
/// A host with no resource implementation at all: it inherits the trait
|
||||
/// defaults, which must fail explicitly with `ResourceUnsupported`.
|
||||
struct InertHost {
|
||||
fuel: u64,
|
||||
}
|
||||
|
||||
impl Host for InertHost {
|
||||
fn invoke(
|
||||
&mut self,
|
||||
op: HostOp,
|
||||
_args: Vec<Value>,
|
||||
ctx: &ExecutionContext,
|
||||
) -> Result<Value, RuntimeError> {
|
||||
Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceUnsupported,
|
||||
ctx.span,
|
||||
format!("inert host does not implement `{}`", op.name()),
|
||||
))
|
||||
}
|
||||
|
||||
fn consume_fuel(&mut self, amount: u64, span: Option<Span>) -> Result<(), RuntimeError> {
|
||||
if amount > self.fuel {
|
||||
return Err(RuntimeError::new(
|
||||
ErrorCategory::ResourceExhausted,
|
||||
span,
|
||||
"inert host fuel exhausted",
|
||||
));
|
||||
}
|
||||
self.fuel -= amount;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn check_stack(&self, _depth: usize, _span: Option<Span>) -> Result<(), RuntimeError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn check_deadline(&self, _span: Option<Span>) -> Result<(), RuntimeError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn take_output(&mut self) -> Vec<u8> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
fn build_program(source: &str) -> Program {
|
||||
let analysis = analyze_source(MODULE_ID, source);
|
||||
assert!(
|
||||
!analysis.has_errors(),
|
||||
"frontend rejected the embedding program: {:#?}",
|
||||
analysis.diagnostics
|
||||
);
|
||||
let module_id = ModuleId::from(MODULE_ID);
|
||||
let mut program = Program {
|
||||
main_module: Some(module_id),
|
||||
..Program::default()
|
||||
};
|
||||
program.insert(analysis.module);
|
||||
let registry = program.callable_registry();
|
||||
let bound = marqdo_frontend::calls::bind_program_calls(&program, ®istry);
|
||||
assert!(
|
||||
bound.diagnostics.is_empty(),
|
||||
"static call binding rejected the embedding program: {:#?}",
|
||||
bound.diagnostics
|
||||
);
|
||||
program.set_call_bindings(bound.bindings);
|
||||
program
|
||||
}
|
||||
|
||||
fn named_args(args: &[(&str, Value)]) -> Vec<EvaluatedArg> {
|
||||
args.iter()
|
||||
.map(|(name, value)| EvaluatedArg::named(*name, value.clone(), Span::default()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn run_case(
|
||||
program: &Program,
|
||||
host: &mut dyn Host,
|
||||
function: &str,
|
||||
args: &[(&str, Value)],
|
||||
limits: MemoryLimits,
|
||||
) -> Result<Value, RuntimeError> {
|
||||
run_with_limits(
|
||||
program,
|
||||
host,
|
||||
&ModuleId::from(MODULE_ID),
|
||||
function,
|
||||
named_args(args),
|
||||
limits,
|
||||
)
|
||||
.map(|outcome| outcome.value)
|
||||
}
|
||||
|
||||
fn report_value(name: &str, value: &Value) -> Result<(), String> {
|
||||
let wire = marqdo_value::to_wire(value);
|
||||
let encoded = serde_json::to_string(&wire).map_err(|error| error.to_string())?;
|
||||
println!("result {name} {encoded}");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn expect_error(name: &str, result: Result<Value, RuntimeError>, expected: ErrorCategory) {
|
||||
match result {
|
||||
Ok(value) => fail(&format!(
|
||||
"{name}: expected error {:?}, ran successfully with {value:?}",
|
||||
expected
|
||||
)),
|
||||
Err(error) => {
|
||||
if error.category != expected {
|
||||
fail(&format!(
|
||||
"{name}: expected error {:?}, got {:?} ({})",
|
||||
expected, error.category, error.message
|
||||
));
|
||||
}
|
||||
println!("error {name} {}", error.code());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn fail(message: &str) -> ! {
|
||||
eprintln!("FAIL: {message}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if let Err(message) = execute() {
|
||||
fail(&message);
|
||||
}
|
||||
println!("PASS embedding-consumer");
|
||||
}
|
||||
|
||||
fn execute() -> Result<(), String> {
|
||||
let source = include_str!("../program.mq.md");
|
||||
let program = build_program(source);
|
||||
|
||||
// Positive: Int loop result.
|
||||
let mut host = TestHost::bounded();
|
||||
let sum = run_case(
|
||||
&program,
|
||||
&mut host,
|
||||
"sum_to",
|
||||
&[("n", Value::int(10))],
|
||||
MemoryLimits::default(),
|
||||
)
|
||||
.map_err(|error| format!("sum_to failed: {}", error.message))?;
|
||||
if sum != Value::int(55) {
|
||||
return Err(format!("sum_to(10) = {sum:?}, expected Int(55)"));
|
||||
}
|
||||
report_value("sum_to", &sum)?;
|
||||
|
||||
// Positive: structural values use the single Value Wire encoder.
|
||||
let mut host = TestHost::bounded();
|
||||
let record = run_case(
|
||||
&program,
|
||||
&mut host,
|
||||
"types",
|
||||
&[("seed", Value::int(7))],
|
||||
MemoryLimits::default(),
|
||||
)
|
||||
.map_err(|error| format!("types failed: {}", error.message))?;
|
||||
report_value("types", &record)?;
|
||||
|
||||
// Negative: real fuel exhaustion.
|
||||
let mut host = TestHost::bounded().with_fuel(4);
|
||||
expect_error(
|
||||
"fuel",
|
||||
run_case(
|
||||
&program,
|
||||
&mut host,
|
||||
"sum_to",
|
||||
&[("n", Value::int(10))],
|
||||
MemoryLimits::default(),
|
||||
),
|
||||
ErrorCategory::ResourceExhausted,
|
||||
);
|
||||
|
||||
// Negative: real stack-depth limit.
|
||||
let mut host = TestHost::bounded().with_stack_limit(2);
|
||||
expect_error(
|
||||
"stack",
|
||||
run_case(
|
||||
&program,
|
||||
&mut host,
|
||||
"recurse",
|
||||
&[("n", Value::int(10))],
|
||||
MemoryLimits::default(),
|
||||
),
|
||||
ErrorCategory::ResourceExhausted,
|
||||
);
|
||||
|
||||
// Negative: real wall-clock deadline.
|
||||
let mut host = TestHost::bounded().with_expired_deadline();
|
||||
expect_error(
|
||||
"deadline",
|
||||
run_case(
|
||||
&program,
|
||||
&mut host,
|
||||
"sum_to",
|
||||
&[("n", Value::int(10))],
|
||||
MemoryLimits::default(),
|
||||
),
|
||||
ErrorCategory::ResourceExhausted,
|
||||
);
|
||||
|
||||
// Negative: addressable-memory bounds are enforced by the runtime.
|
||||
let mut host = TestHost::bounded();
|
||||
match run_case(&program, &mut host, "oob", &[], MemoryLimits::default()) {
|
||||
Ok(value) => return Err(format!("oob: expected a memory error, got {value:?}")),
|
||||
Err(error) => {
|
||||
if !matches!(
|
||||
error.category,
|
||||
ErrorCategory::IndexOutOfBounds | ErrorCategory::MemoryFault
|
||||
) {
|
||||
return Err(format!(
|
||||
"oob: expected a memory bound error, got {:?} ({})",
|
||||
error.category, error.message
|
||||
));
|
||||
}
|
||||
println!("error oob {}", error.code());
|
||||
}
|
||||
}
|
||||
|
||||
// Negative: a host that grants no external effect refuses explicitly.
|
||||
let mut host = TestHost::bounded();
|
||||
expect_error(
|
||||
"file_denied",
|
||||
run_case(
|
||||
&program,
|
||||
&mut host,
|
||||
"read_file",
|
||||
&[],
|
||||
MemoryLimits::default(),
|
||||
),
|
||||
ErrorCategory::PermissionDenied,
|
||||
);
|
||||
|
||||
// Negative: a host with no resource implementation reports Unsupported,
|
||||
// never a prose fallback or a silent success.
|
||||
let mut host = InertHost { fuel: 1_000_000 };
|
||||
expect_error(
|
||||
"file_unsupported",
|
||||
run_case(
|
||||
&program,
|
||||
&mut host,
|
||||
"read_file",
|
||||
&[],
|
||||
MemoryLimits::default(),
|
||||
),
|
||||
ErrorCategory::ResourceUnsupported,
|
||||
);
|
||||
|
||||
// Sanity: budget fields are not a no-op and remain run-scoped.
|
||||
let mut host = TestHost::bounded();
|
||||
let fuel_before = host.fuel;
|
||||
let _ = run_case(
|
||||
&program,
|
||||
&mut host,
|
||||
"sum_to",
|
||||
&[("n", Value::int(3))],
|
||||
MemoryLimits::default(),
|
||||
)
|
||||
.map_err(|error| format!("budget sanity run failed: {}", error.message))?;
|
||||
if host.fuel >= fuel_before {
|
||||
return Err("fuel budget did not decrease during execution".to_string());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user