ci/woodpecker/push/woodpecker Pipeline was successful
Replace the retired rc.2 Analysis v2/Trace v2/Execution Events v1 stack with the
single current contract family:
- Analysis v3 (ADR-0069 public boundary): one check --emit artifact carries the
exact source, Markdown AST, heading scopes (heading_span + complete span),
anchors, state-bearing references, calls, resources and diagnostics; the old
revision-3 shape is rejected with a rebuild hint.
- Observation v1: one run/call --output jsonl stream (+ atomic
--observation-file snapshot) decoded by one decoder and projected into the
reader/SSE/export layers; stale/malformed/truncated/incomplete never render
as success.
- CLI Tool revision 1: requires {api_revision:1, analysis:3, observation:1},
product range >=3.0.0-rc.3,<4.0.0, only MARQDO_BIN and
MARQDO_API_REVISION are consumed.
- Remove compatibility branches, retired flags/env vars and duplicate decoders;
re-record Analysis v3 and Observation v1 fixtures; rewrite contract,
integration and security tests (173 passing locally).
- Add check-no-legacy/check-docs/check-observation gates, rc.4 pins in the
CI pipelines, 0.3.0 Tool bundle and evidence manifest support.
See issues #4, #5 and #6; acceptance baseline is CLI source
452e9a32bd9e40dba427d4180691c58bab74449e, archive
9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8.
254 lines
7.8 KiB
Rust
254 lines
7.8 KiB
Rust
//! Architectural gates (RFC-VIEW-0001 §17.2): no private Core crates, no
|
|
//! source-tree reads of the legacy repositories, no second renderer, no shell
|
|
//! execution, one CSS/JS entry point.
|
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
fn manifest_dir() -> PathBuf {
|
|
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
|
}
|
|
|
|
fn read(path: &Path) -> String {
|
|
std::fs::read_to_string(path).unwrap_or_else(|err| panic!("read {}: {err}", path.display()))
|
|
}
|
|
|
|
fn collect_files(dir: &Path, extension: &str, out: &mut Vec<PathBuf>) {
|
|
let Ok(entries) = std::fs::read_dir(dir) else {
|
|
return;
|
|
};
|
|
for entry in entries.flatten() {
|
|
let path = entry.path();
|
|
if path.is_dir() {
|
|
collect_files(&path, extension, out);
|
|
} else if path.extension().and_then(|e| e.to_str()) == Some(extension) {
|
|
out.push(path);
|
|
}
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn no_private_core_crate_dependencies() {
|
|
let root = manifest_dir();
|
|
let forbidden = [
|
|
"marqdo",
|
|
"marqdo-cli",
|
|
"marqdo-ir",
|
|
"marqdo-runtime",
|
|
"marqdo-frontend",
|
|
"marqdo-host",
|
|
"marqdo-markdown",
|
|
"marqdo-span",
|
|
"marqdo-expression",
|
|
"marqdo-sema",
|
|
];
|
|
let mut in_dependency_section = false;
|
|
for line in read(&root.join("Cargo.toml")).lines() {
|
|
let trimmed = line.trim();
|
|
if trimmed.starts_with('[') {
|
|
in_dependency_section = trimmed.ends_with("dependencies]")
|
|
|| trimmed.contains("dependencies.")
|
|
|| trimmed.contains("dependencies]");
|
|
continue;
|
|
}
|
|
if !in_dependency_section || trimmed.is_empty() || trimmed.starts_with('#') {
|
|
continue;
|
|
}
|
|
let Some((name, _)) = trimmed.split_once('=') else {
|
|
continue;
|
|
};
|
|
let name = name.trim().trim_matches('"');
|
|
assert!(
|
|
!forbidden.contains(&name),
|
|
"Cargo.toml declares forbidden Core dependency {name:?}"
|
|
);
|
|
}
|
|
|
|
let lock = read(&root.join("Cargo.lock"));
|
|
for line in lock.lines() {
|
|
let Some(rest) = line.trim().strip_prefix("name = \"") else {
|
|
continue;
|
|
};
|
|
let name = rest.trim_end_matches('"');
|
|
if name == "marqdo-view" {
|
|
continue;
|
|
}
|
|
assert!(
|
|
!name.starts_with("marqdo") || name == "marqdo",
|
|
"Cargo.lock contains suspicious package {name:?}"
|
|
);
|
|
assert!(
|
|
!forbidden.contains(&name),
|
|
"Cargo.lock contains forbidden Core package {name:?}"
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn source_never_reads_or_links_the_legacy_repositories() {
|
|
let root = manifest_dir();
|
|
let mut sources = Vec::new();
|
|
collect_files(&root.join("src"), "rs", &mut sources);
|
|
assert!(!sources.is_empty(), "src/ has no Rust sources");
|
|
let needles = [
|
|
["marqdo", "_ir"].concat(),
|
|
["marqdo", "-ir"].concat(),
|
|
["marqdo", "_runtime"].concat(),
|
|
["marqdo", "-runtime"].concat(),
|
|
["marqdo", "_frontend"].concat(),
|
|
["marqdo", "-frontend"].concat(),
|
|
["marqdo", "::"].concat(),
|
|
["..", "/marqdo"].concat(),
|
|
["..", "/marqdo-cli"].concat(),
|
|
["inspect", " --ir"].concat(),
|
|
["Command::new", "(\"sh\")"].concat(),
|
|
["Command::new", "(\"bash\")"].concat(),
|
|
["sh", " -c"].concat(),
|
|
["bash", " -c"].concat(),
|
|
];
|
|
for path in sources {
|
|
let text = read(&path);
|
|
for (line_number, line) in text.lines().enumerate() {
|
|
let trimmed = line.trim_start();
|
|
// Documentation may *name* forbidden APIs when explaining what is
|
|
// not used; the gate only scans executable source lines.
|
|
if trimmed.starts_with("//") {
|
|
continue;
|
|
}
|
|
for needle in &needles {
|
|
assert!(
|
|
!line.contains(needle.as_str()),
|
|
"{}:{} contains forbidden reference {:?}",
|
|
path.display(),
|
|
line_number + 1,
|
|
needle
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn exactly_one_reader_theme_and_script_entry() {
|
|
let root = manifest_dir();
|
|
let assets = root.join("assets");
|
|
let mut css = Vec::new();
|
|
let mut js = Vec::new();
|
|
collect_files(&assets, "css", &mut css);
|
|
collect_files(&assets, "js", &mut js);
|
|
assert_eq!(css.len(), 1, "exactly one CSS entry: {css:?}");
|
|
assert_eq!(js.len(), 1, "exactly one JS entry: {js:?}");
|
|
for path in &css {
|
|
assert_eq!(
|
|
path.file_name().and_then(|n| n.to_str()),
|
|
Some("reader.css"),
|
|
"the only CSS entry must be assets/reader.css"
|
|
);
|
|
}
|
|
for path in &js {
|
|
assert_eq!(
|
|
path.file_name().and_then(|n| n.to_str()),
|
|
Some("reader.js"),
|
|
"the only JS entry must be assets/reader.js"
|
|
);
|
|
}
|
|
// The source tree must not reference legacy skin names at all.
|
|
let mut sources = Vec::new();
|
|
collect_files(&root.join("src"), "rs", &mut sources);
|
|
for path in sources {
|
|
let text = read(&path);
|
|
for needle in ["notebook-page", "reader-page", "legacy.css", "new.css"] {
|
|
assert!(
|
|
!text.contains(needle),
|
|
"{} references legacy skin marker {needle:?}",
|
|
path.display()
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn tool_manifest_matches_package_and_protocols() {
|
|
let root = manifest_dir();
|
|
let raw = read(&root.join("tool.json"));
|
|
let tool: serde_json::Value = serde_json::from_str(&raw).expect("tool.json is JSON");
|
|
assert_eq!(tool["schema"], "marqdo.cli-tool");
|
|
assert_eq!(tool["schema_version"], 1);
|
|
assert_eq!(tool["name"], "marqdo-view");
|
|
assert_eq!(tool["command"], "view");
|
|
assert_eq!(tool["entrypoint"], "bin/marqdo-view");
|
|
assert_eq!(
|
|
tool["version"],
|
|
env!("CARGO_PKG_VERSION"),
|
|
"tool.json version must match Cargo package version"
|
|
);
|
|
assert_eq!(
|
|
tool["requires"],
|
|
serde_json::json!({"api_revision": 1, "analysis": 3, "observation": 1}),
|
|
"the manifest must declare exact current revisions"
|
|
);
|
|
assert!(
|
|
tool.get("compatibility").is_none(),
|
|
"the retired compatibility negotiation block must not return"
|
|
);
|
|
let keys: Vec<&str> = tool
|
|
.as_object()
|
|
.unwrap()
|
|
.keys()
|
|
.map(String::as_str)
|
|
.collect();
|
|
assert_eq!(
|
|
keys,
|
|
vec![
|
|
"command",
|
|
"entrypoint",
|
|
"name",
|
|
"requires",
|
|
"schema",
|
|
"schema_version",
|
|
"version"
|
|
],
|
|
"tool.json must not carry retired fields"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn source_has_no_legacy_protocol_or_runtime_probing() {
|
|
let root = manifest_dir();
|
|
let mut sources = Vec::new();
|
|
collect_files(&root.join("src"), "rs", &mut sources);
|
|
let banned = [
|
|
"analysis_v2",
|
|
"trace_v2",
|
|
"execution_events_v1",
|
|
"MARQDO_TOOL_PROTOCOL",
|
|
"MARQDO_PROTOCOL_ANALYSIS",
|
|
"MARQDO_PROTOCOL_TRACE",
|
|
"--trace-file",
|
|
"--event-stream",
|
|
"compatibility",
|
|
];
|
|
for path in sources {
|
|
// Unit-test modules may assert that a retired flag is absent; the gate
|
|
// scans production source only.
|
|
let text = read(&path);
|
|
let production = text.split("#[cfg(test)]").next().unwrap_or("").to_string();
|
|
for needle in banned {
|
|
assert!(
|
|
!production.contains(needle),
|
|
"{} still references retired contract marker {:?}",
|
|
path.display(),
|
|
needle
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn release_lockfile_is_committed() {
|
|
let root = manifest_dir();
|
|
assert!(
|
|
root.join("Cargo.lock").is_file(),
|
|
"Cargo.lock must be committed for --locked release builds"
|
|
);
|
|
}
|