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:
1 parent
c9f01aa8fb
commit
d05f36fd26
65 files changed
+2134
-87
No files matched your search
@@ -110,6 +110,134 @@ fn stdout(output: &Output) -> String {
|
||||
String::from_utf8_lossy(&output.stdout).to_string()
|
||||
}
|
||||
|
||||
fn repo_root() -> PathBuf {
|
||||
Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.parent()
|
||||
.expect("crates/cli has a parent")
|
||||
.parent()
|
||||
.expect("crates has a parent")
|
||||
.to_path_buf()
|
||||
}
|
||||
|
||||
/// Compile one of the checked-in independent consumer samples and package it
|
||||
/// as a Tool Protocol v1 bundle. Sources live in `examples/tool-samples/` so
|
||||
/// they are reviewable software, not hidden test strings.
|
||||
fn write_sample_from_source(dir: &Path, command: &str) -> PathBuf {
|
||||
let root = repo_root();
|
||||
let source = root.join(format!("examples/tool-samples/{command}/src/main.rs"));
|
||||
let package = dir.join(format!("{command}-pkg"));
|
||||
std::fs::create_dir_all(package.join("bin")).unwrap();
|
||||
let entry = package
|
||||
.join("bin")
|
||||
.join(format!("{command}{}", std::env::consts::EXE_SUFFIX));
|
||||
let status = Command::new("rustc")
|
||||
.args(["--edition", "2021", "-o"])
|
||||
.arg(&entry)
|
||||
.arg(&source)
|
||||
.status()
|
||||
.expect("run rustc for the sample tool");
|
||||
assert!(status.success(), "rustc failed for {command}");
|
||||
let entrypoint = format!("bin/{command}{}", std::env::consts::EXE_SUFFIX);
|
||||
let manifest = package.join("tool.json");
|
||||
std::fs::write(
|
||||
&manifest,
|
||||
format!(
|
||||
r#"{{"schema":"marqdo.cli-tool","schema_version":1,"name":"demo.{command}","version":"0.1.0","command":"{command}","entrypoint":"{entrypoint}","compatibility":{{"marqdo":">=0.1,<1","analysis":[2],"trace":[2]}}}}"#
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
manifest
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn independent_sample_tools_consume_public_analysis_and_trace() {
|
||||
let dir = TempDir::new("samples");
|
||||
let home = dir.path().join("home");
|
||||
let analysis = dir.path().join("analysis.json");
|
||||
let trace = dir.path().join("trace.json");
|
||||
let root = repo_root();
|
||||
|
||||
let check = Command::new(binary())
|
||||
.args([
|
||||
"check",
|
||||
"examples/multi-module/index.mq.md",
|
||||
"--refs",
|
||||
"--emit",
|
||||
])
|
||||
.arg(&analysis)
|
||||
.current_dir(&root)
|
||||
.output()
|
||||
.expect("run check");
|
||||
assert!(check.status.success(), "check failed: {}", stderr(&check));
|
||||
let run = Command::new(binary())
|
||||
.args(["run", "examples/multi-module/index.mq.md", "--trace-file"])
|
||||
.arg(&trace)
|
||||
.current_dir(&root)
|
||||
.output()
|
||||
.expect("run");
|
||||
assert!(run.status.success(), "run failed: {}", stderr(&run));
|
||||
|
||||
// None of these names exists in the CLI: dispatch must come from the
|
||||
// installed generic tool registry.
|
||||
for command in ["sample-view", "sample-knowledge", "sample-proof"] {
|
||||
let unknown = cli(&home, &[command]);
|
||||
assert_eq!(unknown.status.code(), Some(2), "{command} must be unknown");
|
||||
assert!(stderr(&unknown).contains("unknown command"));
|
||||
let manifest = write_sample_from_source(dir.path(), command);
|
||||
let install = cli(&home, &["tool", "install", manifest.to_str().unwrap()]);
|
||||
assert_eq!(
|
||||
install.status.code(),
|
||||
Some(0),
|
||||
"{command}: {}",
|
||||
stderr(&install)
|
||||
);
|
||||
}
|
||||
|
||||
let view = cli(
|
||||
&home,
|
||||
&["sample-view", "--analysis", analysis.to_str().unwrap()],
|
||||
);
|
||||
assert_eq!(view.status.code(), Some(0), "{}", stderr(&view));
|
||||
let text = stdout(&view);
|
||||
assert!(
|
||||
text.contains("sample-view schema=marqdo.analysis version=2"),
|
||||
"{text}"
|
||||
);
|
||||
assert!(text.contains("modules="), "{text}");
|
||||
|
||||
let knowledge = cli(
|
||||
&home,
|
||||
&["sample-knowledge", "--trace", trace.to_str().unwrap()],
|
||||
);
|
||||
assert_eq!(knowledge.status.code(), Some(0), "{}", stderr(&knowledge));
|
||||
let text = stdout(&knowledge);
|
||||
assert!(
|
||||
text.contains("sample-knowledge schema=marqdo.trace version=2"),
|
||||
"{text}"
|
||||
);
|
||||
assert!(text.contains("status=ok"), "{text}");
|
||||
|
||||
let proof = cli(
|
||||
&home,
|
||||
&[
|
||||
"sample-proof",
|
||||
"--analysis",
|
||||
analysis.to_str().unwrap(),
|
||||
"--trace",
|
||||
trace.to_str().unwrap(),
|
||||
],
|
||||
);
|
||||
assert_eq!(proof.status.code(), Some(0), "{}", stderr(&proof));
|
||||
let text = stdout(&proof);
|
||||
assert!(text.contains("sample-proof bound=true"), "{text}");
|
||||
assert!(text.contains("digest=sha256:"), "{text}");
|
||||
|
||||
for command in ["sample-view", "sample-knowledge", "sample-proof"] {
|
||||
let removed = cli(&home, &["tool", "remove", command]);
|
||||
assert_eq!(removed.status.code(), Some(0), "{}", stderr(&removed));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn install_dispatch_list_remove_without_core_knowledge_of_the_name() {
|
||||
let dir = TempDir::new("roundtrip");
|
||||
|
||||
Reference in new issue
Block a user