Clarify quantum agent paths for Bell preparation.

Root skills get a choose-a-path table; circuit modules spell the simulate
handoff; call_cli covers ZH bell and stepwise session probabilities.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-11-08 21:50:01 +08:00
1 parent 0e389f34ec
commit 76aa02846a
4 files changed
+116 -5

No files matched your search

+1
View File
@@ -86,3 +86,4 @@ marqdo call <FILE> <FUNCTION> [k=v…]
| 日期 | 说明 |
|------|------|
| 2026-11-06 | 初稿:012 试点契约、call effects/toget、quantum 模块树 |
| 2026-11-06 | quantum 中文树收进 `ext/quantum/量子/`;根 skill 增加「选哪条路」;`ext add` 拒绝装进源码树 |
+12 -3
View File
@@ -35,9 +35,18 @@ Apply CNOT from 0 to 1:
Call example (plain text):
marqdo call ext/quantum/circuit/index.mq.md cnot circuit=$qc control=0 target=1 --effects plugin --session s --toget qc --json
Then open ext/quantum/simulate/index.mq.md for probabilities. Author programs may
import this file and construct the circuit object named circuit (method chain h,
cx, …). Agents should prefer marqdo call on the ## tools above.
If you were given only this file, probabilities are not a ## tool here. After the
CNOT line, call simulate on the same session (do not invent a probabilities
tool on this file):
Call example (plain text):
marqdo call ext/quantum/simulate/index.mq.md probabilities circuit=$qc --effects plugin --session s --json
Author programs may import this file and construct the circuit object named
circuit (method chain h, cx, …). Agents should prefer marqdo call on the ##
tools above, then simulate for amplitudes or probabilities.
*None*
## new
Create a state-vector circuit of width `qubits`=1 by default. Optional
+8 -2
View File
@@ -28,8 +28,14 @@ import:
调用示例(纯文本):
marqdo call ext/quantum/量子/电路/索引.mq.md 控非 电路=$qc 控制=0 目标=1 --effects plugin --session s --toget qc --json
随后打开 ext/quantum/量子/模拟/索引.mq.md 取概率。作者程序可导入本文件并使用对象电路
(方法如哈达玛、控非)。智能体优先用上面的 marqdo call。
若你只拿到本文件,这里没有「概率」这个 ## 工具。控非之后请在同一会话调用模拟模块
(不要在本文件上发明概率工具):
调用示例(纯文本):
marqdo call ext/quantum/量子/模拟/索引.mq.md 概率 电路=$qc --effects plugin --session s --json
作者程序可导入本文件并使用对象电路(方法如哈达玛、控非)。智能体优先用上面的
marqdo call,再调模拟取振幅或概率。
*None*
+95
View File
@@ -263,6 +263,101 @@ fn quantum_index_bell_via_call() {
assert!((p11 - 0.5).abs() < 0.05, "{body}");
}
#[test]
fn quantum_zh_index_bell_via_call() {
let file = root().join("ext/quantum/量子/索引.mq.md");
let out = run(&[
"call",
"--effects",
"plugin",
"--json",
file.to_str().unwrap(),
"贝尔态",
]);
assert_eq!(out.status.code(), Some(0), "{}", text(&out.stdout));
let body: serde_json::Value = serde_json::from_str(&text(&out.stdout)).unwrap();
assert_eq!(body["ok"], true, "{body}");
let p00 = body["result"]["00"].as_f64().unwrap();
let p11 = body["result"]["11"].as_f64().unwrap();
assert!((p00 - 0.5).abs() < 0.05, "{body}");
assert!((p11 - 0.5).abs() < 0.05, "{body}");
}
#[test]
fn quantum_bell_stepwise_session_matches_index() {
let dir = std::env::temp_dir().join(format!("mq-call-bell-{}", std::process::id()));
let _ = fs::remove_dir_all(&dir);
fs::create_dir_all(&dir).unwrap();
let circuit = root().join("ext/quantum/circuit/index.mq.md");
let simulate = root().join("ext/quantum/simulate/index.mq.md");
let sess = "bell-steps";
let steps: &[(&str, &str, &[&str])] = &[
(
circuit.to_str().unwrap(),
"new",
&["qubits=2", "--toget", "qc"],
),
(
circuit.to_str().unwrap(),
"hadamard",
&["circuit=$qc", "qubit=0", "--toget", "qc"],
),
(
circuit.to_str().unwrap(),
"cnot",
&["circuit=$qc", "control=0", "target=1", "--toget", "qc"],
),
];
for (file, function, extra) in steps {
let mut args = vec![
"call",
"--effects",
"plugin",
"--session",
sess,
"--json",
file,
function,
];
args.extend_from_slice(extra);
let out = Command::new(bin())
.env("MARQDO_CALL_SESSION_DIR", &dir)
.args(&args)
.current_dir(root())
.output()
.unwrap();
assert_eq!(
out.status.code(),
Some(0),
"{function} {}",
text(&out.stdout)
);
}
let out = Command::new(bin())
.env("MARQDO_CALL_SESSION_DIR", &dir)
.args([
"call",
"--effects",
"plugin",
"--session",
sess,
"--json",
simulate.to_str().unwrap(),
"probabilities",
"circuit=$qc",
])
.current_dir(root())
.output()
.unwrap();
assert_eq!(out.status.code(), Some(0), "{}", text(&out.stdout));
let body: serde_json::Value = serde_json::from_str(&text(&out.stdout)).unwrap();
assert_eq!(body["ok"], true, "{body}");
let p00 = body["result"]["00"].as_f64().unwrap();
let p11 = body["result"]["11"].as_f64().unwrap();
assert!((p00 - 0.5).abs() < 0.05, "{body}");
assert!((p11 - 0.5).abs() < 0.05, "{body}");
}
#[test]
fn toget_persists_serializable_value() {
let dir = std::env::temp_dir().join(format!("mq-call-sess-{}", std::process::id()));