test(p2): prove foreign/plugin shortcuts fail in the pure lane

- Add negative tests: foreign.call -> permission.denied and plugin.invoke ->
  structured failure under --mode pure, complementing the 21-fixture pure lane.
- Update P2 evidence/tests README/changelog.

Gate: fmt, clippy -D warnings, 438 tests passed.
This commit is contained in:
cflmy committed 2026-11-20 23:29:14 +08:00
1 parent 974102dfc3
commit 313ac035e8
4 files changed
+49 -1

No files matched your search

+2
View File
@@ -130,6 +130,8 @@ currently `0.1.0`; no release tag has been cut. Dates use ISO 8601.
- CM-A10 offline packaging: `tools/pack-stdlib.py` emits a deterministic
`marqdo-stdlib-0.1.0.tar.gz` plus tree/archive digests and a file manifest;
the archive is for the future external repository, not the CLI loader.
- P2 anti-evasion: explicit pure-lane negative tests prove `foreign.call` is
`permission.denied` and `plugin.invoke` fails, alongside the 21 fixture lane.
- C12 sparse matrix: fixture 73 adds triple-list sparse multiply and dense
conversion, included in the P2 pure closure lane.
- P6 baseline profile: add `tools/perf/bench.py` and a checked-in 7-workload
+35
View File
@@ -122,3 +122,38 @@ fn p2_stdlib_table_also_runs_in_pure_mode() {
"| 名称 | 分数 |\n| --- | --- |\n| 甲 | 87 |\n| 乙 | 92 |\n| 丙 | 71 |"
);
}
#[test]
fn foreign_and_plugin_shortcuts_are_unavailable_in_the_pure_lane() {
let dir = tempfile::tempdir().unwrap();
let foreign = dir.path().join("foreign.mq.md");
std::fs::write(
&foreign,
"## 代码\n\n```python\nprint(1)\n```\n\n## main\n\n*foreign.call(ref(\"#代码\"), None)*\n",
)
.unwrap();
let output = Command::new(env!("CARGO_BIN_EXE_marqdo"))
.args(["run", foreign.to_str().unwrap(), "--mode", "pure", "--json"])
.current_dir(dir.path())
.output()
.expect("run foreign fixture");
assert_eq!(output.status.code(), Some(1));
let report: serde_json::Value = serde_json::from_slice(&output.stdout).expect("json");
assert_eq!(report["success"], false);
assert_eq!(report["error"]["code"], "permission.denied");
let plugin = dir.path().join("plugin.mq.md");
std::fs::write(
&plugin,
"## main\n\n> plugin.invoke(\"missing.export\", {})\n\n*None*\n",
)
.unwrap();
let output = Command::new(env!("CARGO_BIN_EXE_marqdo"))
.args(["run", plugin.to_str().unwrap(), "--mode", "pure", "--json"])
.current_dir(dir.path())
.output()
.expect("run plugin fixture");
assert_eq!(output.status.code(), Some(1));
let report: serde_json::Value = serde_json::from_slice(&output.stdout).expect("json");
assert_eq!(report["success"], false);
}
@@ -28,6 +28,16 @@ The independently-run conformance harness (`conformance_semantics.rs`) also
builds `StdHost` with `SandboxMode::Pure` and `Capabilities::pure()` for every
fixture.
Negative shortcuts:
```text
foreign.call in pure -> permission.denied
plugin.invoke in pure -> structured failure
```
so the lane proves both that the algorithms run without host shortcuts and that
the shortcuts are actually unavailable.
## Criterion mapping
| Criterion | Fixtures | What is proven |
+2 -1
View File
@@ -206,7 +206,8 @@ the cargo gate).
`crates/cli/tests/p2_closure.rs`: 21 semantic fixtures run through
`run --mode pure --json`, sources are scanned for foreign/plugin/import
shortcuts, and value/stdout are compared with the goldens; the stdlib table
self-test also runs in pure mode.
self-test also runs in pure mode. Negative cases prove `foreign.call` is
`permission.denied` and `plugin.invoke` fails in the pure lane.
RFC-CM CM-A08 table stdlib (ADR-0032) is pinned by
`crates/cli/tests/stdlib_table.rs`, which runs `stdlib/tests/table.mq.md` and