feat: migrate View 0.3.0 to marqdo 3.0.0-rc.4 contracts
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:
Marqdo View committed 2026-11-25 22:12:51 +08:00
1 parent 7b34199c96
commit 340ecb035f
108 files changed
+13928 -6461

No files matched your search

+4
View File
@@ -1,5 +1,9 @@
# 旧 View 渲染路径审计(PR-00)
> **历史取证**:本文记录旧渲染路径的静态审计,仅作迁移历史;当前实现与契约见
> [`docs/STATUS.md`](../STATUS.md)。
> 状态:**静态审计完成,运行时验证未执行(`LEGACY_RUNTIME_UNVERIFIED`)**
> 审计对象:`cflmy/marqdo` `main@1c55baabd570e18b9da8f9057cef2f848e176690`(下称“旧仓库”)
> 审计方式:只读源码检查(`git status` 干净;**没有**编译、没有写入、没有移动旧仓库任何文件)
+5
View File
@@ -1,5 +1,10 @@
# 旧 View 静态取证与迁移裁决(RFC-VIEW-0002 §3 / PR-00)
> **历史取证**:本文记录旧 View 的静态审计,仅作迁移历史;当前契约与状态见
> [`docs/STATUS.md`](../STATUS.md) 与
> [`observation-v1-and-analysis-v3.md`](../architecture/observation-v1-and-analysis-v3.md)。
- 状态:静态源码审计完成,**旧运行时浏览器复验未执行**
(`LEGACY_RUNTIME_UNVERIFIED`)
- 日期:2026-11-22
+5
View File
@@ -1,5 +1,10 @@
# 协议一致性审计(P-03)
> **历史审计(0.2.0 时代)**:本文快照只对其当时基线有效,不是 0.3.0 的当前证据。
> 当前冻结 CLI 合同审计见 [`protocol-contract-0002.md`](protocol-contract-0002.md)
> 与 [ADR-0012](../decisions/0012-rc4-current-contracts.md)。
> 结论:View 只消费冻结 CLI 的公开 Tool v1 / Analysis v2 / Trace v2 协议;
> 未实现或未提供的能力显式标注 `UNSUPPORTED`。本文把规范条款映射到实现与测试,
> 便于审阅者不依赖对话历史复核。
+190 -197
View File
@@ -1,222 +1,215 @@
# 冻结 CLI 公共合同黑盒审计(RFC-VIEW-0002 §2 / PR-00)
# 冻结 CLI 公共合同黑盒审计(marqdo-view 0.3.0 / rc.4)
- 状态:已用发行二进制黑盒复现;**CLI 源码只读,不修改、不重编译**
- 日期:2026-11-22
- 发行基线:`marqdo 3.0.0-beta.1`(tag `v3.0.0-beta.1`,
`2c7c4f31e7a388d3fcfa717a77067e696ed13854`)
- 二进制:`/root/work/marqdo-cli/dist/marqdo-3.0.0-beta.1-x86_64-unknown-linux-gnu/marqdo`
- SHA-256:`062cb56e226bee55c21d238e195920caa985e62bb3877ba7b07abcc04dc0fe3f`
- 平台:`x86_64-unknown-linux-gnu`;协议:Tool v1 / Analysis v2 / Trace v2 /
Markdown Profile `marqdo.md.v1`
- 规范来源:`/root/work/marqdo-cli/spec/{tool-v1,analysis-v2,trace-v2,callable-resolution,value-wire}.md`、
`spec/schemas/*.json`、`crates/cli/src/commands/run.rs`(只读参考)。
- 日期:2026-11-25
- 发行基线:`marqdo 3.0.0-rc.4`(tag `v3.0.0-rc.4`,
源码提交 `452e9a32bd9e40dba427d4180691c58bab74449e`)
- 归档:`marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu.tar.gz`,
SHA-256 `9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8`
- 二进制(归档内 `marqdo`):
`/root/work/marqdo-cli/dist/marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu/marqdo`,
SHA-256 `a7306962689c635445a59043971ea2eb09298e01feeee81f0ba07b1f3e10306e`
- 平台:`x86_64-unknown-linux-gnu`;当前契约:CLI Tool revision 1(`api_revision` 1)/
Analysis revision 3(ADR-0069 公共边界)/ Observation revision 1 /
Markdown profile `marqdo.md.v1`
- 规范来源:`marqdo-cli@v3.0.0-rc.4` 的 `spec/{analysis,observation,cli-tool,references,
markdown-profile,value-wire}.md`、`docs/adr/0068-*.md`、`docs/adr/0069-*.md`;
正式发布后若规范更新,以**确切发布版**为准,不以本文代替规范。
> 本文是 marqdo-view 实现与测试的合同摘要。任何字段都以“规范 + 黑盒复现二选一”
> 为依据;未复现项显式标 `UNVERIFIED`,绝不推断。
> 本合同摘要依据“规范 + 黑盒复现二选一”。未复现项显式标 `UNVERIFIED`,绝不推断。
> 本文件只描述**当前**契约;0.2.0 时代的旧格式已从当前树与当前文档移除,
> 仅保留在 Git 历史与 CHANGELOG 的 History 段。
## 1. 命令面(`--help` 实测)
- `run [FILE]`:运行入口文件 `main`;`--mode` 默认 **`project`**(View 必须显式传
`--mode pure`)。
- `call <FILE> <FUNCTION>`:调用命名函数;`--arg <NAME=VALUE>` 常量表达式,可重复。
```text
marqdo 3.0.0-rc.4
run Run the entry function (`main` by default) of a document
call Call a named function with typed arguments
check Statically check a document without executing it
inspect Inspect AST, units, signatures, IR, references or platform support
...
tool Manage and dispatch generic external CLI tools
```
- `check [FILE] [--refs] [--emit PATH] [--json]`:纯静态,不执行。
- 预算/追踪参数(`run`/`call` 共有):`--fuel`、`--stack`、`--max-output`、
`--timeout`、`--trace-file`、`--trace-max-events`、`--trace-max-bytes`。
- 权限参数:`--allow-read/--allow-write/--allow-net/--allow-env/--allow-process/
--allow-random/--allow-foreign/--allow-plugin/--plugin/--provider/--allow-provider/
--kernel/--trust-native-plugin`。View 首版只使用 `--allow-read/--allow-write`
(且仅在显式 `project` 请求中),其余一律不暴露。
- 未知顶层命令通过 Tool v1 注册表分发到外部二进制(`spec/tool-v1.md`)。
`--json` 只输出 check 诊断摘要;`--emit` 是完整 Analysis 的唯一写出者。
- `run`/`call`:默认 `--mode project`(View 必须显式传 `--mode pure` 或带白名单的
`--mode project`)。`--output text|json|jsonl` 默认 `text`;`--observation-file PATH`
原子发布同一执行的快照。`--observe-variable NAME`、`--observe-parameter NAME`、
`--observe-text-values`、`--observe-max-events`、`--observe-max-bytes`、
`--observe-max-value-bytes` 控制观测选择与预算。
- 已退休的运行参数在当前 CLI 中直接触发“unexpected argument”并以 exit 2 结束;
View 不得在失败后换旧参数重试。
- 预算/权限参数:`--fuel`、`--stack`、`--max-output`、`--max-memory`、
`--timeout`、`--allow-read/--allow-write/...`。View 首版只使用
`--mode` 与 `--allow-read/--allow-write`(且仅在显式 `project` 请求中)。
- `inspect --ast` 可用于人工调试,但**不得**作为渲染语义的机器来源;渲染语义只来自
同一次 `check --emit`。
## 2. `check --emit` 合同
规范:`spec/analysis-v2.md` §1;实测:
实测(`examples/control-flow/index.mq.md`、`examples/function-params.mq.md`):
| 场景 | 结果 |
| 场景 | 观察 |
|---|---|
| 成功 | exit 0;`--json` stdout 为 `{"command":"check","diagnostics":[],"errors":0,"success":true}`;`--emit` 路径写出 Analysis v2 精确 UTF-8 字节(pretty JSON),原子写入 |
| 失败 | exit 1;stdout 为 `{"command":"check","diagnostics":[...],"errors":N,"success":false}`;**逐条诊断带 `code/severity/message/line/column/module/hints`**(`file` 可能出现绝对路径,View 必须不泄漏/只保留相对信息) |
| stale emit | 失败时 **删除目标路径的旧文件**(实测:先写 `stale.json` 再失败 check,文件不存在)。View 必须同样丢弃自己的旧 Analysis 缓存 |
| `--refs` | 额外链接检查,可能产生额外 `diagnostics`;不得当作语言执行/编译成功证明 |
| 成功 | exit 0;`--json` stdout 输出 `success:true` 诊断摘要;`--emit` 路径写出 Analysis revision 3 的精确 UTF-8 字节(pretty JSON),owner-only 临时文件 + 原子 rename |
| 失败 | exit 1(静态诊断错误)或 exit 2(参数/入口不可读/输出发布失败);不发布成功工件,可能按合同删除调用者指定的旧 emit 文件 |
| `--refs` | 额外链接检查,改变 diagnostics,因此改变 artifact 字节;不能替代普通 emit 作为运行绑定 |
| 无绝对路径 | 相同逻辑项目从不同 checkout 目录 emit 字节一致;错误位置只用 `relative_path`/`line`/`column` |
`AnalysisDigest` = `sha256:` + 精确 emit 文件字节的小写 hex SHA-256;**不是**
反序列化再序列化的哈希。`Trace v2.source.analysis_digest` 必须与它一致。
`AnalysisDigest` = `sha256:` + 精确 emit 文件字节的小写 hex SHA-256(含格式)。
Observation `run.started.payload.source.analysis_digest` 必须与它一致。
## 3. Analysis v2 关键字段(View 消费面)
## 3. Analysis revision 3 关键字段(View 消费面)
- 顶层:`schema="marqdo.analysis"`、`schema_version=2`、`producer{name,version,
markdown_profile}`、`project{root_id,identity_kind,lock_digest,stdlib}`、
`modules[]`、`diagnostics[]`。
- `project.root_id`:`root:<name>@<version>`(有 manifest)或
`sha256:<workspace snapshot>`;是 Trace `source.root_id` 的唯一比对值。
- `modules[].{id,package_instance_id,relative_path,source_digest,units,functions,
imports,references,calls,resources}`。`source_digest` = 精确源文件字节的 SHA-256
(不含 `sha256:` 前缀)。
- `functions[].{id,unit_id,local_name,namespace,span,heading_span,signature{kind,
params[]},body,effects}`;`params[].{name,required,type,default,span}`。
`signature.kind` 为 `explicit|inferred`;`required = default.is_none()`。
- `units[].kind`:`root|namespace|function|knowledge|section`,带 `level`、
`span`、`function`、`name`、`id`。**Analysis 不公开 H3+ 的最终 EffectiveMode**;
View 不得自行重建并宣称为编译器状态(RFC §2.7)。
- `diagnostics[]` 标记 UTF-8 字节 `span`(`start/end`)或行列;View 显示原文与
诊断即可,不从错误推断 IR。
实测顶层与模块字段:
```text
top-level: schema="marqdo.analysis", schema_version=3,
producer{name,version,markdown_profile},
project{root_id, identity_kind, entry_module_id, lock_digest,
manifest_digest, stdlib, extensions},
modules[], diagnostics[]
module: id, package_instance_id, relative_path, source_digest, source,
document, units[], anchors[], functions[], imports[], references[],
calls[], resources[]
unit: id, path[](结构化), parent_id, kind, name, level, mode, mode_origin,
mode_source_unit_id, heading_span, span, function
function: id, unit_id, local_name, namespace, span, heading_span, signature, effects, body
reference:source, source_unit, url, span, state, target_kind, target_module,
target_unit, candidate_package_instance_id, candidate_path, fragment, candidates
```
关键语义:
- `source` 是精确 UTF-8 源文本;所有 `span` 是 half-open UTF-8 字节区间,
`source_digest` = `sha256(source 解码字节)`。消费者不得从 `relative_path` 重读文件
重建 span。
- `units` 的 `heading_span` = 标题 AST 节点范围(标题 UI/目录/锚点);
完整 `span` = 到下一个同级或更高层标题(或 EOF)的 section 范围(内容高亮/切片/归属)。
`path` 是结构化数组;不得 split display id。
- `anchors` 是 `[{anchor, unit_id}]`,anchor 是导航名称,不是身份。
- `calls[].state` 为 `function|builtin|plugin|unresolved`;`unresolved(dynamic|unbound)`
是合法静态结果,不是编译错误。`target_owner` 只携带静态身份,不伪造函数节点。
- `resources` 只投影 `formula`/`code`;`content_digest` 对应 AST literal;
公式 `display` 为 bool,代码为 `null`。
- `diagnostics[]` 已包含文件内诊断;不得用 `inspect` 或私有 IR 生成第二套。
- `effects` 是保守摘要(如 `["unknown"]`),不是纯度证明,不能作为“安全运行”依据。
黑盒样例(`target/probe/function-params.mq.md`,2 个 H1/H2 中文标题)证明:
中文 namespace/local_name、UTF-8 `span`、`heading_span`、`unit_id` 均按字节偏移
给出;`id` 形如
`root:<name>@<ver>::<relative path>::<namespace>.<local_name>`(无 namespace 时
`::<local_name>`)。
## 4. 引用状态(实测 fixture)
## 4. 函数定位与 `call` 的名称解析(关键)
用 `examples` 之外的最小 fixture(单文档,未加载其它模块)实测:
CLI `call FILE FUNCTION` 的查找实现:`Module::function(name)`
(`crates/marqdo-ir/src/lib.rs:404`,只读参考),规则为:
1. 先按 **canonical qualified name**(`function.id.name`,如
`计算示例.double`)完全匹配;
2. 否则按 `local_name` 匹配,且必须**唯一**;同名跨 namespace 重复时返回
`None`,CLI 报 `sem.no_entry_function`,没有“文档顺序优先”。
实测:`call function-params.mq.md 计算示例.double --arg n=7 --mode pure` 成功;
`call function-params.mq.md double` 成功(唯一 local name)。因此 View 必须:
- `target.function_id` 从**当前入口模块** Analysis 的 `functions[]` 精确取得;
- 服务端把 `function_id` 解析为该函数的 CLI 名称:若 `local_name` 在入口模块内
唯一(或与 namespace 无关地唯一)用 `local_name`,否则用
`<namespace>.<local_name>`;**不能**把客户端字符串直接拼接为参数;
- 只允许入口模块函数;依赖模块函数不是 `call FILE FUNCTION` 的目标
(RFC §6.3)。
## 5. `run` / `call` 的 JSON 包络(实测差异,必须容忍)
成功(`run` 与 `call` 同形):
```json
{"command":"run|call","success":true,
"value":{"type":"<wire tag>", "...": "..."},
"stdout":"...","stderr":"...","diagnostics":[],
"trace":[]}
```
`value` 是 Wire Value(`spec/value-wire.md` v1),**不是任意字符串**:
| type | 形状 |
|---|---|
| `unit` | `{"type":"unit"}` |
| `none` | `{"type":"none"}` |
| `bool` | `{"type":"bool","value":true}` |
| `int` | `{"type":"int","decimal":"-123..."}`(十进制字符串,不丢精度) |
| `float` | `{"type":"float","value":1.5}` 或 `{"type":"float","special":"nan|infinity|-infinity"}` |
| `text` | `{"type":"text","value":"..."}` |
| `list` | `{"type":"list","items":[...]}` |
| `map` | `{"type":"map","entries":{"k":<value>}}` |
| `table` | `{"type":"table","header":[...],"rows":[[...]]}` |
| `formula` / `code` | 惰性数据(latex/source 等) |
| `function_ref` | `{"type":"function_ref","module":"...","name":"..."}` |
| `plugin_handle` | `{"type":"plugin_handle",...}` |
| `memory` / `resource` | 仅 `{"type":"memory"}`/`{"type":"resource"}`,**不可解码/不应出现** |
失败包络**不统一**(实测两种,至少):
```json
// A. prepare/semantic 失败(如无 main、函数不存在):error 是字符串,另有顶层 code
{"command":"run","success":false,"code":"sem.no_entry_function",
"error":"<file> has no callable `main`; ..."}
// B. 运行期失败(类型/预算等):error 是对象,含 code/message/line/column/span/...
{"command":"call","success":false,
"error":{"code":"runtime.type","message":"...","span":{...},"frames":[...]},
"stdout":"","stderr":"","trace":[]}
```
**实现要求**:任何失败路径都不得 `unwrap` `value`/`trace`/`stdout`/`stderr`;
`success:true` 但 `value` 缺失时按 `unit` 谨慎显示;`success:false` 时保留
`code`(顶层或 `error.code`)和可读消息;stdout/stderr 一律当用户文本。
关于 `trace` 数组:`run --json` 顶层 `trace` 实测可能为 `[]`(即使
`--trace-file` 写了完整 Trace v2)。**结构化运行证据只以 `--trace-file` 文件为准**,
不能把 JSON 里的 `trace` 当 Trace v2。
## 6. Trace v2 合同(`--trace-file`)
规范:`spec/trace-v2.md`;实测 `target/probe/t2.json`:
- 顶层:`schema="marqdo.trace"`、`schema_version=2`、
`run{id,entry,status}`、`source{root_id,analysis_digest}`、
`limits{max_events,max_bytes}`、`truncated`、`events[]`。
- 事件:`seq`(全局递增)、`kind`、`function_id`、`module_id`、`span`、
`detail`;`effect` 另有 `operation`/`duration_micros`。
- kind:`call.enter|call.exit|return|branch.eval|loop.iteration|effect|
trace.truncated`;未来新增 kind 必须忽略或保守显示,不得猜测。
- 有 span 的事件必须指定真实 `module_id` 与 UTF-8 字节 `span`;
无 span 的 `call.enter/call.exit`(entry call)可 `span:null`。
- `truncated:null | {"reason":"event_budget|byte_budget","limit":N,"written":M}`;
截断只代表观测预算耗尽,不代表程序失败;末事件为 `trace.truncated`。
- **不记录**参数值、逐语句变量值、Handle、文件内容、秘密。View 不得伪造这些值。
- 认证绑定(RFC §2.6):把 `source.analysis_digest` 与**同一源码、同一检查配置**
的 Analysis 原始字节 SHA-256 比较;再核对 `source.root_id`、`module_id` 属于
Analysis `modules[]`、span 边界/UTF-8 合法、模块 `source_digest` 等于当前源码
字节哈希。任一不符 → 不画执行标注。
- 实测 `--trace-max-events 2`:`truncated={reason:event_budget,limit:2,written:2}`,
events 数 3(含 `trace.truncated`)。View 的 `--trace-max-events 10000`、
`--trace-max-bytes 4194304` 是上限而非保证。
## 7. Tool v1 安装/分发(View 打包依据)
规范:`spec/tool-v1.md`。要点(源码 + 既有验收证据):
- `tool.json` 必填:`schema="marqdo.cli-tool"`、`schema_version=1`、`name`、
`version`(合法 SemVer)、`command`、`entrypoint`(包内受控相对路径)、
`compatibility{marqdo:"<semver range>", analysis:[2], trace:[2]}`。
- 安装:校验 schema/SemVer/协议交集/entrypoint 不越界/命令冲突 → 收集整包
规范化文件清单(path/size/sha256,拒绝符号链接/特殊文件)→ staging 复制并
复算一致 → 原子发布;失败清理 staging。
- 分发:启动前重新计算磁盘整包清单并与记录逐项比较;**修改已安装包任意一个字节
后分发被拒绝**(tests 已覆盖,见 `scripts/install-smoke.sh`)。
- 运行时向工具注入 `MARQDO_TOOL_PROTOCOL=1`、
`MARQDO_PROTOCOL_ANALYSIS=2`、`MARQDO_PROTOCOL_TRACE=2`(兼容协商成功时);
原样保留 cwd/stdin/stdout/stderr 与可保留环境,用
`Command::new(entrypoint).args(args)` 直接启动,不经过 shell,退出码原样传播。
- 这些环境变量只表示协议版本,**不是**执行授权;权限仍由 `--mode`/grants 决定。
## 8. 对 View 实现的硬性含义
1. 运行请求必须由服务端重新 `check --emit` 并保存**精确 Analysis 字节 + digest**;
POST 校验顺序中的 Analysis SHA 比对以它为唯一参照,运行后 Trace 也绑定它。
2. `run` 与 `call` 的 argv 由 `core_client`/`process` 以数组构造,显式
`--mode pure` 或带白名单 grants 的 `project`;永不经过 shell。
3. 显式预算:`--timeout 30`(View 另设墙钟上限,默认 30s、最大 120s)、
`--fuel 1000000`、`--max-output 1048576`、`--trace-max-events 10000`、
`--trace-max-bytes 4194304`;接收侧再设 4 MiB JSON / 4 MiB trace 上限。
4. Value 展示按 §5 白名单类型做结构化文本;未知类型折叠为转义 JSON;不得
把 `value` 当变量全集、不得当 HTML。
5. `call` 的目标名按 §4 由 function_id 精确解析;无 main 时 `run` 会返回
`sem.no_entry_function`(实测),View 应提前提示并引导选择函数,绝不替换成别的函数。
6. 运行失败时 `trace` 文件可能不存在(实测 no-main 无 trace 文件);视为
“Trace 不可用”,不是伪造空 Trace。
## 9. 黑盒证据表
| # | 命令(在 `target/probe` 内) | 观察 |
| 输入 | state | 观察 |
|---|---|---|
| 1 | `marqdo --version` | `marqdo 3.0.0-beta.1`;SHA 见头部 |
| 2 | `check function-params.mq.md --emit a1.json --json` | exit 0,success:true,写出 Analysis v2 |
| 3 | `check broken.mq.md --emit stale.json --json` | exit 1,failure JSON,旧 `stale.json` 被删除 |
| 4 | `call function-params.mq.md double --arg n=5 --mode pure --json --trace-file t1.json` | exit 0,`value={type:int,decimal:10}`,Trace v2 写入 |
| 5 | `call function-params.mq.md 计算示例.double --arg n=7 --mode pure` | exit 0,`decimal:14`(canonical 名称可用) |
| 6 | `call function-params.mq.md double --arg 'n="x"' --mode pure --json` | exit 1,`error.code=runtime.type`(对象包络) |
| 7 | `call function-params.mq.md double`(缺 required 参数) | exit 1,`error.code=call.arity` |
| 8 | `call function-params.mq.md nope --mode pure` | exit 1,顶层 `code=sem.no_entry_function`,`error` 为字符串 |
| 9 | `run branch-loop.mq.md --mode pure --json --trace-file t2.json` | exit 0,value int 0;Trace 事件含 loop.iteration/return/call.enter/call.exit |
| 10 | `run branch-loop.mq.md --trace-max-events 2 --trace-file lim.json` | exit 0,`truncated={event_budget,limit:2,written:2}` |
| 11 | `run nomain.mq.md --mode pure --json --trace-file nomain-trace.json` | exit 1,`sem.no_entry_function`,**无 trace 文件** |
| 12 | `run branch-loop.mq.md --json`(未传 mode) | 成功,但 `--help` 证明默认值是 `project`(View 不能依赖此默认) |
| `#引用状态`(同页标题) | `resolved` | `target_kind: module`,fragment 已解码,target_unit 存在 |
| `./theory.mq.md`(未加载) | `not_loaded` | `target_unit: null`;表示当前 catalog 未核验,**不是** missing |
| `#不存在的标题` | `missing` | target fields null |
| `https://example.com/x` | `external` | 不联网;不是错误 |
| `../../../etc/passwd` | `outside_scope` | 不读目标;不输出物理路径 |
| `%zz` | `invalid` | 不做猜测修复 |
## 10. 未复现项(UNVERIFIED)
`check --refs` 会构建显式扩展 catalog 并追加诊断;如果该次检查带 error,则 exit 1
且不发布 artifact。View 的引用 UI 必须按 `state` 渲染:
`not_loaded` 显示“未核验”,`ambiguous` 列出 candidates,绝不静默选第一个。
**`UNVERIFIED`**:`ambiguous` 的稳定黑盒样本(需要两个同名 canonical 候选)与
`resolved` 的 `target_kind: file` 分支未在本次探针中复现;实现按规范校验,证据待补。
## 5. Observation revision 1
实测(`call function-params.mq.md double --arg n=5 --mode pure --output jsonl
--observation-file obs.json`):
- 事件:`stream.opened`、`run.started`、`call.enter`、`parameter.observed`、
`return`、`call.exit`、`run.completed`;每行 `schema:"marqdo.observation"`、
`schema_version:1`、同一 `run_id`、连续 `seq`(0 起)。
- 快照:`{schema, schema_version, run{id, source{analysis_digest,root_id}, status},
capture{level, ...}, events[]}`;同一次执行的 JSONL 行与快照 `events` 逐项相等。
- `run.completed.payload.value` 是 Value Wire(如 `{"type":"int","decimal":"10"}`)。
- `--observe-max-events 2` 实测:`capture.truncated={reason:"event_budget",limit:2,
written:2}`,事件含 `observation.truncated`,最后仍有真实终态;截断**不代表**
程序失败,UI 必须显示 TRUNCATED,不得声明完整。
- 事件错误位置只携带 `module_id`/`relative_path`/`line`/`column`/`span`;
不出现绝对主机路径。
- `stdout.chunk`/`stderr.chunk` 是 base64 字节块;解码后必须与程序输出一致。
- `parameter.observed`/`variable.assigned` 默认不携带值;只有显式
`--observe-parameter`/`--observe-variable`(Text 另需 `--observe-text-values`)
才发布所选标量。内存/资源/句柄永不发布。
- `--mode strict` 只支持 text/JSON stdout;`--output jsonl` 与 `--observation-file`
在启动前 exit 2(`strict.unsupported_grant`)。View 明确拒绝,不回退 `project`。
- EOF/中断且无终态 = 未完成/无结论,不得渲染为成功。
**`UNVERIFIED`**:`run.rejected` 的完整错误码矩阵、`effect.operation` 的具体集合、
多模块事件的跨模块归属由 View 测试覆盖;本审计只复现了 entry 单模块样本。
## 6. Tool revision 1(View 打包/安装依据)
规范 `spec/cli-tool.md`;实测:
```json
{
"schema": "marqdo.cli-tool",
"schema_version": 1,
"name": "marqdo-view",
"version": "0.3.0",
"command": "view",
"entrypoint": "bin/marqdo-view",
"requires": {"api_revision": 1, "analysis": 3, "observation": 1}
}
```
- 必填精确值:`requires.api_revision = 1`;声明 `analysis`/`observation` 时必须是
单个精确整数。没有 `compatibility` 字段、没有版本数组协商。
- 实测 `tool install` 成功 → `tool list` 输出 `demo-view 0.3.0 (marqdo-view)` →
分发时注入 `MARQDO_BIN` 与 `MARQDO_API_REVISION=1`,不注入旧协商变量。
- 实测旧清单(带 `compatibility`)安装失败:`invalid tool.json: unknown field
compatibility ... Build the tool with current exact protocol requirements`,
无迁移器。
- 安装:校验 schema/SemVer/revision/entrypoint 不越界/命令冲突 → 整包规范化文件
清单(path/size/sha256,拒绝符号链接/特殊文件)→ staging 复制复算 → 原子发布;
分发前重算磁盘整包清单,任一字节被改即拒绝。
- 这些环境变量只表示 API revision,**不是**执行授权;权限仍由 `--mode`/grants 决定。
## 7. 对 View 实现的硬性含义
1. 一次入口一次 `check --emit`:保存精确 Analysis 字节 + digest;`inspect --ast`
不再作为机器来源。
2. 运行只解析 Observation v1:JSONL 流是生产来源,原子快照用于测试等价断言;
View 不双读合并、不重编号、不重排、不合成。
3. 运行 argv 由 `core_client`/`process` 以数组构造:`run|call --output jsonl
--observation-file <tmp>`;显式 `--mode pure` 或白名单 grants;永不经过 shell。
4. Trace 绑定改为 Observation 绑定:`source.analysis_digest` + `root_id` +
`module_id` + 模块 `source_digest` + UTF-8 半开 span;任一不符 →
`view.observation_stale` 或等价错误,不显示成功、不错误高亮。
5. `--refs` 改变 artifact 字节,不能用于运行绑定;需要磁盘实时性时重新 check 并比较 digest。
6. 未知字段/旧同 revision 制品显式拒绝并给出可执行提示(重新生成/升级核心/重装 Tool)。
7. 值默认不请求、不发布;不伪造变量/内存状态。
8. 失败/截断/未完成必须诚实呈现;`UNSUPPORTED`/`PARTIAL`/`WARN` 不得写成 PASS。
## 8. 黑盒证据表(2026-11-25,rc.4 二进制)
| # | 命令(临时目录内) | 观察 |
|---|---|---|
| 1 | `marqdo --version` | `marqdo 3.0.0-rc.4`;SHA 见头部 |
| 2 | `marqdo check --help` / `run --help` / `call --help` | `--emit/--refs/--json`;`--output text|json|jsonl`、`--observation-file`、`--observe-*`、strict 支持范围 |
| 3 | `check control-flow/index.mq.md --emit cf.json --json` | exit 0;schema `marqdo.analysis` revision 3;模块含 source/document/units/anchors/functions/calls/resources/diagnostics |
| 4 | `call function-params.mq.md double --arg n=5 --mode pure --output jsonl --observation-file obs.json` | exit 0;7 个事件;JSONL 与快照 events 完全一致;value Int 10 |
| 5 | `run branch-loop.mq.md --mode pure --output jsonl --observation-file runobs.json` | exit 0;事件含 variable.assigned/loop.iteration/return;14 条;快照一致;value Int 0 |
| 6 | `run branch-loop.mq.md --observe-max-events 2 ...` | exit 0;`capture.truncated={event_budget,2,2}`;`observation.truncated` 后仍有终态 |
| 7 | 引用 fixture(resolved/not_loaded/missing/external/outside_scope/invalid) | 六态逐一复现,见 §4 |
| 8 | 传入已退休的旧运行参数(Git 历史保留,不在当前文档重复) | exit 2,unexpected argument;无回退重试 |
| 9 | `run … --mode strict --output jsonl` | exit 2,`strict.unsupported_grant` |
| 10 | 新 `tool.json` install/list/dispatch | 安装成功;`MARQDO_API_REVISION=1`;无旧协商变量 |
| 11 | 带 `compatibility` 的旧 `tool.json` install | exit 1,unknown field + 重写提示 |
## 9. 未复现项(UNVERIFIED)
- `ambiguous` 与 `resolved(target_kind:file)` 的稳定黑盒样本(见 §4)。
- 插件/Provider/Foreign/Kernel 的完整运行时行为(View 首版不暴露;不属 MVP)。
- `--max-output`/`--fuel`/`--stack` 触顶时的精确错误码与包络(由 View 外部的
Core 负责;View 只显示真实错误)。
- 多模块/依赖包事件在入口正文的跨模块绘制(必须按 module_id 拒绝;无有效样本)。
- `--fuel`/`--max-output`/`--max-memory`/`--stack` 触顶时的精确错误码与包络
(由 CLI 负责;View 只显示真实错误)。
- 多模块事件的跨模块归属、`run.rejected` 全错误码矩阵、`effect.operation` 完整集合。
- Windows/macOS 行为(发行范围仅 Linux x86_64)。
- 远端 CI 实际执行(本环境未运行;对应门禁保持 `UNVERIFIED`)。