fix: close release-gate defects in platform cfg, strict launch, and semantics

WHY
- macOS/Windows failed to compile because `cfg!` left `linux::probe()` in the
  type-checked branch (E0433).
- GitHub-hosted Linux can pass the strict probe and then fail the real launch
  with EAGAIN; the CLI test treated the inspect snapshot as a permanent promise.
- The security matrix shared process-id-based scratch paths, so parallel
  `cargo test --workspace` made its own tests clobber each other.
- Condition paragraphs silently ignored executable `Strong`/`Emph`, and
  condition parse spans included the code-span backticks.
- The corpus had no native power/control-flow/inert fixtures and no independent
  generic Tool consumers.

WHAT
- Dispatch strict detection through `#[cfg]` functions; add a non-Linux
  compile/fail-closed regression test.
- Split `linux::run` into an injectable probe/spawn seam; test probe-OK ->
  launch-EAGAIN returns LaunchFailed and never executes unrestricted.
- Make the Linux CLI contract accept only (a) successful isolated run or
  (b) non-zero, diagnosed, fail-closed refusal with no project stdout.
- Give each security test a unique project/outside path and compile the helper
  once.
- Reject executable roles in a condition paragraph; map condition expressions
  from the literal bytes inside the backticks.
- Add 10 AST, 8 semantic, 4 compile-negative and 2 runtime-negative fixtures
  for power, branch/loop conditions, source spans, inert prose/code fences and
  error boundaries.
- Add `sample-view`/`sample-knowledge`/`sample-proof` independent Tool v1
  packages and an end-to-end Analysis/Trace consumer test.
- Add a locked path-dependency content-tamper test.

TESTS
- cargo fmt --all -- --check
- cargo clippy --workspace --all-targets -- -D warnings
- cargo test --workspace --locked
- G-C VM lane (separate evidence commit/run)

CI_URL
- none from this host: the checkout has a Gitee remote and no GitHub
  credentials. Windows/macOS CI remains UNVERIFIED.

BREAKING_CHANGE
- An executable node in a list-item condition paragraph is now a hard
  `markdown.invalid_construct` error instead of being silently ignored.

SECURITY_SCOPE
- strict remains fail-closed; no downgrade, no new capability, L2 still
  rejected. G-C still requires the dedicated self-hosted lane for CI-signed
  evidence.
This commit is contained in:
cflmy committed 2026-11-20 15:40:17 +08:00
1 parent c9f01aa8fb
commit d05f36fd26
65 files changed
+2134 -87

No files matched your search

