feat(ext): single callable binding, provider v2 CLI, capability handlers, stdlib aliases

Implements RFC-EXT-0001 PR-00..PR-07 first pass:
- CallSiteKey/CallBindingTable + one frontend binding pass; runtime dispatch by identity
- prepare composition root shared by check/run/inspect/Analysis; exact plugin reconciliation
- provider.json v2 --provider/--allow-provider worker CLI with fail-closed verification
- capability handler registry with real fs.read and audit
- verified stdlib public aliases replace print_override/AST scan
- docs: specs, ADR-0054/0055/0057/0058, README, CI/release gates, evidence

PR-04 extension selection/lock v4 and final frozen-binary evidence remain.
This commit is contained in:
cflmy committed 2026-11-22 00:17:36 +08:00
1 parent 9aa536c2c9
commit 1f6fd644a0
54 files changed
+8710 -828

No files matched your search

+122
View File
@@ -272,3 +272,125 @@ fn walk_rs(root: &Path) -> Vec<PathBuf> {
}
files
}
/// RFC-EXT-0001 §4/§14: the runtime must dispatch by the prepared binding and
/// never re-resolve a name or special-case a print function.
#[test]
fn callable_binding_is_the_only_static_resolution_path() {
let root = repo_root();
let loader = read(&root.join("crates/cli/src/loader.rs"));
let interpreter = read(&root.join("crates/marqdo-runtime/src/interpreter.rs"));
let run = read(&root.join("crates/cli/src/commands/run.rs"));
let frontend = read(&root.join("crates/marqdo-frontend/src/calls.rs"));
assert!(
!loader.contains("program_uses_print"),
"loader must not scan for per-function names (ADR-0058)"
);
assert!(
!interpreter.contains("print_override"),
"the runtime must not special-case print (ADR-0054/0058)"
);
assert!(
!interpreter.contains("external_callables.is_empty"),
"the runtime must not fall back to plugin guessing (ADR-0054)"
);
assert!(
interpreter.contains("call_bindings.get"),
"the runtime must dispatch by the prepared call binding table"
);
assert!(
!interpreter.contains("builtins::find(&qualified)"),
"a qualified name must not be re-resolved at run time"
);
assert!(
!run.contains("external_callables")
|| !run.contains("external_callables")
|| !run.contains("push(marqdo_ir::callable::CallableDescriptor"),
"run must not synthesise plugin descriptors (ADR-0054/§4.5)"
);
assert!(
frontend.contains("bind_program_calls"),
"the frontend must expose the single binding entry point"
);
}
/// RFC-EXT-0001 §14.2/S4: no business-domain builtin or host-op branch may be
/// added for an ecosystem feature. These must be implemented as `.mq.md`,
/// plugin exports or provider streams.
#[test]
fn no_business_domain_builtins_or_host_ops() {
let root = repo_root();
let builtins = read(&root.join("crates/marqdo-ir/src/builtins.rs"));
let host = read(&root.join("crates/marqdo-host/src/host.rs"));
for forbidden in ["quantum.", "ai.chat", "vendor.", "demo.sensor", "marqdo."] {
assert!(
!builtins.contains(forbidden),
"business builtin namespace `{forbidden}` must not exist"
);
}
assert!(
!host.contains("\"demo.sensor\""),
"provider kinds must be data, not host-op string branches"
);
}
/// RFC-EXT-0001 §8: official stdlib public aliases are verified metadata, not
/// hard-coded runtime names. Recompute the canonical metadata digest.
#[test]
fn official_stdlib_public_aliases_are_verified_metadata() {
let root = repo_root().join("stdlib");
let manifest: serde_json::Value =
serde_json::from_slice(&std::fs::read(root.join("stdlib.json")).unwrap()).unwrap();
let aliases = manifest["public_aliases"]
.as_array()
.expect("stdlib.json must declare public_aliases");
assert!(!aliases.is_empty());
let mut hasher = Sha256::new();
let mut entries: Vec<&serde_json::Value> = aliases.iter().collect();
entries.sort_by_key(|alias| {
(
alias["target_module"].as_str().unwrap_or("").to_string(),
alias["target_function"].as_str().unwrap_or("").to_string(),
)
});
for alias in &entries {
hasher.update(alias["target_module"].as_str().unwrap().as_bytes());
hasher.update([0]);
hasher.update(alias["target_function"].as_str().unwrap().as_bytes());
hasher.update([0]);
let mut names: Vec<&str> = alias["public_names"]
.as_array()
.unwrap()
.iter()
.filter_map(serde_json::Value::as_str)
.collect();
names.sort();
for name in names {
hasher.update(name.as_bytes());
hasher.update([0]);
}
}
let actual = format!("sha256:{}", hex(&hasher.finalize()));
assert_eq!(
manifest["aliases_digest"], actual,
"stdlib.json aliases_digest must cover the public alias table"
);
for alias in aliases {
let target_module = alias["target_module"].as_str().unwrap();
let target_function = alias["target_function"].as_str().unwrap();
let module = read(&root.join(target_module));
assert!(
module.contains(&format!("## {target_function}")),
"public alias target `{target_module}::{target_function}` must exist"
);
}
}
fn hex(bytes: &[u8]) -> String {
let mut out = String::with_capacity(bytes.len() * 2);
for byte in bytes {
out.push_str(&format!("{byte:02x}"));
}
out
}