release: bump to 2.1.2 (EK production chain + View V0–V3 bar)

Ship evidence/closure invalidation, verify/adjudicate, reuse_execute and
agent bind/publish gates, document.extract, KnowledgePresentation + SSE
page_token, and upload max_bytes with the 45-test offline gate.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-10-24 22:52:03 +08:00
1 parent 0b80ff8e50
commit dc853fb580
38 files changed
+3045 -298

No files matched your search

+3 -2
View File
@@ -632,9 +632,10 @@ fn taken_arms_by_branch_line(annots: &[ViewAnnot]) -> HashMap<u32, usize> {
fn render_fun_heading(fun: &Function, annots: &[ViewAnnot]) -> String {
let mut s = format!(
r#"<div class="doc-fun" id="fn-{line}" data-fn="{name}" data-fn-path="{name}" data-line="{line}">
r##"<div class="doc-fun" id="fn-{line}" data-fn="{name}" data-fn-path="{name}" data-line="{line}">
<div class="doc-fun-bar">
<h3 class="doc-fun-title">{name}</h3>"#,
<h3 class="doc-fun-title">{name}</h3>
<a class="knowledge-explain" href="#knowledge-{name}" data-node="{name}">说明</a>"##,
line = fun.span.line,
name = escape(&fun.name),
);
+74 -10
View File
@@ -58,6 +58,17 @@ fn stylesheet() -> &'static str {
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
[id] { scroll-margin-top: 4.5rem; }
.knowledge-block summary { cursor: pointer; font-weight: 600; }
.knowledge-hint { color: var(--muted); font-size: 0.85em; margin: 0.25rem 0 0.5rem; }
.knowledge-error .err { color: #8b1a1a; }
@media print {
.topbar, .stdin-form, .stream-panel, .exec-clear, #notebook-bar, nav { display: none !important; }
.knowledge-block, .source-block { display: block; }
}
@media (prefers-reduced-motion: reduce) {
html { scroll-behavior: auto; }
}
body {
margin: 0;
min-height: 100vh;
@@ -2150,6 +2161,14 @@ pub fn layout(title: &str, nav: &str, main: &str) -> String {
scrollIfPinned();
}}
if (thinkingEl && (answerNode && answerNode.data)) thinkingEl.open = false;
// V2: reject stale result packets when page_token mismatches (source changed).
var pageTok = window.MARQDO_VIEW_PAGE_TOKEN || "";
var pktTok = (typeof ev.page_token === "string") ? ev.page_token : "";
var acceptPacket = !pktTok || !pageTok || pktTok === pageTok;
if (!acceptPacket) {{
if (status) status.textContent = "stale result ignored";
return;
}}
if (typeof ev.bindings_html === "string") {{
var vp = document.getElementById("vars-panel");
if (vp) {{
@@ -2161,10 +2180,38 @@ pub fn layout(title: &str, nav: &str, main: &str) -> String {
if (typeof ev.structure_html === "string" && ev.structure_html) {{
var structEl = document.getElementById("structure");
if (structEl) {{
// Preserve call/loop frame selection across SSE structure swap.
var savedCall = {{}};
structEl.querySelectorAll("select.call-picker").forEach(function(sel) {{
if (sel.id) savedCall[sel.id] = sel.value;
}});
var savedLoop = {{}};
structEl.querySelectorAll("select.loop-picker").forEach(function(sel) {{
if (sel.id) savedLoop[sel.id] = sel.value;
}});
var focusId = (document.activeElement && document.activeElement.id) || "";
structEl.innerHTML = ev.structure_html;
initAnnotLeaders();
initCallPickers();
initLoopPickers();
Object.keys(savedCall).forEach(function(id) {{
var el = document.getElementById(id);
if (el && savedCall[id]) {{
el.value = savedCall[id];
el.dispatchEvent(new Event("change", {{ bubbles: true }}));
}}
}});
Object.keys(savedLoop).forEach(function(id) {{
var el = document.getElementById(id);
if (el && savedLoop[id]) {{
el.value = savedLoop[id];
el.dispatchEvent(new Event("change", {{ bubbles: true }}));
}}
}});
if (focusId) {{
var fe = document.getElementById(focusId);
if (fe && fe.focus) try {{ fe.focus(); }} catch (e) {{}}
}}
}}
}}
if (typeof ev.trace_json === "string" && ev.trace_json) {{
@@ -4153,11 +4200,12 @@ pub fn page_file(files: &[PathBuf], rel: &str, vm: &FileViewModel, links: &LinkM
}
}
};
let title = Path::new(rel)
let fallback_title = Path::new(rel)
.file_name()
.and_then(|s| s.to_str())
.unwrap_or(rel)
.trim_end_matches(".mq.md");
let title = crate::view::title_from_source(&vm.source, fallback_title);
let plots_html = if vm.plots.is_empty() {
String::new()
} else {
@@ -4224,43 +4272,59 @@ pub fn page_file(files: &[PathBuf], rel: &str, vm: &FileViewModel, links: &LinkM
window.MARQDO_VIEW_LIVE = {live};
window.MARQDO_FILE_PATH = {path_js};
window.MARQDO_AUTO_STREAM = {auto_stream};
window.MARQDO_VIEW_PAGE_TOKEN = {page_token_js};
</script>
<script type="application/json" id="mq-view-trace">{trace}</script>
<h1 class="page">{title}<span class="status-pill {status}">{status_label}</span></h1>
<p class="meta">{rel}</p>
{notebook}
{knowledge}
<section class="block structure-block">
<h2>Structure</h2>
<section class="block structure-block" id="structure">
<h2>文档</h2>
{structure_block}
</section>
{knowledge}
<section class="block exec-block" id="exec-block">
<h2>Execution {exec_clear}</h2>
<h2>运行与结果 {exec_clear}</h2>
{stdin_panel}
{stream_panel}
{plan_card}
<div class="out {status}" id="exec-main">{out}</div>
{plots}
</section>
<section class="block source-block">
<h2>Source</h2>
<details class="block source-block">
<summary>完整源码</summary>
<pre class="source">{source}</pre>
</section>
</details>
"#,
live = live_flag,
path_js = escape_js_string(rel),
auto_stream = if vm.auto_stream { "true" } else { "false" },
page_token_js = escape_js_string(&vm.page_token),
trace = if trace_safe.is_empty() {
"{}"
} else {
trace_safe.as_str()
},
title = escape(title),
title = escape(&title),
status = status,
status_label = status_label,
rel = escape(rel),
notebook = notebook,
knowledge = if vm.knowledge_html.is_empty() { String::new() } else { format!("<section class=\"block knowledge-block\"><h2>Executable knowledge</h2>{}</section>", vm.knowledge_html) },
knowledge = {
if !vm.knowledge_error.is_empty() {
format!(
"<section class=\"block knowledge-block knowledge-error\"><h2>知识关系</h2><p class=\"err\">{}</p></section>",
escape(&vm.knowledge_error)
)
} else if vm.knowledge_html.is_empty() {
String::new()
} else {
format!(
"<details class=\"block knowledge-block\"><summary>可执行知识(辅助)</summary>{}</details>",
vm.knowledge_html
)
}
},
exec_clear = exec_clear,
structure_block = structure_block,
stdin_panel = stdin_panel,
+197
View File
@@ -0,0 +1,197 @@
//! V1 KnowledgePresentation model — structured facts shared by body, outline, and detail.
//!
//! Semantic facts come from SemanticProject; this module does not invent verification.
use crate::sema::{SemanticArtifact, SemanticProject};
use serde_json::{json, Value};
use sha2::{Digest, Sha256};
#[derive(Debug, Clone)]
pub struct KnowledgeNode {
pub node_id: String,
pub artifact_id: Option<String>,
pub display_name: String,
pub kind: String,
pub source_file: String,
pub source_line: u32,
pub signature: Option<String>,
pub effects: Vec<String>,
pub evidence: String,
pub dependencies: Vec<String>,
pub artifact_digest: String,
}
#[derive(Debug, Clone)]
pub struct KnowledgePresentation {
pub document_id: String,
pub title: String,
pub source_digest: String,
/// V2: semantic generation / run matching token (empty when not compiled under CURRENT).
pub semantic_generation: String,
/// V2: page token for SSE stale-packet rejection (digest of document facts).
pub page_token: String,
pub execution_state: String,
pub nodes: Vec<KnowledgeNode>,
pub diagnostics: Vec<String>,
}
impl KnowledgePresentation {
pub fn from_project(project: &SemanticProject, rel: &str, title: &str) -> Self {
let mut nodes = Vec::new();
for artifact in &project.artifacts {
if artifact.source.file != rel {
continue;
}
if artifact.kind == "module" {
continue;
}
nodes.push(node_from_artifact(artifact));
}
let mut hasher_parts: Vec<&str> = project
.artifacts
.iter()
.filter(|a| a.source.file == rel)
.map(|a| a.hashes.artifact.0.as_str())
.collect();
hasher_parts.sort();
let mut h = Sha256::new();
h.update(project.project_id.as_bytes());
h.update(rel.as_bytes());
for part in &hasher_parts {
h.update(part.as_bytes());
}
let digest_hex = format!("{:x}", h.finalize());
let source_digest = format!("sha256:{digest_hex}");
// page_token is filled by caller from raw source so SSE can match without recompile.
let page_token = String::new();
let semantic_generation = {
let mut gh = Sha256::new();
gh.update(project.project_id.as_bytes());
for a in &project.artifacts {
gh.update(a.hashes.artifact.0.as_bytes());
}
format!("{:x}", gh.finalize())[..16].to_string()
};
let mut diagnostics = Vec::new();
for n in &nodes {
if n.evidence == "sourced" {
// Never imply sourced == verified (V2).
diagnostics.push(format!(
"{}: 已关联来源,内容尚未核验",
n.display_name
));
}
}
Self {
document_id: rel.to_string(),
title: title.to_string(),
source_digest,
semantic_generation,
page_token,
execution_state: "not_run".into(),
nodes,
diagnostics,
}
}
pub fn to_json(&self) -> Value {
json!({
"schema_version": 1,
"document_id": self.document_id,
"title": self.title,
"source_digest": self.source_digest,
"semantic_generation": self.semantic_generation,
"page_token": self.page_token,
"execution_state": self.execution_state,
"nodes": self.nodes.iter().map(|n| json!({
"node_id": n.node_id,
"artifact_id": n.artifact_id,
"display_name": n.display_name,
"kind": n.kind,
"source": {"file": n.source_file, "line": n.source_line},
"signature": n.signature,
"effects": n.effects,
"evidence": n.evidence,
"dependencies": n.dependencies,
"artifact_digest": n.artifact_digest,
"verified_claim": false,
})).collect::<Vec<_>>(),
"local_deps": self.nodes.iter().flat_map(|n| {
n.dependencies.iter().map(|d| json!({
"from": n.node_id,
"to": d,
})).collect::<Vec<_>>()
}).collect::<Vec<_>>(),
"diagnostics": self.diagnostics,
})
}
}
/// V2: whether an SSE result packet may update the live document structure.
pub fn sse_accepts_packet(page_token: &str, packet_token: Option<&str>) -> bool {
match packet_token {
None | Some("") => true, // legacy packets without token still apply
Some(_tok) if page_token.is_empty() => true,
Some(tok) => tok == page_token,
}
}
/// Stable page token from raw source bytes (used by SSE run path).
pub fn page_token_from_source(rel: &str, source: &str) -> String {
let mut h = Sha256::new();
h.update(rel.as_bytes());
h.update(source.as_bytes());
let hex = format!("{:x}", h.finalize());
hex[..hex.len().min(32)].to_string()
}
fn node_from_artifact(artifact: &SemanticArtifact) -> KnowledgeNode {
let signature = artifact.signature.as_ref().map(|sig| {
let params = sig
.params
.iter()
.map(|p| format!("{}:{}", p.name, p.ty))
.collect::<Vec<_>>()
.join(", ");
format!("({params}) → {}", sig.returns)
});
KnowledgeNode {
node_id: artifact
.symbol_id
.as_ref()
.map(|id| id.as_str().to_string())
.unwrap_or_else(|| artifact.artifact_id.0.clone()),
artifact_id: Some(artifact.artifact_id.0.clone()),
display_name: artifact.display_name.clone(),
kind: artifact.kind.clone(),
source_file: artifact.source.file.clone(),
source_line: artifact.source.line,
signature,
effects: artifact.effects.values(),
evidence: artifact.verification.evidence.clone(),
dependencies: artifact.dependencies.iter().map(|d| d.0.clone()).collect(),
artifact_digest: artifact.hashes.artifact.0.clone(),
}
}
/// Pull `title:` from YAML frontmatter without a full YAML parser.
pub fn title_from_source(source: &str, fallback: &str) -> String {
let mut lines = source.lines();
if lines.next().map(|l| l.trim_end()) != Some("---") {
return fallback.to_string();
}
for line in lines {
let t = line.trim_end();
if t.trim() == "---" {
break;
}
let trimmed = t.trim();
if let Some(rest) = trimmed.strip_prefix("title:") {
let title = rest.trim().trim_matches('"').trim_matches('\'').to_string();
if !title.is_empty() {
return title;
}
}
}
fallback.to_string()
}
+100 -27
View File
@@ -6,10 +6,15 @@ mod debug_api;
mod debug_page;
mod document;
mod html;
mod knowledge_present;
mod notebook_api;
mod output;
mod render;
pub use knowledge_present::{
page_token_from_source, sse_accepts_packet, title_from_source, KnowledgePresentation,
};
/// Surface rendering of an expression (labels/diagnostics reuse). `<TAB>` M6
pub use render::expr_display;
@@ -383,6 +388,18 @@ pub(crate) fn build_file_view(
rel: &str,
stdin_lines: &[String],
live: bool,
) -> Result<FileViewModel> {
build_file_view_with_exec(root, abs, rel, stdin_lines, live, true)
}
/// Like [`build_file_view`], but `execute=false` skips `run_file_capture` entirely (V0 / `--no-exec`).
pub(crate) fn build_file_view_with_exec(
root: &ViewRoot,
abs: &Path,
rel: &str,
stdin_lines: &[String],
live: bool,
execute: bool,
) -> Result<FileViewModel> {
let mut source = fs::read_to_string(abs).with_context(|| format!("read {}", abs.display()))?;
// Structure shows this file only — do not merge imported lib bodies into the tree.
@@ -423,34 +440,43 @@ pub(crate) fn build_file_view(
// Optional: sandbox to the whole view tree so sibling folders are reachable.
opts.fs_root = Some(root.root.clone());
let mut captured: Option<crate::capture::RunCapture> = None;
let (stdout, stderr, ok, plots, mut bindings_html) = if awaiting_input || auto_stream {
(
String::new(),
String::new(),
true,
Vec::new(),
String::new(),
)
} else {
match run_file_capture(abs, &opts) {
Ok(cap) => {
let stdout = cap.stdout.clone();
let plots = cap.plots.iter().map(|p| p.svg.clone()).collect();
let bindings_html = render_bindings_html(&cap.bindings);
captured = Some(cap);
(stdout, String::new(), true, plots, bindings_html)
}
Err(e) => (
let (stdout, stderr, ok, plots, mut bindings_html) =
if !execute {
(
String::new(),
tidy_user_error(&format!("{e:#}"), abs, rel),
false,
"execution skipped (--no-exec)".into(),
true,
Vec::new(),
String::from(r#"<p class="vars-skipped">skipped</p>"#),
)
} else if awaiting_input || auto_stream {
(
String::new(),
String::new(),
true,
Vec::new(),
String::new(),
),
}
};
)
} else {
match run_file_capture(abs, &opts) {
Ok(cap) => {
let stdout = cap.stdout.clone();
let plots = cap.plots.iter().map(|p| p.svg.clone()).collect();
let bindings_html = render_bindings_html(&cap.bindings);
captured = Some(cap);
(stdout, String::new(), true, plots, bindings_html)
}
Err(e) => (
String::new(),
tidy_user_error(&format!("{e:#}"), abs, rel),
false,
Vec::new(),
String::new(),
),
}
};
// Re-read after run so writeback slots / workbook edits show in Structure.
if !awaiting_input && !auto_stream {
if execute && !awaiting_input && !auto_stream {
if let Ok(next) = fs::read_to_string(abs) {
source = next;
}
@@ -480,9 +506,52 @@ pub(crate) fn build_file_view(
};
// Analysis is intentionally independent from capture/run. If a document
// has side effects, its facts remain visible while its values stay absent.
let knowledge_html = crate::sema::compile_project(&crate::sema::CompileOptions {
project_root: root.root.clone(), entry: Some(abs.to_path_buf()), lock_mode: crate::sema::LockMode::Off,
}).map(|compilation| render_knowledge_html(&compilation.semantics, rel)).unwrap_or_default();
let title_guess = crate::view::title_from_source(&source, rel);
let (knowledge_html, knowledge_error, page_token) =
match crate::sema::compile_project(&crate::sema::CompileOptions {
project_root: root.root.clone(),
entry: Some(abs.to_path_buf()),
lock_mode: crate::sema::LockMode::Off,
}) {
Ok(compilation) => {
let html = render_knowledge_html(&compilation.semantics, rel);
// V1: also materialize structured presentation (JSON available to page scripts).
let mut presentation = crate::view::KnowledgePresentation::from_project(
&compilation.semantics,
rel,
&title_guess,
);
presentation.page_token = crate::view::page_token_from_source(rel, &source);
let json = presentation.to_json().to_string();
let with_model = if html.is_empty() {
format!(
r#"<script type="application/json" id="mq-knowledge-presentation">{json}</script>"#,
json = json.replace("</", "<\\/")
)
} else {
format!(
r#"{html}<script type="application/json" id="mq-knowledge-presentation">{json}</script>"#,
html = html,
json = json.replace("</", "<\\/")
)
};
(
with_model,
String::new(),
presentation.page_token.clone(),
)
}
Err(e) => (
String::new(),
format!("知识关系暂不可用:{}", tidy_user_error(&format!("{e:#}"), abs, rel)),
crate::view::page_token_from_source(rel, &source),
),
};
let page_token = if page_token.is_empty() {
crate::view::page_token_from_source(rel, &source)
} else {
page_token
};
Ok(FileViewModel {
rel_path: rel.to_string(),
source,
@@ -500,6 +569,8 @@ pub(crate) fn build_file_view(
bindings_html: std::mem::take(&mut bindings_html),
trace_json,
knowledge_html,
knowledge_error,
page_token,
})
}
@@ -752,6 +823,7 @@ fn api_run(root: &ViewRoot, mut request: Request) -> Result<()> {
}
Err(_) => (String::new(), String::new()),
};
let page_token = crate::view::page_token_from_source(&rel_clone, &source_now);
let done = serde_json::json!({
"type": "done",
"run_id": run_id,
@@ -761,6 +833,7 @@ fn api_run(root: &ViewRoot, mut request: Request) -> Result<()> {
"bindings_html": bindings_html,
"structure_html": structure_html,
"trace_json": trace_json,
"page_token": page_token,
});
crate::host::event_bus::EventBus::global().publish_json(&done.to_string());
}
+3 -21
View File
@@ -11,7 +11,7 @@ use crate::host::foreign_doc::DocumentSession;
use crate::host::json::json_to_value;
use crate::value::Value;
use crate::view::html::{escape, page_file, page_index, LinkMode};
use crate::view::{build_file_view, build_root, ViewRoot};
use crate::view::{build_file_view, build_file_view_with_exec, build_root, ViewRoot};
pub struct OutputOptions {
pub path: PathBuf,
@@ -280,26 +280,8 @@ pub fn write_static(opts: OutputOptions) -> Result<()> {
for rel_pb in &root.files {
let rel = rel_pb.to_string_lossy().replace('\\', "/");
let abs = resolve_abs(&root, &rel)?;
let mut vm = build_file_view(&root, &abs, &rel, &[], false)?;
if opts.no_exec {
vm.stdout.clear();
vm.stderr = "execution skipped (--no-exec)".into();
vm.ok = true;
vm.plots.clear();
vm.bindings_html = String::from(r#"<p class="vars-skipped">skipped</p>"#);
vm.trace_json.clear();
// Rebuild outline + Structure without run annotations.
if let Ok(module) = crate::parse::parse_source(&vm.source) {
let wb = crate::view::render::render_writeback_outline(&vm.source);
vm.outline_html =
crate::view::render::render_right_rail(&module, &vm.bindings_html, &wb);
vm.structure_html = crate::view::render::render_module_structure_with_annots(
&module,
&vm.source,
&[],
);
}
}
// V0: apply --no-exec before any capture run (do not execute then clear).
let vm = build_file_view_with_exec(&root, &abs, &rel, &[], false, !opts.no_exec)?;
let links = LinkMode::Static {
from: Some(rel.clone()),
};
+47 -6
View File
@@ -44,23 +44,38 @@ pub struct FileViewModel {
/// SVG plots from math lib (embedded in Execution).
pub plots: Vec<String>,
/// HTML for Variables panel (entry bindings after run).
#[allow(dead_code)]
pub bindings_html: String,
/// ViewExecutionReport JSON for AI / call-picker (empty if no run).
pub trace_json: String,
/// Static semantic facts; generated without evaluating the document.
pub knowledge_html: String,
/// Visible when semantic analysis fails (V0); empty when analysis succeeded or was skipped.
pub knowledge_error: String,
/// V2: page token for SSE stale-packet rejection (empty when unknown).
pub page_token: String,
}
/// A compact, textual (not colour-only) explanation of executable knowledge.
/// View deliberately compiles semantics without running the target, so a page
/// can show binding/effect/verification facts even in `--no-exec` exports.
///
/// V0: skip module/type container cards by default; rename lock digest accurately.
pub fn render_knowledge_html(project: &crate::sema::SemanticProject, rel: &str) -> String {
let artifacts: Vec<_> = project.artifacts.iter().filter(|artifact| artifact.source.file == rel).collect();
let artifacts: Vec<_> = project
.artifacts
.iter()
.filter(|artifact| {
artifact.source.file == rel && artifact.kind != "module" && artifact.kind != "type"
})
.collect();
let steps: Vec<_> = project.steps.iter().filter(|step| step.source.file == rel).collect();
if artifacts.is_empty() && steps.is_empty() { return String::new(); }
if artifacts.is_empty() && steps.is_empty() {
return String::new();
}
let mut out = String::from(r#"<div class="knowledge-panel" aria-label="Executable knowledge">"#);
if !steps.is_empty() {
out.push_str(r#"<article class="knowledge-card knowledge-steps"><h3>Steps</h3><ol class="knowledge-step-list">"#);
out.push_str(r#"<article class="knowledge-card knowledge-steps"><h3>文档中的步骤</h3><p class="knowledge-hint">结构步骤(非实际执行时序)</p><ol class="knowledge-step-list">"#);
for step in &steps {
let label = project
.refs
@@ -93,12 +108,38 @@ pub fn render_knowledge_html(project: &crate::sema::SemanticProject, rel: &str)
let signature = artifact.signature.as_ref().map(|sig| {
let params = sig.params.iter().map(|param| format!("{}: {}{}", param.name, param.ty, if param.required { "" } else { "?" })).collect::<Vec<_>>().join(", ");
format!("({params}) → {}", sig.returns)
}).unwrap_or_else(|| "module/type declaration".into());
}).unwrap_or_else(|| "declaration".into());
let effects = artifact.effects.values().join(", ");
let deps = if artifact.dependencies.is_empty() { "none".to_string() } else { artifact.dependencies.iter().map(|id| id.0.as_str()).collect::<Vec<_>>().join(", ") };
// Short digest for display; full value in title for copy.
let digest = &artifact.hashes.artifact.0;
let digest_short = if digest.len() > 20 {
format!("{}…", &digest[..20])
} else {
digest.clone()
};
let evidence_note = match artifact.verification.evidence.as_str() {
"sourced" => "已关联来源,内容尚未核验",
"verified" => "证据已核验",
"unverified" => "尚无来源记录",
other => other,
};
out.push_str(&format!(
r#"<article class="knowledge-card"><h3>{}</h3><dl><dt>Target</dt><dd><code>{}</code></dd><dt>Kind</dt><dd>{}{}</dd><dt>Signature</dt><dd><code>{}</code></dd><dt>Effects</dt><dd>{}</dd><dt>Verification</dt><dd>parse: {}; resolve: {}; contract: {}; tests: {}; evidence: {}</dd><dt>Lock digest</dt><dd><code>{}</code></dd><dt>Depends on</dt><dd><code>{}</code></dd><dt>Execution</dt><dd>Not executed by knowledge preview.</dd></dl></article>"#,
escape(&artifact.display_name), escape(target), escape(&artifact.kind), artifact.callable.as_ref().map(|callable| format!(" ({})", escape(callable))).unwrap_or_default(), escape(&signature), escape(&effects), escape(&artifact.verification.parse), escape(&artifact.verification.resolve), escape(&artifact.verification.contract), escape(&artifact.verification.tests), escape(&artifact.verification.evidence), escape(&artifact.hashes.artifact.0), escape(&deps),
r#"<article class="knowledge-card" id="knowledge-{name}"><h3>{name} <span class="ks-kind">{kind}</span></h3><dl><dt>Target</dt><dd><code>{target}</code></dd><dt>Signature</dt><dd><code>{sig}</code></dd><dt>Effects</dt><dd>{effects}</dd><dt>Verification</dt><dd>parse: {parse}; resolve: {resolve}; contract: {contract}; tests: {tests}; evidence: {evidence}({evidence_note})</dd><dt>制品摘要</dt><dd><code title="{digest}">{digest_short}</code> <span class="knowledge-hint">(未检查锁定状态)</span></dd><dt>Depends on</dt><dd><code>{deps}</code></dd><dt>Execution</dt><dd>尚无该知识的运行记录(知识预览不执行)。</dd></dl></article>"#,
name = escape(&artifact.display_name),
kind = escape(&artifact.kind),
target = escape(target),
sig = escape(&signature),
effects = escape(&effects),
parse = escape(&artifact.verification.parse),
resolve = escape(&artifact.verification.resolve),
contract = escape(&artifact.verification.contract),
tests = escape(&artifact.verification.tests),
evidence = escape(&artifact.verification.evidence),
evidence_note = escape(evidence_note),
digest = escape(digest),
digest_short = escape(&digest_short),
deps = escape(&deps),
));
}
out.push_str("</div>");