@@ -0,0 +1,18 @@
# sample-knowledge
A tiny independent Tool Protocol v1 consumer used to prove that arbitrary
top-level tool names dispatch through the registry, not through a hard-coded
CLI match arm. It is a test fixture, not part of a View/Knowledge/Proof
product.
Build and install (any OS with a Rust toolchain):
```sh
rustc --edition 2021 examples/tool-samples/sample-knowledge/src/main.rs \
-o /tmp/marqdo-tool-sample-knowledge/bin/sample-knowledge
cp examples/tool-samples/sample-knowledge/tool.json /tmp/marqdo-tool-sample-knowledge/
MARQDO_TOOL_HOME=/tmp/marqdo-tools marqdo tool install /tmp/marqdo-tool-sample-knowledge/tool.json
```
See `crates/cli/tests/tool_protocol.rs` for the automated Analysis/Trace
consumer test.
@@ -0,0 +1,54 @@
//! Independent Tool Protocol v1 consumer: reads a small part of Trace v2.
use std::fs;
fn string_field<'a>(json: &'a str, key: &str) -> Option<&'a str> {
let needle = format!("\"{key}\"");
let start = json.find(&needle)? + needle.len();
let colon = json[start..].find(':')? + start;
let quote = json[colon..].find('"')? + colon;
let rest = &json[quote + 1..];
let end = rest.find('"')?;
Some(&rest[..end])
}
fn number_field(json: &str, key: &str) -> Option<i64> {
let needle = format!("\"{key}\"");
let start = json.find(&needle)? + needle.len();
let colon = json[start..].find(':')? + start;
let rest = json[colon + 1..].trim_start();
let end = rest
.find(|ch: char| !ch.is_ascii_digit() && ch != '-')
.unwrap_or(rest.len());
rest[..end].parse().ok()
}
fn main() {
let args: Vec<String> = std::env::args().skip(1).collect();
let path = args
.iter()
.position(|arg| arg == "--trace")
.and_then(|index| args.get(index + 1))
.or_else(|| args.first())
.unwrap_or_else(|| {
eprintln!("usage: sample-knowledge --trace <trace-v2.json>");
std::process::exit(2);
});
let json = fs::read_to_string(path).unwrap_or_else(|error| {
eprintln!("sample-knowledge: cannot read {path}: {error}");
std::process::exit(1);
});
let schema = string_field(&json, "schema").unwrap_or_default();
if schema != "marqdo.trace" {
eprintln!("sample-knowledge: expected marqdo.trace, got {schema:?}");
std::process::exit(1);
}
let version = number_field(&json, "schema_version").unwrap_or_default();
if version != 2 {
eprintln!("sample-knowledge: unsupported Trace version {version}");
std::process::exit(1);
}
let status = string_field(&json, "status").unwrap_or_default();
let events = json.matches("\"seq\"").count();
println!("sample-knowledge schema={schema} version={version} events={events} status={status}");
}
@@ -0,0 +1,13 @@
{
"schema": "marqdo.cli-tool",
"schema_version": 1,
"name": "demo.sample-knowledge",
"version": "0.1.0",
"command": "sample-knowledge",
"entrypoint": "bin/sample-knowledge",
"compatibility": {
"marqdo": ">=0.1,<1",
"analysis": [2],
"trace": [2]
}
}
@@ -0,0 +1,18 @@
# sample-proof
A tiny independent Tool Protocol v1 consumer used to prove that arbitrary
top-level tool names dispatch through the registry, not through a hard-coded
CLI match arm. It is a test fixture, not part of a View/Knowledge/Proof
product.
Build and install (any OS with a Rust toolchain):
```sh
rustc --edition 2021 examples/tool-samples/sample-proof/src/main.rs \
-o /tmp/marqdo-tool-sample-proof/bin/sample-proof
cp examples/tool-samples/sample-proof/tool.json /tmp/marqdo-tool-sample-proof/
MARQDO_TOOL_HOME=/tmp/marqdo-tools marqdo tool install /tmp/marqdo-tool-sample-proof/tool.json
```
See `crates/cli/tests/tool_protocol.rs` for the automated Analysis/Trace
consumer test.
@@ -0,0 +1,59 @@
//! Independent Tool Protocol v1 consumer: binds Analysis v2 and Trace v2.
use std::fs;
fn string_field<'a>(json: &'a str, key: &str) -> Option<&'a str> {
let needle = format!("\"{key}\"");
let start = json.find(&needle)? + needle.len();
let colon = json[start..].find(':')? + start;
let quote = json[colon..].find('"')? + colon;
let rest = &json[quote + 1..];
let end = rest.find('"')?;
Some(&rest[..end])
}
fn read(path: &str, label: &str) -> String {
fs::read_to_string(path).unwrap_or_else(|error| {
eprintln!("sample-proof: cannot read {label} {path}: {error}");
std::process::exit(1);
})
}
fn main() {
let args: Vec<String> = std::env::args().skip(1).collect();
let mut analysis = None;
let mut trace = None;
let mut index = 0;
while index + 1 < args.len() {
match args[index].as_str() {
"--analysis" => analysis = Some(args[index + 1].clone()),
"--trace" => trace = Some(args[index + 1].clone()),
_ => {}
}
index += 2;
}
let (Some(analysis), Some(trace)) = (analysis, trace) else {
eprintln!("usage: sample-proof --analysis <analysis-v2.json> --trace <trace-v2.json>");
std::process::exit(2);
};
let analysis = read(&analysis, "analysis");
let trace = read(&trace, "trace");
if string_field(&analysis, "schema") != Some("marqdo.analysis") {
eprintln!("sample-proof: analysis schema mismatch");
std::process::exit(1);
}
if string_field(&trace, "schema") != Some("marqdo.trace") {
eprintln!("sample-proof: trace schema mismatch");
std::process::exit(1);
}
if string_field(&trace, "status") != Some("ok") {
eprintln!("sample-proof: trace did not complete successfully");
std::process::exit(1);
}
let digest = string_field(&trace, "analysis_digest").unwrap_or_default();
if !digest.starts_with("sha256:") {
eprintln!("sample-proof: trace is not bound to an analysis digest");
std::process::exit(1);
}
println!("sample-proof bound=true digest={digest}");
}
@@ -0,0 +1,13 @@
{
"schema": "marqdo.cli-tool",
"schema_version": 1,
"name": "demo.sample-proof",
"version": "0.1.0",
"command": "sample-proof",
"entrypoint": "bin/sample-proof",
"compatibility": {
"marqdo": ">=0.1,<1",
"analysis": [2],
"trace": [2]
}
}
@@ -0,0 +1,18 @@
# sample-view
A tiny independent Tool Protocol v1 consumer used to prove that arbitrary
top-level tool names dispatch through the registry, not through a hard-coded
CLI match arm. It is a test fixture, not part of a View/Knowledge/Proof
product.
Build and install (any OS with a Rust toolchain):
```sh
rustc --edition 2021 examples/tool-samples/sample-view/src/main.rs \
-o /tmp/marqdo-tool-sample-view/bin/sample-view
cp examples/tool-samples/sample-view/tool.json /tmp/marqdo-tool-sample-view/
MARQDO_TOOL_HOME=/tmp/marqdo-tools marqdo tool install /tmp/marqdo-tool-sample-view/tool.json
```
See `crates/cli/tests/tool_protocol.rs` for the automated Analysis/Trace
consumer test.
@@ -0,0 +1,57 @@
//! Independent Tool Protocol v1 consumer: reads a small part of Analysis v2.
//!
//! This is a test fixture, not a hard-coded CLI command. Build it with
//! `rustc --edition 2021`, package it with `tool.json`, install it, and invoke
//! `marqdo sample-view --analysis <file>`.
use std::fs;
fn string_field<'a>(json: &'a str, key: &str) -> Option<&'a str> {
let needle = format!("\"{key}\"");
let start = json.find(&needle)? + needle.len();
let colon = json[start..].find(':')? + start;
let quote = json[colon..].find('"')? + colon;
let rest = &json[quote + 1..];
let end = rest.find('"')?;
Some(&rest[..end])
}
fn number_field(json: &str, key: &str) -> Option<i64> {
let needle = format!("\"{key}\"");
let start = json.find(&needle)? + needle.len();
let colon = json[start..].find(':')? + start;
let rest = json[colon + 1..].trim_start();
let end = rest
.find(|ch: char| !ch.is_ascii_digit() && ch != '-')
.unwrap_or(rest.len());
rest[..end].parse().ok()
}
fn main() {
let args: Vec<String> = std::env::args().skip(1).collect();
let path = args
.iter()
.position(|arg| arg == "--analysis")
.and_then(|index| args.get(index + 1))
.or_else(|| args.first())
.unwrap_or_else(|| {
eprintln!("usage: sample-view --analysis <analysis-v2.json>");
std::process::exit(2);
});
let json = fs::read_to_string(path).unwrap_or_else(|error| {
eprintln!("sample-view: cannot read {path}: {error}");
std::process::exit(1);
});
let schema = string_field(&json, "schema").unwrap_or_default();
if schema != "marqdo.analysis" {
eprintln!("sample-view: expected marqdo.analysis, got {schema:?}");
std::process::exit(1);
}
let version = number_field(&json, "schema_version").unwrap_or_default();
if version != 2 {
eprintln!("sample-view: unsupported Analysis version {version}");
std::process::exit(1);
}
let modules = json.matches("\"functions\"").count();
println!("sample-view schema={schema} version={version} modules={modules}");
}
@@ -0,0 +1,13 @@
{
"schema": "marqdo.cli-tool",
"schema_version": 1,
"name": "demo.sample-view",
"version": "0.1.0",
"command": "sample-view",
"entrypoint": "bin/sample-view",
"compatibility": {
"marqdo": ">=0.1,<1",
"analysis": [2],
"trace": [2]
}
}