feat: migrate View 0.3.0 to marqdo 3.0.0-rc.4 contracts
ci/woodpecker/push/woodpecker Pipeline was successful
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.
This commit is contained in:
1 parent
7b34199c96
commit
a802f96b6e
109 files changed
+14000
-6461
No files matched your search
@@ -289,8 +289,8 @@ function localHostOnly(url) {
|
||||
check("run panel visible", await page.locator("#mq-run-panel").isVisible());
|
||||
check("run chips anchored", (await page.locator(".mq-run-chip").count()) > 0);
|
||||
check(
|
||||
"observed chips carry trace provenance",
|
||||
(await page.locator('.mq-run-chip[data-annotation-source="trace"]').count()) > 0
|
||||
"observed chips carry observation provenance",
|
||||
(await page.locator('.mq-run-chip[data-annotation-source="observation"]').count()) > 0
|
||||
);
|
||||
check(
|
||||
"static statement anchors carry analysis provenance",
|
||||
@@ -313,7 +313,7 @@ function localHostOnly(url) {
|
||||
}))
|
||||
);
|
||||
check(
|
||||
"trace event list rendered",
|
||||
"observation event list rendered",
|
||||
(await page.locator("#mq-run-events li").count()) > 0
|
||||
);
|
||||
check(
|
||||
@@ -366,14 +366,14 @@ function localHostOnly(url) {
|
||||
await page.click('[data-action="run-confirm"]');
|
||||
await page.waitForSelector('body[data-run-state="succeeded"]');
|
||||
check("installed tool displays the real double(5) result",
|
||||
await page.locator("#mq-run-summary").innerText().then((text) => text.includes("返回值:Int(10)")));
|
||||
await page.locator("#mq-run-summary").innerText().then((text) => text.includes("返回值:10")));
|
||||
|
||||
await page.click('.mq-tabs [data-action="functions"]');
|
||||
await call("format_arguments").click();
|
||||
await page.fill('[data-param-name="label"]', '"浏览器 "');
|
||||
await page.fill('[data-param-name="items"]', '["列表", 7]');
|
||||
await page.click('[data-action="run-confirm"]');
|
||||
await page.getByText("返回值:Text(浏览器 列表 · 7)", { exact: true }).waitFor();
|
||||
await page.getByText("返回值:浏览器 列表 · 7", { exact: true }).waitFor();
|
||||
check("CLI round-tripped Unicode Text and a List through the form", submittedRuns === 2);
|
||||
}
|
||||
|
||||
|
||||
+18
-15
@@ -26,21 +26,21 @@ impl Drop for TestServer {
|
||||
}
|
||||
|
||||
/// Start the real `marqdo-view` binary on an OS-chosen loopback port with a
|
||||
/// scripted fake Core. Golden Analysis must match the project's exact source.
|
||||
/// scripted fake Core. The Analysis golden must match the project's exact source;
|
||||
/// the optional Observation v1 goldens are the exact JSONL stream and snapshot of
|
||||
/// one execution.
|
||||
pub fn start(
|
||||
project: &str,
|
||||
analysis_golden: &str,
|
||||
run_golden: Option<&str>,
|
||||
trace_golden: Option<&str>,
|
||||
observation_golden: Option<(&str, &str)>,
|
||||
) -> TestServer {
|
||||
start_with_env(project, analysis_golden, run_golden, trace_golden, &[])
|
||||
start_with_env(project, analysis_golden, observation_golden, &[])
|
||||
}
|
||||
|
||||
pub fn start_with_env(
|
||||
project: &str,
|
||||
analysis_golden: &str,
|
||||
run_golden: Option<&str>,
|
||||
trace_golden: Option<&str>,
|
||||
observation_golden: Option<(&str, &str)>,
|
||||
envs: &[(&str, &str)],
|
||||
) -> TestServer {
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
@@ -50,11 +50,11 @@ pub fn start_with_env(
|
||||
let core = FakeCore::new(&format!("http-core-{seq}"));
|
||||
let golden = std::fs::read(repo_root.join(analysis_golden)).unwrap();
|
||||
core.set_analysis(std::str::from_utf8(&golden).unwrap());
|
||||
if let Some(run_golden) = run_golden {
|
||||
let run = std::fs::read_to_string(repo_root.join(run_golden)).unwrap();
|
||||
let trace =
|
||||
trace_golden.map(|trace| std::fs::read_to_string(repo_root.join(trace)).unwrap());
|
||||
core.set_run(0, &run, trace.as_deref());
|
||||
if let Some((jsonl_path, snapshot_path)) = observation_golden {
|
||||
let jsonl = std::fs::read_to_string(repo_root.join(jsonl_path)).unwrap();
|
||||
let snapshot = std::fs::read_to_string(repo_root.join(snapshot_path)).unwrap();
|
||||
core.set_check_json(r#"{"command":"check","diagnostics":[],"errors":0,"success":true}"#);
|
||||
core.set_observation(0, &jsonl, Some(&snapshot));
|
||||
}
|
||||
|
||||
let mut command = Command::new(view_bin());
|
||||
@@ -63,9 +63,7 @@ pub fn start_with_env(
|
||||
.args([project, "--port", "0", "--no-open", "--marqdo-bin"])
|
||||
.arg(&core.script)
|
||||
.env_remove("MARQDO_BIN")
|
||||
.env_remove("MARQDO_TOOL_PROTOCOL")
|
||||
.env_remove("MARQDO_PROTOCOL_ANALYSIS")
|
||||
.env_remove("MARQDO_PROTOCOL_TRACE")
|
||||
.env_remove("MARQDO_API_REVISION")
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::piped());
|
||||
for (key, value) in envs {
|
||||
@@ -404,7 +402,12 @@ pub fn collect_until_terminal(reader: &mut SseReader) -> Vec<SseFrame> {
|
||||
.map(|state| {
|
||||
matches!(
|
||||
state,
|
||||
"succeeded" | "failed" | "cancelled" | "timed_out" | "unavailable"
|
||||
"succeeded"
|
||||
| "failed"
|
||||
| "cancelled"
|
||||
| "timed_out"
|
||||
| "unavailable"
|
||||
| "incomplete"
|
||||
)
|
||||
})
|
||||
.unwrap_or(false);
|
||||
|
||||
+75
-24
@@ -58,6 +58,11 @@ impl TempProject {
|
||||
|
||||
/// A scriptable shell-based fake core. Every behaviour is controlled by files
|
||||
/// in its directory, so tests never mutate global environment variables.
|
||||
///
|
||||
/// The current contract is Analysis v3 (`check --emit`) plus Observation v1
|
||||
/// (`run|call --output jsonl [--observation-file PATH]`). The fake core emits the
|
||||
/// exact bytes stored in `analysis.json`, `observation.jsonl` and
|
||||
/// `observation.snapshot.json`; it never fakes a successful verification.
|
||||
pub struct FakeCore {
|
||||
pub dir: PathBuf,
|
||||
pub script: PathBuf,
|
||||
@@ -75,35 +80,34 @@ dir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
||||
} >> "$dir/argv.txt"
|
||||
case "$1" in
|
||||
--version)
|
||||
if [ -f "$dir/version" ]; then cat "$dir/version"; else printf 'marqdo 3.0.0-beta.1\n'; fi
|
||||
if [ -f "$dir/version" ]; then cat "$dir/version"; else printf 'marqdo 3.0.0-rc.4\n'; fi
|
||||
exit 0
|
||||
;;
|
||||
check)
|
||||
if [ -f "$dir/check_stderr" ]; then cat "$dir/check_stderr" >&2; fi
|
||||
if [ -f "$dir/check_json" ]; then cat "$dir/check_json"; fi
|
||||
emit=""
|
||||
prev=""
|
||||
for a in "$@"; do
|
||||
if [ "$prev" = "--emit" ]; then emit="$a"; fi
|
||||
prev="$a"
|
||||
done
|
||||
if [ -f "$dir/check_stderr" ]; then cat "$dir/check_stderr" >&2; fi
|
||||
if [ -f "$dir/check_json" ]; then cat "$dir/check_json"; fi
|
||||
if [ -f "$dir/analysis.json" ] && [ -n "$emit" ]; then cp "$dir/analysis.json" "$emit"; fi
|
||||
if [ -f "$dir/check_exit" ]; then exit "$(cat "$dir/check_exit")"; fi
|
||||
exit 0
|
||||
;;
|
||||
run|call)
|
||||
: > "$dir/run-was-called"
|
||||
if [ -f "$dir/sleep" ]; then
|
||||
sleep "$(cat "$dir/sleep")"
|
||||
fi
|
||||
trace=""
|
||||
obs=""
|
||||
prev=""
|
||||
for a in "$@"; do
|
||||
if [ "$prev" = "--trace-file" ]; then trace="$a"; fi
|
||||
if [ "$prev" = "--observation-file" ]; then obs="$a"; fi
|
||||
prev="$a"
|
||||
done
|
||||
if [ -f "$dir/trace.json" ] && [ -n "$trace" ]; then cp "$dir/trace.json" "$trace"; fi
|
||||
if [ -f "$dir/run.json" ]; then cat "$dir/run.json"; else printf '{"command":"run","success":true}\n'; fi
|
||||
if [ -f "$dir/run_stderr" ]; then cat "$dir/run_stderr" >&2; fi
|
||||
if [ -f "$dir/sleep" ]; then sleep "$(cat "$dir/sleep")"; fi
|
||||
if [ -f "$dir/observation.jsonl" ]; then cat "$dir/observation.jsonl"; fi
|
||||
if [ -f "$dir/observation.snapshot.json" ] && [ -n "$obs" ]; then cp "$dir/observation.snapshot.json" "$obs"; fi
|
||||
if [ -f "$dir/run_exit" ]; then exit "$(cat "$dir/run_exit")"; fi
|
||||
exit 0
|
||||
;;
|
||||
@@ -140,23 +144,33 @@ esac
|
||||
std::fs::write(self.dir.join("analysis.json"), analysis).expect("write analysis");
|
||||
}
|
||||
|
||||
pub fn set_run(&self, exit_code: i32, json: &str, trace: Option<&str>) {
|
||||
/// Terminal code/stderr plus the exact Observation v1 stream and snapshot.
|
||||
pub fn set_observation(&self, exit_code: i32, jsonl: &str, snapshot: Option<&str>) {
|
||||
std::fs::write(self.dir.join("run_exit"), exit_code.to_string()).expect("write run exit");
|
||||
std::fs::write(self.dir.join("run.json"), json).expect("write run json");
|
||||
match trace {
|
||||
Some(trace) => {
|
||||
std::fs::write(self.dir.join("trace.json"), trace).expect("write trace");
|
||||
std::fs::write(self.dir.join("observation.jsonl"), jsonl).expect("write observation");
|
||||
match snapshot {
|
||||
Some(snapshot) => {
|
||||
std::fs::write(self.dir.join("observation.snapshot.json"), snapshot)
|
||||
.expect("write snapshot");
|
||||
}
|
||||
None => {
|
||||
let _ = std::fs::remove_file(self.dir.join("trace.json"));
|
||||
let _ = std::fs::remove_file(self.dir.join("observation.snapshot.json"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_run_stderr(&self, stderr: &str) {
|
||||
std::fs::write(self.dir.join("run_stderr"), stderr).expect("write run stderr");
|
||||
}
|
||||
|
||||
pub fn set_sleep_seconds(&self, seconds: u32) {
|
||||
std::fs::write(self.dir.join("sleep"), seconds.to_string()).expect("write sleep");
|
||||
}
|
||||
|
||||
pub fn run_was_called(&self) -> bool {
|
||||
self.dir.join("run-was-called").exists()
|
||||
}
|
||||
|
||||
pub fn argv_lines(&self) -> Vec<String> {
|
||||
std::fs::read_to_string(self.dir.join("argv.txt"))
|
||||
.unwrap_or_default()
|
||||
@@ -190,29 +204,55 @@ pub fn run_view(args: &[&str], cwd: &Path, envs: &[(&str, Option<&str>)]) -> Out
|
||||
command.output().expect("run marqdo-view")
|
||||
}
|
||||
|
||||
/// Minimal valid Analysis v2 JSON for a single module, with a caller-provided
|
||||
/// source digest and schema version.
|
||||
pub fn minimal_analysis(relative_path: &str, source_digest: &str, schema_version: u32) -> String {
|
||||
/// Minimal valid Analysis v3 JSON for a single module, with a caller-provided
|
||||
/// schema version. The root document/unit spans cover the exact source.
|
||||
pub fn minimal_analysis(relative_path: &str, source: &str, schema_version: u32) -> String {
|
||||
let digest = sha256_hex(source.as_bytes());
|
||||
let module_id = format!("root:fixture@0.1.0::{relative_path}");
|
||||
let len = source.len() as u64;
|
||||
serde_json::json!({
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": schema_version,
|
||||
"producer": {
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-beta.1",
|
||||
"version": "3.0.0-rc.4",
|
||||
"markdown_profile": "marqdo.md.v1"
|
||||
},
|
||||
"project": {
|
||||
"root_id": "root:fixture@0.1.0",
|
||||
"identity_kind": "manifest",
|
||||
"entry_module_id": module_id,
|
||||
"lock_digest": "",
|
||||
"stdlib": null
|
||||
"manifest_digest": "",
|
||||
"stdlib": null,
|
||||
"extensions": []
|
||||
},
|
||||
"modules": [{
|
||||
"id": "root:fixture@0.1.0::index.mq.md",
|
||||
"id": module_id,
|
||||
"package_instance_id": "root:fixture@0.1.0",
|
||||
"relative_path": relative_path,
|
||||
"source_digest": source_digest,
|
||||
"units": [],
|
||||
"source_digest": digest,
|
||||
"source": source,
|
||||
"document": {
|
||||
"kind": "document",
|
||||
"span": {"start": 0, "end": len},
|
||||
"children": []
|
||||
},
|
||||
"units": [{
|
||||
"id": format!("{module_id}#"),
|
||||
"path": [],
|
||||
"parent_id": null,
|
||||
"kind": "root",
|
||||
"name": "",
|
||||
"level": 0,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "default",
|
||||
"mode_source_unit_id": format!("{module_id}#"),
|
||||
"heading_span": null,
|
||||
"span": {"start": 0, "end": len},
|
||||
"function": null
|
||||
}],
|
||||
"anchors": [],
|
||||
"functions": [],
|
||||
"imports": [],
|
||||
"references": [],
|
||||
@@ -224,6 +264,17 @@ pub fn minimal_analysis(relative_path: &str, source_digest: &str, schema_version
|
||||
.to_string()
|
||||
}
|
||||
|
||||
/// The committed golden for one example, as exact bytes.
|
||||
pub fn golden_bytes(path: &str) -> Vec<u8> {
|
||||
let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
std::fs::read(root.join(path)).unwrap_or_else(|err| panic!("read {path}: {err}"))
|
||||
}
|
||||
|
||||
/// The committed golden for one example, as text.
|
||||
pub fn golden_text(path: &str) -> String {
|
||||
String::from_utf8(golden_bytes(path)).expect("golden is UTF-8")
|
||||
}
|
||||
|
||||
pub fn sha256_hex(bytes: &[u8]) -> String {
|
||||
use sha2::{Digest, Sha256};
|
||||
let mut hasher = Sha256::new();
|
||||
|
||||
@@ -6,12 +6,7 @@ use crate::common;
|
||||
use common::run_view;
|
||||
|
||||
fn clean_env() -> Vec<(&'static str, Option<&'static str>)> {
|
||||
vec![
|
||||
("MARQDO_BIN", None),
|
||||
("MARQDO_TOOL_PROTOCOL", None),
|
||||
("MARQDO_PROTOCOL_ANALYSIS", None),
|
||||
("MARQDO_PROTOCOL_TRACE", None),
|
||||
]
|
||||
vec![("MARQDO_BIN", None), ("MARQDO_API_REVISION", None)]
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -36,7 +31,7 @@ fn version_is_the_tool_version() {
|
||||
let output = run_view(&["--version"], &cwd, &clean_env());
|
||||
assert_eq!(output.status.code(), Some(0));
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
assert!(stdout.contains("marqdo-view 0.2.0"), "{stdout}");
|
||||
assert!(stdout.contains("marqdo-view 0.3.0"), "{stdout}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+397
-112
@@ -1,5 +1,5 @@
|
||||
//! Contract tests against a real fake-core executable: argv shape, exit codes,
|
||||
//! stderr handling, temp artifacts and process-tree cleanup.
|
||||
//! stderr handling, temp artifacts and the current Analysis v3 revision.
|
||||
//!
|
||||
//! The fake core is a shell script, not a mocked Rust trait, so everything at
|
||||
//! the process boundary is exercised for real.
|
||||
@@ -7,7 +7,9 @@
|
||||
use crate::common;
|
||||
|
||||
use common::{minimal_analysis, sha256_hex, FakeCore, TempProject};
|
||||
use marqdo_view::core_client::{CheckOptions, CheckResponse, CoreClient, RunOptions};
|
||||
use marqdo_view::core_client::{
|
||||
build_call_args, build_run_args, CheckOptions, CheckResponse, CoreClient, RunOptions,
|
||||
};
|
||||
use marqdo_view::reader::source::Project;
|
||||
|
||||
fn fixture(name: &str) -> (TempProject, FakeCore) {
|
||||
@@ -17,11 +19,15 @@ fn fixture(name: &str) -> (TempProject, FakeCore) {
|
||||
(project, core)
|
||||
}
|
||||
|
||||
fn project_source(project: &TempProject) -> String {
|
||||
std::fs::read_to_string(project.path("index.mq.md")).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_returns_exact_analysis_bytes_and_digest() {
|
||||
let (project, core) = fixture("check_ok");
|
||||
let source = std::fs::read(project.path("index.mq.md")).unwrap();
|
||||
let analysis = minimal_analysis("index.mq.md", &sha256_hex(&source), 2);
|
||||
let source = project_source(&project);
|
||||
let analysis = minimal_analysis("index.mq.md", &source, 3);
|
||||
core.set_analysis(&analysis);
|
||||
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
@@ -42,15 +48,18 @@ fn check_returns_exact_analysis_bytes_and_digest() {
|
||||
let args = core.last_args();
|
||||
assert_eq!(args[0], "check");
|
||||
assert!(args.contains(&"--emit".to_string()));
|
||||
// No `--refs` unless requested.
|
||||
assert!(!args.contains(&"--refs".to_string()));
|
||||
// The retired Analysis v2 selector and trace flags never appear.
|
||||
for retired in ["--trace-file", "--event-stream"] {
|
||||
assert!(!args.contains(&retired.to_string()), "retired {retired}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_refs_is_forwarded_as_a_stricter_flag() {
|
||||
let (project, core) = fixture("check_refs");
|
||||
let source = std::fs::read(project.path("index.mq.md")).unwrap();
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &sha256_hex(&source), 2));
|
||||
let source = project_source(&project);
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &source, 3));
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
@@ -85,107 +94,105 @@ fn check_failure_preserves_core_stderr_and_code() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_returns_json_and_raw_trace() {
|
||||
let (project, core) = fixture("run_ok");
|
||||
core.set_run(
|
||||
0,
|
||||
r#"{"command":"run","success":true,"stdout":"ok","stderr":"","trace":[]}"#,
|
||||
Some(r#"{"schema":"marqdo.trace","schema_version":2,"events":[]}"#),
|
||||
fn run_and_call_argv_use_the_current_observation_flags_only() {
|
||||
let args = build_run_args(
|
||||
std::path::Path::new("/p/index.mq.md"),
|
||||
std::path::Path::new("/t/observation.json"),
|
||||
&RunOptions::default(),
|
||||
);
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let output = client
|
||||
.run(&project, &entry, &RunOptions::default())
|
||||
.unwrap();
|
||||
assert_eq!(output.exit_code, 0);
|
||||
assert_eq!(output.json["success"], true);
|
||||
let trace = output.trace_bytes.expect("trace bytes");
|
||||
assert_eq!(output.trace_sha256.unwrap(), sha256_hex(&trace));
|
||||
// Mode is always explicit; pure is the View default.
|
||||
let args = core.last_args();
|
||||
assert!(args.contains(&"--mode".to_string()));
|
||||
let mode_index = args.iter().position(|a| a == "--mode").unwrap();
|
||||
assert_eq!(args[mode_index + 1], "pure");
|
||||
assert!(args.contains(&"--json".to_string()));
|
||||
assert!(args.contains(&"--trace-file".to_string()));
|
||||
let text: Vec<String> = args
|
||||
.iter()
|
||||
.map(|arg| arg.to_string_lossy().to_string())
|
||||
.collect();
|
||||
assert_eq!(text[0], "run");
|
||||
assert!(text.contains(&"--mode".to_string()));
|
||||
assert!(text.contains(&"pure".to_string()));
|
||||
assert!(text.contains(&"--output".to_string()));
|
||||
assert!(text.contains(&"jsonl".to_string()));
|
||||
assert!(text.contains(&"--observation-file".to_string()));
|
||||
assert!(text.contains(&"--observe-max-events".to_string()));
|
||||
assert!(text.contains(&"--observe-max-bytes".to_string()));
|
||||
assert!(text.contains(&"--observe-max-value-bytes".to_string()));
|
||||
for retired in [
|
||||
"--json",
|
||||
"--trace-file",
|
||||
"--event-stream",
|
||||
"--trace-max-events",
|
||||
"--trace-max-bytes",
|
||||
"--trace-max-value-bytes",
|
||||
] {
|
||||
assert!(
|
||||
!text.contains(&retired.to_string()),
|
||||
"retired flag {retired}"
|
||||
);
|
||||
}
|
||||
assert!(!text
|
||||
.iter()
|
||||
.any(|token| token.contains(';') || token.contains('|') || token.contains('&')));
|
||||
|
||||
let args = build_call_args(
|
||||
std::path::Path::new("/p/index.mq.md"),
|
||||
"demo.calculate",
|
||||
&[("n".to_string(), "3".to_string())],
|
||||
std::path::Path::new("/t/observation.json"),
|
||||
&RunOptions::default(),
|
||||
);
|
||||
let text: Vec<String> = args
|
||||
.iter()
|
||||
.map(|arg| arg.to_string_lossy().to_string())
|
||||
.collect();
|
||||
assert_eq!(text[0], "call");
|
||||
assert!(text.contains(&"--arg".to_string()));
|
||||
assert!(text.contains(&"n=3".to_string()));
|
||||
assert!(text.contains(&"--observation-file".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_without_trace_file_reports_no_trace() {
|
||||
let (project, core) = fixture("run_no_trace");
|
||||
core.set_run(
|
||||
0,
|
||||
r#"{"command":"run","success":true,"stdout":"","stderr":"","trace":[]}"#,
|
||||
None,
|
||||
);
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let output = client
|
||||
.run(&project, &entry, &RunOptions::default())
|
||||
.unwrap();
|
||||
assert!(output.trace_bytes.is_none());
|
||||
assert!(output.trace_sha256.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_invalid_json_is_a_protocol_io_error() {
|
||||
let (project, core) = fixture("run_bad_json");
|
||||
core.set_run(0, "this is not json", None);
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let err = client
|
||||
.run(&project, &entry, &RunOptions::default())
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.io");
|
||||
assert!(err.to_string().contains("exactly one JSON"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn timeout_kills_the_process_group_and_reports_timeout() {
|
||||
let (project, core) = fixture("run_timeout");
|
||||
core.set_sleep_seconds(5);
|
||||
core.set_run(0, r#"{"command":"run","success":true}"#, None);
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let started = std::time::Instant::now();
|
||||
let err = client
|
||||
.run(
|
||||
&project,
|
||||
&entry,
|
||||
&RunOptions {
|
||||
view_timeout: Some(std::time::Duration::from_millis(300)),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap_err();
|
||||
let elapsed = started.elapsed();
|
||||
assert_eq!(err.code(), "view.core_timeout");
|
||||
assert!(
|
||||
elapsed < std::time::Duration::from_secs(3),
|
||||
"timeout took {elapsed:?}"
|
||||
fn default_run_does_not_request_variable_or_parameter_values() {
|
||||
let args = build_run_args(
|
||||
std::path::Path::new("/p/index.mq.md"),
|
||||
std::path::Path::new("/t/observation.json"),
|
||||
&RunOptions::default(),
|
||||
);
|
||||
let text: Vec<String> = args
|
||||
.iter()
|
||||
.map(|arg| arg.to_string_lossy().to_string())
|
||||
.collect();
|
||||
// Budgets are explicit, but no value name is selected by default.
|
||||
for flag in [
|
||||
"--observe-variable",
|
||||
"--observe-parameter",
|
||||
"--observe-text-values",
|
||||
] {
|
||||
assert!(!text.contains(&flag.to_string()), "default {flag}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn incompatible_product_version_is_rejected_before_any_work() {
|
||||
let (project, core) = fixture("version_old");
|
||||
core.set_version("marqdo 2.9.1\n");
|
||||
let (_project, core) = fixture("version_old");
|
||||
core.set_version("marqdo 3.0.0-rc.2\n");
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let err = client.negotiate().unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
assert_eq!(err.exit_code(), 2);
|
||||
// Only `--version` was invoked; no check/run happened.
|
||||
assert_eq!(core.last_args(), vec!["--version".to_string()]);
|
||||
let _ = project;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn current_rc_version_is_accepted() {
|
||||
let (_project, core) = fixture("version_rc4");
|
||||
core.set_version("marqdo 3.0.0-rc.4\n");
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
assert_eq!(
|
||||
client.negotiate().unwrap().version.to_string(),
|
||||
"3.0.0-rc.4"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_emit_after_success_is_an_analysis_failure() {
|
||||
// Fake core exits 0 but writes nothing: never accept a phantom analysis.
|
||||
let (project, core) = fixture("check_no_emit");
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
@@ -196,11 +203,6 @@ fn missing_emit_after_success_is_an_analysis_failure() {
|
||||
assert_eq!(err.code(), "view.analysis_failed");
|
||||
}
|
||||
|
||||
fn expect_check_ok(response: CheckResponse) -> marqdo_view::core_client::CheckOutput {
|
||||
assert!(response.success, "check failed: {:?}", response.diagnostics);
|
||||
response.analysis.expect("analysis on success")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failed_check_normalizes_diagnostics_without_absolute_paths() {
|
||||
let (project, core) = fixture("check_diagnostics");
|
||||
@@ -218,44 +220,152 @@ fn failed_check_normalizes_diagnostics_without_absolute_paths() {
|
||||
assert_eq!(response.diagnostics.len(), 1);
|
||||
assert_eq!(response.diagnostics[0].code, "sem.unclosed_control");
|
||||
assert_eq!(response.diagnostics[0].line, Some(5));
|
||||
// The raw absolute `file` field is not part of the normalized type at all.
|
||||
let rendered = serde_json::to_string(&response.diagnostics).unwrap();
|
||||
assert!(!rendered.contains("/home/secret"), "{rendered}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cli_verify_end_to_end_against_fake_core() {
|
||||
let (project, core) = fixture("verify_cli");
|
||||
let source = std::fs::read(project.path("index.mq.md")).unwrap();
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &sha256_hex(&source), 2));
|
||||
fn analysis_v2_revision_is_a_hard_protocol_error() {
|
||||
let (project, core) = fixture("analysis_v2");
|
||||
let source = project_source(&project);
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &source, 2));
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let check = expect_check_ok(
|
||||
client
|
||||
.check(&project, &entry, &CheckOptions::default())
|
||||
.unwrap(),
|
||||
);
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
&check.analysis_bytes,
|
||||
entry.as_str(),
|
||||
Some(&source),
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
assert_eq!(err.exit_code(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn retired_revision_3_shape_is_rejected_with_a_rebuild_hint() {
|
||||
let (project, core) = fixture("analysis_old_shape");
|
||||
let source = project_source(&project);
|
||||
let mut analysis: serde_json::Value =
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", &source, 3)).unwrap();
|
||||
// An old same-revision artifact has no source/document/anchors/entry id.
|
||||
let module = analysis["modules"][0].as_object_mut().unwrap();
|
||||
module.remove("source");
|
||||
module.remove("document");
|
||||
module.remove("anchors");
|
||||
analysis["project"]
|
||||
.as_object_mut()
|
||||
.unwrap()
|
||||
.remove("entry_module_id");
|
||||
core.set_analysis(&analysis.to_string());
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let check = expect_check_ok(
|
||||
client
|
||||
.check(&project, &entry, &CheckOptions::default())
|
||||
.unwrap(),
|
||||
);
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
&check.analysis_bytes,
|
||||
entry.as_str(),
|
||||
Some(&source),
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
assert!(err.to_string().contains("revision 3"), "{err}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn source_digest_mismatch_is_not_silently_accepted() {
|
||||
let (project, core) = fixture("analysis_digest_mismatch");
|
||||
let source = project_source(&project);
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", "# another document\n", 3));
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let check = expect_check_ok(
|
||||
client
|
||||
.check(&project, &entry, &CheckOptions::default())
|
||||
.unwrap(),
|
||||
);
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
&check.analysis_bytes,
|
||||
entry.as_str(),
|
||||
Some(&source),
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.source_mismatch");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tool_api_revision_environment_is_an_exact_expectation() {
|
||||
// Pure validation: no process-global environment mutation (which would race
|
||||
// with tests running in parallel).
|
||||
use marqdo_view::protocol::tool_v1;
|
||||
assert!(tool_v1::validate_api_revision_env(None).is_ok());
|
||||
assert!(tool_v1::validate_api_revision_env(Some("1")).is_ok());
|
||||
let err = tool_v1::validate_api_revision_env(Some("2")).unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
assert!(tool_v1::validate_api_revision_env(Some("nope")).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn installed_tool_api_revision_is_enforced_at_the_process_boundary() {
|
||||
let (project, core) = fixture("api_revision_cli");
|
||||
core.set_analysis(&minimal_analysis(
|
||||
"index.mq.md",
|
||||
&project_source(&project),
|
||||
3,
|
||||
));
|
||||
let script = core.script.to_str().unwrap().to_string();
|
||||
let dir = project.dir.to_str().unwrap().to_string();
|
||||
let output = common::run_view(
|
||||
&["verify", "index.mq.md", "--marqdo-bin", &script],
|
||||
std::path::Path::new(&dir),
|
||||
&[
|
||||
("MARQDO_BIN", None),
|
||||
("MARQDO_TOOL_PROTOCOL", None),
|
||||
("MARQDO_PROTOCOL_ANALYSIS", None),
|
||||
("MARQDO_PROTOCOL_TRACE", None),
|
||||
],
|
||||
&[("MARQDO_BIN", None), ("MARQDO_API_REVISION", Some("2"))],
|
||||
);
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
assert_eq!(output.status.code(), Some(2), "stderr: {stderr}");
|
||||
assert!(
|
||||
stderr.contains("view.protocol_incompatible"),
|
||||
"stderr: {stderr}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cli_verify_end_to_end_against_fake_core() {
|
||||
let (project, core) = fixture("verify_cli");
|
||||
let source = project_source(&project);
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &source, 3));
|
||||
let script = core.script.to_str().unwrap().to_string();
|
||||
let dir = project.dir.to_str().unwrap().to_string();
|
||||
let output = common::run_view(
|
||||
&["verify", "index.mq.md", "--marqdo-bin", &script],
|
||||
std::path::Path::new(&dir),
|
||||
&[("MARQDO_BIN", None), ("MARQDO_API_REVISION", None)],
|
||||
);
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
assert_eq!(output.status.code(), Some(0), "stderr: {stderr}");
|
||||
assert!(stdout.contains("result: PASS"), "{stdout}");
|
||||
assert!(stdout.contains("marqdo 3.0.0-beta.1"), "{stdout}");
|
||||
assert!(stdout.contains("marqdo 3.0.0-rc.4"), "{stdout}");
|
||||
assert!(!stdout.contains(&dir), "absolute path leaked: {stdout}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cli_verify_rejects_schema_v4_and_digest_mismatch() {
|
||||
fn cli_verify_rejects_schema_v2_and_digest_mismatch() {
|
||||
let (project, core) = fixture("verify_negative");
|
||||
let source = std::fs::read(project.path("index.mq.md")).unwrap();
|
||||
let source = project_source(&project);
|
||||
let script = core.script.to_str().unwrap().to_string();
|
||||
let dir = project.dir.to_str().unwrap().to_string();
|
||||
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &sha256_hex(&source), 4));
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &source, 2));
|
||||
let output = common::run_view(
|
||||
&["verify", "index.mq.md", "--marqdo-bin", &script],
|
||||
std::path::Path::new(&dir),
|
||||
@@ -264,12 +374,187 @@ fn cli_verify_rejects_schema_v4_and_digest_mismatch() {
|
||||
assert_eq!(output.status.code(), Some(2));
|
||||
assert!(String::from_utf8_lossy(&output.stderr).contains("view.protocol_incompatible"));
|
||||
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &"0".repeat(64), 2));
|
||||
// A different, internally consistent document: the exact artifact does not
|
||||
// bind to the checked source. This is a source-mismatch, not a silent retry.
|
||||
core.set_analysis(&minimal_analysis(
|
||||
"index.mq.md",
|
||||
"# a different but internally consistent document\n",
|
||||
3,
|
||||
));
|
||||
let output = common::run_view(
|
||||
&["verify", "index.mq.md", "--marqdo-bin", &script],
|
||||
std::path::Path::new(&dir),
|
||||
&[("MARQDO_BIN", None)],
|
||||
);
|
||||
assert_eq!(output.status.code(), Some(1));
|
||||
assert!(String::from_utf8_lossy(&output.stderr).contains("view.source_mismatch"));
|
||||
assert_eq!(
|
||||
output.status.code(),
|
||||
Some(1),
|
||||
"stderr: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
assert!(
|
||||
String::from_utf8_lossy(&output.stderr).contains("view.source_mismatch"),
|
||||
"stderr: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
|
||||
// A forged source_digest is an internal artifact inconsistency.
|
||||
let mut analysis: serde_json::Value =
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", &source, 3)).unwrap();
|
||||
analysis["modules"][0]["source_digest"] = serde_json::json!("0".repeat(64));
|
||||
core.set_analysis(&analysis.to_string());
|
||||
let output = common::run_view(
|
||||
&["verify", "index.mq.md", "--marqdo-bin", &script],
|
||||
std::path::Path::new(&dir),
|
||||
&[("MARQDO_BIN", None)],
|
||||
);
|
||||
assert_eq!(
|
||||
output.status.code(),
|
||||
Some(1),
|
||||
"stderr: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
assert!(
|
||||
String::from_utf8_lossy(&output.stderr).contains("view.analysis_failed"),
|
||||
"stderr: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
}
|
||||
|
||||
fn expect_check_ok(response: CheckResponse) -> marqdo_view::core_client::CheckOutput {
|
||||
assert!(response.success, "check failed: {:?}", response.diagnostics);
|
||||
response.analysis.expect("analysis on success")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_analysis_schema_name_or_major_is_rejected() {
|
||||
// N02: an artifact with the wrong schema identity or an unknown major is a
|
||||
// protocol error; there is no guess or fallback decoder.
|
||||
let source = "# @knowledge fixture\n";
|
||||
let mut analysis: serde_json::Value =
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", source, 3)).unwrap();
|
||||
analysis["schema"] = serde_json::json!("marqdo.analysis.legacy");
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
analysis.to_string().as_bytes(),
|
||||
"index.mq.md",
|
||||
None,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
|
||||
let mut analysis: serde_json::Value =
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", source, 3)).unwrap();
|
||||
analysis["schema_version"] = serde_json::json!(5);
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
analysis.to_string().as_bytes(),
|
||||
"index.mq.md",
|
||||
None,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_required_analysis_fields_are_rejected() {
|
||||
// N03: required fields are not optional; a missing module/document/unit field
|
||||
// must never decode as an empty, successful document.
|
||||
for field in ["modules", "diagnostics"] {
|
||||
let source = "# @knowledge fixture\n";
|
||||
let mut analysis: serde_json::Value =
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", source, 3)).unwrap();
|
||||
analysis.as_object_mut().unwrap().remove(field);
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
analysis.to_string().as_bytes(),
|
||||
"index.mq.md",
|
||||
None,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible", "field {field}");
|
||||
}
|
||||
let source = "# @knowledge fixture\n";
|
||||
let mut analysis: serde_json::Value =
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", source, 3)).unwrap();
|
||||
analysis["modules"][0]
|
||||
.as_object_mut()
|
||||
.unwrap()
|
||||
.remove("functions");
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
analysis.to_string().as_bytes(),
|
||||
"index.mq.md",
|
||||
None,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_module_and_unit_references_are_rejected() {
|
||||
// N08: resolved references, imports, functions and anchors must point at
|
||||
// records that exist in the same artifact.
|
||||
let source = "# @knowledge fixture\n";
|
||||
let base = minimal_analysis("index.mq.md", source, 3);
|
||||
let module_id = serde_json::from_str::<serde_json::Value>(&base).unwrap()["modules"][0]["id"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.to_string();
|
||||
|
||||
let mut analysis: serde_json::Value = serde_json::from_str(&base).unwrap();
|
||||
analysis["modules"][0]["references"] = serde_json::json!([{
|
||||
"source": module_id,
|
||||
"source_unit": format!("{module_id}#missing"),
|
||||
"url": "./theory.mq.md",
|
||||
"span": {"start": 0, "end": 1},
|
||||
"state": "resolved",
|
||||
"target_kind": "module",
|
||||
"target_module": module_id,
|
||||
"target_unit": null,
|
||||
"candidate_package_instance_id": "root:fixture@0.1.0",
|
||||
"candidate_path": "theory.mq.md",
|
||||
"fragment": null,
|
||||
"candidates": []
|
||||
}]);
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
analysis.to_string().as_bytes(),
|
||||
"index.mq.md",
|
||||
None,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.analysis_failed");
|
||||
|
||||
let mut analysis: serde_json::Value = serde_json::from_str(&base).unwrap();
|
||||
analysis["modules"][0]["imports"] = serde_json::json!([{
|
||||
"alias": "theory",
|
||||
"target": "./theory.mq.md",
|
||||
"resolved": "root:fixture@0.1.0::theory.mq.md",
|
||||
"span": {"start": 0, "end": 1}
|
||||
}]);
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
analysis.to_string().as_bytes(),
|
||||
"index.mq.md",
|
||||
None,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.analysis_failed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn strict_mode_run_request_is_rejected_by_view_validation() {
|
||||
// N13: View never passes a `strict` mode to the CLI. The request schema
|
||||
// rejects it before any process starts (no retry with project).
|
||||
let body = serde_json::json!({
|
||||
"document": "index.mq.md",
|
||||
"target": {"kind": "entry"},
|
||||
"analysis_digest": format!("sha256:{}", "0".repeat(64)),
|
||||
"mode": "strict",
|
||||
"grants": {"read": [], "write": []},
|
||||
"client_request_id": "strict-1"
|
||||
})
|
||||
.to_string();
|
||||
let err = marqdo_view::execution::request::validate_request(body.as_bytes()).unwrap_err();
|
||||
assert!(
|
||||
matches!(err.code(), "view.run_invalid" | "view.run_denied"),
|
||||
"strict mode must be refused before spawn, got {}",
|
||||
err.code()
|
||||
);
|
||||
assert_eq!(err.exit_code(), 2);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Contract suite: the frozen CLI black-box process contract, Analysis v2 /
|
||||
//! Trace v2 validation, the View CLI surface, and architecture/asset gates.
|
||||
//! Contract suite: the frozen CLI black-box process contract, Analysis v3 /
|
||||
//! Observation v1 validation, the View CLI surface, and architecture/asset gates.
|
||||
|
||||
#[path = "../common/mod.rs"]
|
||||
mod common;
|
||||
@@ -8,5 +8,5 @@ mod asset_integrity;
|
||||
mod cli_surface;
|
||||
mod core_contract;
|
||||
mod no_coupling;
|
||||
mod observation_contract;
|
||||
mod presentation_states;
|
||||
mod trace_contract;
|
||||
@@ -181,9 +181,66 @@ fn tool_manifest_matches_package_and_protocols() {
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
"tool.json version must match Cargo package version"
|
||||
);
|
||||
assert_eq!(tool["compatibility"]["marqdo"], ">=3.0.0-beta.1,<4.0.0");
|
||||
assert_eq!(tool["compatibility"]["analysis"], serde_json::json!([2, 3]));
|
||||
assert_eq!(tool["compatibility"]["trace"], serde_json::json!([2]));
|
||||
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]
|
||||
|
||||
@@ -0,0 +1,446 @@
|
||||
//! Observation v1 contract: one JSONL event sequence decoded by one decoder,
|
||||
//! schema/lifecycle/sequence/source-binding validation, the atomic snapshot
|
||||
//! equivalence, and negative fail-closed cases.
|
||||
|
||||
use crate::common::golden_bytes;
|
||||
use marqdo_view::protocol::analysis_v3::{verify_analysis, SemanticProjection};
|
||||
use marqdo_view::protocol::observation_v1::{
|
||||
decode_snapshot, ObservationDecoder, ObservedKind, RunDisplayState,
|
||||
};
|
||||
|
||||
const ANALYSIS: &str = "tests/golden/analysis-v3/control-flow.json";
|
||||
const JSONL: &str = "tests/golden/observation-v1/control-flow.jsonl";
|
||||
const SNAPSHOT: &str = "tests/golden/observation-v1/control-flow.snapshot.json";
|
||||
const TRUNCATED_JSONL: &str = "tests/golden/observation-v1/control-flow.truncated.jsonl";
|
||||
const TRUNCATED_SNAPSHOT: &str = "tests/golden/observation-v1/control-flow.truncated.snapshot.json";
|
||||
|
||||
fn projection() -> SemanticProjection {
|
||||
verify_analysis(&golden_bytes(ANALYSIS), "index.mq.md", None)
|
||||
.expect("golden Analysis v3 verifies")
|
||||
.projection
|
||||
}
|
||||
|
||||
fn decode(jsonl: &str) -> Result<marqdo_view::protocol::observation_v1::RunProjection, String> {
|
||||
let projection = projection();
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
let frames = decoder.push(&golden_bytes(jsonl));
|
||||
if let Some(detail) = decoder.invalid() {
|
||||
return Err(detail.to_string());
|
||||
}
|
||||
assert!(!frames.is_empty(), "decoder published no browser frames");
|
||||
decoder
|
||||
.finish(0, "", false)
|
||||
.map_err(|err| format!("{}: {err}", err.code()))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn real_jsonl_stream_verifies_and_binds_to_analysis_digest() {
|
||||
let run = decode(JSONL).expect("real Observation v1 stream verifies");
|
||||
assert_eq!(run.state, RunDisplayState::Succeeded);
|
||||
assert_eq!(run.run_status, "ok");
|
||||
assert_eq!(run.exit_code, 0);
|
||||
assert!(run.source_verified);
|
||||
assert_eq!(run.analysis_digest, projection().analysis_digest);
|
||||
assert!(run.truncated.is_none());
|
||||
assert_eq!(
|
||||
run.events.first().map(|event| event.kind.clone()),
|
||||
Some(ObservedKind::StreamOpened)
|
||||
);
|
||||
assert_eq!(
|
||||
run.events.get(1).map(|event| event.kind.clone()),
|
||||
Some(ObservedKind::RunStarted)
|
||||
);
|
||||
// Terminal is unique and last.
|
||||
let terminals = run
|
||||
.events
|
||||
.iter()
|
||||
.filter(|event| {
|
||||
matches!(
|
||||
event.kind,
|
||||
ObservedKind::RunCompleted | ObservedKind::RunFailed | ObservedKind::RunRejected
|
||||
)
|
||||
})
|
||||
.count();
|
||||
assert_eq!(terminals, 1);
|
||||
assert_eq!(
|
||||
run.events.last().map(|event| event.kind.clone()),
|
||||
Some(ObservedKind::RunCompleted)
|
||||
);
|
||||
assert!(run.counts.effect > 0);
|
||||
assert!(run.counts.branch_eval > 0);
|
||||
assert!(run.counts.loop_iteration > 0);
|
||||
assert!(!run.stdout.is_empty(), "stdout chunks are decoded");
|
||||
assert_eq!(
|
||||
run.result_value.as_ref().map(|value| value.ty.as_str()),
|
||||
Some("Int")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stream_and_snapshot_of_the_same_run_agree() {
|
||||
let projection = projection();
|
||||
let from_stream = decode(JSONL).expect("stream decodes");
|
||||
let from_snapshot =
|
||||
decode_snapshot(&golden_bytes(SNAPSHOT), &projection).expect("snapshot decodes");
|
||||
assert_eq!(from_stream.run_id, from_snapshot.run_id);
|
||||
assert_eq!(from_stream.state, from_snapshot.state);
|
||||
assert_eq!(from_stream.events.len(), from_snapshot.events.len());
|
||||
for (stream, snapshot) in from_stream.events.iter().zip(from_snapshot.events.iter()) {
|
||||
assert_eq!(stream.seq, snapshot.seq);
|
||||
assert_eq!(stream.kind, snapshot.kind);
|
||||
assert_eq!(stream.span, snapshot.span);
|
||||
assert_eq!(stream.anchor_span, snapshot.anchor_span);
|
||||
assert_eq!(stream.detail, snapshot.detail);
|
||||
assert_eq!(stream.operation, snapshot.operation);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn truncated_observation_is_a_terminal_but_never_complete() {
|
||||
let run = decode(TRUNCATED_JSONL).expect("truncated stream decodes");
|
||||
assert_eq!(run.state, RunDisplayState::Truncated);
|
||||
let truncated = run.truncated.clone().expect("observation.truncated");
|
||||
assert_eq!(truncated.reason, "event_budget");
|
||||
assert_eq!(truncated.limit, 5);
|
||||
let terminals = run
|
||||
.events
|
||||
.iter()
|
||||
.filter(|event| {
|
||||
matches!(
|
||||
event.kind,
|
||||
ObservedKind::RunCompleted | ObservedKind::RunFailed | ObservedKind::RunRejected
|
||||
)
|
||||
})
|
||||
.count();
|
||||
assert_eq!(terminals, 1);
|
||||
assert!(!run.is_success() || run.state == RunDisplayState::Truncated);
|
||||
|
||||
let projection = projection();
|
||||
let snapshot = decode_snapshot(&golden_bytes(TRUNCATED_SNAPSHOT), &projection)
|
||||
.expect("truncated snapshot decodes");
|
||||
assert_eq!(snapshot.state, RunDisplayState::Truncated);
|
||||
assert_eq!(
|
||||
snapshot
|
||||
.truncated
|
||||
.as_ref()
|
||||
.map(|value| value.reason.as_str()),
|
||||
Some("event_budget")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lifecycle_negative_cases_fail_closed() {
|
||||
let projection = projection();
|
||||
let module = projection.module_id.clone();
|
||||
let digest = projection.analysis_digest.clone();
|
||||
let root = projection.project_root_id.clone();
|
||||
|
||||
let cases: Vec<(&str, Vec<serde_json::Value>)> = vec![
|
||||
("missing stream.opened", vec![started(0, &digest, &root)]),
|
||||
(
|
||||
"terminal without start",
|
||||
vec![opened(0, &module), completed(1, &module)],
|
||||
),
|
||||
(
|
||||
"unknown kind",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
started(1, &digest, &root),
|
||||
event(2, "future.event", serde_json::json!({})),
|
||||
],
|
||||
),
|
||||
(
|
||||
"sequence gap",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
started(1, &digest, &root),
|
||||
effect(3, &module),
|
||||
],
|
||||
),
|
||||
(
|
||||
"duplicate sequence",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
started(1, &digest, &root),
|
||||
effect(2, &module),
|
||||
effect(2, &module),
|
||||
],
|
||||
),
|
||||
(
|
||||
"mixed run id",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
event(
|
||||
1,
|
||||
"run.started",
|
||||
serde_json::json!({
|
||||
"entry": format!("{module}::main"),
|
||||
"mode": "pure",
|
||||
"source": {"root_id": root, "analysis_digest": digest}
|
||||
}),
|
||||
),
|
||||
event_with_run(2, "other-run", "effect", effect_payload(&module)),
|
||||
],
|
||||
),
|
||||
(
|
||||
"continued after terminal",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
started(1, &digest, &root),
|
||||
completed(2, &module),
|
||||
effect(3, &module),
|
||||
],
|
||||
),
|
||||
(
|
||||
"two terminals",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
started(1, &digest, &root),
|
||||
completed(2, &module),
|
||||
completed(3, &module),
|
||||
],
|
||||
),
|
||||
(
|
||||
"span outside source",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
started(1, &digest, &root),
|
||||
event(
|
||||
2,
|
||||
"effect",
|
||||
serde_json::json!({
|
||||
"frame_id": "f1", "operation": "fs.exists",
|
||||
"result_code": "ok", "module_id": module,
|
||||
"span": {"start": 0, "end": 999_999}
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
(
|
||||
"value without consent",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
started(1, &digest, &root),
|
||||
event(
|
||||
2,
|
||||
"variable.assigned",
|
||||
serde_json::json!({
|
||||
"frame_id": "f1", "module_id": module, "name": "x",
|
||||
"value_state": "observed", "value_type": "Int",
|
||||
"span": {"start": 0, "end": 1},
|
||||
"value": {"type": "int", "decimal": "1"}
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
for (name, events) in cases {
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
let bytes = encode(&events);
|
||||
decoder.push(&bytes);
|
||||
if let Some(detail) = decoder.invalid() {
|
||||
// Push-time rejection is the expected fail-closed path.
|
||||
assert!(!detail.is_empty(), "{name}");
|
||||
continue;
|
||||
}
|
||||
let result = decoder.finish(0, "", false);
|
||||
assert!(result.is_err(), "{name} was accepted as {result:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_schema_and_revision_are_rejected() {
|
||||
let projection = projection();
|
||||
let module = projection.module_id.clone();
|
||||
let mut event = opened(0, &module);
|
||||
event["schema"] = serde_json::json!("marqdo.execution-events");
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
decoder.push(&encode(&[event]));
|
||||
assert!(decoder.invalid().is_some(), "old schema must be rejected");
|
||||
|
||||
let mut event = opened(0, &module);
|
||||
event["schema_version"] = serde_json::json!(2);
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
decoder.push(&encode(&[event]));
|
||||
assert!(
|
||||
decoder.invalid().is_some(),
|
||||
"unknown revision must be rejected"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stale_and_wrong_root_bindings_are_observation_stale() {
|
||||
let projection = projection();
|
||||
let module = projection.module_id.clone();
|
||||
let wrong_digest = format!("sha256:{}", "0".repeat(64));
|
||||
let events = vec![
|
||||
opened(0, &module),
|
||||
started(1, &wrong_digest, &projection.project_root_id),
|
||||
completed(2, &module),
|
||||
];
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
decoder.push(&encode(&events));
|
||||
let err = decoder.finish(0, "", false).unwrap_err();
|
||||
assert_eq!(err.code(), "view.observation_stale");
|
||||
assert!(!err.detail().is_empty());
|
||||
|
||||
let events = vec![
|
||||
opened(0, &module),
|
||||
started(1, &projection.analysis_digest, "root:other@0.1.0"),
|
||||
completed(2, &module),
|
||||
];
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
decoder.push(&encode(&events));
|
||||
let err = decoder.finish(0, "", false).unwrap_err();
|
||||
assert_eq!(err.code(), "view.observation_stale");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejected_before_start_is_a_valid_failed_terminal() {
|
||||
let projection = projection();
|
||||
let module = projection.module_id.clone();
|
||||
let events = vec![opened(0, &module), rejected(1, &module)];
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
decoder.push(&encode(&events));
|
||||
let run = decoder
|
||||
.finish(1, "error[sem.unclosed_control]: refusing to run", false)
|
||||
.expect("compile rejection is a valid terminal");
|
||||
assert_eq!(run.state, RunDisplayState::Failed);
|
||||
assert_eq!(run.run_status, "rejected");
|
||||
assert_eq!(run.error_code.as_deref(), Some("sem.unclosed_control"));
|
||||
assert!(!run.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eof_without_terminal_is_incomplete_never_success() {
|
||||
let projection = projection();
|
||||
let module = projection.module_id.clone();
|
||||
let events = vec![
|
||||
opened(0, &module),
|
||||
started(1, &projection.analysis_digest, &projection.project_root_id),
|
||||
effect(2, &module),
|
||||
];
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
decoder.push(&encode(&events));
|
||||
let run = decoder.finish(0, "", false).expect("no terminal decodes");
|
||||
assert_eq!(run.state, RunDisplayState::Incomplete);
|
||||
assert_eq!(
|
||||
run.error_code.as_deref(),
|
||||
Some("view.observation_incomplete")
|
||||
);
|
||||
assert!(!run.is_success());
|
||||
assert!(!run.output_complete);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Synthetic Observation v1 builders (only for negative-path tests).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
fn encode(events: &[serde_json::Value]) -> Vec<u8> {
|
||||
let mut bytes = Vec::new();
|
||||
for event in events {
|
||||
bytes.extend_from_slice(event.to_string().as_bytes());
|
||||
bytes.push(b'\n');
|
||||
}
|
||||
bytes
|
||||
}
|
||||
|
||||
fn envelope(seq: u64, kind: &str, payload: serde_json::Value) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"schema": "marqdo.observation",
|
||||
"schema_version": 1,
|
||||
"run_id": "test-run-1",
|
||||
"seq": seq,
|
||||
"kind": kind,
|
||||
"payload": payload
|
||||
})
|
||||
}
|
||||
|
||||
fn event(seq: u64, kind: &str, payload: serde_json::Value) -> serde_json::Value {
|
||||
envelope(seq, kind, payload)
|
||||
}
|
||||
|
||||
fn event_with_run(
|
||||
seq: u64,
|
||||
run: &str,
|
||||
kind: &str,
|
||||
payload: serde_json::Value,
|
||||
) -> serde_json::Value {
|
||||
let mut value = envelope(seq, kind, payload);
|
||||
value["run_id"] = serde_json::json!(run);
|
||||
value
|
||||
}
|
||||
|
||||
fn opened(seq: u64, _module: &str) -> serde_json::Value {
|
||||
envelope(
|
||||
seq,
|
||||
"stream.opened",
|
||||
serde_json::json!({
|
||||
"producer": {"name": "marqdo", "version": "3.0.0-rc.4"},
|
||||
"observation": {
|
||||
"level": "structural",
|
||||
"values": false,
|
||||
"selected_variables": [],
|
||||
"selected_parameters": [],
|
||||
"allow_text_values": false
|
||||
},
|
||||
"limits": {
|
||||
"max_observation_events": 10000,
|
||||
"max_observation_bytes": 4194304,
|
||||
"max_value_bytes": 256
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
fn started(seq: u64, digest: &str, root: &str) -> serde_json::Value {
|
||||
let projection = projection();
|
||||
envelope(
|
||||
seq,
|
||||
"run.started",
|
||||
serde_json::json!({
|
||||
"entry": format!("{}::main", projection.module_id),
|
||||
"mode": "pure",
|
||||
"source": {"root_id": root, "analysis_digest": digest},
|
||||
"started_unix_ms": 1
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
fn effect(seq: u64, module: &str) -> serde_json::Value {
|
||||
event(seq, "effect", effect_payload(module))
|
||||
}
|
||||
|
||||
fn effect_payload(module: &str) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"frame_id": "f1",
|
||||
"operation": "fs.exists",
|
||||
"result_code": "ok",
|
||||
"module_id": module,
|
||||
"span": {"start": 0, "end": 1}
|
||||
})
|
||||
}
|
||||
|
||||
fn completed(seq: u64, _module: &str) -> serde_json::Value {
|
||||
envelope(
|
||||
seq,
|
||||
"run.completed",
|
||||
serde_json::json!({
|
||||
"status": "ok",
|
||||
"value": {"type": "int", "decimal": "3"},
|
||||
"value_type": "Int"
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
fn rejected(seq: u64, _module: &str) -> serde_json::Value {
|
||||
envelope(
|
||||
seq,
|
||||
"run.rejected",
|
||||
serde_json::json!({
|
||||
"status": "rejected",
|
||||
"phase": "compile",
|
||||
"error": {"code": "sem.unclosed_control", "message": "`if` is not closed"}
|
||||
}),
|
||||
)
|
||||
}
|
||||
@@ -1,11 +1,18 @@
|
||||
//! Degradation/state matrix contract (RFC-VIEW-0001 S-05..S-07, §12.3):
|
||||
//! prose stays readable while semantics become explicitly unusable.
|
||||
//! Degradation/state matrix contract: prose stays readable while semantics
|
||||
//! become explicitly unusable; run states never claim success from an incomplete or
|
||||
//! truncated observation.
|
||||
|
||||
use crate::common;
|
||||
use crate::common::{golden_bytes, minimal_analysis, FakeCore, TempProject};
|
||||
use marqdo_view::protocol::analysis_v3::{verify_analysis, SemanticProjection};
|
||||
use marqdo_view::protocol::observation_v1::{ObservationDecoder, RunDisplayState, RunProjection};
|
||||
use marqdo_view::reader::assemble::{build, BuildInput, DocumentService};
|
||||
use marqdo_view::reader::markdown::{DocumentIdentity, DocumentModel};
|
||||
use marqdo_view::reader::model::{Navigation, SourceStatus};
|
||||
use marqdo_view::reader::source::Project;
|
||||
|
||||
use common::{minimal_analysis, sha256_hex, FakeCore, TempProject};
|
||||
use marqdo_view::reader::assemble::DocumentService;
|
||||
use marqdo_view::reader::model::SourceStatus;
|
||||
const ANALYSIS: &str = "tests/golden/analysis-v3/control-flow.json";
|
||||
const JSONL: &str = "tests/golden/observation-v1/control-flow.jsonl";
|
||||
const TRUNCATED_JSONL: &str = "tests/golden/observation-v1/control-flow.truncated.jsonl";
|
||||
|
||||
fn project(name: &str) -> (TempProject, FakeCore) {
|
||||
let project = TempProject::new(name);
|
||||
@@ -14,12 +21,53 @@ fn project(name: &str) -> (TempProject, FakeCore) {
|
||||
(project, core)
|
||||
}
|
||||
|
||||
fn projection() -> SemanticProjection {
|
||||
verify_analysis(&golden_bytes(ANALYSIS), "index.mq.md", None)
|
||||
.expect("control-flow golden verifies")
|
||||
.projection
|
||||
}
|
||||
|
||||
fn decode(jsonl: &str) -> RunProjection {
|
||||
let projection = projection();
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
decoder.push(&golden_bytes(jsonl));
|
||||
assert!(decoder.invalid().is_none(), "{:?}", decoder.invalid());
|
||||
decoder
|
||||
.finish(0, "", false)
|
||||
.expect("real observation stream verifies")
|
||||
}
|
||||
|
||||
fn empty_model(
|
||||
document: DocumentModel,
|
||||
run: Option<&RunProjection>,
|
||||
) -> marqdo_view::reader::model::PresentationModel {
|
||||
build(BuildInput {
|
||||
document,
|
||||
analysis: None,
|
||||
status: SourceStatus::CoreUnavailable,
|
||||
status_note: Some("test".into()),
|
||||
diagnostics: Vec::new(),
|
||||
navigation: Navigation {
|
||||
site_title: "test".into(),
|
||||
documents: Vec::new(),
|
||||
active: None,
|
||||
welcome: false,
|
||||
},
|
||||
core_version: None,
|
||||
run,
|
||||
})
|
||||
}
|
||||
|
||||
fn document_for(relative: &str, source: &str) -> DocumentModel {
|
||||
let path = marqdo_view::reader::source::SafeRelativePath::parse(relative).unwrap();
|
||||
DocumentModel::parse(source.to_string(), DocumentIdentity::placeholder(&path))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failed_check_keeps_prose_and_shows_core_diagnostics() {
|
||||
let (project, core) = project("state-check-fail");
|
||||
let source = std::fs::read(project.path("index.mq.md")).unwrap();
|
||||
// Emit a broken analysis too; it must NOT be used after a failed check.
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &sha256_hex(&source), 2));
|
||||
let source = std::fs::read_to_string(project.path("index.mq.md")).unwrap();
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &source, 3));
|
||||
core.set_check(1, "");
|
||||
core.set_check_json(
|
||||
r#"{"command":"check","success":false,"errors":1,"diagnostics":[{"code":"sem.unclosed_control","column":1,"file":"/home/secret/index.mq.md","line":3,"message":"`if` is not closed by `end`","module":"root:fixture@0.1.0::index.mq.md","severity":"error"}]}"#,
|
||||
@@ -38,14 +86,13 @@ fn failed_check_keeps_prose_and_shows_core_diagnostics() {
|
||||
.iter()
|
||||
.any(|diagnostic| diagnostic.code == "sem.unclosed_control"));
|
||||
assert!(!model.source_status.semantics_usable());
|
||||
// Pending run state is explicit, never a success claim.
|
||||
assert_eq!(model.run_state().data_value(), "not-run");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn source_digest_mismatch_degrades_instead_of_misbinding() {
|
||||
let (project, core) = project("state-source-mismatch");
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &"0".repeat(64), 2));
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", "# 完全不同的源码\n", 3));
|
||||
let context = DocumentService::open(&project.dir, Some(&core.script)).unwrap();
|
||||
let relative = context.project().entry().relative.clone();
|
||||
let model = context.load(&relative).unwrap();
|
||||
@@ -57,8 +104,8 @@ fn source_digest_mismatch_degrades_instead_of_misbinding() {
|
||||
#[test]
|
||||
fn unknown_analysis_schema_is_a_hard_protocol_error() {
|
||||
let (project, core) = project("state-protocol");
|
||||
let source = std::fs::read(project.path("index.mq.md")).unwrap();
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &sha256_hex(&source), 4));
|
||||
let source = std::fs::read_to_string(project.path("index.mq.md")).unwrap();
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &source, 4));
|
||||
let context = DocumentService::open(&project.dir, Some(&core.script)).unwrap();
|
||||
let relative = context.project().entry().relative.clone();
|
||||
let err = context.load(&relative).unwrap_err();
|
||||
@@ -67,79 +114,69 @@ fn unknown_analysis_schema_is_a_hard_protocol_error() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_core_span_is_dropped_with_an_explicit_warning() {
|
||||
fn invalid_analysis_span_is_rejected_not_trimmed() {
|
||||
// N09: an out-of-range/negative span in a protocol artifact is a hard
|
||||
// failure; View must never clip it and claim success.
|
||||
let (project, core) = project("state-span-invalid");
|
||||
let source = std::fs::read(project.path("index.mq.md")).unwrap();
|
||||
let source = std::fs::read_to_string(project.path("index.mq.md")).unwrap();
|
||||
let mut analysis: serde_json::Value =
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", &sha256_hex(&source), 2)).unwrap();
|
||||
// A span in the middle of a multi-byte character / beyond EOF.
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", &source, 3)).unwrap();
|
||||
let module_id = analysis["modules"][0]["id"].as_str().unwrap().to_string();
|
||||
analysis["modules"][0]["units"] = serde_json::json!([{
|
||||
"id": "x", "name": "坏", "level": 1, "kind": "namespace", "function": null,
|
||||
"span": {"start": 0, "end": 999_999}
|
||||
"id": format!("{module_id}#坏"),
|
||||
"path": ["坏"],
|
||||
"parent_id": module_id,
|
||||
"kind": "namespace",
|
||||
"name": "坏",
|
||||
"level": 1,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": format!("{module_id}#坏"),
|
||||
"heading_span": {"start": 0, "end": 1},
|
||||
"span": {"start": 0, "end": 999_999},
|
||||
"function": null
|
||||
}]);
|
||||
core.set_analysis(&serde_json::to_string(&analysis).unwrap());
|
||||
let bytes = analysis.to_string().into_bytes();
|
||||
let err = verify_analysis(&bytes, "index.mq.md", Some(&source)).unwrap_err();
|
||||
assert_eq!(err.code(), "view.analysis_failed");
|
||||
|
||||
// Through the reader the prose stays readable, but no annotation may be
|
||||
// attached from the rejected artifact.
|
||||
core.set_analysis(&analysis.to_string());
|
||||
let context = DocumentService::open(&project.dir, Some(&core.script)).unwrap();
|
||||
let relative = context.project().entry().relative.clone();
|
||||
let model = context.load(&relative).unwrap();
|
||||
assert_eq!(model.source_status, SourceStatus::StaticOk);
|
||||
assert!(model.semantic.as_ref().unwrap().units.is_empty());
|
||||
assert!(model
|
||||
.warnings
|
||||
.iter()
|
||||
.any(|warning| warning.code == "view.source_span_invalid"));
|
||||
let _ = source;
|
||||
assert!(model.semantic.is_none());
|
||||
assert_eq!(model.source_status, SourceStatus::CoreError);
|
||||
assert!(model.document.plain_text().contains("正文"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_attached_to_changed_source_becomes_stale() {
|
||||
let repo_root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
let project = TempProject::new("state-stale-run");
|
||||
project.write(
|
||||
"marqdo.yaml",
|
||||
"project:\n name: control-flow\n version: 0.1.0\n",
|
||||
);
|
||||
let source =
|
||||
std::fs::read_to_string(repo_root.join("examples/control-flow/index.mq.md")).unwrap();
|
||||
let source = golden_bytes("tests/golden/analysis-v3/control-flow.json");
|
||||
let source = serde_json::from_slice::<serde_json::Value>(&source).unwrap()["modules"][0]
|
||||
["source"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.to_string();
|
||||
project.write("index.mq.md", &source);
|
||||
let core = FakeCore::new("state-stale-run-core");
|
||||
let analysis =
|
||||
std::fs::read(repo_root.join("tests/golden/analysis-v2/control-flow.json")).unwrap();
|
||||
let analysis = golden_bytes(ANALYSIS);
|
||||
core.set_analysis(std::str::from_utf8(&analysis).unwrap());
|
||||
let context = DocumentService::open(&project.dir, Some(&core.script)).unwrap();
|
||||
let relative = context.project().entry().relative.clone();
|
||||
|
||||
// Build a verified run directly from the golden trace + golden analysis.
|
||||
let source_index = marqdo_view::reader::source::SourceIndex::new(&source);
|
||||
let verified_analysis = marqdo_view::protocol::analysis_v2::verify_analysis(
|
||||
&analysis,
|
||||
&source,
|
||||
&source_index,
|
||||
"index.mq.md",
|
||||
)
|
||||
.unwrap();
|
||||
let trace =
|
||||
std::fs::read(repo_root.join("tests/golden/trace-v2/control-flow.trace.json")).unwrap();
|
||||
let run_json: serde_json::Value = serde_json::from_slice(
|
||||
&std::fs::read(repo_root.join("tests/golden/trace-v2/control-flow.run.json")).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
let run = marqdo_view::protocol::trace_v2::verify_trace(
|
||||
marqdo_view::protocol::trace_v2::TraceVerificationInput {
|
||||
trace_bytes: &trace,
|
||||
analysis_bytes: &analysis,
|
||||
semantic: &verified_analysis.projection,
|
||||
modules: &verified_analysis.projection.modules,
|
||||
source: &source,
|
||||
source_index: &source_index,
|
||||
run_json: &run_json,
|
||||
exit_code: 0,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
let run = decode(JSONL);
|
||||
let attached = context.load_with_run(&relative, Some(&run)).unwrap();
|
||||
assert_eq!(attached.run_state().data_value(), "succeeded");
|
||||
|
||||
// Change the source and rebuild through the same server path.
|
||||
// The document changed after the run; the same projection must never be
|
||||
// re-anchored to the new source.
|
||||
std::fs::write(
|
||||
project.path("index.mq.md"),
|
||||
format!("{source}\n<!-- changed -->\n"),
|
||||
@@ -156,5 +193,72 @@ fn run_attached_to_changed_source_becomes_stale() {
|
||||
if let Some(run) = &changed.run {
|
||||
assert!(run.events.iter().all(|event| event.anchor_span.is_none()));
|
||||
}
|
||||
let _ = core;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn truncated_and_incomplete_runs_never_display_as_success() {
|
||||
let run = decode(TRUNCATED_JSONL);
|
||||
assert_eq!(run.state, RunDisplayState::Truncated);
|
||||
assert!(run.truncated.is_some());
|
||||
let model = empty_model(document_for("index.mq.md", "# @knowledge x\n"), Some(&run));
|
||||
assert_eq!(model.run_state().data_value(), "truncated");
|
||||
assert!(model.run_state().is_terminal());
|
||||
assert_ne!(model.run_state().data_value(), "succeeded");
|
||||
assert_eq!(model.run_state().label(), "观察已截断");
|
||||
|
||||
// A stream that ends before its terminal event is incomplete, not success.
|
||||
let projection = projection();
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
let mut lines = Vec::new();
|
||||
for line in golden_bytes(JSONL).split(|byte| *byte == b'\n') {
|
||||
if line.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let value: serde_json::Value = serde_json::from_slice(line).unwrap();
|
||||
if value["kind"] == "run.completed" {
|
||||
break;
|
||||
}
|
||||
lines.extend_from_slice(line);
|
||||
lines.push(b'\n');
|
||||
}
|
||||
decoder.push(&lines);
|
||||
let incomplete = decoder.finish(0, "", false).unwrap();
|
||||
assert_eq!(incomplete.state, RunDisplayState::Incomplete);
|
||||
assert!(!incomplete.is_success());
|
||||
let model = empty_model(
|
||||
document_for("index.mq.md", "# @knowledge x\n"),
|
||||
Some(&incomplete),
|
||||
);
|
||||
assert_eq!(model.run_state().data_value(), "incomplete");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_core_stays_readable_and_explicitly_unverified() {
|
||||
let project = TempProject::new("state-no-core");
|
||||
project.marqdo_project("# @knowledge fixture\n");
|
||||
let context = DocumentService::open(
|
||||
&project.dir,
|
||||
Some(std::path::Path::new("/definitely/missing/marqdo-frozen")),
|
||||
)
|
||||
.unwrap();
|
||||
let relative = context.project().entry().relative.clone();
|
||||
let model = context.load(&relative).unwrap();
|
||||
assert_eq!(model.source_status, SourceStatus::CoreUnavailable);
|
||||
assert!(model.semantic.is_none());
|
||||
assert!(model.status_note.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn external_projection_can_be_rendered_from_artifact_source() {
|
||||
// The artifact source is the only source used to interpret spans, even when
|
||||
// no checkout file exists for a dependency module.
|
||||
let verified = verify_analysis(&golden_bytes(ANALYSIS), "index.mq.md", None).unwrap();
|
||||
assert_eq!(
|
||||
verified.projection.source,
|
||||
verified.projection.entry_module().unwrap().source
|
||||
);
|
||||
let _ = Project::open(
|
||||
&std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("examples/control-flow"),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
@@ -1,270 +0,0 @@
|
||||
//! Trace v2 contract tests against goldens emitted by the frozen CLI. The
|
||||
//! goldens bind to the committed Analysis v2 bytes by digest, so a changed
|
||||
//! source cannot silently reuse an old trace.
|
||||
|
||||
use marqdo_view::protocol::analysis_v2 as semantic;
|
||||
use marqdo_view::protocol::trace_v2::{verify_trace, RunDisplayState, TraceVerificationInput};
|
||||
use marqdo_view::reader::source::{sha256_prefixed, SourceIndex};
|
||||
use serde_json::Value;
|
||||
|
||||
struct Fixture {
|
||||
source: String,
|
||||
index: SourceIndex,
|
||||
analysis: Vec<u8>,
|
||||
semantic: semantic::VerifiedAnalysis,
|
||||
}
|
||||
|
||||
fn fixture(analysis_golden: &str, source_path: &str) -> Fixture {
|
||||
let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
let source = std::fs::read_to_string(root.join(source_path)).unwrap();
|
||||
let index = SourceIndex::new(&source);
|
||||
let analysis = std::fs::read(root.join(analysis_golden)).unwrap();
|
||||
let semantic = semantic::verify_analysis(&analysis, &source, &index, "index.mq.md").unwrap();
|
||||
Fixture {
|
||||
source,
|
||||
index,
|
||||
analysis,
|
||||
semantic,
|
||||
}
|
||||
}
|
||||
|
||||
fn golden_json(path: &str) -> Value {
|
||||
let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
serde_json::from_slice(&std::fs::read(root.join(path)).unwrap()).unwrap()
|
||||
}
|
||||
|
||||
fn golden_bytes(path: &str) -> Vec<u8> {
|
||||
let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
std::fs::read(root.join(path)).unwrap()
|
||||
}
|
||||
|
||||
fn verify(
|
||||
fixture: &Fixture,
|
||||
trace_golden: &str,
|
||||
run_golden: &str,
|
||||
exit_code: i32,
|
||||
) -> marqdo_view::protocol::trace_v2::VerifiedRun {
|
||||
let trace = golden_bytes(trace_golden);
|
||||
let run_json = golden_json(run_golden);
|
||||
verify_trace(TraceVerificationInput {
|
||||
trace_bytes: &trace,
|
||||
analysis_bytes: &fixture.analysis,
|
||||
semantic: &fixture.semantic.projection,
|
||||
modules: &fixture.semantic.projection.modules,
|
||||
source: &fixture.source,
|
||||
source_index: &fixture.index,
|
||||
run_json: &run_json,
|
||||
exit_code,
|
||||
})
|
||||
.expect("trace verifies")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn real_control_flow_trace_binds_and_projects_events() {
|
||||
let fixture = fixture(
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
"examples/control-flow/index.mq.md",
|
||||
);
|
||||
let run = verify(
|
||||
&fixture,
|
||||
"tests/golden/trace-v2/control-flow.trace.json",
|
||||
"tests/golden/trace-v2/control-flow.run.json",
|
||||
0,
|
||||
);
|
||||
let projection = &run.projection;
|
||||
assert_eq!(projection.state, RunDisplayState::Succeeded);
|
||||
assert_eq!(projection.counts.total(), 27);
|
||||
assert_eq!(projection.entry_event_count, 27);
|
||||
assert_eq!(projection.other_event_count, 0);
|
||||
assert_eq!(projection.run_status, "ok");
|
||||
assert!(projection.truncated.is_none());
|
||||
assert_eq!(projection.stdout, "0\n0\n2\n");
|
||||
let value = projection.result_value.as_ref().expect("return value");
|
||||
assert_eq!(value.ty, "int");
|
||||
assert_eq!(value.display, "3");
|
||||
// Public JSON final value only; never a per-assignment value claim.
|
||||
assert!(projection.analysis_digest.starts_with("sha256:"));
|
||||
|
||||
// The loop header is evaluated four times (three iterations + exit).
|
||||
let loop_span = projection
|
||||
.events
|
||||
.iter()
|
||||
.find(|event| event.anchor_span.is_some() && event.detail.as_deref() == Some("exit"))
|
||||
.and_then(|event| event.anchor_span)
|
||||
.expect("loop anchor");
|
||||
let summary = projection.anchor_summary(loop_span).expect("loop summary");
|
||||
assert_eq!(summary.count, 4);
|
||||
assert_eq!(summary.detail, "loop exit");
|
||||
assert!(summary.kinds.contains(&"loop.iteration".to_string()));
|
||||
|
||||
let return_anchors: Vec<_> = projection
|
||||
.events
|
||||
.iter()
|
||||
.filter(|event| event.anchor_span.is_some())
|
||||
.collect();
|
||||
assert!(!return_anchors.is_empty());
|
||||
// Only entry-module events ever get statement anchors.
|
||||
for event in &projection.events {
|
||||
if event.anchor_span.is_some() {
|
||||
assert_eq!(
|
||||
event.module_id.as_deref(),
|
||||
Some(fixture.semantic.projection.module_id.as_str())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn truncated_trace_is_explicitly_marked() {
|
||||
let fixture = fixture(
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
"examples/control-flow/index.mq.md",
|
||||
);
|
||||
let run = verify(
|
||||
&fixture,
|
||||
"tests/golden/trace-v2/control-flow.truncated.trace.json",
|
||||
"tests/golden/trace-v2/control-flow.truncated.run.json",
|
||||
0,
|
||||
);
|
||||
let projection = &run.projection;
|
||||
assert_eq!(projection.state, RunDisplayState::Truncated);
|
||||
let truncated = projection.truncated.as_ref().expect("truncation");
|
||||
assert_eq!(truncated.reason, "event_budget");
|
||||
assert_eq!(truncated.limit, 5);
|
||||
assert_eq!(truncated.written, 5);
|
||||
assert!(truncated.label().contains("事件数量上限"));
|
||||
assert_ne!(projection.state, RunDisplayState::Succeeded);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failed_run_keeps_the_core_error_code() {
|
||||
let fixture = fixture(
|
||||
"tests/golden/analysis-v2/mixed-modes.json",
|
||||
"examples/mixed-modes/index.mq.md",
|
||||
);
|
||||
let run = verify(
|
||||
&fixture,
|
||||
"tests/golden/trace-v2/mixed-modes.arity.trace.json",
|
||||
"tests/golden/trace-v2/mixed-modes.arity.run.json",
|
||||
1,
|
||||
);
|
||||
let projection = &run.projection;
|
||||
assert_eq!(projection.state, RunDisplayState::Failed);
|
||||
assert_eq!(projection.error_code.as_deref(), Some("call.arity"));
|
||||
assert_eq!(projection.run_status, "call.arity");
|
||||
assert!(projection.result_value.is_none());
|
||||
assert_eq!(projection.state.label(), "运行失败");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stale_analysis_bytes_are_rejected() {
|
||||
let fixture = fixture(
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
"examples/control-flow/index.mq.md",
|
||||
);
|
||||
let mut tampered = fixture.analysis.clone();
|
||||
tampered.push(b' ');
|
||||
let trace = golden_bytes("tests/golden/trace-v2/control-flow.trace.json");
|
||||
let run_json = golden_json("tests/golden/trace-v2/control-flow.run.json");
|
||||
let err = verify_trace(TraceVerificationInput {
|
||||
trace_bytes: &trace,
|
||||
analysis_bytes: &tampered,
|
||||
semantic: &fixture.semantic.projection,
|
||||
modules: &fixture.semantic.projection.modules,
|
||||
source: &fixture.source,
|
||||
source_index: &fixture.index,
|
||||
run_json: &run_json,
|
||||
exit_code: 0,
|
||||
})
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.trace_stale");
|
||||
assert_eq!(err.exit_code(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_event_module_is_rejected() {
|
||||
let fixture = fixture(
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
"examples/control-flow/index.mq.md",
|
||||
);
|
||||
let mut trace: Value = golden_json("tests/golden/trace-v2/control-flow.trace.json");
|
||||
trace["events"][0]["module_id"] = Value::String("rogue::module.mq.md".to_string());
|
||||
let trace_bytes = serde_json::to_vec(&trace).unwrap();
|
||||
let run_json = golden_json("tests/golden/trace-v2/control-flow.run.json");
|
||||
let err = verify_trace(TraceVerificationInput {
|
||||
trace_bytes: &trace_bytes,
|
||||
analysis_bytes: &fixture.analysis,
|
||||
semantic: &fixture.semantic.projection,
|
||||
modules: &fixture.semantic.projection.modules,
|
||||
source: &fixture.source,
|
||||
source_index: &fixture.index,
|
||||
run_json: &run_json,
|
||||
exit_code: 0,
|
||||
})
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.trace_stale");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn non_monotonic_sequence_is_rejected() {
|
||||
let fixture = fixture(
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
"examples/control-flow/index.mq.md",
|
||||
);
|
||||
let mut trace: Value = golden_json("tests/golden/trace-v2/control-flow.trace.json");
|
||||
trace["events"][1]["seq"] = Value::Number(0.into());
|
||||
let trace_bytes = serde_json::to_vec(&trace).unwrap();
|
||||
let run_json = golden_json("tests/golden/trace-v2/control-flow.run.json");
|
||||
let err = verify_trace(TraceVerificationInput {
|
||||
trace_bytes: &trace_bytes,
|
||||
analysis_bytes: &fixture.analysis,
|
||||
semantic: &fixture.semantic.projection,
|
||||
modules: &fixture.semantic.projection.modules,
|
||||
source: &fixture.source,
|
||||
source_index: &fixture.index,
|
||||
run_json: &run_json,
|
||||
exit_code: 0,
|
||||
})
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.trace_stale");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_schema_major_is_a_protocol_error_not_a_stale_trace() {
|
||||
let fixture = fixture(
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
"examples/control-flow/index.mq.md",
|
||||
);
|
||||
let mut trace: Value = golden_json("tests/golden/trace-v2/control-flow.trace.json");
|
||||
trace["schema_version"] = Value::Number(3.into());
|
||||
let trace_bytes = serde_json::to_vec(&trace).unwrap();
|
||||
let run_json = golden_json("tests/golden/trace-v2/control-flow.run.json");
|
||||
let err = verify_trace(TraceVerificationInput {
|
||||
trace_bytes: &trace_bytes,
|
||||
analysis_bytes: &fixture.analysis,
|
||||
semantic: &fixture.semantic.projection,
|
||||
modules: &fixture.semantic.projection.modules,
|
||||
source: &fixture.source,
|
||||
source_index: &fixture.index,
|
||||
run_json: &run_json,
|
||||
exit_code: 0,
|
||||
})
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
assert_eq!(err.exit_code(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn golden_digest_is_really_sha256_of_analysis_bytes() {
|
||||
let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
let analysis = std::fs::read(root.join("tests/golden/analysis-v2/control-flow.json")).unwrap();
|
||||
let trace: Value = golden_json("tests/golden/trace-v2/control-flow.trace.json");
|
||||
assert_eq!(
|
||||
trace["source"]["analysis_digest"].as_str().unwrap(),
|
||||
sha256_prefixed(&analysis)
|
||||
);
|
||||
assert_eq!(
|
||||
trace["source"]["root_id"].as_str().unwrap(),
|
||||
"root:control-flow@0.1.0"
|
||||
);
|
||||
}
|
||||
@@ -11,7 +11,7 @@ binary, not hand-written:
|
||||
Command shape used for every golden:
|
||||
|
||||
```bash
|
||||
"$MARQDO_BIN" check <example> --emit tests/golden/analysis-v2/<name>.json
|
||||
"$MARQDO_BIN" check <example> --emit tests/golden/analysis-v3/<name>.json
|
||||
```
|
||||
|
||||
| Golden | Input |
|
||||
|
||||
@@ -1,278 +0,0 @@
|
||||
{
|
||||
"diagnostics": [],
|
||||
"modules": [
|
||||
{
|
||||
"calls": [],
|
||||
"functions": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"arms": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "assign",
|
||||
"span": {
|
||||
"end": 422,
|
||||
"start": 406
|
||||
},
|
||||
"target": "result",
|
||||
"value": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 417,
|
||||
"start": 416
|
||||
}
|
||||
},
|
||||
"op": "mul",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "2"
|
||||
},
|
||||
"span": {
|
||||
"end": 421,
|
||||
"start": 416
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 439,
|
||||
"start": 424
|
||||
},
|
||||
"value": {
|
||||
"kind": "variable",
|
||||
"name": "result",
|
||||
"span": {
|
||||
"end": 438,
|
||||
"start": 432
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 398,
|
||||
"start": 397
|
||||
}
|
||||
},
|
||||
"op": "gt",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
},
|
||||
"span": {
|
||||
"end": 402,
|
||||
"start": 397
|
||||
}
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
},
|
||||
"span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
}
|
||||
},
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 461,
|
||||
"start": 451
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
},
|
||||
"span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "branch",
|
||||
"span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
}
|
||||
}
|
||||
],
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"heading_span": {
|
||||
"end": 259,
|
||||
"start": 246
|
||||
},
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md::演示.main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"signature": {
|
||||
"kind": "explicit",
|
||||
"params": [
|
||||
{
|
||||
"default": null,
|
||||
"name": "n",
|
||||
"required": true,
|
||||
"span": {
|
||||
"end": 274,
|
||||
"start": 268
|
||||
},
|
||||
"type": "Int"
|
||||
}
|
||||
]
|
||||
},
|
||||
"span": {
|
||||
"end": 470,
|
||||
"start": 246
|
||||
},
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main"
|
||||
}
|
||||
],
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md",
|
||||
"imports": [],
|
||||
"package_instance_id": "root:mixed-modes@0.1.0",
|
||||
"references": [],
|
||||
"relative_path": "index.mq.md",
|
||||
"resources": [],
|
||||
"source_digest": "c5fed57a716e06a29b669c334d475ec03bf08442e27983451ec8dd791dc999ea",
|
||||
"units": [
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#",
|
||||
"kind": "root",
|
||||
"level": 0,
|
||||
"name": "",
|
||||
"span": {
|
||||
"end": 470,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "计算笔记",
|
||||
"span": {
|
||||
"end": 25,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记/算法说明",
|
||||
"kind": "knowledge",
|
||||
"level": 2,
|
||||
"name": "算法说明",
|
||||
"span": {
|
||||
"end": 149,
|
||||
"start": 123
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "演示",
|
||||
"span": {
|
||||
"end": 244,
|
||||
"start": 230
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": "root:mixed-modes@0.1.0::index.mq.md::演示.main",
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示/main",
|
||||
"kind": "function",
|
||||
"level": 2,
|
||||
"name": "main",
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 246
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/用法",
|
||||
"kind": "section",
|
||||
"level": 3,
|
||||
"name": "用法",
|
||||
"span": {
|
||||
"end": 300,
|
||||
"start": 279
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": "root:mixed-modes@0.1.0::index.mq.md::演示.main",
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/计算",
|
||||
"kind": "section",
|
||||
"level": 3,
|
||||
"name": "计算",
|
||||
"span": {
|
||||
"end": 390,
|
||||
"start": 374
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"producer": {
|
||||
"markdown_profile": "marqdo.md.v1",
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-beta.1"
|
||||
},
|
||||
"project": {
|
||||
"identity_kind": "manifest",
|
||||
"lock_digest": "",
|
||||
"root_id": "root:mixed-modes@0.1.0",
|
||||
"stdlib": {
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"version": "0.1.0"
|
||||
}
|
||||
},
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 2
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
{
|
||||
"diagnostics": [],
|
||||
"modules": [
|
||||
{
|
||||
"calls": [],
|
||||
"functions": [],
|
||||
"id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"imports": [],
|
||||
"package_instance_id": "root:tables-math@0.1.0",
|
||||
"references": [
|
||||
{
|
||||
"source": "root:tables-math@0.1.0::index.mq.md",
|
||||
"span": {
|
||||
"end": 403,
|
||||
"start": 354
|
||||
},
|
||||
"state": "external",
|
||||
"target_module": null,
|
||||
"target_unit": null,
|
||||
"url": "https://github.com/cflmy/marqdo-cli"
|
||||
}
|
||||
],
|
||||
"relative_path": "index.mq.md",
|
||||
"resources": [
|
||||
{
|
||||
"content_digest": "2820951a377c18ce3e89093ca7c31c204b1196a7e571781c6080f8207524a8dc",
|
||||
"display": false,
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#resource:formula-1",
|
||||
"kind": "formula",
|
||||
"language": null,
|
||||
"module_id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"span": {
|
||||
"end": 164,
|
||||
"start": 154
|
||||
},
|
||||
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源"
|
||||
},
|
||||
{
|
||||
"content_digest": "8b1e8a7ed159e8223af79e768681907870ae7143f0b16001091377f9ff018db2",
|
||||
"display": true,
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#resource:formula-2",
|
||||
"kind": "formula",
|
||||
"language": null,
|
||||
"module_id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"span": {
|
||||
"end": 222,
|
||||
"start": 181
|
||||
},
|
||||
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源"
|
||||
},
|
||||
{
|
||||
"content_digest": "a0d49e456637468d7f594f4e2bb513321875855c1fe85d28e0ca62f1e9180d15",
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#resource:code-1",
|
||||
"kind": "code",
|
||||
"language": "python",
|
||||
"module_id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"span": {
|
||||
"end": 280,
|
||||
"start": 224
|
||||
},
|
||||
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源"
|
||||
}
|
||||
],
|
||||
"source_digest": "66ce180252d201ff0f3f831d47f7a58d7f6804cb9655898cc80ef6d2262f1ce6",
|
||||
"units": [
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#",
|
||||
"kind": "root",
|
||||
"level": 0,
|
||||
"name": "",
|
||||
"span": {
|
||||
"end": 406,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "表格、公式与惰性资源",
|
||||
"span": {
|
||||
"end": 43,
|
||||
"start": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"producer": {
|
||||
"markdown_profile": "marqdo.md.v1",
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-beta.1"
|
||||
},
|
||||
"project": {
|
||||
"identity_kind": "manifest",
|
||||
"lock_digest": "",
|
||||
"root_id": "root:tables-math@0.1.0",
|
||||
"stdlib": {
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"version": "0.1.0"
|
||||
}
|
||||
},
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 2
|
||||
}
|
||||
@@ -1,212 +0,0 @@
|
||||
{
|
||||
"diagnostics": [],
|
||||
"modules": [
|
||||
{
|
||||
"calls": [],
|
||||
"functions": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"arms": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 148,
|
||||
"start": 138
|
||||
},
|
||||
"value": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 147,
|
||||
"start": 146
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 128,
|
||||
"start": 127
|
||||
}
|
||||
},
|
||||
"op": "gt",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
},
|
||||
"span": {
|
||||
"end": 132,
|
||||
"start": 127
|
||||
}
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
},
|
||||
"span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
}
|
||||
},
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 174,
|
||||
"start": 164
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
},
|
||||
"span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "branch",
|
||||
"span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
}
|
||||
}
|
||||
],
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"heading_span": {
|
||||
"end": 98,
|
||||
"start": 85
|
||||
},
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md::演示.main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"signature": {
|
||||
"kind": "explicit",
|
||||
"params": [
|
||||
{
|
||||
"default": null,
|
||||
"name": "n",
|
||||
"required": true,
|
||||
"span": {
|
||||
"end": 115,
|
||||
"start": 109
|
||||
},
|
||||
"type": "Int"
|
||||
}
|
||||
]
|
||||
},
|
||||
"span": {
|
||||
"end": 185,
|
||||
"start": 85
|
||||
},
|
||||
"unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#演示/main"
|
||||
}
|
||||
],
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md",
|
||||
"imports": [],
|
||||
"package_instance_id": "root:unicode-spans@0.1.0",
|
||||
"references": [],
|
||||
"relative_path": "crlf.mq.md",
|
||||
"resources": [],
|
||||
"source_digest": "3d6c99d8e1666b14cc51e6774a4cf514a3a252f3b2f9f541c7cde4a090551b1f",
|
||||
"units": [
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#",
|
||||
"kind": "root",
|
||||
"level": 0,
|
||||
"name": "",
|
||||
"span": {
|
||||
"end": 185,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#CRLF 文档",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "CRLF 文档",
|
||||
"span": {
|
||||
"end": 24,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#演示",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "演示",
|
||||
"span": {
|
||||
"end": 81,
|
||||
"start": 67
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": "root:unicode-spans@0.1.0::crlf.mq.md::演示.main",
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#演示/main",
|
||||
"kind": "function",
|
||||
"level": 2,
|
||||
"name": "main",
|
||||
"span": {
|
||||
"end": 98,
|
||||
"start": 85
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"producer": {
|
||||
"markdown_profile": "marqdo.md.v1",
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-beta.1"
|
||||
},
|
||||
"project": {
|
||||
"identity_kind": "manifest",
|
||||
"lock_digest": "",
|
||||
"root_id": "root:unicode-spans@0.1.0",
|
||||
"stdlib": {
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"version": "0.1.0"
|
||||
}
|
||||
},
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 2
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
{
|
||||
"diagnostics": [],
|
||||
"modules": [
|
||||
{
|
||||
"calls": [],
|
||||
"functions": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"arms": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 271,
|
||||
"start": 261
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "1"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 253,
|
||||
"start": 252
|
||||
}
|
||||
},
|
||||
"op": "gt",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
},
|
||||
"span": {
|
||||
"end": 257,
|
||||
"start": 252
|
||||
}
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
},
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
}
|
||||
},
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 293,
|
||||
"start": 283
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "1"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
},
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "branch",
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
}
|
||||
}
|
||||
],
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"heading_span": {
|
||||
"end": 227,
|
||||
"start": 214
|
||||
},
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md::演示.main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"signature": {
|
||||
"kind": "explicit",
|
||||
"params": [
|
||||
{
|
||||
"default": null,
|
||||
"name": "n",
|
||||
"required": true,
|
||||
"span": {
|
||||
"end": 242,
|
||||
"start": 236
|
||||
},
|
||||
"type": "Int"
|
||||
}
|
||||
]
|
||||
},
|
||||
"span": {
|
||||
"end": 302,
|
||||
"start": 214
|
||||
},
|
||||
"unit_id": "root:unicode-spans@0.1.0::index.mq.md#演示/main"
|
||||
}
|
||||
],
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md",
|
||||
"imports": [],
|
||||
"package_instance_id": "root:unicode-spans@0.1.0",
|
||||
"references": [],
|
||||
"relative_path": "index.mq.md",
|
||||
"resources": [],
|
||||
"source_digest": "b4f8dd12f18a984af129974bc4dd153e97df99cc262bcafb2ae1187b6c5ce7d0",
|
||||
"units": [
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#",
|
||||
"kind": "root",
|
||||
"level": 0,
|
||||
"name": "",
|
||||
"span": {
|
||||
"end": 302,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#中文 🙂 标题",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "中文 🙂 标题",
|
||||
"span": {
|
||||
"end": 31,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#演示",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "演示",
|
||||
"span": {
|
||||
"end": 212,
|
||||
"start": 198
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": "root:unicode-spans@0.1.0::index.mq.md::演示.main",
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#演示/main",
|
||||
"kind": "function",
|
||||
"level": 2,
|
||||
"name": "main",
|
||||
"span": {
|
||||
"end": 227,
|
||||
"start": 214
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"producer": {
|
||||
"markdown_profile": "marqdo.md.v1",
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-beta.1"
|
||||
},
|
||||
"project": {
|
||||
"identity_kind": "manifest",
|
||||
"lock_digest": "",
|
||||
"root_id": "root:unicode-spans@0.1.0",
|
||||
"stdlib": {
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"version": "0.1.0"
|
||||
}
|
||||
},
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 2
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
{
|
||||
"diagnostics": [],
|
||||
"modules": [
|
||||
{
|
||||
"calls": [],
|
||||
"functions": [],
|
||||
"id": "root:welcome-demo@0.1.0::00-welcome.mq.md",
|
||||
"imports": [],
|
||||
"package_instance_id": "root:welcome-demo@0.1.0",
|
||||
"references": [
|
||||
{
|
||||
"source": "root:welcome-demo@0.1.0::00-welcome.mq.md",
|
||||
"span": {
|
||||
"end": 536,
|
||||
"start": 507
|
||||
},
|
||||
"state": "resolved",
|
||||
"target_module": "root:welcome-demo@0.1.0::guide.mq.md",
|
||||
"target_unit": null,
|
||||
"url": "./guide.mq.md"
|
||||
}
|
||||
],
|
||||
"relative_path": "00-welcome.mq.md",
|
||||
"resources": [],
|
||||
"source_digest": "879215bf0dc432b78924800a08eac37d353a9694652c5542294f4ce7fe6da173",
|
||||
"units": [
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:welcome-demo@0.1.0::00-welcome.mq.md#",
|
||||
"kind": "root",
|
||||
"level": 0,
|
||||
"name": "",
|
||||
"span": {
|
||||
"end": 659,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:welcome-demo@0.1.0::00-welcome.mq.md#欢迎来到 Marqdo",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "欢迎来到 Marqdo",
|
||||
"span": {
|
||||
"end": 32,
|
||||
"start": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"producer": {
|
||||
"markdown_profile": "marqdo.md.v1",
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-beta.1"
|
||||
},
|
||||
"project": {
|
||||
"identity_kind": "manifest",
|
||||
"lock_digest": "",
|
||||
"root_id": "root:welcome-demo@0.1.0",
|
||||
"stdlib": {
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"version": "0.1.0"
|
||||
}
|
||||
},
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 2
|
||||
}
|
||||
+645
-132
@@ -1,79 +1,591 @@
|
||||
{
|
||||
"diagnostics": [],
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 3,
|
||||
"producer": {
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-rc.4",
|
||||
"markdown_profile": "marqdo.md.v1"
|
||||
},
|
||||
"project": {
|
||||
"root_id": "root:control-flow@0.1.0",
|
||||
"identity_kind": "manifest",
|
||||
"entry_module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"lock_digest": "",
|
||||
"manifest_digest": "sha256:a317c418b2b86e74c23f5effcea3e7e4bff0d6dac4043beca78598bc8c90768d",
|
||||
"stdlib": {
|
||||
"version": "0.1.0",
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713"
|
||||
},
|
||||
"extensions": []
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"calls": [
|
||||
"id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"package_instance_id": "root:control-flow@0.1.0",
|
||||
"relative_path": "index.mq.md",
|
||||
"source_digest": "127922e228bbc7931aa8241ff69ee7df3cbc8bbaaaead143b67842a527818854",
|
||||
"source": "# @knowledge 控制流演示\n\n下面的函数可以在 `pure` 模式显式运行并产生真实 Trace。示例把 ASCII 数字和换行写入标准输出资源。\n\n# @exec 演示\n\n## @exec main\n\n`x = 0`\n\n`buffer = memory.new(1, 1)`\n\n`buffer[1] = 10`\n\n`stdout = resource.open(\"stdio\", \"stdout\", [\"write\"])`\n\n**while x < 3**\n\n**if x > 1**\n\n`buffer[0] = 48 + x`\n\n**else**\n\n`buffer[0] = 48`\n\n**end**\n\n`resource.write(stdout, buffer, 0, 2)`\n\n**x = x + 1**\n\n**end**\n\n`resource.close(stdout)`\n\n`return 3`\n",
|
||||
"document": {
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge 控制流演示",
|
||||
"span": {
|
||||
"end": 28,
|
||||
"start": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 28,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "下面的函数可以在 ",
|
||||
"span": {
|
||||
"end": 55,
|
||||
"start": 30
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "pure",
|
||||
"span": {
|
||||
"end": 61,
|
||||
"start": 55
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " 模式显式运行并产生真实 Trace。示例把 ASCII 数字和换行写入标准输出资源。",
|
||||
"span": {
|
||||
"end": 162,
|
||||
"start": 61
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 162,
|
||||
"start": 30
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec 演示",
|
||||
"span": {
|
||||
"end": 178,
|
||||
"start": 166
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 178,
|
||||
"start": 164
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec main",
|
||||
"span": {
|
||||
"end": 193,
|
||||
"start": 183
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 2,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 193,
|
||||
"start": 180
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "x = 0",
|
||||
"span": {
|
||||
"end": 202,
|
||||
"start": 195
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 202,
|
||||
"start": 195
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "buffer = memory.new(1, 1)",
|
||||
"span": {
|
||||
"end": 231,
|
||||
"start": 204
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 231,
|
||||
"start": 204
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "buffer[1] = 10",
|
||||
"span": {
|
||||
"end": 249,
|
||||
"start": 233
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 249,
|
||||
"start": 233
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "stdout = resource.open(\"stdio\", \"stdout\", [\"write\"])",
|
||||
"span": {
|
||||
"end": 305,
|
||||
"start": 251
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 305,
|
||||
"start": 251
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "while x < 3",
|
||||
"span": {
|
||||
"end": 320,
|
||||
"start": 309
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 322,
|
||||
"start": 307
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 322,
|
||||
"start": 307
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "if x > 1",
|
||||
"span": {
|
||||
"end": 334,
|
||||
"start": 326
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "buffer[0] = 48 + x",
|
||||
"span": {
|
||||
"end": 358,
|
||||
"start": 338
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 358,
|
||||
"start": 338
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "else",
|
||||
"span": {
|
||||
"end": 366,
|
||||
"start": 362
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 368,
|
||||
"start": 360
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 368,
|
||||
"start": 360
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "buffer[0] = 48",
|
||||
"span": {
|
||||
"end": 386,
|
||||
"start": 370
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 386,
|
||||
"start": 370
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "end",
|
||||
"span": {
|
||||
"end": 393,
|
||||
"start": 390
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 395,
|
||||
"start": 388
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 395,
|
||||
"start": 388
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "resource.write(stdout, buffer, 0, 2)",
|
||||
"span": {
|
||||
"end": 435,
|
||||
"start": 397
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 435,
|
||||
"start": 397
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "x = x + 1",
|
||||
"span": {
|
||||
"end": 448,
|
||||
"start": 439
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 450,
|
||||
"start": 437
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 450,
|
||||
"start": 437
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "end",
|
||||
"span": {
|
||||
"end": 457,
|
||||
"start": 454
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 459,
|
||||
"start": 452
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 459,
|
||||
"start": 452
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "resource.close(stdout)",
|
||||
"span": {
|
||||
"end": 485,
|
||||
"start": 461
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 485,
|
||||
"start": 461
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "return 3",
|
||||
"span": {
|
||||
"end": 497,
|
||||
"start": 487
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 497,
|
||||
"start": 487
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "document",
|
||||
"span": {
|
||||
"end": 498,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
"units": [
|
||||
{
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "memory"
|
||||
},
|
||||
"field": "new",
|
||||
"kind": "member"
|
||||
},
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#",
|
||||
"path": [],
|
||||
"parent_id": null,
|
||||
"kind": "root",
|
||||
"name": "",
|
||||
"level": 0,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "default",
|
||||
"mode_source_unit_id": "root:control-flow@0.1.0::index.mq.md#",
|
||||
"heading_span": null,
|
||||
"span": {
|
||||
"end": 230,
|
||||
"start": 214
|
||||
"start": 0,
|
||||
"end": 498
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "memory.new"
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "resource"
|
||||
},
|
||||
"field": "open",
|
||||
"kind": "member"
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#控制流演示",
|
||||
"path": [
|
||||
"控制流演示"
|
||||
],
|
||||
"parent_id": "root:control-flow@0.1.0::index.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "控制流演示",
|
||||
"level": 1,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:control-flow@0.1.0::index.mq.md#控制流演示",
|
||||
"heading_span": {
|
||||
"start": 0,
|
||||
"end": 28
|
||||
},
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"span": {
|
||||
"end": 304,
|
||||
"start": 261
|
||||
"start": 0,
|
||||
"end": 164
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "resource.open"
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "resource"
|
||||
},
|
||||
"field": "write",
|
||||
"kind": "member"
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#演示",
|
||||
"path": [
|
||||
"演示"
|
||||
],
|
||||
"parent_id": "root:control-flow@0.1.0::index.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "演示",
|
||||
"level": 1,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:control-flow@0.1.0::index.mq.md#演示",
|
||||
"heading_span": {
|
||||
"start": 164,
|
||||
"end": 178
|
||||
},
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
"start": 164,
|
||||
"end": 498
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "resource.write"
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "resource"
|
||||
},
|
||||
"field": "close",
|
||||
"kind": "member"
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#演示/main",
|
||||
"path": [
|
||||
"演示",
|
||||
"main"
|
||||
],
|
||||
"parent_id": "root:control-flow@0.1.0::index.mq.md#演示",
|
||||
"kind": "function",
|
||||
"name": "main",
|
||||
"level": 2,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:control-flow@0.1.0::index.mq.md#演示/main",
|
||||
"heading_span": {
|
||||
"start": 180,
|
||||
"end": 193
|
||||
},
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"span": {
|
||||
"end": 484,
|
||||
"start": 462
|
||||
"start": 180,
|
||||
"end": 498
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "resource.close"
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main"
|
||||
}
|
||||
],
|
||||
"anchors": [
|
||||
{
|
||||
"anchor": "main",
|
||||
"unit_id": "root:control-flow@0.1.0::index.mq.md#演示/main"
|
||||
},
|
||||
{
|
||||
"anchor": "控制流演示",
|
||||
"unit_id": "root:control-flow@0.1.0::index.mq.md#控制流演示"
|
||||
},
|
||||
{
|
||||
"anchor": "演示",
|
||||
"unit_id": "root:control-flow@0.1.0::index.mq.md#演示"
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"unit_id": "root:control-flow@0.1.0::index.mq.md#演示/main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"span": {
|
||||
"start": 180,
|
||||
"end": 497
|
||||
},
|
||||
"heading_span": {
|
||||
"start": 180,
|
||||
"end": 193
|
||||
},
|
||||
"signature": {
|
||||
"kind": "inferred",
|
||||
"params": []
|
||||
},
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"kind": "assign",
|
||||
@@ -437,12 +949,12 @@
|
||||
"value": true
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
"end": 368,
|
||||
"start": 360
|
||||
},
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
"end": 368,
|
||||
"start": 360
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -678,94 +1190,95 @@
|
||||
"value": "3"
|
||||
}
|
||||
}
|
||||
],
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"heading_span": {
|
||||
"end": 193,
|
||||
"start": 180
|
||||
},
|
||||
"id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"signature": {
|
||||
"kind": "inferred",
|
||||
"params": []
|
||||
},
|
||||
"span": {
|
||||
"end": 497,
|
||||
"start": 180
|
||||
},
|
||||
"unit_id": "root:control-flow@0.1.0::index.mq.md#演示/main"
|
||||
]
|
||||
}
|
||||
],
|
||||
"id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"imports": [],
|
||||
"package_instance_id": "root:control-flow@0.1.0",
|
||||
"references": [],
|
||||
"relative_path": "index.mq.md",
|
||||
"resources": [],
|
||||
"source_digest": "127922e228bbc7931aa8241ff69ee7df3cbc8bbaaaead143b67842a527818854",
|
||||
"units": [
|
||||
"calls": [
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#",
|
||||
"kind": "root",
|
||||
"level": 0,
|
||||
"name": "",
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"span": {
|
||||
"end": 497,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#控制流演示",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "控制流演示",
|
||||
"span": {
|
||||
"end": 28,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#演示",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "演示",
|
||||
"span": {
|
||||
"end": 178,
|
||||
"start": 164
|
||||
}
|
||||
"start": 214,
|
||||
"end": 230
|
||||
},
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "memory"
|
||||
},
|
||||
"field": "new",
|
||||
"kind": "member"
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "memory.new",
|
||||
"target_kind": "builtin",
|
||||
"target_owner": null,
|
||||
"reason": null
|
||||
},
|
||||
{
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#演示/main",
|
||||
"kind": "function",
|
||||
"level": 2,
|
||||
"name": "main",
|
||||
"span": {
|
||||
"end": 193,
|
||||
"start": 180
|
||||
}
|
||||
"start": 261,
|
||||
"end": 304
|
||||
},
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "resource"
|
||||
},
|
||||
"field": "open",
|
||||
"kind": "member"
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "resource.open",
|
||||
"target_kind": "builtin",
|
||||
"target_owner": null,
|
||||
"reason": null
|
||||
},
|
||||
{
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"span": {
|
||||
"start": 398,
|
||||
"end": 434
|
||||
},
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "resource"
|
||||
},
|
||||
"field": "write",
|
||||
"kind": "member"
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "resource.write",
|
||||
"target_kind": "builtin",
|
||||
"target_owner": null,
|
||||
"reason": null
|
||||
},
|
||||
{
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"span": {
|
||||
"start": 462,
|
||||
"end": 484
|
||||
},
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "resource"
|
||||
},
|
||||
"field": "close",
|
||||
"kind": "member"
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "resource.close",
|
||||
"target_kind": "builtin",
|
||||
"target_owner": null,
|
||||
"reason": null
|
||||
}
|
||||
]
|
||||
],
|
||||
"resources": []
|
||||
}
|
||||
],
|
||||
"producer": {
|
||||
"markdown_profile": "marqdo.md.v1",
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-beta.1"
|
||||
},
|
||||
"project": {
|
||||
"identity_kind": "manifest",
|
||||
"lock_digest": "",
|
||||
"root_id": "root:control-flow@0.1.0",
|
||||
"stdlib": null
|
||||
},
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 2
|
||||
"diagnostics": []
|
||||
}
|
||||
@@ -0,0 +1,790 @@
|
||||
{
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 3,
|
||||
"producer": {
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-rc.4",
|
||||
"markdown_profile": "marqdo.md.v1"
|
||||
},
|
||||
"project": {
|
||||
"root_id": "root:mixed-modes@0.1.0",
|
||||
"identity_kind": "manifest",
|
||||
"entry_module_id": "root:mixed-modes@0.1.0::index.mq.md",
|
||||
"lock_digest": "",
|
||||
"manifest_digest": "sha256:b252a5e0d5519cfb5efe1ca7ebfe0660cc1919279fc4283cdebfb70028f5a984",
|
||||
"stdlib": {
|
||||
"version": "0.1.0",
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713"
|
||||
},
|
||||
"extensions": []
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md",
|
||||
"package_instance_id": "root:mixed-modes@0.1.0",
|
||||
"relative_path": "index.mq.md",
|
||||
"source_digest": "c5fed57a716e06a29b669c334d475ec03bf08442e27983451ec8dd791dc999ea",
|
||||
"source": "# @knowledge 计算笔记\n\n这是一份关于简单运算的知识说明。**此处加粗是知识内容,不执行。**\n\n## @knowledge 算法说明\n\n下面描述算法的含义和适用范围;此处的 `n` 是惰性正文。\n\n# @exec 演示\n\n## @exec main\n\n`params(n: Int)`\n\n### @knowledge 用法\n\n调用方提供整数 `n`。这一小节不应该执行任何语句。\n\n### @exec 计算\n\n**if n > 0**\n\n`result = n * 2`\n\n*return result*\n\n**else**\n\n`return 0`\n\n**end**\n",
|
||||
"document": {
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge 计算笔记",
|
||||
"span": {
|
||||
"end": 25,
|
||||
"start": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 25,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "这是一份关于简单运算的知识说明。",
|
||||
"span": {
|
||||
"end": 75,
|
||||
"start": 27
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "此处加粗是知识内容,不执行。",
|
||||
"span": {
|
||||
"end": 119,
|
||||
"start": 77
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 121,
|
||||
"start": 75
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 121,
|
||||
"start": 27
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge 算法说明",
|
||||
"span": {
|
||||
"end": 149,
|
||||
"start": 126
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 2,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 149,
|
||||
"start": 123
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "下面描述算法的含义和适用范围;此处的 ",
|
||||
"span": {
|
||||
"end": 206,
|
||||
"start": 151
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "n",
|
||||
"span": {
|
||||
"end": 209,
|
||||
"start": 206
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " 是惰性正文。",
|
||||
"span": {
|
||||
"end": 228,
|
||||
"start": 209
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 228,
|
||||
"start": 151
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec 演示",
|
||||
"span": {
|
||||
"end": 244,
|
||||
"start": 232
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 244,
|
||||
"start": 230
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec main",
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 249
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 2,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 246
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "params(n: Int)",
|
||||
"span": {
|
||||
"end": 277,
|
||||
"start": 261
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 277,
|
||||
"start": 261
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge 用法",
|
||||
"span": {
|
||||
"end": 300,
|
||||
"start": 283
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 3,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 300,
|
||||
"start": 279
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "调用方提供整数 ",
|
||||
"span": {
|
||||
"end": 324,
|
||||
"start": 302
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "n",
|
||||
"span": {
|
||||
"end": 327,
|
||||
"start": 324
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "。这一小节不应该执行任何语句。",
|
||||
"span": {
|
||||
"end": 372,
|
||||
"start": 327
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 372,
|
||||
"start": 302
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec 计算",
|
||||
"span": {
|
||||
"end": 390,
|
||||
"start": 378
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 3,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 390,
|
||||
"start": 374
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "if n > 0",
|
||||
"span": {
|
||||
"end": 402,
|
||||
"start": 394
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "result = n * 2",
|
||||
"span": {
|
||||
"end": 422,
|
||||
"start": 406
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 422,
|
||||
"start": 406
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "return result",
|
||||
"span": {
|
||||
"end": 438,
|
||||
"start": 425
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "emph",
|
||||
"span": {
|
||||
"end": 439,
|
||||
"start": 424
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 439,
|
||||
"start": 424
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "else",
|
||||
"span": {
|
||||
"end": 447,
|
||||
"start": 443
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 449,
|
||||
"start": 441
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 449,
|
||||
"start": 441
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "return 0",
|
||||
"span": {
|
||||
"end": 461,
|
||||
"start": 451
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 461,
|
||||
"start": 451
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "end",
|
||||
"span": {
|
||||
"end": 468,
|
||||
"start": 465
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 470,
|
||||
"start": 463
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 470,
|
||||
"start": 463
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "document",
|
||||
"span": {
|
||||
"end": 471,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
"units": [
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#",
|
||||
"path": [],
|
||||
"parent_id": null,
|
||||
"kind": "root",
|
||||
"name": "",
|
||||
"level": 0,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "default",
|
||||
"mode_source_unit_id": "root:mixed-modes@0.1.0::index.mq.md#",
|
||||
"heading_span": null,
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 471
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记",
|
||||
"path": [
|
||||
"计算笔记"
|
||||
],
|
||||
"parent_id": "root:mixed-modes@0.1.0::index.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "计算笔记",
|
||||
"level": 1,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记",
|
||||
"heading_span": {
|
||||
"start": 0,
|
||||
"end": 25
|
||||
},
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 230
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记/算法说明",
|
||||
"path": [
|
||||
"计算笔记",
|
||||
"算法说明"
|
||||
],
|
||||
"parent_id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记",
|
||||
"kind": "knowledge",
|
||||
"name": "算法说明",
|
||||
"level": 2,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记/算法说明",
|
||||
"heading_span": {
|
||||
"start": 123,
|
||||
"end": 149
|
||||
},
|
||||
"span": {
|
||||
"start": 123,
|
||||
"end": 230
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示",
|
||||
"path": [
|
||||
"演示"
|
||||
],
|
||||
"parent_id": "root:mixed-modes@0.1.0::index.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "演示",
|
||||
"level": 1,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示",
|
||||
"heading_span": {
|
||||
"start": 230,
|
||||
"end": 244
|
||||
},
|
||||
"span": {
|
||||
"start": 230,
|
||||
"end": 471
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示/main",
|
||||
"path": [
|
||||
"演示",
|
||||
"main"
|
||||
],
|
||||
"parent_id": "root:mixed-modes@0.1.0::index.mq.md#演示",
|
||||
"kind": "function",
|
||||
"name": "main",
|
||||
"level": 2,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main",
|
||||
"heading_span": {
|
||||
"start": 246,
|
||||
"end": 259
|
||||
},
|
||||
"span": {
|
||||
"start": 246,
|
||||
"end": 471
|
||||
},
|
||||
"function": "root:mixed-modes@0.1.0::index.mq.md::演示.main"
|
||||
},
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/用法",
|
||||
"path": [
|
||||
"演示",
|
||||
"main",
|
||||
"用法"
|
||||
],
|
||||
"parent_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main",
|
||||
"kind": "section",
|
||||
"name": "用法",
|
||||
"level": 3,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/用法",
|
||||
"heading_span": {
|
||||
"start": 279,
|
||||
"end": 300
|
||||
},
|
||||
"span": {
|
||||
"start": 279,
|
||||
"end": 374
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/计算",
|
||||
"path": [
|
||||
"演示",
|
||||
"main",
|
||||
"计算"
|
||||
],
|
||||
"parent_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main",
|
||||
"kind": "section",
|
||||
"name": "计算",
|
||||
"level": 3,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/计算",
|
||||
"heading_span": {
|
||||
"start": 374,
|
||||
"end": 390
|
||||
},
|
||||
"span": {
|
||||
"start": 374,
|
||||
"end": 471
|
||||
},
|
||||
"function": "root:mixed-modes@0.1.0::index.mq.md::演示.main"
|
||||
}
|
||||
],
|
||||
"anchors": [
|
||||
{
|
||||
"anchor": "main",
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main"
|
||||
},
|
||||
{
|
||||
"anchor": "演示",
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示"
|
||||
},
|
||||
{
|
||||
"anchor": "用法",
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/用法"
|
||||
},
|
||||
{
|
||||
"anchor": "算法说明",
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记/算法说明"
|
||||
},
|
||||
{
|
||||
"anchor": "计算",
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/计算"
|
||||
},
|
||||
{
|
||||
"anchor": "计算笔记",
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记"
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md::演示.main",
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"span": {
|
||||
"start": 246,
|
||||
"end": 470
|
||||
},
|
||||
"heading_span": {
|
||||
"start": 246,
|
||||
"end": 259
|
||||
},
|
||||
"signature": {
|
||||
"kind": "explicit",
|
||||
"params": [
|
||||
{
|
||||
"name": "n",
|
||||
"required": true,
|
||||
"type": "Int",
|
||||
"default": null,
|
||||
"span": {
|
||||
"start": 268,
|
||||
"end": 274
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"arms": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "assign",
|
||||
"span": {
|
||||
"end": 422,
|
||||
"start": 406
|
||||
},
|
||||
"target": "result",
|
||||
"value": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 417,
|
||||
"start": 416
|
||||
}
|
||||
},
|
||||
"op": "mul",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "2"
|
||||
},
|
||||
"span": {
|
||||
"end": 421,
|
||||
"start": 416
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 439,
|
||||
"start": 424
|
||||
},
|
||||
"value": {
|
||||
"kind": "variable",
|
||||
"name": "result",
|
||||
"span": {
|
||||
"end": 438,
|
||||
"start": 432
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 398,
|
||||
"start": 397
|
||||
}
|
||||
},
|
||||
"op": "gt",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
},
|
||||
"span": {
|
||||
"end": 402,
|
||||
"start": 397
|
||||
}
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
},
|
||||
"span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
}
|
||||
},
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 461,
|
||||
"start": 451
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 449,
|
||||
"start": 441
|
||||
},
|
||||
"span": {
|
||||
"end": 449,
|
||||
"start": 441
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "branch",
|
||||
"span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"imports": [],
|
||||
"references": [],
|
||||
"calls": [],
|
||||
"resources": []
|
||||
}
|
||||
],
|
||||
"diagnostics": []
|
||||
}
|
||||
@@ -0,0 +1,549 @@
|
||||
{
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 3,
|
||||
"producer": {
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-rc.4",
|
||||
"markdown_profile": "marqdo.md.v1"
|
||||
},
|
||||
"project": {
|
||||
"root_id": "root:tables-math@0.1.0",
|
||||
"identity_kind": "manifest",
|
||||
"entry_module_id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"lock_digest": "",
|
||||
"manifest_digest": "sha256:5fd84c1306f43e9ed10a2db2b3fba6fdc67d960516bc94931ac594d21f034c05",
|
||||
"stdlib": {
|
||||
"version": "0.1.0",
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713"
|
||||
},
|
||||
"extensions": []
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"package_instance_id": "root:tables-math@0.1.0",
|
||||
"relative_path": "index.mq.md",
|
||||
"source_digest": "66ce180252d201ff0f3f831d47f7a58d7f6804cb9655898cc80ef6d2262f1ce6",
|
||||
"source": "# @knowledge 表格、公式与惰性资源\n\n| 名称 | 值 | 说明 |\n| --- | ---: | --- |\n| 甲 | 1 | 第一行 |\n| 乙 | 2 | 第二行 |\n\n行内公式 $E = mc^2$;块公式:\n\n$$\n\\sum_{i=1}^{n} i = \\frac{n(n+1)}{2}\n$$\n\n```python\nprint(\"代码围栏永远是惰性资源\")\n```\n\n- [x] 任务列表可读\n- [ ] 不会触发任何执行\n\n外部链接:[Marqdo CLI](https://github.com/cflmy/marqdo-cli)。\n",
|
||||
"document": {
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge 表格、公式与惰性资源",
|
||||
"span": {
|
||||
"end": 43,
|
||||
"start": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 43,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"alignments": [
|
||||
"none",
|
||||
"right",
|
||||
"none"
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "名称",
|
||||
"span": {
|
||||
"end": 53,
|
||||
"start": 47
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 54,
|
||||
"start": 46
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "值",
|
||||
"span": {
|
||||
"end": 59,
|
||||
"start": 56
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 60,
|
||||
"start": 55
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "说明",
|
||||
"span": {
|
||||
"end": 68,
|
||||
"start": 62
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 69,
|
||||
"start": 61
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": true,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 70,
|
||||
"start": 45
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "甲",
|
||||
"span": {
|
||||
"end": 97,
|
||||
"start": 94
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 98,
|
||||
"start": 93
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "1",
|
||||
"span": {
|
||||
"end": 101,
|
||||
"start": 100
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 102,
|
||||
"start": 99
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "第一行",
|
||||
"span": {
|
||||
"end": 113,
|
||||
"start": 104
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 114,
|
||||
"start": 103
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": false,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 115,
|
||||
"start": 92
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "乙",
|
||||
"span": {
|
||||
"end": 121,
|
||||
"start": 118
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 122,
|
||||
"start": 117
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "2",
|
||||
"span": {
|
||||
"end": 125,
|
||||
"start": 124
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 126,
|
||||
"start": 123
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "第二行",
|
||||
"span": {
|
||||
"end": 137,
|
||||
"start": 128
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 138,
|
||||
"start": 127
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": false,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 139,
|
||||
"start": 116
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table",
|
||||
"span": {
|
||||
"end": 139,
|
||||
"start": 45
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "行内公式 ",
|
||||
"span": {
|
||||
"end": 154,
|
||||
"start": 141
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"display": false,
|
||||
"kind": "math",
|
||||
"literal": "E = mc^2",
|
||||
"span": {
|
||||
"end": 164,
|
||||
"start": 154
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": ";块公式:",
|
||||
"span": {
|
||||
"end": 179,
|
||||
"start": 164
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 179,
|
||||
"start": 141
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "math_block",
|
||||
"literal": "\\sum_{i=1}^{n} i = \\frac{n(n+1)}{2}\n",
|
||||
"span": {
|
||||
"end": 222,
|
||||
"start": 181
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"fenced": true,
|
||||
"info": "python",
|
||||
"kind": "code_block",
|
||||
"literal": "print(\"代码围栏永远是惰性资源\")\n",
|
||||
"span": {
|
||||
"end": 280,
|
||||
"start": 224
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "任务列表可读",
|
||||
"span": {
|
||||
"end": 306,
|
||||
"start": 288
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 306,
|
||||
"start": 288
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "item",
|
||||
"span": {
|
||||
"end": 306,
|
||||
"start": 282
|
||||
},
|
||||
"task": true
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "不会触发任何执行",
|
||||
"span": {
|
||||
"end": 337,
|
||||
"start": 313
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 337,
|
||||
"start": 313
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "item",
|
||||
"span": {
|
||||
"end": 337,
|
||||
"start": 307
|
||||
},
|
||||
"task": false
|
||||
}
|
||||
],
|
||||
"kind": "list",
|
||||
"ordered": false,
|
||||
"span": {
|
||||
"end": 337,
|
||||
"start": 282
|
||||
},
|
||||
"start": null,
|
||||
"tight": true
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "外部链接:",
|
||||
"span": {
|
||||
"end": 354,
|
||||
"start": 339
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "Marqdo CLI",
|
||||
"span": {
|
||||
"end": 365,
|
||||
"start": 355
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "link",
|
||||
"span": {
|
||||
"end": 403,
|
||||
"start": 354
|
||||
},
|
||||
"title": "",
|
||||
"url": "https://github.com/cflmy/marqdo-cli"
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "。",
|
||||
"span": {
|
||||
"end": 406,
|
||||
"start": 403
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 406,
|
||||
"start": 339
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "document",
|
||||
"span": {
|
||||
"end": 407,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
"units": [
|
||||
{
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#",
|
||||
"path": [],
|
||||
"parent_id": null,
|
||||
"kind": "root",
|
||||
"name": "",
|
||||
"level": 0,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "default",
|
||||
"mode_source_unit_id": "root:tables-math@0.1.0::index.mq.md#",
|
||||
"heading_span": null,
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 407
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源",
|
||||
"path": [
|
||||
"表格、公式与惰性资源"
|
||||
],
|
||||
"parent_id": "root:tables-math@0.1.0::index.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "表格、公式与惰性资源",
|
||||
"level": 1,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源",
|
||||
"heading_span": {
|
||||
"start": 0,
|
||||
"end": 43
|
||||
},
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 407
|
||||
},
|
||||
"function": null
|
||||
}
|
||||
],
|
||||
"anchors": [
|
||||
{
|
||||
"anchor": "表格公式与惰性资源",
|
||||
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源"
|
||||
}
|
||||
],
|
||||
"functions": [],
|
||||
"imports": [],
|
||||
"references": [
|
||||
{
|
||||
"source": "root:tables-math@0.1.0::index.mq.md",
|
||||
"source_unit": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源",
|
||||
"url": "https://github.com/cflmy/marqdo-cli",
|
||||
"span": {
|
||||
"start": 354,
|
||||
"end": 403
|
||||
},
|
||||
"state": "external",
|
||||
"target_kind": null,
|
||||
"target_module": null,
|
||||
"target_unit": null,
|
||||
"candidate_package_instance_id": null,
|
||||
"candidate_path": null,
|
||||
"fragment": null,
|
||||
"candidates": []
|
||||
}
|
||||
],
|
||||
"calls": [],
|
||||
"resources": [
|
||||
{
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#resource:formula-1",
|
||||
"module_id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源",
|
||||
"kind": "formula",
|
||||
"span": {
|
||||
"start": 154,
|
||||
"end": 164
|
||||
},
|
||||
"content_digest": "2820951a377c18ce3e89093ca7c31c204b1196a7e571781c6080f8207524a8dc",
|
||||
"language": null,
|
||||
"display": false
|
||||
},
|
||||
{
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#resource:formula-2",
|
||||
"module_id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源",
|
||||
"kind": "formula",
|
||||
"span": {
|
||||
"start": 181,
|
||||
"end": 222
|
||||
},
|
||||
"content_digest": "8b1e8a7ed159e8223af79e768681907870ae7143f0b16001091377f9ff018db2",
|
||||
"language": null,
|
||||
"display": true
|
||||
},
|
||||
{
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#resource:code-1",
|
||||
"module_id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源",
|
||||
"kind": "code",
|
||||
"span": {
|
||||
"start": 224,
|
||||
"end": 280
|
||||
},
|
||||
"content_digest": "a0d49e456637468d7f594f4e2bb513321875855c1fe85d28e0ca62f1e9180d15",
|
||||
"language": "python",
|
||||
"display": null
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"diagnostics": []
|
||||
}
|
||||
@@ -0,0 +1,495 @@
|
||||
{
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 3,
|
||||
"producer": {
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-rc.4",
|
||||
"markdown_profile": "marqdo.md.v1"
|
||||
},
|
||||
"project": {
|
||||
"root_id": "root:unicode-spans@0.1.0",
|
||||
"identity_kind": "manifest",
|
||||
"entry_module_id": "root:unicode-spans@0.1.0::crlf.mq.md",
|
||||
"lock_digest": "",
|
||||
"manifest_digest": "sha256:f0fa034f049dddbbd467d7fee6a2995c61b61ec6c075efa3650b490e45fb2b11",
|
||||
"stdlib": {
|
||||
"version": "0.1.0",
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713"
|
||||
},
|
||||
"extensions": []
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md",
|
||||
"package_instance_id": "root:unicode-spans@0.1.0",
|
||||
"relative_path": "crlf.mq.md",
|
||||
"source_digest": "3d6c99d8e1666b14cc51e6774a4cf514a3a252f3b2f9f541c7cde4a090551b1f",
|
||||
"source": "# @knowledge CRLF 文档\r\n\r\n正文包含中文与 emoji 🙂。\r\n\r\n# @exec 演示\r\n\r\n## @exec main\r\n\r\n`params(n: Int)`\r\n\r\n**if n > 0**\r\n\r\n`return n`\r\n\r\n**else**\r\n\r\n`return 0`\r\n\r\n**end**\r\n",
|
||||
"document": {
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge CRLF 文档",
|
||||
"span": {
|
||||
"end": 24,
|
||||
"start": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 24,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "正文包含中文与 emoji 🙂。",
|
||||
"span": {
|
||||
"end": 63,
|
||||
"start": 28
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 63,
|
||||
"start": 28
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec 演示",
|
||||
"span": {
|
||||
"end": 81,
|
||||
"start": 69
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 81,
|
||||
"start": 67
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec main",
|
||||
"span": {
|
||||
"end": 98,
|
||||
"start": 88
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 2,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 98,
|
||||
"start": 85
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "params(n: Int)",
|
||||
"span": {
|
||||
"end": 118,
|
||||
"start": 102
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 118,
|
||||
"start": 102
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "if n > 0",
|
||||
"span": {
|
||||
"end": 132,
|
||||
"start": 124
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "return n",
|
||||
"span": {
|
||||
"end": 148,
|
||||
"start": 138
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 148,
|
||||
"start": 138
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "else",
|
||||
"span": {
|
||||
"end": 158,
|
||||
"start": 154
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 160,
|
||||
"start": 152
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 160,
|
||||
"start": 152
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "return 0",
|
||||
"span": {
|
||||
"end": 174,
|
||||
"start": 164
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 174,
|
||||
"start": 164
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "end",
|
||||
"span": {
|
||||
"end": 183,
|
||||
"start": 180
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 185,
|
||||
"start": 178
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 185,
|
||||
"start": 178
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "document",
|
||||
"span": {
|
||||
"end": 187,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
"units": [
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#",
|
||||
"path": [],
|
||||
"parent_id": null,
|
||||
"kind": "root",
|
||||
"name": "",
|
||||
"level": 0,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "default",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#",
|
||||
"heading_span": null,
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 187
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#CRLF 文档",
|
||||
"path": [
|
||||
"CRLF 文档"
|
||||
],
|
||||
"parent_id": "root:unicode-spans@0.1.0::crlf.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "CRLF 文档",
|
||||
"level": 1,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#CRLF 文档",
|
||||
"heading_span": {
|
||||
"start": 0,
|
||||
"end": 24
|
||||
},
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 67
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#演示",
|
||||
"path": [
|
||||
"演示"
|
||||
],
|
||||
"parent_id": "root:unicode-spans@0.1.0::crlf.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "演示",
|
||||
"level": 1,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#演示",
|
||||
"heading_span": {
|
||||
"start": 67,
|
||||
"end": 81
|
||||
},
|
||||
"span": {
|
||||
"start": 67,
|
||||
"end": 187
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#演示/main",
|
||||
"path": [
|
||||
"演示",
|
||||
"main"
|
||||
],
|
||||
"parent_id": "root:unicode-spans@0.1.0::crlf.mq.md#演示",
|
||||
"kind": "function",
|
||||
"name": "main",
|
||||
"level": 2,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#演示/main",
|
||||
"heading_span": {
|
||||
"start": 85,
|
||||
"end": 98
|
||||
},
|
||||
"span": {
|
||||
"start": 85,
|
||||
"end": 187
|
||||
},
|
||||
"function": "root:unicode-spans@0.1.0::crlf.mq.md::演示.main"
|
||||
}
|
||||
],
|
||||
"anchors": [
|
||||
{
|
||||
"anchor": "crlf-文档",
|
||||
"unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#CRLF 文档"
|
||||
},
|
||||
{
|
||||
"anchor": "main",
|
||||
"unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#演示/main"
|
||||
},
|
||||
{
|
||||
"anchor": "演示",
|
||||
"unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#演示"
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md::演示.main",
|
||||
"unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#演示/main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"span": {
|
||||
"start": 85,
|
||||
"end": 185
|
||||
},
|
||||
"heading_span": {
|
||||
"start": 85,
|
||||
"end": 98
|
||||
},
|
||||
"signature": {
|
||||
"kind": "explicit",
|
||||
"params": [
|
||||
{
|
||||
"name": "n",
|
||||
"required": true,
|
||||
"type": "Int",
|
||||
"default": null,
|
||||
"span": {
|
||||
"start": 109,
|
||||
"end": 115
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"arms": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 148,
|
||||
"start": 138
|
||||
},
|
||||
"value": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 147,
|
||||
"start": 146
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 128,
|
||||
"start": 127
|
||||
}
|
||||
},
|
||||
"op": "gt",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
},
|
||||
"span": {
|
||||
"end": 132,
|
||||
"start": 127
|
||||
}
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
},
|
||||
"span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
}
|
||||
},
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 174,
|
||||
"start": 164
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 160,
|
||||
"start": 152
|
||||
},
|
||||
"span": {
|
||||
"end": 160,
|
||||
"start": 152
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "branch",
|
||||
"span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"imports": [],
|
||||
"references": [],
|
||||
"calls": [],
|
||||
"resources": []
|
||||
}
|
||||
],
|
||||
"diagnostics": []
|
||||
}
|
||||
@@ -0,0 +1,638 @@
|
||||
{
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 3,
|
||||
"producer": {
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-rc.4",
|
||||
"markdown_profile": "marqdo.md.v1"
|
||||
},
|
||||
"project": {
|
||||
"root_id": "root:unicode-spans@0.1.0",
|
||||
"identity_kind": "manifest",
|
||||
"entry_module_id": "root:unicode-spans@0.1.0::index.mq.md",
|
||||
"lock_digest": "",
|
||||
"manifest_digest": "sha256:f0fa034f049dddbbd467d7fee6a2995c61b61ec6c075efa3650b490e45fb2b11",
|
||||
"stdlib": {
|
||||
"version": "0.1.0",
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713"
|
||||
},
|
||||
"extensions": []
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md",
|
||||
"package_instance_id": "root:unicode-spans@0.1.0",
|
||||
"relative_path": "index.mq.md",
|
||||
"source_digest": "b4f8dd12f18a984af129974bc4dd153e97df99cc262bcafb2ae1187b6c5ce7d0",
|
||||
"source": "# @knowledge 中文 🙂 标题\n\n正文包含 emoji 🙂 与组合字符 é,以及惰性 `代码`。**此处加粗是知识内容,不执行。**\n\n| 名称 | 值 |\n| --- | --- |\n| 甲🙂 | 1 |\n\n# @exec 演示\n\n## @exec main\n\n`params(n: Int)`\n\n**if n > 0**\n\n`return 1`\n\n**else**\n\n`return 1`\n\n**end**\n",
|
||||
"document": {
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge 中文 🙂 标题",
|
||||
"span": {
|
||||
"end": 31,
|
||||
"start": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 31,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "正文包含 emoji 🙂 与组合字符 é,以及惰性 ",
|
||||
"span": {
|
||||
"end": 91,
|
||||
"start": 33
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "代码",
|
||||
"span": {
|
||||
"end": 99,
|
||||
"start": 91
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "。",
|
||||
"span": {
|
||||
"end": 102,
|
||||
"start": 99
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "此处加粗是知识内容,不执行。",
|
||||
"span": {
|
||||
"end": 146,
|
||||
"start": 104
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 148,
|
||||
"start": 102
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 148,
|
||||
"start": 33
|
||||
}
|
||||
},
|
||||
{
|
||||
"alignments": [
|
||||
"none",
|
||||
"none"
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "名称",
|
||||
"span": {
|
||||
"end": 158,
|
||||
"start": 152
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 159,
|
||||
"start": 151
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "值",
|
||||
"span": {
|
||||
"end": 164,
|
||||
"start": 161
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 165,
|
||||
"start": 160
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": true,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 166,
|
||||
"start": 150
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "甲🙂",
|
||||
"span": {
|
||||
"end": 190,
|
||||
"start": 183
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 191,
|
||||
"start": 182
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "1",
|
||||
"span": {
|
||||
"end": 194,
|
||||
"start": 193
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 195,
|
||||
"start": 192
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": false,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 196,
|
||||
"start": 181
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table",
|
||||
"span": {
|
||||
"end": 196,
|
||||
"start": 150
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec 演示",
|
||||
"span": {
|
||||
"end": 212,
|
||||
"start": 200
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 212,
|
||||
"start": 198
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec main",
|
||||
"span": {
|
||||
"end": 227,
|
||||
"start": 217
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 2,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 227,
|
||||
"start": 214
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "params(n: Int)",
|
||||
"span": {
|
||||
"end": 245,
|
||||
"start": 229
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 245,
|
||||
"start": 229
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "if n > 0",
|
||||
"span": {
|
||||
"end": 257,
|
||||
"start": 249
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "return 1",
|
||||
"span": {
|
||||
"end": 271,
|
||||
"start": 261
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 271,
|
||||
"start": 261
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "else",
|
||||
"span": {
|
||||
"end": 279,
|
||||
"start": 275
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 281,
|
||||
"start": 273
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 281,
|
||||
"start": 273
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "return 1",
|
||||
"span": {
|
||||
"end": 293,
|
||||
"start": 283
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 293,
|
||||
"start": 283
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "end",
|
||||
"span": {
|
||||
"end": 300,
|
||||
"start": 297
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 302,
|
||||
"start": 295
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 302,
|
||||
"start": 295
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "document",
|
||||
"span": {
|
||||
"end": 303,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
"units": [
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#",
|
||||
"path": [],
|
||||
"parent_id": null,
|
||||
"kind": "root",
|
||||
"name": "",
|
||||
"level": 0,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "default",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::index.mq.md#",
|
||||
"heading_span": null,
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 303
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#中文 🙂 标题",
|
||||
"path": [
|
||||
"中文 🙂 标题"
|
||||
],
|
||||
"parent_id": "root:unicode-spans@0.1.0::index.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "中文 🙂 标题",
|
||||
"level": 1,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::index.mq.md#中文 🙂 标题",
|
||||
"heading_span": {
|
||||
"start": 0,
|
||||
"end": 31
|
||||
},
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 198
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#演示",
|
||||
"path": [
|
||||
"演示"
|
||||
],
|
||||
"parent_id": "root:unicode-spans@0.1.0::index.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "演示",
|
||||
"level": 1,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::index.mq.md#演示",
|
||||
"heading_span": {
|
||||
"start": 198,
|
||||
"end": 212
|
||||
},
|
||||
"span": {
|
||||
"start": 198,
|
||||
"end": 303
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#演示/main",
|
||||
"path": [
|
||||
"演示",
|
||||
"main"
|
||||
],
|
||||
"parent_id": "root:unicode-spans@0.1.0::index.mq.md#演示",
|
||||
"kind": "function",
|
||||
"name": "main",
|
||||
"level": 2,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::index.mq.md#演示/main",
|
||||
"heading_span": {
|
||||
"start": 214,
|
||||
"end": 227
|
||||
},
|
||||
"span": {
|
||||
"start": 214,
|
||||
"end": 303
|
||||
},
|
||||
"function": "root:unicode-spans@0.1.0::index.mq.md::演示.main"
|
||||
}
|
||||
],
|
||||
"anchors": [
|
||||
{
|
||||
"anchor": "main",
|
||||
"unit_id": "root:unicode-spans@0.1.0::index.mq.md#演示/main"
|
||||
},
|
||||
{
|
||||
"anchor": "中文--标题",
|
||||
"unit_id": "root:unicode-spans@0.1.0::index.mq.md#中文 🙂 标题"
|
||||
},
|
||||
{
|
||||
"anchor": "演示",
|
||||
"unit_id": "root:unicode-spans@0.1.0::index.mq.md#演示"
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md::演示.main",
|
||||
"unit_id": "root:unicode-spans@0.1.0::index.mq.md#演示/main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"span": {
|
||||
"start": 214,
|
||||
"end": 302
|
||||
},
|
||||
"heading_span": {
|
||||
"start": 214,
|
||||
"end": 227
|
||||
},
|
||||
"signature": {
|
||||
"kind": "explicit",
|
||||
"params": [
|
||||
{
|
||||
"name": "n",
|
||||
"required": true,
|
||||
"type": "Int",
|
||||
"default": null,
|
||||
"span": {
|
||||
"start": 236,
|
||||
"end": 242
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"arms": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 271,
|
||||
"start": 261
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "1"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 253,
|
||||
"start": 252
|
||||
}
|
||||
},
|
||||
"op": "gt",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
},
|
||||
"span": {
|
||||
"end": 257,
|
||||
"start": 252
|
||||
}
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
},
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
}
|
||||
},
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 293,
|
||||
"start": 283
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "1"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 281,
|
||||
"start": 273
|
||||
},
|
||||
"span": {
|
||||
"end": 281,
|
||||
"start": 273
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "branch",
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"imports": [],
|
||||
"references": [],
|
||||
"calls": [],
|
||||
"resources": []
|
||||
}
|
||||
],
|
||||
"diagnostics": []
|
||||
}
|
||||
@@ -0,0 +1,716 @@
|
||||
{
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 3,
|
||||
"producer": {
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-rc.4",
|
||||
"markdown_profile": "marqdo.md.v1"
|
||||
},
|
||||
"project": {
|
||||
"root_id": "root:welcome-demo@0.1.0",
|
||||
"identity_kind": "manifest",
|
||||
"entry_module_id": "root:welcome-demo@0.1.0::00-welcome.mq.md",
|
||||
"lock_digest": "",
|
||||
"manifest_digest": "sha256:69ce9ddb5e526f335adb51f374ada998db8752185fab11f686002dbbb567b46f",
|
||||
"stdlib": {
|
||||
"version": "0.1.0",
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713"
|
||||
},
|
||||
"extensions": []
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"id": "root:welcome-demo@0.1.0::00-welcome.mq.md",
|
||||
"package_instance_id": "root:welcome-demo@0.1.0",
|
||||
"relative_path": "00-welcome.mq.md",
|
||||
"source_digest": "879215bf0dc432b78924800a08eac37d353a9694652c5542294f4ce7fe6da173",
|
||||
"source": "# @knowledge 欢迎来到 Marqdo\n\nMarqdo 把 Markdown 当作可执行文档的语言:标题声明 `@exec` / `@knowledge` 模式,\n强调、斜体与行内代码是**等价的单语句载体**,而 `if` / `else` / `while` / `end` /\n`return` 决定真正的操作。\n\n| 阅读态 | 内容 | 是否执行 |\n| --- | --- | --- |\n| 文档 | 原始 Markdown 排版 | 否 |\n| 源码 | 逐行原文,包含全部标记 | 否 |\n| 运行 | 用户显式确认后才出现 | 是(需要确认) |\n\n继续阅读:[语法演示](./guide.mq.md)。\n\n> 这份欢迎页只是 `view.json` 显式指定的站点首页,普通 `welcome` 文件名不会自动变成 Hero。\n",
|
||||
"document": {
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge 欢迎来到 Marqdo",
|
||||
"span": {
|
||||
"end": 32,
|
||||
"start": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 32,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "Marqdo 把 Markdown 当作可执行文档的语言:标题声明 ",
|
||||
"span": {
|
||||
"end": 100,
|
||||
"start": 34
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "@exec",
|
||||
"span": {
|
||||
"end": 107,
|
||||
"start": 100
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " / ",
|
||||
"span": {
|
||||
"end": 110,
|
||||
"start": 107
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "@knowledge",
|
||||
"span": {
|
||||
"end": 122,
|
||||
"start": 110
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " 模式,",
|
||||
"span": {
|
||||
"end": 132,
|
||||
"start": 122
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "soft_break",
|
||||
"span": {
|
||||
"end": 133,
|
||||
"start": 132
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "强调、斜体与行内代码是",
|
||||
"span": {
|
||||
"end": 166,
|
||||
"start": 133
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "等价的单语句载体",
|
||||
"span": {
|
||||
"end": 192,
|
||||
"start": 168
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 194,
|
||||
"start": 166
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": ",而 ",
|
||||
"span": {
|
||||
"end": 201,
|
||||
"start": 194
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "if",
|
||||
"span": {
|
||||
"end": 205,
|
||||
"start": 201
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " / ",
|
||||
"span": {
|
||||
"end": 208,
|
||||
"start": 205
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "else",
|
||||
"span": {
|
||||
"end": 214,
|
||||
"start": 208
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " / ",
|
||||
"span": {
|
||||
"end": 217,
|
||||
"start": 214
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "while",
|
||||
"span": {
|
||||
"end": 224,
|
||||
"start": 217
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " / ",
|
||||
"span": {
|
||||
"end": 227,
|
||||
"start": 224
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "end",
|
||||
"span": {
|
||||
"end": 232,
|
||||
"start": 227
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " /",
|
||||
"span": {
|
||||
"end": 234,
|
||||
"start": 232
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "soft_break",
|
||||
"span": {
|
||||
"end": 235,
|
||||
"start": 234
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "return",
|
||||
"span": {
|
||||
"end": 243,
|
||||
"start": 235
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " 决定真正的操作。",
|
||||
"span": {
|
||||
"end": 268,
|
||||
"start": 243
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 268,
|
||||
"start": 34
|
||||
}
|
||||
},
|
||||
{
|
||||
"alignments": [
|
||||
"none",
|
||||
"none",
|
||||
"none"
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "阅读态",
|
||||
"span": {
|
||||
"end": 281,
|
||||
"start": 272
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 282,
|
||||
"start": 271
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "内容",
|
||||
"span": {
|
||||
"end": 290,
|
||||
"start": 284
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 291,
|
||||
"start": 283
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "是否执行",
|
||||
"span": {
|
||||
"end": 305,
|
||||
"start": 293
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 306,
|
||||
"start": 292
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": true,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 307,
|
||||
"start": 270
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "文档",
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 330
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 337,
|
||||
"start": 329
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "原始 Markdown 排版",
|
||||
"span": {
|
||||
"end": 361,
|
||||
"start": 339
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 362,
|
||||
"start": 338
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "否",
|
||||
"span": {
|
||||
"end": 367,
|
||||
"start": 364
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 368,
|
||||
"start": 363
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": false,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 369,
|
||||
"start": 328
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "源码",
|
||||
"span": {
|
||||
"end": 378,
|
||||
"start": 372
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 379,
|
||||
"start": 371
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "逐行原文,包含全部标记",
|
||||
"span": {
|
||||
"end": 414,
|
||||
"start": 381
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 415,
|
||||
"start": 380
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "否",
|
||||
"span": {
|
||||
"end": 420,
|
||||
"start": 417
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 421,
|
||||
"start": 416
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": false,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 422,
|
||||
"start": 370
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "运行",
|
||||
"span": {
|
||||
"end": 431,
|
||||
"start": 425
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 432,
|
||||
"start": 424
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "用户显式确认后才出现",
|
||||
"span": {
|
||||
"end": 464,
|
||||
"start": 434
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 465,
|
||||
"start": 433
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "是(需要确认)",
|
||||
"span": {
|
||||
"end": 488,
|
||||
"start": 467
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 489,
|
||||
"start": 466
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": false,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 490,
|
||||
"start": 423
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table",
|
||||
"span": {
|
||||
"end": 490,
|
||||
"start": 270
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "继续阅读:",
|
||||
"span": {
|
||||
"end": 507,
|
||||
"start": 492
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "语法演示",
|
||||
"span": {
|
||||
"end": 520,
|
||||
"start": 508
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "link",
|
||||
"span": {
|
||||
"end": 536,
|
||||
"start": 507
|
||||
},
|
||||
"title": "",
|
||||
"url": "./guide.mq.md"
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "。",
|
||||
"span": {
|
||||
"end": 539,
|
||||
"start": 536
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 539,
|
||||
"start": 492
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "这份欢迎页只是 ",
|
||||
"span": {
|
||||
"end": 565,
|
||||
"start": 543
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "view.json",
|
||||
"span": {
|
||||
"end": 576,
|
||||
"start": 565
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " 显式指定的站点首页,普通 ",
|
||||
"span": {
|
||||
"end": 614,
|
||||
"start": 576
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "welcome",
|
||||
"span": {
|
||||
"end": 623,
|
||||
"start": 614
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " 文件名不会自动变成 Hero。",
|
||||
"span": {
|
||||
"end": 659,
|
||||
"start": 623
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 659,
|
||||
"start": 543
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "block_quote",
|
||||
"span": {
|
||||
"end": 659,
|
||||
"start": 541
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "document",
|
||||
"span": {
|
||||
"end": 660,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
"units": [
|
||||
{
|
||||
"id": "root:welcome-demo@0.1.0::00-welcome.mq.md#",
|
||||
"path": [],
|
||||
"parent_id": null,
|
||||
"kind": "root",
|
||||
"name": "",
|
||||
"level": 0,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "default",
|
||||
"mode_source_unit_id": "root:welcome-demo@0.1.0::00-welcome.mq.md#",
|
||||
"heading_span": null,
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 660
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:welcome-demo@0.1.0::00-welcome.mq.md#欢迎来到 Marqdo",
|
||||
"path": [
|
||||
"欢迎来到 Marqdo"
|
||||
],
|
||||
"parent_id": "root:welcome-demo@0.1.0::00-welcome.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "欢迎来到 Marqdo",
|
||||
"level": 1,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:welcome-demo@0.1.0::00-welcome.mq.md#欢迎来到 Marqdo",
|
||||
"heading_span": {
|
||||
"start": 0,
|
||||
"end": 32
|
||||
},
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 660
|
||||
},
|
||||
"function": null
|
||||
}
|
||||
],
|
||||
"anchors": [
|
||||
{
|
||||
"anchor": "欢迎来到-marqdo",
|
||||
"unit_id": "root:welcome-demo@0.1.0::00-welcome.mq.md#欢迎来到 Marqdo"
|
||||
}
|
||||
],
|
||||
"functions": [],
|
||||
"imports": [],
|
||||
"references": [
|
||||
{
|
||||
"source": "root:welcome-demo@0.1.0::00-welcome.mq.md",
|
||||
"source_unit": "root:welcome-demo@0.1.0::00-welcome.mq.md#欢迎来到 Marqdo",
|
||||
"url": "./guide.mq.md",
|
||||
"span": {
|
||||
"start": 507,
|
||||
"end": 536
|
||||
},
|
||||
"state": "not_loaded",
|
||||
"target_kind": null,
|
||||
"target_module": null,
|
||||
"target_unit": null,
|
||||
"candidate_package_instance_id": "root:welcome-demo@0.1.0",
|
||||
"candidate_path": "guide.mq.md",
|
||||
"fragment": null,
|
||||
"candidates": []
|
||||
}
|
||||
],
|
||||
"calls": [],
|
||||
"resources": []
|
||||
}
|
||||
],
|
||||
"diagnostics": []
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
{"kind":"stream.opened","payload":{"limits":{"max_observation_bytes":16777216,"max_observation_events":100000,"max_value_bytes":256},"observation":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"values":false},"producer":{"name":"marqdo","version":"3.0.0-rc.4"}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":0}
|
||||
{"kind":"run.started","payload":{"entry":"root:control-flow@0.1.0::index.mq.md::main","mode":"pure","source":{"analysis_digest":"sha256:7e8711e9cbb5d5c73369da0c6620279468fa957d5ab8af038de6dd07d23117e3","root_id":"root:control-flow@0.1.0"},"started_unix_ms":1795610282724},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":1}
|
||||
{"kind":"call.enter","payload":{"frame_id":"f1","function_id":"root:control-flow@0.1.0::index.mq.md::演示.main","module_id":"root:control-flow@0.1.0::index.mq.md","parent_frame_id":null,"span":null},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":2}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":202,"start":195},"value_state":"not_requested","value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":3}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.new","result_code":"ok","span":{"end":230,"start":214}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":4}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"buffer","span":{"end":231,"start":204},"value_state":"not_requested","value_type":"Memory"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":5}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":243,"start":234}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":6}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"resource.open","result_code":"ok","span":{"end":304,"start":261}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":7}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"stdout","span":{"end":305,"start":251},"value_state":"not_requested","value_type":"Resource"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":8}
|
||||
{"kind":"loop.iteration","payload":{"decision":"continue","frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":{"end":322,"start":307}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":9}
|
||||
{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":false,"span":{"end":336,"start":324}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":10}
|
||||
{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":true,"span":{"end":368,"start":360}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":11}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":380,"start":371}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":12}
|
||||
{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"MAo=","encoding":"base64"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":13}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"resource.write","result_code":"ok","span":{"end":434,"start":398}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":14}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":450,"start":437},"value_state":"not_requested","value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":15}
|
||||
{"kind":"loop.iteration","payload":{"decision":"continue","frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":{"end":322,"start":307}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":16}
|
||||
{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":false,"span":{"end":336,"start":324}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":17}
|
||||
{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":true,"span":{"end":368,"start":360}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":18}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":380,"start":371}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":19}
|
||||
{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"MAo=","encoding":"base64"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":20}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"resource.write","result_code":"ok","span":{"end":434,"start":398}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":21}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":450,"start":437},"value_state":"not_requested","value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":22}
|
||||
{"kind":"loop.iteration","payload":{"decision":"continue","frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":{"end":322,"start":307}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":23}
|
||||
{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":true,"span":{"end":336,"start":324}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":24}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":348,"start":339}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":25}
|
||||
{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"Mgo=","encoding":"base64"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":26}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"resource.write","result_code":"ok","span":{"end":434,"start":398}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":27}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":450,"start":437},"value_state":"not_requested","value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":28}
|
||||
{"kind":"loop.iteration","payload":{"decision":"exit","frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":{"end":322,"start":307}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":29}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"resource.close","result_code":"ok","span":{"end":484,"start":462}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":30}
|
||||
{"kind":"return","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":{"end":497,"start":487},"value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":31}
|
||||
{"kind":"call.exit","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":null,"status":"return"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":32}
|
||||
{"kind":"run.completed","payload":{"status":"ok","value":{"decimal":"3","type":"int"},"value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":33}
|
||||
@@ -0,0 +1 @@
|
||||
{"events":[{"kind":"stream.opened","payload":{"limits":{"max_observation_bytes":16777216,"max_observation_events":100000,"max_value_bytes":256},"observation":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"values":false},"producer":{"name":"marqdo","version":"3.0.0-rc.4"}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":0},{"kind":"run.started","payload":{"entry":"root:control-flow@0.1.0::index.mq.md::main","mode":"pure","source":{"analysis_digest":"sha256:7e8711e9cbb5d5c73369da0c6620279468fa957d5ab8af038de6dd07d23117e3","root_id":"root:control-flow@0.1.0"},"started_unix_ms":1795610282724},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":1},{"kind":"call.enter","payload":{"frame_id":"f1","function_id":"root:control-flow@0.1.0::index.mq.md::演示.main","module_id":"root:control-flow@0.1.0::index.mq.md","parent_frame_id":null,"span":null},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":2},{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":202,"start":195},"value_state":"not_requested","value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":3},{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.new","result_code":"ok","span":{"end":230,"start":214}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":4},{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"buffer","span":{"end":231,"start":204},"value_state":"not_requested","value_type":"Memory"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":5},{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":243,"start":234}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":6},{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"resource.open","result_code":"ok","span":{"end":304,"start":261}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":7},{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"stdout","span":{"end":305,"start":251},"value_state":"not_requested","value_type":"Resource"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":8},{"kind":"loop.iteration","payload":{"decision":"continue","frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":{"end":322,"start":307}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":9},{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":false,"span":{"end":336,"start":324}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":10},{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":true,"span":{"end":368,"start":360}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":11},{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":380,"start":371}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":12},{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"MAo=","encoding":"base64"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":13},{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"resource.write","result_code":"ok","span":{"end":434,"start":398}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":14},{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":450,"start":437},"value_state":"not_requested","value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":15},{"kind":"loop.iteration","payload":{"decision":"continue","frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":{"end":322,"start":307}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":16},{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":false,"span":{"end":336,"start":324}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":17},{"kind":"branch.eLine truncated
|
||||
@@ -0,0 +1,12 @@
|
||||
{"kind":"stream.opened","payload":{"limits":{"max_observation_bytes":16777216,"max_observation_events":5,"max_value_bytes":256},"observation":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"values":false},"producer":{"name":"marqdo","version":"3.0.0-rc.4"}},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":0}
|
||||
{"kind":"run.started","payload":{"entry":"root:control-flow@0.1.0::index.mq.md::main","mode":"pure","source":{"analysis_digest":"sha256:7e8711e9cbb5d5c73369da0c6620279468fa957d5ab8af038de6dd07d23117e3","root_id":"root:control-flow@0.1.0"},"started_unix_ms":1795610282743},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":1}
|
||||
{"kind":"call.enter","payload":{"frame_id":"f1","function_id":"root:control-flow@0.1.0::index.mq.md::演示.main","module_id":"root:control-flow@0.1.0::index.mq.md","parent_frame_id":null,"span":null},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":2}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":202,"start":195},"value_state":"not_requested","value_type":"Int"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":3}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.new","result_code":"ok","span":{"end":230,"start":214}},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":4}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"buffer","span":{"end":231,"start":204},"value_state":"not_requested","value_type":"Memory"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":5}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":243,"start":234}},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":6}
|
||||
{"kind":"observation.truncated","payload":{"dropped":null,"limit":5,"reason":"event_budget","written":5},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":7}
|
||||
{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"MAo=","encoding":"base64"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":8}
|
||||
{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"MAo=","encoding":"base64"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":9}
|
||||
{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"Mgo=","encoding":"base64"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":10}
|
||||
{"kind":"run.completed","payload":{"status":"ok","value":{"decimal":"3","type":"int"},"value_type":"Int"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":11}
|
||||
@@ -0,0 +1 @@
|
||||
{"events":[{"kind":"stream.opened","payload":{"limits":{"max_observation_bytes":16777216,"max_observation_events":5,"max_value_bytes":256},"observation":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"values":false},"producer":{"name":"marqdo","version":"3.0.0-rc.4"}},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":0},{"kind":"run.started","payload":{"entry":"root:control-flow@0.1.0::index.mq.md::main","mode":"pure","source":{"analysis_digest":"sha256:7e8711e9cbb5d5c73369da0c6620279468fa957d5ab8af038de6dd07d23117e3","root_id":"root:control-flow@0.1.0"},"started_unix_ms":1795610282743},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":1},{"kind":"call.enter","payload":{"frame_id":"f1","function_id":"root:control-flow@0.1.0::index.mq.md::演示.main","module_id":"root:control-flow@0.1.0::index.mq.md","parent_frame_id":null,"span":null},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":2},{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":202,"start":195},"value_state":"not_requested","value_type":"Int"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":3},{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.new","result_code":"ok","span":{"end":230,"start":214}},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":4},{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"buffer","span":{"end":231,"start":204},"value_state":"not_requested","value_type":"Memory"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":5},{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":243,"start":234}},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":6},{"kind":"observation.truncated","payload":{"dropped":null,"limit":5,"reason":"event_budget","written":5},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":7},{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"MAo=","encoding":"base64"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":8},{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"MAo=","encoding":"base64"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":9},{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"Mgo=","encoding":"base64"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":10},{"kind":"run.completed","payload":{"status":"ok","value":{"decimal":"3","type":"int"},"value_type":"Int"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":11}],"capture":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"truncated":{"dropped":null,"limit":5,"reason":"event_budget","written":5},"values":false},"run":{"id":"28-1795610282728843625","source":{"analysis_digest":"sha256:7e8711e9cbb5d5c73369da0c6620279468fa957d5ab8af038de6dd07d23117e3","root_id":"root:control-flow@0.1.0"},"status":"ok"},"schema":"marqdo.observation","schema_version":1}
|
||||
@@ -0,0 +1,3 @@
|
||||
{"kind":"stream.opened","payload":{"limits":{"max_observation_bytes":16777216,"max_observation_events":100000,"max_value_bytes":256},"observation":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"values":false},"producer":{"name":"marqdo","version":"3.0.0-rc.4"}},"run_id":"35-1795610282746900014","schema":"marqdo.observation","schema_version":1,"seq":0}
|
||||
{"kind":"run.started","payload":{"entry":"root:mixed-modes@0.1.0::index.mq.md::main","mode":"pure","source":{"analysis_digest":"sha256:fd686ba0851c34a897f3e432c579ed4c64188914e5b6aec5e24b8ee4f444b01f","root_id":"root:mixed-modes@0.1.0"},"started_unix_ms":1795610282761},"run_id":"35-1795610282746900014","schema":"marqdo.observation","schema_version":1,"seq":1}
|
||||
{"kind":"run.failed","payload":{"error":{"code":"call.arity","column":null,"frames":[],"line":null,"message":"`演示.main` is missing required argument `n`","module_id":null,"origin":"source","relative_path":null,"span":null},"status":"error"},"run_id":"35-1795610282746900014","schema":"marqdo.observation","schema_version":1,"seq":2}
|
||||
@@ -0,0 +1 @@
|
||||
{"events":[{"kind":"stream.opened","payload":{"limits":{"max_observation_bytes":16777216,"max_observation_events":100000,"max_value_bytes":256},"observation":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"values":false},"producer":{"name":"marqdo","version":"3.0.0-rc.4"}},"run_id":"35-1795610282746900014","schema":"marqdo.observation","schema_version":1,"seq":0},{"kind":"run.started","payload":{"entry":"root:mixed-modes@0.1.0::index.mq.md::main","mode":"pure","source":{"analysis_digest":"sha256:fd686ba0851c34a897f3e432c579ed4c64188914e5b6aec5e24b8ee4f444b01f","root_id":"root:mixed-modes@0.1.0"},"started_unix_ms":1795610282761},"run_id":"35-1795610282746900014","schema":"marqdo.observation","schema_version":1,"seq":1},{"kind":"run.failed","payload":{"error":{"code":"call.arity","column":null,"frames":[],"line":null,"message":"`演示.main` is missing required argument `n`","module_id":null,"origin":"source","relative_path":null,"span":null},"status":"error"},"run_id":"35-1795610282746900014","schema":"marqdo.observation","schema_version":1,"seq":2}],"capture":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"truncated":null,"values":false},"run":{"id":"35-1795610282746900014","source":{"analysis_digest":"sha256:fd686ba0851c34a897f3e432c579ed4c64188914e5b6aec5e24b8ee4f444b01f","root_id":"root:mixed-modes@0.1.0"},"status":"error"},"schema":"marqdo.observation","schema_version":1}
|
||||
@@ -1,68 +0,0 @@
|
||||
{
|
||||
"command": "run",
|
||||
"diagnostics": [],
|
||||
"stderr": "",
|
||||
"stdout": "0\n0\n2\n",
|
||||
"success": true,
|
||||
"trace": [
|
||||
{
|
||||
"duration_micros": 14,
|
||||
"module": "root:control-flow@0.1.0::index.mq.md",
|
||||
"op": "resource.open",
|
||||
"result": "ok",
|
||||
"seq": 4,
|
||||
"span": {
|
||||
"end": 304,
|
||||
"start": 261
|
||||
}
|
||||
},
|
||||
{
|
||||
"duration_micros": 21,
|
||||
"module": "root:control-flow@0.1.0::index.mq.md",
|
||||
"op": "resource.write",
|
||||
"result": "kind=stdio count=2",
|
||||
"seq": 10,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"duration_micros": 0,
|
||||
"module": "root:control-flow@0.1.0::index.mq.md",
|
||||
"op": "resource.write",
|
||||
"result": "kind=stdio count=2",
|
||||
"seq": 16,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"duration_micros": 0,
|
||||
"module": "root:control-flow@0.1.0::index.mq.md",
|
||||
"op": "resource.write",
|
||||
"result": "kind=stdio count=2",
|
||||
"seq": 21,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"duration_micros": 0,
|
||||
"module": "root:control-flow@0.1.0::index.mq.md",
|
||||
"op": "resource.close",
|
||||
"result": "flushed_bytes=0",
|
||||
"seq": 24,
|
||||
"span": {
|
||||
"end": 484,
|
||||
"start": 462
|
||||
}
|
||||
}
|
||||
],
|
||||
"value": {
|
||||
"decimal": "3",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -1,316 +0,0 @@
|
||||
{
|
||||
"events": [
|
||||
{
|
||||
"detail": null,
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "call.enter",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 0,
|
||||
"span": null
|
||||
},
|
||||
{
|
||||
"detail": "initial_pages=1 max_pages=1",
|
||||
"function_id": null,
|
||||
"kind": "memory.new",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 1,
|
||||
"span": {
|
||||
"end": 230,
|
||||
"start": 214
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "byte",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "memory.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 2,
|
||||
"span": {
|
||||
"end": 243,
|
||||
"start": 234
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio descriptor=stdout",
|
||||
"function_id": null,
|
||||
"kind": "resource.open",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 3,
|
||||
"span": {
|
||||
"end": 304,
|
||||
"start": 261
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "ok",
|
||||
"duration_micros": 14,
|
||||
"kind": "effect",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"operation": "resource.open",
|
||||
"seq": 4,
|
||||
"span": {
|
||||
"end": 304,
|
||||
"start": 261
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "continue",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "loop.iteration",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 5,
|
||||
"span": {
|
||||
"end": 322,
|
||||
"start": 307
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "false",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "branch.eval",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 6,
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "true",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "branch.eval",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 7,
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "byte",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "memory.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 8,
|
||||
"span": {
|
||||
"end": 380,
|
||||
"start": 371
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio count=2",
|
||||
"function_id": null,
|
||||
"kind": "resource.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 9,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio count=2",
|
||||
"duration_micros": 21,
|
||||
"kind": "effect",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"operation": "resource.write",
|
||||
"seq": 10,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "continue",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "loop.iteration",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 11,
|
||||
"span": {
|
||||
"end": 322,
|
||||
"start": 307
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "false",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "branch.eval",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 12,
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "true",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "branch.eval",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 13,
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "byte",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "memory.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 14,
|
||||
"span": {
|
||||
"end": 380,
|
||||
"start": 371
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio count=2",
|
||||
"function_id": null,
|
||||
"kind": "resource.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 15,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio count=2",
|
||||
"duration_micros": 0,
|
||||
"kind": "effect",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"operation": "resource.write",
|
||||
"seq": 16,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "continue",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "loop.iteration",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 17,
|
||||
"span": {
|
||||
"end": 322,
|
||||
"start": 307
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "true",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "branch.eval",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 18,
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "byte",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "memory.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 19,
|
||||
"span": {
|
||||
"end": 348,
|
||||
"start": 339
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio count=2",
|
||||
"function_id": null,
|
||||
"kind": "resource.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 20,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio count=2",
|
||||
"duration_micros": 0,
|
||||
"kind": "effect",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"operation": "resource.write",
|
||||
"seq": 21,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "exit",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "loop.iteration",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 22,
|
||||
"span": {
|
||||
"end": 322,
|
||||
"start": 307
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "flushed_bytes=0",
|
||||
"function_id": null,
|
||||
"kind": "resource.close",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 23,
|
||||
"span": {
|
||||
"end": 484,
|
||||
"start": 462
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "flushed_bytes=0",
|
||||
"duration_micros": 0,
|
||||
"kind": "effect",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"operation": "resource.close",
|
||||
"seq": 24,
|
||||
"span": {
|
||||
"end": 484,
|
||||
"start": 462
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "Int",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "return",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 25,
|
||||
"span": {
|
||||
"end": 497,
|
||||
"start": 487
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "return",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "call.exit",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 26,
|
||||
"span": null
|
||||
}
|
||||
],
|
||||
"limits": {
|
||||
"max_bytes": 33554432,
|
||||
"max_events": 100000
|
||||
},
|
||||
"run": {
|
||||
"entry": "root:control-flow@0.1.0::index.mq.md::main",
|
||||
"id": "29-1795354081718410176",
|
||||
"status": "ok"
|
||||
},
|
||||
"schema": "marqdo.trace",
|
||||
"schema_version": 2,
|
||||
"source": {
|
||||
"analysis_digest": "sha256:392c82598cdd9d649951133df9a364d85bca7036aa653a4139aab190e9040af4",
|
||||
"root_id": "root:control-flow@0.1.0"
|
||||
},
|
||||
"truncated": null
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"command": "run",
|
||||
"diagnostics": [],
|
||||
"stderr": "",
|
||||
"stdout": "0\n0\n2\n",
|
||||
"success": true,
|
||||
"trace": [
|
||||
{
|
||||
"duration_micros": 10,
|
||||
"module": "root:control-flow@0.1.0::index.mq.md",
|
||||
"op": "resource.open",
|
||||
"result": "ok",
|
||||
"seq": 4,
|
||||
"span": {
|
||||
"end": 304,
|
||||
"start": 261
|
||||
}
|
||||
}
|
||||
],
|
||||
"value": {
|
||||
"decimal": "3",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
{
|
||||
"events": [
|
||||
{
|
||||
"detail": null,
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "call.enter",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 0,
|
||||
"span": null
|
||||
},
|
||||
{
|
||||
"detail": "initial_pages=1 max_pages=1",
|
||||
"function_id": null,
|
||||
"kind": "memory.new",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 1,
|
||||
"span": {
|
||||
"end": 230,
|
||||
"start": 214
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "byte",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "memory.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 2,
|
||||
"span": {
|
||||
"end": 243,
|
||||
"start": 234
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio descriptor=stdout",
|
||||
"function_id": null,
|
||||
"kind": "resource.open",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 3,
|
||||
"span": {
|
||||
"end": 304,
|
||||
"start": 261
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "ok",
|
||||
"duration_micros": 10,
|
||||
"kind": "effect",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"operation": "resource.open",
|
||||
"seq": 4,
|
||||
"span": {
|
||||
"end": 304,
|
||||
"start": 261
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "event_budget",
|
||||
"kind": "trace.truncated",
|
||||
"module_id": null,
|
||||
"seq": 5,
|
||||
"span": null
|
||||
}
|
||||
],
|
||||
"limits": {
|
||||
"max_bytes": 33554432,
|
||||
"max_events": 5
|
||||
},
|
||||
"run": {
|
||||
"entry": "root:control-flow@0.1.0::index.mq.md::main",
|
||||
"id": "31-1795354081721454068",
|
||||
"status": "ok"
|
||||
},
|
||||
"schema": "marqdo.trace",
|
||||
"schema_version": 2,
|
||||
"source": {
|
||||
"analysis_digest": "sha256:392c82598cdd9d649951133df9a364d85bca7036aa653a4139aab190e9040af4",
|
||||
"root_id": "root:control-flow@0.1.0"
|
||||
},
|
||||
"truncated": {
|
||||
"limit": 5,
|
||||
"reason": "event_budget",
|
||||
"written": 5
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"command": "run",
|
||||
"error": {
|
||||
"code": "call.arity",
|
||||
"column": null,
|
||||
"file": null,
|
||||
"frames": [],
|
||||
"line": null,
|
||||
"message": "`演示.main` is missing required argument `n`",
|
||||
"module_id": null,
|
||||
"origin": "source",
|
||||
"relative_path": null,
|
||||
"span": null
|
||||
},
|
||||
"stderr": "",
|
||||
"stdout": "",
|
||||
"success": false,
|
||||
"trace": []
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"events": [
|
||||
{
|
||||
"detail": null,
|
||||
"function_id": "root:mixed-modes@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "call.enter",
|
||||
"module_id": "root:mixed-modes@0.1.0::index.mq.md",
|
||||
"seq": 0,
|
||||
"span": null
|
||||
}
|
||||
],
|
||||
"limits": {
|
||||
"max_bytes": 33554432,
|
||||
"max_events": 100000
|
||||
},
|
||||
"run": {
|
||||
"entry": "root:mixed-modes@0.1.0::index.mq.md::main",
|
||||
"id": "12-1795317753068595848",
|
||||
"status": "call.arity"
|
||||
},
|
||||
"schema": "marqdo.trace",
|
||||
"schema_version": 2,
|
||||
"source": {
|
||||
"analysis_digest": "sha256:5b13d0cd2044cbe3d5d5f51145a9dd0015e2992400f803dad5f0e42214ce4959",
|
||||
"root_id": "root:mixed-modes@0.1.0"
|
||||
},
|
||||
"truncated": null
|
||||
}
|
||||
+183
-180
@@ -2,7 +2,8 @@
|
||||
//! unique terminal state, SSE-ready events, dedupe, grants and cancellation.
|
||||
//!
|
||||
//! The fake Core is a real executable (never a mocked trait) so argv, process
|
||||
//! lifecycle and trace files are exercised at the process boundary.
|
||||
//! lifecycle and the Observation v1 stdout/snapshot destinations are exercised at
|
||||
//! the process boundary.
|
||||
|
||||
use crate::common::{sha256_hex, FakeCore};
|
||||
use marqdo_view::execution::controller::{ExecutionConfig, ExecutionController, SseSubscription};
|
||||
@@ -12,12 +13,19 @@ use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
const ANALYSIS: &str = "tests/golden/analysis-v3/control-flow.json";
|
||||
const OBS_JSONL: &str = "tests/golden/observation-v1/control-flow.jsonl";
|
||||
const OBS_SNAPSHOT: &str = "tests/golden/observation-v1/control-flow.snapshot.json";
|
||||
const OBS_TRUNCATED_JSONL: &str = "tests/golden/observation-v1/control-flow.truncated.jsonl";
|
||||
const OBS_TRUNCATED_SNAPSHOT: &str =
|
||||
"tests/golden/observation-v1/control-flow.truncated.snapshot.json";
|
||||
|
||||
fn repo_root() -> PathBuf {
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
}
|
||||
|
||||
fn golden(name: &str) -> String {
|
||||
let path = repo_root().join("tests/golden/analysis-v2").join(name);
|
||||
let path = repo_root().join(name);
|
||||
std::fs::read_to_string(&path).unwrap_or_else(|err| panic!("read {path:?}: {err}"))
|
||||
}
|
||||
|
||||
@@ -35,14 +43,14 @@ fn fixture_with(
|
||||
name: &str,
|
||||
project_relative: &str,
|
||||
analysis: &str,
|
||||
run_json: &str,
|
||||
trace: Option<&str>,
|
||||
observation_jsonl: &str,
|
||||
observation_snapshot: Option<&str>,
|
||||
config: ExecutionConfig,
|
||||
) -> Fixture {
|
||||
let core = FakeCore::new(name);
|
||||
core.set_analysis(analysis);
|
||||
core.set_check_json(r#"{"command":"check","diagnostics":[],"errors":0,"success":true}"#);
|
||||
core.set_run(0, run_json, trace);
|
||||
core.set_observation(0, observation_jsonl, observation_snapshot);
|
||||
let project = repo_root().join(project_relative);
|
||||
let service = Arc::new(
|
||||
DocumentService::open(&project, Some(core.script.as_path()))
|
||||
@@ -57,19 +65,12 @@ fn fixture_with(
|
||||
}
|
||||
|
||||
fn control_flow(name: &str) -> Fixture {
|
||||
let analysis = golden("control-flow.json");
|
||||
let run =
|
||||
std::fs::read_to_string(repo_root().join("tests/golden/trace-v2/control-flow.run.json"))
|
||||
.expect("run golden");
|
||||
let trace =
|
||||
std::fs::read_to_string(repo_root().join("tests/golden/trace-v2/control-flow.trace.json"))
|
||||
.expect("trace golden");
|
||||
fixture_with(
|
||||
name,
|
||||
"examples/control-flow",
|
||||
&analysis,
|
||||
&run,
|
||||
Some(&trace),
|
||||
&golden(ANALYSIS),
|
||||
&golden(OBS_JSONL),
|
||||
Some(&golden(OBS_SNAPSHOT)),
|
||||
ExecutionConfig::default().with_timeout(10),
|
||||
)
|
||||
}
|
||||
@@ -106,7 +107,7 @@ fn is_terminal_data(data: &serde_json::Value) -> bool {
|
||||
.map(|state| {
|
||||
matches!(
|
||||
state,
|
||||
"succeeded" | "failed" | "cancelled" | "timed_out" | "unavailable"
|
||||
"succeeded" | "failed" | "cancelled" | "timed_out" | "unavailable" | "incomplete"
|
||||
)
|
||||
})
|
||||
.unwrap_or(false)
|
||||
@@ -159,9 +160,9 @@ fn wait_for_file(path: &Path) {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_entry_run_streams_accepted_running_and_succeeded_with_verified_trace() {
|
||||
fn explicit_entry_run_streams_accepted_running_and_verified_observation() {
|
||||
let fixture = control_flow("ctrl-success");
|
||||
let analysis = golden("control-flow.json");
|
||||
let analysis = golden(ANALYSIS);
|
||||
let body = request_body(
|
||||
&analysis,
|
||||
serde_json::json!({"kind": "entry"}),
|
||||
@@ -207,17 +208,26 @@ fn explicit_entry_run_streams_accepted_running_and_succeeded_with_verified_trace
|
||||
);
|
||||
assert_eq!(terminal["state"], "succeeded");
|
||||
assert_eq!(terminal["result"]["success"], true);
|
||||
assert_eq!(terminal["trace"]["status"], "verified");
|
||||
assert!(!terminal["trace"]["events"].as_array().unwrap().is_empty());
|
||||
assert_eq!(terminal["trace"]["stale"], false);
|
||||
// The fake Core's stderr/stdout were read through the adapter, not guessed.
|
||||
assert_eq!(terminal["result"]["observation_status"], "verified");
|
||||
let summary = terminal["observation_summary"]
|
||||
.as_object()
|
||||
.expect("observation summary");
|
||||
assert_eq!(summary["status"], "verified");
|
||||
assert!(!summary["events"].as_array().unwrap().is_empty());
|
||||
assert_eq!(terminal["result"]["stdout"], "0\n0\n2\n");
|
||||
let argv = fixture.core.last_args();
|
||||
assert!(argv.contains(&"--output".to_string()), "argv: {argv:?}");
|
||||
assert!(argv.contains(&"jsonl".to_string()), "argv: {argv:?}");
|
||||
assert!(
|
||||
argv.contains(&"--observation-file".to_string()),
|
||||
"argv: {argv:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn call_target_uses_the_call_subcommand_and_function_name() {
|
||||
let fixture = control_flow("ctrl-call");
|
||||
let analysis = golden("control-flow.json");
|
||||
let analysis = golden(ANALYSIS);
|
||||
let function_id = "root:control-flow@0.1.0::index.mq.md::演示.main";
|
||||
let body = request_body(
|
||||
&analysis,
|
||||
@@ -236,15 +246,22 @@ fn call_target_uses_the_call_subcommand_and_function_name() {
|
||||
.expect("subscribe");
|
||||
let (_events, terminal) = terminal_events(subscription);
|
||||
assert_eq!(terminal["state"], "succeeded");
|
||||
let argv = std::fs::read_to_string(fixture.core.dir.join("argv.txt")).unwrap_or_default();
|
||||
assert!(argv.contains("arg=call"), "argv: {argv}");
|
||||
assert!(argv.contains("arg=main"), "argv: {argv}");
|
||||
let argv = fixture.core.last_args();
|
||||
assert!(argv.iter().any(|arg| arg == "call"), "argv: {argv:?}");
|
||||
assert!(
|
||||
argv.iter().any(|arg| arg.contains("main")),
|
||||
"argv: {argv:?}"
|
||||
);
|
||||
assert!(
|
||||
!argv.iter().any(|arg| arg == "--trace-file"),
|
||||
"argv: {argv:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn same_client_request_id_is_idempotent_and_different_payload_conflicts() {
|
||||
let fixture = control_flow("ctrl-dedupe");
|
||||
let analysis = golden("control-flow.json");
|
||||
let analysis = golden(ANALYSIS);
|
||||
let body = request_body(
|
||||
&analysis,
|
||||
serde_json::json!({"kind": "entry"}),
|
||||
@@ -274,17 +291,9 @@ fn same_client_request_id_is_idempotent_and_different_payload_conflicts() {
|
||||
|
||||
#[test]
|
||||
fn second_run_is_busy_while_one_is_active_and_cancel_is_idempotent() {
|
||||
let analysis = golden("control-flow.json");
|
||||
let run = r#"{"command":"run","success":true,"value":{"type":"int","decimal":"1"}}"#;
|
||||
let fixture = fixture_with(
|
||||
"ctrl-cancel",
|
||||
"examples/control-flow",
|
||||
&analysis,
|
||||
run,
|
||||
None,
|
||||
ExecutionConfig::default().with_timeout(30),
|
||||
);
|
||||
let fixture = control_flow("ctrl-cancel");
|
||||
fixture.core.set_sleep_seconds(30);
|
||||
let analysis = golden(ANALYSIS);
|
||||
let body = request_body(
|
||||
&analysis,
|
||||
serde_json::json!({"kind": "entry"}),
|
||||
@@ -320,7 +329,6 @@ fn second_run_is_busy_while_one_is_active_and_cancel_is_idempotent() {
|
||||
state,
|
||||
RunState::CancelRequested | RunState::Cancelled
|
||||
));
|
||||
// Repeat cancel is idempotent.
|
||||
let _ = fixture
|
||||
.controller
|
||||
.cancel("session-a", &accepted.run_id)
|
||||
@@ -334,17 +342,7 @@ fn second_run_is_busy_while_one_is_active_and_cancel_is_idempotent() {
|
||||
assert_eq!(terminal["state"], "cancelled");
|
||||
let terminal_count = events
|
||||
.iter()
|
||||
.filter(|event| {
|
||||
event["state"]
|
||||
.as_str()
|
||||
.map(|state| {
|
||||
matches!(
|
||||
state,
|
||||
"succeeded" | "failed" | "cancelled" | "timed_out" | "unavailable"
|
||||
)
|
||||
})
|
||||
.unwrap_or(false)
|
||||
})
|
||||
.filter(|event| is_terminal_data(event))
|
||||
.count();
|
||||
assert_eq!(terminal_count, 1, "exactly one terminal state: {events:?}");
|
||||
assert!(started.elapsed() < Duration::from_secs(10));
|
||||
@@ -353,7 +351,7 @@ fn second_run_is_busy_while_one_is_active_and_cancel_is_idempotent() {
|
||||
#[test]
|
||||
fn cross_session_observation_is_rejected() {
|
||||
let fixture = control_flow("ctrl-session");
|
||||
let analysis = golden("control-flow.json");
|
||||
let analysis = golden(ANALYSIS);
|
||||
let body = request_body(
|
||||
&analysis,
|
||||
serde_json::json!({"kind": "entry"}),
|
||||
@@ -384,9 +382,9 @@ fn cross_session_observation_is_rejected() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stale_analysis_digest_is_rejected_before_any_process_starts() {
|
||||
let fixture = control_flow("ctrl-stale");
|
||||
let analysis = golden("control-flow.json");
|
||||
fn stale_request_digest_is_rejected_before_any_process_starts() {
|
||||
let fixture = control_flow("ctrl-stale-request");
|
||||
let analysis = golden(ANALYSIS);
|
||||
let mut body: serde_json::Value = serde_json::from_slice(&request_body(
|
||||
&analysis,
|
||||
serde_json::json!({"kind": "entry"}),
|
||||
@@ -401,13 +399,13 @@ fn stale_analysis_digest_is_rejected_before_any_process_starts() {
|
||||
.submit("session-a", body.to_string().as_bytes())
|
||||
.expect_err("stale digest must be rejected");
|
||||
assert_eq!(err.code(), "view.run_invalid");
|
||||
assert!(!fixture.core.dir.join("run-was-called").exists());
|
||||
assert!(!fixture.core.run_was_called());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_grants_are_mapped_to_explicit_cli_flags_and_pure_grants_are_rejected() {
|
||||
let fixture = control_flow("ctrl-grants");
|
||||
let analysis = golden("control-flow.json");
|
||||
let analysis = golden(ANALYSIS);
|
||||
let body = request_body(
|
||||
&analysis,
|
||||
serde_json::json!({"kind": "entry"}),
|
||||
@@ -425,19 +423,22 @@ fn project_grants_are_mapped_to_explicit_cli_flags_and_pure_grants_are_rejected(
|
||||
.expect("subscribe");
|
||||
let (_events, terminal) = terminal_events(subscription);
|
||||
assert_eq!(terminal["state"], "succeeded");
|
||||
let argv = std::fs::read_to_string(fixture.core.dir.join("argv.txt")).unwrap_or_default();
|
||||
assert!(argv.contains("arg=--mode\narg=project"), "argv: {argv}");
|
||||
let argv = fixture.core.last_args();
|
||||
assert!(
|
||||
argv.contains("arg=--allow-read\narg=data/**"),
|
||||
"argv: {argv}"
|
||||
argv.windows(2).any(|pair| pair == ["--mode", "project"]),
|
||||
"argv: {argv:?}"
|
||||
);
|
||||
assert!(
|
||||
argv.contains("arg=--allow-write\narg=out/*.txt"),
|
||||
"argv: {argv}"
|
||||
argv.windows(2)
|
||||
.any(|pair| pair == ["--allow-read", "data/**"]),
|
||||
"argv: {argv:?}"
|
||||
);
|
||||
assert!(
|
||||
argv.windows(2)
|
||||
.any(|pair| pair == ["--allow-write", "out/*.txt"]),
|
||||
"argv: {argv:?}"
|
||||
);
|
||||
assert!(!argv.contains("arg=--mode\narg=pure"));
|
||||
|
||||
// pure with grants is rejected by request validation before the Core runs.
|
||||
let pure_with_grants = request_body(
|
||||
&analysis,
|
||||
serde_json::json!({"kind": "entry"}),
|
||||
@@ -453,23 +454,18 @@ fn project_grants_are_mapped_to_explicit_cli_flags_and_pure_grants_are_rejected(
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_without_a_trace_file_succeeds_but_reports_unavailable_trace() {
|
||||
let analysis = golden("control-flow.json");
|
||||
let run = r#"{"command":"run","success":true,"value":{"type":"int","decimal":"7"},"stdout":"hi\n","stderr":"","diagnostics":[]}"#;
|
||||
let fixture = fixture_with(
|
||||
"ctrl-no-trace",
|
||||
"examples/control-flow",
|
||||
&analysis,
|
||||
run,
|
||||
None,
|
||||
ExecutionConfig::default().with_timeout(10),
|
||||
);
|
||||
fn missing_observation_stream_is_incomplete_never_success() {
|
||||
let fixture = control_flow("ctrl-no-observation");
|
||||
fixture
|
||||
.core
|
||||
.set_observation(0, "", Some(&golden(OBS_SNAPSHOT)));
|
||||
let analysis = golden(ANALYSIS);
|
||||
let body = request_body(
|
||||
&analysis,
|
||||
serde_json::json!({"kind": "entry"}),
|
||||
"pure",
|
||||
serde_json::json!({}),
|
||||
"req-no-trace",
|
||||
"req-no-observation",
|
||||
);
|
||||
let accepted = fixture
|
||||
.controller
|
||||
@@ -480,62 +476,26 @@ fn run_without_a_trace_file_succeeds_but_reports_unavailable_trace() {
|
||||
.subscribe("session-a", &accepted.run_id, Some(0))
|
||||
.expect("subscribe");
|
||||
let (_events, terminal) = terminal_events(subscription);
|
||||
assert_eq!(terminal["state"], "succeeded");
|
||||
assert_eq!(terminal["result"]["value_text"], "Int(7)");
|
||||
assert_eq!(terminal["trace"], serde_json::Value::Null);
|
||||
assert_eq!(terminal["result"]["trace_status"], "unavailable");
|
||||
assert!(!fixture.core.dir.join("trace.json").exists() || terminal["trace"].is_null());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn event_frames_use_the_view_run_events_schema_and_numeric_ids() {
|
||||
let fixture = control_flow("ctrl-frames");
|
||||
let analysis = golden("control-flow.json");
|
||||
let body = request_body(
|
||||
&analysis,
|
||||
serde_json::json!({"kind": "entry"}),
|
||||
"pure",
|
||||
serde_json::json!({}),
|
||||
"req-frames",
|
||||
assert_eq!(terminal["state"], "failed");
|
||||
assert_eq!(
|
||||
terminal["result"]["error"]["code"],
|
||||
"view.observation_invalid"
|
||||
);
|
||||
let accepted = fixture
|
||||
.controller
|
||||
.submit("session-a", &body)
|
||||
.expect("accepted");
|
||||
let subscription = fixture
|
||||
.controller
|
||||
.subscribe("session-a", &accepted.run_id, None)
|
||||
.expect("subscribe");
|
||||
let (events, terminal) = terminal_events(subscription);
|
||||
assert_eq!(terminal["schema"], "marqdo.view-run-events");
|
||||
assert_eq!(terminal["schema_version"], 1);
|
||||
assert_eq!(terminal["run_id"], accepted.run_id.as_str());
|
||||
assert!(!events.is_empty());
|
||||
assert_ne!(terminal["result"]["success"], true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn source_edit_during_a_run_marks_the_result_stale_and_drops_anchor_ids() {
|
||||
let project = crate::common::TempProject::new("exec-stale");
|
||||
let source = std::fs::read_to_string(repo_root().join("examples/control-flow/index.mq.md"))
|
||||
.expect("example source");
|
||||
project.write(
|
||||
"marqdo.yaml",
|
||||
"project:\n name: control-flow\n version: 0.1.0\n",
|
||||
);
|
||||
project.write("index.mq.md", &source);
|
||||
let analysis = golden("control-flow.json");
|
||||
let run =
|
||||
std::fs::read_to_string(repo_root().join("tests/golden/trace-v2/control-flow.run.json"))
|
||||
.expect("run golden");
|
||||
let trace =
|
||||
std::fs::read_to_string(repo_root().join("tests/golden/trace-v2/control-flow.trace.json"))
|
||||
.expect("trace golden");
|
||||
let core = FakeCore::new("exec-stale-core");
|
||||
let project = crate::common::TempProject::new("ctrl-stale-source");
|
||||
project.marqdo_project(&golden("examples/control-flow/index.mq.md"));
|
||||
let analysis = golden(ANALYSIS);
|
||||
let core = FakeCore::new("ctrl-stale-source");
|
||||
core.set_analysis(&analysis);
|
||||
core.set_run(0, &run, Some(&trace));
|
||||
core.set_check_json(r#"{"command":"check","diagnostics":[],"errors":0,"success":true}"#);
|
||||
core.set_observation(0, &golden(OBS_JSONL), Some(&golden(OBS_SNAPSHOT)));
|
||||
core.set_sleep_seconds(1);
|
||||
let service = Arc::new(
|
||||
DocumentService::open(&project.dir, Some(core.script.as_path())).expect("service"),
|
||||
DocumentService::open(&project.dir, Some(core.script.as_path())).expect("open service"),
|
||||
);
|
||||
let controller = Arc::new(ExecutionController::new(
|
||||
Arc::clone(&service),
|
||||
@@ -550,51 +510,93 @@ fn source_edit_during_a_run_marks_the_result_stale_and_drops_anchor_ids() {
|
||||
);
|
||||
let accepted = controller.submit("session-a", &body).expect("accepted");
|
||||
wait_for_file(&core.dir.join("run-was-called"));
|
||||
project.write("index.mq.md", &format!("{source}\n\n追加的编辑。\n"));
|
||||
project.write(
|
||||
"index.mq.md",
|
||||
&format!(
|
||||
"{}\n\n<!-- changed -->\n",
|
||||
golden("examples/control-flow/index.mq.md")
|
||||
),
|
||||
);
|
||||
let subscription = controller
|
||||
.subscribe("session-a", &accepted.run_id, Some(0))
|
||||
.expect("subscribe");
|
||||
let (_events, terminal) = terminal_events(subscription);
|
||||
assert_eq!(terminal["state"], "succeeded");
|
||||
assert_eq!(terminal["result"]["stale"], true);
|
||||
assert_eq!(terminal["trace"]["status"], "verified");
|
||||
assert_eq!(terminal["trace"]["stale"], true);
|
||||
let events = terminal["trace"]["events"].as_array().expect("events");
|
||||
assert!(!events.is_empty());
|
||||
assert!(
|
||||
events
|
||||
.iter()
|
||||
.all(|event| event["anchor"].is_null() && event["source_id"].is_null()),
|
||||
"stale runs must not anchor to the current text"
|
||||
assert_eq!(terminal["state"], "failed");
|
||||
assert_eq!(
|
||||
terminal["result"]["error"]["code"],
|
||||
"view.observation_stale"
|
||||
);
|
||||
assert_eq!(terminal["result"]["observation_status"], "stale");
|
||||
assert_ne!(terminal["result"]["success"], true);
|
||||
let summary = terminal["observation_summary"]
|
||||
.as_object()
|
||||
.expect("stale summary");
|
||||
assert_eq!(summary["status"], "stale");
|
||||
assert!(summary["events"].as_array().unwrap().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trace_with_a_mismatched_digest_is_reported_invalid_but_the_run_still_succeeds() {
|
||||
let analysis = golden("control-flow.json");
|
||||
let run =
|
||||
std::fs::read_to_string(repo_root().join("tests/golden/trace-v2/control-flow.run.json"))
|
||||
.expect("run golden");
|
||||
let mut trace: serde_json::Value = serde_json::from_str(
|
||||
&std::fs::read_to_string(repo_root().join("tests/golden/trace-v2/control-flow.trace.json"))
|
||||
.expect("trace golden"),
|
||||
)
|
||||
.expect("trace json");
|
||||
trace["source"]["analysis_digest"] = serde_json::json!(format!("sha256:{}", "0".repeat(64)));
|
||||
let fixture = fixture_with(
|
||||
"exec-trace-invalid",
|
||||
"examples/control-flow",
|
||||
&analysis,
|
||||
&run,
|
||||
Some(&trace.to_string()),
|
||||
ExecutionConfig::default().with_timeout(10),
|
||||
fn observation_with_a_mismatched_digest_is_rejected_as_stale() {
|
||||
let fixture = control_flow("ctrl-observation-mismatch");
|
||||
let mut lines: Vec<String> = golden(OBS_JSONL).lines().map(str::to_string).collect();
|
||||
for line in &mut lines {
|
||||
if line.contains("\"kind\":\"run.started\"") {
|
||||
*line = line.replace(
|
||||
&format!(
|
||||
"\"analysis_digest\":\"sha256:{}\"",
|
||||
sha256_hex(&golden(ANALYSIS).into_bytes())
|
||||
),
|
||||
&format!("\"analysis_digest\":\"sha256:{}\"", "0".repeat(64)),
|
||||
);
|
||||
}
|
||||
}
|
||||
fixture.core.set_observation(
|
||||
0,
|
||||
&format!("{}\n", lines.join("\n")),
|
||||
Some(&golden(OBS_SNAPSHOT)),
|
||||
);
|
||||
let analysis = golden(ANALYSIS);
|
||||
let body = request_body(
|
||||
&analysis,
|
||||
serde_json::json!({"kind": "entry"}),
|
||||
"pure",
|
||||
serde_json::json!({}),
|
||||
"req-trace-invalid",
|
||||
"req-observation-mismatch",
|
||||
);
|
||||
let accepted = fixture
|
||||
.controller
|
||||
.submit("session-a", &body)
|
||||
.expect("accepted");
|
||||
let subscription = fixture
|
||||
.controller
|
||||
.subscribe("session-a", &accepted.run_id, Some(0))
|
||||
.expect("subscribe");
|
||||
let (_events, terminal) = terminal_events(subscription);
|
||||
assert_eq!(terminal["state"], "failed");
|
||||
assert_eq!(
|
||||
terminal["result"]["error"]["code"],
|
||||
"view.observation_stale"
|
||||
);
|
||||
assert_ne!(terminal["result"]["observation_status"], "verified");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn truncated_observation_is_explicit_and_never_labelled_complete() {
|
||||
let fixture = fixture_with(
|
||||
"ctrl-truncated",
|
||||
"examples/control-flow",
|
||||
&golden(ANALYSIS),
|
||||
&golden(OBS_TRUNCATED_JSONL),
|
||||
Some(&golden(OBS_TRUNCATED_SNAPSHOT)),
|
||||
ExecutionConfig::default().with_timeout(10),
|
||||
);
|
||||
let analysis = golden(ANALYSIS);
|
||||
let body = request_body(
|
||||
&analysis,
|
||||
serde_json::json!({"kind": "entry"}),
|
||||
"pure",
|
||||
serde_json::json!({}),
|
||||
"req-truncated",
|
||||
);
|
||||
let accepted = fixture
|
||||
.controller
|
||||
@@ -606,35 +608,27 @@ fn trace_with_a_mismatched_digest_is_reported_invalid_but_the_run_still_succeeds
|
||||
.expect("subscribe");
|
||||
let (_events, terminal) = terminal_events(subscription);
|
||||
assert_eq!(terminal["state"], "succeeded");
|
||||
assert_eq!(terminal["trace"]["status"], "invalid");
|
||||
assert!(terminal["trace"]["events"].is_null());
|
||||
assert_eq!(terminal["result"]["observation_status"], "truncated");
|
||||
assert_eq!(terminal["result"]["observation_truncated"], true);
|
||||
assert_eq!(terminal["result"]["output_complete"], false);
|
||||
let summary = terminal["observation_summary"]
|
||||
.as_object()
|
||||
.expect("observation summary");
|
||||
assert_eq!(summary["state"], "truncated");
|
||||
assert_eq!(summary["truncated"]["reason"], "event_budget");
|
||||
assert_eq!(summary["truncated"]["limit"], 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn truncated_trace_is_marked_without_claiming_complete_coverage() {
|
||||
let analysis = golden("control-flow.json");
|
||||
let run = std::fs::read_to_string(
|
||||
repo_root().join("tests/golden/trace-v2/control-flow.truncated.run.json"),
|
||||
)
|
||||
.expect("run golden");
|
||||
let trace = std::fs::read_to_string(
|
||||
repo_root().join("tests/golden/trace-v2/control-flow.truncated.trace.json"),
|
||||
)
|
||||
.expect("trace golden");
|
||||
let fixture = fixture_with(
|
||||
"exec-trace-truncated",
|
||||
"examples/control-flow",
|
||||
&analysis,
|
||||
&run,
|
||||
Some(&trace),
|
||||
ExecutionConfig::default().with_timeout(10),
|
||||
);
|
||||
fn event_frames_use_the_view_run_events_schema_and_numeric_ids() {
|
||||
let fixture = control_flow("ctrl-events");
|
||||
let analysis = golden(ANALYSIS);
|
||||
let body = request_body(
|
||||
&analysis,
|
||||
serde_json::json!({"kind": "entry"}),
|
||||
"pure",
|
||||
serde_json::json!({}),
|
||||
"req-trace-truncated",
|
||||
"req-events",
|
||||
);
|
||||
let accepted = fixture
|
||||
.controller
|
||||
@@ -642,11 +636,20 @@ fn truncated_trace_is_marked_without_claiming_complete_coverage() {
|
||||
.expect("accepted");
|
||||
let subscription = fixture
|
||||
.controller
|
||||
.subscribe("session-a", &accepted.run_id, Some(0))
|
||||
.subscribe("session-a", &accepted.run_id, None)
|
||||
.expect("subscribe");
|
||||
let (_events, terminal) = terminal_events(subscription);
|
||||
let (events, terminal) = terminal_events(subscription);
|
||||
assert!(events.iter().all(|event| {
|
||||
event["schema"] == "marqdo.view-run-events" && event["schema_version"] == 1
|
||||
}));
|
||||
assert!(events
|
||||
.iter()
|
||||
.all(|event| event["run_id"] == accepted.run_id));
|
||||
assert!(events.iter().all(|event| event["seq"].as_u64().is_some()));
|
||||
let observation_frames = events
|
||||
.iter()
|
||||
.filter(|event| event.get("observation").is_some())
|
||||
.count();
|
||||
assert!(observation_frames > 0, "events: {events:?}");
|
||||
assert_eq!(terminal["state"], "succeeded");
|
||||
assert_eq!(terminal["trace"]["status"], "verified");
|
||||
assert_eq!(terminal["trace"]["truncated"]["reason"], "event_budget");
|
||||
assert_eq!(terminal["trace"]["truncated"]["limit"], 5);
|
||||
}
|
||||
@@ -25,7 +25,7 @@ fn exported_dir(name: &str) -> PathBuf {
|
||||
|
||||
fn fake_core_for_welcome(name: &str) -> FakeCore {
|
||||
let core = FakeCore::new(name);
|
||||
let golden = std::fs::read(repo_root().join("tests/golden/analysis-v2/welcome.json")).unwrap();
|
||||
let golden = std::fs::read(repo_root().join("tests/golden/analysis-v3/welcome.json")).unwrap();
|
||||
core.set_analysis(std::str::from_utf8(&golden).unwrap());
|
||||
core
|
||||
}
|
||||
@@ -141,7 +141,7 @@ fn export_never_executes_side_effects() {
|
||||
let out = exported_dir("export-no-exec");
|
||||
let core = FakeCore::new("export-core-noexec");
|
||||
let golden =
|
||||
std::fs::read(repo_root().join("tests/golden/analysis-v2/control-flow.json")).unwrap();
|
||||
std::fs::read(repo_root().join("tests/golden/analysis-v3/control-flow.json")).unwrap();
|
||||
core.set_analysis(std::str::from_utf8(&golden).unwrap());
|
||||
let output = export(&project, &out, &[], Some(&core));
|
||||
assert_eq!(
|
||||
@@ -168,7 +168,7 @@ fn no_annotations_keeps_prose_but_removes_anchors() {
|
||||
let out = exported_dir("export-no-annotations");
|
||||
let core = FakeCore::new("export-core-noannot");
|
||||
let golden =
|
||||
std::fs::read(repo_root().join("tests/golden/analysis-v2/mixed-modes.json")).unwrap();
|
||||
std::fs::read(repo_root().join("tests/golden/analysis-v3/mixed-modes.json")).unwrap();
|
||||
core.set_analysis(std::str::from_utf8(&golden).unwrap());
|
||||
let output = export(&project, &out, &["--no-annotations"], Some(&core));
|
||||
assert_eq!(
|
||||
@@ -291,7 +291,7 @@ fn exported_html_has_no_remote_subresources() {
|
||||
let out = exported_dir("export-offline");
|
||||
let core = FakeCore::new("export-core-offline");
|
||||
let golden =
|
||||
std::fs::read(repo_root().join("tests/golden/analysis-v2/tables-math.json")).unwrap();
|
||||
std::fs::read(repo_root().join("tests/golden/analysis-v3/tables-math.json")).unwrap();
|
||||
core.set_analysis(std::str::from_utf8(&golden).unwrap());
|
||||
let output = export(&project, &out, &[], Some(&core));
|
||||
assert_eq!(output.status.code(), Some(0));
|
||||
|
||||
@@ -10,24 +10,22 @@ use crate::common::http::{
|
||||
};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
const RUN_GOLDEN: &str = "tests/golden/trace-v2/control-flow.run.json";
|
||||
const TRACE_GOLDEN: &str = "tests/golden/trace-v2/control-flow.trace.json";
|
||||
const ANALYSIS_GOLDEN: &str = "tests/golden/analysis-v2/control-flow.json";
|
||||
const OBS_JSONL: &str = "tests/golden/observation-v1/control-flow.jsonl";
|
||||
const OBS_SNAPSHOT: &str = "tests/golden/observation-v1/control-flow.snapshot.json";
|
||||
const ANALYSIS_GOLDEN: &str = "tests/golden/analysis-v3/control-flow.json";
|
||||
|
||||
fn control_flow() -> TestServer {
|
||||
http::start(
|
||||
"examples/control-flow",
|
||||
ANALYSIS_GOLDEN,
|
||||
Some(RUN_GOLDEN),
|
||||
Some(TRACE_GOLDEN),
|
||||
Some((OBS_JSONL, OBS_SNAPSHOT)),
|
||||
)
|
||||
}
|
||||
|
||||
fn welcome() -> TestServer {
|
||||
http::start(
|
||||
"examples/welcome",
|
||||
"tests/golden/analysis-v2/welcome.json",
|
||||
None,
|
||||
"tests/golden/analysis-v3/welcome.json",
|
||||
None,
|
||||
)
|
||||
}
|
||||
@@ -160,8 +158,11 @@ fn explicit_run_streams_sse_accepted_running_and_terminal_with_verified_trace()
|
||||
assert_eq!(data["run_id"], run_id.as_str());
|
||||
assert_eq!(data["state"], "succeeded");
|
||||
assert_eq!(data["result"]["success"], true);
|
||||
assert_eq!(data["trace"]["status"], "verified");
|
||||
assert!(!data["trace"]["events"].as_array().unwrap().is_empty());
|
||||
assert_eq!(data["observation_summary"]["status"], "verified");
|
||||
assert!(!data["observation_summary"]["events"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.is_empty());
|
||||
let states: Vec<_> = frames
|
||||
.iter()
|
||||
.filter_map(|frame| frame.data.as_ref().and_then(|data| data["state"].as_str()))
|
||||
@@ -277,8 +278,7 @@ fn cancel_is_idempotent_and_yields_one_terminal_state() {
|
||||
let server = http::start_with_env(
|
||||
"examples/control-flow",
|
||||
ANALYSIS_GOLDEN,
|
||||
Some(RUN_GOLDEN),
|
||||
Some(TRACE_GOLDEN),
|
||||
Some((OBS_JSONL, OBS_SNAPSHOT)),
|
||||
&[("MARQDO_VIEW_SSE_HEARTBEAT_SECS", "1")],
|
||||
);
|
||||
server.core.set_sleep_seconds(10);
|
||||
@@ -333,7 +333,12 @@ fn cancel_is_idempotent_and_yields_one_terminal_state() {
|
||||
.map(|state| {
|
||||
matches!(
|
||||
state,
|
||||
"succeeded" | "failed" | "cancelled" | "timed_out" | "unavailable"
|
||||
"succeeded"
|
||||
| "failed"
|
||||
| "cancelled"
|
||||
| "timed_out"
|
||||
| "unavailable"
|
||||
| "incomplete"
|
||||
)
|
||||
})
|
||||
.unwrap_or(false)
|
||||
@@ -352,8 +357,7 @@ fn sse_heartbeats_keep_a_slow_job_connected() {
|
||||
let server = http::start_with_env(
|
||||
"examples/control-flow",
|
||||
ANALYSIS_GOLDEN,
|
||||
Some(RUN_GOLDEN),
|
||||
Some(TRACE_GOLDEN),
|
||||
Some((OBS_JSONL, OBS_SNAPSHOT)),
|
||||
&[("MARQDO_VIEW_SSE_HEARTBEAT_SECS", "1")],
|
||||
);
|
||||
server.core.set_sleep_seconds(3);
|
||||
@@ -386,8 +390,7 @@ fn sse_heartbeats_keep_a_slow_job_connected() {
|
||||
fn document_without_main_is_rejected_without_running_another_function() {
|
||||
let server = http::start(
|
||||
"examples/tables-math",
|
||||
"tests/golden/analysis-v2/tables-math.json",
|
||||
None,
|
||||
"tests/golden/analysis-v3/tables-math.json",
|
||||
None,
|
||||
);
|
||||
let (session, _) = open_session(&server, "/");
|
||||
@@ -408,8 +411,7 @@ fn at_most_two_sse_observers_per_run() {
|
||||
let server = http::start_with_env(
|
||||
"examples/control-flow",
|
||||
ANALYSIS_GOLDEN,
|
||||
Some(RUN_GOLDEN),
|
||||
Some(TRACE_GOLDEN),
|
||||
Some((OBS_JSONL, OBS_SNAPSHOT)),
|
||||
&[("MARQDO_VIEW_SSE_HEARTBEAT_SECS", "1")],
|
||||
);
|
||||
server.core.set_sleep_seconds(5);
|
||||
|
||||
+102
-58
@@ -1,47 +1,81 @@
|
||||
//! Rendering contract tests: one renderer, safe Markdown, exact source view,
|
||||
//! verified semantic annotations and Live/Export link differences.
|
||||
//! verified Analysis v3 annotations and Live/Export link differences.
|
||||
|
||||
use marqdo_view::config::ViewConfig;
|
||||
use marqdo_view::protocol::analysis_v2 as semantic;
|
||||
use marqdo_view::reader::assemble::{self as assemble, BuildInput};
|
||||
use marqdo_view::protocol::analysis_v3;
|
||||
use marqdo_view::reader::assemble::{build, BuildInput};
|
||||
use marqdo_view::reader::markdown::{DocumentIdentity, DocumentModel};
|
||||
use marqdo_view::reader::model::{Navigation, SourceStatus};
|
||||
use marqdo_view::reader::render::{ReaderRenderer, RenderContext};
|
||||
use marqdo_view::reader::source::{Project, SafeRelativePath};
|
||||
|
||||
fn example(name: &str) -> (marqdo_view::reader::model::PresentationModel, String) {
|
||||
let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("examples")
|
||||
.join(name);
|
||||
let project = Project::open(&root).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let source = project.read_source_text(&entry).unwrap();
|
||||
let document = DocumentModel::parse(source.clone(), DocumentIdentity::placeholder(&entry));
|
||||
let golden_name = name;
|
||||
let golden = std::fs::read(
|
||||
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("tests/golden/analysis-v2")
|
||||
.join(format!("{golden_name}.json")),
|
||||
)
|
||||
.unwrap_or_else(|err| panic!("missing golden for {name}: {err}"));
|
||||
let verified =
|
||||
semantic::verify_analysis(&golden, &source, &document.source_index, entry.as_str())
|
||||
.unwrap_or_else(|err| panic!("golden does not verify for {name}: {err}"));
|
||||
fn repo_root() -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
}
|
||||
|
||||
fn example(
|
||||
name: &str,
|
||||
entry: &str,
|
||||
golden: &str,
|
||||
) -> (marqdo_view::reader::model::PresentationModel, String) {
|
||||
let project = Project::open(&repo_root().join("examples").join(name)).unwrap();
|
||||
let analysis = std::fs::read(repo_root().join(golden)).unwrap();
|
||||
let verified = analysis_v3::verify_analysis(&analysis, entry, None)
|
||||
.unwrap_or_else(|err| panic!("golden does not verify for {name}: {err}"));
|
||||
let source = verified.projection.source.clone();
|
||||
assert_eq!(
|
||||
verified.projection.source_digest,
|
||||
marqdo_view::reader::source::sha256_hex(source.as_bytes())
|
||||
);
|
||||
let entry_path = SafeRelativePath::parse(entry).unwrap();
|
||||
let document = DocumentModel::parse(source.clone(), DocumentIdentity::placeholder(&entry_path));
|
||||
let config = ViewConfig::load(project.root()).unwrap_or_default();
|
||||
let navigation = Navigation::from_project(&project, &config, &entry);
|
||||
let model = assemble::build(BuildInput {
|
||||
let navigation = Navigation::from_project(&project, &config, &entry_path);
|
||||
let model = build(BuildInput {
|
||||
document,
|
||||
analysis: Some(&verified),
|
||||
status: SourceStatus::StaticOk,
|
||||
status_note: None,
|
||||
diagnostics: Vec::new(),
|
||||
navigation,
|
||||
core_version: Some("3.0.0-beta.1".to_string()),
|
||||
core_version: Some("3.0.0-rc.4".to_string()),
|
||||
run: None,
|
||||
});
|
||||
(model, source)
|
||||
}
|
||||
|
||||
fn control_flow() -> (marqdo_view::reader::model::PresentationModel, String) {
|
||||
example(
|
||||
"control-flow",
|
||||
"index.mq.md",
|
||||
"tests/golden/analysis-v3/control-flow.json",
|
||||
)
|
||||
}
|
||||
|
||||
fn mixed_modes() -> (marqdo_view::reader::model::PresentationModel, String) {
|
||||
example(
|
||||
"mixed-modes",
|
||||
"index.mq.md",
|
||||
"tests/golden/analysis-v3/mixed-modes.json",
|
||||
)
|
||||
}
|
||||
|
||||
fn tables_math() -> (marqdo_view::reader::model::PresentationModel, String) {
|
||||
example(
|
||||
"tables-math",
|
||||
"index.mq.md",
|
||||
"tests/golden/analysis-v3/tables-math.json",
|
||||
)
|
||||
}
|
||||
|
||||
fn welcome() -> (marqdo_view::reader::model::PresentationModel, String) {
|
||||
example(
|
||||
"welcome",
|
||||
"00-welcome.mq.md",
|
||||
"tests/golden/analysis-v3/welcome.json",
|
||||
)
|
||||
}
|
||||
|
||||
fn render_live(model: &marqdo_view::reader::model::PresentationModel) -> String {
|
||||
ReaderRenderer::new()
|
||||
.render(model, &RenderContext::live())
|
||||
@@ -60,8 +94,7 @@ fn heading_ids(html: &str) -> Vec<String> {
|
||||
let Some(after_tag) = part.split_once(' ') else {
|
||||
continue;
|
||||
};
|
||||
let rest = after_tag.1;
|
||||
if let Some(id_part) = rest.split_once("id=\"") {
|
||||
if let Some(id_part) = after_tag.1.split_once("id=\"") {
|
||||
if let Some((id, _)) = id_part.1.split_once('"') {
|
||||
ids.push(id.to_string());
|
||||
}
|
||||
@@ -72,7 +105,7 @@ fn heading_ids(html: &str) -> Vec<String> {
|
||||
|
||||
#[test]
|
||||
fn page_has_exactly_one_theme_and_one_script() {
|
||||
let (model, _) = example("mixed-modes");
|
||||
let (model, _) = mixed_modes();
|
||||
let html = render_live(&model);
|
||||
assert_eq!(html.matches("<link rel=\"stylesheet\"").count(), 1);
|
||||
assert_eq!(
|
||||
@@ -84,14 +117,13 @@ fn page_has_exactly_one_theme_and_one_script() {
|
||||
assert!(html.contains("Content-Security-Policy"));
|
||||
assert!(html.contains("default-src 'none'"));
|
||||
assert!(html.contains("data-live=\"true\""));
|
||||
// The one source of prose is the Markdown document itself.
|
||||
assert!(html.contains("计算笔记"));
|
||||
assert!(html.contains("静态阅读"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn semantic_annotations_come_from_analysis_and_are_unique() {
|
||||
let (model, _) = example("mixed-modes");
|
||||
let (model, _) = mixed_modes();
|
||||
let html = render_live(&model);
|
||||
assert!(html.contains("data-source-status=\"static-ok\""));
|
||||
assert!(html.contains("data-statement-kind=\"return\""));
|
||||
@@ -109,31 +141,29 @@ fn semantic_annotations_come_from_analysis_and_are_unique() {
|
||||
|
||||
#[test]
|
||||
fn tables_math_and_code_are_inert_and_readable() {
|
||||
let (model, source) = example("tables-math");
|
||||
let (model, source) = tables_math();
|
||||
let html = render_live(&model);
|
||||
assert!(html.contains("<table>"));
|
||||
assert!(html.contains("mq-table-wrap"));
|
||||
assert!(html.contains("mq-math-block"));
|
||||
assert!(html.contains("代码围栏永远是惰性资源"));
|
||||
assert!(html.contains("mq-codeblock"));
|
||||
// Inert resources are never executed: no run controls are enabled.
|
||||
assert!(html.contains("data-live=\"true\""));
|
||||
assert!(!html.contains("RUNNING"));
|
||||
// Source is preserved exactly in the textarea (escaped only).
|
||||
assert!(source.contains("```python"));
|
||||
assert!(html.contains("mq-raw-source"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn welcome_hero_only_when_configured() {
|
||||
let (welcome, _) = example("welcome");
|
||||
let (welcome, _) = welcome();
|
||||
let html = render_live(&welcome);
|
||||
assert!(welcome.navigation.welcome);
|
||||
assert!(html.contains("mq-welcome"));
|
||||
assert!(html.contains("WELCOME TO"));
|
||||
assert!(html.contains("代码即文档 · 文档即知识库 · 知识即可执行"));
|
||||
|
||||
let (ordinary, _) = example("tables-math");
|
||||
let (ordinary, _) = tables_math();
|
||||
let html = render_live(&ordinary);
|
||||
assert!(!ordinary.navigation.welcome);
|
||||
assert!(!html.contains("mq-welcome"));
|
||||
@@ -141,25 +171,23 @@ fn welcome_hero_only_when_configured() {
|
||||
|
||||
#[test]
|
||||
fn live_and_static_share_content_but_rewrite_links() {
|
||||
let (model, _) = example("welcome");
|
||||
let (model, _) = welcome();
|
||||
let live = render_live(&model);
|
||||
let static_site = render_static(&model, 0);
|
||||
assert!(live.contains("/file?path=guide.mq.md"));
|
||||
assert!(static_site.contains("pages/guide.mq.md.html"));
|
||||
assert!(!static_site.contains("/file?path="));
|
||||
// Same prose and semantics.
|
||||
for needle in ["欢迎来到 Marqdo", "代码即文档", "mq-document"] {
|
||||
assert!(live.contains(needle));
|
||||
assert!(static_site.contains(needle));
|
||||
assert!(live.contains(needle), "live misses {needle}");
|
||||
assert!(static_site.contains(needle), "static misses {needle}");
|
||||
}
|
||||
// Assets are relative from the site root.
|
||||
assert!(static_site.contains("href=\"assets/reader."));
|
||||
assert!(live.contains("href=\"/assets/reader."));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn static_pages_use_parent_relative_assets_and_links() {
|
||||
let (model, _) = example("welcome");
|
||||
let (model, _) = welcome();
|
||||
let html = render_static(&model, 1);
|
||||
assert!(html.contains("href=\"../assets/reader."));
|
||||
assert!(html.contains("../pages/guide.mq.md.html"));
|
||||
@@ -193,17 +221,13 @@ fn malicious_markdown_cannot_inject_markup_or_scripts() {
|
||||
source_sha256: String::new(),
|
||||
},
|
||||
);
|
||||
let project = Project::open(
|
||||
&std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("examples/tables-math"),
|
||||
)
|
||||
.unwrap();
|
||||
let config = ViewConfig::default();
|
||||
let project = Project::open(&repo_root().join("examples/tables-math")).unwrap();
|
||||
let navigation = Navigation::from_project(
|
||||
&project,
|
||||
&config,
|
||||
&ViewConfig::default(),
|
||||
&SafeRelativePath::parse("index.mq.md").unwrap(),
|
||||
);
|
||||
let model = assemble::build(BuildInput {
|
||||
let model = build(BuildInput {
|
||||
document,
|
||||
analysis: None,
|
||||
status: SourceStatus::CoreUnavailable,
|
||||
@@ -219,10 +243,7 @@ fn malicious_markdown_cannot_inject_markup_or_scripts() {
|
||||
assert!(!html.contains("<svg onload"));
|
||||
assert!(!html.contains("href=\"javascript:"));
|
||||
assert!(!html.contains("href=\"data:text/html"));
|
||||
// Ordinary page chrome (logo, dock icons) is allowed, but no tag carries an
|
||||
// attacker-supplied event handler.
|
||||
assert!(!html.contains("onerror=\"") && !html.contains("onload=\""));
|
||||
// The exact source is still available in the source pane, safely escaped.
|
||||
assert!(html.contains("<script>alert"));
|
||||
assert!(html.contains("https://example.com/ok"));
|
||||
assert!(html.contains("已忽略原始 HTML"));
|
||||
@@ -231,29 +252,26 @@ fn malicious_markdown_cannot_inject_markup_or_scripts() {
|
||||
|
||||
#[test]
|
||||
fn rendering_is_deterministic() {
|
||||
let (model, _) = example("control-flow");
|
||||
let first = render_live(&model);
|
||||
let second = render_live(&model);
|
||||
assert_eq!(first, second);
|
||||
let (model, _) = control_flow();
|
||||
assert_eq!(render_live(&model), render_live(&model));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_controls_are_explicitly_unavailable_before_pr04() {
|
||||
let (model, _) = example("control-flow");
|
||||
fn run_controls_are_explicitly_unavailable_before_an_explicit_run() {
|
||||
let (model, _) = control_flow();
|
||||
let html = render_live(&model);
|
||||
assert!(html.contains("data-live=\"true\""));
|
||||
assert!(
|
||||
html.contains("data-disabled=\"true\"") || html.contains("aria-disabled"),
|
||||
"run control must have an explicit disabled marker"
|
||||
);
|
||||
// No fake RUNNING/SUCCEEDED marker on a freshly opened document.
|
||||
assert!(!html.contains("data-run-state=\"running\""));
|
||||
assert!(!html.contains("data-run-state=\"succeeded\""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reader_exposes_simple_theme_toggle_and_no_variable_or_memory_tabs() {
|
||||
let (model, _source) = example("welcome");
|
||||
let (model, _) = welcome();
|
||||
let html = render_live(&model);
|
||||
assert!(html.contains("data-theme=\"light\""));
|
||||
assert!(html.contains("data-action=\"theme\""));
|
||||
@@ -261,3 +279,29 @@ fn reader_exposes_simple_theme_toggle_and_no_variable_or_memory_tabs() {
|
||||
assert!(!html.contains("data-action=\"memory\""));
|
||||
assert!(html.contains("data-action=\"unsupported\""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn headings_use_heading_span_while_sections_use_the_complete_span() {
|
||||
// ADR-0069: `heading_span` locates the heading node; the complete `span`
|
||||
// includes child sections. The renderer must not use the complete span as the
|
||||
// heading id source (that would shift ids when a section grows).
|
||||
let (model, _) = control_flow();
|
||||
let projection = model.semantic.as_ref().unwrap();
|
||||
for unit in &projection.units {
|
||||
if let Some(heading) = unit.heading_span {
|
||||
if unit.span != heading {
|
||||
assert!(unit.span.contains(heading));
|
||||
}
|
||||
}
|
||||
}
|
||||
let function = &projection.functions[0];
|
||||
let html = render_live(&model);
|
||||
let expected = marqdo_view::reader::model::anchor_for_span(
|
||||
function.heading_span.start,
|
||||
function.heading_span.end,
|
||||
);
|
||||
assert!(
|
||||
html.contains(&format!("id=\"{expected}\"")),
|
||||
"{expected} missing"
|
||||
);
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
//! Unicode/CRLF/duplicate-text span contract (RFC-VIEW-0001 S-04).
|
||||
//! Goldens are emitted by the frozen CLI from the exact fixture bytes.
|
||||
//! Unicode/CRLF/duplicate-text span contract. The only source is the exact
|
||||
//! `modules[].source` carried by the Analysis v3 artifact; all spans are
|
||||
//! half-open UTF-8 byte ranges into it.
|
||||
|
||||
use marqdo_view::config::ViewConfig;
|
||||
use marqdo_view::protocol::analysis_v2 as semantic;
|
||||
use marqdo_view::reader::assemble::{self as assemble, BuildInput};
|
||||
use marqdo_view::protocol::analysis_v3;
|
||||
use marqdo_view::reader::assemble::{build, BuildInput};
|
||||
use marqdo_view::reader::markdown::{DocumentIdentity, DocumentModel};
|
||||
use marqdo_view::reader::model::{Navigation, SourceStatus};
|
||||
use marqdo_view::reader::model::{anchor_for_span, Navigation, SourceStatus};
|
||||
use marqdo_view::reader::render::{ReaderRenderer, RenderContext};
|
||||
use marqdo_view::reader::source::sha256_hex;
|
||||
use marqdo_view::reader::source::{Project, SafeRelativePath};
|
||||
@@ -14,34 +15,33 @@ fn repo_root() -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
}
|
||||
|
||||
fn load(path: &str, golden: &str) -> (String, Vec<u8>, semantic::VerifiedAnalysis) {
|
||||
let root = repo_root();
|
||||
let source = std::fs::read_to_string(root.join(path)).unwrap();
|
||||
let index = marqdo_view::reader::source::SourceIndex::new(&source);
|
||||
let analysis = std::fs::read(root.join(golden)).unwrap();
|
||||
let relative = std::path::Path::new(path)
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
let verified = semantic::verify_analysis(&analysis, &source, &index, &relative).unwrap();
|
||||
(source, analysis, verified)
|
||||
fn load(golden: &str, relative: &str) -> analysis_v3::VerifiedAnalysis {
|
||||
let bytes = std::fs::read(repo_root().join(golden)).unwrap();
|
||||
let verified = analysis_v3::verify_analysis(&bytes, relative, None)
|
||||
.unwrap_or_else(|err| panic!("{golden} does not verify: {err}"));
|
||||
let source = &verified.projection.source;
|
||||
assert_eq!(
|
||||
verified.projection.source_digest,
|
||||
sha256_hex(source.as_bytes())
|
||||
);
|
||||
verified
|
||||
}
|
||||
|
||||
fn render(verified: &semantic::VerifiedAnalysis, source: &str, relative: &str) -> String {
|
||||
let root = repo_root().join("examples/unicode-spans");
|
||||
fn render(verified: &analysis_v3::VerifiedAnalysis, project_dir: &str, relative: &str) -> String {
|
||||
let root = repo_root().join(project_dir);
|
||||
let project = Project::open(&root).unwrap();
|
||||
let entry = SafeRelativePath::parse(relative).unwrap();
|
||||
let document = DocumentModel::parse(source.to_string(), DocumentIdentity::placeholder(&entry));
|
||||
let source = verified.projection.source.clone();
|
||||
let document = DocumentModel::parse(source, DocumentIdentity::placeholder(&entry));
|
||||
let navigation = Navigation::from_project(&project, &ViewConfig::default(), &entry);
|
||||
let model = assemble::build(BuildInput {
|
||||
let model = build(BuildInput {
|
||||
document,
|
||||
analysis: Some(verified),
|
||||
status: SourceStatus::StaticOk,
|
||||
status_note: None,
|
||||
diagnostics: Vec::new(),
|
||||
navigation,
|
||||
core_version: Some("3.0.0-beta.1".to_string()),
|
||||
core_version: Some("3.0.0-rc.4".to_string()),
|
||||
run: None,
|
||||
});
|
||||
ReaderRenderer::new()
|
||||
@@ -51,35 +51,25 @@ fn render(verified: &semantic::VerifiedAnalysis, source: &str, relative: &str) -
|
||||
|
||||
#[test]
|
||||
fn unicode_spans_are_exact_and_duplicate_returns_get_distinct_anchors() {
|
||||
let (source, analysis, verified) = load(
|
||||
"examples/unicode-spans/index.mq.md",
|
||||
"tests/golden/analysis-v2/unicode-spans.json",
|
||||
);
|
||||
assert_eq!(
|
||||
verified.projection.source_digest,
|
||||
sha256_hex(source.as_bytes())
|
||||
);
|
||||
let verified = load("tests/golden/analysis-v3/unicode-spans.json", "index.mq.md");
|
||||
let source = verified.projection.source.clone();
|
||||
let function = &verified.projection.functions[0];
|
||||
let returns: Vec<_> = function
|
||||
.flattened_statements()
|
||||
.into_iter()
|
||||
.filter(|statement| statement.kind == semantic::StatementKind::Return)
|
||||
.filter(|statement| statement.kind == analysis_v3::StatementKind::Return)
|
||||
.collect();
|
||||
assert_eq!(returns.len(), 2);
|
||||
let first = returns[0].span;
|
||||
let second = returns[1].span;
|
||||
assert_ne!(first, second);
|
||||
let index = marqdo_view::reader::source::SourceIndex::new(&source);
|
||||
// Core statement spans cover the whole carrier node (including markers).
|
||||
assert_eq!(index.source_text(&source, first), Some("`return 1`"));
|
||||
assert_eq!(index.source_text(&source, second), Some("`return 1`"));
|
||||
// The carrier text is identical, so only spans can distinguish the two.
|
||||
assert_eq!(first.start, source.find("`return 1`").unwrap() as u64);
|
||||
assert_ne!(first.start, second.start);
|
||||
|
||||
let html = render(&verified, &source, "index.mq.md");
|
||||
let statement_ids: Vec<&str> = html.matches("data-source-id=\"").map(|_| "").collect();
|
||||
let _ = statement_ids;
|
||||
let html = render(&verified, "examples/unicode-spans", "index.mq.md");
|
||||
// 3 anchored statements: branch header + two returns.
|
||||
assert_eq!(html.matches("class=\"mq-anchor\"").count(), 3, "{html}");
|
||||
let ids: Vec<&str> = html
|
||||
@@ -91,30 +81,28 @@ fn unicode_spans_are_exact_and_duplicate_returns_get_distinct_anchors() {
|
||||
unique.sort();
|
||||
unique.dedup();
|
||||
assert_eq!(ids.len(), unique.len(), "duplicate source ids: {ids:?}");
|
||||
// Emoji and CJK survive both rendering and source mapping.
|
||||
assert!(html.contains("中文 🙂 标题"));
|
||||
assert!(html.contains("甲🙂"));
|
||||
let _ = analysis;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn crlf_source_keeps_exact_digest_and_line_mapping() {
|
||||
let (source, _analysis, verified) = load(
|
||||
"examples/unicode-spans/crlf.mq.md",
|
||||
"tests/golden/analysis-v2/unicode-spans-crlf.json",
|
||||
let verified = load(
|
||||
"tests/golden/analysis-v3/unicode-spans-crlf.json",
|
||||
"crlf.mq.md",
|
||||
);
|
||||
let source = verified.projection.source.clone();
|
||||
assert!(source.contains("\r\n"), "fixture must stay CRLF");
|
||||
assert_eq!(
|
||||
verified.projection.source_digest,
|
||||
sha256_hex(source.as_bytes())
|
||||
);
|
||||
let index = marqdo_view::reader::source::SourceIndex::new(&source);
|
||||
let function = &verified.projection.functions[0];
|
||||
for (_, statement) in verified
|
||||
.projection
|
||||
.all_statements()
|
||||
.into_iter()
|
||||
.filter(|(_, statement)| statement.kind == semantic::StatementKind::Return)
|
||||
.filter(|(_, statement)| statement.kind == analysis_v3::StatementKind::Return)
|
||||
{
|
||||
assert!(
|
||||
index
|
||||
@@ -125,42 +113,20 @@ fn crlf_source_keeps_exact_digest_and_line_mapping() {
|
||||
statement.span
|
||||
);
|
||||
}
|
||||
let html = render(&verified, &source, "crlf.mq.md");
|
||||
let html = render(&verified, "examples/unicode-spans", "crlf.mq.md");
|
||||
assert!(html.contains("CRLF 文档"));
|
||||
// One list item per source line (SourceIndex counts the trailing line too).
|
||||
let source_lines = index.line_count();
|
||||
assert_eq!(html.matches("class=\"mq-line-text\"").count(), source_lines);
|
||||
let _ = function;
|
||||
assert_eq!(
|
||||
html.matches("class=\"mq-line-text\"").count(),
|
||||
index.line_count()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn knowledge_emphasis_never_becomes_an_execution_anchor() {
|
||||
let root = repo_root();
|
||||
let project = Project::open(&root.join("examples/mixed-modes")).unwrap();
|
||||
let project = Project::open(&repo_root().join("examples/mixed-modes")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let source = project.read_source_text(&entry).unwrap();
|
||||
let index = marqdo_view::reader::source::SourceIndex::new(&source);
|
||||
let analysis = std::fs::read(root.join("tests/golden/analysis-v2/mixed-modes.json")).unwrap();
|
||||
let verified = semantic::verify_analysis(&analysis, &source, &index, entry.as_str()).unwrap();
|
||||
assert_eq!(
|
||||
verified.projection.source_digest,
|
||||
sha256_hex(source.as_bytes())
|
||||
);
|
||||
let document = DocumentModel::parse(source.clone(), DocumentIdentity::placeholder(&entry));
|
||||
let navigation = Navigation::from_project(&project, &ViewConfig::default(), &entry);
|
||||
let model = assemble::build(BuildInput {
|
||||
document,
|
||||
analysis: Some(&verified),
|
||||
status: SourceStatus::StaticOk,
|
||||
status_note: None,
|
||||
diagnostics: Vec::new(),
|
||||
navigation,
|
||||
core_version: Some("3.0.0-beta.1".to_string()),
|
||||
run: None,
|
||||
});
|
||||
let html = ReaderRenderer::new()
|
||||
.render(&model, &RenderContext::live())
|
||||
.html;
|
||||
let verified = load("tests/golden/analysis-v3/mixed-modes.json", entry.as_str());
|
||||
let html = render(&verified, "examples/mixed-modes", entry.as_str());
|
||||
// Exactly the four Exec statements are anchored (branch + assign + 2 returns).
|
||||
assert_eq!(html.matches("class=\"mq-anchor\"").count(), 4, "{html}");
|
||||
let knowledge_bold = "此处加粗是知识内容,不执行。";
|
||||
@@ -173,3 +139,50 @@ fn knowledge_emphasis_never_becomes_an_execution_anchor() {
|
||||
"knowledge emphasis received an execution anchor"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn heading_ui_uses_heading_span_and_section_span_includes_children() {
|
||||
// ADR-0069: heading_span is the heading AST node; the complete span runs
|
||||
// through child sections. A section heading id must be derived from its own
|
||||
// heading span, so adding a child never moves it.
|
||||
let verified = load("tests/golden/analysis-v3/control-flow.json", "index.mq.md");
|
||||
let projection = &verified.projection;
|
||||
let mut sections_with_children = 0;
|
||||
for unit in &projection.units {
|
||||
let Some(heading) = unit.heading_span else {
|
||||
assert_eq!(unit.kind, analysis_v3::UnitKind::Root);
|
||||
continue;
|
||||
};
|
||||
assert!(unit.span.contains(heading));
|
||||
let anchor = anchor_for_span(heading.start, heading.end);
|
||||
// A heading id is derived from the heading itself, not the section body.
|
||||
assert_ne!(
|
||||
anchor,
|
||||
anchor_for_span(unit.span.start, unit.span.end),
|
||||
"unit {:?} used the complete section span as its heading id",
|
||||
unit.id
|
||||
);
|
||||
if projection
|
||||
.units
|
||||
.iter()
|
||||
.any(|child| child.parent_id.as_deref() == Some(unit.id.as_str()))
|
||||
{
|
||||
sections_with_children += 1;
|
||||
assert!(
|
||||
unit.span.end > heading.end,
|
||||
"section {:?} complete span does not include its children",
|
||||
unit.id
|
||||
);
|
||||
}
|
||||
}
|
||||
assert!(
|
||||
sections_with_children > 0,
|
||||
"fixture needs a section with children"
|
||||
);
|
||||
let html = render(&verified, "examples/control-flow", "index.mq.md");
|
||||
let function_anchor = anchor_for_span(
|
||||
projection.functions[0].heading_span.start,
|
||||
projection.functions[0].heading_span.end,
|
||||
);
|
||||
assert!(html.contains(&format!("id=\"{function_anchor}\"")));
|
||||
}
|
||||
+25
-22
@@ -15,17 +15,18 @@ use crate::common::http::{
|
||||
fn control_flow() -> TestServer {
|
||||
http::start(
|
||||
"examples/control-flow",
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
Some("tests/golden/trace-v2/control-flow.run.json"),
|
||||
Some("tests/golden/trace-v2/control-flow.trace.json"),
|
||||
"tests/golden/analysis-v3/control-flow.json",
|
||||
Some((
|
||||
"tests/golden/observation-v1/control-flow.jsonl",
|
||||
"tests/golden/observation-v1/control-flow.snapshot.json",
|
||||
)),
|
||||
)
|
||||
}
|
||||
|
||||
fn welcome() -> TestServer {
|
||||
http::start(
|
||||
"examples/welcome",
|
||||
"tests/golden/analysis-v2/welcome.json",
|
||||
None,
|
||||
"tests/golden/analysis-v3/welcome.json",
|
||||
None,
|
||||
)
|
||||
}
|
||||
@@ -160,8 +161,7 @@ fn oversized_and_unknown_fields_are_rejected_before_execution() {
|
||||
fn session_cookie_and_headers_are_hardened() {
|
||||
let server = http::start(
|
||||
"examples/welcome",
|
||||
"tests/golden/analysis-v2/welcome.json",
|
||||
None,
|
||||
"tests/golden/analysis-v3/welcome.json",
|
||||
None,
|
||||
);
|
||||
let page = http::get(server.port, "/");
|
||||
@@ -196,9 +196,11 @@ fn session_cookie_and_headers_are_hardened() {
|
||||
fn sec_fetch_site_cross_site_is_rejected_even_with_a_valid_token() {
|
||||
let server = http::start(
|
||||
"examples/control-flow",
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
Some("tests/golden/trace-v2/control-flow.run.json"),
|
||||
Some("tests/golden/trace-v2/control-flow.trace.json"),
|
||||
"tests/golden/analysis-v3/control-flow.json",
|
||||
Some((
|
||||
"tests/golden/observation-v1/control-flow.jsonl",
|
||||
"tests/golden/observation-v1/control-flow.snapshot.json",
|
||||
)),
|
||||
);
|
||||
let (session, _) = open_session(&server, "/");
|
||||
let body = run_body(
|
||||
@@ -225,8 +227,7 @@ fn symlink_escape_outside_the_project_root_is_rejected() {
|
||||
symlink(&outside.dir, project.dir.join("link")).expect("create symlink");
|
||||
let server = http::start(
|
||||
project.dir.to_str().expect("utf8 path"),
|
||||
"tests/golden/analysis-v2/welcome.json",
|
||||
None,
|
||||
"tests/golden/analysis-v3/welcome.json",
|
||||
None,
|
||||
);
|
||||
for path in [
|
||||
@@ -247,8 +248,7 @@ fn symlink_escape_outside_the_project_root_is_rejected() {
|
||||
fn adversarial_markdown_never_injects_markup_or_handlers() {
|
||||
let server = http::start(
|
||||
"tests/fixtures/security-project",
|
||||
"tests/golden/analysis-v2/welcome.json",
|
||||
None,
|
||||
"tests/golden/analysis-v3/welcome.json",
|
||||
None,
|
||||
);
|
||||
let page = http::get(server.port, "/");
|
||||
@@ -266,9 +266,11 @@ fn adversarial_markdown_never_injects_markup_or_handlers() {
|
||||
fn sse_requires_a_session_and_only_the_owning_session_can_read_or_cancel() {
|
||||
let server = http::start(
|
||||
"examples/control-flow",
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
Some("tests/golden/trace-v2/control-flow.run.json"),
|
||||
Some("tests/golden/trace-v2/control-flow.trace.json"),
|
||||
"tests/golden/analysis-v3/control-flow.json",
|
||||
Some((
|
||||
"tests/golden/observation-v1/control-flow.jsonl",
|
||||
"tests/golden/observation-v1/control-flow.snapshot.json",
|
||||
)),
|
||||
);
|
||||
let (owner, _) = open_session(&server, "/");
|
||||
let (other, _) = open_session(&server, "/");
|
||||
@@ -318,8 +320,7 @@ fn sse_requires_a_session_and_only_the_owning_session_can_read_or_cancel() {
|
||||
fn aggressive_markdown_links_cannot_become_a_file_read_api() {
|
||||
let server = http::start(
|
||||
"examples/welcome",
|
||||
"tests/golden/analysis-v2/welcome.json",
|
||||
None,
|
||||
"tests/golden/analysis-v3/welcome.json",
|
||||
None,
|
||||
);
|
||||
let page = http::get(server.port, "/");
|
||||
@@ -336,9 +337,11 @@ fn aggressive_markdown_links_cannot_become_a_file_read_api() {
|
||||
fn cancel_cannot_be_replayed_to_start_a_new_process() {
|
||||
let server = http::start(
|
||||
"examples/control-flow",
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
Some("tests/golden/trace-v2/control-flow.run.json"),
|
||||
Some("tests/golden/trace-v2/control-flow.trace.json"),
|
||||
"tests/golden/analysis-v3/control-flow.json",
|
||||
Some((
|
||||
"tests/golden/observation-v1/control-flow.jsonl",
|
||||
"tests/golden/observation-v1/control-flow.snapshot.json",
|
||||
)),
|
||||
);
|
||||
let (session, _) = open_session(&server, "/");
|
||||
let body = run_body(
|
||||
|
||||
Reference in new issue
Block a user