feat(lang): implement RFC-LANG-0002 unified semantics (breaking)

One Markdown-to-program mapping, no version selector or legacy mapper.

Frontend/runtime:
- resolve @exec/@knowledge heading declarations with nearest-ancestor
  inheritance; only an Exec H2 is callable; add UnitKind::Knowledge and
  sem.* diagnostics (mode marker, unit name, exec-without-function,
  payload nesting/empty, syntax, control stack, params position,
  version directive, inferred-signature lint)
- extract Strong/Emph/inline Code as one-statement carriers, refuse
  nested carriers, and honour heading segment boundaries so an if/while
  cannot be closed across a heading
- lower if/else/while/end to the existing Branch/Loop/Return IR with a
  compile-time control stack; keep payload-relative source spans through
  expression parsing and rewrite them onto the file
- accept params(...) only as the first direct Exec H2 payload; keep the
  existing free-variable inference and named-only rule for inferred
  signatures; fix duplicate-mode/else/end and Knowledge-body inertness
- reject marqdo_semantics/syntax front matter directives

Data and tests:
- migrate stdlib/**/*.mq.md, regenerate stdlib.json digest
- migrate examples and the full semantics/negative/runtime corpus to
  the only current syntax; expected values/runtime codes preserved
- migrate Rust-embedded .mq.md fixtures, init template, CLI help and
  security-lane fixtures

Verified: cargo fmt --check, cargo clippy -D warnings and
cargo test --workspace --locked (green).
This commit is contained in:
cflmy committed 2026-11-21 12:26:46 +08:00
1 parent 49835424ee
commit e029853e32
375 files changed
+6591 -4790

No files matched your search

+2 -2
View File
@@ -273,7 +273,7 @@ mod tests {
fn excludes_git_and_marqdo_directories() {
let dir = tempfile::tempdir().unwrap();
let root = dir.path();
write(&root.join("index.mq.md"), b"## main\n");
write(&root.join("index.mq.md"), b"## @exec main\n");
write(&root.join(".git/HEAD"), b"ref: main\n");
write(&root.join(".marqdo/env/env.json"), b"{}");
write(&root.join("nested/.marqdo/state"), b"x");
@@ -343,7 +343,7 @@ mod tests {
let dir = tempfile::tempdir().unwrap();
let source = dir.path().join("source");
let target = dir.path().join("target");
write(&source.join("index.mq.md"), b"## main\n");
write(&source.join("index.mq.md"), b"## @exec main\n");
write(&source.join("data/value.txt"), b"42");
write(&source.join(".git/HEAD"), b"ignored");
let digest = hash_tree(&source).unwrap();
+7 -7
View File
@@ -1599,7 +1599,7 @@ capabilities:
"project:\n name: geometry\n version: 0.1.0\n",
)
.unwrap();
std::fs::write(first.join("index.mq.md"), "## f\n\n*1*\n").unwrap();
std::fs::write(first.join("index.mq.md"), "## @exec f\n\n`return 1`\n").unwrap();
let manifest = Manifest::load(&root.join(MANIFEST_FILE)).unwrap();
let resolver =
PackageResolver::new(root.clone(), Some(manifest.clone()), None).with_unlocked(true);
@@ -1668,7 +1668,7 @@ capabilities:
"project:\n name: remote\n version: 0.2.0\n",
)
.unwrap();
std::fs::write(dep.join("index.mq.md"), "## hello\n\n*1*\n").unwrap();
std::fs::write(dep.join("index.mq.md"), "## @exec hello\n\n`return 1`\n").unwrap();
git(&dep, &["init", "-q"]);
git(&dep, &["add", "."]);
git(&dep, &["commit", "-q", "-m", "initial"]);
@@ -1721,7 +1721,7 @@ capabilities:
"project:\n name: geometry\n version: 0.1.0\n",
)
.unwrap();
std::fs::write(dep.join("index.mq.md"), "## area\n\n*1*\n").unwrap();
std::fs::write(dep.join("index.mq.md"), "## @exec area\n\n`return 1`\n").unwrap();
std::fs::write(
root.join(MANIFEST_FILE),
"project:\n name: p\n version: 0.1.0\ndependencies:\n geometry:\n path: ./deps/geometry\n",
@@ -1765,19 +1765,19 @@ capabilities:
"project:\n name: root\n version: 0.1.0\ndependencies:\n a:\n path: ./deps/a\n",
)
.unwrap();
std::fs::write(root.join("index.mq.md"), "## main\n\n*1*\n").unwrap();
std::fs::write(root.join("index.mq.md"), "## @exec main\n\n`return 1`\n").unwrap();
std::fs::write(
a.join(MANIFEST_FILE),
"project:\n name: a\n version: 0.1.0\ndependencies:\n b:\n path: ./b\n",
)
.unwrap();
std::fs::write(a.join("index.mq.md"), "## a\n\n*1*\n").unwrap();
std::fs::write(a.join("index.mq.md"), "## @exec a\n\n`return 1`\n").unwrap();
std::fs::write(
b.join(MANIFEST_FILE),
"project:\n name: b\n version: 0.1.0\n",
)
.unwrap();
std::fs::write(b.join("index.mq.md"), "## b\n\n*2*\n").unwrap();
std::fs::write(b.join("index.mq.md"), "## @exec b\n\n`return 2`\n").unwrap();
let manifest = Manifest::load(&root.join(MANIFEST_FILE)).unwrap();
let resolver = PackageResolver::new(root.clone(), Some(manifest), None).with_unlocked(true);
let graph = resolver.resolve_lock_graph().unwrap();
@@ -1813,7 +1813,7 @@ capabilities:
"project:\n name: geometry\n version: 0.1.0\n",
)
.unwrap();
std::fs::write(dep.join("index.mq.md"), "## area\n\n*1*\n").unwrap();
std::fs::write(dep.join("index.mq.md"), "## @exec area\n\n`return 1`\n").unwrap();
std::fs::write(
root.join(MANIFEST_FILE),
"project:\n name: p\n version: 0.1.0\ndependencies:\n geometry:\n path: ./deps/geometry\n",