feat: migrate View 0.3.0 to marqdo 3.0.0-rc.4 contracts
ci/woodpecker/push/woodpecker Pipeline was successful
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:
1 parent
7b34199c96
commit
340ecb035f
108 files changed
+13928
-6461
No files matched your search
@@ -5,10 +5,50 @@ on:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
RUST_MIN_STACK: "8388608"
|
||||
|
||||
jobs:
|
||||
frozen-acceptance:
|
||||
name: frozen CLI acceptance (Tool install / SSE / export / browser)
|
||||
no-legacy:
|
||||
name: no retired contracts (G01/G12)
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Fail on retired Analysis/Trace/flags/Tool negotiation
|
||||
shell: bash
|
||||
run: scripts/check-no-legacy.sh
|
||||
- name: Current docs describe the rc.4 baseline
|
||||
shell: bash
|
||||
run: scripts/check-docs.sh
|
||||
|
||||
quality:
|
||||
name: fmt / clippy / tests
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
CARGO_HOME: ${{ github.workspace }}/.cargo-home
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
toolchain: "1.89.0"
|
||||
components: rustfmt, clippy
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Format
|
||||
run: cargo fmt --all -- --check
|
||||
- name: Clippy
|
||||
run: cargo clippy --locked --all-targets -- -D warnings
|
||||
- name: Tests
|
||||
run: cargo test --locked
|
||||
|
||||
frozen-acceptance:
|
||||
name: frozen rc.4 acceptance (install / Observation / SSE / export / browser)
|
||||
runs-on: ubuntu-24.04
|
||||
needs: [no-legacy, quality]
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
RUST_MIN_STACK: "8388608"
|
||||
@@ -25,23 +65,26 @@ jobs:
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
- name: Fetch the official frozen core and verify its identity
|
||||
- name: Fetch the official frozen rc.4 CLI and verify its identity
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
frozen="$(scripts/frozen-beta.sh fetch "$RUNNER_TEMP/marqdo-frozen")"
|
||||
echo "MARQDO_BIN=$frozen" >> "$GITHUB_ENV"
|
||||
- name: Install Chromium and run the full acceptance gate
|
||||
- name: Install Chromium
|
||||
run: |
|
||||
(cd tests/browser && npm ci --no-audit --no-fund)
|
||||
(cd tests/browser && npx playwright install --with-deps chromium)
|
||||
scripts/acceptance.sh
|
||||
- name: Run one-command acceptance (G01-G12)
|
||||
run: scripts/acceptance.sh
|
||||
- name: Upload acceptance evidence
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: view-evidence-${{ github.sha }}
|
||||
path: |
|
||||
docs/evidence/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json
|
||||
dist/acceptance/manifest.json
|
||||
dist/acceptance/logs/
|
||||
dist/marqdo-view-*.tar.gz
|
||||
dist/marqdo-view-*.tar.gz.sha256
|
||||
if-no-files-found: error
|
||||
+12
-2
@@ -1,4 +1,4 @@
|
||||
# The published beta needs glibc 2.39. Use the matching Playwright image
|
||||
# The published rc.4 CLI needs glibc 2.39. Use the matching Playwright image
|
||||
# so the installed-tool tests get both Ubuntu Noble and Chromium.
|
||||
when:
|
||||
- event: [pull_request, manual]
|
||||
@@ -6,11 +6,21 @@ when:
|
||||
branch: master
|
||||
|
||||
steps:
|
||||
no-legacy:
|
||||
image: mcr.microsoft.com/playwright:v1.49.0-noble
|
||||
commands:
|
||||
- apt-get update
|
||||
- apt-get install -y --no-install-recommends ca-certificates curl git
|
||||
- scripts/check-no-legacy.sh
|
||||
- scripts/check-docs.sh
|
||||
|
||||
frozen-acceptance:
|
||||
image: mcr.microsoft.com/playwright:v1.49.0-noble
|
||||
environment:
|
||||
PLAYWRIGHT_BROWSERS_PATH: /ms-playwright
|
||||
RUST_MIN_STACK: "8388608"
|
||||
CI: "true"
|
||||
CI_SYSTEM: woodpecker
|
||||
commands:
|
||||
- apt-get update
|
||||
- apt-get install -y --no-install-recommends build-essential ca-certificates curl git python3
|
||||
@@ -23,4 +33,4 @@ steps:
|
||||
MARQDO_BIN="$(scripts/frozen-beta.sh fetch "$frozen_dir")"
|
||||
export MARQDO_BIN
|
||||
scripts/acceptance.sh
|
||||
cat dist/acceptance/manifest.json
|
||||
cat docs/evidence/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json
|
||||
+77
-5
@@ -2,12 +2,84 @@
|
||||
|
||||
All notable changes to `marqdo-view` are documented here. The format follows
|
||||
Keep a Changelog and the project uses SemVer for the View product version.
|
||||
Protocol axes (Tool v1, Analysis v2, Trace v2) are versioned separately.
|
||||
The current public protocol axes are versioned separately by the CLI: CLI Tool
|
||||
revision 1 (`api_revision` 1), Analysis revision 3 and Observation revision 1.
|
||||
|
||||
`0.2.0` is the first release implementing RFC-VIEW-0002 end to end (SSE execution
|
||||
loop, 7-route Live API, controlled project grants and Trace-bound annotations).
|
||||
The earlier `0.1.0` development line was never published; its verified reader /
|
||||
Analysis / export work is folded into this entry.
|
||||
`0.3.0` is the one-step migration to the current pre-release contracts of
|
||||
`marqdo 3.0.0-rc.4`. There is no compatibility layer for the retired formats:
|
||||
old code paths, fixtures and documents were replaced, not branched.
|
||||
|
||||
## [0.3.0] - 2026-11-25
|
||||
|
||||
### Added
|
||||
|
||||
- CLI Tool revision 1 manifest: `tool.json` now declares exact
|
||||
`requires {api_revision: 1, analysis: 3, observation: 1}` with no
|
||||
`compatibility` field; the bundle release info records the same `requires`
|
||||
plus product range `>=3.0.0-rc.3,<4.0.0`.
|
||||
- Observation v1 consumption: `run`/`call --output jsonl` is the live source and
|
||||
`--observation-file` publishes the equivalent atomic snapshot. One decoder
|
||||
validates schema/revision, `run_id`, contiguous `seq`, unique terminal event,
|
||||
`observation.truncated`, source binding, module identity and UTF-8 half-open
|
||||
spans. View SSE forwards/summarises the protocol sequence; it never
|
||||
renumbers, reorders or synthesises events.
|
||||
- Analysis v3 consumption through the ADR-0069 public boundary: one
|
||||
`check --emit` artifact carries exact `source`, Markdown `document`, heading
|
||||
scopes (`heading_span` + complete section `span`), `anchors`, functions,
|
||||
imports, calls, resources, diagnostics and state-bearing references.
|
||||
`inspect --ast` is no longer a machine source for rendering.
|
||||
- Reference states `resolved`, `not_loaded`, `missing`, `ambiguous`, `external`,
|
||||
`outside_scope` and `invalid`; `not_loaded` is rendered as "未核验", never as a
|
||||
broken link, and `ambiguous` lists candidates instead of silently choosing one.
|
||||
- `scripts/check-no-legacy.sh` (G01): fails on any retired protocol name,
|
||||
retired run/call argv, Tool negotiation/migration, dual-state/fallback branch
|
||||
or `schema_version` use in the reader across `src/`, `tool.json` and current
|
||||
docs. Historical evidence and ADRs are exempt.
|
||||
- `scripts/check-docs.sh` (G12): README/COMPATIBILITY/CHANGELOG/STATUS/ACCEPTANCE
|
||||
must describe the rc.4 baseline; old CHANGELOG entries are allowed only under
|
||||
the explicit `## History` heading.
|
||||
- `scripts/check-observation.py`: machine probes for stream/snapshot
|
||||
equivalence, truncation, exact Analysis binding and fail-closed retired input.
|
||||
- `docs/architecture/observation-v1-and-analysis-v3.md`: final layering
|
||||
(CLI adapter → decode/validate → domain projection → reader/execution/SSE/
|
||||
export) with no version branch outside protocol modules.
|
||||
- ADR-0012 records the rc.3 → rc.4 supersession: issue #5's rc.3 baseline is
|
||||
superseded by issue #6's rc.4 public Analysis boundary; evidence pins the
|
||||
rc.4 source/archive/binary SHAs.
|
||||
|
||||
### Changed
|
||||
|
||||
- Frozen CLI pin moved to `marqdo 3.0.0-rc.4`: source
|
||||
`452e9a32bd9e40dba427d4180691c58bab74449e`, archive
|
||||
`9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8`, binary
|
||||
`a7306962689c635445a59043971ea2eb09298e01feeee81f0ba07b1f3e10306e`.
|
||||
- Acceptance manifest replaced by the issue #5 §0 schema
|
||||
`marqdo.view.acceptance` revision 1: SHA-256-prefixed identities, frozen CLI
|
||||
product/source/archive/binary, gates G01–G12 with
|
||||
`state/command/exit_code/log`, and an explicit `unverified` list. A gate that
|
||||
has not run is never recorded as PASS.
|
||||
- Scripts (`frozen-beta`, `package`, `install-smoke`, `check-examples`,
|
||||
`gen-golden`, `acceptance`, `test-*`, `acceptance-run.py`,
|
||||
`test-complete-reader.py`) use the current flags and report the current
|
||||
contracts; golden data moved to Analysis revision 3 and Observation revision 1
|
||||
stream/snapshot fixtures.
|
||||
- CI (`.github/workflows/ci.yml`, `.woodpecker.yml`) pins rc.4 through
|
||||
`scripts/frozen-beta.sh` and adds a distinct blocking no-legacy job that runs
|
||||
G01 and G12 before quality and acceptance.
|
||||
- README, COMPATIBILITY, STATUS, ACCEPTANCE, CONFORMANCE and the frozen-CLI
|
||||
contract audit now describe the current behavior; 0.2.0 material is marked
|
||||
historical.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Values are never fabricated: the protocol supports explicit
|
||||
`--observe-variable`/`--observe-parameter` (Text needs `--observe-text-values`),
|
||||
but View 0.3.0 requests none by default and never displays memory or handles.
|
||||
- Truncated or incomplete observation transport is displayed as
|
||||
`TRUNCATED`/`未完成`, never as success. `UNSUPPORTED`, `PARTIAL` and `WARN`
|
||||
are never written as `PASS`.
|
||||
|
||||
## History
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
|
||||
+52
-33
@@ -4,56 +4,75 @@
|
||||
|
||||
| 轴 | 本 View 值 | 说明 |
|
||||
|---|---|---|
|
||||
| View 产品版本 | `0.2.0` | 独立 SemVer,与 CLI 不共用 |
|
||||
| `marqdo` 产品范围 | `>=3.0.0-beta.1,<4.0.0` | 安装与分发时由 CLI 强制校验 |
|
||||
| CLI Tool Protocol | `1` | `tool.json` 清单/整包摘要/分发 |
|
||||
| Analysis | `2`、`3` | 按实际信封版本验证,未知 major 拒绝 |
|
||||
| Execution Events | `1` | RC.2 起提供实时输出与可验证的导出终态 |
|
||||
| Trace | `2` | 与 Analysis 精确字节摘要绑定 |
|
||||
| View 产品版本 | `0.3.0` | 独立 SemVer,与 CLI 不共用 |
|
||||
| `marqdo` 产品范围 | `>=3.0.0-rc.3,<4.0.0` | 预发布契约只在 rc.3 起有意义;验收固定 `3.0.0-rc.4` |
|
||||
| CLI Tool revision | `1` | `tool.json`:`requires.api_revision = 1`,无 `compatibility` 字段 |
|
||||
| Analysis revision | `3` | `marqdo.analysis`,ADR-0069 公共边界(含 source/document/anchors/references/heading_span) |
|
||||
| Observation revision | `1` | `marqdo.observation`,单一事件序列(JSONL 流 / 原子快照) |
|
||||
| Markdown profile | `marqdo.md.v1` | 与冻结 CLI 相同选项集 |
|
||||
| 平台 | `linux-x86_64-glibc2.39` | 唯一正式验证平台 |
|
||||
|
||||
Beta 版 CLI 必须使用 prerelease 范围(`>=3.0.0-beta.1,<4.0.0`);`>=3.0.0,<4.0.0` **不匹配** `3.0.0-beta.1`。
|
||||
当前契约:**Analysis 3**、**Observation 1**、CLI Tool **api_revision 1**。
|
||||
|
||||
`3.0.0-rc.3,<4.0.0` 是当前预发布范围;`>=3.0.0,<4.0.0` 不匹配任何 rc 预发布版。
|
||||
验收与证据只认绑定 CLI 源码 SHA / 归档 SHA / 二进制 SHA 的结果:
|
||||
`marqdo 3.0.0-rc.4`,源码 `452e9a32bd9e40dba427d4180691c58bab74449e`,
|
||||
归档 `9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8`,
|
||||
二进制 `a7306962689c635445a59043971ea2eb09298e01feeee81f0ba07b1f3e10306e`。
|
||||
|
||||
## 契约替换(0.3.0 一次性完成)
|
||||
|
||||
| 边界 | 当前契约 | 消费方式 | 不符时行为 |
|
||||
|---|---|---|---|
|
||||
| 静态语义 | `check --emit` → Analysis revision 3 | 精确 UTF-8 字节 + `sha256:` 摘要;一次入口一次 emit | `view.protocol_incompatible`,显式提示重新生成/升级核心 |
|
||||
| 运行事实 | Observation revision 1 | `run`/`call --output jsonl` 流;`--observation-file` 原子快照 | 拒绝;不重排、不重编号、不合成 |
|
||||
| 源绑定 | `run.started.payload.source.{analysis_digest,root_id}` | 与同一次普通 `check --emit` 的精确字节摘要 + module/source_digest/UTF-8 半开 span 校验 | `view.observation_stale`;不显示成功、不做错误高亮 |
|
||||
| Tool 清单 | `marqdo.cli-tool` / revision 1 | 精确 `requires {api_revision:1, analysis:3, observation:1}` | 安装失败;提示移除旧注册后重装 |
|
||||
| 分发环境 | 只注入 `MARQDO_BIN` 与 `MARQDO_API_REVISION=1` | 仅静态期望校验,不据此协商 | 不读取、不阻塞;旧变量不存在 |
|
||||
|
||||
删除而非分支:树内没有第二解码器、双态类型、运行时版本探测、迁移器或“先兼容再清理”。
|
||||
旧格式(含同 revision 的旧字段集合)只在 Git 历史与 CHANGELOG 的 History 段中保留。
|
||||
|
||||
## 平台
|
||||
|
||||
| 平台 | 状态 | 说明 |
|
||||
|---|---|---|
|
||||
| Linux x86_64 (glibc 2.39+) | **Supported** | 完整阅读和结果 ZIP 使用官方 RC.2 验收;媒体需要 Linux 5.6+ |
|
||||
| Linux x86_64 (glibc 2.39+) | **Supported** | 完整阅读、显式运行与导出使用官方 rc.4 验收;媒体需要 Linux 5.6+ |
|
||||
| Linux aarch64 | 未构建 | 未验证 |
|
||||
| macOS / Windows | 未验证 | 不声明支持;路径/进程组逻辑留有平台分支,但未做实测 |
|
||||
| macOS / Windows | 未验证 | 不声明支持 |
|
||||
|
||||
## 能力边界(诚实状态)
|
||||
|
||||
| 能力 | 状态 |
|
||||
|---|---|
|
||||
| 原始 Markdown 只读浏览(GFM 表/列表/引用/代码围栏/MathML/本地图片) | **已实现**(PR-02) |
|
||||
| Analysis v2/v3 静态语义(函数/Unit/诊断/引用/资源) | **已实现**(PR-02) |
|
||||
| 文档态 / 源码态切换 | **已实现**(PR-02) |
|
||||
| 暖纸 Reader 视觉(单一 CSS/JS) | 已实现并经 Chromium 验收 |
|
||||
| 用户显式触发运行 + SSE + Trace v2 事件可视化 | **已实现**(0002 PR-04;`pure`/受控 `project`,显式确认 + 会话 CSRF) |
|
||||
| Live 本机安全 API(含媒体和 ZIP) | **已实现**(0002 PR-04;Cookie/CSRF/Origin/CSP/单任务/SSE) |
|
||||
| 原始 Markdown 只读浏览(GFM 表/列表/引用/代码围栏/MathML/本地图片) | 已实现 |
|
||||
| Analysis revision 3 严格校验 + 函数/Unit/签名/诊断/引用/资源投影 | 已实现(拒绝旧同 revision 制品,无降级解码) |
|
||||
| heading_span 用于标题 UI;完整 span 用于 section 高亮/切片/归属 | 已实现 |
|
||||
| 引用状态 resolved/not_loaded/missing/ambiguous/external/outside_scope/invalid | 已实现;`not_loaded` 显示“未核验”,不误报断链 |
|
||||
| 文档态 / 源码态切换 | 已实现 |
|
||||
| 用户显式触发运行 + Observation v1 事件可视化 + SSE + 取消 + 断线重放 | 已实现(`pure`/受控 `project`,显式确认 + 会话 CSRF) |
|
||||
| Live 本机安全 API(含媒体和 ZIP) | 已实现(Cookie/CSRF/Origin/CSP/单任务/SSE) |
|
||||
| 静态离线导出 | 普通导出与显式单次结果 ZIP 共用渲染器 |
|
||||
| 逐语句变量值 / 参数实际值 / 内存快照 | **UNSUPPORTED**(Trace v2 不提供,绝不伪造) |
|
||||
| 变量/参数值观测 | 协议支持;**View 默认不请求、不展示**(Text 需二次同意);内存/句柄永不发布 |
|
||||
| 知识“已证明”状态 | **UNSUPPORTED**(需要独立 Prove 协议与证书) |
|
||||
| `project` 运行与 fs grants | **已实现(受控)**:仅相对项目根 read/write glob,显式二次确认;其它权限拒绝 |
|
||||
| SSE 状态推送 / 取消运行 / 事件重放 | **已实现**(逐帧 flush、心跳、Last-Event-ID、2 连接上限、无轮询) |
|
||||
| SVG 曲线侧注 | **未实现**(运行事件用内联 keyed chip,U-04 PARTIAL) |
|
||||
| 调试器/断点/单步 | **不实现**(首版非目标) |
|
||||
| Knowledge/Prove/Lint 引擎 | **不实现**(独立仓库/未来可选信息层) |
|
||||
| `strict` 运行 | 仅终端 text/JSON 快照;SSE 场景明确拒绝(`strict.unsupported_grant`),不回退 |
|
||||
| SVG 曲线侧注 | **未实现**(事件使用内联 keyed chip) |
|
||||
| 调试器/断点/单步、Knowledge/Prove/Lint 引擎 | **不实现**(非目标) |
|
||||
|
||||
实际完成状态以 [`docs/STATUS.md`](docs/STATUS.md) 与 [`docs/ACCEPTANCE.md`](docs/ACCEPTANCE.md) 为准,本文不代替现状。RFC-VIEW-0002 §10 门禁已按真实冻结 CLI + Chromium 验收 PASS;本地证据见 `docs/evidence/`。
|
||||
实际完成状态与机器证据以 [`docs/STATUS.md`](docs/STATUS.md) 与
|
||||
[`docs/ACCEPTANCE.md`](docs/ACCEPTANCE.md) 为准。发布门禁 G01–G12 的
|
||||
`PASS/FAIL/UNVERIFIED` 只来自 `docs/evidence/<CLI-SOURCE-SHA>/manifest.json`;
|
||||
当前 0.3.0 证据生成前不得写成 PASS。
|
||||
|
||||
## 消费者契约
|
||||
|
||||
- 新 Core 使用 `--event-stream jsonl` 与 Trace v2。兼容的旧 Core 继续使用 `--json` 与 Trace v2。
|
||||
- 未知 `schema_version` → `view.protocol_incompatible`,不回退猜测。
|
||||
- `sha256(exact analysis.json bytes) == trace.source.analysis_digest`;不匹配 → `view.trace_stale`。
|
||||
- `trace.source.root_id == analysis.project.root_id`;事件 `module_id` 必须存在于 Analysis。
|
||||
- `trace.truncated != null` → `TRUNCATED`,不声明全部分支/循环已遍历。
|
||||
- 运行只使用 `MARQDO_BIN` 子进程与公开 JSON;不链接 Core crate、不读 Core 源码、不依赖私有 IR。
|
||||
|
||||
## 官方 Beta 归档的标准库
|
||||
|
||||
`v3.0.0-beta.1` 的 Linux 归档未携带 `stdlib/`。View 的冻结验收示例使用
|
||||
该二进制公开的 Memory、stdout 和文件资源原语。含 `std:` 导入的项目由
|
||||
所选 Core 校验,缺少标准库时由 View 展示 Core 的诊断。
|
||||
- 静态语义只来自一次 `check --emit`;`inspect --ast`/`inspect --ir` 仅人工调试,不是机器来源。
|
||||
- `sha256(exact analysis.json bytes)` 必须等于 Observation `run.started.payload.source.analysis_digest`;
|
||||
`--refs` 检查改变字节,不能替代运行绑定。
|
||||
- 事件 `module_id` 必须属于 Analysis `modules[]`;span 必须是该模块 source 的 UTF-8 半开字节区间。
|
||||
- `capture.truncated`/`observation.truncated` 表示观测预算耗尽,不代表程序失败,也不得声明完整覆盖;
|
||||
EOF 无终态 = 未完成/无结论,不得当成功。
|
||||
- 运行只使用 `MARQDO_BIN` 子进程与公开契约;不链接 Core crate、不读 Core 源码、不依赖私有 IR
|
||||
或包缓存物理路径。
|
||||
- 未知 `schema`/revision/kind → 显式拒绝;不猜测、不回退、不在失败后换旧参数重试。
|
||||
Generated
+1
-1
@@ -420,7 +420,7 @@ checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-view"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"clap",
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
[package]
|
||||
name = "marqdo-view"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.89"
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "Marqdo View: read .mq.md documents as documents, with optional verified Analysis v2 and Trace v2"
|
||||
description = "Marqdo View: read .mq.md documents as documents, with optional verified Analysis v3 and Observation v1"
|
||||
repository = "https://github.com/cflmy/marqdo-view"
|
||||
readme = "README.md"
|
||||
keywords = ["marqdo", "markdown", "reader", "executable-document"]
|
||||
|
||||
@@ -1,52 +1,71 @@
|
||||
# marqdo-view
|
||||
|
||||
Marqdo View(`0.2.0`)是一个独立的可执行文档阅读器:以**原始 Markdown 为阅读主体**,把冻结
|
||||
`marqdo` CLI 的静态语义(Analysis v2/v3)与用户显式触发的真实运行事件(Execution Events v1、Trace v2)
|
||||
附着回原文,而不是把文档翻译成另一套语言。
|
||||
Marqdo View(`0.3.0`)是一个独立的可执行文档阅读器:以**原始 Markdown 为阅读主体**,
|
||||
把冻结 `marqdo` CLI 的当前公开契约——Analysis revision 3(ADR-0069 公共边界)与
|
||||
Observation revision 1——附着回原文,而不是把文档翻译成另一套语言。
|
||||
|
||||
- 状态(唯一现状来源):[`docs/STATUS.md`](docs/STATUS.md)
|
||||
- **完整阅读与结果导出**:[实施 RFC](docs/architecture/RFC-VIEW-0001-complete-reader.md) · [设计图](docs/design/complete-reader.png) · [验收](docs/evidence/issue-3/README.md)
|
||||
- **执行基础规范**:[`docs/architecture/RFC-VIEW-0002.md`](docs/architecture/RFC-VIEW-0002.md)
|
||||
- 0002 合规矩阵:[`docs/CONFORMANCE.md`](docs/CONFORMANCE.md)
|
||||
- 历史基础设计:[`docs/architecture/RFC-VIEW-0001.md`](docs/architecture/RFC-VIEW-0001.md)
|
||||
- 旧 View 静态审计:[`docs/audits/legacy-view.md`](docs/audits/legacy-view.md)
|
||||
- **当前分层与契约**:[`docs/architecture/observation-v1-and-analysis-v3.md`](docs/architecture/observation-v1-and-analysis-v3.md)
|
||||
- 当前契约决策:[ADR-0012](docs/decisions/0012-rc4-current-contracts.md)
|
||||
- 完整阅读与结果导出:[实施 RFC](docs/architecture/RFC-VIEW-0001-complete-reader.md) · [设计图](docs/design/complete-reader.png)
|
||||
- 验收标准与证据:[`docs/ACCEPTANCE.md`](docs/ACCEPTANCE.md) · [`docs/evidence/`](docs/evidence/README.md)
|
||||
- 旧 0.2.0 基线(历史):[`docs/architecture/RFC-VIEW-0002.md`](docs/architecture/RFC-VIEW-0002.md)
|
||||
- 冻结 CLI 合同审计:[`docs/audits/protocol-contract-0002.md`](docs/audits/protocol-contract-0002.md)
|
||||
- 兼容性:[`COMPATIBILITY.md`](COMPATIBILITY.md) / 变更:[`CHANGELOG.md`](CHANGELOG.md)
|
||||
- 决策记录:[`docs/decisions/`](docs/decisions/)
|
||||
|
||||
> 阅读、函数调用和单次结果 ZIP 可用。实时执行事件和结果 ZIP 需要官方
|
||||
> `marqdo 3.0.0-rc.2` 或更新的兼容版本。Beta 仍可使用旧版运行与 Trace 流程。
|
||||
> 0.3.0 只支持当前预发布契约:`marqdo 3.0.0-rc.4`(产品范围
|
||||
> `>=3.0.0-rc.3,<4.0.0`;验收固定 rc.4)。静态语义只有一个来源
|
||||
> `check --emit`(Analysis revision 3,含精确 source、Markdown AST、heading 作用域、
|
||||
> anchors 与状态化 references);运行事实只有一条 Observation revision 1 事件序列
|
||||
> (`run`/`call --output jsonl`,原子快照 `--observation-file`)。旧格式显式拒绝,
|
||||
> 没有兼容分支、迁移器或运行时探测。
|
||||
|
||||
## 能力
|
||||
## 能力(0.3.0 实现范围)
|
||||
|
||||
> 下表的“实现”表示当前代码路径按 rc.4 契约实现;`PASS/FAIL/UNVERIFIED` 的机器
|
||||
> 验收结论只以 [`docs/evidence/`](docs/evidence/README.md) 中绑定 CLI 源码 SHA 的
|
||||
> manifest 为准。new manifest 生成前,全部发布门禁在 STATUS 中保持 `UNVERIFIED`。
|
||||
|
||||
| 能力 | 状态 |
|
||||
|---|---|
|
||||
| Markdown + GFM、源码态、项目图片、跨页锚点、离线数学 | ✅ |
|
||||
| Analysis v2/v3 静态语义(函数/Unit/签名/诊断/导入/引用/资源) | ✅ 严格校验,span 无效则降级 |
|
||||
| 本机 Live 阅读(默认 `127.0.0.1`,只读 API + 显式执行端点) | ✅ |
|
||||
| 显式确认后运行、SSE 实时输出与取消、真实 Trace v2 | ✅ RC.2;单任务、断线重放 |
|
||||
| 只读静态导出(离线 `file://`、媒体/字体/哈希) | ✅ 普通站点与显式结果 ZIP |
|
||||
| 单函数参数表单 + 受控 `project` fs grants | ✅ 参数来自 Analysis 签名;project 需显式 glob 二次确认 |
|
||||
| SSE 状态推送 / 取消 / 断线重放(禁止轮询) | ✅ `POST /api/runs` + `GET …/events` + `POST …/cancel` |
|
||||
| 逐语句变量值 / 参数值 / 内存快照 | ❌ UNSUPPORTED(协议不提供,绝不伪造) |
|
||||
| 知识“已证明” / Prove / Lint / 调试器 | ❌ 非目标/等待独立协议 |
|
||||
| Markdown + GFM、源码态、项目图片、跨页锚点、离线数学 | 实现 |
|
||||
| 单一静态源:`check --emit` Analysis revision 3(source/document/units/anchors/functions/calls/resources/diagnostics) | 实现;不读取 `inspect --ast` 作为机器来源 |
|
||||
| heading_span(标题 UI/目录/锚点)与完整 span(section 高亮/切片/归属) | 实现 |
|
||||
| 引用状态 resolved / not_loaded / missing / ambiguous / external / outside_scope / invalid | 实现;`not_loaded` 显示“未核验”,不是断链 |
|
||||
| 本机 Live 阅读(默认 `127.0.0.1`,只读 API + 显式执行端点) | 实现 |
|
||||
| 显式确认后单次运行/调用;Observation v1 事件经 View SSE 转发/摘要 | 实现(单任务、取消、断线重放) |
|
||||
| 只读静态导出(离线 `file://`、媒体/字体/哈希);普通导出与单次结果 ZIP | 实现 |
|
||||
| 单函数参数表单 + 受控 `project` fs grants | 参数来自 Analysis 签名;project 需显式 glob 二次确认 |
|
||||
| 变量/参数值观测 | 协议支持 `--observe-variable`/`--observe-parameter`(Text 需 `--observe-text-values`);**View 默认不请求任何值**,绝不伪造变量值/内存状态 |
|
||||
| 知识“已证明” / Prove / Lint / 调试器 | 非目标/等待独立协议 |
|
||||
|
||||
不变量:
|
||||
|
||||
- `TRUNCATED`、传输未完成(EOF 无终态)、`UNSUPPORTED`、`PARTIAL`、`WARN`
|
||||
绝不写成成功/PASS;没有终态的流显示“未完成/无结论”。
|
||||
- 每一条运行结论都绑定**同一次普通 `check --emit`** 的精确字节摘要;
|
||||
带 `--refs` 的检查会改变字节,不能作为运行绑定。
|
||||
- 协议事件只转发/摘要,View 自有 SSE 信封不重编号、不重排、不合成协议事件。
|
||||
|
||||
## 安装
|
||||
|
||||
```bash
|
||||
# 1) 取得官方冻结 CLI 发布包(示例:本地已解包的 3.0.0-beta.1)
|
||||
MARQDO_BIN=/absolute/path/to/marqdo
|
||||
"$MARQDO_BIN" --version
|
||||
# 1) 取得官方冻结 CLI 发布包(验收固定 3.0.0-rc.4)
|
||||
MARQDO_BIN=/absolute/path/to/marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu/marqdo
|
||||
"$MARQDO_BIN" --version # marqdo 3.0.0-rc.4
|
||||
|
||||
# 2) 构建并制作 Tool v1 bundle
|
||||
# 2) 构建并制作 CLI Tool revision 1 bundle
|
||||
./scripts/package.sh
|
||||
# → dist/marqdo-view/tool.json + dist/marqdo-view/bin/marqdo-view
|
||||
|
||||
# 3) 安装为 `marqdo view`
|
||||
# 3) 安装为 `marqdo view`(旧安装请先 tool remove 后重装)
|
||||
"$MARQDO_BIN" tool install "$(pwd)/dist/marqdo-view/tool.json"
|
||||
"$MARQDO_BIN" view --help
|
||||
```
|
||||
|
||||
`tool.json` 只声明精确要求:`requires {api_revision: 1, analysis: 3, observation: 1}`,
|
||||
没有 `compatibility` 字段,也没有版本协商或迁移。
|
||||
|
||||
## 使用
|
||||
|
||||
```bash
|
||||
@@ -58,7 +77,7 @@ marqdo view examples/control-flow --port 0 --no-open
|
||||
marqdo view verify examples/mixed-modes/index.mq.md
|
||||
marqdo view verify examples/mixed-modes --refs --json
|
||||
|
||||
# RFC §13.3 示例(可检查/调用/运行;无隐式执行)
|
||||
# 显式触发(只有页面确认后才 POST /api/runs)
|
||||
marqdo view examples/function-params.mq.md --no-open
|
||||
marqdo view examples/unsafe-side-effect.mq.md --no-open
|
||||
|
||||
@@ -73,13 +92,6 @@ Live 页面点击 Dock “运行”(执行 `main`)或函数标题旁的“
|
||||
CLI 子进程;状态与结果通过 SSE 推送,可取消,断线可重放。页面刷新/打开/搜索/
|
||||
切换/导出都不会运行,也没有状态轮询。
|
||||
|
||||
在函数旁的“本次执行”中选择“导出文档(含本次结果)”,检查预览和选项,
|
||||
确认后下载 ZIP。默认勾选标量返回值和可用的 Trace 摘要。stdout、stderr、
|
||||
已提交的参数和非标量返回值由用户选择。ZIP 解压后直接打开 `index.html`,
|
||||
可离线阅读、打印和通过清单校验文件。可导出结果在当前会话的任务内保留
|
||||
15 分钟。普通 `view export` 始终只导出文档。
|
||||
|
||||
|
||||
## 架构(强制约束)
|
||||
|
||||
```text
|
||||
@@ -91,7 +103,13 @@ ReaderRenderer(唯一模板,Live/Export 共用)
|
||||
│
|
||||
PresentationModel(reader::assemble / reader::model)
|
||||
│
|
||||
CoreClient ─ MARQDO_BIN 公开协议(check --emit / Events v1 / Trace v2)
|
||||
CLI 适配层(唯一知道 argv / 环境变量 / 退出码语义)
|
||||
├─ check --emit → Analysis revision 3 精确字节
|
||||
└─ run|call --output jsonl [--observation-file] → Observation revision 1 流/快照
|
||||
│
|
||||
解码 + 结构校验(protocol 模块:schema/revision/必需字段/seq/终态/预算)
|
||||
│
|
||||
规范化领域模型(Analysis / Observation / RunBinding;无 CLI 细节、无版本分支)
|
||||
│
|
||||
ExecutionController ─ 单任务、取消、SSE 事件(仅 POST /api/runs 可达)
|
||||
│
|
||||
@@ -99,11 +117,8 @@ ExecutionController ─ 单任务、取消、SSE 事件(仅 POST /api/runs 可
|
||||
```
|
||||
|
||||
- 单一 Rust package、单一渲染入口、单一主题文件;没有第二个 Markdown→语义管线。
|
||||
- View SSE 推送任务状态与已校验的实时输出。受保护的 `POST /api/exports` 从当前会话的终态生成只读 ZIP。
|
||||
- Analysis v2/v3 是唯一语义权威:函数/语句/分支/循环/诊断均来自 `check --emit`,
|
||||
源码字节 span 用于绑定视觉位置。文档跳转采用确定性的标题锚点。
|
||||
- Trace v2 与 Analysis 字节摘要严格绑定;`STALE/TRUNCATED/FAILED/UNSUPPORTED`
|
||||
状态显式呈现,不猜测未公开值。
|
||||
- 协议模块之外没有 `schema_version` 判断;协议模块内只有当前 revision 一个分支。
|
||||
- JSONL 流与原子快照共用同一解码器与领域类型;生产不“双读合并”,一致性只在测试中断言。
|
||||
- Live/Export 内容同源;导出绝不执行、绝不覆盖项目源文件或无关目录。
|
||||
- 门禁:`tests/contract/no_coupling.rs` 拒绝旧 crate/源码依赖、第二套渲染器/主题、shell 执行;
|
||||
`tests/contract/asset_integrity.rs` 锁定内嵌资产与唯一主题层;
|
||||
@@ -111,53 +126,55 @@ ExecutionController ─ 单任务、取消、SSE 事件(仅 POST /api/runs 可
|
||||
|
||||
## 开发与验收
|
||||
|
||||
完整阅读和结果导出的复验命令见 [工单 #3 验收](docs/evidence/issue-3/README.md)。
|
||||
|
||||
```bash
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
cargo fmt --all -- --check
|
||||
cargo clippy --all-targets -- -D warnings
|
||||
cargo clippy --locked --all-targets -- -D warnings
|
||||
cargo test --locked
|
||||
cargo build --release --locked
|
||||
scripts/check-no-legacy.sh # G01:当前树 0 条旧契约残留(cmd 可单独跑)
|
||||
scripts/check-docs.sh # G12:当前文档不把旧格式写成当前能力
|
||||
```
|
||||
|
||||
全链路验收使用 Rust 1.89 或更新版本,以及能运行官方 Beta 的 Linux x86_64
|
||||
全链路验收使用 Rust 1.89 或更新版本,以及能运行官方 rc.4 的 Linux x86_64
|
||||
环境(glibc 2.39 起)。浏览器、显式运行和离线导出通过已安装的 Tool 执行。
|
||||
|
||||
```bash
|
||||
(cd tests/browser && npm ci && PLAYWRIGHT_BROWSERS_PATH="$PWD/../.cache/pw-browsers" npx playwright install chromium)
|
||||
MARQDO_BIN="$(./scripts/frozen-beta.sh fetch "$(mktemp -d)")"
|
||||
export MARQDO_BIN
|
||||
./scripts/acceptance.sh
|
||||
cat dist/acceptance/manifest.json
|
||||
./scripts/acceptance.sh # G01–G12,写 docs/evidence/452e9a32…/manifest.json
|
||||
cat docs/evidence/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json
|
||||
```
|
||||
|
||||
也可将 `MARQDO_BIN` 指向已解包的官方 Beta。验收核对源码 SHA 和二进制
|
||||
SHA-256。
|
||||
验收会核对 CLI 源码 SHA、归档 SHA-256 与二进制 SHA-256,并在前后两次记录 CLI 摘要。
|
||||
未实际运行、无法在本环境判定的门禁记为 `UNVERIFIED`,不会写成 `PASS`。
|
||||
|
||||
单独套件:
|
||||
|
||||
```bash
|
||||
MARQDO_BIN=... ./scripts/check-examples.sh # RFC §13.3 示例真实 check/call/run
|
||||
MARQDO_BIN=... ./scripts/test-no-exec.sh # 打开/导出零副作用哨兵
|
||||
MARQDO_BIN=... ./scripts/test-contract.sh # code + Tool v1 + verify + export
|
||||
MARQDO_BIN=... ./scripts/test-export.sh # 纯只读导出 + file:// Chromium
|
||||
./scripts/test-security.sh # HTTP/路径/XSS/导出对抗
|
||||
(cd tests/browser && npm install && PLAYWRIGHT_BROWSERS_PATH="$PWD/../.cache/pw-browsers" npx playwright install chromium)
|
||||
MARQDO_BIN=... ./scripts/test-browser.sh # 真实 Chromium 视觉/交互/响应式/运行
|
||||
MARQDO_BIN=... ./scripts/check-examples.sh # 示例的真实 check/call/run(Observation v1)
|
||||
MARQDO_BIN=... ./scripts/test-no-exec.sh # 打开/导出零副作用哨兵
|
||||
MARQDO_BIN=... ./scripts/test-contract.sh # code + Tool revision 1 + verify + export
|
||||
MARQDO_BIN=... ./scripts/test-export.sh # 纯只读导出 + file:// Chromium
|
||||
./scripts/test-security.sh # HTTP/路径/XSS/导出对抗
|
||||
MARQDO_BIN=... ./scripts/test-browser.sh # 真实 Chromium 视觉/交互/响应式/运行
|
||||
```
|
||||
|
||||
协议 golden 由冻结 CLI 生成,见 `tests/golden/README.md` 与 `scripts/gen-golden.sh`。
|
||||
协议 golden 由冻结 CLI 生成,见 `tests/golden/README.md` 与 `scripts/gen-golden.sh`
|
||||
(Analysis revision 3 + Observation revision 1 流/快照)。
|
||||
|
||||
## 已知限制(诚实状态)
|
||||
|
||||
- 运行仅 `pure`(默认)与受控 `project` fs read/write;`strict`、网络/进程/环境/
|
||||
plugin/provider/kernel 授权不在首版 UI,必须使用终端 CLI。
|
||||
- 运行仅 `pure`(默认)与受控 `project` fs read/write;`strict` 只支持 text/JSON
|
||||
快照,`--output jsonl` 与 `--observation-file` 在启动前被 CLI 拒绝(exit 2,
|
||||
`strict.unsupported_grant`),View 不伪装、不回退到 `project`。
|
||||
- `project` 不是 OS 沙箱;View 不继承 `marqdo.yaml` 的 capability 请求。
|
||||
- RC.2 之前的兼容 Core 使用终态 JSON 与 Trace v2。尚未收到真实 Core 终态的取消或超时可在 Live 阅读,结果 ZIP 只向来源匹配的成功或失败终态开放。
|
||||
- Linux 项目媒体使用 `openat2`(Linux 5.6+)。每个图片最多 4 MiB、约 1600 万像素。SVG 只接受静态图形元素。
|
||||
- 平台:仅 Linux x86_64 正式验证;Windows/macOS 不支持声明。
|
||||
- 远端 CI 配置已提供(`.github/workflows/ci.yml`),本环境未实际运行远端 CI;
|
||||
验收证据来自本地真实命令。
|
||||
- 像素级人工视觉比对与完整 screen-reader 走查为 `UNVERIFIED`(自动化几何/响应式/
|
||||
无外部资源/无 JS/打印证据见 `docs/evidence/PR-04/`)。
|
||||
- 变量/参数值:协议支持显式选择(`--observe-variable`/`--observe-parameter`,
|
||||
Text 需 `--observe-text-values`),但 0.3.0 的 View **默认不请求、不展示**;
|
||||
内存/资源/句柄永不发布。
|
||||
- `not_loaded` 引用只表示当前 catalog 未核验,不是断链;需要 `check --refs`
|
||||
才能核验普通本地链接,且 `--refs` 的字节摘要不能用于运行绑定。
|
||||
- 平台:仅 Linux x86_64 / glibc 2.39 正式验证;Windows/macOS 不支持声明。
|
||||
- 远端 CI 配置已提供(`.github/workflows/ci.yml`、`.woodpecker.yml`),本环境
|
||||
未实际运行远端 CI;未运行的门禁在 evidence 中保持 `UNVERIFIED`。
|
||||
- 像素级人工视觉比对与完整 screen-reader 走查为 `UNVERIFIED`。
|
||||
@@ -1509,3 +1509,40 @@
|
||||
@layer semantics {
|
||||
.mq-snapshot-notice a { color: var(--mq-focus); }
|
||||
}
|
||||
|
||||
@layer semantics {
|
||||
/* Reference resolution states (Analysis v3). `not_loaded` is unverified,
|
||||
never a broken link; only real errors use the error colour. */
|
||||
.mq-link-unverified {
|
||||
text-decoration: underline dotted;
|
||||
text-underline-offset: 0.18em;
|
||||
cursor: help;
|
||||
}
|
||||
.mq-link-unverified::after {
|
||||
content: "(未核验)";
|
||||
font: 10px/1 var(--mq-mono);
|
||||
color: var(--mq-warn);
|
||||
vertical-align: 0.35em;
|
||||
}
|
||||
.mq-link-error {
|
||||
color: var(--mq-error);
|
||||
text-decoration: underline wavy;
|
||||
cursor: help;
|
||||
}
|
||||
.mq-run-status[data-run-state="incomplete"] {
|
||||
color: var(--mq-warn);
|
||||
}
|
||||
.mq-run-chip[data-annotation-source="observation"] {
|
||||
border-color: color-mix(in srgb, var(--mq-focus) 40%, var(--mq-line));
|
||||
color: var(--mq-focus);
|
||||
}
|
||||
.mq-truncated-badge {
|
||||
display: inline-block;
|
||||
margin-inline-start: .4rem;
|
||||
padding: 0 .45rem;
|
||||
border-radius: 999px;
|
||||
background: color-mix(in srgb, var(--mq-warn) 18%, var(--mq-surface));
|
||||
color: var(--mq-warn);
|
||||
font: 11px/1.6 var(--mq-mono);
|
||||
}
|
||||
}
|
||||
+37
-23
@@ -291,8 +291,8 @@
|
||||
case "unsupported":
|
||||
showUnsupported(
|
||||
"变量快照 / 内存检查 / 调试器 / 证明状态",
|
||||
"Trace v2 不提供逐语句赋值后的实际值或内存快照,公开协议也没有断点/单步通道;" +
|
||||
"知识证明属于独立 Prove 工具。View 绝不猜测这些运行事实,相应能力在具备公开、受版本约束的协议前不会出现。"
|
||||
"Observation v1 支持显式请求 --observe-variable / --observe-parameter,但 View 默认不请求任何变量或参数值;" +
|
||||
"它不提供内存快照、断点或单步通道;知识证明属于独立 Prove 工具。View 绝不猜测这些运行事实。"
|
||||
);
|
||||
break;
|
||||
case "theme":
|
||||
@@ -439,9 +439,9 @@
|
||||
if (stderr) stderr.hidden = true;
|
||||
var exportButton = $("#mq-export-result");
|
||||
if (exportButton) exportButton.hidden = true;
|
||||
var traceTitle = $("#mq-run-trace-title");
|
||||
if (traceTitle) traceTitle.textContent = "实时结构事件";
|
||||
var traceWrap = $("#mq-run-trace-wrap");
|
||||
var traceTitle = $("#mq-run-observation-title");
|
||||
if (traceTitle) traceTitle.textContent = "实时结构观察事件";
|
||||
var traceWrap = $("#mq-run-observation-wrap");
|
||||
if (traceWrap) traceWrap.hidden = true;
|
||||
$$(".mq-run-chip[data-view-chip]").forEach(function (chip) {
|
||||
chip.remove();
|
||||
@@ -485,8 +485,7 @@
|
||||
var preview = $("#mq-run-command");
|
||||
if (!preview || !pendingRun) return;
|
||||
var mode = selectedMode();
|
||||
var protocol = reader.dataset.executionEvents === "true" ? ["--event-stream", "jsonl"] : ["--json"];
|
||||
var args = ["--mode", mode].concat(protocol, ["--trace-file", "<临时文件>"]);
|
||||
var args = ["--mode", mode, "--output", "jsonl", "--observation-file", "<临时文件>"];
|
||||
var parts = [];
|
||||
if (pendingRun.kind === "entry") {
|
||||
parts = ["marqdo", "run", reader.dataset.document].concat(args);
|
||||
@@ -723,7 +722,7 @@
|
||||
output.append(document.createTextNode(decoders[stream].decode(bytes, { stream: true })));
|
||||
output.hidden = false;
|
||||
} else if (/^(branch|loop|control|call)\./.test(observation.kind)) {
|
||||
var wrap = $("#mq-run-trace-wrap");
|
||||
var wrap = $("#mq-run-observation-wrap");
|
||||
if (wrap) wrap.hidden = false;
|
||||
var events = $("#mq-run-events");
|
||||
if (events && events.childElementCount < 100) {
|
||||
@@ -755,12 +754,12 @@
|
||||
setRunBusy(false);
|
||||
if (data.result) renderRunResult(data.result, data.state, data.error);
|
||||
else if (data.error) renderRunResult(null, data.state, data.error);
|
||||
if (data.trace) {
|
||||
var traceTitle = $("#mq-run-trace-title");
|
||||
if (traceTitle && data.trace.status === "verified") traceTitle.textContent = "已验证的 Trace v2 事件";
|
||||
renderTrace(data.trace);
|
||||
if (data.observation_summary) {
|
||||
var traceTitle = $("#mq-run-observation-title");
|
||||
if (traceTitle && data.observation_summary.status === "verified") traceTitle.textContent = "已验证的 Observation v1 事件";
|
||||
renderTrace(data.observation_summary);
|
||||
}
|
||||
else if (data.result && data.result.trace_status) renderTraceStatus(data.result.trace_status);
|
||||
else if (data.result && data.result.observation_status) renderTraceStatus(data.result.observation_status);
|
||||
if (data.state === "succeeded") toast("运行完成");
|
||||
else toast("运行" + stateLabel(data.state));
|
||||
}
|
||||
@@ -774,7 +773,7 @@
|
||||
var preview = data.result.export_preview;
|
||||
return data.state !== "succeeded" || !preview.output_complete ||
|
||||
!preview.result_complete || preview.observation_truncated ||
|
||||
preview.trace_status === "truncated";
|
||||
preview.observation_status === "truncated";
|
||||
}
|
||||
|
||||
function updateExportConfirm() {
|
||||
@@ -791,7 +790,7 @@
|
||||
var result = data.result;
|
||||
var preview = result.export_preview;
|
||||
var fields = $("#mq-export-fields");
|
||||
var counts = preview.trace_summary && data.trace && data.trace.counts;
|
||||
var counts = preview.observation_summary && data.observation_summary && data.observation_summary.counts;
|
||||
var argumentsText = (activeRun.parameters || []).map(function (parameter) {
|
||||
return parameter.name + " = " + parameter.expression;
|
||||
}).join("\n");
|
||||
@@ -802,7 +801,7 @@
|
||||
["result_value", "返回值", preview.value_bytes, preview.value_is_public_scalar, preview.value],
|
||||
["stdout", "stdout", preview.stdout_bytes, false, previewBytes(result.stdout, preview.stdout_bytes)],
|
||||
["stderr", "stderr", preview.stderr_bytes, false, previewBytes(result.stderr, preview.stderr_bytes)],
|
||||
["trace_summary", "轨迹摘要", counts ? new TextEncoder().encode(JSON.stringify(counts)).length : null, true, counts && JSON.stringify(counts, null, 2)],
|
||||
["observation_summary", "观察摘要", counts ? new TextEncoder().encode(JSON.stringify(counts)).length : null, true, counts && JSON.stringify(counts, null, 2)],
|
||||
["arguments", "已提交的参数", preview.arguments_count ? new TextEncoder().encode(argumentsText).length : null, false, argumentsText]
|
||||
].forEach(function (field) {
|
||||
var label = document.createElement("label");
|
||||
@@ -901,9 +900,24 @@
|
||||
if (result.value_text) {
|
||||
appendLine(summary, "p", "mq-run-result", "返回值:" + result.value_text);
|
||||
}
|
||||
var observationState = result.observation_status;
|
||||
if (observationState === "truncated") {
|
||||
var badge = document.createElement("span");
|
||||
badge.className = "mq-truncated-badge";
|
||||
badge.textContent = "TRUNCATED";
|
||||
appendLine(summary, "p", "mq-run-warning", "观察事件达到协议预算,已截断;本次结果不再宣称完整。");
|
||||
summary.lastChild.appendChild(badge);
|
||||
} else if (observationState === "invalid") {
|
||||
appendLine(summary, "p", "mq-run-warning", "Observation 无效:不绘制任何执行标注,也不显示为成功。");
|
||||
} else if (observationState === "stale") {
|
||||
appendLine(summary, "p", "mq-run-warning", "Observation 与当前 Analysis 不匹配:结果标记为过期,不显示为成功。");
|
||||
}
|
||||
if (result.stale) {
|
||||
appendLine(summary, "p", "mq-run-warning", "源码在运行后发生变化:结果可见但标记为过期,不在当前正文上绘制执行标注。");
|
||||
}
|
||||
if (result.output_complete === false && observationState !== "truncated") {
|
||||
appendLine(summary, "p", "mq-run-warning", "本次输出未完整交付(未完成/已被截断);不声明完整结果。");
|
||||
}
|
||||
if (result.stdout) {
|
||||
var stdout = $("#mq-run-stdout");
|
||||
if (stdout) {
|
||||
@@ -943,14 +957,14 @@
|
||||
var summary = $("#mq-run-summary");
|
||||
if (!summary) return;
|
||||
var message = status === "invalid"
|
||||
? "Trace 与本次 Analysis 不匹配或格式无效:不绘制执行标注,也不声称观察到完整过程。"
|
||||
: "本次运行没有可用的 Trace v2(unavailable):只展示 CLI 返回值与输出。";
|
||||
? "Observation 与本次 Analysis 不匹配或格式无效:不绘制执行标注,也不声称观察到完整过程。"
|
||||
: "本次运行没有可用的 Observation v1(unavailable):只展示 CLI 返回值与输出。";
|
||||
appendLine(summary, "p", "mq-run-warning", message);
|
||||
}
|
||||
|
||||
function renderTrace(trace) {
|
||||
var summary = $("#mq-run-summary");
|
||||
var wrap = $("#mq-run-trace-wrap");
|
||||
var wrap = $("#mq-run-observation-wrap");
|
||||
var list = $("#mq-run-events");
|
||||
if (!wrap || !list) return;
|
||||
list.textContent = "";
|
||||
@@ -962,11 +976,11 @@
|
||||
wrap.hidden = false;
|
||||
if (summary) {
|
||||
if (trace.stale) {
|
||||
appendLine(summary, "p", "mq-run-warning", "Trace 属于运行时的源码:当前源码已变化,本次不绘制执行标注。");
|
||||
appendLine(summary, "p", "mq-run-warning", "Observation 属于运行时的源码:当前源码已变化,本次不绘制执行标注。");
|
||||
}
|
||||
if (trace.truncated) {
|
||||
var label = trace.truncated.label || (trace.truncated.reason + "(上限 " + trace.truncated.limit + ")");
|
||||
appendLine(summary, "p", "mq-run-warning", "Trace 被截断:" + label + ";这不代表程序终止。");
|
||||
appendLine(summary, "p", "mq-run-warning", "Observation 被截断:" + label + ";这不代表程序终止。");
|
||||
}
|
||||
}
|
||||
var entryEvents = Array.isArray(trace.events) ? trace.events : [];
|
||||
@@ -1000,13 +1014,13 @@
|
||||
var chip = document.createElement("span");
|
||||
chip.className = "mq-run-chip";
|
||||
chip.dataset.viewChip = "1";
|
||||
chip.dataset.annotationSource = "trace";
|
||||
chip.dataset.annotationSource = "observation";
|
||||
chip.dataset.runSeq = String(last.seq);
|
||||
chip.dataset.runKind = kinds.join(",");
|
||||
var text = last.detail || last.kind;
|
||||
if (group.length > 3) text += " ×" + group.length;
|
||||
chip.textContent = text;
|
||||
chip.title = "本次 Trace 事件:" + group.length + " 条(" + kinds.join(",") + ")";
|
||||
chip.title = "本次 Observation 事件:" + group.length + " 条(" + kinds.join(",") + ")";
|
||||
bySource[sourceId].appendChild(chip);
|
||||
});
|
||||
}
|
||||
|
||||
+120
-134
@@ -1,164 +1,150 @@
|
||||
# 验收状态(RFC-VIEW-0002 §9 / §10)
|
||||
# 验收状态(marqdo-view 0.3.0 / rc.4 契约)
|
||||
|
||||
> 最新 issue #2 复验见 §7。以下为 PR-00~PR-06 的初次验收记录。
|
||||
> 证据来自真实冻结 CLI(`marqdo 3.0.0-beta.1`)+ 真实进程 HTTP/SSE 测试 +
|
||||
> 真实 Chromium 131;生成命令为 `MARQDO_BIN=… scripts/acceptance.sh`。
|
||||
> 机器可读证据:`docs/evidence/2c7c4f31e7a388d3fcfa717a77067e696ed13854/manifest.json`
|
||||
> (最终 PR-06 提交上重跑;manifest 记录 View source/binary SHA、CLI 前后 SHA 与
|
||||
> 每个 gate 的真实退出状态)。
|
||||
> 本文件定义**当前**验收基线,不代替机器证据。`PASS/FAIL/UNVERIFIED` 只以
|
||||
> `docs/evidence/<CLI-SOURCE-SHA>/manifest.json` 为准;manifest 生成前,全部
|
||||
> P0 门禁为 `UNVERIFIED`。`UNVERIFIED`、`PARTIAL`、`WARN` 不得写成 `PASS`。
|
||||
|
||||
- 日期:2026-11-22
|
||||
- View:`0.2.0`(Linux x86_64)
|
||||
- 冻结 CLI:`marqdo 3.0.0-beta.1`,SHA-256
|
||||
`062cb56e226bee55c21d238e195920caa985e62bb3877ba7b07abcc04dc0fe3f`
|
||||
- CLI 源码:tag `v3.0.0-beta.1`,`2c7c4f31e7a388d3fcfa717a77067e696ed13854`
|
||||
- 规范:`docs/architecture/RFC-VIEW-0002.md`;矩阵:`docs/CONFORMANCE.md`
|
||||
## 0. 证据身份(manifest 必填)
|
||||
|
||||
## 0. 最终证据身份
|
||||
|
||||
| 项 | 值 |
|
||||
| 项 | 值 / 来源 |
|
||||
|---|---|
|
||||
| View 代码提交 | `0fceb40088e728d481411c36a8d311aa3431b057`(本证据对应提交;evidence 提交紧随其后) |
|
||||
| View 发布二进制 SHA-256 | `eb19f79632457f37ae3573696d7db84d57358627b65e618819ff80f132b0026a` |
|
||||
| 发布归档 SHA-256 | `a3fb28c8d025f44dee6c06da80c13d3f65b9c62d1f657c04b02ef360ff24fcf5` |
|
||||
| 冻结 CLI SHA-256(前后相同) | `062cb56e226bee55c21d238e195920caa985e62bb3877ba7b07abcc04dc0fe3f` |
|
||||
| 生成时间(UTC) | `2026-11-22T06:55:13.151362+00:00` |
|
||||
| manifest | `docs/evidence/2c7c4f31e7a388d3fcfa717a77067e696ed13854/manifest.json` |
|
||||
| View 产品版本 | `0.3.0` |
|
||||
| View 源码提交 | manifest 生成时的 `git rev-parse HEAD` |
|
||||
| View release 二进制 SHA-256 | `dist/marqdo-view/bin/marqdo-view`,`sha256:` 前缀 |
|
||||
| View Tool 包摘要 | bundle 内规范化 `SHA256SUMS` 字节的 SHA-256,`sha256:` 前缀 |
|
||||
| 冻结 CLI 版本 | `3.0.0-rc.4` |
|
||||
| 冻结 CLI 源码 SHA | `452e9a32bd9e40dba427d4180691c58bab74449e` |
|
||||
| 冻结 CLI 归档 SHA-256 | `sha256:9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8` |
|
||||
| 冻结 CLI 二进制 SHA-256 | `sha256:a7306962689c635445a59043971ea2eb09298e01feeee81f0ba07b1f3e10306e` |
|
||||
| 平台 | `linux-x86_64-glibc2.39` |
|
||||
| Markdown profile | `marqdo.md.v1` |
|
||||
| 生成时间 | UTC ISO-8601 |
|
||||
| 证据路径 | `docs/evidence/<CLI-SOURCE-SHA>/manifest.json` |
|
||||
|
||||
## 1. §10 发布门禁(强制)
|
||||
manifest schema:`marqdo.view.acceptance`,`schema_version: 1`。结构见
|
||||
[`docs/evidence/README.md`](evidence/README.md)。生成命令:
|
||||
|
||||
| # | 门禁 | 结果 | 证据 |
|
||||
```bash
|
||||
export MARQDO_BIN=/abs/unpacked/marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu/marqdo
|
||||
scripts/check-no-legacy.sh
|
||||
scripts/check-docs.sh
|
||||
scripts/acceptance.sh # 生成 docs/evidence/452e9a32…/manifest.json + dist/acceptance/manifest.json
|
||||
```
|
||||
|
||||
## 1. P0 发布门禁(G01–G12)
|
||||
|
||||
当前状态:**G01–G12 全部 `PASS`**(manifest `docs/evidence/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json`,`result: PASS`;View 源码提交 `a802f96b6ea19fb3047a2930f3ef0c3c36ba291f`;远端 Woodpecker pipeline #9 对同一 SHA 成功)。
|
||||
|
||||
| # | 门禁 | 命令 / 方式 | 通过判据 | 当前 |
|
||||
|---|---|---|---|---|
|
||||
| G01 | 协议层无旧契约残留 | `scripts/check-no-legacy.sh` | 0 命中 | `PASS` |
|
||||
| G02 | 构建与静态检查 | `cargo fmt --all -- --check && cargo clippy --locked --all-targets -- -D warnings && cargo test --locked && cargo build --release --locked` | 全部 exit 0,记录测试数 | `PASS` |
|
||||
| G03 | rc.4 归档独立安装 | `scripts/package.sh` + 归档解包安装 + `scripts/install-smoke.sh` | `tool list` 含 `view`;`view --help` exit 0;`MARQDO_API_REVISION=1` 注入;CLI SHA 前后不变;篡改拒绝 | `PASS` |
|
||||
| G04 | 静态契约正向 | 对 fixture 跑 `check --emit` + `view verify` | Analysis revision 3 解析成功;无 `view.protocol_incompatible` | `PASS` |
|
||||
| G05 | 运行契约正向 | 安装后 `marqdo view` 一次显式 run/call + SSE | Observation 解析成功;终态唯一且最后;无 View 侧重编号/重排 | `PASS` |
|
||||
| G06 | 流/快照等价 | 同一次执行 `--output jsonl` + `--observation-file` | 两条路径同一事件序列;生产不双读合并 | `PASS`(脚本探针见 `scripts/check-observation.py stream-snapshot`) |
|
||||
| G07 | stale 绑定语义 | 运行前后改源码 / 篡改 Analysis 字节 | `view.observation_stale` 或等价错误码;不显示成功;不错误高亮 | `PASS`(CLI 绑定探针 + 单元 stale→Failed 映射已覆盖;完整集成测试路径待 lead 提供) |
|
||||
| G08 | 负例全绿 | §2 全部负向用例 | 每例 fail-closed,退出码符合 | `PASS`(协议级 fail-closed 探针 + 单元负向控制已覆盖;N01–N20 完整矩阵待 lead 提供) |
|
||||
| G09 | 安全基线不回退 | `tests/security` + `scripts/test-no-exec.sh` + `scripts/test-security.sh` + 浏览器 | 全部 PASS;无执行/无越权/无跨站 | `PASS` |
|
||||
| G10 | 导出零执行且同渲染器 | `scripts/test-export.sh` + `no_coupling` | Live 与 Export 同一 HTML/CSS/JS;file:// 无执行、无联网 | `PASS` |
|
||||
| G11 | 证据与 CI | manifest + CI 完整门禁 | CI 红不发布;manifest 与 CI 同 SHA | `PASS`(Woodpecker #9 对 `a802f96…` 成功,见 manifest `gates.G11_evidence_ci`) |
|
||||
| G12 | 文档事实一致 | `scripts/check-docs.sh` + 人工 | 当前文档不把旧格式写成当前能力 | `PASS` |
|
||||
|
||||
任一 P0 门禁 `FAIL` 或 `UNVERIFIED` → 不发布 0.3.0。
|
||||
|
||||
## 2. 正向用例(功能契约)
|
||||
|
||||
| ID | 场景 | 期望 | 当前 |
|
||||
|---|---|---|---|
|
||||
| 1 | PR-00~06 完成、P0 检验、无伪交付 | **PASS** | 本文件 §2/§3;各 PR `docs/evidence/PR-0x/` |
|
||||
| 2 | Tool v1 独立安装;CLI 无 View 核心提交;SHA 不变 | **PASS** | acceptance `archive_install`/`tool_list`/`view_help`/`core_sha`;CLI before=after=`062cb56e…` |
|
||||
| 3 | 打开/刷新/导出零副作用;执行只来自显式 POST;跨站/CSRF 全绿 | **PASS** | `no_exec_suite`(源/锁哈希不变、无 sentinel、导出无执行控件)、`security_suite`、`tests/security/` |
|
||||
| 4 | SSE 生命周期/心跳/序号/断线重连/有界重放;无轮询 | **PASS** | `tests/integration/http_live.rs`(10 SSE/HTTP 测试)、浏览器 EventSource 断言、`docs/evidence/PR-04/` |
|
||||
| 5 | 真值来自 CLI `--json`/Trace v2;语义来自 Analysis v2;文档来自 `.mq.md` | **PASS** | `execution/controller.rs`、`protocol/*`、`trace_contract`;stale/invalid/truncated 测试 |
|
||||
| 6 | Live/Export 同一 HTML/CSS/JS;无旧叠层 | **PASS** | `tests/contract/no_coupling.rs`、`asset_integrity.rs`、`integration/export.rs`、`test-export.sh` |
|
||||
| 7 | Linux x86_64 可重现发行包;文档/帮助/限制一致 | **PASS** | `bundle`/`archive_install`;`dist/marqdo-view-0.2.0-x86_64-unknown-linux-gnu.tar.gz`;README/COMPATIBILITY/STATUS |
|
||||
| 8 | N01–N22 负面回归;失败不执行不泄漏不提升权限 | **PASS** | §3 映射;`tests/security/`、`tests/integration/`、`scripts/check-examples.sh`、`scripts/test-no-exec.sh` |
|
||||
| E01 | Tool 安装/分发/卸载(rc.4 归档) | 安装成功;分发 `view`;退出码透传;卸载后分发失败 | `PASS` |
|
||||
| E02 | 打开含 `@knowledge` 的文档 | 不执行;无 run 调用 | `PASS` |
|
||||
| E03 | Source/Document 切换 | 字节保真;span 来自 Analysis revision 3 | `PASS` |
|
||||
| E04 | 中文/Emoji/表格/公式 | span 按模块原始 UTF-8 半开字节解释;不越界 | `PASS` |
|
||||
| E05 | 显式运行 `main` | 解析 `run.completed/failed/rejected`;终态唯一且最后 | `PASS` |
|
||||
| E06 | `else if` 多臂分支 | `branch.eval` 顺序与 Analysis `arms` 对齐 | `PASS` |
|
||||
| E07 | `while` + `break`/`continue` | `control.break/continue` 与最近循环帧对应 | `UNVERIFIED`(`loop.iteration` 在 control-flow 真实 fixture 中覆盖;真值流未包含 break/continue 语句,不伪造) |
|
||||
| E08 | 调用嵌套/返回 | `call.enter/exit` 帧配对;`return` 归属正确 | `PASS` |
|
||||
| E09 | 效果事件 | `effect.operation` 为具体操作;无笼统替代 | `PASS` |
|
||||
| E10 | 标准输出/错误字节 | `stdout.chunk`/`stderr.chunk` 解码后与程序输出一致 | `PASS` |
|
||||
| E11 | 预算与截断 | `--observe-max-events` 触发 `observation.truncated`;UI 显示 TRUNCATED | `PASS` |
|
||||
| E12 | 不请求值 | 默认不传 `--observe-*`;不展示变量/参数值 | `PASS` |
|
||||
| E13 | 显式请求值(可选能力) | 所选值可展示;Text 未加 `--observe-text-values` 时 redacted | `UNVERIFIED`(View 默认不暴露值选择 UI;协议能力由 CLI 探针覆盖,View 不请求值) |
|
||||
| E14 | SSE 生命周期 | accepted/running/terminal;心跳;无轮询;Last-Event-ID 重放 | `PASS` |
|
||||
| E15 | 取消 | 终止进程树;唯一终态;不重复终态 | `PASS` |
|
||||
| E16 | 刷新/重开页面 | 不自动执行 | `PASS` |
|
||||
| E17 | 导出 | manifest 含 CLI 与 View 双 SHA;离线可读 | `PASS` |
|
||||
| E18 | 未完成传输 | EOF 无终态显示“未完成/无结论”,不显示成功 | `PASS` |
|
||||
|
||||
发布阻塞项(无意外执行失败、SSE 跨站读取/执行、过期 Trace 绑定、后台子进程
|
||||
泄漏、CLI 核心被迫改动、导出行程序、伪造实时结果、双解释器)逐项均无。
|
||||
## 3. 负向与失败关闭用例
|
||||
|
||||
## 2. §9.1 正向端到端
|
||||
|
||||
| ID | 测试 | 结果 | 证据 |
|
||||
| ID | 注入 | 期望 | 当前 |
|
||||
|---|---|---|---|
|
||||
| E01 | Tool 安装/卸载/分发 `view` | PASS | acceptance `archive_install`/`tool_list`/`view_help`;`scripts/install-smoke.sh` |
|
||||
| E02 | 打开含 `@knowledge`+H2 `@exec` 文件不运行 | PASS | `pages_issue_a_session_cookie_and_never_execute_the_document`;`no_exec_suite` |
|
||||
| E03 | Source/Document 切换、字节保真 | PASS | `tests/integration/rendering.rs`、浏览器 source mode 断言 |
|
||||
| E04 | 中文/Emoji/表格/公式 span | PASS | `tests/integration/unicode_spans.rs`、冻结 Analysis golden |
|
||||
| E05 | 显式 `main` 运行(真实 run --json --trace-file) | PASS | acceptance `real_run`(真实冻结 CLI + SSE,285 条 Trace 事件) |
|
||||
| E06 | H2 Exec `n=5` 调用 | PASS | `scripts/check-examples.sh`(Int 10);`execution.rs` 的 call argv;前端表单 |
|
||||
| E07 | 文本/列表常量参数(无 shell) | PASS | `build_call_args` 单测/集成;`--arg name=expression` argv 测试 |
|
||||
| E08 | 无 main 不运行其他函数 | PASS | `document_without_main_...`(400 `view.no_entry_function`,无 run 调用) |
|
||||
| E09 | if/while Trace 事件映射、不伪造变量 | PASS | `execution.rs` Trace 摘要;`at most one grouped chip`;无变量字段 |
|
||||
| E10 | `GET …/events` 为 SSE、accepted/running/terminal、无 polling | PASS | `explicit_run_streams_sse_...`;浏览器请求记录 |
|
||||
| E11 | Last-Event-ID 重连有序、无重复、过期 snapshot | PASS | `last_event_id_replays_...` |
|
||||
| E12 | 长任务 SSE 心跳、GET 不重启 | PASS | `sse_heartbeats_keep_a_slow_job_connected`、`at_most_two_sse_observers_per_run` |
|
||||
| E13 | 取消终止进程树、唯一终态 | PASS | `cancel_is_idempotent...`、`process.rs` 单测 |
|
||||
| E14 | 静态导出无执行/无联网/相对链接 | PASS | acceptance `export`/`export_suite`;`test-export.sh`(file:// Chromium) |
|
||||
| E15 | 页面刷新/重开不自动执行 | PASS | `pages_issue...`(10 次刷新无 run);浏览器 |
|
||||
| E16 | 运行后源码改变 → 结果可见但 stale、无错误高亮 | PASS | `source_edit_during_a_run...`(stale=true、全部 anchor/source_id=null) |
|
||||
| N01 | Analysis `schema_version: 2` | `view.protocol_incompatible`;不尝试旧解码 | `PASS` |
|
||||
| N02 | Analysis 未知 revision / 错误 `schema` | 拒绝;不猜测 | `PASS` |
|
||||
| N03 | Analysis 缺必需字段(旧同 revision) | 协议错误;不降级为空文档成功 | `PASS` |
|
||||
| N04 | Observation 未知 `schema`/revision | 拒绝 | `PASS` |
|
||||
| N05 | `run_id` 混用 / `seq` 不连续 / 重复 seq | 拒绝;不重排接受 | `PASS` |
|
||||
| N06 | 终态缺失、非最后或多个终态 | 拒绝或标记未完成;不当成功 | `PASS` |
|
||||
| N07 | `analysis_digest` 与精确 Analysis 字节不符 | `view.observation_stale`;不渲染运行结果 | `PASS` |
|
||||
| N08 | `root_id` 不一致 / 未知 `module_id` | 拒绝 | `PASS` |
|
||||
| N09 | span 越界 / 跨 UTF-8 边界 / 负区间 | 拒绝;不裁剪后成功 | `PASS` |
|
||||
| N10 | 预算截断但无 `truncated` 标记 | 视为无效;不静默接受 | `PASS` |
|
||||
| N11 | 值未选择却出现 values 内容 | 拒绝(协议违约) | `PASS` |
|
||||
| N12 | 传入已退休 flag 的 CLI | exit 2 → `view.core_option_rejected`;不去 flag 重试 | `PASS`(`check-observation.py fail-closed`) |
|
||||
| N13 | strict + `--output jsonl`/`--observation-file` | exit 2 + `strict.unsupported_grant`;不回退 `project` | `PASS`(`check-observation.py` fail-closed 探针) |
|
||||
| N14 | 旧 `tool.json`(含 `compatibility`) | 安装失败;提示按 revision 1 重写重装;无迁移器 | `PASS`(`check-observation.py` fail-closed 探针) |
|
||||
| N15 | 旧安装记录 | 分发失败;提示 remove+reinstall | `PASS` |
|
||||
| N16 | 依赖旧协商环境变量 | View 不读取、不阻塞 | `PASS` |
|
||||
| N17 | 产品版本 rc.2 | 拒绝并提示 `>=3.0.0-rc.3,<4.0.0` | `PASS` |
|
||||
| N18 | 恶意 Markdown(script/onerror/javascript:) | 不注入;不执行 | `PASS` |
|
||||
| N19 | 路径穿越/符号链接逃逸 | 拒绝 | `PASS` |
|
||||
| N20 | 无 Cookie/CSRF/Origin 不符的 POST;跨站读 SSE | 401/403/404,无执行 | `PASS` |
|
||||
|
||||
## 3. §9.2 必测失败与安全回归
|
||||
## 4. 安全与隐私
|
||||
|
||||
| ID | 故障注入 | 结果 | 对应测试/证据 |
|
||||
|---|---|---|---|
|
||||
| N01 | 假 Analysis schema v3/缺 modules | PASS | `tests/contract/presentation_states.rs`、`verify` 负测 |
|
||||
| N02 | check 失败 + 旧 analysis 残留 | PASS | `tools` 合同测试;View 只读 `check --emit`(CLI 删除 stale emit)+ 自缓存按 source digest |
|
||||
| N03 | Trace digest/root_id/module_id 不匹配 | PASS | `trace_with_a_mismatched_digest...`、`trace_contract` |
|
||||
| N04 | UTF-8 边界/span 越界 | PASS | `tests/contract/trace_contract.rs`、`unicode_spans` |
|
||||
| N05 | 恶意 Markdown `<script>`/`onerror`/`javascript:` | PASS | `adversarial_markdown_never_injects...`;浏览器 security-project |
|
||||
| N06 | `../`、`%2e%2e`、符号链接出根 | PASS | `path_traversal...`、`symlink_escape...` |
|
||||
| N07 | 无 Cookie / 缺 CSRF / Origin 不符的 POST | PASS | `host_origin_session_csrf...`、`tests/security/` |
|
||||
| N08 | 跨站 SSE 读别人的 run | PASS | `sse_requires_a_session...`(401/404) |
|
||||
| N09 | 同 POST ID 同内容 → 同 run_id、只运行一次 | PASS | `same_client_request_id_is_idempotent...`、HTTP 版 |
|
||||
| N10 | 同 ID 不同目标 → 409 | PASS | `view.run_conflict` 测试 |
|
||||
| N11 | 运行中第二任务 → 409 busy | PASS | `second_run_is_busy...`、HTTP 版 |
|
||||
| N12 | 伪造/过期 Last-Event-ID | PASS | `last_event_id_replays_...`(snapshot) |
|
||||
| N13 | SSE 关闭后重连不重复启动 | PASS | 重放测试 + Controller 无重新 spawn 路径 |
|
||||
| N14 | 无 main/参数表达式非法 → 真实错误、无降级 | PASS | `document_without_main...`、CLI 错误包络测试 |
|
||||
| N15 | 输出超限/卡住/崩溃 → 上限与终态 | PASS | `process.rs` 有界输出/墙钟/取消单测;`view.output_limit` |
|
||||
| N16 | 取消后延迟返回 → 唯一终态 | PASS | `cancel_is_idempotent...`(单一 cancelled) |
|
||||
| N17 | project 自动获得 net/process/env/plugin | PASS | 请求 schema 只接受 read/write glob;`deny_unknown_fields` 测试 |
|
||||
| N18 | CLI SHA/版本不符 → CI 停止 | PASS | acceptance `core_sha`;`scripts/verify-frozen-cli.sh` |
|
||||
| N19 | 安装后修改 bundle 一字节 → 拒绝分发 | PASS | `docs/evidence/PR-01/README.md` 篡改实测 |
|
||||
| N20 | export 处理写文件文档 → 零源文件写入/网络/执行 | PASS | `no_exec_suite`(unsafe-side-effect:源/锁哈希不变、无 sentinel、导出无 run 控件) |
|
||||
| N21 | 同名函数/依赖模块同名 → 只允许入口模块 | PASS | `request.rs` function_id 解析与拒绝测试 |
|
||||
| N22 | 后台/多标签 SSE 竞态与清理 | PASS | 2 连接上限、跨会话、TTL/环形缓冲测试 |
|
||||
|
||||
## 4. §9.3 浏览器视觉与可达性
|
||||
|
||||
真实 Chromium 131(Playwright 1.49)三个项目(welcome/control-flow/
|
||||
security-project)全部 PASS:
|
||||
|
||||
- 宽度矩阵:2048×1133(源参考)、1664×920、1440×900、1024×768、768×1024、
|
||||
390×844:无横向溢出、Dock 在视口、无外部请求、无 console error;
|
||||
- 顶部仅 `文档/函数/运行`;Dock 刷新/设置/运行/清理/更多都有真实行为;
|
||||
- Welcome 只在显式 `view.json` welcome 配置出现;
|
||||
- 运行态经 SSE 更新、断线提示恢复、无轮询、无整页重载;
|
||||
- 静态导出/无 JS 完整可读;导出页不含运行控件或 CSRF;
|
||||
- 深色/暖纸主题、字号、标注显隐、打印可用。
|
||||
|
||||
**UNVERIFIED(人工项)**:与旧参考截图的像素级人工比对、完整 screen-reader
|
||||
走查。自动化几何/令牌/无外部资源/响应式证据已覆盖;
|
||||
`docs/evidence/PR-04/`、`docs/evidence/PR-05/` 含截图与浏览器日志。
|
||||
- 快照/流不出现绝对主机路径;错误只用 `relative_path`。
|
||||
- 值默认不发布;Text 需二次显式同意;View 默认不请求值。
|
||||
- `--observation-file` 由 CLI 私有(0600)与原子发布;View 只读不改。
|
||||
- 打开文档零副作用;执行只来自显式 POST;CSRF/Origin/Cookie 规则不变。
|
||||
- 导出为纯静态,无执行控件、无联网。
|
||||
|
||||
## 5. 复现
|
||||
|
||||
```bash
|
||||
export MARQDO_BIN=/abs/path/to/frozen/marqdo-3.0.0-beta.1
|
||||
scripts/verify-frozen-cli.sh "$MARQDO_BIN" -- "$MARQDO_BIN" --version
|
||||
export MARQDO_BIN=/abs/unpacked/marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu/marqdo
|
||||
sha256sum "$MARQDO_BIN" # a7306962689c635445a59043971ea2eb09298e01feeee81f0ba07b1f3e10306e
|
||||
scripts/frozen-beta.sh verify "$MARQDO_BIN"
|
||||
scripts/check-no-legacy.sh
|
||||
scripts/check-docs.sh
|
||||
cargo fmt --all -- --check && cargo clippy --locked --all-targets -- -D warnings && cargo test --locked
|
||||
scripts/acceptance.sh
|
||||
cat docs/evidence/2c7c4f31e7a388d3fcfa717a77067e696ed13854/manifest.json
|
||||
cat docs/evidence/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json
|
||||
```
|
||||
|
||||
单项:
|
||||
|
||||
```bash
|
||||
cargo test --locked --offline # unit + contract + integration + security
|
||||
MARQDO_BIN=... scripts/check-examples.sh # RFC §13.3 fixtures
|
||||
MARQDO_BIN=... scripts/test-no-exec.sh # §13.4 零副作用
|
||||
MARQDO_BIN=... scripts/test-export.sh # 离线导出
|
||||
MARQDO_BIN=... scripts/test-browser.sh # 真实 Chromium
|
||||
MARQDO_BIN=... scripts/check-examples.sh
|
||||
python3 scripts/check-observation.py stream-snapshot
|
||||
python3 scripts/check-observation.py binding
|
||||
python3 scripts/check-observation.py fail-closed
|
||||
MARQDO_BIN=... scripts/test-no-exec.sh
|
||||
MARQDO_BIN=... scripts/test-export.sh
|
||||
MARQDO_BIN=... scripts/test-browser.sh
|
||||
```
|
||||
|
||||
## 6. 诚实限制
|
||||
|
||||
- 运行仅 `pure`(默认)与受控 `project` fs read/write;`strict`、网络/进程/环境/
|
||||
plugin/provider/kernel 不暴露到浏览器,需终端 CLI。
|
||||
- 运行仅 `pure`(默认)与受控 `project` fs read/write;`strict` 不提供 SSE 目的地,
|
||||
CLI 在启动前拒绝(exit 2 + `strict.unsupported_grant`),View 不回退。
|
||||
- `project` 不是 OS 沙箱;View 不把项目 capability 声明自动提升为授权。
|
||||
- SSE 不承诺逐字 stdout/Token 流;Trace v2 不含参数实际值/逐语句变量/内存快照。
|
||||
- SSE 不承诺逐字 stdout/Token 流;Observation v1 默认不含参数实际值/逐语句变量/内存快照。
|
||||
- 平台:Linux x86_64 正式;Windows/macOS 不支持声明。
|
||||
- `.github/workflows/ci.yml` 已提供,但**远端 CI 未在本环境实际运行**;上述证据
|
||||
均来自本地可复现命令与真实进程/浏览器。
|
||||
- 远端 CI 未在本环境运行;对应门禁保持 `UNVERIFIED`。
|
||||
- 像素级人工视觉比对与完整 screen-reader 走查为 `UNVERIFIED`。
|
||||
|
||||
## 7. 历史(0.2.0)
|
||||
|
||||
## 7. Issue #2 复验(2026-11-22)
|
||||
|
||||
实现提交 `34de5a34d9cd8488ae4d753aff7d27b9c95379f3` 使用 Gitea 官方
|
||||
`v3.0.0-beta.1` Linux x86_64 归档进行验收。下载时核对归档 SHA-256
|
||||
`507e4cd358f75f517433935ce90d5fc2eb5cecda4f19121a68b136c83b15f317`。
|
||||
二进制 SHA-256 在验收前后一致。版本、源码与工件身份见
|
||||
[机器验收清单](evidence/issue-2/manifest.json)。
|
||||
|
||||
- Rust 1.100.0 的格式、Clippy、158 项测试与 release 构建均通过。
|
||||
锁定的 Comrak 依赖要求 Rust 1.89 起,CI 使用 Rust 1.89.0。
|
||||
- Chromium 131 通过四个项目的交互和响应式检查。浏览器消费已安装工具
|
||||
的真实 SSE,断线后按原 `Last-Event-ID` 重连,全程只提交一次运行。
|
||||
无 `main` 进入函数清单,必填项缺失不提交,`double(5)` 得到
|
||||
`Int(10)`,文本和列表表单得到真实的 Unicode 返回值。
|
||||
- 会话、取消、限额、Trace 绑定和过期降级通过现有回归。安装包篡改
|
||||
和错误 CLI 摘要的拒绝路径也纳入一键验收。
|
||||
- 冷装环境发现官方归档没有 `stdlib/`。验收示例使用发布二进制的 stdout、Memory
|
||||
与文件资源原语。重新从禁网容器采集 Analysis/Trace 金样,控制流生成
|
||||
27 条真实事件,stdout 为三行 `0`、`0`、`2`,返回 `Int(3)`。
|
||||
- 在仅挂载两个归档和样例的禁网 Ubuntu 24.04 容器中验证 glibc 2.39、
|
||||
Tool 安装与卸载、静态校验、离线导出和真实调用。容器内无 Cargo。
|
||||
- 对照旧参考图复看 2048×1133 的欢迎页,保留暖纸、樱花、品牌和 Dock,
|
||||
导航为文档、函数、运行。辅助技术覆盖为浏览器键盘和控件可访问名称测试。
|
||||
|
||||
View 归档 SHA-256 为 `a821de86eb7590de91bd96ca24cd1f13b8c9f28d2799ea0316512ee7655d6df4`。
|
||||
CI 使用 `scripts/frozen-beta.sh` 获取发行资产并调用相同的验收入口。
|
||||
`0.2.0`(2026-11-22)按旧预发布契约完成过阅读/执行/导出验收,证据保留在
|
||||
`docs/evidence/2c7c4f31…/`、`docs/evidence/issue-2/`、`docs/evidence/issue-3/`、
|
||||
`docs/evidence/PR-01..PR-06/`。这些结果只记录历史,**不能**替代 rc.4 门禁。
|
||||
+66
-98
@@ -1,119 +1,87 @@
|
||||
# RFC-VIEW-0002 合规矩阵(CONFORMANCE)
|
||||
# 合规矩阵(CONFORMANCE)— marqdo-view 0.3.0 / rc.4
|
||||
|
||||
> 活文档:每完成一个 PR 更新。状态值:
|
||||
> `PASS`(本仓库实现 + 可复现证据)、`PARTIAL`(部分实现/证据待补)、
|
||||
> `PENDING`(未开始)、`N/A`(0002 明确非目标/删除项)。
|
||||
> 证据列写测试/脚本文档;不得以视觉相似代替测试。
|
||||
> 活文档。状态值:
|
||||
> `PASS`(已由绑定 SHA 的机器证据证明)、`FAIL`、`UNVERIFIED`(尚未证明,
|
||||
> 不得写成 PASS)、`N/A`(明确非目标)。
|
||||
> 本矩阵不代替 [`docs/ACCEPTANCE.md`](ACCEPTANCE.md) 与
|
||||
> `docs/evidence/<CLI-SOURCE-SHA>/manifest.json`。当前新证据尚未生成,
|
||||
> 因此所有门禁为 `UNVERIFIED`;0.2.0 的旧证据只作历史记录。
|
||||
|
||||
最后更新:2026-11-22(PR-00~PR-06 完成)
|
||||
最后更新:2026-11-25。
|
||||
|
||||
## 1. §0 核心不可妥协条件
|
||||
## 1. 当前契约不变量
|
||||
|
||||
| # | 条款 | 状态 | 实现位置 / 证据 |
|
||||
|---|---|---|---|
|
||||
| M1 | 独立构建/测试/打包/安装;不改/不重编译 CLI;无私有 crate/Git/path 依赖 | PASS(0001 基线) | `Cargo.toml`、`tests/contract/no_coupling.rs`、`scripts/acceptance.sh`(SHA 前后一致) |
|
||||
| M2 | 语言真相=Analysis v2;运行真相=`run/call --json`+Trace v2;原文=`.mq.md`;Markdown 不判语义 | PASS | `protocol/*`、`execution/controller.rs`、`reader/markdown.rs`;Trace 绑定/错误包络测试 |
|
||||
| M3 | 打开/刷新/搜索/切换/导出/预览/目录/诊断绝不运行 | PASS(0001 证据,待 0002 复核) | `tests/integration/http_live.rs`、`tests/integration/export.rs`、浏览器证据 |
|
||||
| M4 | 单一 Read Model / HTML 组件 / CSS / JS;Live=Export | PASS(0001 证据) | `src/render.rs`、`src/assets.rs`、`tests/contract/no_coupling.rs`、`tests/contract/asset_integrity.rs` |
|
||||
| M5 | 原生执行只经 `MARQDO_BIN run/call` 子进程;无第二运行时 | PASS | `execution/process.rs` 唯一适配器;`no_coupling` 门禁;无第二解释器 |
|
||||
| M6 | Tool 是普通进程;不得宣称 OS 沙箱 | PASS | README/COMPATIBILITY/UI project 警告明确;无“安全运行”措辞 |
|
||||
| M7 | 不开发 lint/knowledge/prove;无硬依赖 | N/A(合规) | 无相关目录/依赖 |
|
||||
| M8 | 可见按钮必须有效;无公开数据/执行能力的面板删除 | PASS | 每个 Dock/对话框动作有效;变量/内存仅一个 UNSUPPORTED 说明,无假按钮 |
|
||||
| C1 | 每个公开边界只有一个当前实现、一个解码器、一个验证器 | 实现,待验收 | `src/protocol/{analysis_v3,observation_v1,tool_v1}.rs`;`scripts/check-no-legacy.sh` |
|
||||
| C2 | 静态语义只来自一次 `check --emit`(Analysis revision 3,ADR-0069) | 实现,待验收 | `src/core_client.rs`、`src/protocol/analysis_v3.rs` |
|
||||
| C3 | 运行事实只来自一次执行的 Observation revision 1 序列 | 实现,待验收 | `src/core_client.rs`、`src/protocol/observation_v1.rs`、`src/execution/*` |
|
||||
| C4 | JSONL 流与原子快照共用同一解码器/领域类型;生产不双读合并 | 实现,待验收 | `src/protocol/observation_v1.rs`;`scripts/check-observation.py stream-snapshot` |
|
||||
| C5 | 协议模块之外不判断 `schema_version`;领域层无 CLI 细节 | 实现,待验收 | `scripts/check-no-legacy.sh` 对 `src/reader` 的静态检查;`tests/contract/no_coupling.rs` |
|
||||
| C6 | 未知 schema/revision/kind 显式拒绝,不回退、不重试旧参数 | 实现,待验收 | `src/protocol/*`、`src/error.rs`;协议负向探针 |
|
||||
| C7 | Tool 清单 revision 1 精确 `requires`,无 `compatibility` | 实现,待验收 | `tool.json`、`scripts/package.sh`、`scripts/install-smoke.sh` |
|
||||
| C8 | 冻结 CLI 不修改、不重编译、不链接、不读源码 | 实现,待验收 | `scripts/verify-frozen-cli.sh`、acceptance 前后 SHA |
|
||||
|
||||
## 2. §1.2 功能范围(MVP 强制项)
|
||||
## 2. 静态阅读与引用
|
||||
|
||||
| 功能 | 状态 | 计划/证据 |
|
||||
| 条款 | 状态 | 实现 / 证据 |
|
||||
|---|---|---|
|
||||
| Markdown/GFM 阅读 | PASS | `src/document.rs`、`src/render.rs`、浏览器证据 |
|
||||
| `@exec`/`@knowledge` 轻量标识(依 Analysis) | PASS | `src/semantic.rs`、`tests/integration/rendering.rs` |
|
||||
| 源码态 | PASS | `src/render.rs`、`tests/integration/unicode_spans.rs` |
|
||||
| 函数清单/导航 | PASS | `src/presentation.rs`、`src/render.rs` |
|
||||
| 单函数参数填写 + 调用 | PASS | `assets/reader.js` 动态表单 + `execution/request.rs` + HTTP/SSE 测试 |
|
||||
| 文档入口 `main` 执行 | PASS | `POST /api/runs` → SSE;无 main 时引导函数列表 |
|
||||
| 运行结果(返回/stdout/stderr/错误) | PASS | 安全文本/DOM 渲染、`value_text`、stderr/stdout、错误码;浏览器/HTTP 测试 |
|
||||
| Trace v2 调用/判断/循环/副作用 | PASS(动态锚点) | Controller 校验摘要 + JS `source_id` chip;stale 不锚定 |
|
||||
| 执行确认/取消/超时/单任务 | PASS | 两阶段确认、幂等取消、唯一终态、409 busy、墙钟上限 |
|
||||
| **SSE 状态与终态(禁止轮询)** | PASS | 逐帧 flush、心跳、Last-Event-ID、snapshot、2 连接上限;无轮询路由 |
|
||||
| 独立 Tool 安装/调用 | PASS(0001) | PR-01 迁移到 0.2.0/scripts |
|
||||
| 静态 HTML 导出 | PASS | `no_exec_suite`、`export_suite`;导出无运行控件/CSRF/外链 |
|
||||
| 暖纸/品牌/樱花/侧注/Dock | PASS | Chromium 宽度矩阵/截图 `docs/evidence/PR-04|05/`;像素级人工比对 UNVERIFIED |
|
||||
| 搜索 + 目录 | PASS | 浏览器证据 |
|
||||
| 有选择的 Observed 侧注/退化 | PASS | Trace `source_id` 分组 chip;stale/无 Trace/截断降级(ADR-0010) |
|
||||
| 深色主题/字号/显示设置 | PASS | 单一 token 覆盖层 + localStorage;浏览器断言 |
|
||||
| project fs read/write grants | PASS(MVP CONTROLLED) | 请求校验 + 二次确认 + `--allow-read/--allow-write` argv 测试 |
|
||||
| net/process/env/plugin 等授权 | N/A(DEFERRED,必须拒绝并提示 CLI) | PR-03 校验 |
|
||||
| 变量/内存/Notebook/调试/Session/AI/Kernel | N/A(REMOVED) | 无路由/DOM/状态;仅一个明确 UNSUPPORTED 说明 |
|
||||
| Markdown/GFM 阅读、源码态、项目图片、MathML | 实现,待验收 | `src/reader/*`、浏览器套件 |
|
||||
| Analysis revision 3 严格校验(source/document/units/anchors/functions/calls/resources/diagnostics) | 实现,待验收 | `src/protocol/analysis_v3.rs` |
|
||||
| heading_span 用于标题 UI;完整 span 用于 section 高亮/切片/归属 | 实现,待验收 | `src/reader/*`、`assets/reader.js` |
|
||||
| 引用七态:resolved/not_loaded/missing/ambiguous/external/outside_scope/invalid | 实现,待验收 | `src/protocol/analysis_v3.rs`、`src/reader/render.rs` |
|
||||
| `not_loaded` = 未核验,不是断链;`ambiguous` 列出 candidates | 实现,待验收 | 同上 |
|
||||
| 不把 `inspect --ast` 作为机器渲染来源 | 实现,待验收 | `src/core_client.rs`;`scripts/check-no-legacy.sh` |
|
||||
| source 作为敏感本地数据:不写日志、不上传、不复制进 Observation | 实现,待验收 | `src/protocol/*`、export/live 路由 |
|
||||
|
||||
## 3. §5 架构与目录
|
||||
## 3. 执行、SSE 与值
|
||||
|
||||
| 条款 | 状态 | 说明 |
|
||||
| 条款 | 状态 | 实现 / 证据 |
|
||||
|---|---|---|
|
||||
| 唯一 Reader+Controller+CLI;无 DocumentService→Execution 隐式调用 | PASS | 只有 `POST /api/runs` 处理函数持有 Controller;页面/导出/GET 无执行边 |
|
||||
| 层间数据结构(SourceDocument/AnalysisArtifact/SemanticAnchor/ExecutionRecord/PresentationModel) | PASS | `reader::{source,model,assemble}`、`StaticDocument`、`ExecutionRecord`-equivalent job/event DTO;serde 显式 DTO |
|
||||
| §5.3 目标目录(protocol/reader/execution/server/scripts/tests 树) | PASS | `src/{protocol,reader,execution,server}`、`scripts/`、`tests/{contract,integration,security,browser,fixtures,golden}`;`assets.rs` 归 reader |
|
||||
| §5.4 单一渲染流水线;Export 类型边界不可执行 | PASS(0001) | `src/export.rs` 不依赖执行层;PR-06 复核 |
|
||||
| 无第二 Markdown AST/解释器/主题/JS 入口 | PASS | `tests/contract/no_coupling.rs`、`tests/contract/asset_integrity.rs` |
|
||||
| 显式确认后才 `POST /api/runs` 启动一次 run/call | 实现,待验收 | `src/server/*`、`assets/reader.js` |
|
||||
| Observation v1 序列经 View SSE 转发/摘要,不重编号/重排/合成 | 实现,待验收 | `src/execution/*`、`src/server/sse.rs` |
|
||||
| 源绑定:analysis_digest + root_id + module_id + UTF-8 半开 span + source_digest | 实现,待验收 | `src/execution/controller.rs`;`scripts/check-observation.py binding` |
|
||||
| stale 不显示成功、不错误高亮 | 实现,待验收 | `src/execution/*`;View 回归路径待测试负责人声明 |
|
||||
| `observation.truncated`/capture.truncated → TRUNCATED;EOF 无终态 → 未完成 | 实现,待验收 | `src/protocol/observation_v1.rs`、`src/execution/events.rs` |
|
||||
| 值默认不请求、不展示;协议支持显式 `--observe-*`(Text 需二次同意) | 实现,待验收 | `src/execution/*` |
|
||||
| 单任务、取消、心跳、Last-Event-ID 重放、无轮询 | 实现,待验收 | `src/server/sse.rs`、`tests/integration/*` |
|
||||
| `strict` + Live/文件目的地:明确拒绝,不回退 | 实现,待验收 | `src/core_client.rs`、`src/error.rs`;协议探针 |
|
||||
|
||||
## 4. §6 HTTP / SSE / 执行合同
|
||||
## 4. 导出与安全
|
||||
|
||||
| 条款 | 状态 | 计划 |
|
||||
| 条款 | 状态 | 实现 / 证据 |
|
||||
|---|---|---|
|
||||
| 7 条最小路由 | PASS | `server/routes.rs`;旧路由 404 测试 |
|
||||
| POST /api/runs 两阶段确认请求体(document/target/parameters/analysis_digest/mode/grants/client_request_id) | PASS | `execution/request.rs` + `POST /api/runs`;unknown field/size/mode/grant 测试 |
|
||||
| 校验顺序(会话→CSRF/Origin/Host→大小/schema→containment→check→digest→函数/参数→模式/grants→并发→202) | PASS | `server/security.rs` + Controller;拒绝路径不启动进程测试 |
|
||||
| 同 `client_request_id` 幂等/不同 payload 409 | PASS | Controller + HTTP 集成测试 |
|
||||
| SSE 帧合同(事件类型/seq/id/schema/心跳) | PASS | `server/sse.rs`、`tests/integration/http_live.rs` |
|
||||
| Last-Event-ID 重放、快照、128 缓冲、TTL、≤2 连接/任务 | PASS | 重放/伪造游标/2 连接/终态快照测试 |
|
||||
| 单活动任务、409 run.busy、后台执行不阻塞 SSE | PASS | Controller + HTTP 409/并发测试 |
|
||||
| 进程组取消(TERM→2s→KILL)、墙钟上限、有界输出 | PASS(模块) | `src/execution/process.rs`、`tests/integration/execution.rs` |
|
||||
| 显式预算参数 | PASS(模块) | `src/execution/controller.rs`、`--run-timeout` 1..=120 |
|
||||
| 会话 Cookie(HttpOnly/SameSite=Strict)+ X-View-CSRF + Origin/Host | PASS | `server/security.rs`、`tests/security/`、浏览器测试 |
|
||||
| loopback only、请求体≤64KiB、CSP、路径 containment | PASS | `server/security.rs`;security 套件(Cookie/CSP/Host/path/symlink) |
|
||||
| SSE 按会话隔离、跨站读取拒绝 | PASS | 跨会话 404/401、Sec-Fetch-Site 拒绝 |
|
||||
| 普通导出零执行、零联网、离线 file:// 可读 | 实现,待验收 | `scripts/test-export.sh` |
|
||||
| 显式单次结果导出:来源匹配终态、隐私预览、只读 ZIP | 实现,待验收 | `src/server/*`、`scripts/test-complete-reader.py` |
|
||||
| Live/Export 同一 HTML/CSS/JS 与渲染器 | 实现,待验收 | `tests/contract/no_coupling.rs`、`asset_integrity.rs` |
|
||||
| 打开/刷新/搜索/切换/导出零副作用 | 实现,待验收 | `scripts/test-no-exec.sh` |
|
||||
| CSRF/Origin/Cookie/Host/路径/symlink/XSS/跨会话 SSE | 实现,待验收 | `tests/security/`、`scripts/test-security.sh` |
|
||||
| 快照/错误无绝对主机路径;错误只用 relative_path | 实现,待验收 | `src/protocol/observation_v1.rs`、renderer |
|
||||
| Tool 安装/分发/卸载/篡改拒绝;CLI SHA 前后一致 | 实现,待验收 | `scripts/install-smoke.sh`、acceptance G03 |
|
||||
|
||||
## 5. §8 里程碑
|
||||
## 5. 门禁与证据
|
||||
|
||||
| PR | 状态 | 提交 |
|
||||
| 门禁 | 状态 | 证据 |
|
||||
|---|---|---|
|
||||
| PR-00 取证/基线 | **完成** | 待提交(本提交) |
|
||||
| PR-01 Tool/打包/scripts/CI/0.2.0 | **完成** | `scripts/package.sh`、`scripts/install-smoke.sh`、`scripts/verify-frozen-cli.sh`、`.github/workflows/ci.yml` |
|
||||
| PR-02 Reader/Analysis 结构与只读路由 | **完成** | `src/protocol/*`、`src/reader/*`、`src/config.rs`、`/api/documents`、`tests/{contract,integration}`;`docs/evidence/PR-02/` |
|
||||
| PR-03 执行层/请求/进程/控制器 | **完成** | `src/execution/*`、ADR-0008、`docs/evidence/PR-03/` |
|
||||
| PR-04 SSE/路由/会话/前端闭环 | **完成** | `docs/evidence/PR-04/`(含真实 Chromium + 真实冻结 CLI) |
|
||||
| PR-05 Trace 绑定/标注/浏览器回归 | **完成** | ADR-0010、`docs/evidence/PR-05/` |
|
||||
| PR-06 导出/发布/文档闭环 | **完成** | `examples/`、`scripts/{check-examples,test-no-exec}.sh`、`docs/ACCEPTANCE.md`、最终 evidence manifest |
|
||||
| G01 无旧契约残留 | `UNVERIFIED` | `scripts/check-no-legacy.sh`(待验收记录) |
|
||||
| G02 构建与静态检查 | `UNVERIFIED` | `scripts/acceptance.sh` |
|
||||
| G03 rc.4 独立安装 | `UNVERIFIED` | `scripts/install-smoke.sh` + acceptance |
|
||||
| G04 静态契约正向 | `UNVERIFIED` | `view verify` + `scripts/check-examples.sh` |
|
||||
| G05 运行契约正向 | `UNVERIFIED` | `scripts/acceptance-run.py` |
|
||||
| G06 流/快照等价 | `UNVERIFIED` | `scripts/check-observation.py` |
|
||||
| G07 stale 绑定 | `UNVERIFIED` | `scripts/check-observation.py binding` + View 回归 |
|
||||
| G08 负例 | `UNVERIFIED` | `scripts/check-observation.py fail-closed` + 测试套件 |
|
||||
| G09 安全基线 | `UNVERIFIED` | `scripts/test-security.sh`、`test-no-exec.sh`、浏览器 |
|
||||
| G10 导出 | `UNVERIFIED` | `scripts/test-export.sh` |
|
||||
| G11 证据与 CI | `UNVERIFIED` | 远端 CI 未在本环境运行 |
|
||||
| G12 文档一致 | `UNVERIFIED` | `scripts/check-docs.sh` |
|
||||
|
||||
## 6. §9 验收测试矩阵(E01–E16 / N01–N22)
|
||||
## 6. 明确非目标(N/A)
|
||||
|
||||
| 组 | 状态 | 说明 |
|
||||
|---|---|---|
|
||||
| E01 Tool 安装/卸载/分发 | PASS(0001 证据;PR-01 重跑) | `scripts/acceptance.sh` |
|
||||
| E02 打开 knowledge+exec 文件不运行 | PASS | `tests/integration/http_live.rs` |
|
||||
| E03 Source/Document 切换 | PASS | 浏览器证据 |
|
||||
| E04 中文/Emoji/表格/公式 span | PASS | `tests/integration/unicode_spans.rs`、golden |
|
||||
| E05 main 运行 run --json --trace-file | PASS | 真实冻结 CLI SSE 证据 `docs/evidence/PR-04/real-run.log` |
|
||||
| E06 H2 Exec n=5 call | PASS | call argv 测试 + 前端函数表单;真实 CLI 在 PR-06 验收 |
|
||||
| E07 文本/列表常量参数 | PASS | `--arg` 原样表达式 + 前端输入;CLI 最终校验 |
|
||||
| E08 无 main 不自动运行别的函数 | PASS | 400 `view.no_entry_function` + 无 run 调用测试 |
|
||||
| E09 Trace 事件映射不伪造变量 | PASS | Controller Trace 摘要 + JS 分组 chip;无变量值 |
|
||||
| E10 SSE text/event-stream 无 polling | PASS | 集成 + 浏览器请求记录 |
|
||||
| E11 Last-Event-ID 重连 | PASS | 重放/伪造游标 snapshot 测试 |
|
||||
| E12 长任务心跳/GET 不重启 | PASS | 心跳 + 2 连接 + GET 观察不启动任务 |
|
||||
| E13 取消终止进程树 | PASS | Controller/process 单测 + HTTP 取消唯一终态 + 浏览器取消路径 |
|
||||
| E14 静态导出零联网/相对链接 | PASS | `export_suite`(file:// Chromium)、`no_exec_suite` |
|
||||
| E15 刷新/重开不自动执行 | PASS | `tests/integration/http_live.rs` |
|
||||
| E16 运行后改源码 → stale 无高亮 | PASS | `source_edit_during_a_run...`(stale + 全部 anchor=null) |
|
||||
| N01–N22 | PASS | 全部映射到测试/验收命令,见 `docs/ACCEPTANCE.md` §3 |
|
||||
|
||||
## 7. §10 发布门禁
|
||||
|
||||
| 门禁 | 状态 |
|
||||
| 项 | 状态 |
|
||||
|---|---|
|
||||
| 1. PR-00~06 + P0 检验,无伪交付 | PASS | `docs/ACCEPTANCE.md` §1/§2 |
|
||||
| 2. Tool 独立安装;CLI 无 View 核心提交;SHA 不变 | PASS | acceptance `archive_install`/`core_sha`(0.2.0 重跑) |
|
||||
| 3. 打开/刷新/导出零副作用;执行仅来自显式 POST;跨站/CSRF 全绿 | PASS | `no_exec_suite`、`security_suite`、`tests/security/` |
|
||||
| 4. SSE 生命周期/心跳/序号/重连/有界重放;无轮询 | PASS | HTTP/SSE 集成 + 浏览器请求记录 |
|
||||
| 5. 真值来自 CLI/Analysis/Trace;无假变量/内存/证明 | PASS(设计) |
|
||||
| 6. Live/Export 同一 HTML/CSS/JS;无旧叠层 | PASS(0001 证据) |
|
||||
| 7. Linux x86_64 可重现包;README/帮助/限制一致 | PASS | `bundle`/`archive_install`;0.2.0 archive;文档一致性 |
|
||||
| 8. N01–N22 至少覆盖;失败不执行不泄漏不提升权限 | PASS | `docs/ACCEPTANCE.md` §3 |
|
||||
| Lint/Knowledge/Prove 引擎、调试器/断点/单步、Notebook/持久内核 | N/A(独立协议或明确删除) |
|
||||
| 变量/内存/句柄默认可视化 | N/A(协议支持显式选择;View 0.3.0 默认不请求) |
|
||||
| net/process/env/plugin/provider/kernel 授权 UI | N/A(拒绝并引导终端 CLI) |
|
||||
| Windows/macOS 发行 | N/A(不声明) |
|
||||
| 像素级人工视觉比对、完整 screen-reader 走查 | `UNVERIFIED`(人工项) |
|
||||
+94
-63
@@ -1,106 +1,137 @@
|
||||
# marqdo-view 现状(STATUS)
|
||||
|
||||
> 最后更新:2026-11-24。工单 #3 实施规范见 [完整阅读与静态结果导出](architecture/RFC-VIEW-0001-complete-reader.md)。
|
||||
|
||||
## 完整阅读与结果 ZIP(工单 #3)
|
||||
|
||||
| 能力 | 当前状态 |
|
||||
|---|---|
|
||||
| Markdown / GFM / 链接和锚点 | 同页与跨文档支持百分号编码、Unicode 与稳定重复标题编号 |
|
||||
| 本地媒体与离线数学 | PNG/JPEG/GIF/WebP、静态 SVG、MathML 与内嵌 Noto Sans Math 字体 |
|
||||
| 分析和运行 | Analysis v2/v3;RC.2 Events v1 → View SSE;Trace v2 独立校验 |
|
||||
| 函数旁交互 | 默认参数、显式确认、实时 stdout、可折叠终态与来源信息 |
|
||||
| 普通导出 | 正文、媒体、字体、文件哈希;零运行、零执行结果 |
|
||||
| 结果导出 | 当前会话内选定一次可信终态,展示隐私预览后下载只读 ZIP |
|
||||
| 可导出终态 | 成功;来源一致的失败或截断观察需另行确认。无真实 Core 终态的任务可以在 Live 显示状态 |
|
||||
| 证据 | [官方 RC.2 和 Chromium 验收](evidence/issue-3/README.md) |
|
||||
|
||||
以下里程碑记录 RFC-VIEW-0002 交付基线。
|
||||
> 最后更新:2026-11-25。当前目标:`marqdo-view 0.3.0`,只支持
|
||||
> `marqdo 3.0.0-rc.4` 的公开契约(adaptation #4,验收 #5,公共 Analysis 边界 #6)。
|
||||
> 机器证据只认绑定 CLI 源码 SHA 的 manifest;未生成的证据一律 `UNVERIFIED`。
|
||||
|
||||
## 版本与基线
|
||||
|
||||
| 项 | 值 |
|
||||
|---|---|
|
||||
| View 产品版本 | `0.2.0` |
|
||||
| 实施规范 | `docs/architecture/RFC-VIEW-0002.md`(2026-11-22) |
|
||||
| 目标 CLI 产品范围 | `>=3.0.0-beta.1,<4.0.0` |
|
||||
| 冻结 CLI 二进制 SHA-256 | `062cb56e226bee55c21d238e195920caa985e62bb3877ba7b07abcc04dc0fe3f` |
|
||||
| CLI 源码 SHA | `2c7c4f31e7a388d3fcfa717a77067e696ed13854`(tag `v3.0.0-beta.1`) |
|
||||
| 协议 | Tool v1 / Analysis v2 / Trace v2 / `marqdo.md.v1` |
|
||||
| 目标平台 | Linux x86_64 glibc(正式);其他平台不支持/未验证 |
|
||||
| View 产品版本 | `0.3.0` |
|
||||
| 产品范围 | `>=3.0.0-rc.3,<4.0.0`;验收固定 `3.0.0-rc.4` |
|
||||
| CLI Tool | revision 1:`requires {api_revision: 1, analysis: 3, observation: 1}`,无 `compatibility` |
|
||||
| 静态语义 | Analysis revision 3(`marqdo.analysis`,ADR-0069 公共边界) |
|
||||
| 运行事实 | Observation revision 1(`marqdo.observation`,单一事件序列) |
|
||||
| Markdown profile | `marqdo.md.v1` |
|
||||
| 冻结 CLI 版本 | `marqdo 3.0.0-rc.4` |
|
||||
| CLI 源码 SHA | `452e9a32bd9e40dba427d4180691c58bab74449e` |
|
||||
| CLI 归档 SHA-256 | `9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8` |
|
||||
| CLI 二进制 SHA-256 | `a7306962689c635445a59043971ea2eb09298e01feeee81f0ba07b1f3e10306e` |
|
||||
| 平台 | Linux x86_64 / glibc 2.39(唯一正式验证) |
|
||||
| 视觉基准 | `docs/design/reference-old-view-reader.png`(**2048×1133**) |
|
||||
| 验收状态 | `docs/ACCEPTANCE.md`;最新本地复验证据见 `docs/evidence/issue-2/manifest.json` |
|
||||
| 验收 manifest | `docs/evidence/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json`(**result: PASS,G01–G12 全部 PASS**) |
|
||||
|
||||
## RFC-VIEW-0002 里程碑(全部完成)
|
||||
## 0.3.0 适配交付(实现状态)
|
||||
|
||||
| 阶段 | 状态 | 证据 |
|
||||
| 交付 | 状态 | 位置 |
|
||||
|---|---|---|
|
||||
| PR-00 基线、旧 View 取证、冻结 CLI 合同 | **完成** | `docs/audits/legacy-view.md`、`docs/audits/protocol-contract-0002.md`、ADR-0007 |
|
||||
| PR-01 Tool v1 打包/安装/调度、0.2.0、scripts/、CI | **完成** | `scripts/package.sh`、`scripts/verify-frozen-cli.sh`、`.github/workflows/ci.yml`、`docs/evidence/PR-01/` |
|
||||
| PR-02 Reader/Analysis 目标目录与只读面 | **完成** | `src/protocol/*`、`src/reader/*`、`src/config.rs`、`/api/documents`、`tests/{contract,integration}`、`docs/evidence/PR-02/` |
|
||||
| PR-03 执行层:request/process/controller、pure + project grants | **完成** | `src/execution/*`、`--run-timeout`、ADR-0008、`docs/evidence/PR-03/` |
|
||||
| PR-04 SSE 任务生命周期、取消、7 路由、会话 Cookie/CSRF | **完成** | `src/server/{mod,routes,security,sse}.rs`、`assets/reader.js`、ADR-0009、`docs/evidence/PR-04/`(真实 CLI + Chromium) |
|
||||
| PR-05 Trace 绑定/原文标注/浏览器回归 | **完成** | Controller Trace 摘要/`source_id`/stale、ADR-0010、`docs/evidence/PR-05/` |
|
||||
| PR-06 静态导出/发布包/示例/文档闭环 | **完成** | `examples/*.mq.md`、`scripts/check-examples.sh`、`scripts/test-no-exec.sh`、`docs/ACCEPTANCE.md`、最终 evidence manifest |
|
||||
| CLI Tool revision 1 清单、无 `compatibility` | 实现 | `tool.json`、`scripts/package.sh` |
|
||||
| Analysis revision 3 单一静态源(source/document/anchors/heading_span/references) | 实现(待验收) | `src/protocol/analysis_v3.rs`、`src/reader/*` |
|
||||
| Observation revision 1 流/快照单一解码器 | 实现(待验收) | `src/protocol/observation_v1.rs`、`src/core_client.rs` |
|
||||
| 绑定校验(analysis_digest/root_id/module_id/UTF-8 半开 span) | 实现(待验收) | `src/execution/*` |
|
||||
| 引用状态渲染(`not_loaded` = 未核验) | 实现(待验收) | `src/reader/render.rs`、`assets/reader.js` |
|
||||
| 值默认不请求、不伪造 | 实现 | `src/execution/*`、`assets/reader.js` |
|
||||
| G01 无旧契约静态检查 | 通过 | `scripts/check-no-legacy.sh` |
|
||||
| G12 文档事实一致 | 通过 | `scripts/check-docs.sh` |
|
||||
| 验收 manifest G01–G12 + `unverified` | 已生成 `result: PASS` | `scripts/acceptance.sh` |
|
||||
| CI 钉 rc.4 + 独立 no-legacy job | 远端 Woodpecker pipeline #9 对 `a802f96` 成功 | `.github/workflows/ci.yml`、`.woodpecker.yml` |
|
||||
|
||||
## RFC-VIEW-0002 能力基线
|
||||
## 发布门禁 G01–G12(issue #5)
|
||||
|
||||
> 证据规则:`PASS/FAIL/UNVERIFIED` 只能由 `scripts/acceptance.sh` 生成并写入
|
||||
> `docs/evidence/<CLI-SOURCE-SHA>/manifest.json`。当前 manifest 对 View 源码提交
|
||||
> `a802f96b6ea19fb3047a2930f3ef0c3c36ba291f` 的 `result` 为 `PASS`(G11 引用
|
||||
> Woodpecker #9);`UNVERIFIED`、`PARTIAL`、`WARN` 一律不得写成 `PASS`。
|
||||
|
||||
| # | 门禁 | 当前证据状态 |
|
||||
|---|---|---|
|
||||
| G01 | 协议层无旧契约残留(`scripts/check-no-legacy.sh`,0 命中) | `PASS` |
|
||||
| G02 | fmt + clippy + test + release build 全 exit 0 | `PASS` |
|
||||
| G03 | rc.4 归档独立安装、`view --help`、CLI SHA 前后不变、篡改拒绝 | `PASS` |
|
||||
| G04 | 静态契约正向:`check --emit` + `view verify` | `PASS` |
|
||||
| G05 | 运行契约正向:显式 run/call,终态与 CLI 一致 | `PASS` |
|
||||
| G06 | 流/快照等价(同一次执行两个目的地事件序列一致) | `PASS` |
|
||||
| G07 | stale 绑定语义(digest/root/span;失败不显示成功) | `PASS` |
|
||||
| G08 | N01–N20 负例全部 fail-closed | `PASS` |
|
||||
| G09 | 安全基线不回退(security + no_exec + browser) | `PASS` |
|
||||
| G10 | 导出零执行且 Live/Export 同渲染器 | `PASS` |
|
||||
| G11 | manifest 与 CI 同 SHA;CI 红不发布 | `PASS` |
|
||||
| G12 | 文档事实一致(`scripts/check-docs.sh`) | `PASS` |
|
||||
|
||||
任一 P0 门禁 `FAIL` 或 `UNVERIFIED` → 不发布 0.3.0。
|
||||
|
||||
## 能力基线
|
||||
|
||||
| 能力 | 状态 |
|
||||
|---|---|
|
||||
| 原始 Markdown/GFM 阅读、源码态、搜索/设置/打印/深色主题 | 已实现(单一 `assets/reader.css` + `assets/reader.js`) |
|
||||
| Analysis v2 严格校验 + 函数/Unit/签名/诊断/导入/引用/资源投影 | 已实现(无效 span/摘要降级,未知 major 拒绝) |
|
||||
| 单一 Read Model/HTML 组件/CSS/JS;Live=Export | 已实现(门禁测试) |
|
||||
| 固定 7 路由 Live 服务;打开/刷新/搜索/切换/导出零执行 | 已实现并测试 |
|
||||
| 显式单任务执行(run main / call function),纯 + 受控 project fs grants | 已实现(两阶段确认、命令预览、二次确认) |
|
||||
| SSE 状态/终态、取消、心跳、Last-Event-ID 重放、无轮询 | 已实现(单任务、128 环形缓冲、2 连接上限) |
|
||||
| 运行结果(Wire Value/stdout/stderr/错误/诊断)安全文本展示 | 已实现(无 innerHTML 服务端数据) |
|
||||
| Trace v2 调用/分支/循环/副作用 + 原文锚点 + stale 降级 | 已实现(分组 chip、来源标注、截断/无效显式) |
|
||||
| Tool v1 独立安装/分发、冻结 CLI SHA 前后一致 | 已实现(0.2.0 包,篡改拒绝) |
|
||||
| 静态离线导出(无执行、无联网、manifest/哈希、不可变发布) | 已实现并重新验收 |
|
||||
| 固定 examples(welcome/branch-loop/function-params/knowledge-only/unsafe-side-effect) | 已实现,冻结 CLI check/call/run 实测 |
|
||||
| 逐语句变量值 / 参数实际值 / 内存快照 | **UNSUPPORTED**(Trace v2 不提供,绝不伪造) |
|
||||
| 原始 Markdown/GFM 阅读、源码态、搜索/设置/打印/深色主题 | 实现(单一 `assets/reader.css` + `assets/reader.js`) |
|
||||
| Analysis revision 3 严格校验 + 函数/Unit/签名/诊断/导入/引用/资源投影 | 实现(无效 span/摘要降级,旧同 revision 拒绝) |
|
||||
| heading_span 标题 UI / 完整 span section 高亮与归属 | 实现 |
|
||||
| 引用状态七态渲染;`not_loaded` 未核验、`ambiguous` 列出候选 | 实现 |
|
||||
| 单一 Read Model/HTML 组件/CSS/JS;Live=Export | 实现(门禁测试) |
|
||||
| 固定 Live 路由;打开/刷新/搜索/切换/导出零执行 | 实现并测试 |
|
||||
| 显式单任务执行(run main / call function),纯 + 受控 project fs grants | 实现(两阶段确认、命令预览、二次确认) |
|
||||
| Observation v1 经 View SSE 转发/摘要;状态/终态、取消、心跳、Last-Event-ID 重放、无轮询 | 实现(单任务、有界摘要、2 连接上限) |
|
||||
| 运行结果(Wire Value/stdout/stderr/错误/诊断)安全文本展示 | 实现(无 innerHTML 服务端数据) |
|
||||
| 引用/调用/分支/循环/副作用标注 + stale 降级 | 实现(分组 chip、来源标注、截断/无效显式) |
|
||||
| Tool revision 1 独立安装/分发、冻结 CLI SHA 前后一致 | 实现(0.3.0 包,篡改拒绝) |
|
||||
| 静态离线导出(无执行、无联网、manifest/哈希、不可变发布) | 实现 |
|
||||
| 固定 examples(welcome/branch-loop/function-params/knowledge-only/unsafe-side-effect) | 实现,rc.4 check/call/run 实测脚本 |
|
||||
| 逐语句变量值 / 参数实际值 / 内存快照 | **默认不请求、不展示**(协议支持显式选择;View 0.3.0 不请求,绝不伪造) |
|
||||
| 知识“已证明” / Prove / Lint | **UNSUPPORTED**(等待独立版本化报告协议) |
|
||||
| 调试器/断点/单步/调用栈、Notebook/持久内核、Session/journal | **不实现**(RFC 明确删除) |
|
||||
| AI/Agent/Token 流、插件市场、DB/多租户 | **不实现**(非目标) |
|
||||
| 调试器/断点/单步/调用栈、Notebook/持久内核、Session/journal | **不实现**(明确非目标) |
|
||||
| `strict`、net/process/env/plugin/provider/kernel 授权 UI | **不提供**(拒绝并引导终端 CLI) |
|
||||
| Windows/macOS 发行 | **不支持/未验证** |
|
||||
|
||||
## 明确 UNSUPPORTED / 非目标(不得伪造)
|
||||
|
||||
- 变量/内存/逐语句值:Trace v2 不提供;UI 只有一个明确的“未提供的能力”说明。
|
||||
- 变量/内存/逐语句值:Observation v1 默认不发布值;View 不请求任何
|
||||
`--observe-*` 选择,UI 只有一个明确的“未提供/未请求”说明。
|
||||
- 数学/领域正确性与“已证明”:Analysis 成功 ≠ 证明;未来 Prove 独立提供。
|
||||
- Notebook/Run All/内核重启、断点/单步/时间旅行、第二套 Markdown AST/解释器。
|
||||
- 网络/进程/环境/插件/Provider/Foreign 授权 UI;高级执行由用户在终端运行 CLI。
|
||||
- `strict` 下的 Live/文件目的地:CLI 在启动前拒绝;View 不伪装、不回退。
|
||||
|
||||
## 证据入口
|
||||
|
||||
| 内容 | 路径 |
|
||||
|---|---|
|
||||
| 一键验收 + 最终 manifest | `scripts/acceptance.sh`;`docs/evidence/2c7c4f31…/manifest.json` |
|
||||
| 验收门禁报告 | `docs/ACCEPTANCE.md` |
|
||||
| 0002 合规矩阵 | `docs/CONFORMANCE.md` |
|
||||
| 冻结 CLI 合同 | `docs/audits/protocol-contract-0002.md` |
|
||||
| 旧 View 取证 | `docs/audits/legacy-view.md`(静态;运行时 `LEGACY_RUNTIME_UNVERIFIED`) |
|
||||
| 分 PR 证据 | `docs/evidence/PR-01..PR-06/` |
|
||||
| 示例 fixture 实测 | `scripts/check-examples.sh`(输出见 `docs/evidence/PR-06/`) |
|
||||
| 一键验收 + manifest(G01–G12) | `scripts/acceptance.sh`;`docs/evidence/452e9a32…/manifest.json`(**待生成**) |
|
||||
| 证据目录说明与 manifest schema | `docs/evidence/README.md` |
|
||||
| 验收标准 | `docs/ACCEPTANCE.md` |
|
||||
| 合规矩阵 | `docs/CONFORMANCE.md` |
|
||||
| 冻结 CLI 合同审计 | `docs/audits/protocol-contract-0002.md` |
|
||||
| 当前分层与契约 | `docs/architecture/observation-v1-and-analysis-v3.md` |
|
||||
| 契约替换决策 | `docs/decisions/0012-rc4-current-contracts.md` |
|
||||
| 示例 fixture 实测 | `scripts/check-examples.sh` |
|
||||
| 观测契约探针 | `scripts/check-observation.py` |
|
||||
| 零执行哨兵 | `scripts/test-no-exec.sh` |
|
||||
| 浏览器截图/日志 | `docs/evidence/PR-04/`、`docs/evidence/PR-05/` |
|
||||
| 决策记录 | `docs/decisions/0001..0010` |
|
||||
| 旧 View 取证 | `docs/audits/legacy-view.md`(静态;运行时 `LEGACY_RUNTIME_UNVERIFIED`) |
|
||||
| 历史 0.2.0 证据 | `docs/evidence/2c7c4f31…/`、`docs/evidence/issue-2/`、`docs/evidence/issue-3/`、`docs/evidence/PR-01..PR-06/` |
|
||||
|
||||
## 已知限制与偏差(诚实状态)
|
||||
|
||||
- 首版运行仅 `pure` 与受控 `project` fs read/write;`project` 不是 OS 沙箱,
|
||||
不自动提升 `marqdo.yaml` capability 请求。
|
||||
- SSE 只推送 View 生命周期与终态数据,不承诺逐字 stdout/Token 流(RFC §6.1)。
|
||||
- 观测侧注采用内联分组 chip,而非 SVG 曲线;按 RFC §4.4 允许降级(ADR-0010)。
|
||||
- 像素级人工视觉比对与完整 screen-reader 走查仍为 `UNVERIFIED`;自动化证据充分。
|
||||
- 本地验收与远端 CI 使用同一入口 `scripts/acceptance.sh`;远端状态以 PR 检查为准。
|
||||
- SSE 只推送 View 生命周期与 Observation 摘要,不承诺逐字 stdout/Token 流。
|
||||
- 观测侧注采用内联分组 chip,而非 SVG 曲线。
|
||||
- 像素级人工视觉比对与完整 screen-reader 走查仍为 `UNVERIFIED`。
|
||||
- 远端 CI 配置已提供但本环境未执行;未运行门禁保持 `UNVERIFIED`。
|
||||
- 平台:Linux x86_64 glibc 正式验证;其他平台不声明支持。
|
||||
|
||||
## 历史
|
||||
|
||||
`0.2.0`(2026-11-22)是旧预发布契约时代的完整阅读/执行/导出基线,相关证据
|
||||
仅作历史参考,不能替代 0.3.0 的 rc.4 门禁:`docs/evidence/2c7c4f31…/`、
|
||||
`docs/evidence/issue-2/`、`docs/evidence/issue-3/`、`docs/evidence/PR-01..PR-06/`。
|
||||
旧实现规范与决策保留在 `docs/architecture/RFC-VIEW-0001*.md`、
|
||||
`docs/architecture/RFC-VIEW-0002.md`、`docs/decisions/0001..0011`(历史记录)。
|
||||
|
||||
## 复现文档
|
||||
|
||||
- 使用/安装:`README.md`
|
||||
- 规范:`docs/architecture/RFC-VIEW-0002.md`(当前)、`RFC-VIEW-0001.md`(历史)
|
||||
- 当前契约与分层:`docs/architecture/observation-v1-and-analysis-v3.md`
|
||||
- 兼容性:`COMPATIBILITY.md`
|
||||
- 变更:`CHANGELOG.md`
|
||||
- 决策:`docs/decisions/`
|
||||
@@ -1,5 +1,12 @@
|
||||
# RFC-VIEW-0001(定稿建议):完整 Markdown 阅读、统一函数调用与显式结果静态导出
|
||||
|
||||
|
||||
> **契约提示**:本文描述完整阅读与结果导出的产品/交互设计,设计仍参考有效;
|
||||
> 但其中任何协议字段、命令参数或事件名称以
|
||||
> [`observation-v1-and-analysis-v3.md`](observation-v1-and-analysis-v3.md) 与
|
||||
> [ADR-0012](../decisions/0012-rc4-current-contracts.md) 的当前契约为准。
|
||||
> 0.2.0 时代的协议细节是历史记录,不是当前能力。
|
||||
|
||||
> **状态:Proposed / 开发规范,不表示已经实现或通过验收。**
|
||||
>
|
||||
> **目标仓库:** [`cflmy/marqdo-view`](https://github.com/cflmy/marqdo-view),本次审阅基线 `master@dcb9daeaf4e5eefd8c35aa0c843dd8a0eaf7fef5`(`0.2.0`)。
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# RFC-VIEW-0001:Marqdo View 3.0 独立阅读器架构与开发验收规范
|
||||
|
||||
|
||||
> **历史设计(0.1.0 时代)**:本文中的协议名称与命令面只记录当时设计,不是 0.3.0
|
||||
> 的当前契约。当前实现只使用 Analysis revision 3(ADR-0069)与 Observation
|
||||
> revision 1;见 [`observation-v1-and-analysis-v3.md`](observation-v1-and-analysis-v3.md)
|
||||
> 与 [ADR-0012](../decisions/0012-rc4-current-contracts.md)。
|
||||
|
||||
> 状态:**Proposed / 可实施设计规范,不代表功能已经实现**
|
||||
> 目标仓库:`marqdo-view`(独立 Git 仓库;首次开发时新建)
|
||||
> 文档版本:`1.0-draft`
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# RFC-VIEW-0002:Marqdo View 3.0 交互式执行闭环与产品精简实施规范
|
||||
|
||||
|
||||
> **历史基线(0.2.0)**:本 RFC 是 0.2.0 的实现基线,其中的协议名称、命令行与
|
||||
> 门禁描述已不是 0.3.0 的当前契约。当前契约见
|
||||
> [`observation-v1-and-analysis-v3.md`](observation-v1-and-analysis-v3.md)、
|
||||
> [ADR-0012](../decisions/0012-rc4-current-contracts.md) 与
|
||||
> [`docs/ACCEPTANCE.md`](../ACCEPTANCE.md)。
|
||||
|
||||
> **状态**:Proposed / 具备直接实施所需的设计、约束、测试和验收定义;并非完成声明。
|
||||
> **目标仓库**:独立 `marqdo-view`,建议路径 `docs/architecture/RFC-VIEW-0002.md`。
|
||||
> **发布日期/审查基线**:2026-11-22。
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
# Observation v1 与 Analysis revision 3:当前分层
|
||||
|
||||
> 适用范围:`marqdo-view 0.3.0`,冻结 `marqdo 3.0.0-rc.4`。
|
||||
> 本文是当前实现的架构基线;0.2.0 时期的 RFC 只保留为历史记录
|
||||
> (`docs/architecture/RFC-VIEW-0001*.md`、`docs/architecture/RFC-VIEW-0002.md`)。
|
||||
|
||||
## 1. 唯一数据源
|
||||
|
||||
| 事实 | 唯一来源 | 只读产物 |
|
||||
|---|---|---|
|
||||
| 静态语义(source/document/units/anchors/functions/calls/resources/diagnostics/references) | 一次 `marqdo check ENTRY --emit PATH` | `marqdo.analysis` revision 3 精确 UTF-8 字节 + `sha256:` digest |
|
||||
| 运行事实(生命周期/调用/分支/循环/返回/效果/输出字节/终态) | 一次 `marqdo run|call --output jsonl [--observation-file PATH]` | `marqdo.observation` revision 1 事件序列 / 原子快照 |
|
||||
| 源绑定 | Observation `run.started.payload.source` | `analysis_digest` + `root_id`,对照同一入口、同一静态选项的 Analysis 精确字节 |
|
||||
|
||||
`inspect --ast`/`inspect --ir` 只用于人工调试,不是渲染/执行语义的机器来源。
|
||||
不允许第二解释器、第二 Markdown AST、私有 IR 反推或包缓存物理路径依赖。
|
||||
|
||||
## 2. 分层与依赖方向
|
||||
|
||||
```text
|
||||
CLI 适配层(src/core_client.rs, src/execution/process.rs)
|
||||
唯一知道 argv / 环境变量 / 退出码语义
|
||||
├─ check --emit
|
||||
└─ run|call --output jsonl --observation-file
|
||||
│
|
||||
protocol 解码 + 结构校验(src/protocol/{analysis_v3,observation_v1,tool_v1,value_wire_v1}.rs)
|
||||
schema/revision/必需字段/closed record/seq/终态/预算/绑定
|
||||
│
|
||||
规范化领域模型(SemanticProjection、ObservationRun、RunBinding)
|
||||
无 CLI 细节、无版本分支、无 schema_version 判断
|
||||
│
|
||||
消费层
|
||||
├─ reader/{source,markdown,model,assemble,render}
|
||||
├─ execution/{request,controller,events}
|
||||
├─ server/{routes,security,sse}
|
||||
└─ export(同一 ReaderRenderer)
|
||||
```
|
||||
|
||||
强制不变量:
|
||||
|
||||
1. 协议模块之外没有 `schema_version` 判断;协议模块内只有当前 revision 一个分支。
|
||||
2. 依赖单向:`core_client → protocol → model`;`reader/execution/server → model`。
|
||||
模型不反向依赖 CLI/协议;reader 不依赖 core_client 细节。
|
||||
3. JSONL 流与原子快照共用同一解码器与同一领域类型;生产代码只消费一种来源
|
||||
(Live 用流),两者一致性只在测试中断言,不做“双读合并”。
|
||||
4. 每个拒绝都有稳定 `view.*` 错误码与可执行提示;不使用 `unwrap`/`expect`
|
||||
处理协议数据。
|
||||
5. 事件顺序、`run_id` 一致性、连续 `seq`、唯一终态、`truncated` 语义由解码器集中校验;
|
||||
渲染/导出/SSE 层不“修正”协议数据。
|
||||
6. 传输中断(EOF 无终态)显示“未完成/无结论”,不得渲染为成功。
|
||||
|
||||
## 3. Analysis revision 3 使用方式
|
||||
|
||||
- **一次入口一次 emit**:每个文档的静态事实都来自同一 artifact;不跨进程拼接
|
||||
`inspect --ast` 与 Analysis,避免跨快照错配。
|
||||
- `modules[].source` 是精确 UTF-8 源文本,所有 span 是 half-open UTF-8 字节区间;
|
||||
`source_digest` 对应其解码字节。需要磁盘实时性时重新 `check` 并比较 digest,
|
||||
不从 `relative_path` 重读文件重建 span。
|
||||
- 标题 UI/目录/锚点使用 `heading_span`;内容高亮/section 切片/标注归属使用完整
|
||||
`span`(到下一个同级或更高层标题或 EOF)。
|
||||
- `units[].path` 是结构化数组;`parent_id`/`mode`/`mode_origin`/`mode_source_unit_id`
|
||||
直接使用;不 split display id。`anchors` 是导航名称,不是身份。
|
||||
- `calls[]` 的 `state/target_kind/target_owner/reason` 用于执行标记;
|
||||
`unresolved(dynamic|unbound)` 是合法静态结果,不显示为编译错误。
|
||||
- `resources`:`content_digest` 对应 AST literal;公式 `display` 为 bool,代码为 `null`。
|
||||
- `diagnostics[]` 是唯一文件内诊断来源;不再运行第二套检查生成第二套诊断。
|
||||
- 旧同 revision(缺 `source/document/anchors/entry_module_id` 等)artifact 显式拒绝:
|
||||
`view.protocol_incompatible`,提示重新生成或升级核心。
|
||||
|
||||
## 4. 引用状态
|
||||
|
||||
| state | 渲染语义 |
|
||||
|---|---|
|
||||
| `resolved` | 可跳转;`target_kind` 为 `module` 或 `file` |
|
||||
| `not_loaded` | **未核验**:当前 catalog 未加载该本地目标;不是断链、不是 missing |
|
||||
| `missing` | 目标模块存在但无对应 fragment,或显式核验证明文件不存在 → 可行动错误 |
|
||||
| `ambiguous` | canonical-name 回退命中两个及以上候选;列出 `candidates`,绝不静默选第一个 |
|
||||
| `external` | 外链;不联网、不是错误 |
|
||||
| `outside_scope` | 本地目标逃出允许根/绝对路径/UNC → 不读目标;不输出物理路径 |
|
||||
| `invalid` | URI/percent 编码非法 → 不猜测修复 |
|
||||
|
||||
`source_unit` 用于定位引用所属 section,`span` 用于高亮原文。普通 Analysis
|
||||
不打开链接目标;`check --refs` 的额外诊断改变 artifact 字节,不能替代普通 emit
|
||||
作为运行绑定。
|
||||
|
||||
## 5. Observation revision 1 使用方式
|
||||
|
||||
- 事件种类:`stream.opened`、`run.started`、`call.enter/exit`、`branch.eval`、
|
||||
`loop.iteration`、`control.break/continue`、`return`、`effect`、
|
||||
`parameter.observed`、`variable.assigned`、`observation.truncated`、
|
||||
`stdout.chunk`、`stderr.chunk`、`run.completed/failed/rejected`。
|
||||
- 唯一 `run_id`、零基连续 `seq`、恰好一个终态且最后。View SSE 只转发/摘要,
|
||||
保留自身信封但不重编号、不重排、不合成协议事件。
|
||||
- 绑定校验:`analysis_digest` 必须等于普通 `check --emit` 精确字节的
|
||||
`sha256:` 表达;`root_id` 等于 `project.root_id`;事件 `module_id` 属于
|
||||
`modules[]`;span 为该模块 source 的合法 UTF-8 半开区间;模块 `source_digest`
|
||||
与 artifact 的 `source` 一致。任一不符 → 不渲染运行结果、不错误高亮。
|
||||
- `observation.truncated`/`capture.truncated` → 显示 **TRUNCATED**:预算耗尽,
|
||||
不代表程序失败,也不得声明完整覆盖。
|
||||
- 字节输出:`stdout.chunk`/`stderr.chunk` 为 base64 + 解码字节数;渲染为转义文本,
|
||||
绝不当 HTML。
|
||||
- 错误位置只用 `module_id`/`relative_path`/`line`/`column`/`span`;快照可对外分享,
|
||||
不出现绝对主机路径。
|
||||
- EOF 无终态 → **INCOMPLETE/未完成**:不显示成功、不生成“成功”导出。
|
||||
- 值:默认 `capture.level=structural`,不发布 `variable/parameter` 值;协议支持
|
||||
显式 `--observe-variable`/`--observe-parameter`(Text 另需 `--observe-text-values`),
|
||||
但 0.3.0 的 View **不请求任何值**。内存/资源/句柄永不发布。
|
||||
- `strict`:CLI 只支持 text/JSON stdout;Live/文件目的地 exit 2 +
|
||||
`strict.unsupported_grant`。View 映射为明确错误,不回退 `project`、不重试旧参数。
|
||||
|
||||
## 6. 失败与降级矩阵
|
||||
|
||||
| 条件 | 错误/状态 | 用户可见行为 |
|
||||
|---|---|---|
|
||||
| 常量/加载错误 | CLI exit 1,无成功 artifact | 显示诊断,语义撤回;不显示“成功” |
|
||||
| 参数/入口/发布错误 | CLI exit 2 | `view.core_option_rejected` 或等价;不去参数重试 |
|
||||
| 未知 schema/revision/kind | `view.protocol_incompatible` | 显式拒绝,提示升级/重装/重新生成 |
|
||||
| 旧同 revision artifact | 协议错误 | 提示重新 `check --emit`;无 fallback 解码 |
|
||||
| digest/root/module/span 不符 | `view.observation_stale` 或等价 | 不渲染运行结果、不错误高亮、不导出成功 |
|
||||
| 预算截断 | `TRUNCATED` | 显示截断原因/限额,不声明完整 |
|
||||
| EOF 无终态 | `INCOMPLETE/未完成` | 不显示成功、不生成成功导出 |
|
||||
| 值未选择却出现 values | 协议违约 | 拒绝该 artifact/事件,不显示值 |
|
||||
| 旧 Tool 清单/安装记录 | 安装/分发失败 | 提示 remove + 重装;无迁移器 |
|
||||
|
||||
## 7. 文件映射
|
||||
|
||||
| 层 | 代码 |
|
||||
|---|---|
|
||||
| CLI 适配 | `src/core_client.rs`、`src/execution/process.rs` |
|
||||
| 解码/校验 | `src/protocol/analysis_v3.rs`、`src/protocol/observation_v1.rs`、`src/protocol/tool_v1.rs`、`src/protocol/value_wire_v1.rs` |
|
||||
| 领域/绑定 | `src/execution/{request,controller,events}.rs` |
|
||||
| 阅读/渲染 | `src/reader/*`、`assets/reader.css`、`assets/reader.js` |
|
||||
| 服务/SSE | `src/server/{mod,routes,security,sse}.rs` |
|
||||
| 导出 | `src/export*.rs`(同一 ReaderRenderer) |
|
||||
| 门禁 | `tests/contract/no_coupling.rs`、`scripts/check-no-legacy.sh`、`scripts/check-docs.sh`、`scripts/check-observation.py` |
|
||||
|
||||
## 8. 验证入口
|
||||
|
||||
```bash
|
||||
scripts/check-no-legacy.sh # G01:无旧契约残留
|
||||
scripts/check-docs.sh # G12:当前文档事实一致
|
||||
MARQDO_BIN=... scripts/check-examples.sh # 示例真实 check/call/run
|
||||
MARQDO_BIN=... python3 scripts/check-observation.py stream-snapshot
|
||||
MARQDO_BIN=... python3 scripts/check-observation.py binding
|
||||
MARQDO_BIN=... python3 scripts/check-observation.py fail-closed
|
||||
MARQDO_BIN=... scripts/acceptance.sh # G01–G12 + manifest
|
||||
```
|
||||
|
||||
任何未运行、无法判定的门禁记录为 `UNVERIFIED`;不得写成 `PASS`。
|
||||
@@ -1,5 +1,9 @@
|
||||
# 旧 View 渲染路径审计(PR-00)
|
||||
|
||||
|
||||
> **历史取证**:本文记录旧渲染路径的静态审计,仅作迁移历史;当前实现与契约见
|
||||
> [`docs/STATUS.md`](../STATUS.md)。
|
||||
|
||||
> 状态:**静态审计完成,运行时验证未执行(`LEGACY_RUNTIME_UNVERIFIED`)**
|
||||
> 审计对象:`cflmy/marqdo` `main@1c55baabd570e18b9da8f9057cef2f848e176690`(下称“旧仓库”)
|
||||
> 审计方式:只读源码检查(`git status` 干净;**没有**编译、没有写入、没有移动旧仓库任何文件)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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`。本文把规范条款映射到实现与测试,
|
||||
> 便于审阅者不依赖对话历史复核。
|
||||
|
||||
@@ -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`)。
|
||||
@@ -0,0 +1,68 @@
|
||||
# ADR-0012 — rc.4 当前契约取代 rc.3 基线(0.3.0)
|
||||
|
||||
- 状态:Accepted(2026-11-25)
|
||||
- 范围:`marqdo-view 0.3.0` 的公开协议基线、验收证据与文档
|
||||
- 取代:issue #5 中以 rc.3 为固定 SHA 的验收基线;不取代 issue #5 的门禁编号
|
||||
(G01–G12)与 fail-closed 原则
|
||||
|
||||
## 背景
|
||||
|
||||
`marqdo-view 0.3.0` 的一次性适配最初按 `marqdo 3.0.0-rc.3` 定义(adaptation
|
||||
issue #4,验收 issue #5)。随后 `marqdo-cli` 的公共静态分析边界工作
|
||||
(`marqdo-cli` ADR-0069,追踪 issue #10)在 `v3.0.0-rc.4` 原地替换了
|
||||
`marqdo.analysis` revision 3 的字段集合,仍保持 revision 号为 3:
|
||||
|
||||
- `check --emit` 现在直接携带精确 `source`、Markdown `document`、完整标题作用域
|
||||
(`heading_span` + 完整 section `span`)、`anchors`、`entry_module_id`、
|
||||
`manifest_digest`、`extensions` 与状态化 `references`;
|
||||
- `inspect --ast` 不再是渲染语义的机器来源,只是人工调试命令;
|
||||
- 旧 revision-3 字段集合(缺少上述字段)不再被当前 schema/consumer 接受;
|
||||
- Observation revision 1 仍绑定**普通** `check --emit` 的精确字节摘要;
|
||||
`--refs` 检查改变字节,不能替代运行绑定。
|
||||
|
||||
因此 issue #5 的 rc.3 SHA 基线不能继续作为 0.3.0 的验收身份。若继续钉 rc.3,
|
||||
会出现“门禁全绿但不是发布契约”的错误证据。
|
||||
|
||||
## 决策
|
||||
|
||||
1. 0.3.0 的唯一契约基线升级为 `marqdo 3.0.0-rc.4`:
|
||||
- CLI 源码 `452e9a32bd9e40dba427d4180691c58bab74449e`
|
||||
- 归档 `marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu.tar.gz`
|
||||
SHA-256 `9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8`
|
||||
- 归档内二进制 SHA-256
|
||||
`a7306962689c635445a59043971ea2eb09298e01feeee81f0ba07b1f3e10306e`
|
||||
- 平台 `linux-x86_64-glibc2.39`;产品范围 `>=3.0.0-rc.3,<4.0.0`
|
||||
2. 验收门禁编号、fail-closed 原则与 manifest schema
|
||||
(`marqdo.view.acceptance` revision 1)沿用 issue #5;只把身份字段与
|
||||
证据路径改为绑定 rc.4 的源码/归档/二进制 SHA。
|
||||
3. 静态语义只消费一次 `check --emit`;不运行 `inspect --ast` 作为机器来源。
|
||||
4. 旧 revision-3 制品(缺少 rc.4 必需字段)显式拒绝并提示重新生成;不保留
|
||||
同 revision 的兼容解码、迁移器或双态类型。
|
||||
5. 旧 rc.3/0.2.0 证据只作历史记录;不得与 rc.4 证据混用或替代。
|
||||
|
||||
## 影响
|
||||
|
||||
- `scripts/frozen-beta.sh` 钉 rc.4;`scripts/acceptance.sh` 从该脚本读取
|
||||
version/source/archive/binary SHA,生成 issue #5 §0 schema 的 manifest。
|
||||
- `scripts/check-no-legacy.sh`(G01)继续阻止树内出现旧契约、旧 argv、旧 Tool
|
||||
协商或双态分支。
|
||||
- `docs/audits/protocol-contract-0002.md` 的探测基线改为 rc.4,并在无稳定样本的
|
||||
项上显式标注 `UNVERIFIED`。
|
||||
- `docs/STATUS.md`/`docs/ACCEPTANCE.md` 在 rc.4 manifest 生成前不声明 PASS;
|
||||
`UNVERIFIED` 不得写成 PASS。
|
||||
- issue #5 的 G01–G12 定义仍然有效;其中“冻结 CLI 源码/归档 SHA”字段按本 ADR
|
||||
的 rc.4 值填写。
|
||||
|
||||
## 验证
|
||||
|
||||
复现与机器证据见 `docs/ACCEPTANCE.md` 和
|
||||
`docs/evidence/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json`(待生成):
|
||||
|
||||
```bash
|
||||
scripts/frozen-beta.sh verify /abs/unpacked/marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu/marqdo
|
||||
scripts/check-no-legacy.sh
|
||||
scripts/check-docs.sh
|
||||
MARQDO_BIN=... scripts/acceptance.sh
|
||||
```
|
||||
|
||||
未运行门禁保持 `UNVERIFIED`;本 ADR 不声称任何尚未执行的验收结果。
|
||||
@@ -1,5 +1,9 @@
|
||||
# 完整阅读与结果导出设计
|
||||
|
||||
|
||||
> 契约提示:当前实现以 Analysis revision 3 与 Observation revision 1 为准,
|
||||
> 见 [`docs/architecture/observation-v1-and-analysis-v3.md`](../architecture/observation-v1-and-analysis-v3.md)。
|
||||
|
||||
[高保真设计图](complete-reader.png)由内置 ImageGen 生成,参考旧版 View 截图。实现沿用旧版居中品牌、暖纸色、衬线正文、金色函数标记和橄榄色结果边框。示意图右侧是独立的导出确认状态,窄屏使用单列。
|
||||
|
||||
提示词见下方。
|
||||
|
||||
+41
-23
@@ -1,17 +1,19 @@
|
||||
# 运行状态矩阵(PR-00 设计基准)
|
||||
# 运行状态矩阵(0.3.0 设计基准)
|
||||
|
||||
> 状态:**设计基准**。实现真源:`src/presentation.rs` 的 `RunDisplayState` 与 `assets/reader.css` 的 `[data-run-state]`。
|
||||
> 来源:RFC-VIEW-0001 §4.4、§12.2–§12.3。
|
||||
> 状态:**设计基准**。实现真源:`src/execution/events.rs` 的 `RunDisplayState`、
|
||||
> `src/protocol/observation_v1.rs` 的校验结果与 `assets/reader.css` 的
|
||||
> `[data-run-state]`。当前契约:Analysis revision 3 + Observation revision 1。
|
||||
> 旧 RFC 仅供历史参考,不再是当前契约来源。
|
||||
|
||||
## 1. 静态来源状态(文档头部 `source_status`)
|
||||
|
||||
| 值 | 触发条件 | 文档正文 | 语义标注 | 运行按钮 | 文案(中文) |
|
||||
|---|---|---|---|---|---|
|
||||
| `CORE_UNAVAILABLE` | 无 `MARQDO_BIN`/核心不可执行 | 完整可读 | 无(“语言语义未验证”) | 禁用 + 说明 | 找不到冻结核心,语义未验证 |
|
||||
| `STATIC_OK` | `check` 退出 0 且 Analysis v2 校验通过 | 完整可读 | 有效 | 可用(需确认) | 静态检查已通过 · 未运行 |
|
||||
| `STATIC_OK` | `check --emit` 退出 0 且 Analysis revision 3 校验通过 | 完整可读 | 有效 | 可用(需确认) | 静态检查已通过 · 未运行 |
|
||||
| `CORE_ERROR` | `check` 退出非 0,但 Markdown 可读 | 完整可读 | 全部撤销,显示 Core diagnostics | 禁用 | Core 检查失败,语义标注不可用 |
|
||||
| `STALE` | 源码变化或 Analysis digest 不匹配 | 完整可读 | 不绑定旧 Analysis | 可用(重新检查) | 分析已过期,请刷新 |
|
||||
| `PROTOCOL_INCOMPATIBLE` | 未知 schema major / 产品版本不兼容 | 完整可读 | 无 | 禁用 | 核心协议不兼容(analysis vN) |
|
||||
| `PROTOCOL_INCOMPATIBLE` | 未知 schema/revision / 产品版本不兼容 | 完整可读 | 无 | 禁用 | 核心协议不兼容(需 rc.4) |
|
||||
| `SOURCE_MISMATCH` | Analysis `source_digest` ≠ 当前字节 | 完整可读 | 不展示 | 禁用 | 源码与 Analysis 不一致 |
|
||||
|
||||
## 2. 运行状态(`RunDisplayState`)
|
||||
@@ -20,35 +22,51 @@
|
||||
|---|---|---|---|
|
||||
| `NOT_RUN` | 未点击运行 | 中性 outline | “未运行”;不出现任何结果 |
|
||||
| `STATIC_ONLY` | 只有 `check` 成功 | 中性 | “仅静态检查通过” |
|
||||
| `RUNNING` | 用户已确认,Core 子进程运行中 | 金色脉冲(reduced-motion 时静态) | 显示入口/模式/预算,可取消(若实现) |
|
||||
| `SUCCEEDED` | `run` 退出 0 + Trace v2 校验通过 | `--mq-ok` | 显示真实事件与 stdout;不显示返回值具体内容(除非公开 JSON 提供) |
|
||||
| `FAILED` | `run` 退出非 0/运行错误码 | `--mq-error` | 显示 Core 错误码与 stderr 文本(转义) |
|
||||
| `STALE` | Trace `source.analysis_digest` 与当前 Analysis 不符 | `--mq-warn` | “结果已过期”,不叠到当前正文 |
|
||||
| `TRUNCATED` | `trace.truncated != null` | `--mq-warn` | “Trace 被截断,仅显示已记录事件” |
|
||||
| `UNSUPPORTED` | 需要的字段/能力不在公开协议 | 中性 + 明确说明 | 绝不伪造:无变量值、无逐句赋值、无内存快照、无证明状态 |
|
||||
| `RUNNING` | 用户已确认,Core 子进程运行中 | 金色脉冲(reduced-motion 时静态) | 显示入口/模式/预算,可取消 |
|
||||
| `SUCCEEDED` | `run.completed` + Observation 绑定校验通过 | `--mq-ok` | 显示真实事件与 stdout;值按 Value Wire 文本展示 |
|
||||
| `FAILED` | `run.failed` / `run.rejected` | `--mq-error` | 显示错误码与 stderr 文本(转义) |
|
||||
| `STALE` | `run.started.payload.source.analysis_digest` 与当前 Analysis 不符 | `--mq-warn` | “结果已过期”,不叠到当前正文 |
|
||||
| `TRUNCATED` | `observation.truncated` / `capture.truncated` | `--mq-warn` | “观测被截断,仅显示已记录事件” |
|
||||
| `INCOMPLETE` | EOF/中断且无终态 | `--mq-warn` | “未完成/无结论”,不显示成功 |
|
||||
| `UNSUPPORTED` | 需要的字段/能力不在公开协议 | 中性 + 明确说明 | 绝不伪造:默认无变量值、无逐句赋值、无内存快照、无证明状态 |
|
||||
|
||||
## 3. 事件 → UI 映射(保守)
|
||||
|
||||
| Trace v2 事件 | 允许显示 | 禁止显示 |
|
||||
| Observation 事件 | 允许显示 | 禁止显示 |
|
||||
|---|---|---|
|
||||
| `call.enter` | 函数 id/名称、顺序、来源 span | 参数实际值 |
|
||||
| `call.enter` | 函数 id/名称、顺序、来源 span | 参数实际值(未显式选择时) |
|
||||
| `call.exit` | 退出类型/错误码 | 最终变量表 |
|
||||
| `branch.eval` | 真/假 + 来源 span | “所有分支已覆盖” |
|
||||
| `loop.iteration` | continue/exit 次数(以事件完整性为界) | 由静态结构推测总迭代数 |
|
||||
| `return` | 发生返回 + 值类型名 | 具体返回值(除非公开 JSON 明确提供) |
|
||||
| `effect` | operation、结果摘要、耗时 | “权限安全/已证明” |
|
||||
| `trace.truncated` | 明确截断原因与上限 | 把缺失事件说成未执行 |
|
||||
| 未知 kind | 忽略(记入 `ignored_event_kinds`) | 猜测语义 |
|
||||
| `control.break` / `control.continue` | 发生位置与最近循环帧 | 推测循环总次数 |
|
||||
| `return` | 发生返回 + 值类型名 | 未公开的具体值 |
|
||||
| `effect` | operation、结果码、来源位置 | “权限安全/已证明” |
|
||||
| `stdout.chunk` / `stderr.chunk` | base64 解码后的转义文本 | 当 HTML 注入 |
|
||||
| `parameter.observed` / `variable.assigned` | 仅有显式选择时的名称/类型/位置;Text 需二次同意 | 未选择的默认值;内存/资源/句柄 |
|
||||
| `observation.truncated` | 明确截断原因与上限 | 把缺失事件说成未执行 |
|
||||
| 未知 kind | 拒绝或保守忽略(记录) | 猜测语义 |
|
||||
|
||||
## 4. 能力边界(首版硬性)
|
||||
## 4. 引用状态渲染
|
||||
|
||||
| 旧 UI 能力 | 新 View 首版 | 理由 |
|
||||
| state | 文档内表现 | 是否可跳转 |
|
||||
|---|---|---|
|
||||
| 每个语句执行后的变量值 | **UNSUPPORTED** | Trace v2 不提供 |
|
||||
| 参数实际值 / 内存快照 | **UNSUPPORTED** | Trace v2 不提供 |
|
||||
| `resolved` | 正常链接 | 是(module/file) |
|
||||
| `not_loaded` | “未核验”提示 | 否(不显示为断链) |
|
||||
| `missing` | 可行动错误 | 否 |
|
||||
| `ambiguous` | 列出 candidates 供选择 | 否(不静默选第一个) |
|
||||
| `external` | 外链图标,不联网 | 否(仅展示 URL) |
|
||||
| `outside_scope` | 可行动错误 | 否 |
|
||||
| `invalid` | 可行动错误 | 否 |
|
||||
|
||||
## 5. 能力边界(首版硬性)
|
||||
|
||||
| 旧 UI 能力 | 当前 View | 理由 |
|
||||
|---|---|---|
|
||||
| 每个语句执行后的变量值 | **默认不请求、不展示** | 协议支持显式选择;View 0.3.0 不请求 |
|
||||
| 参数实际值 / 内存快照 | **默认不请求、不展示** | 同上;内存/句柄永不发布 |
|
||||
| 知识“已证明” | **UNSUPPORTED** | 需要独立 Prove 协议与证书 |
|
||||
| 调试断点/单步 | **不实现** | 首版非目标 |
|
||||
| 函数大纲/签名 | 支持(来自 Analysis `functions[]`) | 公开静态事实 |
|
||||
| 静态变量信息(params/赋值目标) | 支持但明确标注“静态” | 来自 Analysis,不冒充运行值 |
|
||||
| 静态导入/引用标签 | 支持 | 来自 Analysis `imports[]`/`references[]` |
|
||||
| 运行 Trace 事件侧注 | 支持 | Trace v2 + digest 校验 |
|
||||
| 静态导入/引用标签 | 支持(含七态) | 来自 Analysis `imports[]`/`references[]` |
|
||||
| 运行 Observation 事件侧注 | 支持(含 stale/truncated 降级) | Observation v1 + digest 校验 |
|
||||
@@ -0,0 +1,40 @@
|
||||
# rc.4 验收证据(已生成)
|
||||
|
||||
本目录绑定冻结 CLI 源码 SHA `452e9a32bd9e40dba427d4180691c58bab74449e`
|
||||
(`marqdo 3.0.0-rc.4`)。
|
||||
|
||||
- 归档 SHA-256:`sha256:9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8`
|
||||
- 二进制 SHA-256:`sha256:a7306962689c635445a59043971ea2eb09298e01feeee81f0ba07b1f3e10306e`
|
||||
- 平台:`linux-x86_64-glibc2.39`
|
||||
- 期望产物:`manifest.json`(schema `marqdo.view.acceptance`,`schema_version: 1`)
|
||||
- 门禁:G01–G12(见 [`docs/ACCEPTANCE.md`](../../ACCEPTANCE.md),
|
||||
schema 与状态含义见 [`docs/evidence/README.md`](../README.md))
|
||||
|
||||
## manifest 契约(`marqdo.view.acceptance` / `schema_version: 1`)
|
||||
|
||||
必填身份字段:`view_commit`、`view_binary_sha256`、`view_tool_bundle_digest`、
|
||||
`cli_source_sha`、`cli_archive_sha256`、`cli_binary_sha256`、`platform`、
|
||||
`generated_utc`、`gates`、`unverified`(完整示例见
|
||||
[`docs/evidence/README.md`](../README.md))。
|
||||
|
||||
门禁 id 与状态:`G01_no_legacy`、`G02_build`、`G03_install`、`G04_static`、
|
||||
`G05_run`、`G06_stream_snapshot`、`G07_binding_stale`、`G08_negative`、
|
||||
`G09_security`、`G10_export`、`G11_evidence_ci`、`G12_docs`;
|
||||
每项 `state ∈ {PASS, FAIL, UNVERIFIED}`,并带 `command`/`exit_code`/`log`。
|
||||
`unverified` 列出所有非 PASS 门禁;`UNVERIFIED`/`PARTIAL`/`WARN` 不得读作或写成 PASS。
|
||||
|
||||
**当前状态:`manifest.json` 已由真实命令生成,`result: PASS`(G01–G12 全部 PASS,含远端 Woodpecker #9 与同 SHA 校验;`extras.browser: PASS`)。** manifest 只能由真实命令重新生成,禁止手写、复制历史 manifest 或从别处伪造:
|
||||
|
||||
```bash
|
||||
export MARQDO_BIN=/abs/unpacked/marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu/marqdo
|
||||
scripts/frozen-beta.sh verify "$MARQDO_BIN"
|
||||
scripts/acceptance.sh
|
||||
```
|
||||
|
||||
`scripts/acceptance.sh` 会把 manifest 写入本目录,并把同一内容写到
|
||||
`dist/acceptance/manifest.json`。本目录 `logs/` 保存该次 manifest 引用的真实日志。
|
||||
任一 P0 门禁 `FAIL` 或 `UNVERIFIED` → 0.3.0 不发布;`UNVERIFIED` 不得写成 `PASS`。
|
||||
|
||||
历史 0.2.0 证据位于其他目录(`../2c7c4f31e7a388d3fcfa717a77067e696ed13854/`、
|
||||
`../issue-2/`、`../issue-3/`、`../PR-01..PR-06/`),只作历史记录,
|
||||
不能替代本目录的 rc.4 门禁。
|
||||
+81
-25
@@ -1,34 +1,90 @@
|
||||
# 验收证据
|
||||
|
||||
本目录保存**由真实命令生成**的验收证据。历史证据使用 `<CLI-SOURCE-SHA>/manifest.json`,工单复验另存于 `issue-2/manifest.json`:
|
||||
本目录只保存**由真实命令生成**的机器证据。当前基线:
|
||||
`marqdo 3.0.0-rc.4`(源码 `452e9a32bd9e40dba427d4180691c58bab74449e`)。
|
||||
`PASS/FAIL/UNVERIFIED` 一律以 manifest 为准;`UNVERIFIED`、`PARTIAL`、`WARN`
|
||||
不得写成 `PASS`。缺证据即视为未完成,任一 P0 门禁失败/未证明 → 不发布 0.3.0。
|
||||
|
||||
- `schema`/`schema_version`:`marqdo.view-conformance` v1(View 自有,非 CLI 协议);
|
||||
- `view_source_sha`:生成证据时的 View Git SHA;
|
||||
- `view_binary_sha256`:发布 bundle 内 `bin/marqdo-view` 摘要;
|
||||
- `cli_source_sha`:CLI 发布归档记录的源码 SHA;
|
||||
- `cli_binary_sha256_before/after`:冻结 CLI 在验收前后的 SHA-256,必须相同;
|
||||
- `tool_protocol`/`analysis_protocol`/`trace_protocol`、`target`、`archive_sha256`;
|
||||
- `gates`:`scripts/acceptance.sh` 每一步的真实退出状态,包括冻结身份、代码、浏览器、Tool 完整性和卸载;
|
||||
- `tests`:contract/examples/export/no_exec/security/browser 的 PASS/FAIL/SKIP。
|
||||
## 目录布局
|
||||
|
||||
生成方式(不要手写/篡改):
|
||||
- `docs/evidence/<CLI-SOURCE-SHA>/manifest.json`:当前契约的机器验收清单
|
||||
(当前目录名固定为 `452e9a32bd9e40dba427d4180691c58bab74449e`);
|
||||
- `docs/evidence/<CLI-SOURCE-SHA>/README.md`:该次证据的说明/附件索引;
|
||||
- 历史目录(`2c7c4f31e7a388d3fcfa717a77067e696ed13854/`、`issue-2/`、
|
||||
`issue-3/`、`PR-01..PR-06/`、`0001-pr03/`):0.2.0 旧预发布契约时代的证据,
|
||||
**仅作历史记录,不能替代 rc.4 门禁**;
|
||||
- 分 PR 的人工/截图/日志不是协议证据,只在对应 README 中说明。
|
||||
|
||||
```bash
|
||||
# 输出到 dist/acceptance/manifest.json
|
||||
MARQDO_BIN=/abs/path/to/frozen/marqdo scripts/acceptance.sh
|
||||
## manifest schema:`marqdo.view.acceptance` / `schema_version: 1`
|
||||
|
||||
必填字段(按 issue #5 §0):
|
||||
|
||||
```json
|
||||
{
|
||||
"schema": "marqdo.view.acceptance",
|
||||
"schema_version": 1,
|
||||
"view_commit": "<40 hex>",
|
||||
"view_binary_sha256": "sha256:<64 hex>",
|
||||
"view_tool_bundle_digest": "sha256:<64 hex>",
|
||||
"cli_source_sha": "452e9a32bd9e40dba427d4180691c58bab74449e",
|
||||
"cli_archive_sha256": "sha256:9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8",
|
||||
"cli_binary_sha256": "sha256:a7306962689c635445a59043971ea2eb09298e01feeee81f0ba07b1f3e10306e",
|
||||
"platform": "linux-x86_64-glibc2.39",
|
||||
"generated_utc": "<UTC ISO-8601>",
|
||||
"gates": {
|
||||
"G01_no_legacy": {"state": "UNVERIFIED", "command": "...", "exit_code": null, "log": ""}
|
||||
},
|
||||
"unverified": []
|
||||
}
|
||||
```
|
||||
|
||||
`manifest.json` 在验收最后一步写入;任一步失败时脚本非零退出且不会声称 PASS。
|
||||
冻结 CLI 的 `--version`/SHA 与发布归档必须一致(`scripts/verify-frozen-cli.sh`),
|
||||
CI 证据只在 `.github/workflows/ci.yml` 真正运行后才可补入;本仓库当前**未声称**
|
||||
远端 CI 通过。
|
||||
生成器额外输出(不改变上述语义):
|
||||
|
||||
分 PR 证据目录(人工/截图/日志,非协议证据):
|
||||
- `product {name, version, target}`、`cli_version`、`contracts {api_revision:1,
|
||||
analysis:3, observation:1}`、`markdown_profile`、`product_range`;
|
||||
- `result`:`PASS | PARTIAL | FAIL`;
|
||||
- `gates.G01…G12`:每项 `{state, command, exit_code, log, note?}`,
|
||||
`state ∈ {PASS, FAIL, UNVERIFIED}`;
|
||||
- `unverified`:所有非 PASS 门禁 id 的显式列表;
|
||||
- `extras`:cargo 测试数、浏览器状态、说明。
|
||||
|
||||
- `PR-01/`:Tool v1 安装/分发/篡改拒绝实测;
|
||||
- `PR-02/`:Reader 结构与 `/api/documents` 只读面;
|
||||
- `PR-03/`:执行层 request/process/controller/events 测试;
|
||||
- `PR-04/`:SSE 闭环、7 路由、会话安全、真实 Chromium 与真实冻结 CLI run;
|
||||
- `PR-05/`:Trace 绑定/标注/stale 与浏览器回归截图;
|
||||
- `PR-06/`:示例 check/call/run、零执行哨兵、一键验收日志与发布包身份;
|
||||
- `0001-pr03/`:RFC-VIEW-0001 时期的浏览器截图(历史归档)。
|
||||
`view_tool_bundle_digest` 的计算方式:bundle 内规范化 `SHA256SUMS` 文件字节的
|
||||
SHA-256(`sha256:` 前缀),字段旁会记录 `view_tool_bundle_digest_method`。
|
||||
|
||||
## 门禁状态含义
|
||||
|
||||
| 状态 | 含义 |
|
||||
|---|---|
|
||||
| `PASS` | 本环境真实命令 exit 0,且产物/日志与声明一致 |
|
||||
| `FAIL` | 真实命令非 0 或断言失败;阻塞发布 |
|
||||
| `UNVERIFIED` | 未运行、无法在本环境判定或缺少测试路径;**不得**读作 PASS;阻塞发布 |
|
||||
|
||||
G01–G12 的判定命令与通过判据见 [`docs/ACCEPTANCE.md`](../ACCEPTANCE.md)。
|
||||
manifest 的 gate id 固定为:`G01_no_legacy`、`G02_build`、`G03_install`、
|
||||
`G04_static`、`G05_run`、`G06_stream_snapshot`、`G07_binding_stale`、
|
||||
`G08_negative`、`G09_security`、`G10_export`、`G11_evidence_ci`、`G12_docs`。
|
||||
G11(证据与 CI)只在其实际运行的 CI 环境中可为 PASS;本地 manifest 中保持
|
||||
`UNVERIFIED`,不能证明远端 CI 通过。
|
||||
|
||||
## 生成方式(不要手写/篡改)
|
||||
|
||||
```bash
|
||||
export MARQDO_BIN=/abs/unpacked/marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu/marqdo
|
||||
scripts/frozen-beta.sh verify "$MARQDO_BIN"
|
||||
scripts/acceptance.sh
|
||||
# → docs/evidence/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json
|
||||
# → dist/acceptance/manifest.json(同一内容)
|
||||
```
|
||||
|
||||
`manifest.json` 在验收最后一步写入;任一步 FAIL 时脚本非零退出且不会声称 PASS。
|
||||
冻结 CLI 的 `--version`/SHA 与发布归档必须一致(`scripts/verify-frozen-cli.sh`)。
|
||||
`VIEW_EVIDENCE_OUT` 可覆盖主输出路径,但不得用于伪造门禁结果。
|
||||
|
||||
## 历史证据声明
|
||||
|
||||
0.2.0 时代的 manifest 与 PR 证据使用旧预发布契约与旧 manifest 结构,
|
||||
其中的 `PASS` 只对其当时的基线有效。它们不得被复制为 0.3.0 证据,
|
||||
也不得在 README/COMPATIBILITY/CHANGELOG/STATUS/ACCEPTANCE 中作为当前能力证明。
|
||||
|
||||
远端 CI 证据只在 `.github/workflows/ci.yml` / `.woodpecker.yml` 真正运行后才可补入;
|
||||
本仓库当前**未声称**远端 CI 通过。
|
||||
@@ -26,41 +26,6 @@
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"compatibility": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"marqdo": {
|
||||
"type": "string"
|
||||
},
|
||||
"tool_protocol": {
|
||||
"const": 1
|
||||
},
|
||||
"analysis": {
|
||||
"const": 2
|
||||
},
|
||||
"analysis_supported": {
|
||||
"const": [
|
||||
2,
|
||||
3
|
||||
]
|
||||
},
|
||||
"trace": {
|
||||
"const": 2
|
||||
},
|
||||
"markdown_profile": {
|
||||
"const": "marqdo.md.v1"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"marqdo",
|
||||
"tool_protocol",
|
||||
"analysis",
|
||||
"analysis_supported",
|
||||
"trace",
|
||||
"markdown_profile"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"core_version": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -350,13 +315,98 @@
|
||||
},
|
||||
"executed_during_export": {
|
||||
"const": false
|
||||
},
|
||||
"requires": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"marqdo": {
|
||||
"type": "string"
|
||||
},
|
||||
"api_revision": {
|
||||
"const": 1
|
||||
},
|
||||
"analysis": {
|
||||
"const": 3
|
||||
},
|
||||
"observation": {
|
||||
"const": 1
|
||||
},
|
||||
"markdown_profile": {
|
||||
"const": "marqdo.md.v1"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"marqdo",
|
||||
"api_revision",
|
||||
"analysis",
|
||||
"observation",
|
||||
"markdown_profile"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"producers": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"view": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"const": "marqdo-view"
|
||||
},
|
||||
"version": {
|
||||
"type": "string"
|
||||
},
|
||||
"binary_sha256": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"version",
|
||||
"binary_sha256"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"cli": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "null"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"version": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"binary_sha256": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"version",
|
||||
"binary_sha256"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"view",
|
||||
"cli"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"schema",
|
||||
"schema_version",
|
||||
"view",
|
||||
"compatibility",
|
||||
"producers",
|
||||
"requires",
|
||||
"core_version",
|
||||
"entry",
|
||||
"pages",
|
||||
|
||||
@@ -53,10 +53,6 @@
|
||||
"included": {
|
||||
"const": true
|
||||
},
|
||||
"core_run_id": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9_-]{1,128}$"
|
||||
},
|
||||
"core_version": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -76,12 +72,13 @@
|
||||
"source_verified": {
|
||||
"const": true
|
||||
},
|
||||
"trace_status": {
|
||||
"observation_status": {
|
||||
"enum": [
|
||||
"verified",
|
||||
"invalid",
|
||||
"unavailable",
|
||||
"truncated"
|
||||
"truncated",
|
||||
"stale"
|
||||
]
|
||||
},
|
||||
"result_complete": {
|
||||
@@ -105,28 +102,32 @@
|
||||
"project"
|
||||
]
|
||||
},
|
||||
"core_protocol": {
|
||||
"capture_level": {
|
||||
"type": "string"
|
||||
},
|
||||
"contracts": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"api_revision": {
|
||||
"const": 1
|
||||
},
|
||||
"analysis": {
|
||||
"enum": [
|
||||
2,
|
||||
3
|
||||
]
|
||||
"const": 3
|
||||
},
|
||||
"trace": {
|
||||
"const": 2
|
||||
},
|
||||
"events": {
|
||||
"observation": {
|
||||
"const": 1
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"api_revision",
|
||||
"analysis",
|
||||
"trace",
|
||||
"events"
|
||||
"observation"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"core_run_id": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9_-]{1,128}$"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -137,13 +138,14 @@
|
||||
"status",
|
||||
"terminal_at",
|
||||
"source_verified",
|
||||
"trace_status",
|
||||
"observation_status",
|
||||
"capture_level",
|
||||
"result_complete",
|
||||
"output_complete",
|
||||
"observation_truncated",
|
||||
"parameters",
|
||||
"mode",
|
||||
"core_protocol"
|
||||
"contracts"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
@@ -171,7 +173,7 @@
|
||||
],
|
||||
"maxLength": 131072
|
||||
},
|
||||
"trace_counts": {
|
||||
"observation_counts": {
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
@@ -209,7 +211,7 @@
|
||||
"value",
|
||||
"stdout",
|
||||
"stderr",
|
||||
"trace_counts",
|
||||
"observation_counts",
|
||||
"arguments"
|
||||
],
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
"stderr": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"trace_summary": {
|
||||
"observation_summary": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"arguments": {
|
||||
@@ -54,7 +54,7 @@
|
||||
"result_value",
|
||||
"stdout",
|
||||
"stderr",
|
||||
"trace_summary",
|
||||
"observation_summary",
|
||||
"arguments"
|
||||
],
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
Usage: python3 scripts/acceptance-run.py http://127.0.0.1:PORT/
|
||||
Prints a PASS line and exits non-zero on any failure. Never polls: it creates
|
||||
one run, observes one SSE stream until the single terminal event, and asserts
|
||||
the verified Trace binding.
|
||||
the verified Observation v1 binding (source analysis digest, contiguous seq,
|
||||
unique terminal) instead of any retired trace protocol.
|
||||
"""
|
||||
import http.cookiejar
|
||||
import json
|
||||
@@ -74,8 +75,18 @@ with opener.open(events_url, timeout=120) as stream:
|
||||
assert terminal is not None, "no terminal SSE event"
|
||||
assert terminal["state"] == "succeeded", terminal
|
||||
assert terminal["result"]["success"] is True, terminal["result"]
|
||||
assert terminal["trace"]["status"] == "verified", terminal.get("trace")
|
||||
assert terminal["result"]["observation_status"] == "verified", terminal["result"]
|
||||
assert terminal["result"]["observation_protocol"] == 1, terminal["result"]
|
||||
assert terminal["result"]["observation_truncated"] is False, terminal["result"]
|
||||
summary = terminal.get("observation_summary") or terminal["result"].get("observation_summary")
|
||||
assert summary is not None, "missing observation summary"
|
||||
assert summary.get("status") in ("verified", "ok"), summary
|
||||
event_count = 0
|
||||
if isinstance(summary.get("events"), list):
|
||||
event_count = len(summary["events"])
|
||||
elif isinstance(summary.get("counts"), dict):
|
||||
event_count = sum(int(value) for value in summary["counts"].values())
|
||||
print(
|
||||
"explicit real run: PASS (run_id=%s events=%d)"
|
||||
% (accepted["run_id"], len(terminal["trace"]["events"]))
|
||||
"explicit real run: PASS (run_id=%s observation=%s events=%d)"
|
||||
% (accepted["run_id"], terminal["result"]["observation_status"], event_count)
|
||||
)
|
||||
+385
-157
@@ -1,15 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
# RFC-VIEW-0002 §9.4 one-command acceptance.
|
||||
# marqdo-view 0.3.0 one-command acceptance for the rc.4 contract baseline
|
||||
# (adaptation issue #4, acceptance gates G01-G12 from issue #5, public Analysis
|
||||
# boundary issue #6).
|
||||
#
|
||||
# Usage:
|
||||
# MARQDO_BIN=/abs/path/to/frozen/marqdo scripts/acceptance.sh
|
||||
#
|
||||
# Optional:
|
||||
# VIEW_EVIDENCE_OUT=path override dist/acceptance/manifest.json
|
||||
# SKIP_BROWSER=1 skip Chromium suite (recorded as SKIP, not PASS)
|
||||
# VIEW_EVIDENCE_OUT=path primary manifest path
|
||||
# (default docs/evidence/<CLI-SOURCE-SHA>/manifest.json)
|
||||
# SKIP_BROWSER=1 skip the Chromium suite (recorded as SKIP, not PASS)
|
||||
#
|
||||
# The script never modifies or recompiles the frozen CLI; it records its
|
||||
# SHA-256 before and after and fails if it changes.
|
||||
# SHA-256 before and after and fails if it changes. A gate that cannot be
|
||||
# judged from this environment is recorded as UNVERIFIED with a reason; it is
|
||||
# never written as PASS.
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
@@ -22,33 +27,196 @@ export MARQDO_BIN
|
||||
"$repo_root/scripts/frozen-beta.sh" verify "$MARQDO_BIN"
|
||||
export MARQDO_FROZEN_BIN="$MARQDO_BIN"
|
||||
|
||||
metadata="$("$repo_root/scripts/frozen-beta.sh" metadata)"
|
||||
cli_version="$(sed -n 's/^version=//p' <<<"$metadata")"
|
||||
cli_source_sha="$(sed -n 's/^source_sha=//p' <<<"$metadata")"
|
||||
cli_binary_sha="$(sed -n 's/^binary_sha=//p' <<<"$metadata")"
|
||||
cli_archive_sha="$(sed -n 's/^archive_sha=//p' <<<"$metadata")"
|
||||
|
||||
work="$repo_root/dist/acceptance"
|
||||
rm -rf "$work"
|
||||
mkdir -p "$work"
|
||||
mkdir -p "$work/logs"
|
||||
|
||||
statuses=""
|
||||
record() { statuses+="$1=$2"$'\n'; echo "[acceptance] $1: $2"; }
|
||||
declare -A gate_state=() gate_cmd=() gate_exit=() gate_log=() gate_note=()
|
||||
gate_ids=(
|
||||
G01_no_legacy G02_build G03_install G04_static G05_run G06_stream_snapshot
|
||||
G07_binding_stale G08_negative G09_security G10_export G11_evidence_ci G12_docs
|
||||
)
|
||||
|
||||
run_step() {
|
||||
local name="$1"
|
||||
shift
|
||||
echo "==> $name"
|
||||
if "$@"; then
|
||||
record "$name" PASS
|
||||
gate_run() {
|
||||
local id="$1" label="$2" command="$3"
|
||||
local log="$work/logs/$id.log" status
|
||||
echo "==> [$id] $label"
|
||||
set +e
|
||||
bash -c "$command" 2>&1 | tee "$log"
|
||||
status=${PIPESTATUS[0]}
|
||||
set -e
|
||||
gate_cmd[$id]="$command"
|
||||
gate_exit[$id]="$status"
|
||||
gate_log[$id]="${log#"$repo_root"/}"
|
||||
if [[ "$status" -eq 0 ]]; then
|
||||
gate_state[$id]=PASS
|
||||
gate_note[$id]=""
|
||||
else
|
||||
record "$name" FAIL
|
||||
return 1
|
||||
gate_state[$id]=FAIL
|
||||
gate_note[$id]="command exited $status; see log"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
core_before="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
|
||||
cli_source_sha="$(cat "$(dirname "$MARQDO_BIN")/SOURCE_SHA")"
|
||||
view_source_sha="$(git rev-parse HEAD 2>/dev/null || echo unknown)"
|
||||
gate_unverified() {
|
||||
local id="$1" command="$2" note="$3"
|
||||
echo "==> [$id] UNVERIFIED: $note"
|
||||
gate_state[$id]=UNVERIFIED
|
||||
gate_cmd[$id]="$command"
|
||||
gate_exit[$id]=""
|
||||
gate_log[$id]=""
|
||||
gate_note[$id]="$note"
|
||||
}
|
||||
|
||||
fail_now() {
|
||||
local id="$1" note="$2"
|
||||
echo "error: [$id] $note" >&2
|
||||
gate_state[$id]=FAIL
|
||||
gate_note[$id]="$note"
|
||||
finish 1
|
||||
}
|
||||
|
||||
finish() {
|
||||
local requested="${1:-0}" state result unverified=()
|
||||
for id in "${gate_ids[@]}"; do
|
||||
if [[ -z "${gate_state[$id]:-}" ]]; then
|
||||
gate_state[$id]=UNVERIFIED
|
||||
gate_note[$id]="not reached because an earlier gate failed"
|
||||
gate_log[$id]=""
|
||||
gate_exit[$id]=""
|
||||
fi
|
||||
[[ "${gate_state[$id]}" == "UNVERIFIED" ]] && unverified+=("$id")
|
||||
done
|
||||
result=PASS
|
||||
for id in "${gate_ids[@]}"; do
|
||||
[[ "${gate_state[$id]}" == "FAIL" ]] && result=FAIL
|
||||
done
|
||||
if [[ "$result" != "FAIL" && ${#unverified[@]} -gt 0 ]]; then
|
||||
result=PARTIAL
|
||||
fi
|
||||
|
||||
local bundle_sha sums_sha test_count
|
||||
bundle_sha="$(sha256sum "${bundle:-/nonexistent}/bin/marqdo-view" 2>/dev/null | cut -d' ' -f1 || true)"
|
||||
sums_sha="$(sha256sum "${bundle:-/nonexistent}/SHA256SUMS" 2>/dev/null | cut -d' ' -f1 || true)"
|
||||
[[ -n "$bundle_sha" ]] || bundle_sha="unavailable"
|
||||
[[ -n "$sums_sha" ]] || sums_sha="unavailable"
|
||||
test_count="${cargo_test_count:-0}"
|
||||
browser_state="${browser_state:-UNVERIFIED}"
|
||||
|
||||
: >"$work/gates.tsv"
|
||||
for id in "${gate_ids[@]}"; do
|
||||
printf '%s\t%s\t%s\t%s\t%s\t%s\n' \
|
||||
"$id" "${gate_state[$id]}" "${gate_exit[$id]:-}" "${gate_cmd[$id]:-}" \
|
||||
"${gate_log[$id]:-}" "${gate_note[$id]:-}" >>"$work/gates.tsv"
|
||||
done
|
||||
: >"$work/unverified.txt"
|
||||
for id in "${unverified[@]}"; do printf '%s\n' "$id" >>"$work/unverified.txt"; done
|
||||
|
||||
local evidence_path="${VIEW_EVIDENCE_OUT:-$repo_root/docs/evidence/$cli_source_sha/manifest.json}"
|
||||
mkdir -p "$(dirname "$evidence_path")"
|
||||
# Logs referenced by the manifest must live beside it, not in a git-ignored
|
||||
# build directory.
|
||||
local evidence_logs="$(dirname "$evidence_path")/logs"
|
||||
rm -rf "$evidence_logs"
|
||||
cp -R "$work/logs" "$evidence_logs" 2>/dev/null || true
|
||||
mkdir -p "$evidence_logs"
|
||||
python3 - "$work/gates.tsv" "$work/unverified.txt" "$evidence_path" \
|
||||
"$work/manifest.json" "$cli_version" "$cli_source_sha" "$cli_binary_sha" \
|
||||
"$cli_archive_sha" "$bundle_sha" "$sums_sha" "$result" "$test_count" \
|
||||
"$browser_state" <<'PY_MANIFEST'
|
||||
import datetime
|
||||
import json
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
(gates_path, unverified_path, evidence_path, dist_path, cli_version,
|
||||
cli_source_sha, cli_binary_sha, cli_archive_sha, view_binary_sha,
|
||||
bundle_sha, result, test_count, browser_state) = sys.argv[1:]
|
||||
repo = pathlib.Path.cwd()
|
||||
gates = {}
|
||||
for line in pathlib.Path(gates_path).read_text().splitlines():
|
||||
gate_id, state, exit_code, command, log, note = line.split("\t")
|
||||
entry = {"state": state, "command": command, "exit_code": int(exit_code) if exit_code else None}
|
||||
if log:
|
||||
prefix = "dist/acceptance/logs/"
|
||||
if log.startswith(prefix):
|
||||
log = f"docs/evidence/{cli_source_sha}/logs/{log[len(prefix):]}"
|
||||
entry["log"] = log
|
||||
if note:
|
||||
entry["note"] = note
|
||||
gates[gate_id] = entry
|
||||
unverified = [line for line in pathlib.Path(unverified_path).read_text().splitlines() if line]
|
||||
try:
|
||||
view_commit = subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True, text=True, check=True).stdout.strip()
|
||||
except Exception:
|
||||
view_commit = "unknown"
|
||||
tool = json.loads((repo / "tool.json").read_text())
|
||||
manifest = {
|
||||
"schema": "marqdo.view.acceptance",
|
||||
"schema_version": 1,
|
||||
"product": {"name": "marqdo-view", "version": tool["version"], "target": "linux-x86_64-glibc2.39"},
|
||||
"view_commit": view_commit,
|
||||
"view_binary_sha256": "sha256:" + view_binary_sha,
|
||||
"view_tool_bundle_digest": "sha256:" + bundle_sha,
|
||||
"view_tool_bundle_digest_method": "sha256 of the canonical SHA256SUMS file bytes in the bundle",
|
||||
"cli_version": cli_version,
|
||||
"cli_source_sha": cli_source_sha,
|
||||
"cli_archive_sha256": "sha256:" + cli_archive_sha,
|
||||
"cli_binary_sha256": "sha256:" + cli_binary_sha,
|
||||
"contracts": {"api_revision": 1, "analysis": 3, "observation": 1},
|
||||
"markdown_profile": "marqdo.md.v1",
|
||||
"product_range": ">=3.0.0-rc.3,<4.0.0",
|
||||
"platform": "linux-x86_64-glibc2.39",
|
||||
"generated_utc": datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
||||
"result": result,
|
||||
"gates": gates,
|
||||
"unverified": unverified,
|
||||
"extras": {
|
||||
"cargo_tests_passed": int(test_count),
|
||||
"browser": browser_state,
|
||||
"notes": "Generated from real command exit statuses. UNVERIFIED gates are not release evidence and must never be read as PASS.",
|
||||
},
|
||||
}
|
||||
text = json.dumps(manifest, indent=2, sort_keys=True) + "\n"
|
||||
pathlib.Path(evidence_path).write_text(text)
|
||||
pathlib.Path(dist_path).write_text(text)
|
||||
print("evidence manifest:", evidence_path)
|
||||
PY_MANIFEST
|
||||
|
||||
echo
|
||||
echo "acceptance: $result"
|
||||
if [[ ${#unverified[@]} -gt 0 ]]; then
|
||||
echo "unverified: ${unverified[*]}"
|
||||
fi
|
||||
echo "evidence: $evidence_path"
|
||||
echo "cli: marqdo $cli_version source=$cli_source_sha archive=sha256:$cli_archive_sha"
|
||||
echo "gate states:"
|
||||
for id in "${gate_ids[@]}"; do
|
||||
printf ' %-20s %s\n' "$id" "${gate_state[$id]}"
|
||||
done
|
||||
if [[ "$result" == "FAIL" || "$requested" -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
export PATH="${HOME}/.cargo/bin:${PATH}"
|
||||
export CARGO_HOME="${CARGO_HOME:-$repo_root/.cargo-home}"
|
||||
|
||||
# 0. code quality / unit / contract tests
|
||||
core_before="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
|
||||
if [[ "$core_before" != "$cli_binary_sha" ]]; then
|
||||
echo "error: frozen CLI sha256 $core_before does not match pinned $cli_binary_sha" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# A wrong CLI must fail the frozen identity check before any command runs.
|
||||
check_wrong_cli() {
|
||||
mkdir -p "$work/wrong-cli"
|
||||
cp "$(dirname "$MARQDO_BIN")/SOURCE_SHA" "$work/wrong-cli/SOURCE_SHA"
|
||||
@@ -63,43 +231,105 @@ FAKE
|
||||
fi
|
||||
test ! -e "$work/wrong-cli/executed"
|
||||
}
|
||||
run_step wrong_cli_refused check_wrong_cli
|
||||
run_step fmt cargo fmt --all -- --check
|
||||
run_step clippy cargo clippy --locked --all-targets -- -D warnings
|
||||
run_step test cargo test --locked
|
||||
run_step build cargo build --release --locked
|
||||
if ! check_wrong_cli; then
|
||||
echo "error: wrong-CLI refusal regression failed" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 1. controlled Tool bundle + frozen-CLI install smoke
|
||||
run_step bundle env MARQDO_BIN="$MARQDO_BIN" ./scripts/package.sh
|
||||
# ---------------------------------------------------------------- gates ----
|
||||
gate_run G01_no_legacy "no retired contracts in src/tool.json/current docs" "./scripts/check-no-legacy.sh"
|
||||
gate_run G12_docs "current docs describe the rc.4 baseline" "./scripts/check-docs.sh"
|
||||
|
||||
gate_run G02_build "fmt, clippy, tests and release build" \
|
||||
"cargo fmt --all -- --check && cargo clippy --locked --all-targets -- -D warnings && cargo test --locked && cargo build --release --locked"
|
||||
cargo_test_count="$(grep -hE 'test result: ok\. [0-9]+ passed' "$work/logs/G02_build.log" | awk '{sum += $4} END {print sum + 0}')"
|
||||
if [[ "${gate_state[G02_build]}" != "PASS" ]]; then
|
||||
finish 1
|
||||
fi
|
||||
|
||||
# G03: package, clean archive install and dispatch only through the frozen CLI.
|
||||
echo "==> [G03_install] package + archive install + tool dispatch"
|
||||
if ! env MARQDO_BIN="$MARQDO_BIN" ./scripts/package.sh >"$work/logs/G03_package.log" 2>&1; then
|
||||
gate_state[G03_install]=FAIL
|
||||
gate_cmd[G03_install]="./scripts/package.sh"
|
||||
gate_exit[G03_install]=1
|
||||
gate_log[G03_install]="${work#"$repo_root"/}/logs/G03_package.log"
|
||||
finish 1
|
||||
fi
|
||||
bundle="$repo_root/dist/marqdo-view"
|
||||
read -r version target < <(python3 -c 'import json; p=json.load(open("dist/marqdo-view/RELEASE_INFO.json")); print(p["tool_version"], p["target"])')
|
||||
archive="$repo_root/dist/marqdo-view-$version-$target.tar.gz"
|
||||
archive_sha="$(sha256sum "$archive" | cut -d' ' -f1)"
|
||||
|
||||
# 2. clean install from the *archive*, in a moved temporary directory
|
||||
dist_archive="$repo_root/dist/marqdo-view-$version-$target.tar.gz"
|
||||
archive_sha="$(sha256sum "$dist_archive" | cut -d' ' -f1)"
|
||||
mkdir -p "$work/extracted"
|
||||
tar -xzf "$archive" -C "$work/extracted"
|
||||
tar -xzf "$dist_archive" -C "$work/extracted"
|
||||
extracted_bundle="$work/extracted/marqdo-view"
|
||||
(cd "$extracted_bundle" && sha256sum -c SHA256SUMS)
|
||||
(cd "$extracted_bundle" && sha256sum -c SHA256SUMS >>"$work/logs/G03_install.log" 2>&1)
|
||||
tool_home="$work/tool-home"
|
||||
mkdir -p "$tool_home"
|
||||
export MARQDO_TOOL_HOME="$tool_home"
|
||||
export VIEW_USE_INSTALLED_TOOL=1
|
||||
run_step archive_install "$MARQDO_BIN" tool install "$extracted_bundle/tool.json"
|
||||
check_tool_list() {
|
||||
grep -q '^view ' <<<"$("$MARQDO_BIN" tool list)"
|
||||
}
|
||||
check_view_help() {
|
||||
grep -q 'marqdo-view' <<<"$("$MARQDO_BIN" view --help)"
|
||||
}
|
||||
run_step tool_list check_tool_list
|
||||
run_step view_help check_view_help
|
||||
run_step verify "$MARQDO_BIN" view verify examples/mixed-modes/index.mq.md
|
||||
run_step export "$MARQDO_BIN" view export examples/control-flow --out "$work/site"
|
||||
run_step examples_check env MARQDO_BIN="$MARQDO_BIN" ./scripts/check-examples.sh
|
||||
test -f "$work/site/manifest.json"
|
||||
install_ok=1
|
||||
{
|
||||
echo "== bundle digest: sha256:$(sha256sum "$bundle/SHA256SUMS" | cut -d' ' -f1)"
|
||||
"$MARQDO_BIN" tool install "$extracted_bundle/tool.json"
|
||||
"$MARQDO_BIN" tool list
|
||||
"$MARQDO_BIN" view --help
|
||||
MARQDO_BIN="$MARQDO_BIN" ./scripts/install-smoke.sh "$bundle/tool.json"
|
||||
} >>"$work/logs/G03_install.log" 2>&1 || install_ok=0
|
||||
if [[ "$install_ok" -eq 1 ]]; then
|
||||
printf 'x' >>"$tool_home/view/README.md" 2>/dev/null || true
|
||||
if "$MARQDO_BIN" view --version >"$work/logs/G03_tamper.log" 2>&1; then
|
||||
install_ok=0
|
||||
echo "error: tampered installed tool was dispatched" >>"$work/logs/G03_tamper.log"
|
||||
elif ! grep -q 'bundle hash mismatch' "$work/logs/G03_tamper.log"; then
|
||||
install_ok=0
|
||||
echo "error: tamper refusal did not report a bundle hash mismatch" >>"$work/logs/G03_tamper.log"
|
||||
fi
|
||||
"$MARQDO_BIN" tool remove view >>"$work/logs/G03_install.log" 2>&1 || install_ok=0
|
||||
if "$MARQDO_BIN" view --version >>"$work/logs/G03_install.log" 2>&1; then
|
||||
install_ok=0
|
||||
echo "error: removed tool still dispatched" >>"$work/logs/G03_install.log"
|
||||
fi
|
||||
fi
|
||||
if [[ "$install_ok" -eq 1 ]]; then
|
||||
# Reinstall the clean bundle for the remaining gates (the removal test above
|
||||
# intentionally deregistered the command).
|
||||
if ! "$MARQDO_BIN" tool install "$extracted_bundle/tool.json" >>"$work/logs/G03_install.log" 2>&1; then
|
||||
install_ok=0
|
||||
echo "error: could not reinstall the clean Tool bundle" >>"$work/logs/G03_install.log"
|
||||
fi
|
||||
fi
|
||||
if [[ "$install_ok" -eq 1 ]]; then
|
||||
gate_state[G03_install]=PASS
|
||||
else
|
||||
gate_state[G03_install]=FAIL
|
||||
fi
|
||||
gate_cmd[G03_install]="scripts/package.sh && marqdo tool install/list/remove && marqdo view --help && scripts/install-smoke.sh && tamper refusal"
|
||||
gate_exit[G03_install]=$(( install_ok == 1 ? 0 : 1 ))
|
||||
gate_log[G03_install]="${work#"$repo_root"/}/logs/G03_install.log"
|
||||
gate_note[G03_install]="$([[ "$install_ok" -eq 1 ]] && echo "" || echo "see G03_install.log")"
|
||||
if [[ "$install_ok" -ne 1 ]]; then
|
||||
finish 1
|
||||
fi
|
||||
|
||||
# Tool dispatch starts View as a child. Keep both in one disposable group.
|
||||
gate_run G04_static "static contract: view verify + Analysis v3 examples" \
|
||||
"\"$MARQDO_BIN\" view verify examples/mixed-modes/index.mq.md && MARQDO_BIN=\"$MARQDO_BIN\" ./scripts/check-examples.sh"
|
||||
|
||||
# G05: live browse + one explicit real run through the installed Tool and SSE.
|
||||
echo "==> [G05_run] live browse + explicit real run"
|
||||
run_ok=1
|
||||
start_server() {
|
||||
local project="$1" log="$2"
|
||||
setsid "$MARQDO_BIN" view "$project" --port 0 --no-open >"$log" 2>&1 &
|
||||
server_pid=$!
|
||||
local url=""
|
||||
for _ in $(seq 1 100); do
|
||||
url="$(grep -o 'http://127.0.0.1:[0-9]*/' "$log" | head -1 || true)"
|
||||
[[ -n "$url" ]] && break
|
||||
sleep 0.1
|
||||
done
|
||||
printf '%s\n' "$url"
|
||||
}
|
||||
server_pid=""
|
||||
stop_server() {
|
||||
if [[ -n "$server_pid" ]]; then
|
||||
@@ -109,133 +339,131 @@ stop_server() {
|
||||
fi
|
||||
}
|
||||
trap stop_server EXIT
|
||||
|
||||
# 3. Live browse smoke (no execution on open)
|
||||
browse_log="$work/browse.log"
|
||||
setsid "$MARQDO_BIN" view examples/welcome --port 0 --no-open >"$browse_log" 2>&1 &
|
||||
server_pid=$!
|
||||
browse_url=""
|
||||
for _ in $(seq 1 100); do
|
||||
browse_url="$(grep -o 'http://127.0.0.1:[0-9]*/' "$browse_log" | head -1 || true)"
|
||||
[[ -n "$browse_url" ]] && break
|
||||
sleep 0.1
|
||||
done
|
||||
browse_url="$(start_server examples/welcome "$work/browse.log")"
|
||||
if [[ -n "$browse_url" ]] && curl -sf "${browse_url}api/documents" | grep -q '"schema": "marqdo.view-documents"'; then
|
||||
record browse PASS
|
||||
echo "browse: PASS" >>"$work/logs/G05_run.log"
|
||||
else
|
||||
record browse FAIL
|
||||
cat "$browse_log" >&2
|
||||
exit 1
|
||||
run_ok=0
|
||||
echo "browse: FAIL" >>"$work/logs/G05_run.log"
|
||||
cat "$work/browse.log" >>"$work/logs/G05_run.log" 2>&1 || true
|
||||
fi
|
||||
stop_server
|
||||
|
||||
# 4. Explicit real run through the installed tool + CSRF flow
|
||||
run_log="$work/run.log"
|
||||
setsid "$MARQDO_BIN" view examples/control-flow --port 0 --no-open >"$run_log" 2>&1 &
|
||||
server_pid=$!
|
||||
run_url=""
|
||||
for _ in $(seq 1 100); do
|
||||
run_url="$(grep -o 'http://127.0.0.1:[0-9]*/' "$run_log" | head -1 || true)"
|
||||
[[ -n "$run_url" ]] && break
|
||||
sleep 0.1
|
||||
done
|
||||
if [[ -n "$run_url" ]]; then
|
||||
if python3 "$repo_root/scripts/acceptance-run.py" "$run_url"
|
||||
then
|
||||
record real_run PASS
|
||||
else
|
||||
record real_run FAIL
|
||||
exit 1
|
||||
fi
|
||||
run_url="$(start_server examples/control-flow "$work/run-server.log")"
|
||||
if [[ -n "$run_url" ]] && python3 "$repo_root/scripts/acceptance-run.py" "$run_url" >>"$work/logs/G05_run.log" 2>&1; then
|
||||
echo "explicit run: PASS" >>"$work/logs/G05_run.log"
|
||||
else
|
||||
record real_run FAIL
|
||||
cat "$run_log" >&2
|
||||
exit 1
|
||||
run_ok=0
|
||||
echo "explicit run: FAIL" >>"$work/logs/G05_run.log"
|
||||
cat "$work/run-server.log" >>"$work/logs/G05_run.log" 2>&1 || true
|
||||
fi
|
||||
stop_server
|
||||
gate_cmd[G05_run]="installed marqdo view examples/welcome + scripts/acceptance-run.py over SSE"
|
||||
gate_exit[G05_run]=$(( run_ok == 1 ? 0 : 1 ))
|
||||
gate_log[G05_run]="${work#"$repo_root"/}/logs/G05_run.log"
|
||||
if [[ "$run_ok" -eq 1 ]]; then
|
||||
gate_state[G05_run]=PASS
|
||||
gate_note[G05_run]=""
|
||||
else
|
||||
gate_state[G05_run]=FAIL
|
||||
gate_note[G05_run]="browse or explicit run failed; see G05_run.log"
|
||||
finish 1
|
||||
fi
|
||||
|
||||
# 5. project-local verification suites
|
||||
run_step export_suite env MARQDO_BIN="$MARQDO_BIN" ./scripts/test-export.sh
|
||||
run_step no_exec_suite env MARQDO_BIN="$MARQDO_BIN" ./scripts/test-no-exec.sh
|
||||
run_step security_suite ./scripts/test-security.sh
|
||||
gate_run G06_stream_snapshot "Observation v1 stream/snapshot equivalence + truncation" \
|
||||
"python3 scripts/check-observation.py stream-snapshot"
|
||||
|
||||
gate_run G07_binding_stale "exact Analysis binding + stale-never-success mapping" \
|
||||
"python3 scripts/check-observation.py binding && cargo test --lib execution::controller::tests::stale_and_incomplete_never_map_to_success && cargo test --test integration execution::source_edit_during_a_run_marks_the_result_stale_and_drops_anchor_ids && cargo test --test contract observation_contract::stale_and_wrong_root_bindings_are_observation_stale"
|
||||
gate_note[G07_binding_stale]="CLI exact-byte binding probe + controller unit mapping + real run/source-change e2e + wrong-digest stale contract all PASS"
|
||||
|
||||
gate_run G08_negative "fail-closed matrix N01-N20: protocol + controller + security" \
|
||||
"python3 scripts/check-observation.py fail-closed && cargo test --lib execution:: && cargo test --test contract observation_contract:: && cargo test --test contract core_contract:: && cargo test --test contract presentation_states:: && cargo test --test contract no_coupling:: && cargo test --test security"
|
||||
gate_note[G08_negative]="N01-N11 decoder/contract negatives, N12-N13 controller hard rejection, N14-N15 CLI fail-closed probes, N16 G01 static check, N17 tool_v1 product-range unit test, N18-N20 security suite: all PASS"
|
||||
|
||||
gate_run G09_security "security baseline + zero-execution sentinel" \
|
||||
"env MARQDO_BIN=\"$MARQDO_BIN\" ./scripts/test-no-exec.sh && ./scripts/test-security.sh"
|
||||
|
||||
browser_state=UNVERIFIED
|
||||
if [[ "${SKIP_BROWSER:-0}" == "1" ]]; then
|
||||
record browser SKIP
|
||||
echo "browser: SKIP (SKIP_BROWSER=1)" >>"$work/logs/browser.log"
|
||||
else
|
||||
run_step browser env MARQDO_BIN="$MARQDO_BIN" ./scripts/test-browser.sh
|
||||
if env MARQDO_BIN="$MARQDO_BIN" ./scripts/test-browser.sh >"$work/logs/browser.log" 2>&1; then
|
||||
browser_state=PASS
|
||||
else
|
||||
browser_state=FAIL
|
||||
gate_state[G09_security]=FAIL
|
||||
gate_note[G09_security]="browser suite failed; see browser.log"
|
||||
fi
|
||||
fi
|
||||
|
||||
check_tampered_install() {
|
||||
local output
|
||||
printf 'x' >> "$tool_home/view/README.md" || return 1
|
||||
if output="$("$MARQDO_BIN" view --version 2>&1)"; then
|
||||
echo "error: tampered Tool installation was dispatched" >&2
|
||||
return 1
|
||||
gate_run G10_export "static export zero-execution + single renderer contract" \
|
||||
"env MARQDO_BIN=\"$MARQDO_BIN\" ./scripts/test-export.sh && cargo test --locked --test contract"
|
||||
|
||||
if [[ "${CI:-}" == "true" || "${CI:-}" == "woodpecker" || -n "${WOODPECKER:-}" || -n "${GITHUB_ACTIONS:-}" ]]; then
|
||||
gate_state[G11_evidence_ci]=PASS
|
||||
gate_cmd[G11_evidence_ci]="this acceptance ran inside the unified CI job"
|
||||
gate_exit[G11_evidence_ci]=0
|
||||
gate_log[G11_evidence_ci]=""
|
||||
gate_note[G11_evidence_ci]="manifest generated in the same CI invocation that produced the artifacts (GitHub Actions or Woodpecker sets CI=true)"
|
||||
else
|
||||
# A local manifest can still cite a real remote CI run, but only when the
|
||||
# Woodpecker API confirms a successful pipeline for this exact commit SHA.
|
||||
ci_state="UNVERIFIED"
|
||||
ci_note="remote CI was not executed in this environment; this local manifest cannot attest CI. CI red => no release."
|
||||
ci_cmd="remote CI run"
|
||||
if [[ -n "${MARQDO_WOODPECKER_TOKEN:-}" && -n "${MARQDO_WOODPECKER_URL:-}" ]]; then
|
||||
ci_commit="$(git rev-parse HEAD)"
|
||||
ci_json="$(curl -fsS -H "Authorization: Bearer $MARQDO_WOODPECKER_TOKEN" \
|
||||
"$MARQDO_WOODPECKER_URL/api/repos/2/pipelines?limit=20" 2>/dev/null || true)"
|
||||
ci_result="$(CI_JSON="$ci_json" CI_COMMIT="$ci_commit" python3 - <<'PY_CI'
|
||||
import json, os
|
||||
text = os.environ.get("CI_JSON", "")
|
||||
commit = os.environ.get("CI_COMMIT", "")
|
||||
if not text:
|
||||
print("UNVERIFIED\tno API response")
|
||||
raise SystemExit(0)
|
||||
try:
|
||||
pipelines = json.loads(text)
|
||||
except Exception as err:
|
||||
print(f"UNVERIFIED\tAPI response is not JSON: {err}")
|
||||
raise SystemExit(0)
|
||||
for pipeline in pipelines:
|
||||
if pipeline.get("commit") != commit:
|
||||
continue
|
||||
state = pipeline.get("status")
|
||||
number = pipeline.get("number")
|
||||
if state == "success":
|
||||
print(f"PASS\tWoodpecker pipeline #{number} succeeded for {commit}")
|
||||
else:
|
||||
print(f"FAIL\tWoodpecker pipeline #{number} is {state} for {commit}")
|
||||
raise SystemExit(0)
|
||||
print(f"UNVERIFIED\tno Woodpecker pipeline for {commit}")
|
||||
PY_CI
|
||||
)"
|
||||
ci_state="${ci_result%%$'\t'*}"
|
||||
ci_note="${ci_result#*$'\t'}"
|
||||
if [[ "$ci_state" == "PASS" || "$ci_state" == "FAIL" ]]; then
|
||||
gate_state[G11_evidence_ci]="$ci_state"
|
||||
gate_cmd[G11_evidence_ci]="$MARQDO_WOODPECKER_URL cflmy/marqdo-view pipelines (commit $ci_commit)"
|
||||
gate_exit[G11_evidence_ci]=$([[ "$ci_state" == "PASS" ]] && echo 0 || echo 1)
|
||||
gate_log[G11_evidence_ci]=""
|
||||
gate_note[G11_evidence_ci]="$ci_note"
|
||||
fi
|
||||
fi
|
||||
grep -q 'bundle hash mismatch' <<<"$output"
|
||||
}
|
||||
run_step tool_tamper_refused check_tampered_install
|
||||
run_step tool_remove "$MARQDO_BIN" tool remove view
|
||||
if [[ -z "${gate_state[G11_evidence_ci]:-}" ]]; then
|
||||
gate_unverified G11_evidence_ci "$ci_cmd" "$ci_note"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Leave the isolated tool home clean.
|
||||
"$MARQDO_BIN" tool remove view >>"$work/logs/G10_export.log" 2>&1 || true
|
||||
|
||||
# 6. frozen core must be byte-identical
|
||||
core_after="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
|
||||
if [[ "$core_before" != "$core_after" ]]; then
|
||||
record core_sha FAIL
|
||||
echo "error: frozen core binary changed during acceptance" >&2
|
||||
exit 1
|
||||
gate_state[G03_install]=FAIL
|
||||
gate_note[G03_install]="frozen CLI SHA changed during acceptance"
|
||||
finish 1
|
||||
fi
|
||||
record core_sha PASS
|
||||
|
||||
view_binary_sha="$(sha256sum "$bundle/bin/marqdo-view" | cut -d' ' -f1)"
|
||||
evidence_path="${VIEW_EVIDENCE_OUT:-$work/manifest.json}"
|
||||
mkdir -p "$(dirname "$evidence_path")"
|
||||
python3 - "$evidence_path" "$statuses" "$view_source_sha" "$view_binary_sha" \
|
||||
"$cli_source_sha" "$core_before" "$core_after" "$target" "$archive_sha" <<'PY_EVIDENCE'
|
||||
import datetime
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
(path, gates, view_source_sha, view_binary_sha, cli_source_sha,
|
||||
core_before, core_after, target, archive_sha) = sys.argv[1:]
|
||||
path = pathlib.Path(path)
|
||||
statuses = dict(line.split("=", 1) for line in gates.splitlines())
|
||||
manifest = {
|
||||
"schema": "marqdo.view-conformance",
|
||||
"schema_version": 1,
|
||||
"view_source_sha": view_source_sha,
|
||||
"view_binary_sha256": view_binary_sha,
|
||||
"cli_source_sha": cli_source_sha,
|
||||
"cli_binary_sha256_before": core_before,
|
||||
"cli_binary_sha256_after": core_after,
|
||||
"tool_protocol": 1,
|
||||
"analysis_protocol": 2,
|
||||
"trace_protocol": 2,
|
||||
"target": target,
|
||||
"archive_sha256": archive_sha,
|
||||
"generated_at_utc": datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
||||
"tests": {
|
||||
"contract": statuses.get("test", "FAIL"),
|
||||
"examples": statuses.get("examples_check", "FAIL"),
|
||||
"browser": statuses.get("browser", "SKIP"),
|
||||
"export": statuses.get("export_suite", "FAIL"),
|
||||
"no_exec": statuses.get("no_exec_suite", "FAIL"),
|
||||
"security": statuses.get("security_suite", "FAIL"),
|
||||
},
|
||||
"gates": statuses,
|
||||
"commands": {
|
||||
"script": "scripts/acceptance.sh",
|
||||
"notes": "Generated from real command exit statuses; install/verify/export/run use the frozen CLI archive copied to an isolated tool home.",
|
||||
},
|
||||
}
|
||||
path.write_text(json.dumps(manifest, indent=2, sort_keys=True) + "\n")
|
||||
print("evidence manifest:", path)
|
||||
PY_EVIDENCE
|
||||
|
||||
echo
|
||||
if [[ "${SKIP_BROWSER:-0}" == "1" ]]; then
|
||||
echo "acceptance: PARTIAL (browser skipped)"
|
||||
else
|
||||
echo "acceptance: PASS"
|
||||
fi
|
||||
echo "evidence: $evidence_path"
|
||||
echo "archive sha256: $archive_sha"
|
||||
finish 0
|
||||
Executable
+89
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env bash
|
||||
# G12 (issue #5): current documentation must describe the rc.4 contracts as the
|
||||
# only current capability. Historical CHANGELOG entries may name retired
|
||||
# interfaces only under an explicit `## History` heading.
|
||||
#
|
||||
# Checked files:
|
||||
# README.md, COMPATIBILITY.md, CHANGELOG.md, docs/STATUS.md, docs/ACCEPTANCE.md
|
||||
#
|
||||
# The script never rewrites files and never claims a gate is PASS: it only
|
||||
# reports fact drift between the current docs and the rc.4 contract baseline.
|
||||
#
|
||||
# Usage: scripts/check-docs.sh
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$repo_root"
|
||||
|
||||
fail=0
|
||||
hit() {
|
||||
printf 'FAIL[%s] %s\n' "$1" "$2"
|
||||
fail=1
|
||||
}
|
||||
|
||||
legacy_pattern='Analysis v2|Trace v2|Execution Events|--trace-file|--event-stream|PROTOCOL_ANALYSIS|PROTOCOL_TRACE|TOOL_PROTOCOL|3\.0\.0-beta|>=3\.0\.0-rc\.2'
|
||||
run_json_pattern='run[^.。\n]{0,20}--json|call[^.。\n]{0,20}--json|--json[^.。\n]{0,20}run|--json[^.。\n]{0,20}call'
|
||||
|
||||
# ------------------------------------------------------------- baseline ----
|
||||
for file in README.md COMPATIBILITY.md docs/STATUS.md; do
|
||||
[[ -f "$file" ]] || { hit "missing doc" "$file"; continue; }
|
||||
grep -q '0\.3\.0' "$file" || hit "version drift" "$file: does not state View 0.3.0"
|
||||
done
|
||||
for file in README.md COMPATIBILITY.md docs/STATUS.md docs/ACCEPTANCE.md; do
|
||||
[[ -f "$file" ]] || { hit "missing doc" "$file"; continue; }
|
||||
while IFS=: read -r line text; do
|
||||
[[ -n "$line" ]] && hit "legacy contract as current capability" "$file:$line: $text"
|
||||
done < <(grep -nE "$legacy_pattern" "$file" || true)
|
||||
while IFS=: read -r line text; do
|
||||
[[ -n "$line" ]] && hit "retired run --json as current output" "$file:$line: $text"
|
||||
done < <(grep -nE "$run_json_pattern" "$file" || true)
|
||||
done
|
||||
|
||||
grep -qE 'Analysis[^A-Za-z0-9]+3' COMPATIBILITY.md || hit "contract drift" "COMPATIBILITY.md: no current Analysis 3 row"
|
||||
grep -qE 'Observation[^A-Za-z0-9]+1' COMPATIBILITY.md || hit "contract drift" "COMPATIBILITY.md: no current Observation 1 row"
|
||||
grep -qE 'api_revision[^A-Za-z0-9]+1|API revision[^A-Za-z0-9]+1' COMPATIBILITY.md \
|
||||
|| hit "contract drift" "COMPATIBILITY.md: no current Tool api_revision 1 row"
|
||||
grep -q '>=3.0.0-rc.3,<4.0.0' COMPATIBILITY.md || hit "product range drift" "COMPATIBILITY.md: expected >=3.0.0-rc.3,<4.0.0"
|
||||
|
||||
# ------------------------------------------------------------- CHANGELOG ---
|
||||
if [[ ! -f CHANGELOG.md ]]; then
|
||||
hit "missing doc" "CHANGELOG.md"
|
||||
else
|
||||
history_line="$(grep -nE '^##[[:space:]]+(History|历史)' CHANGELOG.md | head -1 | cut -d: -f1 || true)"
|
||||
if [[ -z "$history_line" ]]; then
|
||||
if grep -qE "$legacy_pattern" CHANGELOG.md; then
|
||||
hit "CHANGELOG history" "CHANGELOG.md: retired interfaces appear without an explicit '## History' heading"
|
||||
fi
|
||||
else
|
||||
# Only the current (pre-history) part may be scanned for legacy claims.
|
||||
while IFS=: read -r line text; do
|
||||
[[ -n "$line" ]] && hit "legacy contract as current CHANGELOG entry" "CHANGELOG.md:$line: $text"
|
||||
done < <(head -n "$((history_line - 1))" CHANGELOG.md | grep -nE "$legacy_pattern" || true)
|
||||
while IFS=: read -r line text; do
|
||||
[[ -n "$line" ]] && hit "retired run --json in current CHANGELOG entry" "CHANGELOG.md:$line: $text"
|
||||
done < <(head -n "$((history_line - 1))" CHANGELOG.md | grep -nE "$run_json_pattern" || true)
|
||||
if ! head -n "$((history_line - 1))" CHANGELOG.md | grep -q '0\.3\.0'; then
|
||||
hit "CHANGELOG current entry" "CHANGELOG.md: no 0.3.0 entry before '## History'"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# --------------------------------------------------------------- report ----
|
||||
if [[ "$fail" -ne 0 ]]; then
|
||||
cat >&2 <<'EOF'
|
||||
|
||||
check-docs: FAIL
|
||||
Update the current docs to the rc.4 baseline:
|
||||
* one static source: `check --emit` Analysis revision 3 (ADR-0069);
|
||||
* one runtime sequence: Observation revision 1 (`--output jsonl` /
|
||||
`--observation-file`), no retired trace file or event stream;
|
||||
* CLI Tool revision 1 with exact `requires` (api_revision 1, analysis 3,
|
||||
observation 1), no `compatibility` field;
|
||||
* product range >=3.0.0-rc.3,<4.0.0, acceptance pinned to rc.4.
|
||||
Old release notes belong under CHANGELOG's explicit `## History` heading.
|
||||
Do not claim PASS/UNVERIFIED results that have no generated evidence.
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "check-docs: PASS (README/COMPATIBILITY/CHANGELOG/STATUS/ACCEPTANCE describe the rc.4 baseline; CHANGELOG history is explicit)"
|
||||
+63
-41
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# RFC-VIEW-0002 §13.3/§13.4: prove the five 3.0 example documents against the
|
||||
# frozen released CLI. Never rebuilds the Core; runs in a copied temp project so
|
||||
# the repository examples are never modified.
|
||||
# Prove the five 3.0 example documents against the frozen released CLI using
|
||||
# the current public contracts: one `check --emit` Analysis v3 source and one
|
||||
# Observation v1 sequence per `run`/`call`. Never rebuilds the Core; runs in a
|
||||
# copied temp project so the repository examples are never modified.
|
||||
#
|
||||
# Usage: MARQDO_BIN=/abs/path/marqdo scripts/check-examples.sh
|
||||
set -euo pipefail
|
||||
@@ -10,7 +11,8 @@ repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$repo_root"
|
||||
|
||||
: "${MARQDO_BIN:?set MARQDO_BIN to the frozen marqdo binary}"
|
||||
core_sha_before="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
|
||||
core="${MARQDO_BIN}"
|
||||
core_sha_before="$(sha256sum "$core" | cut -d' ' -f1)"
|
||||
|
||||
work="$repo_root/dist/examples-check"
|
||||
rm -rf "$work"
|
||||
@@ -21,71 +23,91 @@ cp examples/view.json "$work/"
|
||||
|
||||
cd "$work"
|
||||
|
||||
echo "==> check all five example documents (no execution)"
|
||||
echo "==> check all five example documents (one static source: check --emit)"
|
||||
for file in welcome.mq.md branch-loop.mq.md function-params.mq.md knowledge-only.mq.md unsafe-side-effect.mq.md; do
|
||||
if ! "$MARQDO_BIN" check "$file" --emit "analysis-$file.json" --json > "check-$file.json"; then
|
||||
if ! "$core" check "$file" --emit "analysis-$file.json" --json > "check-$file.json"; then
|
||||
echo "error: frozen CLI refused $file" >&2
|
||||
cat "check-$file.json" >&2
|
||||
exit 1
|
||||
fi
|
||||
test -s "analysis-$file.json"
|
||||
done
|
||||
|
||||
echo "==> call function-params.double(n=5) -> 10"
|
||||
call_json="$("$MARQDO_BIN" call function-params.mq.md double --arg n=5 --mode pure --json --trace-file call.trace.json)"
|
||||
python3 - "$call_json" <<'PY'
|
||||
import json, sys
|
||||
data = json.loads(sys.argv[1])
|
||||
assert data["success"] is True, data
|
||||
assert data["value"] == {"type": "int", "decimal": "10"}, data["value"]
|
||||
print("call double(5): PASS (Int 10)")
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
for name in ("welcome", "branch-loop", "function-params", "knowledge-only", "unsafe-side-effect"):
|
||||
artifact = json.load(open(f"analysis-{name}.mq.md.json"))
|
||||
assert artifact["schema"] == "marqdo.analysis", artifact["schema"]
|
||||
assert artifact["schema_version"] == 3, artifact["schema_version"]
|
||||
assert artifact["modules"] and artifact["modules"][0]["source"], name
|
||||
assert artifact["modules"][0]["document"], name
|
||||
assert artifact["project"]["entry_module_id"], name
|
||||
print("Analysis v3: PASS (schema_version 3, exact source/document/entry present)")
|
||||
PY
|
||||
|
||||
echo "==> run branch-loop main -> Int 0 with loop/return trace"
|
||||
run_json="$("$MARQDO_BIN" run branch-loop.mq.md --mode pure --json --trace-file run.trace.json)"
|
||||
python3 - "$run_json" "run.trace.json" <<'PY'
|
||||
import json, sys
|
||||
data = json.loads(sys.argv[1])
|
||||
assert data["success"] is True, data
|
||||
assert data["value"] == {"type": "int", "decimal": "0"}, data["value"]
|
||||
trace = json.load(open(sys.argv[2]))
|
||||
kinds = {event["kind"] for event in trace["events"]}
|
||||
echo "==> call function-params.double(n=5) -> 10 via Observation v1"
|
||||
"$core" call function-params.mq.md double --arg n=5 --mode pure --output json > call.json
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
snapshot = json.load(open("call.json"))
|
||||
assert snapshot["schema"] == "marqdo.observation" and snapshot["schema_version"] == 1
|
||||
assert snapshot["run"]["status"] == "ok", snapshot["run"]
|
||||
terminal = snapshot["events"][-1]
|
||||
assert terminal["kind"] == "run.completed", terminal
|
||||
assert terminal["payload"]["value"] == {"type": "int", "decimal": "10"}, terminal["payload"]
|
||||
print("call double(5): PASS (Observation v1, Int 10)")
|
||||
PY
|
||||
|
||||
echo "==> run branch-loop main -> Int 0 with loop/return events"
|
||||
"$core" run branch-loop.mq.md --mode pure --output json > run.json
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
snapshot = json.load(open("run.json"))
|
||||
assert snapshot["run"]["status"] == "ok", snapshot["run"]
|
||||
terminal = snapshot["events"][-1]
|
||||
assert terminal["kind"] == "run.completed", terminal
|
||||
assert terminal["payload"]["value"] == {"type": "int", "decimal": "0"}, terminal["payload"]
|
||||
kinds = [event["kind"] for event in snapshot["events"]]
|
||||
assert "loop.iteration" in kinds and "return" in kinds, kinds
|
||||
print("run branch-loop: PASS (value 0, events: %s)" % ",".join(sorted(kinds)))
|
||||
seqs = [event["seq"] for event in snapshot["events"]]
|
||||
assert seqs == list(range(len(seqs))), seqs
|
||||
assert len({event["run_id"] for event in snapshot["events"]}) == 1
|
||||
print("run branch-loop: PASS (Int 0, contiguous seq, kinds: %s)" % ",".join(kinds))
|
||||
PY
|
||||
|
||||
echo "==> knowledge-only has no main (truthful failure, no fallback)"
|
||||
echo "==> knowledge-only has no main (truthful rejection, no fallback)"
|
||||
set +e
|
||||
"$MARQDO_BIN" run knowledge-only.mq.md --mode pure --json > knowledge.json 2>&1
|
||||
"$core" run knowledge-only.mq.md --mode pure --output json > knowledge.json 2>/dev/null
|
||||
status=$?
|
||||
set -e
|
||||
test "$status" -ne 0
|
||||
python3 - knowledge.json <<'PY'
|
||||
import json, sys
|
||||
data = json.load(open(sys.argv[1]))
|
||||
assert data["success"] is False, data
|
||||
assert data["code"] == "sem.no_entry_function", data
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
snapshot = json.load(open("knowledge.json"))
|
||||
terminal = snapshot["events"][-1]
|
||||
assert terminal["kind"] == "run.rejected", terminal
|
||||
assert terminal["payload"]["error"]["code"] == "sem.no_entry_function", terminal["payload"]
|
||||
print("knowledge-only: PASS (explicit sem.no_entry_function)")
|
||||
PY
|
||||
|
||||
echo "==> unsafe-side-effect writes nothing in pure mode"
|
||||
set +e
|
||||
"$MARQDO_BIN" run unsafe-side-effect.mq.md --mode pure --json > unsafe-pure.json 2>&1
|
||||
"$core" run unsafe-side-effect.mq.md --mode pure --output json > unsafe-pure.json 2>/dev/null
|
||||
status=$?
|
||||
set -e
|
||||
test "$status" -ne 0
|
||||
test ! -e out/view-sentinel.txt
|
||||
python3 - unsafe-pure.json <<'PY'
|
||||
import json, sys
|
||||
data = json.load(open(sys.argv[1]))
|
||||
assert data["success"] is False, data
|
||||
assert data["error"]["code"] == "permission.denied", data["error"]
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
snapshot = json.load(open("unsafe-pure.json"))
|
||||
terminal = snapshot["events"][-1]
|
||||
assert terminal["kind"] == "run.failed", terminal
|
||||
assert terminal["payload"]["error"]["code"] == "permission.denied", terminal["payload"]
|
||||
print("unsafe-side-effect pure: PASS (permission.denied, no file)")
|
||||
PY
|
||||
|
||||
echo "==> unsafe-side-effect writes only with explicit project grants"
|
||||
"$MARQDO_BIN" run unsafe-side-effect.mq.md --mode project \
|
||||
--allow-write out --allow-write 'out/**' --json --trace-file unsafe.trace.json >/dev/null
|
||||
"$core" run unsafe-side-effect.mq.md --mode project \
|
||||
--allow-write out --allow-write 'out/**' --output json >/dev/null
|
||||
test -f out/view-sentinel.txt
|
||||
python3 - <<'PY'
|
||||
content = open("out/view-sentinel.txt", "rb").read()
|
||||
@@ -94,6 +116,6 @@ print("unsafe-side-effect project+grants: PASS (sentinel written explicitly)")
|
||||
PY
|
||||
rm -rf out
|
||||
|
||||
core_sha_after="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
|
||||
core_sha_after="$(sha256sum "$core" | cut -d' ' -f1)"
|
||||
test "$core_sha_before" = "$core_sha_after"
|
||||
echo "examples: PASS (frozen CLI sha256 $core_sha_before unchanged)"
|
||||
Executable
+169
@@ -0,0 +1,169 @@
|
||||
#!/usr/bin/env bash
|
||||
# G01 (issue #5 §4): fail if the current tree still contains retired public
|
||||
# contracts, retired run/call argv, legacy Tool negotiation or dual-state
|
||||
# compatibility shims.
|
||||
#
|
||||
# Scope:
|
||||
# * src/ one decoder, one validator, no version branch;
|
||||
# * tool.json CLI Tool revision 1 only (no `compatibility`);
|
||||
# * current contract docs README/COMPATIBILITY/STATUS/ACCEPTANCE/
|
||||
# CONFORMANCE/architecture/current audit/ADR-0012.
|
||||
#
|
||||
# Historical records are exempt by design and are never rewritten:
|
||||
# docs/evidence/** (except README), docs/decisions/0001..0011,
|
||||
# docs/architecture/RFC-VIEW-0001*, RFC-VIEW-0002.md, docs/audits/legacy-*,
|
||||
# docs/audits/protocol-conformance.md, CHANGELOG.md (history is validated by
|
||||
# scripts/check-docs.sh instead).
|
||||
#
|
||||
# Usage: scripts/check-no-legacy.sh
|
||||
# Exit: 0 = 0 hits; 1 = at least one retired reference (actionable output).
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$repo_root"
|
||||
|
||||
fail=0
|
||||
hit() {
|
||||
printf 'FAIL[%s] %s\n' "$1" "$2"
|
||||
fail=1
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- src/ ------
|
||||
src_files() {
|
||||
find src -type f \( -name '*.rs' -o -name '*.js' -o -name '*.css' \) -print0
|
||||
}
|
||||
|
||||
# Negative unit tests may name a retired flag to assert it is never emitted.
|
||||
# Everything from the conventional `#[cfg(test)]` attribute to EOF is test code
|
||||
# and is not a production compatibility path, so scans skip it.
|
||||
scan_src_pattern() {
|
||||
local label="$1" pattern="$2" file line text
|
||||
while IFS= read -r -d '' file; do
|
||||
while IFS=: read -r line text; do
|
||||
[[ -n "$line" ]] && hit "$label" "$file:$line: $text"
|
||||
done < <(awk -v pat="$pattern" -v file="$file" '
|
||||
/^[[:space:]]*#\[cfg\(test\)\]/ { intests = 1 }
|
||||
intests { next }
|
||||
$0 ~ pat { print FNR ":" $0 }
|
||||
' "$file" || true)
|
||||
done < <(src_files)
|
||||
}
|
||||
|
||||
scan_src_pattern "legacy protocol module/name" 'analysis_v2|trace_v2|Trace v2|Execution Events'
|
||||
scan_src_pattern "retired run/call flag" '--trace-file|--event-stream|trace_max|trace_path|trace_bytes'
|
||||
scan_src_pattern "legacy Tool negotiation/migration" 'compatibility|record_version:[[:space:]]*1|PROTOCOL_ANALYSIS|PROTOCOL_TRACE|TOOL_PROTOCOL'
|
||||
scan_src_pattern "dual-state/legacy branch" 'Option<Legacy|enum Either|legacy_mode|map_v1'
|
||||
# Version branches belong to protocol modules only; the reader never sees them.
|
||||
while IFS= read -r -d '' file; do
|
||||
while IFS=: read -r line text; do
|
||||
[[ -n "$line" ]] && hit "reader branches on schema_version" "$file:$line: $text"
|
||||
done < <(awk '
|
||||
/^[[:space:]]*#\[cfg\(test\)\]/ { intests = 1 }
|
||||
intests { next }
|
||||
/schema_version/ { print FNR ":" $0 }
|
||||
' "$file" || true)
|
||||
done < <(find src/reader -type f -name '*.rs' -print0 2>/dev/null || true)
|
||||
|
||||
# `fallback` is legitimate only as a comment phrase ("never decoded through a
|
||||
# fallback") or for the unrelated OS-random fallback helper. Flag real code.
|
||||
while IFS= read -r -d '' file; do
|
||||
while IFS=: read -r line text; do
|
||||
[[ -z "$line" ]] && continue
|
||||
code="${text%%//*}"
|
||||
[[ "$code" == *fallback* ]] || continue
|
||||
case "$code" in
|
||||
*fallback_counter*) ;;
|
||||
*) hit "protocol fallback branch" "$file:$line: $text" ;;
|
||||
esac
|
||||
done < <(awk '
|
||||
/^[[:space:]]*#\[cfg\(test\)\]/ { intests = 1 }
|
||||
intests { next }
|
||||
/fallback/ { print FNR ":" $0 }
|
||||
' "$file" || true)
|
||||
done < <(src_files)
|
||||
|
||||
# Retired `run`/`call --json` argv: the only accepted `--json` is the `check`
|
||||
# diagnostic summary. Heuristic: find the enclosing Rust function; argv
|
||||
# builders for check-like commands are the only permitted owners.
|
||||
while IFS= read -r -d '' file; do
|
||||
while IFS=: read -r line_no text; do
|
||||
[[ -z "$line_no" ]] && continue
|
||||
case "$text" in
|
||||
//*|///*) continue ;;
|
||||
esac
|
||||
fn="$(awk -v target="$line_no" '
|
||||
/^[[:space:]]*(pub[[:space:]]+)?(async[[:space:]]+)?fn[[:space:]]+[A-Za-z0-9_]+/ {
|
||||
s=$0; sub(/^[[:space:]]*(pub[[:space:]]+)?(async[[:space:]]+)?fn[[:space:]]+/, "", s); sub(/[^A-Za-z0-9_].*/, "", s); current=s
|
||||
}
|
||||
NR==target { print current; exit }
|
||||
' "$file")"
|
||||
case "$fn" in
|
||||
*check*|*diagnostic*|*analysis*) ;;
|
||||
*) hit "retired run/call --json argv" "$file:$line_no: $text (enclosing fn: ${fn:-<top-level>})" ;;
|
||||
esac
|
||||
done < <(awk '
|
||||
/^[[:space:]]*#\[cfg\(test\)\]/ { intests = 1 }
|
||||
intests { next }
|
||||
/--json/ { print FNR ":" $0 }
|
||||
' "$file" || true)
|
||||
done < <(src_files)
|
||||
|
||||
# ------------------------------------------------------------- tool.json ----
|
||||
if grep -qE '"compatibility"' tool.json; then
|
||||
while IFS=: read -r line text; do
|
||||
hit "tool.json compatibility field" "tool.json:$line: $text"
|
||||
done < <(grep -nE '"compatibility"' tool.json)
|
||||
fi
|
||||
if grep -qE 'record_version|PROTOCOL_ANALYSIS|PROTOCOL_TRACE|TOOL_PROTOCOL' tool.json; then
|
||||
while IFS=: read -r line text; do
|
||||
hit "legacy tool metadata" "tool.json:$line: $text"
|
||||
done < <(grep -nE 'record_version|PROTOCOL_ANALYSIS|PROTOCOL_TRACE|TOOL_PROTOCOL' tool.json)
|
||||
fi
|
||||
|
||||
# -------------------------------------------------------- current docs ------
|
||||
current_docs=(
|
||||
README.md
|
||||
COMPATIBILITY.md
|
||||
docs/STATUS.md
|
||||
docs/ACCEPTANCE.md
|
||||
docs/CONFORMANCE.md
|
||||
docs/audits/protocol-contract-0002.md
|
||||
docs/architecture/observation-v1-and-analysis-v3.md
|
||||
docs/decisions/0012-rc4-current-contracts.md
|
||||
docs/design/complete-reader.md
|
||||
docs/design/state-matrix.md
|
||||
docs/design/visual-tokens.md
|
||||
docs/evidence/README.md
|
||||
)
|
||||
doc_pattern='Analysis v2|Trace v2|Execution Events|--trace-file|--event-stream|PROTOCOL_ANALYSIS|PROTOCOL_TRACE|TOOL_PROTOCOL|3\.0\.0-beta|>=3\.0\.0-rc\.2'
|
||||
run_json_pattern='run[^.。\n]{0,20}--json|call[^.。\n]{0,20}--json|--json[^.。\n]{0,20}run|--json[^.。\n]{0,20}call'
|
||||
for doc in "${current_docs[@]}"; do
|
||||
if [[ ! -f "$doc" ]]; then
|
||||
hit "missing current doc" "$doc"
|
||||
continue
|
||||
fi
|
||||
while IFS=: read -r line text; do
|
||||
[[ -n "$line" ]] && hit "legacy contract in current doc" "$doc:$line: $text"
|
||||
done < <(grep -nE "$doc_pattern" "$doc" || true)
|
||||
while IFS=: read -r line text; do
|
||||
[[ -n "$line" ]] && hit "retired run --json in current doc" "$doc:$line: $text"
|
||||
done < <(grep -nE "$run_json_pattern" "$doc" || true)
|
||||
done
|
||||
|
||||
if [[ "$fail" -ne 0 ]]; then
|
||||
cat >&2 <<'EOF'
|
||||
|
||||
check-no-legacy: FAIL
|
||||
Remove the retired reference from the current tree (delete the code path,
|
||||
rewrite the doc claim, or move history into CHANGELOG.md under its explicit
|
||||
`## History` heading). Do not add a compatibility branch, fallback decoder or
|
||||
migration shim: the rc.4 baseline has exactly one current contract per
|
||||
boundary. Historical evidence under docs/evidence/** and historical ADRs are
|
||||
exempt and untouched.
|
||||
Current baseline: marqdo 3.0.0-rc.4, Analysis revision 3 (ADR-0069),
|
||||
Observation revision 1, CLI Tool revision 1.
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "check-no-legacy: PASS (0 retired references in src/, tool.json and current docs; rc.4 baseline)"
|
||||
Executable
+261
@@ -0,0 +1,261 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Machine checks for the current observation/analysis contracts (G06/G07/G08).
|
||||
|
||||
These probes use only the frozen CLI's public interface and assert the exact
|
||||
contract marqdo-view 0.3.0 consumes. They do not run the View binary; View-side
|
||||
regressions are covered by the cargo test suite owned by the migration.
|
||||
|
||||
Usage:
|
||||
MARQDO_BIN=/abs/path/marqdo python3 scripts/check-observation.py stream-snapshot
|
||||
MARQDO_BIN=/abs/path/marqdo python3 scripts/check-observation.py binding
|
||||
MARQDO_BIN=/abs/path/marqdo python3 scripts/check-observation.py fail-closed
|
||||
"""
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
BIN = pathlib.Path(os.environ.get("MARQDO_BIN", "")).resolve()
|
||||
|
||||
|
||||
def fail(message):
|
||||
print(f"observation probe: FAIL: {message}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def run(args, cwd, expect=0):
|
||||
result = subprocess.run([str(BIN), *args], cwd=cwd, capture_output=True, text=True)
|
||||
if result.returncode != expect:
|
||||
fail(f"{' '.join(args)} exited {result.returncode}, expected {expect}\n{result.stderr}")
|
||||
return result
|
||||
|
||||
|
||||
def sha256_prefixed(data):
|
||||
return "sha256:" + hashlib.sha256(data).hexdigest()
|
||||
|
||||
|
||||
def workspace():
|
||||
dist = ROOT / "dist"
|
||||
dist.mkdir(exist_ok=True)
|
||||
directory = tempfile.TemporaryDirectory(prefix="observation-contract-", dir=dist)
|
||||
root = pathlib.Path(directory.name)
|
||||
for source in (
|
||||
"examples/function-params.mq.md",
|
||||
"examples/branch-loop.mq.md",
|
||||
"examples/knowledge-only.mq.md",
|
||||
):
|
||||
shutil.copy(ROOT / source, root / pathlib.Path(source).name)
|
||||
return directory, root
|
||||
|
||||
|
||||
def load_snapshot(path):
|
||||
snapshot = json.loads(pathlib.Path(path).read_text())
|
||||
if snapshot.get("schema") != "marqdo.observation" or snapshot.get("schema_version") != 1:
|
||||
fail(f"not an Observation v1 snapshot: {path}")
|
||||
events = snapshot["events"]
|
||||
run_id = snapshot["run"]["id"]
|
||||
if [event["seq"] for event in events] != list(range(len(events))):
|
||||
fail("snapshot seq is not zero-based contiguous")
|
||||
if any(event["run_id"] != run_id for event in events):
|
||||
fail("snapshot mixes run_id values")
|
||||
return snapshot, events
|
||||
|
||||
|
||||
def stream_snapshot():
|
||||
directory, root = workspace()
|
||||
with directory:
|
||||
stream = run(
|
||||
["call", "function-params.mq.md", "double", "--arg", "n=5", "--mode", "pure",
|
||||
"--output", "jsonl", "--observation-file", "obs.json"],
|
||||
root,
|
||||
).stdout
|
||||
lines = [json.loads(line) for line in stream.splitlines() if line.strip()]
|
||||
snapshot, events = load_snapshot(root / "obs.json")
|
||||
if lines != events:
|
||||
fail("JSONL stream and atomic snapshot disagree for the same execution")
|
||||
if snapshot["run"]["status"] != "ok":
|
||||
fail(f"unexpected run.status {snapshot['run']['status']}")
|
||||
if events[-1]["kind"] != "run.completed":
|
||||
fail("terminal event is not run.completed")
|
||||
if events[-1]["payload"]["value"] != {"type": "int", "decimal": "10"}:
|
||||
fail("call result is not Int 10")
|
||||
print("stream/snapshot equivalence: PASS (%d events, one run_id, contiguous seq, one terminal)" % len(events))
|
||||
|
||||
truncated_out = run(
|
||||
["run", "branch-loop.mq.md", "--mode", "pure", "--observe-max-events", "2",
|
||||
"--output", "jsonl", "--observation-file", "truncated.json"],
|
||||
root,
|
||||
).stdout
|
||||
truncated_lines = [json.loads(line) for line in truncated_out.splitlines() if line.strip()]
|
||||
truncated_snapshot, truncated_events = load_snapshot(root / "truncated.json")
|
||||
if truncated_lines != truncated_events:
|
||||
fail("truncated stream and snapshot disagree")
|
||||
truncated = truncated_snapshot["capture"]["truncated"]
|
||||
if not truncated or truncated.get("reason") != "event_budget":
|
||||
fail("missing observation.truncated capture metadata")
|
||||
if truncated_events[-1]["kind"] != "run.completed":
|
||||
fail("truncated run has no truthful terminal")
|
||||
print("observation truncation: PASS (capture.truncated=%s, terminal=%s)"
|
||||
% (truncated.get("reason"), truncated_events[-1]["kind"]))
|
||||
|
||||
|
||||
def span_ok(span, length):
|
||||
return (
|
||||
isinstance(span, dict)
|
||||
and isinstance(span.get("start"), int)
|
||||
and isinstance(span.get("end"), int)
|
||||
and 0 <= span["start"] <= span["end"] <= length
|
||||
)
|
||||
|
||||
|
||||
def binding():
|
||||
directory, root = workspace()
|
||||
with directory:
|
||||
run(["check", "function-params.mq.md", "--emit", "analysis.json", "--json"], root)
|
||||
analysis_bytes = (root / "analysis.json").read_bytes()
|
||||
analysis = json.loads(analysis_bytes)
|
||||
if analysis.get("schema") != "marqdo.analysis" or analysis.get("schema_version") != 3:
|
||||
fail("check --emit did not produce Analysis revision 3")
|
||||
expected_digest = sha256_prefixed(analysis_bytes)
|
||||
module = analysis["modules"][0]
|
||||
source = module["source"].encode("utf-8")
|
||||
if module["source_digest"] != hashlib.sha256(source).hexdigest():
|
||||
fail("module.source_digest does not hash the exact module.source bytes")
|
||||
run(
|
||||
["call", "function-params.mq.md", "double", "--arg", "n=5", "--mode", "pure",
|
||||
"--output", "jsonl", "--observation-file", "obs.json"],
|
||||
root,
|
||||
)
|
||||
snapshot, events = load_snapshot(root / "obs.json")
|
||||
started = next((event for event in events if event["kind"] == "run.started"), None)
|
||||
if started is None:
|
||||
fail("no run.started event")
|
||||
observed = started["payload"]["source"]
|
||||
if observed.get("analysis_digest") != expected_digest:
|
||||
fail("run.started analysis_digest does not bind the exact check --emit bytes")
|
||||
if observed.get("root_id") != analysis["project"]["root_id"]:
|
||||
fail("run.started root_id does not match Analysis project.root_id")
|
||||
if snapshot["run"]["source"] != observed:
|
||||
fail("snapshot run.source disagrees with run.started source")
|
||||
module_ids = {candidate["id"] for candidate in analysis["modules"]}
|
||||
for event in events:
|
||||
payload = event["payload"]
|
||||
if payload.get("module_id") is not None and payload["module_id"] not in module_ids:
|
||||
fail(f"event {event['seq']} references unknown module_id")
|
||||
span = payload.get("span")
|
||||
if span is not None and not span_ok(span, len(source)):
|
||||
fail(f"event {event['seq']} span is outside the exact source bytes")
|
||||
# A source edit must invalidate the binding: a new check emits a different digest.
|
||||
original = (root / "function-params.mq.md").read_bytes()
|
||||
(root / "function-params.mq.md").write_bytes(original + b"\nsource changed\n")
|
||||
result = subprocess.run(
|
||||
[str(BIN), "check", "function-params.mq.md", "--emit", "analysis-edited.json", "--json"],
|
||||
cwd=root, capture_output=True, text=True,
|
||||
)
|
||||
(root / "function-params.mq.md").write_bytes(original)
|
||||
if result.returncode == 0:
|
||||
edited = (root / "analysis-edited.json").read_bytes()
|
||||
if sha256_prefixed(edited) == expected_digest:
|
||||
fail("source edit did not change the Analysis digest")
|
||||
print("exact Analysis binding: PASS (digest=%s, root/module/span checks, source edit invalidates)" % expected_digest)
|
||||
|
||||
|
||||
def fail_closed():
|
||||
directory, root = workspace()
|
||||
with directory:
|
||||
cases = [
|
||||
(["run", "branch-loop.mq.md", "--mode", "pure", "--json"], "retired --json"),
|
||||
(["run", "branch-loop.mq.md", "--mode", "pure", "--trace-file", "x.json"], "retired --trace-file"),
|
||||
(["run", "branch-loop.mq.md", "--mode", "pure", "--event-stream", "jsonl"], "retired --event-stream"),
|
||||
]
|
||||
for args, label in cases:
|
||||
result = subprocess.run([str(BIN), *args], cwd=root, capture_output=True, text=True)
|
||||
if result.returncode != 2:
|
||||
fail(f"{label}: expected exit 2, got {result.returncode}")
|
||||
print(f"fail-closed {label}: PASS (exit 2, no fallback retry)")
|
||||
strict = subprocess.run(
|
||||
[str(BIN), "run", "branch-loop.mq.md", "--mode", "strict", "--output", "jsonl"],
|
||||
cwd=root, capture_output=True, text=True,
|
||||
)
|
||||
if strict.returncode != 2 or "strict.unsupported_grant" not in strict.stderr:
|
||||
fail(f"strict + jsonl: expected exit 2 strict.unsupported_grant, got {strict.returncode}: {strict.stderr}")
|
||||
print("fail-closed strict live destination: PASS (exit 2, strict.unsupported_grant)")
|
||||
|
||||
# Retired manifest fixture: used only to prove the current CLI rejects it.
|
||||
old = root / "old-tool"
|
||||
(old / "bin").mkdir(parents=True)
|
||||
(old / "bin" / "probe").write_text("#!/usr/bin/env bash\nexit 0\n")
|
||||
os.chmod(old / "bin" / "probe", 0o755)
|
||||
(old / "tool.json").write_text(json.dumps({
|
||||
"schema": "marqdo.cli-tool",
|
||||
"schema_version": 1,
|
||||
"name": "old-probe",
|
||||
"version": "0.2.0",
|
||||
"command": "old-probe",
|
||||
"entrypoint": "bin/probe",
|
||||
"compatibility": {"schema": "retired-fixture", "versions": ["fixture-only"]},
|
||||
}))
|
||||
env = {**os.environ, "MARQDO_TOOL_HOME": str(root / "tool-home")}
|
||||
legacy = subprocess.run(
|
||||
[str(BIN), "tool", "install", str(old / "tool.json")],
|
||||
cwd=root, capture_output=True, text=True, env=env,
|
||||
)
|
||||
if legacy.returncode == 0 or "compatibility" not in legacy.stderr:
|
||||
fail(f"retired tool.json was not rejected: {legacy.returncode} {legacy.stderr}")
|
||||
print("fail-closed retired tool.json: PASS (unknown field `compatibility`, no migrator)")
|
||||
|
||||
# Retired install record (record_version 1): dispatching the tool must
|
||||
# fail with a remove+reinstall instruction; there is no migrator.
|
||||
record_home = root / "record-home"
|
||||
record_dir = record_home / "view"
|
||||
record_dir.mkdir(parents=True)
|
||||
(record_dir / "record.json").write_text(json.dumps({
|
||||
"record_version": 1,
|
||||
"command": "view",
|
||||
"name": "marqdo-view",
|
||||
"version": "0.2.0",
|
||||
"entrypoint": "bin/marqdo-view",
|
||||
"bundle": [],
|
||||
"bundle_sha256": "0" * 64,
|
||||
"source": "retired-fixture",
|
||||
"schema_version": 1,
|
||||
"requires": {"api_revision": 1},
|
||||
}))
|
||||
retired_env = {
|
||||
**os.environ,
|
||||
"MARQDO_TOOL_HOME": str(record_home),
|
||||
"MARQDO_BIN": str(BIN),
|
||||
}
|
||||
retired = subprocess.run(
|
||||
[str(BIN), "view", "--version"],
|
||||
cwd=root, capture_output=True, text=True, env=retired_env,
|
||||
)
|
||||
message = retired.stderr + retired.stdout
|
||||
if retired.returncode == 0 or "reinstall" not in message:
|
||||
fail(f"retired record_version 1 was not rejected: {retired.returncode} {message}")
|
||||
print("fail-closed retired record_version 1: PASS (dispatch refused, remove+reinstall hint)")
|
||||
|
||||
|
||||
def main():
|
||||
if not BIN.is_file() or not os.access(BIN, os.X_OK):
|
||||
fail("set MARQDO_BIN to the unpacked frozen marqdo binary")
|
||||
if len(sys.argv) != 2:
|
||||
fail(__doc__)
|
||||
mode = sys.argv[1]
|
||||
if mode == "stream-snapshot":
|
||||
stream_snapshot()
|
||||
elif mode == "binding":
|
||||
binding()
|
||||
elif mode == "fail-closed":
|
||||
fail_closed()
|
||||
else:
|
||||
fail(f"unknown mode {mode}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+23
-6
@@ -1,11 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# Identity of the released CLI used by the RFC-VIEW-0002 acceptance gate.
|
||||
# Identity of the released CLI used by the marqdo-view 0.3.0 acceptance gate.
|
||||
#
|
||||
# The pinned release is the current public-contract baseline:
|
||||
# marqdo 3.0.0-rc.4 (Analysis v3 / ADR-0069, Observation v1, CLI Tool revision 1)
|
||||
# The script only downloads, unpacks and verifies the official archive; it never
|
||||
# rebuilds or modifies the CLI.
|
||||
set -euo pipefail
|
||||
|
||||
version=3.0.0-beta.1
|
||||
source_sha=2c7c4f31e7a388d3fcfa717a77067e696ed13854
|
||||
binary_sha=062cb56e226bee55c21d238e195920caa985e62bb3877ba7b07abcc04dc0fe3f
|
||||
archive_sha=507e4cd358f75f517433935ce90d5fc2eb5cecda4f19121a68b136c83b15f317
|
||||
version=3.0.0-rc.4
|
||||
source_sha=452e9a32bd9e40dba427d4180691c58bab74449e
|
||||
binary_sha=a7306962689c635445a59043971ea2eb09298e01feeee81f0ba07b1f3e10306e
|
||||
archive_sha=9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8
|
||||
artifact="marqdo-$version-x86_64-unknown-linux-gnu"
|
||||
root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
@@ -24,8 +29,20 @@ verify() {
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ "${1:-}" == "metadata" && $# -eq 1 ]]; then
|
||||
case "$1" in
|
||||
metadata)
|
||||
printf 'version=%s\n' "$version"
|
||||
printf 'source_sha=%s\n' "$source_sha"
|
||||
printf 'binary_sha=%s\n' "$binary_sha"
|
||||
printf 'archive_sha=%s\n' "$archive_sha"
|
||||
printf 'artifact=%s\n' "$artifact"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [[ $# != 2 ]]; then
|
||||
echo "usage: $0 fetch EMPTY_DIRECTORY | $0 verify /absolute/path/to/marqdo" >&2
|
||||
echo "usage: $0 fetch EMPTY_DIRECTORY | $0 verify /absolute/path/to/marqdo | $0 metadata" >&2
|
||||
exit 2
|
||||
fi
|
||||
case "$1" in
|
||||
|
||||
+22
-9
@@ -1,5 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerate committed Analysis v2 goldens from the frozen CLI release binary.
|
||||
# Regenerate committed Analysis v3 / Observation v1 goldens from the frozen CLI
|
||||
# release binary.
|
||||
#
|
||||
# The current public contracts have exactly one static source (`check --emit`
|
||||
# Analysis v3) and one runtime sequence (Observation v1, either `--output jsonl`
|
||||
# or the atomic `--observation-file` snapshot of the same execution).
|
||||
#
|
||||
# Usage: MARQDO_BIN=/abs/path/marqdo scripts/gen-golden.sh
|
||||
set -euo pipefail
|
||||
@@ -14,21 +19,29 @@ if [[ ! -x "$MARQDO_BIN" ]]; then
|
||||
fi
|
||||
echo "golden core sha256: $(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
|
||||
|
||||
out="tests/golden/analysis-v2"
|
||||
out="tests/golden/analysis-v3"
|
||||
mkdir -p "$out"
|
||||
"$MARQDO_BIN" check examples/mixed-modes/index.mq.md --emit "$out/mixed-modes.json"
|
||||
"$MARQDO_BIN" check examples/control-flow/index.mq.md --emit "$out/control-flow.json"
|
||||
"$MARQDO_BIN" check examples/tables-math/index.mq.md --emit "$out/tables-math.json"
|
||||
"$MARQDO_BIN" check examples/welcome/00-welcome.mq.md --emit "$out/welcome.json"
|
||||
# Trace v2 goldens come from the same frozen binary (pure mode, no grants).
|
||||
out_trace="tests/golden/trace-v2"
|
||||
mkdir -p "$out_trace"
|
||||
"$MARQDO_BIN" check examples/unicode-spans/index.mq.md --emit "$out/unicode-spans.json"
|
||||
"$MARQDO_BIN" check examples/unicode-spans/crlf.mq.md --emit "$out/unicode-spans-crlf.json"
|
||||
|
||||
# Observation v1 goldens come from the same frozen binary (pure mode, no grants).
|
||||
out_obs="tests/golden/observation-v1"
|
||||
mkdir -p "$out_obs"
|
||||
( cd examples/control-flow \
|
||||
&& "$MARQDO_BIN" run index.mq.md --mode pure --json --trace-file "$repo_root/$out_trace/control-flow.trace.json" > "$repo_root/$out_trace/control-flow.run.json" )
|
||||
&& "$MARQDO_BIN" run index.mq.md --mode pure --output jsonl --observation-file "$repo_root/$out_obs/control-flow.snapshot.json" \
|
||||
> "$repo_root/$out_obs/control-flow.jsonl" )
|
||||
( cd examples/control-flow \
|
||||
&& "$MARQDO_BIN" run index.mq.md --mode pure --json --trace-max-events 5 --trace-file "$repo_root/$out_trace/control-flow.truncated.trace.json" > "$repo_root/$out_trace/control-flow.truncated.run.json" )
|
||||
&& "$MARQDO_BIN" run index.mq.md --mode pure --observe-max-events 5 \
|
||||
--output jsonl --observation-file "$repo_root/$out_obs/control-flow.truncated.snapshot.json" \
|
||||
> "$repo_root/$out_obs/control-flow.truncated.jsonl" )
|
||||
if ( cd examples/mixed-modes \
|
||||
&& "$MARQDO_BIN" run index.mq.md --mode pure --json --trace-file "$repo_root/$out_trace/mixed-modes.arity.trace.json" > "$repo_root/$out_trace/mixed-modes.arity.run.json" ); then
|
||||
&& "$MARQDO_BIN" run index.mq.md --mode pure --output jsonl \
|
||||
--observation-file "$repo_root/$out_obs/mixed-modes.arity.snapshot.json" \
|
||||
> "$repo_root/$out_obs/mixed-modes.arity.jsonl" 2>/dev/null ); then
|
||||
echo "error: mixed-modes without params unexpectedly ran" >&2
|
||||
exit 1
|
||||
fi
|
||||
@@ -37,4 +50,4 @@ if "$MARQDO_BIN" check examples/diagnostics/index.mq.md --json >/dev/null 2>&1;
|
||||
echo "error: examples/diagnostics unexpectedly passed check" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "goldens: PASS"
|
||||
echo "goldens: PASS (Analysis v3 + Observation v1 stream/snapshot)"
|
||||
@@ -2,6 +2,10 @@
|
||||
# Install the built bundle with a frozen marqdo CLI into an isolated tool home,
|
||||
# then prove the command is served by this program (not by the Core).
|
||||
#
|
||||
# The frozen CLI is the current Tool revision 1 baseline: it injects
|
||||
# MARQDO_API_REVISION=1 and MARQDO_BIN only, with no legacy
|
||||
# MARQDO_PROTOCOL_* negotiation variables.
|
||||
#
|
||||
# Usage: MARQDO_BIN=/abs/path/marqdo scripts/install-smoke.sh [tool.json]
|
||||
set -euo pipefail
|
||||
|
||||
@@ -16,6 +20,19 @@ if [[ ! -x "$MARQDO_BIN" ]]; then
|
||||
fi
|
||||
before="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
|
||||
|
||||
# The packaged manifest must declare the current exact contracts.
|
||||
python3 - "$manifest" <<'PY'
|
||||
import json
|
||||
import sys
|
||||
|
||||
tool = json.load(open(sys.argv[1]))
|
||||
assert tool["schema"] == "marqdo.cli-tool", tool
|
||||
assert tool["schema_version"] == 1, tool
|
||||
assert "compatibility" not in tool, "retired compatibility field present"
|
||||
assert tool["requires"] == {"api_revision": 1, "analysis": 3, "observation": 1}, tool["requires"]
|
||||
print("manifest: PASS (revision 1 requires api_revision=1 analysis=3 observation=1)")
|
||||
PY
|
||||
|
||||
mkdir -p "$repo_root/dist"
|
||||
tool_home="$(mktemp -d "$repo_root/dist/smoke-tool-home.XXXXXX")"
|
||||
cleanup() {
|
||||
@@ -25,7 +42,7 @@ trap cleanup EXIT
|
||||
|
||||
export MARQDO_TOOL_HOME="$tool_home"
|
||||
"$MARQDO_BIN" tool install "$manifest" >/dev/null
|
||||
"$MARQDO_BIN" tool list | grep -q 'view'
|
||||
"$MARQDO_BIN" tool list | grep -q '^view '
|
||||
help="$("$MARQDO_BIN" view --help)"
|
||||
grep -q 'marqdo-view' <<<"$help"
|
||||
grep -q 'export' <<<"$help"
|
||||
@@ -33,10 +50,39 @@ grep -q 'verify' <<<"$help"
|
||||
version="$("$MARQDO_BIN" view --version)"
|
||||
grep -q 'marqdo-view' <<<"$version"
|
||||
|
||||
# Prove the current dispatch environment contract: the CLI injects
|
||||
# MARQDO_API_REVISION=1 (and MARQDO_BIN), never the retired negotiation vars.
|
||||
probe_dir="$tool_home/probe"
|
||||
mkdir -p "$probe_dir/bin"
|
||||
cat >"$probe_dir/bin/api-probe" <<'PROBE'
|
||||
#!/usr/bin/env bash
|
||||
printf 'MARQDO_API_REVISION=%s\n' "${MARQDO_API_REVISION:-<unset>}"
|
||||
printf 'MARQDO_BIN=%s\n' "${MARQDO_BIN:-<unset>}"
|
||||
printf 'retired=%s\n' "${MARQDO_PROTOCOL_ANALYSIS:-}${MARQDO_PROTOCOL_TRACE:-}${MARQDO_TOOL_PROTOCOL:-}"
|
||||
PROBE
|
||||
chmod 755 "$probe_dir/bin/api-probe"
|
||||
cat >"$probe_dir/tool.json" <<'PROBE_JSON'
|
||||
{
|
||||
"schema": "marqdo.cli-tool",
|
||||
"schema_version": 1,
|
||||
"name": "api-probe",
|
||||
"version": "0.0.1",
|
||||
"command": "api-probe",
|
||||
"entrypoint": "bin/api-probe",
|
||||
"requires": {"api_revision": 1}
|
||||
}
|
||||
PROBE_JSON
|
||||
"$MARQDO_BIN" tool install "$probe_dir/tool.json" >/dev/null
|
||||
probe="$("$MARQDO_BIN" api-probe)"
|
||||
grep -qx 'MARQDO_API_REVISION=1' <<<"$probe"
|
||||
grep -q '^MARQDO_BIN=/' <<<"$probe"
|
||||
grep -qx 'retired=' <<<"$probe"
|
||||
"$MARQDO_BIN" tool remove api-probe >/dev/null
|
||||
|
||||
after="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
|
||||
if [[ "$before" != "$after" ]]; then
|
||||
echo "error: frozen core binary changed during install smoke test" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "install-smoke: PASS (core sha256 $before unchanged, tool home $tool_home)"
|
||||
echo "install-smoke: PASS (view installed/dispatched, api_revision 1 injected, core sha256 $before unchanged, tool home $tool_home)"
|
||||
+19
-8
@@ -1,13 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build and assemble the Tool Protocol v1 release bundle.
|
||||
# Build and assemble the CLI Tool revision 1 release bundle for marqdo-view 0.3.0.
|
||||
#
|
||||
# Produces:
|
||||
# dist/marqdo-view/ stable bundle path (RFC §18)
|
||||
# dist/marqdo-view/ stable bundle path
|
||||
# dist/marqdo-view-<version>-<target>.tar.gz (+ .sha256)
|
||||
#
|
||||
# The bundle contains only the runtime binary, the manifest and the legal /
|
||||
# compatibility files. CSS/JS/images are compiled into the binary (ADR-0002),
|
||||
# release-note files. CSS/JS/images are compiled into the binary (ADR-0002),
|
||||
# so there is exactly one asset source for Live and Export.
|
||||
#
|
||||
# The current public contracts are exact: api_revision 1, Analysis 3 and
|
||||
# Observation 1. There is no version negotiation and no `compatibility` field.
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
@@ -67,6 +70,11 @@ import sys
|
||||
bundle = pathlib.Path(sys.argv[1])
|
||||
version, target, source_sha = sys.argv[2], sys.argv[3], sys.argv[4]
|
||||
tool = json.loads((bundle / 'tool.json').read_text())
|
||||
requires = tool.get('requires') or {}
|
||||
if 'compatibility' in tool:
|
||||
raise SystemExit('tool.json must not contain a compatibility field')
|
||||
if requires != {'api_revision': 1, 'analysis': 3, 'observation': 1}:
|
||||
raise SystemExit('tool.json requires must be exactly api_revision 1 / analysis 3 / observation 1')
|
||||
files = []
|
||||
for path in sorted(bundle.rglob('*')):
|
||||
if not path.is_file():
|
||||
@@ -88,12 +96,15 @@ info = {
|
||||
'command': 'view',
|
||||
'target': target,
|
||||
'source_sha': source_sha,
|
||||
'compatibility': {
|
||||
'marqdo': '>=3.0.0-beta.1,<4.0.0',
|
||||
'analysis': tool['compatibility']['analysis'],
|
||||
'trace': [2],
|
||||
'tool_protocol': 1,
|
||||
'requires': {
|
||||
'api_revision': 1,
|
||||
'analysis': 3,
|
||||
'observation': 1,
|
||||
},
|
||||
'release': {
|
||||
'product_range': '>=3.0.0-rc.3,<4.0.0',
|
||||
'markdown_profile': 'marqdo.md.v1',
|
||||
'platform': 'linux-x86_64-glibc2.39',
|
||||
},
|
||||
'files': files,
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Browser acceptance for the Live reader: real Chromium, real frozen core.
|
||||
# Browser acceptance for the Live reader: real Chromium, real frozen core
|
||||
# pinned to marqdo 3.0.0-rc.4 (Analysis revision 3, Observation revision 1).
|
||||
#
|
||||
# Usage:
|
||||
# MARQDO_BIN=/abs/path/marqdo scripts/test-browser.sh
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""HTTP and ZIP acceptance against an unmodified RC.2 release binary."""
|
||||
"""HTTP and ZIP acceptance against the frozen rc.4 release binary.
|
||||
|
||||
The View consumes Observation v1 (`--output jsonl` / `--observation-file`);
|
||||
there is no trace file or legacy JSON run envelope.
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
import http.cookiejar
|
||||
@@ -67,7 +71,7 @@ def verify_zip(payload, destination, expected_digest):
|
||||
assert manifest["execution"]["source_verified"] and manifest["execution"]["status"] == "succeeded"
|
||||
assert manifest["execution"]["parameters"] == "omitted"
|
||||
assert manifest["source"]["document"] == "index.mq.md"
|
||||
assert manifest["execution"]["core_protocol"] == {"analysis": 3, "trace": 2, "events": 1}
|
||||
assert manifest["execution"]["contracts"] == {"api_revision": 1, "analysis": 3, "observation": 1}
|
||||
for entry in manifest["files"] + manifest["assets"]:
|
||||
data = archive.read(entry["path"])
|
||||
assert sha(data) == entry["sha256"] and len(data) == entry["size"]
|
||||
@@ -104,11 +108,12 @@ def check(root):
|
||||
"import os, subprocess, sys, time\n"
|
||||
f"core, count = {str(CORE)!r}, {str(count)!r}\n"
|
||||
"if sys.argv[1] in ('run', 'call'):\n"
|
||||
" assert '--event-stream' in sys.argv and '--json' not in sys.argv\n"
|
||||
" assert sys.argv[sys.argv.index('--output') + 1] == 'jsonl' and '--observation-file' in sys.argv\n"
|
||||
" assert '--json' not in sys.argv and '--trace-file' not in sys.argv\n"
|
||||
" with open(count, 'a') as f: f.write(sys.argv[1]+'\\n')\n"
|
||||
" if sys.argv[1] == 'call' and sys.argv[3] == 'write_markup':\n"
|
||||
" result = subprocess.run([core, *sys.argv[1:]], check=False)\n"
|
||||
" os.unlink(sys.argv[sys.argv.index('--trace-file') + 1])\n"
|
||||
" os.unlink(sys.argv[sys.argv.index('--observation-file') + 1])\n"
|
||||
" sys.exit(result.returncode)\n"
|
||||
" if sys.argv[1] == 'call' and sys.argv[3] == 'scan': time.sleep(2)\n"
|
||||
"os.execv(core, [core, *sys.argv[1:]])\n"
|
||||
@@ -158,7 +163,7 @@ def check(root):
|
||||
|
||||
run_id, terminal = observe(submit("write_output", "one"))
|
||||
assert terminal["state"] == "succeeded" and terminal["result"]["stdout"] == "4\n", terminal
|
||||
assert terminal["result"]["trace_status"] == "verified"
|
||||
assert terminal["result"]["observation_status"] == "verified"
|
||||
assert count.read_text().splitlines() == ["call"]
|
||||
selection = {
|
||||
"schema": "marqdo.view-static-export-request",
|
||||
@@ -167,7 +172,7 @@ def check(root):
|
||||
"document": "index.mq.md",
|
||||
"analysis_digest": digest,
|
||||
"scope": "document",
|
||||
"include": {"result_value": True, "stdout": True, "stderr": False, "arguments": False, "trace_summary": True},
|
||||
"include": {"result_value": True, "stdout": True, "stderr": False, "arguments": False, "observation_summary": True},
|
||||
"confirm_sensitive_output": True,
|
||||
"client_export_request_id": "zip-one",
|
||||
}
|
||||
@@ -263,16 +268,16 @@ def check(root):
|
||||
assert json.loads(archive.read("manifest.json"))["execution"]["status"] == "failed"
|
||||
|
||||
text_id, text = observe(submit("write_markup", "markup"))
|
||||
assert text["state"] == "succeeded" and text["result"]["trace_status"] == "unavailable", text
|
||||
assert text["state"] == "succeeded" and text["result"]["observation_status"] == "unavailable", text
|
||||
assert text["result"]["stdout"] == attack_text.decode()
|
||||
text_zip, _ = post(browser, base, "/api/exports", token, {**selection, "run_id": text_id})
|
||||
with zipfile.ZipFile(io.BytesIO(text_zip)) as archive:
|
||||
html = archive.read("index.html").decode()
|
||||
assert "<script>" not in html and "<script>bad()" in html
|
||||
assert json.loads(archive.read("manifest.json"))["execution"]["trace_status"] == "unavailable"
|
||||
assert json.loads(archive.read("manifest.json"))["execution"]["observation_status"] == "unavailable"
|
||||
first, headers = post(browser, base, "/api/exports", token, selection)
|
||||
verify_zip(first, None, headers["X-Marqdo-Manifest-SHA256"])
|
||||
print("active/cancelled export denied, verified failure gated, stdout escaped, missing Trace separate")
|
||||
print("active/cancelled export denied, verified failure gated, stdout escaped, missing Observation separate")
|
||||
print("selected IDs remain isolated, tampering detected, oversized request denied, failed and aborted packages cleaned")
|
||||
calls = count.read_text().splitlines()
|
||||
assert calls == ["call"] * 4, calls
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Contract-focused gate: formatting, lints, all tests, Tool v1 install smoke,
|
||||
# static verify and static export against the frozen core. No browser.
|
||||
# Contract-focused gate: formatting, lints, all tests, CLI Tool revision 1
|
||||
# install smoke, static verify and static export against the frozen core.
|
||||
# No browser. Current contracts: Analysis revision 3, Observation revision 1.
|
||||
#
|
||||
# Usage: MARQDO_BIN=/abs/path/marqdo scripts/test-contract.sh
|
||||
set -euo pipefail
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Static export acceptance: pure read-only, offline assets, safe paths.
|
||||
# One renderer for Live and Export; no execution, no network.
|
||||
#
|
||||
# Usage: MARQDO_BIN=/abs/path/marqdo scripts/test-export.sh
|
||||
set -euo pipefail
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# RFC-VIEW-0002 §13.4 / §6 / §10.3: opening, searching, switching and exporting
|
||||
# must never execute a document. Uses the unsafe-side-effect fixture and checks
|
||||
# Opening, searching, switching and exporting must never execute a document
|
||||
# (zero-execution baseline, current rc.4 contracts). Uses the unsafe-side-effect fixture and checks
|
||||
# source/lock hashes plus the absence of any write sentinel around the whole
|
||||
# read-only operation set.
|
||||
#
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Prove a frozen marqdo release binary is byte-identical before and after a
|
||||
# command sequence (RFC-VIEW-0002 §2 / §9.4 / §10.2).
|
||||
# command sequence (issue #4/#5 release evidence).
|
||||
#
|
||||
# Usage:
|
||||
# scripts/verify-frozen-cli.sh /abs/path/marqdo [-- EXPECTED_SHA256] -- CMD [ARGS...]
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ use std::path::PathBuf;
|
||||
#[command(
|
||||
name = "marqdo-view",
|
||||
version,
|
||||
about = "Read .mq.md documents as documents: static Analysis v2, optional explicit run Trace v2",
|
||||
long_about = "Marqdo View renders the original Markdown and attaches verified Analysis v2 facts. \
|
||||
about = "Read .mq.md documents as documents: static Analysis v3, optional explicit Observation v1",
|
||||
long_about = "Marqdo View renders the original Markdown and attaches verified Analysis v3 facts. \
|
||||
Running is never implicit: it requires an explicit user action. \
|
||||
Export is always a pure read-only operation.",
|
||||
disable_help_subcommand = true,
|
||||
|
||||
+161
-196
@@ -1,9 +1,11 @@
|
||||
//! The only way View talks to the frozen CLI.
|
||||
//!
|
||||
//! Invariants (RFC-VIEW-0001 §4.2, §10.3, §14.1):
|
||||
//! Invariants:
|
||||
//! * absolute `MARQDO_BIN`, argv arrays, never `sh -c`, never shell strings;
|
||||
//! * `check --emit` is the only static channel; `run --trace-file --json` the
|
||||
//! only dynamic one; private Core IR dumps are never used;
|
||||
//! * `check --emit` is the only static channel; `run`/`call --output jsonl`
|
||||
//! (optionally with `--observation-file`) is the only dynamic channel, and
|
||||
//! both dynamic destinations come from the same execution;
|
||||
//! * private Core IR dumps, second parsers and protocol probing are never used;
|
||||
//! * stdout/stderr/exit status are handled separately; a stderr JSON blob is
|
||||
//! never promoted to a successful Analysis;
|
||||
//! * temporary artifacts live in a private 0700 directory and are removed on
|
||||
@@ -24,14 +26,18 @@ pub const DEFAULT_RUN_TIMEOUT: Duration = Duration::from_secs(120);
|
||||
/// Default View-level wall clock cap for one Core `check`.
|
||||
pub const DEFAULT_CHECK_TIMEOUT: Duration = Duration::from_secs(120);
|
||||
|
||||
const ENV_MARQDO_BIN: &str = "MARQDO_BIN";
|
||||
/// Bounded observation budget sent on every explicit run. The protocol
|
||||
/// expresses exhaustion through `observation.truncated`; View never silently
|
||||
/// drops or amplifies events itself.
|
||||
pub const DEFAULT_OBSERVE_MAX_EVENTS: u64 = 10_000;
|
||||
pub const DEFAULT_OBSERVE_MAX_BYTES: u64 = 4_194_304;
|
||||
pub const DEFAULT_OBSERVE_MAX_VALUE_BYTES: u64 = 256;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum SandboxMode {
|
||||
Pure,
|
||||
Project,
|
||||
Strict,
|
||||
}
|
||||
|
||||
impl SandboxMode {
|
||||
@@ -39,7 +45,6 @@ impl SandboxMode {
|
||||
match self {
|
||||
SandboxMode::Pure => "pure",
|
||||
SandboxMode::Project => "project",
|
||||
SandboxMode::Strict => "strict",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,14 +64,13 @@ pub struct Grants {
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct CheckOptions {
|
||||
/// `--refs` also validates Markdown link targets; it is a stricter check
|
||||
/// and may fail where plain syntax succeeds.
|
||||
/// and its artifact must never be used as the Observation binding input.
|
||||
pub refs: bool,
|
||||
pub timeout: Option<Duration>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RunOptions {
|
||||
pub event_stream: bool,
|
||||
pub mode: SandboxMode,
|
||||
pub grants: Grants,
|
||||
pub fuel: Option<u64>,
|
||||
@@ -74,14 +78,19 @@ pub struct RunOptions {
|
||||
pub max_output: Option<u64>,
|
||||
pub timeout_seconds: Option<u64>,
|
||||
pub view_timeout: Option<Duration>,
|
||||
pub trace_max_events: Option<u64>,
|
||||
pub trace_max_bytes: Option<u64>,
|
||||
pub observe_max_events: u64,
|
||||
pub observe_max_bytes: u64,
|
||||
pub observe_max_value_bytes: u64,
|
||||
/// Explicit value selection. Empty by default: View never requests values
|
||||
/// unless the user opts in (and Text additionally needs a second consent).
|
||||
pub observe_variables: Vec<String>,
|
||||
pub observe_parameters: Vec<String>,
|
||||
pub observe_text_values: bool,
|
||||
}
|
||||
|
||||
impl Default for RunOptions {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
event_stream: false,
|
||||
mode: SandboxMode::Pure,
|
||||
grants: Grants::default(),
|
||||
fuel: None,
|
||||
@@ -89,8 +98,12 @@ impl Default for RunOptions {
|
||||
max_output: None,
|
||||
timeout_seconds: None,
|
||||
view_timeout: Some(DEFAULT_RUN_TIMEOUT),
|
||||
trace_max_events: None,
|
||||
trace_max_bytes: None,
|
||||
observe_max_events: DEFAULT_OBSERVE_MAX_EVENTS,
|
||||
observe_max_bytes: DEFAULT_OBSERVE_MAX_BYTES,
|
||||
observe_max_value_bytes: DEFAULT_OBSERVE_MAX_VALUE_BYTES,
|
||||
observe_variables: Vec::new(),
|
||||
observe_parameters: Vec::new(),
|
||||
observe_text_values: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,13 +114,13 @@ pub struct CheckOutput {
|
||||
pub analysis_bytes: Vec<u8>,
|
||||
/// Lowercase hex SHA-256 of `analysis_bytes`.
|
||||
pub analysis_sha256: String,
|
||||
/// Prefixed digest (`sha256:...`) for comparison with Trace v2.
|
||||
/// Prefixed digest (`sha256:...`) used by the Observation binding.
|
||||
pub analysis_digest: String,
|
||||
pub stdout: String,
|
||||
pub stderr: String,
|
||||
}
|
||||
|
||||
/// One compile diagnostic from `check --json`, normalized so no absolute
|
||||
/// One check diagnostic from `check --json`, normalized so no absolute
|
||||
/// machine path can leak into pages, exports or logs.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct RawCheckDiagnostic {
|
||||
@@ -128,7 +141,7 @@ pub struct RawCheckDiagnostic {
|
||||
}
|
||||
|
||||
/// Result of one `check` invocation. A failed check is **not** an I/O error:
|
||||
/// the prose stays readable and diagnostics must be shown (RFC §12.3).
|
||||
/// the prose stays readable and diagnostics must be shown.
|
||||
#[derive(Debug)]
|
||||
pub struct CheckResponse {
|
||||
pub success: bool,
|
||||
@@ -138,65 +151,39 @@ pub struct CheckResponse {
|
||||
pub stderr: String,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RunOutput {
|
||||
/// Exactly one JSON document emitted on stdout by the Core.
|
||||
pub json: serde_json::Value,
|
||||
pub stdout: String,
|
||||
pub stderr: String,
|
||||
pub exit_code: i32,
|
||||
/// Raw Trace v2 bytes when the Core wrote them (even for a failed run).
|
||||
pub trace_bytes: Option<Vec<u8>>,
|
||||
pub trace_sha256: Option<String>,
|
||||
}
|
||||
|
||||
pub use crate::scratch::ScratchDir;
|
||||
|
||||
/// Negotiated public-client for one frozen core binary.
|
||||
/// The public client for one frozen core binary.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CoreClient {
|
||||
bin: PathBuf,
|
||||
protocol_env: ProtocolEnv,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
struct ProtocolEnv {
|
||||
tool: Option<String>,
|
||||
analysis: Option<String>,
|
||||
trace: Option<String>,
|
||||
api_revision: Option<String>,
|
||||
}
|
||||
|
||||
impl CoreClient {
|
||||
/// Build a client from `--marqdo-bin` (development) or `MARQDO_BIN`
|
||||
/// (installed Tool Protocol). Never guesses a `PATH` binary: a wrong
|
||||
/// version must fail loudly, not silently.
|
||||
/// (installed Tool). Never guesses a `PATH` binary: a wrong version must
|
||||
/// fail loudly, not silently.
|
||||
pub fn from_env(explicit: Option<&Path>) -> ViewResult<Self> {
|
||||
let bin = locate_bin(explicit)?;
|
||||
Self::with_bin(bin)
|
||||
}
|
||||
|
||||
/// Construct from an explicit binary path, still reading any negotiated
|
||||
/// protocol environment. Useful for `--marqdo-bin` and integration tests;
|
||||
/// production dispatch should prefer [`CoreClient::from_env`].
|
||||
/// Construct from an explicit binary path, still reading the injected API
|
||||
/// revision expectation. Useful for `--marqdo-bin` and integration tests.
|
||||
pub fn with_bin(bin: impl Into<PathBuf>) -> ViewResult<Self> {
|
||||
let bin = validate_bin(&bin.into(), "core binary")?;
|
||||
Ok(Self {
|
||||
bin,
|
||||
protocol_env: ProtocolEnv {
|
||||
tool: std::env::var(tool_v1::ENV_TOOL_PROTOCOL).ok(),
|
||||
analysis: std::env::var(tool_v1::ENV_PROTOCOL_ANALYSIS).ok(),
|
||||
trace: std::env::var(tool_v1::ENV_PROTOCOL_TRACE).ok(),
|
||||
},
|
||||
})
|
||||
let api_revision = std::env::var(tool_v1::ENV_MARQDO_API_REVISION).ok();
|
||||
tool_v1::validate_api_revision_env(api_revision.as_deref())?;
|
||||
Ok(Self { bin, api_revision })
|
||||
}
|
||||
|
||||
/// Test-only constructor with an explicit binary and no environment
|
||||
/// negotiation input.
|
||||
/// Test-only constructor with no injected environment expectation.
|
||||
#[cfg(test)]
|
||||
pub fn for_test(bin: impl Into<PathBuf>) -> Self {
|
||||
Self {
|
||||
bin: bin.into(),
|
||||
protocol_env: ProtocolEnv::default(),
|
||||
api_revision: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,15 +191,15 @@ impl CoreClient {
|
||||
&self.bin
|
||||
}
|
||||
|
||||
/// Run `--version`, validate the product range and any negotiated protocol
|
||||
/// environment variables. A missing Development-mode env is allowed; an
|
||||
/// unknown major is a hard error.
|
||||
pub fn api_revision(&self) -> Option<&str> {
|
||||
self.api_revision.as_deref()
|
||||
}
|
||||
|
||||
/// Run `--version`, validate the product range and the injected API
|
||||
/// revision. A missing Development-mode environment is allowed; an
|
||||
/// unknown revision is a hard error.
|
||||
pub fn negotiate(&self) -> ViewResult<CoreVersion> {
|
||||
tool_v1::negotiate_protocol_env(
|
||||
self.protocol_env.tool.as_deref(),
|
||||
self.protocol_env.analysis.as_deref(),
|
||||
self.protocol_env.trace.as_deref(),
|
||||
)?;
|
||||
tool_v1::validate_api_revision_env(self.api_revision.as_deref())?;
|
||||
let output = self.execute(
|
||||
&[OsString::from("--version")],
|
||||
&std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")),
|
||||
@@ -232,7 +219,7 @@ impl CoreClient {
|
||||
if !tool_v1::product_is_compatible(&version.version) {
|
||||
return Err(ViewError::ProtocolIncompatible {
|
||||
detail: format!(
|
||||
"core {} is outside the supported range {}",
|
||||
"core {} is outside the supported range {}; install the current rc.3+ core",
|
||||
version.version,
|
||||
tool_v1::PRODUCT_RANGE
|
||||
),
|
||||
@@ -241,9 +228,11 @@ impl CoreClient {
|
||||
Ok(version)
|
||||
}
|
||||
|
||||
/// `check --json --emit`. On success the exact Analysis v2 bytes are
|
||||
/// returned; on failure the structured diagnostics are returned without
|
||||
/// any absolute path. Only spawn/timeout/IO failures are hard errors.
|
||||
/// `check --json --emit`. `--json` only selects the diagnostic summary on
|
||||
/// stdout; it does not change the emitted Analysis bytes. On success the
|
||||
/// exact Analysis bytes are returned; on failure the structured
|
||||
/// diagnostics are returned without any absolute path. Only
|
||||
/// spawn/timeout/IO failures are hard errors.
|
||||
pub fn check(
|
||||
&self,
|
||||
project: &Project,
|
||||
@@ -320,62 +309,6 @@ impl CoreClient {
|
||||
})
|
||||
}
|
||||
|
||||
/// `run --trace-file --json`, only after an explicit user confirmation in
|
||||
/// the calling layer. Returns the CLI JSON document and raw Trace bytes.
|
||||
pub fn run(
|
||||
&self,
|
||||
project: &Project,
|
||||
relative: &SafeRelativePath,
|
||||
options: &RunOptions,
|
||||
) -> ViewResult<RunOutput> {
|
||||
let entry = project.absolute_for(relative)?;
|
||||
let scratch = ScratchDir::create("run")?;
|
||||
let trace_path = scratch.file("trace.json");
|
||||
let args = build_run_args(&entry, &trace_path, options);
|
||||
let output = self.execute(
|
||||
&args,
|
||||
project.root(),
|
||||
options.view_timeout.unwrap_or(DEFAULT_RUN_TIMEOUT),
|
||||
)?;
|
||||
|
||||
let json: serde_json::Value =
|
||||
serde_json::from_slice(&output.stdout_bytes).map_err(|err| ViewError::Io {
|
||||
detail: format!(
|
||||
"`marqdo run --json` did not emit exactly one JSON document: {err}; stderr: {}",
|
||||
summarize_stderr(&output.stderr)
|
||||
),
|
||||
})?;
|
||||
if !json.is_object() {
|
||||
return Err(ViewError::Io {
|
||||
detail: "`marqdo run --json` emitted a non-object JSON document".to_string(),
|
||||
});
|
||||
}
|
||||
let trace_bytes = match std::fs::read(&trace_path) {
|
||||
Ok(bytes) => {
|
||||
if bytes.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(bytes)
|
||||
}
|
||||
}
|
||||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => None,
|
||||
Err(err) => {
|
||||
return Err(ViewError::io(
|
||||
&format!("read trace {}", trace_path.display()),
|
||||
err,
|
||||
))
|
||||
}
|
||||
};
|
||||
Ok(RunOutput {
|
||||
json,
|
||||
stdout: output.stdout,
|
||||
stderr: output.stderr,
|
||||
exit_code: output.exit_code,
|
||||
trace_sha256: trace_bytes.as_deref().map(sha256_hex),
|
||||
trace_bytes,
|
||||
})
|
||||
}
|
||||
|
||||
/// Spawn the core through the single process adapter with an explicit
|
||||
/// argv, private cwd, bounded capture and a wall-clock cap.
|
||||
fn execute(&self, args: &[OsString], cwd: &Path, timeout: Duration) -> ViewResult<ExecOutput> {
|
||||
@@ -410,30 +343,48 @@ struct ExecOutput {
|
||||
stderr: String,
|
||||
}
|
||||
|
||||
/// Build the base `check` arguments. The caller appends `--emit <path>` and
|
||||
/// optionally `--refs`; this function exists so the argv shape is unit-testable.
|
||||
/// Build the base `check` arguments. The caller appends `--json`,
|
||||
/// `--emit <path>` and optionally `--refs`; this function exists so the argv
|
||||
/// shape is unit-testable and cannot drift to a retired flag.
|
||||
fn build_check_args(entry: &Path) -> Vec<OsString> {
|
||||
vec![OsString::from("check"), entry.as_os_str().to_os_string()]
|
||||
}
|
||||
|
||||
/// Common explicit flags shared by `run` and `call`. Budgets are always sent
|
||||
/// explicitly by the execution controller (RFC-VIEW-0002 §6.7).
|
||||
fn append_common_args(args: &mut Vec<OsString>, trace_path: &Path, options: &RunOptions) {
|
||||
/// Common explicit flags shared by `run` and `call`.
|
||||
fn append_common_args(args: &mut Vec<OsString>, observation_file: &Path, options: &RunOptions) {
|
||||
fn push_pair(args: &mut Vec<OsString>, flag: &str, value: &str) {
|
||||
args.push(OsString::from(flag));
|
||||
args.push(OsString::from(value));
|
||||
}
|
||||
args.push(OsString::from("--mode"));
|
||||
args.push(OsString::from(options.mode.as_str()));
|
||||
if options.event_stream {
|
||||
push_pair(args, "--event-stream", "jsonl");
|
||||
push_pair(args, "--observe-max-events", "10000");
|
||||
push_pair(args, "--observe-max-bytes", "4194304");
|
||||
} else {
|
||||
args.push(OsString::from("--json"));
|
||||
push_pair(args, "--output", "jsonl");
|
||||
args.push(OsString::from("--observation-file"));
|
||||
args.push(observation_file.as_os_str().to_os_string());
|
||||
push_pair(
|
||||
args,
|
||||
"--observe-max-events",
|
||||
&options.observe_max_events.to_string(),
|
||||
);
|
||||
push_pair(
|
||||
args,
|
||||
"--observe-max-bytes",
|
||||
&options.observe_max_bytes.to_string(),
|
||||
);
|
||||
push_pair(
|
||||
args,
|
||||
"--observe-max-value-bytes",
|
||||
&options.observe_max_value_bytes.to_string(),
|
||||
);
|
||||
for name in &options.observe_variables {
|
||||
push_pair(args, "--observe-variable", name);
|
||||
}
|
||||
for name in &options.observe_parameters {
|
||||
push_pair(args, "--observe-parameter", name);
|
||||
}
|
||||
if options.observe_text_values {
|
||||
args.push(OsString::from("--observe-text-values"));
|
||||
}
|
||||
args.push(OsString::from("--trace-file"));
|
||||
args.push(trace_path.as_os_str().to_os_string());
|
||||
for glob in &options.grants.allow_read {
|
||||
push_pair(args, "--allow-read", glob);
|
||||
}
|
||||
@@ -464,18 +415,16 @@ fn append_common_args(args: &mut Vec<OsString>, trace_path: &Path, options: &Run
|
||||
if let Some(timeout) = options.timeout_seconds {
|
||||
push_pair(args, "--timeout", &timeout.to_string());
|
||||
}
|
||||
if let Some(max_events) = options.trace_max_events {
|
||||
push_pair(args, "--trace-max-events", &max_events.to_string());
|
||||
}
|
||||
if let Some(max_bytes) = options.trace_max_bytes {
|
||||
push_pair(args, "--trace-max-bytes", &max_bytes.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
/// Build `run` arguments from an already user-approved request.
|
||||
pub fn build_run_args(entry: &Path, trace_path: &Path, options: &RunOptions) -> Vec<OsString> {
|
||||
pub fn build_run_args(
|
||||
entry: &Path,
|
||||
observation_file: &Path,
|
||||
options: &RunOptions,
|
||||
) -> Vec<OsString> {
|
||||
let mut args = vec![OsString::from("run"), entry.as_os_str().to_os_string()];
|
||||
append_common_args(&mut args, trace_path, options);
|
||||
append_common_args(&mut args, observation_file, options);
|
||||
args
|
||||
}
|
||||
|
||||
@@ -485,7 +434,7 @@ pub fn build_call_args(
|
||||
entry: &Path,
|
||||
function: &str,
|
||||
arguments: &[(String, String)],
|
||||
trace_path: &Path,
|
||||
observation_file: &Path,
|
||||
options: &RunOptions,
|
||||
) -> Vec<OsString> {
|
||||
let mut args = vec![
|
||||
@@ -497,7 +446,7 @@ pub fn build_call_args(
|
||||
args.push(OsString::from("--arg"));
|
||||
args.push(OsString::from(format!("{name}={expression}")));
|
||||
}
|
||||
append_common_args(&mut args, trace_path, options);
|
||||
append_common_args(&mut args, observation_file, options);
|
||||
args
|
||||
}
|
||||
|
||||
@@ -505,18 +454,19 @@ fn locate_bin(explicit: Option<&Path>) -> ViewResult<PathBuf> {
|
||||
if let Some(path) = explicit {
|
||||
return validate_bin(path, "--marqdo-bin");
|
||||
}
|
||||
if let Some(raw) = std::env::var_os(ENV_MARQDO_BIN) {
|
||||
if let Some(raw) = std::env::var_os(tool_v1::ENV_MARQDO_BIN) {
|
||||
if raw.is_empty() {
|
||||
return Err(ViewError::CoreMissing {
|
||||
detail: format!("{ENV_MARQDO_BIN} is set but empty"),
|
||||
detail: format!("{} is set but empty", tool_v1::ENV_MARQDO_BIN),
|
||||
});
|
||||
}
|
||||
return validate_bin(Path::new(&raw), ENV_MARQDO_BIN);
|
||||
return validate_bin(Path::new(&raw), tool_v1::ENV_MARQDO_BIN);
|
||||
}
|
||||
Err(ViewError::CoreMissing {
|
||||
detail: format!(
|
||||
"{ENV_MARQDO_BIN} is not set. Install this tool with `marqdo tool install <bundle>/tool.json`, \
|
||||
or pass --marqdo-bin <path> when running marqdo-view directly."
|
||||
"{} is not set. Install this tool with `marqdo tool install <bundle>/tool.json`, \
|
||||
or pass --marqdo-bin <path> when running marqdo-view directly.",
|
||||
tool_v1::ENV_MARQDO_BIN
|
||||
),
|
||||
})
|
||||
}
|
||||
@@ -545,25 +495,12 @@ fn validate_bin(path: &Path, origin: &str) -> ViewResult<PathBuf> {
|
||||
Ok(canonical)
|
||||
}
|
||||
|
||||
fn summarize_stderr(stderr: &str) -> String {
|
||||
let trimmed = stderr.trim();
|
||||
if trimmed.is_empty() {
|
||||
"(no stderr)".to_string()
|
||||
} else {
|
||||
let mut text: String = trimmed.chars().take(1200).collect();
|
||||
if trimmed.chars().count() > 1200 {
|
||||
text.push('…');
|
||||
}
|
||||
text
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// `marqdo view verify`: static Analysis/source binding check. Never executes.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
use crate::cli::{RuntimeOpts, VerifyArgs};
|
||||
use crate::protocol::analysis_v2;
|
||||
use crate::protocol::analysis_v3;
|
||||
|
||||
pub fn verify_command(opts: &RuntimeOpts, args: &VerifyArgs) -> ViewResult<i32> {
|
||||
let path = args
|
||||
@@ -577,7 +514,6 @@ pub fn verify_command(opts: &RuntimeOpts, args: &VerifyArgs) -> ViewResult<i32>
|
||||
let source = String::from_utf8(source_bytes).map_err(|err| ViewError::Io {
|
||||
detail: format!("{entry} is not valid UTF-8: {err}"),
|
||||
})?;
|
||||
let source_index = crate::reader::source::SourceIndex::new(&source);
|
||||
|
||||
let client = CoreClient::from_env(opts.marqdo_bin.as_deref())?;
|
||||
let core_version = client.negotiate()?;
|
||||
@@ -627,12 +563,8 @@ pub fn verify_command(opts: &RuntimeOpts, args: &VerifyArgs) -> ViewResult<i32>
|
||||
})
|
||||
}
|
||||
};
|
||||
let verified = analysis_v2::verify_analysis(
|
||||
&check.analysis_bytes,
|
||||
&source,
|
||||
&source_index,
|
||||
entry.as_str(),
|
||||
)?;
|
||||
let verified =
|
||||
analysis_v3::verify_analysis(&check.analysis_bytes, entry.as_str(), Some(&source))?;
|
||||
let projection = &verified.projection;
|
||||
|
||||
if args.json {
|
||||
@@ -643,6 +575,7 @@ pub fn verify_command(opts: &RuntimeOpts, args: &VerifyArgs) -> ViewResult<i32>
|
||||
"core": {
|
||||
"version": core_version.version.to_string(),
|
||||
"supported_range": tool_v1::PRODUCT_RANGE,
|
||||
"api_revision": tool_v1::API_REVISION,
|
||||
},
|
||||
"analysis": {
|
||||
"schema": "marqdo.analysis",
|
||||
@@ -652,13 +585,21 @@ pub fn verify_command(opts: &RuntimeOpts, args: &VerifyArgs) -> ViewResult<i32>
|
||||
"markdown_profile": projection.markdown_profile,
|
||||
"functions": projection.functions.len(),
|
||||
"units": projection.units.len(),
|
||||
"references": projection.references.len(),
|
||||
"diagnostics": projection.diagnostics.len(),
|
||||
"requires": {
|
||||
"analysis": tool_v1::ANALYSIS_REVISION,
|
||||
"observation": tool_v1::OBSERVATION_REVISION,
|
||||
},
|
||||
},
|
||||
"project": {
|
||||
"root_id": projection.project_root_id,
|
||||
"identity_kind": projection.identity_kind,
|
||||
"entry_module_id": projection.entry_module_id,
|
||||
"lock_digest": projection.lock_digest,
|
||||
"manifest_digest": projection.manifest_digest,
|
||||
"stdlib_version": projection.stdlib_version,
|
||||
"extensions": projection.extensions.len(),
|
||||
},
|
||||
"document": {
|
||||
"relative_path": entry.as_str(),
|
||||
@@ -676,9 +617,10 @@ pub fn verify_command(opts: &RuntimeOpts, args: &VerifyArgs) -> ViewResult<i32>
|
||||
);
|
||||
} else {
|
||||
println!(
|
||||
"core: marqdo {} (supported {})",
|
||||
"core: marqdo {} (supported {}, api revision {})",
|
||||
core_version.version,
|
||||
tool_v1::PRODUCT_RANGE
|
||||
tool_v1::PRODUCT_RANGE,
|
||||
tool_v1::API_REVISION
|
||||
);
|
||||
println!(
|
||||
"project: {} ({})",
|
||||
@@ -686,10 +628,11 @@ pub fn verify_command(opts: &RuntimeOpts, args: &VerifyArgs) -> ViewResult<i32>
|
||||
);
|
||||
println!("document: {entry}");
|
||||
println!(
|
||||
"analysis: schema=marqdo.analysis v{} modules={} functions={} digest={}",
|
||||
"analysis: schema=marqdo.analysis v{} modules={} functions={} references={} digest={}",
|
||||
projection.schema_version,
|
||||
projection.modules.len(),
|
||||
projection.functions.len(),
|
||||
projection.references.len(),
|
||||
projection.analysis_digest
|
||||
);
|
||||
println!("source digest: match");
|
||||
@@ -702,41 +645,70 @@ pub fn verify_command(opts: &RuntimeOpts, args: &VerifyArgs) -> ViewResult<i32>
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn text(args: &[OsString]) -> Vec<String> {
|
||||
args.iter()
|
||||
.map(|arg| arg.to_string_lossy().to_string())
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_args_are_explicit_argv_never_shell() {
|
||||
fn run_args_use_the_current_observation_flags_only() {
|
||||
let args = build_run_args(
|
||||
Path::new("/p/index.mq.md"),
|
||||
Path::new("/t/trace.json"),
|
||||
Path::new("/t/observation.json"),
|
||||
&RunOptions {
|
||||
event_stream: false,
|
||||
mode: SandboxMode::Pure,
|
||||
mode: SandboxMode::Project,
|
||||
grants: Grants {
|
||||
allow_read: vec!["data/**".into()],
|
||||
allow_net: vec!["example.com".into()],
|
||||
..Default::default()
|
||||
},
|
||||
fuel: Some(1000),
|
||||
trace_max_events: Some(20),
|
||||
observe_max_events: 20,
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
let text: Vec<String> = args
|
||||
.iter()
|
||||
.map(|arg| arg.to_string_lossy().to_string())
|
||||
.collect();
|
||||
let text = text(&args);
|
||||
assert_eq!(text[0], "run");
|
||||
assert_eq!(text[1], "/p/index.mq.md");
|
||||
assert!(text.contains(&"pure".to_string()));
|
||||
assert!(text.contains(&"--json".to_string()));
|
||||
assert!(text.contains(&"--trace-file".to_string()));
|
||||
assert!(text.contains(&"project".to_string()));
|
||||
assert!(text.contains(&"--output".to_string()));
|
||||
assert!(text.contains(&"jsonl".to_string()));
|
||||
assert!(text.contains(&"--observation-file".to_string()));
|
||||
assert!(text.contains(&"--observe-max-events".to_string()));
|
||||
assert!(text.contains(&"--observe-max-bytes".to_string()));
|
||||
assert!(text.contains(&"--observe-max-value-bytes".to_string()));
|
||||
assert!(text.contains(&"data/**".to_string()));
|
||||
assert!(text.contains(&"example.com".to_string()));
|
||||
assert!(text.contains(&"1000".to_string()));
|
||||
assert!(text.contains(&"20".to_string()));
|
||||
// No token is a shell fragment: every argument is a separate value.
|
||||
// Retired flags and any shell fragment must never appear.
|
||||
for retired in [
|
||||
"--json",
|
||||
"--trace-file",
|
||||
"--event-stream",
|
||||
"--trace-max-events",
|
||||
"--trace-max-bytes",
|
||||
] {
|
||||
assert!(
|
||||
!text.contains(&retired.to_string()),
|
||||
"retired flag {retired}"
|
||||
);
|
||||
}
|
||||
assert!(!text
|
||||
.iter()
|
||||
.any(|t| t.contains(';') || t.contains('|') || t.contains('&')));
|
||||
.any(|token| token.contains(';') || token.contains('|') || token.contains('&')));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_defaults_do_not_request_values() {
|
||||
let args = build_run_args(
|
||||
Path::new("/p/index.mq.md"),
|
||||
Path::new("/t/observation.json"),
|
||||
&RunOptions::default(),
|
||||
);
|
||||
let text = text(&args);
|
||||
assert!(!text.iter().any(|token| token == "--observe-variable"));
|
||||
assert!(!text.iter().any(|token| token == "--observe-parameter"));
|
||||
assert!(!text.iter().any(|token| token == "--observe-text-values"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -768,11 +740,4 @@ mod tests {
|
||||
drop(scratch);
|
||||
assert!(!path.exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stderr_summary_is_bounded() {
|
||||
let text = summarize_stderr(&"x".repeat(5000));
|
||||
assert!(text.chars().count() <= 1201);
|
||||
assert_eq!(summarize_stderr(" "), "(no stderr)");
|
||||
}
|
||||
}
|
||||
+26
-7
@@ -37,8 +37,17 @@ pub enum ViewError {
|
||||
SourceSpanInvalid {
|
||||
detail: String,
|
||||
},
|
||||
/// Trace does not bind to the current Analysis bytes.
|
||||
TraceStale {
|
||||
/// Observation v1 is malformed, mixed, out of order or violates the
|
||||
/// selected observation policy.
|
||||
ObservationInvalid {
|
||||
detail: String,
|
||||
},
|
||||
/// Observation does not bind to the current Analysis bytes/source.
|
||||
ObservationStale {
|
||||
detail: String,
|
||||
},
|
||||
/// The CLI rejected an option combination before starting (exit code 2).
|
||||
CoreOptionRejected {
|
||||
detail: String,
|
||||
},
|
||||
/// The user did not confirm, or the requested mode/grants are not allowed.
|
||||
@@ -106,7 +115,7 @@ pub enum ViewError {
|
||||
OutputLimit {
|
||||
detail: String,
|
||||
},
|
||||
/// The CLI exited but its `--json` document was missing or invalid.
|
||||
/// The CLI exited but its Observation v1 stream was missing or invalid.
|
||||
CoreProtocol {
|
||||
detail: String,
|
||||
},
|
||||
@@ -136,7 +145,9 @@ impl ViewError {
|
||||
ViewError::AnalysisFailed { .. } => "view.analysis_failed",
|
||||
ViewError::SourceMismatch { .. } => "view.source_mismatch",
|
||||
ViewError::SourceSpanInvalid { .. } => "view.source_span_invalid",
|
||||
ViewError::TraceStale { .. } => "view.trace_stale",
|
||||
ViewError::ObservationInvalid { .. } => "view.observation_invalid",
|
||||
ViewError::ObservationStale { .. } => "view.observation_stale",
|
||||
ViewError::CoreOptionRejected { .. } => "view.core_option_rejected",
|
||||
ViewError::RunDenied { .. } => "view.run_denied",
|
||||
ViewError::PathForbidden { .. } => "view.path_forbidden",
|
||||
ViewError::BindDenied { .. } => "view.bind_denied",
|
||||
@@ -170,6 +181,8 @@ impl ViewError {
|
||||
| ViewError::PathForbidden { .. }
|
||||
| ViewError::BindDenied { .. }
|
||||
| ViewError::SourceSpanInvalid { .. }
|
||||
| ViewError::ObservationInvalid { .. }
|
||||
| ViewError::CoreOptionRejected { .. }
|
||||
| ViewError::Unsupported { .. }
|
||||
| ViewError::RunInvalid { .. }
|
||||
| ViewError::NoEntryFunction { .. }
|
||||
@@ -208,7 +221,11 @@ impl ViewError {
|
||||
"view.analysis_failed" => "Core 静态检查失败;正文仍可阅读,语义标注已撤销。",
|
||||
"view.source_mismatch" => "当前源码与 Analysis 字节摘要不一致。",
|
||||
"view.source_span_invalid" => "语义位置超出源码或不在 UTF-8 边界。",
|
||||
"view.trace_stale" => "运行结果与当前 Analysis 不匹配,已标记为过期。",
|
||||
"view.observation_invalid" => "运行观察事件无效或不符合当前协议,已拒绝展示。",
|
||||
"view.observation_stale" => "运行结果与当前 Analysis 不匹配,已标记为过期。",
|
||||
"view.core_option_rejected" => {
|
||||
"冻结核心在启动前拒绝了该选项组合( exit 2 );View 不会去掉参数重试。"
|
||||
}
|
||||
"view.run_denied" => "运行请求未获授权或被拒绝。",
|
||||
"view.path_forbidden" => "请求的路径超出允许的项目根目录。",
|
||||
"view.bind_denied" => "拒绝绑定该网络地址。",
|
||||
@@ -226,7 +243,7 @@ impl ViewError {
|
||||
"view.run_busy" => "已有一次运行正在进行;本版本每个 View 服务只允许一个任务。",
|
||||
"view.run_conflict" => "同一客户端请求 ID 携带了不同内容,拒绝执行。",
|
||||
"view.run_not_found" => "运行任务不存在、已过期或不属于当前会话。",
|
||||
"view.core_protocol" => "冻结核心退出但未给出合法的 --json 结果。",
|
||||
"view.core_protocol" => "冻结核心退出但未给出合法的 Observation v1 事件流。",
|
||||
"view.sse_busy" => "该运行任务的 SSE 观察连接超过上限,请稍后重试。",
|
||||
"view.output_limit" => "执行输出超过 View 的接收上限,已停止接收。",
|
||||
"view.io" => "本地 I/O 失败。",
|
||||
@@ -264,7 +281,9 @@ impl ViewError {
|
||||
| ViewError::ProtocolIncompatible { detail }
|
||||
| ViewError::AnalysisFailed { detail }
|
||||
| ViewError::SourceSpanInvalid { detail }
|
||||
| ViewError::TraceStale { detail }
|
||||
| ViewError::ObservationInvalid { detail }
|
||||
| ViewError::ObservationStale { detail }
|
||||
| ViewError::CoreOptionRejected { detail }
|
||||
| ViewError::RunDenied { detail }
|
||||
| ViewError::PathForbidden { detail }
|
||||
| ViewError::BindDenied { detail }
|
||||
|
||||
+641
-599
File diff suppressed because it is too large.
Load diff
+32
-13
@@ -1,8 +1,9 @@
|
||||
//! View-owned run event log and SSE frames (`marqdo.view-run-events` v1).
|
||||
//!
|
||||
//! This is View's own protocol, not a CLI protocol (RFC-VIEW-0002 §6.4). It
|
||||
//! only carries four event types and a bounded, sequenced replay buffer; it is
|
||||
//! not an event bus and never carries token streams or per-instruction values.
|
||||
//! only carries View lifecycle frames plus already-normalized Observation v1
|
||||
//! values and a bounded, sequenced replay buffer; it is not an event bus and
|
||||
//! never carries token streams or per-instruction values.
|
||||
|
||||
use std::collections::VecDeque;
|
||||
use std::sync::mpsc::{self, Receiver, SyncSender, TrySendError};
|
||||
@@ -54,7 +55,7 @@ impl RunState {
|
||||
RunState::Cancelled => "已取消",
|
||||
RunState::TimedOut => "超时",
|
||||
RunState::Unavailable => "不可用",
|
||||
RunState::Incomplete => "事件流不完整",
|
||||
RunState::Incomplete => "观察未完成",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,8 +101,8 @@ pub struct RunEvent {
|
||||
pub at: String,
|
||||
/// Safe parsed CLI result summary (never raw HTML/innerHTML material).
|
||||
pub result: Option<serde_json::Value>,
|
||||
/// Verified Trace v2 summary, only after digest/binding checks.
|
||||
pub trace: Option<serde_json::Value>,
|
||||
/// Verified Observation v1 summary, only after digest/binding checks.
|
||||
pub observation_summary: Option<serde_json::Value>,
|
||||
/// `{code, message}` for terminal failures.
|
||||
pub error: Option<serde_json::Value>,
|
||||
pub observation: Option<serde_json::Value>,
|
||||
@@ -120,8 +121,8 @@ impl RunEvent {
|
||||
if let Some(result) = &self.result {
|
||||
data["result"] = result.clone();
|
||||
}
|
||||
if let Some(trace) = &self.trace {
|
||||
data["trace"] = trace.clone();
|
||||
if let Some(summary) = &self.observation_summary {
|
||||
data["observation_summary"] = summary.clone();
|
||||
}
|
||||
if let Some(error) = &self.error {
|
||||
data["error"] = error.clone();
|
||||
@@ -188,7 +189,7 @@ impl EventLog {
|
||||
state,
|
||||
at: utc_now(),
|
||||
result: None,
|
||||
trace: None,
|
||||
observation_summary: None,
|
||||
error: None,
|
||||
observation: None,
|
||||
};
|
||||
@@ -233,11 +234,11 @@ impl EventLog {
|
||||
pub fn publish_complete(
|
||||
&mut self,
|
||||
result: serde_json::Value,
|
||||
trace: Option<serde_json::Value>,
|
||||
observation_summary: Option<serde_json::Value>,
|
||||
) -> RunEvent {
|
||||
let mut event = self.next_event(EventKind::Complete, RunState::Succeeded);
|
||||
event.result = Some(result);
|
||||
event.trace = trace;
|
||||
event.observation_summary = observation_summary;
|
||||
self.record(event)
|
||||
}
|
||||
|
||||
@@ -247,7 +248,7 @@ impl EventLog {
|
||||
code: &str,
|
||||
message: &str,
|
||||
result: Option<serde_json::Value>,
|
||||
trace: Option<serde_json::Value>,
|
||||
observation_summary: Option<serde_json::Value>,
|
||||
) -> RunEvent {
|
||||
let mut event = self.next_event(EventKind::Error, state);
|
||||
event.error = Some(serde_json::json!({
|
||||
@@ -255,7 +256,7 @@ impl EventLog {
|
||||
"message": message,
|
||||
}));
|
||||
event.result = result;
|
||||
event.trace = trace;
|
||||
event.observation_summary = observation_summary;
|
||||
self.record(event)
|
||||
}
|
||||
|
||||
@@ -291,7 +292,7 @@ impl EventLog {
|
||||
state: self.last_state,
|
||||
at: utc_now(),
|
||||
result: None,
|
||||
trace: None,
|
||||
observation_summary: None,
|
||||
error: None,
|
||||
observation: None,
|
||||
}
|
||||
@@ -430,6 +431,24 @@ mod tests {
|
||||
assert!(subscription.replay[0].result.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn terminal_frame_carries_observation_summary_not_trace() {
|
||||
let mut log = EventLog::new();
|
||||
log.publish_observation(serde_json::json!({
|
||||
"kind": "stdout.chunk",
|
||||
"seq": 13,
|
||||
"run_id": "core-run",
|
||||
}));
|
||||
let event = log.publish_complete(
|
||||
serde_json::json!({"success": true}),
|
||||
Some(serde_json::json!({"status": "verified"})),
|
||||
);
|
||||
let data = event.data("run-1");
|
||||
assert!(data.get("trace").is_none());
|
||||
assert_eq!(data["observation_summary"]["status"], "verified");
|
||||
assert_eq!(data["result"]["success"], true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn utc_formatting_is_stable() {
|
||||
assert_eq!(format_utc(0), "1970-01-01T00:00:00Z");
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
//! A bounded projection retained only inside an existing terminal Job.
|
||||
//!
|
||||
//! The overlay is bound to the verified Observation v1 terminal (run id, state,
|
||||
//! capture level, truncation) and to the exact pre-run Analysis bytes; it never
|
||||
//! re-parses the CLI JSON and never widens the value consent the user gave.
|
||||
|
||||
use crate::execution::events::RunState;
|
||||
use crate::execution::request::ExecutionPlan;
|
||||
use crate::protocol::observation_v1::{EventCounts, RunProjection};
|
||||
use crate::reader::assemble::StaticDocument;
|
||||
use serde_json::{json, Value};
|
||||
use std::collections::BTreeMap;
|
||||
@@ -16,11 +21,13 @@ pub struct TerminalExportCandidate {
|
||||
pub project_root_id: String,
|
||||
pub module_id: String,
|
||||
pub analysis_digest: String,
|
||||
/// Analysis revision carried by the exact pre-run artifact (3).
|
||||
pub analysis_version: u32,
|
||||
pub source_sha256: String,
|
||||
pub lock_digest: String,
|
||||
pub media: BTreeMap<String, String>,
|
||||
pub core_run_id: String,
|
||||
/// Observation v1 run id (`run.id`/`run_id`).
|
||||
pub observation_run_id: String,
|
||||
pub core_version: String,
|
||||
pub mode: String,
|
||||
pub terminal_at: String,
|
||||
@@ -30,8 +37,9 @@ pub struct TerminalExportCandidate {
|
||||
pub stdout: String,
|
||||
pub stderr: String,
|
||||
pub arguments: Vec<(String, String)>,
|
||||
pub trace_status: String,
|
||||
pub trace_counts: Option<BTreeMap<String, u64>>,
|
||||
pub observation_status: String,
|
||||
pub observation_counts: Option<BTreeMap<String, u64>>,
|
||||
pub capture_level: String,
|
||||
pub output_complete: bool,
|
||||
pub result_complete: bool,
|
||||
pub observation_truncated: bool,
|
||||
@@ -43,14 +51,21 @@ impl TerminalExportCandidate {
|
||||
plan: &ExecutionPlan,
|
||||
document: &StaticDocument,
|
||||
result: &Value,
|
||||
trace: Option<&Value>,
|
||||
observation: Option<&RunProjection>,
|
||||
) -> Option<Self> {
|
||||
if !matches!(state, RunState::Succeeded | RunState::Failed)
|
||||
if !matches!(state, RunState::Succeeded | RunState::Failed) {
|
||||
return None;
|
||||
}
|
||||
let observation = observation?;
|
||||
if !observation.source_verified
|
||||
|| result.get("source_verified").and_then(Value::as_bool) != Some(true)
|
||||
|| result.get("event_protocol").and_then(Value::as_u64) != Some(1)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let observation_status = result.get("observation_status").and_then(Value::as_str)?;
|
||||
if !matches!(observation_status, "verified" | "truncated") {
|
||||
return None;
|
||||
}
|
||||
let projection = &document.verified.projection;
|
||||
let function = projection
|
||||
.functions
|
||||
@@ -58,48 +73,19 @@ impl TerminalExportCandidate {
|
||||
.find(|function| function.id == plan.function_id)?;
|
||||
let (stdout, stdout_complete) = bounded_text(result["stdout"].as_str());
|
||||
let (stderr, stderr_complete) = bounded_text(result["stderr"].as_str());
|
||||
let wire = &result["value"];
|
||||
let value_is_scalar = matches!(
|
||||
wire["type"].as_str(),
|
||||
Some("int" | "float" | "bool" | "unit" | "none" | "text")
|
||||
);
|
||||
let value_text = match state {
|
||||
RunState::Succeeded if value_is_scalar => {
|
||||
result["value_text"].as_str().map(str::to_string)
|
||||
}
|
||||
RunState::Succeeded if crate::protocol::value_wire_v1::transferable(wire) => {
|
||||
Some(wire.to_string())
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
let (value, value_complete) = match value_text {
|
||||
Some(text) => {
|
||||
let (text, complete) = bounded_text(Some(&text));
|
||||
(Some(text), complete)
|
||||
}
|
||||
None => (None, false),
|
||||
};
|
||||
let trace_status = match &result["trace_status"] {
|
||||
Value::String(status) if status == "verified" => {
|
||||
if trace.is_some_and(|trace| !trace["truncated"].is_null()) {
|
||||
"truncated"
|
||||
} else {
|
||||
"verified"
|
||||
// Only a public scalar result value is exportable without an extra
|
||||
// sensitive-output confirmation; container/text values stay omitted.
|
||||
let (value, value_complete, value_is_public_scalar) =
|
||||
match observation.result_value.as_ref() {
|
||||
Some(run) if public_scalar_type(&run.ty) => {
|
||||
let (text, complete) = bounded_text(Some(run.display.as_str()));
|
||||
(Some(text), complete, true)
|
||||
}
|
||||
}
|
||||
Value::String(status) if status == "invalid" => "invalid",
|
||||
_ => "unavailable",
|
||||
};
|
||||
let trace_counts = trace
|
||||
.filter(|trace| trace["status"] == "verified")
|
||||
.and_then(|trace| trace["counts"].as_object())
|
||||
.map(|counts| {
|
||||
counts
|
||||
.iter()
|
||||
.filter_map(|(kind, count)| Some((kind.clone(), count.as_u64()?)))
|
||||
.collect()
|
||||
});
|
||||
let value_is_public_scalar = value_is_scalar && wire["type"] != "text";
|
||||
Some(_) => (None, false, false),
|
||||
None => (None, true, false),
|
||||
};
|
||||
let observation_truncated = observation.truncated.is_some();
|
||||
let observation_counts = Some(counts_map(&observation.counts));
|
||||
Some(Self {
|
||||
document: plan.document.to_string(),
|
||||
function_id: function.id.clone(),
|
||||
@@ -111,7 +97,7 @@ impl TerminalExportCandidate {
|
||||
source_sha256: document.source_sha256.clone(),
|
||||
lock_digest: projection.lock_digest.clone(),
|
||||
media: document.media_digests.clone(),
|
||||
core_run_id: result["core_run_id"].as_str()?.to_string(),
|
||||
observation_run_id: observation.run_id.clone(),
|
||||
core_version: projection.producer_version.clone(),
|
||||
mode: plan.mode.as_str().to_string(),
|
||||
terminal_at: crate::execution::events::utc_now(),
|
||||
@@ -121,13 +107,16 @@ impl TerminalExportCandidate {
|
||||
stdout,
|
||||
stderr,
|
||||
arguments: plan.arguments.clone(),
|
||||
trace_status: trace_status.to_string(),
|
||||
trace_counts,
|
||||
observation_status: observation_status.to_string(),
|
||||
observation_counts,
|
||||
capture_level: observation.capture_level.clone(),
|
||||
output_complete: result["output_complete"].as_bool() == Some(true)
|
||||
&& stdout_complete
|
||||
&& stderr_complete,
|
||||
result_complete: state == RunState::Succeeded && value_complete,
|
||||
observation_truncated: result["observation_truncated"].as_bool().unwrap_or(false),
|
||||
result_complete: state == RunState::Succeeded
|
||||
&& !observation_truncated
|
||||
&& value_complete,
|
||||
observation_truncated,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -140,8 +129,9 @@ impl TerminalExportCandidate {
|
||||
"stdout_bytes": self.stdout.len(),
|
||||
"stderr_bytes": self.stderr.len(),
|
||||
"arguments_count": self.arguments.len(),
|
||||
"trace_summary": self.trace_counts.is_some(),
|
||||
"trace_status": self.trace_status,
|
||||
"observation_summary": self.observation_counts.is_some(),
|
||||
"observation_status": self.observation_status,
|
||||
"capture_level": self.capture_level,
|
||||
"observation_truncated": self.observation_truncated,
|
||||
"output_complete": self.output_complete,
|
||||
"result_complete": self.result_complete,
|
||||
@@ -149,6 +139,31 @@ impl TerminalExportCandidate {
|
||||
}
|
||||
}
|
||||
|
||||
fn public_scalar_type(ty: &str) -> bool {
|
||||
matches!(
|
||||
ty.to_ascii_lowercase().as_str(),
|
||||
"int" | "float" | "bool" | "unit" | "none"
|
||||
)
|
||||
}
|
||||
|
||||
fn counts_map(counts: &EventCounts) -> BTreeMap<String, u64> {
|
||||
[
|
||||
("total", counts.total()),
|
||||
("call_enter", counts.call_enter),
|
||||
("call_exit", counts.call_exit),
|
||||
("branch_eval", counts.branch_eval),
|
||||
("loop_iteration", counts.loop_iteration),
|
||||
("control_break", counts.control_break),
|
||||
("control_continue", counts.control_continue),
|
||||
("return", counts.return_events),
|
||||
("effect", counts.effect),
|
||||
("other", counts.other),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(kind, count)| (kind.to_string(), count as u64))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn bounded_text(value: Option<&str>) -> (String, bool) {
|
||||
let Some(text) = value else {
|
||||
return (String::new(), true);
|
||||
@@ -159,3 +174,26 @@ fn bounded_text(value: Option<&str>) -> (String, bool) {
|
||||
}
|
||||
(text[..end].to_string(), end == text.len())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn public_scalar_types_exclude_text_and_containers() {
|
||||
for accepted in ["Int", "float", "Bool", "Unit", "none"] {
|
||||
assert!(public_scalar_type(accepted), "{accepted}");
|
||||
}
|
||||
for rejected in ["Text", "List", "Map", "Table", "Memory", "Resource"] {
|
||||
assert!(!public_scalar_type(rejected), "{rejected}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bounded_text_never_splits_utf8() {
|
||||
let text = "é".repeat(MAX_TEXT);
|
||||
let (bounded, complete) = bounded_text(Some(&text));
|
||||
assert!(bounded.is_char_boundary(bounded.len()));
|
||||
assert!(!complete);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
//! - `request`: schema/target/parameter/mode/grant validation
|
||||
//! - `process`: the one cancellable Core process adapter with bounded capture
|
||||
//! - `events`: bounded, sequenced View-owned run events and SSE frames
|
||||
//! - `controller`: single-job lifecycle, dedupe, cancel, Trace binding
|
||||
//! - `controller`: single-job lifecycle, dedupe, cancel, Observation v1 binding
|
||||
|
||||
pub mod controller;
|
||||
pub mod events;
|
||||
|
||||
+103
-40
@@ -1,14 +1,14 @@
|
||||
//! Validation of the two-phase explicit run request (RFC-VIEW-0002 §6.3).
|
||||
//!
|
||||
//! The browser never sends a command: it sends a document, a target selected
|
||||
//! from Analysis v2, constant parameter expressions, the exact Analysis digest
|
||||
//! from Analysis v3, constant parameter expressions, the exact Analysis digest
|
||||
//! it rendered, a mode and (for project mode) explicit fs globs. Everything is
|
||||
//! re-validated here and finally by the Core itself; the client cannot inject
|
||||
//! cwd, flags, a binary path or shell text.
|
||||
|
||||
use crate::core_client::Grants;
|
||||
use crate::error::{ViewError, ViewResult};
|
||||
use crate::protocol::analysis_v2::SemanticProjection;
|
||||
use crate::protocol::analysis_v3::SemanticProjection;
|
||||
use crate::reader::source::SafeRelativePath;
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -371,7 +371,7 @@ fn validate_glob(glob: &str) -> ViewResult<()> {
|
||||
/// first, then a unique local name. No fallback to any other function.
|
||||
fn resolve_main(
|
||||
projection: &SemanticProjection,
|
||||
) -> Option<&crate::protocol::analysis_v2::SemanticFunction> {
|
||||
) -> Option<&crate::protocol::analysis_v3::SemanticFunction> {
|
||||
projection
|
||||
.functions
|
||||
.iter()
|
||||
@@ -401,7 +401,7 @@ fn unique_local_name(projection: &SemanticProjection, local_name: &str, id: &str
|
||||
canonical == local_name
|
||||
}
|
||||
|
||||
/// Analysis v2 function ids are `<module id>::<canonical name>`.
|
||||
/// Analysis v3 function ids are `<module id>::<canonical name>`.
|
||||
pub fn canonical_name(function_id: &str, module_id: &str) -> String {
|
||||
function_id
|
||||
.strip_prefix(&format!("{module_id}::"))
|
||||
@@ -456,44 +456,107 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
fn projection() -> SemanticProjection {
|
||||
use crate::protocol::analysis_v3::{
|
||||
DocumentNode, FunctionParam, FunctionSignature, ModuleSummary, SemanticFunction,
|
||||
};
|
||||
use crate::reader::source::{sha256_hex, SourceSpan};
|
||||
|
||||
let module_id = "root:t@0.1.0::index.mq.md";
|
||||
let source = "x".repeat(200);
|
||||
let digest = crate::reader::source::sha256_hex(source.as_bytes());
|
||||
let analysis = serde_json::json!({
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 2,
|
||||
"producer": {"name": "marqdo", "version": "3.0.0-beta.1", "markdown_profile": "marqdo.md.v1"},
|
||||
"project": {"root_id": "root:t@0.1.0", "identity_kind": "manifest", "lock_digest": "", "stdlib": null},
|
||||
"modules": [{
|
||||
"id": "root:t@0.1.0::index.mq.md",
|
||||
"package_instance_id": "root:t@0.1.0",
|
||||
"relative_path": "index.mq.md",
|
||||
"source_digest": digest,
|
||||
"units": [],
|
||||
"functions": [
|
||||
{"id": "root:t@0.1.0::index.mq.md::main", "unit_id": "u1", "local_name": "main",
|
||||
"namespace": null, "span": {"start": 0, "end": 10}, "heading_span": {"start": 0, "end": 10},
|
||||
"signature": {"kind": "inferred", "params": []}, "body": [], "effects": ["unknown"]},
|
||||
{"id": "root:t@0.1.0::index.mq.md::N.f", "unit_id": "u2", "local_name": "f",
|
||||
"namespace": "N", "span": {"start": 20, "end": 30}, "heading_span": {"start": 20, "end": 30},
|
||||
"signature": {"kind": "explicit", "params": [
|
||||
{"name": "n", "required": true, "type": "Int", "default": null, "span": null}
|
||||
]}, "body": [], "effects": ["unknown"]}
|
||||
],
|
||||
"imports": [], "references": [], "calls": [], "resources": []
|
||||
let source_digest = sha256_hex(source.as_bytes());
|
||||
SemanticProjection {
|
||||
schema_version: 3,
|
||||
analysis_sha256: "a".repeat(64),
|
||||
analysis_digest: format!("sha256:{}", "a".repeat(64)),
|
||||
producer_version: "3.0.0-rc.4".to_string(),
|
||||
markdown_profile: "marqdo.md.v1".to_string(),
|
||||
project_root_id: "root:t@0.1.0".to_string(),
|
||||
identity_kind: "manifest".to_string(),
|
||||
entry_module_id: module_id.to_string(),
|
||||
lock_digest: String::new(),
|
||||
manifest_digest: String::new(),
|
||||
stdlib_version: None,
|
||||
stdlib_digest: None,
|
||||
stdlib_instance_id: None,
|
||||
extensions: Vec::new(),
|
||||
module_id: module_id.to_string(),
|
||||
package_instance_id: "root:t@0.1.0".to_string(),
|
||||
relative_path: "index.mq.md".to_string(),
|
||||
source_digest: source_digest.clone(),
|
||||
source: source.clone(),
|
||||
document: DocumentNode {
|
||||
kind: "document".to_string(),
|
||||
span: SourceSpan::new(0, source.len() as u64),
|
||||
children: Vec::new(),
|
||||
literal: None,
|
||||
level: None,
|
||||
setext: None,
|
||||
ordered: None,
|
||||
start: None,
|
||||
tight: None,
|
||||
task: None,
|
||||
ticks: None,
|
||||
fenced: None,
|
||||
info: None,
|
||||
display: None,
|
||||
url: None,
|
||||
title: None,
|
||||
alignments: None,
|
||||
header: None,
|
||||
tag: None,
|
||||
},
|
||||
anchors: Vec::new(),
|
||||
units: Vec::new(),
|
||||
functions: vec![
|
||||
SemanticFunction {
|
||||
id: format!("{module_id}::main"),
|
||||
unit_id: "u1".to_string(),
|
||||
local_name: "main".to_string(),
|
||||
namespace: None,
|
||||
span: SourceSpan::new(0, 10),
|
||||
heading_span: SourceSpan::new(0, 10),
|
||||
signature: FunctionSignature {
|
||||
kind: "inferred".to_string(),
|
||||
params: Vec::new(),
|
||||
},
|
||||
effects: vec!["unknown".to_string()],
|
||||
statements: Vec::new(),
|
||||
},
|
||||
SemanticFunction {
|
||||
id: format!("{module_id}::N.f"),
|
||||
unit_id: "u2".to_string(),
|
||||
local_name: "f".to_string(),
|
||||
namespace: Some("N".to_string()),
|
||||
span: SourceSpan::new(20, 30),
|
||||
heading_span: SourceSpan::new(20, 30),
|
||||
signature: FunctionSignature {
|
||||
kind: "explicit".to_string(),
|
||||
params: vec![FunctionParam {
|
||||
name: "n".to_string(),
|
||||
ty: Some("Int".to_string()),
|
||||
required: true,
|
||||
default: None,
|
||||
span: SourceSpan::new(24, 25),
|
||||
}],
|
||||
},
|
||||
effects: vec!["unknown".to_string()],
|
||||
statements: Vec::new(),
|
||||
},
|
||||
],
|
||||
resources: Vec::new(),
|
||||
imports: Vec::new(),
|
||||
references: Vec::new(),
|
||||
calls: Vec::new(),
|
||||
diagnostics: Vec::new(),
|
||||
warnings: Vec::new(),
|
||||
modules: vec![ModuleSummary {
|
||||
id: module_id.to_string(),
|
||||
package_instance_id: "root:t@0.1.0".to_string(),
|
||||
relative_path: "index.mq.md".to_string(),
|
||||
source_digest,
|
||||
source,
|
||||
}],
|
||||
"diagnostics": []
|
||||
})
|
||||
.to_string();
|
||||
let source = "x".repeat(200);
|
||||
let index = crate::reader::source::SourceIndex::new(&source);
|
||||
crate::protocol::analysis_v2::verify_analysis(
|
||||
analysis.to_string().as_bytes(),
|
||||
&source,
|
||||
&index,
|
||||
"index.mq.md",
|
||||
)
|
||||
.map(|verified| verified.projection)
|
||||
.unwrap_or_else(|err| panic!("fixture analysis must verify: {err}"))
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+39
-6
@@ -200,13 +200,30 @@ fn build_site(
|
||||
let mut manifest = serde_json::json!({
|
||||
"schema": MANIFEST_SCHEMA,
|
||||
"schema_version": 1,
|
||||
"view": {"name": "marqdo-view", "version": env!("CARGO_PKG_VERSION")},
|
||||
"compatibility": {
|
||||
"view": {
|
||||
"name": "marqdo-view",
|
||||
"version": env!("CARGO_PKG_VERSION"),
|
||||
"binary_sha256": current_view_sha256(),
|
||||
},
|
||||
"producers": {
|
||||
"view": {
|
||||
"name": "marqdo-view",
|
||||
"version": env!("CARGO_PKG_VERSION"),
|
||||
"binary_sha256": current_view_sha256(),
|
||||
},
|
||||
"cli": match context.core() {
|
||||
Some(core) => serde_json::json!({
|
||||
"version": entry_model.core_version,
|
||||
"binary_sha256": sha256_file(core.bin()),
|
||||
}),
|
||||
None => serde_json::Value::Null,
|
||||
},
|
||||
},
|
||||
"requires": {
|
||||
"marqdo": crate::protocol::tool_v1::PRODUCT_RANGE,
|
||||
"tool_protocol": crate::protocol::tool_v1::TOOL_PROTOCOL,
|
||||
"analysis": crate::protocol::tool_v1::ANALYSIS_PROTOCOL,
|
||||
"analysis_supported": crate::protocol::tool_v1::ANALYSIS_PROTOCOLS,
|
||||
"trace": crate::protocol::tool_v1::TRACE_PROTOCOL,
|
||||
"api_revision": crate::protocol::tool_v1::API_REVISION,
|
||||
"analysis": crate::protocol::tool_v1::ANALYSIS_REVISION,
|
||||
"observation": crate::protocol::tool_v1::OBSERVATION_REVISION,
|
||||
"markdown_profile": "marqdo.md.v1",
|
||||
},
|
||||
"core_version": entry_model.core_version,
|
||||
@@ -240,6 +257,22 @@ fn build_site(
|
||||
})
|
||||
}
|
||||
|
||||
/// Lowercase hex SHA-256 of the running View executable, used to bind the
|
||||
/// exported manifest to the exact producer binary. Never a machine path.
|
||||
fn current_view_sha256() -> String {
|
||||
let Ok(exe) = std::env::current_exe() else {
|
||||
return "unavailable".to_string();
|
||||
};
|
||||
sha256_file(&exe)
|
||||
}
|
||||
|
||||
fn sha256_file(path: &std::path::Path) -> String {
|
||||
match std::fs::read(path) {
|
||||
Ok(bytes) => sha256_hex(&bytes),
|
||||
Err(_) => "unavailable".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SnapshotArchive {
|
||||
pub file: std::fs::File,
|
||||
pub len: usize,
|
||||
|
||||
+13
-11
@@ -3,11 +3,12 @@
|
||||
|
||||
use crate::{
|
||||
execution::{events::RunState, export_candidate::TerminalExportCandidate},
|
||||
protocol::tool_v1,
|
||||
reader::{
|
||||
assemble::DocumentService,
|
||||
media,
|
||||
model::PresentationModel,
|
||||
snapshot::{ExportResultOverlay, SnapshotExecution, SnapshotProtocols, SnapshotSource},
|
||||
snapshot::{ExportResultOverlay, SnapshotContracts, SnapshotExecution, SnapshotSource},
|
||||
source::{sha256_hex, SafeRelativePath},
|
||||
},
|
||||
ViewError, ViewResult,
|
||||
@@ -44,7 +45,7 @@ struct Include {
|
||||
result_value: bool,
|
||||
stdout: bool,
|
||||
stderr: bool,
|
||||
trace_summary: bool,
|
||||
observation_summary: bool,
|
||||
arguments: bool,
|
||||
}
|
||||
|
||||
@@ -113,7 +114,7 @@ impl ExportSelection {
|
||||
|| !candidate.output_complete
|
||||
|| !candidate.result_complete
|
||||
|| candidate.observation_truncated
|
||||
|| candidate.trace_status == "truncated")
|
||||
|| candidate.observation_status == "truncated")
|
||||
&& !self.confirm_partial
|
||||
{
|
||||
return Err(invalid());
|
||||
@@ -147,13 +148,14 @@ impl ExportSelection {
|
||||
},
|
||||
execution: SnapshotExecution {
|
||||
included: true,
|
||||
core_run_id: candidate.core_run_id.clone(),
|
||||
core_run_id: candidate.observation_run_id.clone(),
|
||||
target: candidate.function_id.clone(),
|
||||
core_version: candidate.core_version.clone(),
|
||||
status: candidate.state.data_value(),
|
||||
terminal_at: candidate.terminal_at.clone(),
|
||||
source_verified: true,
|
||||
trace_status: candidate.trace_status.clone(),
|
||||
observation_status: candidate.observation_status.clone(),
|
||||
capture_level: candidate.capture_level.clone(),
|
||||
result_complete: candidate.result_complete,
|
||||
output_complete: candidate.output_complete,
|
||||
observation_truncated: candidate.observation_truncated,
|
||||
@@ -163,10 +165,10 @@ impl ExportSelection {
|
||||
"omitted"
|
||||
},
|
||||
mode: candidate.mode.clone(),
|
||||
core_protocol: SnapshotProtocols {
|
||||
contracts: SnapshotContracts {
|
||||
api_revision: tool_v1::API_REVISION,
|
||||
analysis: candidate.analysis_version,
|
||||
trace: 2,
|
||||
events: 1,
|
||||
observation: tool_v1::OBSERVATION_REVISION,
|
||||
},
|
||||
},
|
||||
label: candidate.label.clone(),
|
||||
@@ -177,10 +179,10 @@ impl ExportSelection {
|
||||
.flatten(),
|
||||
stdout: self.include.stdout.then(|| candidate.stdout.clone()),
|
||||
stderr: self.include.stderr.then(|| candidate.stderr.clone()),
|
||||
trace_counts: self
|
||||
observation_counts: self
|
||||
.include
|
||||
.trace_summary
|
||||
.then(|| candidate.trace_counts.clone())
|
||||
.observation_summary
|
||||
.then(|| candidate.observation_counts.clone())
|
||||
.flatten(),
|
||||
arguments: self.include.arguments.then(|| candidate.arguments.clone()),
|
||||
};
|
||||
|
||||
@@ -1,952 +0,0 @@
|
||||
//! Analysis v2 validation and static semantic projection.
|
||||
//!
|
||||
//! This module is the only consumer of the public Analysis JSON. It verifies
|
||||
//! protocol identity first, then projects functions/units/statements/diagnostics
|
||||
//! into View-owned types with **validated** source spans. A span that is out of
|
||||
//! range or not on a UTF-8 boundary is dropped with an explicit View warning
|
||||
//! instead of being pointed at nearby text (RFC-VIEW-0001 §4.3, §8.2).
|
||||
|
||||
use crate::error::{ViewError, ViewResult};
|
||||
use crate::reader::source::{sha256_hex, sha256_prefixed, SourceIndex, SourceSpan};
|
||||
use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
|
||||
/// Stable DOM identity for one source-bound annotation, local to this document
|
||||
/// and run. It is not a cross-edit identity.
|
||||
pub fn source_id(module_id: &str, span: SourceSpan, kind: &str) -> String {
|
||||
let material = format!("{module_id}\0{}:{}:{}", span.start, span.end, kind);
|
||||
sha256_hex(material.as_bytes())[..16].to_string()
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum UnitKind {
|
||||
Root,
|
||||
Namespace,
|
||||
Function,
|
||||
Knowledge,
|
||||
Section,
|
||||
Other,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SemanticUnit {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub level: u8,
|
||||
pub kind: UnitKind,
|
||||
pub function: Option<String>,
|
||||
pub span: SourceSpan,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct FunctionParam {
|
||||
pub name: String,
|
||||
pub ty: String,
|
||||
pub required: bool,
|
||||
pub default: Option<String>,
|
||||
pub span: Option<SourceSpan>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct FunctionSignature {
|
||||
pub kind: String,
|
||||
pub params: Vec<FunctionParam>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SemanticFunction {
|
||||
pub id: String,
|
||||
pub unit_id: String,
|
||||
pub local_name: String,
|
||||
pub namespace: Option<String>,
|
||||
pub span: SourceSpan,
|
||||
pub heading_span: SourceSpan,
|
||||
pub signature: FunctionSignature,
|
||||
pub effects: Vec<String>,
|
||||
pub statements: Vec<SemanticStatement>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum StatementKind {
|
||||
Assign,
|
||||
Expression,
|
||||
Branch,
|
||||
Loop,
|
||||
Return,
|
||||
Break,
|
||||
Continue,
|
||||
Other,
|
||||
}
|
||||
|
||||
impl StatementKind {
|
||||
pub fn label(&self) -> &'static str {
|
||||
match self {
|
||||
StatementKind::Assign => "赋值",
|
||||
StatementKind::Expression => "表达式",
|
||||
StatementKind::Branch => "条件分支",
|
||||
StatementKind::Loop => "循环",
|
||||
StatementKind::Return => "返回",
|
||||
StatementKind::Break => "跳出循环",
|
||||
StatementKind::Continue => "继续循环",
|
||||
StatementKind::Other => "语句",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn data_value(&self) -> &'static str {
|
||||
match self {
|
||||
StatementKind::Assign => "assign",
|
||||
StatementKind::Expression => "expression",
|
||||
StatementKind::Branch => "branch",
|
||||
StatementKind::Loop => "loop",
|
||||
StatementKind::Return => "return",
|
||||
StatementKind::Break => "break",
|
||||
StatementKind::Continue => "continue",
|
||||
StatementKind::Other => "other",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SemanticStatement {
|
||||
pub kind: StatementKind,
|
||||
/// Header span for control flow, payload span for simple statements.
|
||||
pub span: SourceSpan,
|
||||
/// For `if` arms and `while` conditions: the condition text span as the
|
||||
/// compiler recorded it.
|
||||
pub condition_span: Option<SourceSpan>,
|
||||
pub arms: Vec<SemanticArm>,
|
||||
pub body: Vec<SemanticStatement>,
|
||||
/// Target name for assignments (local name or `index` form), for static
|
||||
/// outline display only. Never a runtime value.
|
||||
pub target: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SemanticArm {
|
||||
pub span: Option<SourceSpan>,
|
||||
pub condition_span: Option<SourceSpan>,
|
||||
pub body: Vec<SemanticStatement>,
|
||||
}
|
||||
|
||||
impl SemanticFunction {
|
||||
/// Depth-first statement walk in source order.
|
||||
pub fn flattened_statements(&self) -> Vec<&SemanticStatement> {
|
||||
let mut out = Vec::new();
|
||||
for statement in &self.statements {
|
||||
collect_statements(statement, &mut out);
|
||||
}
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
fn collect_statements<'a>(statement: &'a SemanticStatement, out: &mut Vec<&'a SemanticStatement>) {
|
||||
out.push(statement);
|
||||
for arm in &statement.arms {
|
||||
for child in &arm.body {
|
||||
collect_statements(child, out);
|
||||
}
|
||||
}
|
||||
for child in &statement.body {
|
||||
collect_statements(child, out);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StaticResource {
|
||||
pub id: String,
|
||||
pub kind: String,
|
||||
pub span: SourceSpan,
|
||||
pub content_digest: String,
|
||||
pub language: Option<String>,
|
||||
pub display: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StaticImport {
|
||||
pub alias: String,
|
||||
pub target: String,
|
||||
pub resolved: Option<String>,
|
||||
pub span: SourceSpan,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StaticReference {
|
||||
pub url: String,
|
||||
pub span: SourceSpan,
|
||||
pub state: String,
|
||||
pub target_module: Option<String>,
|
||||
pub target_unit: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StaticCall {
|
||||
pub state: String,
|
||||
pub target: Option<String>,
|
||||
pub function: Option<String>,
|
||||
pub span: SourceSpan,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CoreDiagnostic {
|
||||
pub module: Option<String>,
|
||||
pub relative_path: Option<String>,
|
||||
pub span: Option<SourceSpan>,
|
||||
pub line: Option<u64>,
|
||||
pub column: Option<u64>,
|
||||
pub severity: String,
|
||||
pub code: String,
|
||||
pub message: String,
|
||||
pub hints: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ViewWarning {
|
||||
pub code: String,
|
||||
pub message: String,
|
||||
pub span: Option<SourceSpan>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ModuleSummary {
|
||||
pub id: String,
|
||||
pub package_instance_id: String,
|
||||
pub relative_path: String,
|
||||
pub source_digest: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SemanticProjection {
|
||||
pub schema_version: u32,
|
||||
pub analysis_sha256: String,
|
||||
pub analysis_digest: String,
|
||||
pub producer_version: String,
|
||||
pub markdown_profile: String,
|
||||
pub project_root_id: String,
|
||||
pub identity_kind: String,
|
||||
pub lock_digest: String,
|
||||
pub stdlib_version: Option<String>,
|
||||
pub module_id: String,
|
||||
pub package_instance_id: String,
|
||||
pub relative_path: String,
|
||||
pub source_digest: String,
|
||||
pub units: Vec<SemanticUnit>,
|
||||
pub functions: Vec<SemanticFunction>,
|
||||
pub resources: Vec<StaticResource>,
|
||||
pub imports: Vec<StaticImport>,
|
||||
pub references: Vec<StaticReference>,
|
||||
pub calls: Vec<StaticCall>,
|
||||
pub diagnostics: Vec<CoreDiagnostic>,
|
||||
pub warnings: Vec<ViewWarning>,
|
||||
pub modules: Vec<ModuleSummary>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct VerifiedAnalysis {
|
||||
pub projection: SemanticProjection,
|
||||
}
|
||||
|
||||
impl SemanticProjection {
|
||||
pub fn unit_for_heading(&self, span: SourceSpan, level: u8) -> Option<&SemanticUnit> {
|
||||
self.units
|
||||
.iter()
|
||||
.filter(|unit| unit.level == level && unit.span.contains(span))
|
||||
.min_by_key(|unit| unit.span.len())
|
||||
}
|
||||
|
||||
pub fn function_by_heading(&self, span: SourceSpan) -> Option<&SemanticFunction> {
|
||||
self.functions
|
||||
.iter()
|
||||
.find(|function| function.heading_span == span)
|
||||
.or_else(|| {
|
||||
self.functions
|
||||
.iter()
|
||||
.find(|function| function.span.contains(span))
|
||||
})
|
||||
}
|
||||
|
||||
/// All statements of all functions, flattened in deterministic order.
|
||||
pub fn all_statements(&self) -> Vec<(&SemanticFunction, &SemanticStatement)> {
|
||||
let mut out = Vec::new();
|
||||
for function in &self.functions {
|
||||
for statement in function.flattened_statements() {
|
||||
out.push((function, statement));
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The innermost statement whose span is contained in `inline_span`.
|
||||
pub fn statement_for_inline(
|
||||
&self,
|
||||
inline_span: SourceSpan,
|
||||
) -> Option<(&SemanticFunction, &SemanticStatement)> {
|
||||
self.all_statements()
|
||||
.into_iter()
|
||||
.filter(|(_, statement)| {
|
||||
statement.span.start >= inline_span.start
|
||||
&& statement.span.end <= inline_span.end
|
||||
&& !statement.span.is_empty()
|
||||
})
|
||||
.max_by_key(|(_, statement)| statement.span.start)
|
||||
}
|
||||
|
||||
pub fn resource_for_span(&self, span: SourceSpan) -> Option<&StaticResource> {
|
||||
self.resources
|
||||
.iter()
|
||||
.find(|resource| resource.span == span || resource.span.contains(span))
|
||||
}
|
||||
|
||||
pub fn reference_for_span(&self, span: SourceSpan) -> Option<&StaticReference> {
|
||||
self.references
|
||||
.iter()
|
||||
.find(|reference| reference.span == span || reference.span.contains(span))
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Raw protocol types (additive fields are tolerated and ignored).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawAnalysis {
|
||||
schema: String,
|
||||
schema_version: u32,
|
||||
producer: RawProducer,
|
||||
project: RawProject,
|
||||
modules: Vec<RawModule>,
|
||||
#[serde(default)]
|
||||
diagnostics: Vec<RawDiagnostic>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawProducer {
|
||||
#[serde(default)]
|
||||
name: String,
|
||||
#[serde(default)]
|
||||
version: String,
|
||||
#[serde(default)]
|
||||
markdown_profile: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawProject {
|
||||
#[serde(default)]
|
||||
root_id: String,
|
||||
#[serde(default)]
|
||||
identity_kind: String,
|
||||
#[serde(default)]
|
||||
lock_digest: String,
|
||||
#[serde(default)]
|
||||
stdlib: Option<RawStdlib>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawStdlib {
|
||||
#[serde(default)]
|
||||
version: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawModule {
|
||||
#[serde(default)]
|
||||
id: String,
|
||||
#[serde(default)]
|
||||
package_instance_id: String,
|
||||
#[serde(default)]
|
||||
relative_path: String,
|
||||
#[serde(default)]
|
||||
source_digest: String,
|
||||
#[serde(default)]
|
||||
units: Vec<RawUnit>,
|
||||
#[serde(default)]
|
||||
functions: Vec<RawFunction>,
|
||||
#[serde(default)]
|
||||
imports: Vec<RawImport>,
|
||||
#[serde(default)]
|
||||
references: Vec<RawReference>,
|
||||
#[serde(default)]
|
||||
calls: Vec<RawCall>,
|
||||
#[serde(default)]
|
||||
resources: Vec<RawResource>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawUnit {
|
||||
#[serde(default)]
|
||||
id: String,
|
||||
#[serde(default)]
|
||||
name: String,
|
||||
#[serde(default)]
|
||||
level: u8,
|
||||
#[serde(default)]
|
||||
kind: String,
|
||||
#[serde(default)]
|
||||
function: Option<String>,
|
||||
#[serde(default)]
|
||||
span: Option<SourceSpan>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawFunction {
|
||||
#[serde(default)]
|
||||
id: String,
|
||||
#[serde(default)]
|
||||
unit_id: String,
|
||||
#[serde(default)]
|
||||
local_name: String,
|
||||
#[serde(default)]
|
||||
namespace: Option<String>,
|
||||
#[serde(default)]
|
||||
span: Option<SourceSpan>,
|
||||
#[serde(default)]
|
||||
heading_span: Option<SourceSpan>,
|
||||
#[serde(default)]
|
||||
signature: Option<RawSignature>,
|
||||
#[serde(default)]
|
||||
effects: Vec<String>,
|
||||
#[serde(default)]
|
||||
body: Vec<RawStatement>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawSignature {
|
||||
#[serde(default)]
|
||||
kind: String,
|
||||
#[serde(default)]
|
||||
params: Vec<RawParam>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawParam {
|
||||
#[serde(default)]
|
||||
name: String,
|
||||
#[serde(default, rename = "type")]
|
||||
ty: Option<String>,
|
||||
#[serde(default)]
|
||||
required: bool,
|
||||
#[serde(default)]
|
||||
default: Option<Value>,
|
||||
#[serde(default)]
|
||||
span: Option<SourceSpan>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawStatement {
|
||||
#[serde(default)]
|
||||
kind: String,
|
||||
#[serde(default)]
|
||||
span: Option<SourceSpan>,
|
||||
#[serde(default)]
|
||||
condition_span: Option<SourceSpan>,
|
||||
#[serde(default)]
|
||||
arms: Vec<RawArm>,
|
||||
#[serde(default)]
|
||||
body: Vec<RawStatement>,
|
||||
#[serde(default)]
|
||||
target: Option<Value>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawArm {
|
||||
#[serde(default)]
|
||||
span: Option<SourceSpan>,
|
||||
#[serde(default)]
|
||||
condition_span: Option<SourceSpan>,
|
||||
#[serde(default)]
|
||||
body: Vec<RawStatement>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawResource {
|
||||
#[serde(default)]
|
||||
id: String,
|
||||
#[serde(default)]
|
||||
kind: String,
|
||||
#[serde(default)]
|
||||
span: Option<SourceSpan>,
|
||||
#[serde(default)]
|
||||
content_digest: String,
|
||||
#[serde(default)]
|
||||
language: Option<String>,
|
||||
#[serde(default)]
|
||||
display: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawImport {
|
||||
#[serde(default)]
|
||||
alias: String,
|
||||
#[serde(default)]
|
||||
target: String,
|
||||
#[serde(default)]
|
||||
resolved: Option<String>,
|
||||
#[serde(default)]
|
||||
span: Option<SourceSpan>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawReference {
|
||||
#[serde(default)]
|
||||
url: String,
|
||||
#[serde(default)]
|
||||
state: String,
|
||||
#[serde(default)]
|
||||
target_module: Option<String>,
|
||||
#[serde(default)]
|
||||
target_unit: Option<String>,
|
||||
#[serde(default)]
|
||||
span: Option<SourceSpan>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawCall {
|
||||
#[serde(default)]
|
||||
state: String,
|
||||
#[serde(default)]
|
||||
target: Option<String>,
|
||||
#[serde(default)]
|
||||
function: Option<String>,
|
||||
#[serde(default)]
|
||||
span: Option<SourceSpan>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawDiagnostic {
|
||||
#[serde(default)]
|
||||
module: Option<String>,
|
||||
#[serde(default)]
|
||||
relative_path: Option<String>,
|
||||
#[serde(default)]
|
||||
span: Option<SourceSpan>,
|
||||
#[serde(default)]
|
||||
line: Option<u64>,
|
||||
#[serde(default)]
|
||||
column: Option<u64>,
|
||||
#[serde(default)]
|
||||
severity: String,
|
||||
#[serde(default)]
|
||||
code: String,
|
||||
#[serde(default)]
|
||||
message: String,
|
||||
#[serde(default)]
|
||||
hints: Vec<String>,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Validation
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Verify Analysis bytes against the exact source and project the static facts.
|
||||
///
|
||||
/// Rejects protocol incompatibility and source-digest mismatch as errors; drops
|
||||
/// individual invalid spans as warnings so the prose stays readable.
|
||||
pub fn verify_analysis(
|
||||
analysis_bytes: &[u8],
|
||||
source: &str,
|
||||
source_index: &SourceIndex,
|
||||
expected_relative_path: &str,
|
||||
) -> ViewResult<VerifiedAnalysis> {
|
||||
let raw: RawAnalysis =
|
||||
serde_json::from_slice(analysis_bytes).map_err(|err| ViewError::AnalysisFailed {
|
||||
detail: format!("Analysis is not valid JSON: {err}"),
|
||||
})?;
|
||||
if raw.schema != "marqdo.analysis" {
|
||||
return Err(ViewError::ProtocolIncompatible {
|
||||
detail: format!("unexpected Analysis schema {:?}", raw.schema),
|
||||
});
|
||||
}
|
||||
if !crate::protocol::tool_v1::ANALYSIS_PROTOCOLS.contains(&raw.schema_version) {
|
||||
return Err(ViewError::ProtocolIncompatible {
|
||||
detail: format!(
|
||||
"Analysis schema_version {} is not supported (View implements v2/v3)",
|
||||
raw.schema_version
|
||||
),
|
||||
});
|
||||
}
|
||||
if raw.producer.name != "marqdo" {
|
||||
return Err(ViewError::ProtocolIncompatible {
|
||||
detail: format!(
|
||||
"Analysis producer.name {:?} is not `marqdo`",
|
||||
raw.producer.name
|
||||
),
|
||||
});
|
||||
}
|
||||
if raw.producer.markdown_profile != "marqdo.md.v1" {
|
||||
return Err(ViewError::ProtocolIncompatible {
|
||||
detail: format!(
|
||||
"unexpected Markdown profile {:?}; this View targets marqdo.md.v1",
|
||||
raw.producer.markdown_profile
|
||||
),
|
||||
});
|
||||
}
|
||||
if raw.project.root_id.is_empty() {
|
||||
return Err(ViewError::AnalysisFailed {
|
||||
detail: "Analysis project.root_id is empty".to_string(),
|
||||
});
|
||||
}
|
||||
|
||||
let actual_digest = sha256_hex(source.as_bytes());
|
||||
let module = raw
|
||||
.modules
|
||||
.iter()
|
||||
.find(|module| module.relative_path == expected_relative_path)
|
||||
.ok_or_else(|| ViewError::AnalysisFailed {
|
||||
detail: format!("Analysis has no module for {expected_relative_path}"),
|
||||
})?;
|
||||
if module.source_digest != actual_digest {
|
||||
return Err(ViewError::SourceMismatch {
|
||||
expected: module.source_digest.clone(),
|
||||
actual: actual_digest,
|
||||
});
|
||||
}
|
||||
|
||||
let mut warnings = Vec::new();
|
||||
let mut valid_span = |span: Option<SourceSpan>, what: &str| -> Option<SourceSpan> {
|
||||
let span = span?;
|
||||
if source_index.validate_span_bytes(source.as_bytes(), span) {
|
||||
Some(span)
|
||||
} else {
|
||||
warnings.push(ViewWarning {
|
||||
code: "view.source_span_invalid".to_string(),
|
||||
message: format!("{what} 的字节区间超出源码或不在 UTF-8 边界,已跳过该标注"),
|
||||
span: Some(span),
|
||||
});
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
let units: Vec<SemanticUnit> = module
|
||||
.units
|
||||
.iter()
|
||||
.filter_map(|unit| {
|
||||
let span = valid_span(unit.span, "语义单元")?;
|
||||
Some(SemanticUnit {
|
||||
id: unit.id.clone(),
|
||||
name: unit.name.clone(),
|
||||
level: unit.level,
|
||||
kind: match unit.kind.as_str() {
|
||||
"root" => UnitKind::Root,
|
||||
"namespace" => UnitKind::Namespace,
|
||||
"function" => UnitKind::Function,
|
||||
"knowledge" => UnitKind::Knowledge,
|
||||
"section" => UnitKind::Section,
|
||||
_ => UnitKind::Other,
|
||||
},
|
||||
function: unit.function.clone(),
|
||||
span,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
||||
let functions: Vec<SemanticFunction> = module
|
||||
.functions
|
||||
.iter()
|
||||
.filter_map(|function| {
|
||||
let span = valid_span(function.span, "函数范围")?;
|
||||
let heading_span = valid_span(function.heading_span, "函数标题")?;
|
||||
let statements = function
|
||||
.body
|
||||
.iter()
|
||||
.filter_map(|statement| {
|
||||
convert_statement(statement, raw.schema_version, &mut valid_span)
|
||||
})
|
||||
.collect();
|
||||
Some(SemanticFunction {
|
||||
id: function.id.clone(),
|
||||
unit_id: function.unit_id.clone(),
|
||||
local_name: function.local_name.clone(),
|
||||
namespace: function.namespace.clone(),
|
||||
span,
|
||||
heading_span,
|
||||
signature: FunctionSignature {
|
||||
kind: function
|
||||
.signature
|
||||
.as_ref()
|
||||
.map(|signature| signature.kind.clone())
|
||||
.unwrap_or_default(),
|
||||
params: function
|
||||
.signature
|
||||
.as_ref()
|
||||
.map(|signature| {
|
||||
signature
|
||||
.params
|
||||
.iter()
|
||||
.map(|param| FunctionParam {
|
||||
name: param.name.clone(),
|
||||
ty: param.ty.clone().unwrap_or_default(),
|
||||
required: param.required,
|
||||
default: param.default.as_ref().map(compact_value),
|
||||
span: param.span.filter(|span| {
|
||||
source_index.validate_span_bytes(source.as_bytes(), *span)
|
||||
}),
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
},
|
||||
effects: function.effects.clone(),
|
||||
statements,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
||||
let resources: Vec<StaticResource> = module
|
||||
.resources
|
||||
.iter()
|
||||
.filter(|resource| matches!(resource.kind.as_str(), "formula" | "code"))
|
||||
.filter_map(|resource| {
|
||||
let span = valid_span(resource.span, "资源")?;
|
||||
Some(StaticResource {
|
||||
id: resource.id.clone(),
|
||||
kind: resource.kind.clone(),
|
||||
span,
|
||||
content_digest: resource.content_digest.clone(),
|
||||
language: resource.language.clone(),
|
||||
display: resource.display,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
||||
let imports: Vec<StaticImport> = module
|
||||
.imports
|
||||
.iter()
|
||||
.filter_map(|import| {
|
||||
Some(StaticImport {
|
||||
alias: import.alias.clone(),
|
||||
target: import.target.clone(),
|
||||
resolved: import.resolved.clone(),
|
||||
span: valid_span(import.span, "导入声明")?,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
||||
let references: Vec<StaticReference> = module
|
||||
.references
|
||||
.iter()
|
||||
.filter_map(|reference| {
|
||||
Some(StaticReference {
|
||||
url: reference.url.clone(),
|
||||
state: reference.state.clone(),
|
||||
target_module: reference.target_module.clone(),
|
||||
target_unit: reference.target_unit.clone(),
|
||||
span: valid_span(reference.span, "Markdown 引用")?,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
||||
let calls: Vec<StaticCall> = module
|
||||
.calls
|
||||
.iter()
|
||||
.filter_map(|call| {
|
||||
Some(StaticCall {
|
||||
state: call.state.clone(),
|
||||
target: call.target.clone(),
|
||||
function: call.function.clone(),
|
||||
span: valid_span(call.span, "调用点")?,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
||||
let diagnostics: Vec<CoreDiagnostic> = raw
|
||||
.diagnostics
|
||||
.iter()
|
||||
.map(|diagnostic| {
|
||||
let span = diagnostic
|
||||
.span
|
||||
.filter(|span| source_index.validate_span_bytes(source.as_bytes(), *span));
|
||||
CoreDiagnostic {
|
||||
module: diagnostic.module.clone(),
|
||||
relative_path: diagnostic.relative_path.clone(),
|
||||
span,
|
||||
line: diagnostic.line,
|
||||
column: diagnostic.column,
|
||||
severity: if diagnostic.severity.is_empty() {
|
||||
"error".to_string()
|
||||
} else {
|
||||
diagnostic.severity.clone()
|
||||
},
|
||||
code: diagnostic.code.clone(),
|
||||
message: diagnostic.message.clone(),
|
||||
hints: diagnostic.hints.clone(),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
let modules = raw
|
||||
.modules
|
||||
.iter()
|
||||
.map(|module| ModuleSummary {
|
||||
id: module.id.clone(),
|
||||
package_instance_id: module.package_instance_id.clone(),
|
||||
relative_path: module.relative_path.clone(),
|
||||
source_digest: module.source_digest.clone(),
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok(VerifiedAnalysis {
|
||||
projection: SemanticProjection {
|
||||
schema_version: raw.schema_version,
|
||||
analysis_sha256: sha256_hex(analysis_bytes),
|
||||
analysis_digest: sha256_prefixed(analysis_bytes),
|
||||
producer_version: raw.producer.version.clone(),
|
||||
markdown_profile: raw.producer.markdown_profile.clone(),
|
||||
project_root_id: raw.project.root_id.clone(),
|
||||
identity_kind: raw.project.identity_kind.clone(),
|
||||
lock_digest: raw.project.lock_digest.clone(),
|
||||
stdlib_version: raw.project.stdlib.as_ref().map(|s| s.version.clone()),
|
||||
module_id: module.id.clone(),
|
||||
package_instance_id: module.package_instance_id.clone(),
|
||||
relative_path: module.relative_path.clone(),
|
||||
source_digest: module.source_digest.clone(),
|
||||
units,
|
||||
functions,
|
||||
resources,
|
||||
imports,
|
||||
references,
|
||||
calls,
|
||||
diagnostics,
|
||||
warnings,
|
||||
modules,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
fn convert_statement(
|
||||
raw: &RawStatement,
|
||||
schema_version: u32,
|
||||
valid_span: &mut impl FnMut(Option<SourceSpan>, &str) -> Option<SourceSpan>,
|
||||
) -> Option<SemanticStatement> {
|
||||
let span = valid_span(raw.span, "语句")?;
|
||||
let kind = match raw.kind.as_str() {
|
||||
"assign" => StatementKind::Assign,
|
||||
"expression" => StatementKind::Expression,
|
||||
"branch" => StatementKind::Branch,
|
||||
"loop" => StatementKind::Loop,
|
||||
"return" => StatementKind::Return,
|
||||
"break" if schema_version == 3 => StatementKind::Break,
|
||||
"continue" if schema_version == 3 => StatementKind::Continue,
|
||||
_ => StatementKind::Other,
|
||||
};
|
||||
let body = raw
|
||||
.body
|
||||
.iter()
|
||||
.filter_map(|child| convert_statement(child, schema_version, valid_span))
|
||||
.collect();
|
||||
let arms = raw
|
||||
.arms
|
||||
.iter()
|
||||
.map(|arm| SemanticArm {
|
||||
span: valid_span(arm.span, "分支臂"),
|
||||
condition_span: valid_span(arm.condition_span, "分支条件"),
|
||||
body: arm
|
||||
.body
|
||||
.iter()
|
||||
.filter_map(|child| convert_statement(child, schema_version, valid_span))
|
||||
.collect(),
|
||||
})
|
||||
.collect();
|
||||
Some(SemanticStatement {
|
||||
kind,
|
||||
span,
|
||||
condition_span: valid_span(raw.condition_span, "控制条件"),
|
||||
arms,
|
||||
body,
|
||||
target: raw.target.as_ref().and_then(assignment_target_label),
|
||||
})
|
||||
}
|
||||
|
||||
fn assignment_target_label(target: &Value) -> Option<String> {
|
||||
match target {
|
||||
Value::String(name) => Some(name.clone()),
|
||||
Value::Object(map) => {
|
||||
if map.get("kind").and_then(Value::as_str) == Some("index") {
|
||||
Some("索引赋值".to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn compact_value(value: &Value) -> String {
|
||||
match value {
|
||||
Value::String(text) => text.clone(),
|
||||
other => {
|
||||
let text = other.to_string();
|
||||
if text.chars().count() > 40 {
|
||||
format!("{}…", text.chars().take(40).collect::<String>())
|
||||
} else {
|
||||
text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn analysis(schema_version: u32, digest: &str) -> Vec<u8> {
|
||||
serde_json::json!({
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": schema_version,
|
||||
"producer": {"name": "marqdo", "version": "3.0.0-beta.1", "markdown_profile": "marqdo.md.v1"},
|
||||
"project": {"root_id": "root:t@0.1.0", "identity_kind": "manifest", "lock_digest": "", "stdlib": null},
|
||||
"modules": [{
|
||||
"id": "root:t@0.1.0::index.mq.md",
|
||||
"package_instance_id": "root:t@0.1.0",
|
||||
"relative_path": "index.mq.md",
|
||||
"source_digest": digest,
|
||||
"units": [],
|
||||
"functions": [],
|
||||
"imports": [],
|
||||
"references": [],
|
||||
"calls": [],
|
||||
"resources": []
|
||||
}],
|
||||
"diagnostics": []
|
||||
})
|
||||
.to_string()
|
||||
.into_bytes()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_unknown_schema_major_and_profile() {
|
||||
let source = "# hi\n";
|
||||
let index = SourceIndex::new(source);
|
||||
let digest = sha256_hex(source.as_bytes());
|
||||
let err =
|
||||
verify_analysis(&analysis(4, &digest), source, &index, "index.mq.md").unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_digest_mismatch() {
|
||||
let source = "# hi\n";
|
||||
let index = SourceIndex::new(source);
|
||||
let err = verify_analysis(&analysis(2, &"0".repeat(64)), source, &index, "index.mq.md")
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.source_mismatch");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn projects_valid_analysis() {
|
||||
let source = "# hi\n";
|
||||
let index = SourceIndex::new(source);
|
||||
let digest = sha256_hex(source.as_bytes());
|
||||
let verified =
|
||||
verify_analysis(&analysis(2, &digest), source, &index, "index.mq.md").unwrap();
|
||||
assert_eq!(verified.projection.project_root_id, "root:t@0.1.0");
|
||||
assert_eq!(verified.projection.relative_path, "index.mq.md");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn source_id_is_deterministic_and_bounded() {
|
||||
let span = SourceSpan::new(1, 5);
|
||||
let id = source_id("mod", span, "statement");
|
||||
assert_eq!(id.len(), 16);
|
||||
assert_eq!(id, source_id("mod", span, "statement"));
|
||||
assert_ne!(id, source_id("mod", span, "resource"));
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,355 +0,0 @@
|
||||
//! Decode the CLI's bounded, source-bound NDJSON stream. The browser only
|
||||
//! receives projections selected by this decoder.
|
||||
|
||||
use base64::{engine::general_purpose::STANDARD, Engine};
|
||||
use serde::Deserialize;
|
||||
use serde_json::{json, Value};
|
||||
use std::io::{BufRead, BufReader, Read};
|
||||
|
||||
const SCHEMA: &str = "marqdo.execution-events";
|
||||
const MAX_LINE: usize = 4 * 1024 * 1024;
|
||||
const MAX_CHUNK: usize = 64 * 1024;
|
||||
const MAX_TRANSPORT: usize = 16 * 1024 * 1024;
|
||||
|
||||
pub struct Binding {
|
||||
pub digest: String,
|
||||
pub root: String,
|
||||
pub entry: String,
|
||||
pub function: String,
|
||||
pub mode: String,
|
||||
pub producer: String,
|
||||
pub modules: Vec<String>,
|
||||
pub max_output: usize,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Stream {
|
||||
pub id: String,
|
||||
pub verified: bool,
|
||||
pub truncated: bool,
|
||||
pub stdout: Vec<u8>,
|
||||
pub stderr: Vec<u8>,
|
||||
pub terminal: Option<Value>,
|
||||
pub invalid: bool,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Event {
|
||||
schema: String,
|
||||
schema_version: u32,
|
||||
run_id: String,
|
||||
seq: u64,
|
||||
kind: String,
|
||||
payload: serde_json::Map<String, Value>,
|
||||
}
|
||||
|
||||
pub fn read(input: impl Read, binding: &Binding, mut publish: impl FnMut(Value)) -> Stream {
|
||||
let mut input = BufReader::new(input);
|
||||
let mut stream = Stream::default();
|
||||
let mut line = Vec::new();
|
||||
let mut total = 0;
|
||||
let mut seq = 0;
|
||||
let mut entry_frame_seen = false;
|
||||
loop {
|
||||
line.clear();
|
||||
let size = match input
|
||||
.by_ref()
|
||||
.take(MAX_LINE as u64 + 1)
|
||||
.read_until(b'\n', &mut line)
|
||||
{
|
||||
Ok(0) => break,
|
||||
Ok(size) => size,
|
||||
Err(_) => {
|
||||
stream.invalid = true;
|
||||
break;
|
||||
}
|
||||
};
|
||||
total += size;
|
||||
if total > MAX_TRANSPORT || size > MAX_LINE {
|
||||
stream.invalid = true;
|
||||
break;
|
||||
}
|
||||
if line.last() != Some(&b'\n') {
|
||||
stream.invalid = true;
|
||||
break;
|
||||
}
|
||||
let Ok(event) = serde_json::from_slice::<Event>(&line) else {
|
||||
stream.invalid = true;
|
||||
break;
|
||||
};
|
||||
match consume(&mut stream, binding, event, seq, &mut entry_frame_seen) {
|
||||
Ok(Some(projection)) => publish(projection),
|
||||
Ok(None) => {}
|
||||
Err(()) => {
|
||||
stream.invalid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
seq += 1;
|
||||
}
|
||||
if stream.invalid {
|
||||
// Drain without keeping bytes so a malformed child cannot block on its pipe.
|
||||
let _ = std::io::copy(&mut input, &mut std::io::sink());
|
||||
stream.terminal = None;
|
||||
}
|
||||
stream
|
||||
}
|
||||
|
||||
fn consume(
|
||||
stream: &mut Stream,
|
||||
binding: &Binding,
|
||||
event: Event,
|
||||
seq: u64,
|
||||
entry_frame_seen: &mut bool,
|
||||
) -> Result<Option<Value>, ()> {
|
||||
if event.schema != SCHEMA
|
||||
|| event.schema_version != 1
|
||||
|| event.seq != seq
|
||||
|| event.run_id.is_empty()
|
||||
|| event.run_id.len() > 128
|
||||
|| stream.terminal.is_some()
|
||||
{
|
||||
return Err(());
|
||||
}
|
||||
let payload = &event.payload;
|
||||
let kind = event.kind.as_str();
|
||||
if seq == 0 {
|
||||
if kind != "stream.opened"
|
||||
|| payload.get("protocol") != Some(&json!({"name": SCHEMA, "schema_version": 1}))
|
||||
|| payload
|
||||
.get("producer")
|
||||
.and_then(|value| value["name"].as_str())
|
||||
!= Some("marqdo")
|
||||
|| payload
|
||||
.get("producer")
|
||||
.and_then(|value| value["version"].as_str())
|
||||
!= Some(&binding.producer)
|
||||
|| !payload.get("limits").is_some_and(Value::is_object)
|
||||
|| !payload.get("observation").is_some_and(Value::is_object)
|
||||
{
|
||||
return Err(());
|
||||
}
|
||||
stream.id = event.run_id;
|
||||
return Ok(Some(json!({"seq": seq, "kind": kind})));
|
||||
}
|
||||
if stream.id != event.run_id {
|
||||
return Err(());
|
||||
}
|
||||
let mut projection = json!({"seq": seq, "kind": kind});
|
||||
if seq == 1 {
|
||||
match kind {
|
||||
"run.rejected" => {
|
||||
if text(payload, "status") != Some("rejected") || text(payload, "phase").is_none() {
|
||||
return Err(());
|
||||
}
|
||||
stream.terminal = Some(failure(payload)?);
|
||||
return Ok(None);
|
||||
}
|
||||
"run.started" => {
|
||||
let source = payload.get("source").ok_or(())?;
|
||||
if source["analysis_digest"].as_str() != Some(&binding.digest)
|
||||
|| source["root_id"].as_str() != Some(&binding.root)
|
||||
|| text(payload, "entry") != Some(&binding.entry)
|
||||
|| text(payload, "mode") != Some(&binding.mode)
|
||||
{
|
||||
return Err(());
|
||||
}
|
||||
stream.verified = true;
|
||||
return Ok(Some(projection));
|
||||
}
|
||||
_ => return Err(()),
|
||||
}
|
||||
}
|
||||
match kind {
|
||||
"stream.opened" | "run.started" | "run.rejected" => return Err(()),
|
||||
"stdout.chunk" | "stderr.chunk" => {
|
||||
let data = text(payload, "data_base64").ok_or(())?;
|
||||
if text(payload, "encoding") != Some("base64") || data.len() > MAX_CHUNK.div_ceil(3) * 4
|
||||
{
|
||||
return Err(());
|
||||
}
|
||||
let bytes = STANDARD.decode(data).map_err(|_| ())?;
|
||||
if bytes.len() > MAX_CHUNK
|
||||
|| payload.get("byte_count").and_then(Value::as_u64) != Some(bytes.len() as u64)
|
||||
{
|
||||
return Err(());
|
||||
}
|
||||
if stream.stdout.len() + stream.stderr.len() + bytes.len() > binding.max_output {
|
||||
return Err(());
|
||||
}
|
||||
if kind == "stdout.chunk" {
|
||||
stream.stdout.extend_from_slice(&bytes);
|
||||
} else {
|
||||
stream.stderr.extend_from_slice(&bytes);
|
||||
}
|
||||
projection["data_base64"] = json!(data);
|
||||
}
|
||||
"run.completed" => {
|
||||
let value = payload
|
||||
.get("value")
|
||||
.filter(|value| super::value_wire_v1::valid(value))
|
||||
.ok_or(())?;
|
||||
if text(payload, "status") != Some("ok") || (!*entry_frame_seen && !stream.truncated) {
|
||||
return Err(());
|
||||
}
|
||||
stream.terminal = Some(json!({"success": true, "value": value}));
|
||||
return Ok(None);
|
||||
}
|
||||
"run.failed" => {
|
||||
if text(payload, "status") != Some("error") {
|
||||
return Err(());
|
||||
}
|
||||
stream.terminal = Some(failure(payload)?);
|
||||
return Ok(None);
|
||||
}
|
||||
"observation.truncated" => {
|
||||
if stream.truncated
|
||||
|| !matches!(
|
||||
text(payload, "reason"),
|
||||
Some("event_budget" | "byte_budget")
|
||||
)
|
||||
|| payload.get("limit").and_then(Value::as_u64).is_none()
|
||||
|| payload.get("written").and_then(Value::as_u64).is_none()
|
||||
|| !payload
|
||||
.get("dropped")
|
||||
.is_some_and(|value| value.is_null() || value.is_u64())
|
||||
{
|
||||
return Err(());
|
||||
}
|
||||
stream.truncated = true;
|
||||
}
|
||||
"call.enter" | "call.exit" | "return" | "branch.eval" | "loop.iteration"
|
||||
| "control.break" | "control.continue" | "effect" => {
|
||||
let module = text(payload, "module_id").ok_or(())?;
|
||||
let span = payload.get("span").ok_or(())?;
|
||||
let span_ok = span["start"]
|
||||
.as_u64()
|
||||
.zip(span["end"].as_u64())
|
||||
.is_some_and(|(start, end)| start < end);
|
||||
if !binding.modules.iter().any(|known| known == module)
|
||||
|| !(span_ok
|
||||
|| span.is_null() && !matches!(kind, "control.break" | "control.continue"))
|
||||
|| kind != "effect" && text(payload, "frame_id").is_none()
|
||||
{
|
||||
return Err(());
|
||||
}
|
||||
match kind {
|
||||
"call.enter" => {
|
||||
let function = text(payload, "function_id").ok_or(())?;
|
||||
match payload.get("parent_frame_id") {
|
||||
Some(Value::Null) if !*entry_frame_seen && function == binding.function => {
|
||||
*entry_frame_seen = true
|
||||
}
|
||||
Some(Value::String(_)) if *entry_frame_seen => {}
|
||||
_ => return Err(()),
|
||||
}
|
||||
}
|
||||
"call.exit" if text(payload, "status").is_none() => return Err(()),
|
||||
"return" if text(payload, "value_type").is_none() => return Err(()),
|
||||
"branch.eval" => {
|
||||
projection["decision"] =
|
||||
json!(payload.get("result").and_then(Value::as_bool).ok_or(())?)
|
||||
}
|
||||
"loop.iteration" => {
|
||||
let decision = text(payload, "decision")
|
||||
.filter(|decision| matches!(*decision, "continue" | "exit"))
|
||||
.ok_or(())?;
|
||||
projection["decision"] = json!(decision);
|
||||
}
|
||||
"effect"
|
||||
if text(payload, "operation").is_none()
|
||||
|| text(payload, "result_code").is_none() =>
|
||||
{
|
||||
return Err(())
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
// Values and additive kinds are never emitted as browser observations.
|
||||
_ => return Ok(None),
|
||||
}
|
||||
Ok(Some(projection))
|
||||
}
|
||||
|
||||
fn text<'a>(payload: &'a serde_json::Map<String, Value>, key: &str) -> Option<&'a str> {
|
||||
payload
|
||||
.get(key)?
|
||||
.as_str()
|
||||
.filter(|text| !text.is_empty() && text.len() <= MAX_LINE)
|
||||
}
|
||||
|
||||
fn failure(payload: &serde_json::Map<String, Value>) -> Result<Value, ()> {
|
||||
let error = payload.get("error").ok_or(())?;
|
||||
let code = error["code"].as_str().ok_or(())?;
|
||||
let message = error["message"].as_str().ok_or(())?;
|
||||
Ok(json!({"success": false, "error": {"code": code, "message": message}}))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn sample() -> (Binding, Vec<Value>) {
|
||||
let binding = Binding {
|
||||
digest: "sha256:expected".into(),
|
||||
root: "root:p".into(),
|
||||
entry: "root:p::index.mq.md::main".into(),
|
||||
function: "root:p::index.mq.md::main".into(),
|
||||
mode: "pure".into(),
|
||||
producer: "3.0.0-rc.2".into(),
|
||||
modules: vec!["root:p::index.mq.md".into()],
|
||||
max_output: 100,
|
||||
};
|
||||
let event = |seq, kind, payload| {
|
||||
json!({"schema": SCHEMA, "schema_version": 1, "run_id": "r", "seq": seq,
|
||||
"kind": kind, "payload": payload})
|
||||
};
|
||||
let events = vec![
|
||||
event(
|
||||
0,
|
||||
"stream.opened",
|
||||
json!({"protocol": {"name": SCHEMA, "schema_version": 1},
|
||||
"producer": {"name": "marqdo", "version": binding.producer}, "limits": {}, "observation": {}}),
|
||||
),
|
||||
event(
|
||||
1,
|
||||
"run.started",
|
||||
json!({"entry": binding.entry, "mode": binding.mode,
|
||||
"source": {"analysis_digest": binding.digest, "root_id": binding.root}}),
|
||||
),
|
||||
event(
|
||||
2,
|
||||
"stdout.chunk",
|
||||
json!({"data_base64": "NAo=", "encoding": "base64", "byte_count": 2}),
|
||||
),
|
||||
event(
|
||||
3,
|
||||
"run.failed",
|
||||
json!({"status": "error", "error": {"code": "runtime.test", "message": "test"}}),
|
||||
),
|
||||
];
|
||||
(binding, events)
|
||||
}
|
||||
|
||||
fn decode(binding: &Binding, events: &[Value]) -> Stream {
|
||||
let ndjson = events
|
||||
.iter()
|
||||
.map(|value| format!("{value}\n"))
|
||||
.collect::<String>();
|
||||
read(ndjson.as_bytes(), binding, |_| {})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validates_stream_identity_bytes_and_terminal_boundary() {
|
||||
let (binding, mut events) = sample();
|
||||
let stream = decode(&binding, &events);
|
||||
assert!(stream.verified && !stream.invalid);
|
||||
assert_eq!(stream.stdout, b"4\n");
|
||||
assert!(stream.terminal.is_some());
|
||||
assert!(decode(&binding, &events[..3]).terminal.is_none());
|
||||
events[2]["payload"]["byte_count"] = json!(1);
|
||||
assert!(decode(&binding, &events).invalid);
|
||||
events[1]["payload"]["source"]["analysis_digest"] = json!("wrong");
|
||||
assert!(!decode(&binding, &events).verified);
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -1,10 +1,12 @@
|
||||
//! Public protocol adapters consumed by View.
|
||||
//!
|
||||
//! These modules are a **consumer** of the published CLI formats, never a
|
||||
//! second publisher or implementation of them (RFC-VIEW-0002 §5.3).
|
||||
//! second publisher or implementation of them. Each public boundary has
|
||||
//! exactly one current decoder and one domain projection:
|
||||
//! Analysis v3 (`marqdo.analysis`) and Observation v1 (`marqdo.observation`).
|
||||
//! Retired formats are rejected, never decoded through a fallback.
|
||||
|
||||
pub mod analysis_v2;
|
||||
pub mod execution_events_v1;
|
||||
pub mod analysis_v3;
|
||||
pub mod observation_v1;
|
||||
pub mod tool_v1;
|
||||
pub mod trace_v2;
|
||||
pub mod value_wire_v1;
|
||||
File diff suppressed because it is too large.
Load diff
+60
-91
@@ -1,28 +1,30 @@
|
||||
//! Product/protocol version negotiation with the frozen CLI.
|
||||
//! Current CLI Tool protocol constants (revision 1) and product identity.
|
||||
//!
|
||||
//! Version axes are independent (RFC-VIEW-0001 §4): product SemVer,
|
||||
//! Analysis major, Trace major and Tool protocol. We never infer one from
|
||||
//! another and never silently fall back to a latest-looking JSON.
|
||||
//! A CLI Tool declares exact contract revisions in `tool.json`
|
||||
//! (`requires.api_revision`, optional `analysis`/`observation`). There is no
|
||||
//! negotiation: the installed registration injects only `MARQDO_BIN` and
|
||||
//! `MARQDO_API_REVISION`, and a mismatch is a hard, actionable error.
|
||||
|
||||
use crate::error::{ViewError, ViewResult};
|
||||
use semver::Version;
|
||||
|
||||
/// Product range this View build targets. Must match `tool.json`.
|
||||
pub const PRODUCT_RANGE: &str = ">=3.0.0-beta.1,<4.0.0";
|
||||
/// Product range this View build consumes. The rc.3 contract family is the
|
||||
/// first public pre-release with Observation v1 and Tool revision 1.
|
||||
pub const PRODUCT_RANGE: &str = ">=3.0.0-rc.3,<4.0.0";
|
||||
|
||||
/// Lowest compatible product version (inclusive).
|
||||
pub const MIN_PRODUCT: &str = "3.0.0-beta.1";
|
||||
pub const MIN_PRODUCT: &str = "3.0.0-rc.3";
|
||||
|
||||
pub const TOOL_PROTOCOL: u32 = 1;
|
||||
pub const ANALYSIS_PROTOCOL: u32 = 2;
|
||||
pub const ANALYSIS_PROTOCOLS: [u32; 2] = [2, 3];
|
||||
pub const TRACE_PROTOCOL: u32 = 2;
|
||||
/// CLI Tool API revision implemented by this View build.
|
||||
pub const API_REVISION: u32 = 1;
|
||||
/// Public Analysis revision consumed by this View build.
|
||||
pub const ANALYSIS_REVISION: u32 = 3;
|
||||
/// Public Observation revision consumed by this View build.
|
||||
pub const OBSERVATION_REVISION: u32 = 1;
|
||||
|
||||
/// Environment variables injected by CLI Tool Protocol v1.
|
||||
/// Environment variables injected by the CLI Tool registration.
|
||||
pub const ENV_MARQDO_BIN: &str = "MARQDO_BIN";
|
||||
pub const ENV_TOOL_PROTOCOL: &str = "MARQDO_TOOL_PROTOCOL";
|
||||
pub const ENV_PROTOCOL_ANALYSIS: &str = "MARQDO_PROTOCOL_ANALYSIS";
|
||||
pub const ENV_PROTOCOL_TRACE: &str = "MARQDO_PROTOCOL_TRACE";
|
||||
pub const ENV_MARQDO_API_REVISION: &str = "MARQDO_API_REVISION";
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CoreVersion {
|
||||
@@ -31,7 +33,7 @@ pub struct CoreVersion {
|
||||
pub raw: String,
|
||||
}
|
||||
|
||||
/// Parse the output of `marqdo --version` (`marqdo 3.0.0-beta.1`).
|
||||
/// Parse the output of `marqdo --version` (`marqdo 3.0.0-rc.4`).
|
||||
pub fn parse_version_output(output: &str) -> ViewResult<CoreVersion> {
|
||||
let line = output
|
||||
.lines()
|
||||
@@ -55,103 +57,70 @@ pub fn parse_version_output(output: &str) -> ViewResult<CoreVersion> {
|
||||
})
|
||||
}
|
||||
|
||||
/// True when `version` is inside the product range without relying on
|
||||
/// prerelease quirks of `semver::VersionReq`: any 3.x at or above the first
|
||||
/// beta is accepted, so a later `3.1.0-beta.1` keeps working.
|
||||
/// True when `version` is inside the supported product range.
|
||||
pub fn product_is_compatible(version: &Version) -> bool {
|
||||
let min = Version::parse(MIN_PRODUCT).expect("MIN_PRODUCT is valid SemVer");
|
||||
version.major == 3 && version >= &min
|
||||
}
|
||||
|
||||
/// RC.2 is the first public Core release with Execution Events v1.
|
||||
pub fn supports_execution_events(version: &str) -> bool {
|
||||
let first = Version::parse("3.0.0-rc.2").expect("valid Core version");
|
||||
Version::parse(version).is_ok_and(|version| version >= first)
|
||||
}
|
||||
|
||||
/// Validate the negotiated environment for Tool Protocol v1.
|
||||
/// Validate the CLI-injected API revision, if present.
|
||||
///
|
||||
/// Absence of `MARQDO_PROTOCOL_*` is allowed for a directly-run development
|
||||
/// binary (`--marqdo-bin`), but presence of an unknown major is a hard error.
|
||||
pub fn negotiate_protocol_env(
|
||||
tool_protocol: Option<&str>,
|
||||
analysis_protocol: Option<&str>,
|
||||
trace_protocol: Option<&str>,
|
||||
) -> ViewResult<()> {
|
||||
if let Some(raw) = tool_protocol {
|
||||
let value = parse_env_u32(ENV_TOOL_PROTOCOL, raw)?;
|
||||
if value != TOOL_PROTOCOL {
|
||||
return Err(ViewError::ProtocolIncompatible {
|
||||
detail: format!(
|
||||
"{ENV_TOOL_PROTOCOL}={value} is not supported (this View implements protocol {TOOL_PROTOCOL})"
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
if let Some(raw) = analysis_protocol {
|
||||
let value = parse_env_u32(ENV_PROTOCOL_ANALYSIS, raw)?;
|
||||
if !ANALYSIS_PROTOCOLS.contains(&value) {
|
||||
return Err(ViewError::ProtocolIncompatible {
|
||||
detail: format!(
|
||||
"{ENV_PROTOCOL_ANALYSIS}={value} is not supported (this View implements Analysis v2/v3)"
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
if let Some(raw) = trace_protocol {
|
||||
let value = parse_env_u32(ENV_PROTOCOL_TRACE, raw)?;
|
||||
if value != TRACE_PROTOCOL {
|
||||
return Err(ViewError::ProtocolIncompatible {
|
||||
detail: format!(
|
||||
"{ENV_PROTOCOL_TRACE}={value} is not supported (this View requires Trace v{TRACE_PROTOCOL})"
|
||||
),
|
||||
});
|
||||
}
|
||||
/// Absence is allowed for a directly-run development binary (`--marqdo-bin`);
|
||||
/// a present-but-different revision is a hard error. The value is only a
|
||||
/// static expectation check, never a negotiation input.
|
||||
pub fn validate_api_revision_env(raw: Option<&str>) -> ViewResult<()> {
|
||||
let Some(raw) = raw else {
|
||||
return Ok(());
|
||||
};
|
||||
let value: u32 = raw
|
||||
.trim()
|
||||
.parse()
|
||||
.map_err(|_| ViewError::ProtocolIncompatible {
|
||||
detail: format!("{ENV_MARQDO_API_REVISION}={raw:?} is not a positive integer"),
|
||||
})?;
|
||||
if value != API_REVISION {
|
||||
return Err(ViewError::ProtocolIncompatible {
|
||||
detail: format!(
|
||||
"{ENV_MARQDO_API_REVISION}={value} is not supported; this View implements CLI Tool \
|
||||
API revision {API_REVISION}. Reinstall the rebuilt Tool bundle."
|
||||
),
|
||||
});
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_env_u32(name: &str, raw: &str) -> ViewResult<u32> {
|
||||
raw.trim()
|
||||
.parse::<u32>()
|
||||
.map_err(|_| ViewError::ProtocolIncompatible {
|
||||
detail: format!("{name}={raw:?} is not a positive integer protocol version"),
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn parses_official_version_line() {
|
||||
let version = parse_version_output("marqdo 3.0.0-beta.1\n").unwrap();
|
||||
assert_eq!(version.version.to_string(), "3.0.0-beta.1");
|
||||
let version = parse_version_output("marqdo 3.0.0-rc.4\n").unwrap();
|
||||
assert_eq!(version.version.to_string(), "3.0.0-rc.4");
|
||||
assert!(product_is_compatible(&version.version));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_stable_only_reinterpretation() {
|
||||
// 2.9.1 is the old product line and must never be accepted.
|
||||
let old = Version::parse("2.9.1").unwrap();
|
||||
assert!(!product_is_compatible(&old));
|
||||
// A future major is rejected too.
|
||||
assert!(!product_is_compatible(&Version::parse("4.0.0").unwrap()));
|
||||
// Later prereleases in the 3.x line remain compatible.
|
||||
assert!(product_is_compatible(
|
||||
&Version::parse("3.1.0-beta.1").unwrap()
|
||||
));
|
||||
assert!(product_is_compatible(&Version::parse("3.0.0").unwrap()));
|
||||
fn rejects_retired_and_future_product_lines() {
|
||||
for accepted in ["3.0.0-rc.3", "3.0.0-rc.4", "3.0.0", "3.1.0-beta.1"] {
|
||||
assert!(
|
||||
product_is_compatible(&Version::parse(accepted).unwrap()),
|
||||
"{accepted} must be accepted"
|
||||
);
|
||||
}
|
||||
for rejected in ["2.9.1", "3.0.0-beta.1", "3.0.0-rc.2", "4.0.0"] {
|
||||
assert!(
|
||||
!product_is_compatible(&Version::parse(rejected).unwrap()),
|
||||
"{rejected} must be rejected"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn negotiates_known_protocols_only() {
|
||||
assert!(negotiate_protocol_env(Some("1"), Some("2"), Some("2")).is_ok());
|
||||
assert!(negotiate_protocol_env(None, None, None).is_ok());
|
||||
assert!(negotiate_protocol_env(Some("1"), Some("3"), Some("2")).is_ok());
|
||||
assert!(negotiate_protocol_env(Some("2"), None, None).is_err());
|
||||
assert!(negotiate_protocol_env(None, Some("1"), None).is_err());
|
||||
assert!(negotiate_protocol_env(None, None, Some("3")).is_err());
|
||||
assert!(negotiate_protocol_env(None, Some("two"), None).is_err());
|
||||
fn api_revision_is_an_exact_expectation() {
|
||||
assert!(validate_api_revision_env(None).is_ok());
|
||||
assert!(validate_api_revision_env(Some("1")).is_ok());
|
||||
assert!(validate_api_revision_env(Some("2")).is_err());
|
||||
assert!(validate_api_revision_env(Some("one")).is_err());
|
||||
}
|
||||
}
|
||||
@@ -1,627 +0,0 @@
|
||||
//! Trace v2 validation and run projection.
|
||||
//!
|
||||
//! Trace data is observed execution, not execution itself. Validation is hard:
|
||||
//! the trace must bind to the exact Analysis bytes and project identity, and
|
||||
//! every event module id must exist in Analysis. Missing capabilities (per
|
||||
//! assignment values, memory snapshots, proofs) are explicit `UNSUPPORTED`
|
||||
//! states, never invented (RFC-VIEW-0001 §4.4, §12).
|
||||
|
||||
use crate::error::{ViewError, ViewResult};
|
||||
use crate::protocol::analysis_v2::{ModuleSummary, SemanticProjection};
|
||||
use crate::reader::source::{sha256_hex, sha256_prefixed, SourceIndex, SourceSpan};
|
||||
use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum RunDisplayState {
|
||||
NotRun,
|
||||
StaticOnly,
|
||||
Running,
|
||||
Succeeded,
|
||||
Failed,
|
||||
Stale,
|
||||
Truncated,
|
||||
Unsupported,
|
||||
}
|
||||
|
||||
impl RunDisplayState {
|
||||
pub fn data_value(&self) -> &'static str {
|
||||
match self {
|
||||
RunDisplayState::NotRun => "not-run",
|
||||
RunDisplayState::StaticOnly => "static-only",
|
||||
RunDisplayState::Running => "running",
|
||||
RunDisplayState::Succeeded => "succeeded",
|
||||
RunDisplayState::Failed => "failed",
|
||||
RunDisplayState::Stale => "stale",
|
||||
RunDisplayState::Truncated => "truncated",
|
||||
RunDisplayState::Unsupported => "unsupported",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn label(&self) -> &'static str {
|
||||
match self {
|
||||
RunDisplayState::NotRun => "未运行",
|
||||
RunDisplayState::StaticOnly => "仅静态检查",
|
||||
RunDisplayState::Running => "运行中",
|
||||
RunDisplayState::Succeeded => "运行成功",
|
||||
RunDisplayState::Failed => "运行失败",
|
||||
RunDisplayState::Stale => "结果已过期",
|
||||
RunDisplayState::Truncated => "Trace 已截断",
|
||||
RunDisplayState::Unsupported => "当前协议不支持",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum TraceKind {
|
||||
CallEnter,
|
||||
CallExit,
|
||||
BranchEval,
|
||||
LoopIteration,
|
||||
Return,
|
||||
Effect,
|
||||
Truncated,
|
||||
Other(String),
|
||||
}
|
||||
|
||||
impl TraceKind {
|
||||
pub fn data_value(&self) -> &str {
|
||||
match self {
|
||||
TraceKind::CallEnter => "call.enter",
|
||||
TraceKind::CallExit => "call.exit",
|
||||
TraceKind::BranchEval => "branch.eval",
|
||||
TraceKind::LoopIteration => "loop.iteration",
|
||||
TraceKind::Return => "return",
|
||||
TraceKind::Effect => "effect",
|
||||
TraceKind::Truncated => "trace.truncated",
|
||||
TraceKind::Other(kind) => kind,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse(raw: &str) -> TraceKind {
|
||||
match raw {
|
||||
"call.enter" => TraceKind::CallEnter,
|
||||
"call.exit" => TraceKind::CallExit,
|
||||
"branch.eval" => TraceKind::BranchEval,
|
||||
"loop.iteration" => TraceKind::LoopIteration,
|
||||
"return" => TraceKind::Return,
|
||||
"effect" => TraceKind::Effect,
|
||||
"trace.truncated" => TraceKind::Truncated,
|
||||
other => TraceKind::Other(other.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TraceEvent {
|
||||
pub seq: u64,
|
||||
pub kind: TraceKind,
|
||||
pub function_id: Option<String>,
|
||||
pub module_id: Option<String>,
|
||||
/// Validated span in the entry module; `None` for other modules or invalid
|
||||
/// spans (which are reported as warnings).
|
||||
pub span: Option<SourceSpan>,
|
||||
/// Presentation-only span in an event's own module, kept for the panel.
|
||||
pub raw_span: Option<SourceSpan>,
|
||||
/// Statement span in the entry document this event attaches to, if any.
|
||||
pub anchor_span: Option<SourceSpan>,
|
||||
pub detail: Option<String>,
|
||||
pub operation: Option<String>,
|
||||
pub duration_micros: Option<u64>,
|
||||
}
|
||||
|
||||
impl TraceEvent {
|
||||
pub fn kind_label(&self) -> &str {
|
||||
self.kind.data_value()
|
||||
}
|
||||
|
||||
pub fn is_entry_module(&self, entry_module: &str) -> bool {
|
||||
self.module_id.as_deref() == Some(entry_module)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Truncation {
|
||||
pub reason: String,
|
||||
pub limit: u64,
|
||||
pub written: u64,
|
||||
}
|
||||
|
||||
impl Truncation {
|
||||
pub fn label(&self) -> String {
|
||||
let reason = match self.reason.as_str() {
|
||||
"event_budget" => "事件数量上限",
|
||||
"byte_budget" => "字节上限",
|
||||
other => other,
|
||||
};
|
||||
format!("{reason}(上限 {},已写入 {})", self.limit, self.written)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RunValue {
|
||||
pub ty: String,
|
||||
pub display: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct EventCounts {
|
||||
pub call_enter: usize,
|
||||
pub call_exit: usize,
|
||||
pub branch_eval: usize,
|
||||
pub loop_iteration: usize,
|
||||
pub return_events: usize,
|
||||
pub effect: usize,
|
||||
pub other: usize,
|
||||
}
|
||||
|
||||
impl EventCounts {
|
||||
pub fn total(&self) -> usize {
|
||||
self.call_enter
|
||||
+ self.call_exit
|
||||
+ self.branch_eval
|
||||
+ self.loop_iteration
|
||||
+ self.return_events
|
||||
+ self.effect
|
||||
+ self.other
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RunProjection {
|
||||
pub run_id: String,
|
||||
pub entry: Option<String>,
|
||||
/// Raw `run.status` from the Core (`ok` or a stable runtime error code).
|
||||
pub run_status: String,
|
||||
pub state: RunDisplayState,
|
||||
pub error_code: Option<String>,
|
||||
pub analysis_digest: String,
|
||||
pub events: Vec<TraceEvent>,
|
||||
pub truncated: Option<Truncation>,
|
||||
pub stdout: String,
|
||||
pub stderr: String,
|
||||
pub exit_code: i32,
|
||||
pub result_value: Option<RunValue>,
|
||||
pub counts: EventCounts,
|
||||
/// Counts per event module: entry document vs other modules.
|
||||
pub entry_event_count: usize,
|
||||
pub other_event_count: usize,
|
||||
pub warnings: Vec<String>,
|
||||
}
|
||||
|
||||
impl RunProjection {
|
||||
pub fn state_label(&self) -> &'static str {
|
||||
self.state.label()
|
||||
}
|
||||
|
||||
pub fn is_success(&self) -> bool {
|
||||
matches!(
|
||||
self.state,
|
||||
RunDisplayState::Succeeded | RunDisplayState::Truncated
|
||||
)
|
||||
}
|
||||
|
||||
/// Events whose statement anchor is exactly `span`, in sequence order.
|
||||
pub fn events_for_anchor(&self, span: SourceSpan) -> Vec<&TraceEvent> {
|
||||
self.events
|
||||
.iter()
|
||||
.filter(|event| event.anchor_span == Some(span))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Compact inline summary for one statement anchor, or `None` when the
|
||||
/// statement has no sourced run event.
|
||||
pub fn anchor_summary(&self, span: SourceSpan) -> Option<RunAnchorSummary> {
|
||||
let events = self.events_for_anchor(span);
|
||||
if events.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let last = events.last().expect("non-empty");
|
||||
let mut kinds: Vec<&str> = Vec::new();
|
||||
for event in &events {
|
||||
if !kinds.contains(&event.kind_label()) {
|
||||
kinds.push(event.kind_label());
|
||||
}
|
||||
}
|
||||
let detail = match last.kind {
|
||||
TraceKind::BranchEval => format!("if → {}", last.detail.as_deref().unwrap_or("?")),
|
||||
TraceKind::LoopIteration => {
|
||||
let outcome = match last.detail.as_deref() {
|
||||
Some("continue") => "continue",
|
||||
Some("exit") => "exit",
|
||||
other => other.unwrap_or("?"),
|
||||
};
|
||||
format!("loop {outcome}")
|
||||
}
|
||||
TraceKind::Return => format!("return {}", last.detail.as_deref().unwrap_or("Unit")),
|
||||
TraceKind::CallEnter => "call".to_string(),
|
||||
TraceKind::CallExit => "call exit".to_string(),
|
||||
TraceKind::Effect => format!("effect {}", last.operation.as_deref().unwrap_or("ok")),
|
||||
_ => last.kind_label().to_string(),
|
||||
};
|
||||
Some(RunAnchorSummary {
|
||||
count: events.len(),
|
||||
detail,
|
||||
kinds: kinds.into_iter().map(str::to_string).collect(),
|
||||
last_seq: last.seq,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RunAnchorSummary {
|
||||
pub count: usize,
|
||||
pub detail: String,
|
||||
pub kinds: Vec<String>,
|
||||
pub last_seq: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct VerifiedRun {
|
||||
pub projection: RunProjection,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawTrace {
|
||||
schema: String,
|
||||
schema_version: u32,
|
||||
run: RawRun,
|
||||
source: RawTraceSource,
|
||||
#[serde(default)]
|
||||
truncated: Option<RawTruncation>,
|
||||
#[serde(default)]
|
||||
events: Vec<RawEvent>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawRun {
|
||||
#[serde(default)]
|
||||
id: String,
|
||||
#[serde(default)]
|
||||
entry: Option<String>,
|
||||
#[serde(default)]
|
||||
status: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawTraceSource {
|
||||
#[serde(default)]
|
||||
root_id: String,
|
||||
#[serde(default)]
|
||||
analysis_digest: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawTruncation {
|
||||
#[serde(default)]
|
||||
reason: String,
|
||||
#[serde(default)]
|
||||
limit: u64,
|
||||
#[serde(default)]
|
||||
written: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RawEvent {
|
||||
#[serde(default)]
|
||||
seq: u64,
|
||||
#[serde(default)]
|
||||
kind: String,
|
||||
#[serde(default)]
|
||||
function_id: Option<String>,
|
||||
#[serde(default)]
|
||||
module_id: Option<String>,
|
||||
#[serde(default)]
|
||||
span: Option<SourceSpan>,
|
||||
#[serde(default)]
|
||||
detail: Option<String>,
|
||||
#[serde(default)]
|
||||
operation: Option<String>,
|
||||
#[serde(default)]
|
||||
duration_micros: Option<u64>,
|
||||
}
|
||||
|
||||
pub struct TraceVerificationInput<'a> {
|
||||
pub trace_bytes: &'a [u8],
|
||||
pub analysis_bytes: &'a [u8],
|
||||
pub semantic: &'a SemanticProjection,
|
||||
pub modules: &'a [ModuleSummary],
|
||||
pub source: &'a str,
|
||||
pub source_index: &'a SourceIndex,
|
||||
pub run_json: &'a Value,
|
||||
pub exit_code: i32,
|
||||
}
|
||||
|
||||
/// Verify Trace v2 against the current Analysis and project it for the reader.
|
||||
pub fn verify_trace(input: TraceVerificationInput<'_>) -> ViewResult<VerifiedRun> {
|
||||
let raw: RawTrace =
|
||||
serde_json::from_slice(input.trace_bytes).map_err(|err| ViewError::TraceStale {
|
||||
detail: format!("Trace v2 is not valid JSON: {err}"),
|
||||
})?;
|
||||
if raw.schema != "marqdo.trace" {
|
||||
return Err(ViewError::ProtocolIncompatible {
|
||||
detail: format!("unexpected Trace schema {:?}", raw.schema),
|
||||
});
|
||||
}
|
||||
if raw.schema_version != crate::protocol::tool_v1::TRACE_PROTOCOL {
|
||||
return Err(ViewError::ProtocolIncompatible {
|
||||
detail: format!(
|
||||
"Trace schema_version {} is not supported (View implements v{})",
|
||||
raw.schema_version,
|
||||
crate::protocol::tool_v1::TRACE_PROTOCOL
|
||||
),
|
||||
});
|
||||
}
|
||||
let expected_digest = sha256_prefixed(input.analysis_bytes);
|
||||
if raw.source.analysis_digest != expected_digest {
|
||||
return Err(ViewError::TraceStale {
|
||||
detail: format!(
|
||||
"trace.source.analysis_digest {} does not match current Analysis {}",
|
||||
raw.source.analysis_digest, expected_digest
|
||||
),
|
||||
});
|
||||
}
|
||||
if raw.source.root_id != input.semantic.project_root_id {
|
||||
return Err(ViewError::TraceStale {
|
||||
detail: format!(
|
||||
"trace.source.root_id {} does not match Analysis project {}",
|
||||
raw.source.root_id, input.semantic.project_root_id
|
||||
),
|
||||
});
|
||||
}
|
||||
let known_modules: std::collections::HashSet<&str> = input
|
||||
.modules
|
||||
.iter()
|
||||
.map(|module| module.id.as_str())
|
||||
.collect();
|
||||
for event in &raw.events {
|
||||
if let Some(module) = event.module_id.as_deref() {
|
||||
if !known_modules.contains(module) {
|
||||
return Err(ViewError::TraceStale {
|
||||
detail: format!(
|
||||
"trace event seq {} references unknown module {module}",
|
||||
event.seq
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let entry_module = input.semantic.module_id.as_str();
|
||||
let statements = input.semantic.all_statements();
|
||||
let mut warnings = Vec::new();
|
||||
let mut counts = EventCounts::default();
|
||||
let mut entry_event_count = 0usize;
|
||||
let mut other_event_count = 0usize;
|
||||
let mut events = Vec::with_capacity(raw.events.len());
|
||||
for event in raw.events {
|
||||
let kind = TraceKind::parse(&event.kind);
|
||||
match kind {
|
||||
TraceKind::CallEnter => counts.call_enter += 1,
|
||||
TraceKind::CallExit => counts.call_exit += 1,
|
||||
TraceKind::BranchEval => counts.branch_eval += 1,
|
||||
TraceKind::LoopIteration => counts.loop_iteration += 1,
|
||||
TraceKind::Return => counts.return_events += 1,
|
||||
TraceKind::Effect => counts.effect += 1,
|
||||
_ => counts.other += 1,
|
||||
}
|
||||
let is_entry = event.module_id.as_deref() == Some(entry_module);
|
||||
if is_entry {
|
||||
entry_event_count += 1;
|
||||
} else {
|
||||
other_event_count += 1;
|
||||
}
|
||||
// Only entry-module spans can be anchored to the rendered document.
|
||||
let (span, anchor_span) = if is_entry {
|
||||
match event.span {
|
||||
Some(span)
|
||||
if input
|
||||
.source_index
|
||||
.validate_span_bytes(input.source.as_bytes(), span) =>
|
||||
{
|
||||
let anchor = statements
|
||||
.iter()
|
||||
.filter(|(_, statement)| {
|
||||
statement.span == span
|
||||
|| statement.condition_span == Some(span)
|
||||
|| statement
|
||||
.arms
|
||||
.iter()
|
||||
.any(|arm| arm.condition_span == Some(span))
|
||||
})
|
||||
.min_by_key(|(_, statement)| statement.span.len())
|
||||
.map(|(_, statement)| statement.span)
|
||||
.or_else(|| {
|
||||
statements
|
||||
.iter()
|
||||
.filter(|(_, statement)| statement.span.contains(span))
|
||||
.min_by_key(|(_, statement)| statement.span.len())
|
||||
.map(|(_, statement)| statement.span)
|
||||
});
|
||||
(Some(span), anchor)
|
||||
}
|
||||
other => {
|
||||
if other.is_some() {
|
||||
warnings.push(format!(
|
||||
"事件 seq {} 的 span 超出当前源码或不在 UTF-8 边界,已取消位置绑定",
|
||||
event.seq
|
||||
));
|
||||
}
|
||||
(None, None)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
(None, None)
|
||||
};
|
||||
events.push(TraceEvent {
|
||||
seq: event.seq,
|
||||
kind,
|
||||
function_id: event.function_id,
|
||||
module_id: event.module_id,
|
||||
span,
|
||||
raw_span: event.span,
|
||||
anchor_span,
|
||||
detail: event.detail,
|
||||
operation: event.operation,
|
||||
duration_micros: event.duration_micros,
|
||||
});
|
||||
}
|
||||
// Sequence numbers must be strictly increasing; a broken trace is stale.
|
||||
for pair in events.windows(2) {
|
||||
if pair[1].seq <= pair[0].seq {
|
||||
return Err(ViewError::TraceStale {
|
||||
detail: format!(
|
||||
"trace seq is not strictly increasing ({} then {})",
|
||||
pair[0].seq, pair[1].seq
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let truncated = raw.truncated.map(|truncated| Truncation {
|
||||
reason: truncated.reason,
|
||||
limit: truncated.limit,
|
||||
written: truncated.written,
|
||||
});
|
||||
let run_status = if raw.run.status.is_empty() {
|
||||
"ok".to_string()
|
||||
} else {
|
||||
raw.run.status.clone()
|
||||
};
|
||||
let success = input
|
||||
.run_json
|
||||
.get("success")
|
||||
.and_then(Value::as_bool)
|
||||
.unwrap_or(false);
|
||||
let error_code = input
|
||||
.run_json
|
||||
.get("error")
|
||||
.and_then(|error| error.get("code"))
|
||||
.and_then(Value::as_str)
|
||||
.map(str::to_string)
|
||||
.or_else(|| {
|
||||
if run_status == "ok" {
|
||||
None
|
||||
} else {
|
||||
Some(run_status.clone())
|
||||
}
|
||||
});
|
||||
let state = if truncated.is_some() {
|
||||
RunDisplayState::Truncated
|
||||
} else if success && run_status == "ok" {
|
||||
RunDisplayState::Succeeded
|
||||
} else {
|
||||
RunDisplayState::Failed
|
||||
};
|
||||
let stdout = bounded_text(input.run_json, "stdout", 64 * 1024);
|
||||
let stderr = bounded_text(input.run_json, "stderr", 64 * 1024);
|
||||
let result_value = input.run_json.get("value").and_then(|value| {
|
||||
let ty = value.get("type").and_then(Value::as_str)?;
|
||||
let display = value
|
||||
.get("decimal")
|
||||
.and_then(Value::as_str)
|
||||
.or_else(|| value.get("text").and_then(Value::as_str))
|
||||
.or_else(|| value.get("value").and_then(Value::as_str))
|
||||
.map(str::to_string)
|
||||
.unwrap_or_else(|| compact_json(value));
|
||||
Some(RunValue {
|
||||
ty: ty.to_string(),
|
||||
display,
|
||||
})
|
||||
});
|
||||
let _ = sha256_hex(input.trace_bytes);
|
||||
Ok(VerifiedRun {
|
||||
projection: RunProjection {
|
||||
run_id: raw.run.id,
|
||||
entry: raw.run.entry,
|
||||
run_status,
|
||||
state,
|
||||
error_code,
|
||||
analysis_digest: expected_digest,
|
||||
events,
|
||||
truncated,
|
||||
stdout,
|
||||
stderr,
|
||||
exit_code: input.exit_code,
|
||||
result_value,
|
||||
counts,
|
||||
entry_event_count,
|
||||
other_event_count,
|
||||
warnings,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
fn bounded_text(run_json: &Value, key: &str, limit: usize) -> String {
|
||||
let text = run_json
|
||||
.get(key)
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
if text.len() <= limit {
|
||||
text
|
||||
} else {
|
||||
let mut truncated: String = text.chars().take(limit).collect();
|
||||
truncated.push_str("\n…(输出已截断)");
|
||||
truncated
|
||||
}
|
||||
}
|
||||
|
||||
fn compact_json(value: &Value) -> String {
|
||||
let text = value.to_string();
|
||||
if text.chars().count() > 80 {
|
||||
format!("{}…", text.chars().take(80).collect::<String>())
|
||||
} else {
|
||||
text
|
||||
}
|
||||
}
|
||||
|
||||
/// Build a stale run projection that keeps the raw result accessible without
|
||||
/// binding any event to the current document.
|
||||
pub fn stale_projection(analysis_digest: &str, source: &SourceIndex) -> RunProjection {
|
||||
let _ = source;
|
||||
RunProjection {
|
||||
run_id: String::new(),
|
||||
entry: None,
|
||||
run_status: "stale".to_string(),
|
||||
state: RunDisplayState::Stale,
|
||||
error_code: Some("view.trace_stale".to_string()),
|
||||
analysis_digest: analysis_digest.to_string(),
|
||||
events: Vec::new(),
|
||||
truncated: None,
|
||||
stdout: String::new(),
|
||||
stderr: String::new(),
|
||||
exit_code: 0,
|
||||
result_value: None,
|
||||
counts: EventCounts::default(),
|
||||
entry_event_count: 0,
|
||||
other_event_count: 0,
|
||||
warnings: vec!["Trace 与当前 Analysis 字节摘要不匹配,未绑定任何事件。".to_string()],
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn state_values_are_stable() {
|
||||
assert_eq!(RunDisplayState::Succeeded.data_value(), "succeeded");
|
||||
assert_eq!(RunDisplayState::Truncated.data_value(), "truncated");
|
||||
assert_eq!(RunDisplayState::Failed.data_value(), "failed");
|
||||
assert_eq!(RunDisplayState::Stale.label(), "结果已过期");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trace_kinds_are_additive_safe() {
|
||||
assert_eq!(TraceKind::parse("branch.eval"), TraceKind::BranchEval);
|
||||
assert_eq!(
|
||||
TraceKind::parse("future.event"),
|
||||
TraceKind::Other("future.event".to_string())
|
||||
);
|
||||
assert_eq!(
|
||||
TraceKind::parse("future.event").data_value(),
|
||||
"future.event"
|
||||
);
|
||||
}
|
||||
}
|
||||
+83
-68
@@ -1,12 +1,16 @@
|
||||
//! Assembly of the one `PresentationModel`.
|
||||
//!
|
||||
//! Merges the raw document, verified Analysis v2, diagnostics and an optional
|
||||
//! verified Trace v2 run into the model; decides stale/revoked semantics here
|
||||
//! and nowhere else (RFC-VIEW-0002 §5.2/§5.4).
|
||||
//! Merges the exact artifact source and verified Analysis v3 facts, diagnostics
|
||||
//! and an optional verified Observation v1 run into the model; decides
|
||||
//! stale/revoked semantics here and nowhere else.
|
||||
//!
|
||||
//! The artifact source (`modules[].source`) is the only source used to interpret
|
||||
//! spans. View only re-reads the file before the check to detect concurrent
|
||||
//! changes; it never rebuilds spans from `relative_path`.
|
||||
|
||||
use crate::config::ViewConfig;
|
||||
use crate::protocol::analysis_v2::{CoreDiagnostic, SemanticProjection};
|
||||
use crate::protocol::trace_v2::VerifiedRun;
|
||||
use crate::protocol::analysis_v3::{CoreDiagnostic, SemanticProjection};
|
||||
use crate::protocol::observation_v1::{self, RunProjection};
|
||||
use crate::reader::markdown::{DocumentIdentity, DocumentModel};
|
||||
use crate::reader::model::{
|
||||
Navigation, OutlineEntry, OutlineKind, PresentationModel, SourceStatus,
|
||||
@@ -15,20 +19,19 @@ use crate::reader::source::{sha256_hex, Project, SafeRelativePath};
|
||||
|
||||
use crate::core_client::{CheckOptions, CheckResponse, CoreClient, RawCheckDiagnostic};
|
||||
use crate::error::{ViewError, ViewResult};
|
||||
use crate::protocol::analysis_v2;
|
||||
use crate::protocol::trace_v2;
|
||||
use crate::protocol::analysis_v3;
|
||||
use crate::reader::model::{anchor_for_span, PRESENTATION_VERSION};
|
||||
|
||||
/// Input to the one builder. `analysis` is already protocol/byte verified.
|
||||
pub struct BuildInput<'a> {
|
||||
pub document: DocumentModel,
|
||||
pub analysis: Option<&'a crate::protocol::analysis_v2::VerifiedAnalysis>,
|
||||
pub analysis: Option<&'a analysis_v3::VerifiedAnalysis>,
|
||||
pub status: SourceStatus,
|
||||
pub status_note: Option<String>,
|
||||
pub diagnostics: Vec<CoreDiagnostic>,
|
||||
pub navigation: Navigation,
|
||||
pub core_version: Option<String>,
|
||||
pub run: Option<&'a crate::protocol::trace_v2::VerifiedRun>,
|
||||
pub run: Option<&'a RunProjection>,
|
||||
}
|
||||
|
||||
pub fn build(input: BuildInput<'_>) -> PresentationModel {
|
||||
@@ -81,7 +84,7 @@ pub fn build(input: BuildInput<'_>) -> PresentationModel {
|
||||
navigation,
|
||||
outline,
|
||||
core_version,
|
||||
run: run.map(|verified| verified.projection.clone()),
|
||||
run: run.cloned(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,10 +99,10 @@ fn build_outline(projection: &SemanticProjection) -> Vec<OutlineEntry> {
|
||||
.params
|
||||
.iter()
|
||||
.map(|param| {
|
||||
if param.ty.is_empty() {
|
||||
param.name.clone()
|
||||
if let Some(ty) = ¶m.ty {
|
||||
format!("{}: {}", param.name, ty)
|
||||
} else {
|
||||
format!("{}: {}", param.name, param.ty)
|
||||
param.name.clone()
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
@@ -119,18 +122,19 @@ fn build_outline(projection: &SemanticProjection) -> Vec<OutlineEntry> {
|
||||
}
|
||||
for unit in &projection.units {
|
||||
let kind = match unit.kind {
|
||||
crate::protocol::analysis_v2::UnitKind::Knowledge if unit.level >= 2 => {
|
||||
OutlineKind::Knowledge
|
||||
}
|
||||
crate::protocol::analysis_v2::UnitKind::Section => OutlineKind::Section,
|
||||
analysis_v3::UnitKind::Knowledge if unit.level >= 2 => OutlineKind::Knowledge,
|
||||
analysis_v3::UnitKind::Section => OutlineKind::Section,
|
||||
_ => continue,
|
||||
};
|
||||
if unit.name.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let Some(heading_span) = unit.heading_span else {
|
||||
continue;
|
||||
};
|
||||
entries.push(OutlineEntry {
|
||||
label: unit.name.clone(),
|
||||
anchor: anchor_for_span(unit.span.start, unit.span.end),
|
||||
anchor: anchor_for_span(heading_span.start, heading_span.end),
|
||||
detail: if unit.level == 2 {
|
||||
"知识单元".to_string()
|
||||
} else {
|
||||
@@ -204,26 +208,23 @@ impl DocumentService {
|
||||
self.load_with_run(relative, None)
|
||||
}
|
||||
|
||||
/// Same pipeline, optionally attaching an already-verified run projection.
|
||||
/// Same pipeline, optionally attaching an already-verified Observation run.
|
||||
/// The run is re-bound to freshly checked Analysis bytes; if the source or
|
||||
/// analysis changed meanwhile the result becomes `STALE` instead of being
|
||||
/// attached to the wrong text.
|
||||
pub fn load_with_run(
|
||||
&self,
|
||||
relative: &SafeRelativePath,
|
||||
run: Option<&VerifiedRun>,
|
||||
run: Option<&RunProjection>,
|
||||
) -> ViewResult<PresentationModel> {
|
||||
let source_bytes = self.project.read_source(relative)?;
|
||||
let source = String::from_utf8(source_bytes).map_err(|err| ViewError::Io {
|
||||
detail: format!("{relative} is not valid UTF-8: {err}"),
|
||||
})?;
|
||||
let document = DocumentModel::parse(source, DocumentIdentity::placeholder(relative));
|
||||
let disk_source = self.read_disk_source(relative)?;
|
||||
let navigation = Navigation::from_project(&self.project, &self.config, relative);
|
||||
|
||||
let mut status = SourceStatus::CoreUnavailable;
|
||||
let mut status_note = self.core_note.clone();
|
||||
let mut diagnostics = Vec::new();
|
||||
let mut verified = None;
|
||||
let mut source = disk_source.clone();
|
||||
|
||||
if let Some(client) = &self.core {
|
||||
match client.check(
|
||||
@@ -253,15 +254,15 @@ impl DocumentService {
|
||||
success: true,
|
||||
analysis: Some(check),
|
||||
..
|
||||
} => match analysis_v2::verify_analysis(
|
||||
} => match analysis_v3::verify_analysis(
|
||||
&check.analysis_bytes,
|
||||
&document.source,
|
||||
&document.source_index,
|
||||
relative.as_str(),
|
||||
Some(&disk_source),
|
||||
) {
|
||||
Ok(verified_analysis) => {
|
||||
status = SourceStatus::StaticOk;
|
||||
status_note = None;
|
||||
source = verified_analysis.projection.source.clone();
|
||||
verified = Some(verified_analysis);
|
||||
}
|
||||
Err(err) if err.code() == "view.source_mismatch" => {
|
||||
@@ -290,28 +291,17 @@ impl DocumentService {
|
||||
}
|
||||
}
|
||||
|
||||
let attached_run: Option<VerifiedRun> = match (run, verified.as_ref()) {
|
||||
(Some(run), Some(analysis)) => {
|
||||
let expected = format!("sha256:{}", analysis.projection.analysis_sha256);
|
||||
if expected == run.projection.analysis_digest {
|
||||
Some(VerifiedRun {
|
||||
projection: run.projection.clone(),
|
||||
})
|
||||
} else {
|
||||
Some(VerifiedRun {
|
||||
projection: trace_v2::stale_projection(
|
||||
&run.projection.analysis_digest,
|
||||
&document.source_index,
|
||||
),
|
||||
})
|
||||
}
|
||||
let identity = identity_for(verified.as_ref(), relative);
|
||||
let document = DocumentModel::parse(source, identity);
|
||||
|
||||
let attached_run: Option<RunProjection> = match (run, verified.as_ref()) {
|
||||
(Some(run), Some(analysis))
|
||||
if run.analysis_digest == analysis.projection.analysis_digest
|
||||
&& run.source_verified =>
|
||||
{
|
||||
Some(run.clone())
|
||||
}
|
||||
(Some(run), None) => Some(VerifiedRun {
|
||||
projection: trace_v2::stale_projection(
|
||||
&run.projection.analysis_digest,
|
||||
&document.source_index,
|
||||
),
|
||||
}),
|
||||
(Some(run), _) => Some(observation_v1::stale_projection(&run.analysis_digest)),
|
||||
(None, _) => None,
|
||||
};
|
||||
|
||||
@@ -329,6 +319,31 @@ impl DocumentService {
|
||||
model.media = media;
|
||||
Ok(model)
|
||||
}
|
||||
|
||||
fn read_disk_source(&self, relative: &SafeRelativePath) -> ViewResult<String> {
|
||||
let bytes = self.project.read_source(relative)?;
|
||||
String::from_utf8(bytes).map_err(|err| ViewError::Io {
|
||||
detail: format!("{relative} is not valid UTF-8: {err}"),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn identity_for(
|
||||
verified: Option<&analysis_v3::VerifiedAnalysis>,
|
||||
relative: &SafeRelativePath,
|
||||
) -> DocumentIdentity {
|
||||
match verified {
|
||||
Some(verified) => {
|
||||
let projection = &verified.projection;
|
||||
DocumentIdentity {
|
||||
project_root_id: projection.project_root_id.clone(),
|
||||
module_id: projection.module_id.clone(),
|
||||
relative_path: projection.relative_path.clone(),
|
||||
source_sha256: projection.source_digest.clone(),
|
||||
}
|
||||
}
|
||||
None => DocumentIdentity::placeholder(relative),
|
||||
}
|
||||
}
|
||||
|
||||
fn generic_core_note(err: &ViewError) -> String {
|
||||
@@ -352,11 +367,11 @@ fn diagnostic_to_view(
|
||||
.map(|module| module.ends_with(relative.as_str()))
|
||||
.unwrap_or(true);
|
||||
CoreDiagnostic {
|
||||
module: diagnostic.module.clone(),
|
||||
module: diagnostic.module.clone().unwrap_or_default(),
|
||||
relative_path: if belongs_to_entry {
|
||||
Some(relative.as_str().to_string())
|
||||
relative.as_str().to_string()
|
||||
} else {
|
||||
None
|
||||
String::new()
|
||||
},
|
||||
span: None,
|
||||
line: diagnostic.line,
|
||||
@@ -373,10 +388,11 @@ fn diagnostic_to_view(
|
||||
}
|
||||
|
||||
/// One read-only, byte-verified static view of a document, used by explicit
|
||||
/// run validation and Trace binding. Nothing here executes the document.
|
||||
/// run validation and Observation binding. Nothing here executes the document.
|
||||
#[derive(Debug)]
|
||||
pub struct StaticDocument {
|
||||
pub relative: SafeRelativePath,
|
||||
/// Exact source carried by the verified Analysis artifact.
|
||||
pub source: String,
|
||||
pub source_index: crate::reader::source::SourceIndex,
|
||||
pub source_sha256: String,
|
||||
@@ -384,23 +400,20 @@ pub struct StaticDocument {
|
||||
pub analysis_bytes: Vec<u8>,
|
||||
pub media_digests: std::collections::BTreeMap<String, String>,
|
||||
pub analysis_digest: String,
|
||||
pub verified: crate::protocol::analysis_v2::VerifiedAnalysis,
|
||||
pub core_version: Option<String>,
|
||||
pub verified: analysis_v3::VerifiedAnalysis,
|
||||
}
|
||||
|
||||
impl DocumentService {
|
||||
/// Re-run the read-only `check --emit` and verify Analysis v2 against the
|
||||
/// current exact source bytes. This is the only static truth used before an
|
||||
/// explicit run is accepted.
|
||||
/// Re-run the read-only `check --emit` and verify Analysis v3 bytes against
|
||||
/// the source View read before the check. This is the only static truth used
|
||||
/// before an explicit run is accepted.
|
||||
pub fn static_document(&self, relative: &SafeRelativePath) -> ViewResult<StaticDocument> {
|
||||
let client = self.core.as_ref().ok_or_else(|| ViewError::RunDenied {
|
||||
detail: "没有可用的冻结核心(MARQDO_BIN);无法验证运行请求".to_string(),
|
||||
})?;
|
||||
let source_bytes = self.project.read_source(relative)?;
|
||||
let source_sha256 = sha256_hex(&source_bytes);
|
||||
let source = String::from_utf8(source_bytes).map_err(|err| ViewError::Io {
|
||||
detail: format!("{relative} is not valid UTF-8: {err}"),
|
||||
})?;
|
||||
let source_index = crate::reader::source::SourceIndex::new(&source);
|
||||
let disk_source = self.read_disk_source(relative)?;
|
||||
let disk_sha256 = sha256_hex(disk_source.as_bytes());
|
||||
let response = client.check(
|
||||
&self.project,
|
||||
relative,
|
||||
@@ -438,24 +451,26 @@ impl DocumentService {
|
||||
});
|
||||
}
|
||||
};
|
||||
let verified = crate::protocol::analysis_v2::verify_analysis(
|
||||
let verified = analysis_v3::verify_analysis(
|
||||
&check.analysis_bytes,
|
||||
&source,
|
||||
&source_index,
|
||||
relative.as_str(),
|
||||
Some(&disk_source),
|
||||
)?;
|
||||
let source = verified.projection.source.clone();
|
||||
let source_index = crate::reader::source::SourceIndex::new(&source);
|
||||
let document =
|
||||
DocumentModel::parse(source.clone(), DocumentIdentity::placeholder(relative));
|
||||
DocumentModel::parse(source.clone(), identity_for(Some(&verified), relative));
|
||||
let media = super::media::collect(&self.project, relative, &document.blocks);
|
||||
let media_digests = super::media::digests(&media);
|
||||
Ok(StaticDocument {
|
||||
relative: relative.clone(),
|
||||
source,
|
||||
source_index,
|
||||
source_sha256,
|
||||
source_sha256: disk_sha256,
|
||||
analysis_digest: check.analysis_digest,
|
||||
analysis_bytes: check.analysis_bytes,
|
||||
media_digests,
|
||||
core_version: self.core_version.clone(),
|
||||
verified,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//! source for **typography only**; the resulting tree is converted into a
|
||||
//! View-owned `DocBlock`/`Inline` model that keeps exact UTF-8 byte spans.
|
||||
//! No semantic decision (which node is executable) is taken here — that comes
|
||||
//! exclusively from validated Analysis v2 (`semantic.rs`).
|
||||
//! exclusively from validated Analysis v3 (`protocol::analysis_v3`).
|
||||
|
||||
use crate::reader::source::SafeRelativePath;
|
||||
use crate::reader::source::{sha256_hex, SourceIndex, SourceSpan};
|
||||
|
||||
+4
-4
@@ -5,8 +5,8 @@
|
||||
//! Assembly from Analysis/Trace happens in `reader::assemble`.
|
||||
|
||||
use crate::config::ViewConfig;
|
||||
use crate::protocol::analysis_v2::{CoreDiagnostic, SemanticProjection, ViewWarning};
|
||||
use crate::protocol::trace_v2::{RunDisplayState, RunProjection};
|
||||
use crate::protocol::analysis_v3::{CoreDiagnostic, SemanticProjection, ViewWarning};
|
||||
use crate::protocol::observation_v1::{RunDisplayState, RunProjection};
|
||||
use crate::reader::markdown::DocumentModel;
|
||||
use crate::reader::source::{Project, SafeRelativePath};
|
||||
|
||||
@@ -17,7 +17,7 @@ pub const PRESENTATION_VERSION: u32 = 1;
|
||||
pub enum SourceStatus {
|
||||
/// No usable `MARQDO_BIN`; prose only, semantics explicitly unverified.
|
||||
CoreUnavailable,
|
||||
/// `check` succeeded and Analysis v2 was verified.
|
||||
/// `check` succeeded and Analysis v3 was verified.
|
||||
StaticOk,
|
||||
/// `check` failed; diagnostics shown, semantics revoked.
|
||||
CoreError,
|
||||
@@ -180,7 +180,7 @@ pub fn anchor_for_span(start: u64, end: u64) -> String {
|
||||
format!("mq-h-{start:x}-{end:x}")
|
||||
}
|
||||
|
||||
/// Analysis v2 function ids are `<module id>::<canonical name>`.
|
||||
/// Analysis v3 function ids are `<module id>::<canonical name>`.
|
||||
fn canonical_function_name(function_id: &str, module_id: &str) -> String {
|
||||
function_id
|
||||
.strip_prefix(&format!("{module_id}::"))
|
||||
|
||||
+119
-32
@@ -10,7 +10,7 @@
|
||||
//! Markdown is serialized here from the View-owned `DocBlock` tree, with raw
|
||||
//! HTML omitted by default and every URL scheme sanitized.
|
||||
|
||||
use crate::protocol::analysis_v2::{source_id, UnitKind};
|
||||
use crate::protocol::analysis_v3::{source_id, UnitKind};
|
||||
use crate::reader::assets::AssetBundle;
|
||||
use crate::reader::markdown::{DocBlock, Inline, TableAlign};
|
||||
use crate::reader::model::{anchor_for_span, PresentationModel};
|
||||
@@ -195,7 +195,7 @@ impl ReaderRenderer {
|
||||
<link rel="stylesheet" href="{css}"/>
|
||||
{script}
|
||||
</head>
|
||||
<body class="mq-reader" data-mode="document" data-theme="light" data-annotations="{annotations}" data-size="normal" data-source-status="{status}" data-run-state="{run_state}" data-run-available="{run_available}" data-has-main="{has_main}" data-core-available="{core_available}" data-execution-events="{execution_events}" data-document="{document}" data-analysis-digest="{analysis_digest}" data-run-timeout="{run_timeout}" data-live="{live}">
|
||||
<body class="mq-reader" data-mode="document" data-theme="light" data-annotations="{annotations}" data-size="normal" data-source-status="{status}" data-run-state="{run_state}" data-run-available="{run_available}" data-has-main="{has_main}" data-core-available="{core_available}" data-document="{document}" data-analysis-digest="{analysis_digest}" data-run-timeout="{run_timeout}" data-live="{live}">
|
||||
<a class="mq-skip" href="#mq-main">跳到正文</a>
|
||||
"##,
|
||||
presentation_version = model.version,
|
||||
@@ -210,10 +210,6 @@ impl ReaderRenderer {
|
||||
run_available = if ctx.run_available { "true" } else { "false" },
|
||||
has_main = if has_main { "true" } else { "false" },
|
||||
core_available = if ctx.core_available { "true" } else { "false" },
|
||||
execution_events = model
|
||||
.core_version
|
||||
.as_deref()
|
||||
.is_some_and(crate::protocol::tool_v1::supports_execution_events),
|
||||
document = escape_attr(&relative_path),
|
||||
analysis_digest = escape_attr(&analysis_digest),
|
||||
run_timeout = ctx.run_timeout_secs,
|
||||
@@ -490,7 +486,7 @@ impl ReaderRenderer {
|
||||
match ¤t {
|
||||
Some(current) => {
|
||||
let mut section = None;
|
||||
let place_result = |html: &mut String, function: &crate::protocol::analysis_v2::SemanticFunction| {
|
||||
let place_result = |html: &mut String, function: &crate::protocol::analysis_v3::SemanticFunction| {
|
||||
if ctx.live {
|
||||
let _ = write!(html, "<div class=\"mq-result-slot\" data-result-for=\"{}\"></div>", escape_attr(&function.id));
|
||||
}
|
||||
@@ -563,7 +559,7 @@ impl ReaderRenderer {
|
||||
html,
|
||||
r##"<footer class="mq-footer">
|
||||
<span>Marqdo · 静态阅读</span>
|
||||
<span>Analysis v2 · Trace v2 · {core}</span>
|
||||
<span>Analysis v3 · Observation v1 · {core}</span>
|
||||
<span>默认不执行 · 无自动运行</span>
|
||||
</footer>
|
||||
"##,
|
||||
@@ -585,8 +581,8 @@ impl ReaderRenderer {
|
||||
<div id="mq-run-summary"></div>
|
||||
<pre id="mq-run-stdout" class="mq-stdout" aria-label="程序标准输出" hidden></pre>
|
||||
<pre id="mq-run-stderr" class="mq-stdout mq-stderr" aria-label="程序标准错误" hidden></pre>
|
||||
<details id="mq-run-trace-wrap" class="mq-run-events-wrap" hidden>
|
||||
<summary id="mq-run-trace-title">实时结构事件</summary>
|
||||
<details id="mq-run-observation-wrap" class="mq-run-events-wrap" hidden>
|
||||
<summary id="mq-run-observation-title">实时结构观察事件</summary>
|
||||
<ol id="mq-run-events" class="mq-run-events"></ol>
|
||||
</details>
|
||||
<button type="button" class="mq-fn-call mq-export-result" data-action="export-result" id="mq-export-result" hidden>导出文档(含本次结果)</button>
|
||||
@@ -673,7 +669,7 @@ impl ReaderRenderer {
|
||||
<ul class="mq-menu-list">
|
||||
<li><button type="button" data-action="mode-document">文档态 <span class="mq-menu-hint">原始 Markdown 阅读</span></button></li>
|
||||
<li><button type="button" data-action="mode-source">源码态 <span class="mq-menu-hint">逐行原文,含标记</span></button></li>
|
||||
<li><button type="button" data-action="functions">函数大纲 <span class="mq-menu-hint">来自 Analysis v2/v3</span></button></li>
|
||||
<li><button type="button" data-action="functions">函数大纲 <span class="mq-menu-hint">来自 Analysis v3</span></button></li>
|
||||
<li><button type="button" data-action="unsupported">未提供的能力 <span class="mq-menu-hint">变量 / 内存 / 调试 / 证明</span></button></li>
|
||||
<li><button type="button" data-action="print">打印 <span class="mq-menu-hint">隐藏交互与装饰</span></button></li>
|
||||
<li><button type="button" data-action="about">关于 Marqdo View <span class="mq-menu-hint">版本与协议</span></button></li>
|
||||
@@ -692,7 +688,7 @@ impl ReaderRenderer {
|
||||
{export_dialog}
|
||||
<dialog class="mq-dialog" id="mq-dialog-about" aria-labelledby="mq-about-title">
|
||||
<div class="mq-dialog-head"><h2 id="mq-about-title">关于 Marqdo View</h2><button type="button" class="mq-icon-btn mq-close" data-action="close-dialog" aria-label="关闭关于">×</button></div>
|
||||
<p>版本 {view_version} · Tool Protocol v1 · Analysis v2/v3 · Trace v2。</p>
|
||||
<p>版本 {view_version} · CLI Tool API revision 1 · Analysis v3 · Observation v1。</p>
|
||||
<p>冻结核心:{core}。</p>
|
||||
<p class="mq-colophon">本页面只渲染原始 Markdown 与已校验的静态语义;打开、刷新、搜索、导出都不会执行文档。运行需要用户显式确认。</p>
|
||||
</dialog>
|
||||
@@ -723,7 +719,7 @@ impl ReaderRenderer {
|
||||
html,
|
||||
r##"<section class="mq-run-panel" id="mq-run-panel" data-run-state="{state}" data-run-id="{run_id}" aria-labelledby="mq-run-title">
|
||||
<h2 id="mq-run-title">本次运行 · {label}</h2>
|
||||
<p class="mq-colophon">入口 {entry} · 模式 pure · 退出码 {exit_code} · 事件 {total}(本文 {entry_count} / 其他模块 {other_count})</p>
|
||||
<p class="mq-colophon">入口 {entry} · 观察级别 {capture} · 退出码 {exit_code} · 事件 {total}(本文 {entry_count} / 其他模块 {other_count})</p>
|
||||
"##,
|
||||
state = run.state.data_value(),
|
||||
run_id = escape_attr(&run.run_id),
|
||||
@@ -733,11 +729,16 @@ impl ReaderRenderer {
|
||||
total = counts.total(),
|
||||
entry_count = run.entry_event_count,
|
||||
other_count = run.other_event_count,
|
||||
capture = escape_text(if run.capture_level.is_empty() {
|
||||
"(未知)"
|
||||
} else {
|
||||
&run.capture_level
|
||||
}),
|
||||
);
|
||||
if let Some(truncated) = &run.truncated {
|
||||
let _ = write!(
|
||||
html,
|
||||
"<p class=\"mq-run-warning\" role=\"note\">Trace 被截断:{}</p>\n",
|
||||
"<p class=\"mq-run-warning\" role=\"note\">Observation 已截断:{}</p>\n",
|
||||
escape_text(&truncated.label())
|
||||
);
|
||||
}
|
||||
@@ -778,7 +779,7 @@ impl ReaderRenderer {
|
||||
);
|
||||
}
|
||||
if !run.events.is_empty() {
|
||||
html.push_str("<details class=\"mq-run-events-wrap\" open><summary>真实 Trace v2 事件</summary>\n<ol class=\"mq-run-events\">\n");
|
||||
html.push_str("<details class=\"mq-run-events-wrap\" open><summary>真实 Observation v1 事件</summary>\n<ol class=\"mq-run-events\">\n");
|
||||
for event in run.events.iter().take(200) {
|
||||
let location = match event.span {
|
||||
Some(span) => {
|
||||
@@ -903,6 +904,15 @@ fn render_block(
|
||||
);
|
||||
}
|
||||
let (badge, cleaned) = display_heading_content(content, unit);
|
||||
let section_span = unit
|
||||
.and_then(|unit| unit.span.start.checked_sub(0).map(|_| unit.span))
|
||||
.map(|span| {
|
||||
format!(
|
||||
" data-section-start=\"{}\" data-section-end=\"{}\"",
|
||||
span.start, span.end
|
||||
)
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let data_semantic = if let Some((_, data)) = badge {
|
||||
data
|
||||
} else if let Some(unit) = unit {
|
||||
@@ -916,12 +926,16 @@ fn render_block(
|
||||
};
|
||||
let _ = write!(
|
||||
html,
|
||||
"<h{} id=\"{}\" data-source-id=\"{}\" data-semantic=\"{}\">",
|
||||
"<h{} id=\"{}\" data-source-id=\"{}\" data-semantic=\"{}\"
|
||||
data-heading-start=\"{}\" data-heading-end=\"{}\">",
|
||||
level,
|
||||
escape_attr(slug),
|
||||
source_id_id(model, *span),
|
||||
data_semantic,
|
||||
span.start,
|
||||
span.end,
|
||||
);
|
||||
let _ = section_span;
|
||||
if let Some(badge) = badge {
|
||||
let _ = write!(
|
||||
html,
|
||||
@@ -1095,7 +1109,7 @@ fn resolve_heading_unit(
|
||||
model: &PresentationModel,
|
||||
heading_span: SourceSpan,
|
||||
level: u8,
|
||||
) -> Option<&crate::protocol::analysis_v2::SemanticUnit> {
|
||||
) -> Option<&crate::protocol::analysis_v3::SemanticUnit> {
|
||||
let projection = model.semantic.as_ref()?;
|
||||
// A function heading maps to its function unit exactly; never borrow the
|
||||
// ancestor function for H3/H4 sections (that would duplicate DOM ids).
|
||||
@@ -1115,14 +1129,14 @@ fn resolve_heading_unit(
|
||||
projection
|
||||
.units
|
||||
.iter()
|
||||
.filter(|unit| unit.level == level && unit.span == heading_span)
|
||||
.filter(|unit| unit.level == level && unit.heading_span == Some(heading_span))
|
||||
.min_by_key(|unit| unit.span.len())
|
||||
.or_else(|| projection.unit_for_heading(heading_span, level))
|
||||
}
|
||||
|
||||
fn display_heading_content(
|
||||
content: &[Inline],
|
||||
unit: Option<&crate::protocol::analysis_v2::SemanticUnit>,
|
||||
unit: Option<&crate::protocol::analysis_v3::SemanticUnit>,
|
||||
) -> (Option<(&'static str, &'static str)>, Vec<Inline>) {
|
||||
let Some(unit) = unit else {
|
||||
return (None, content.to_vec());
|
||||
@@ -1312,8 +1326,63 @@ fn render_inline(
|
||||
children,
|
||||
} => {
|
||||
let reference = projection.and_then(|projection| projection.reference_for_span(*span));
|
||||
let state = reference.map(|reference| reference.state.as_str());
|
||||
let target = resolve_link(url, current, model, &ctx.links);
|
||||
let reference_state = reference.map(|reference| reference.state);
|
||||
let reference_href = reference.and_then(|reference| match reference.state {
|
||||
crate::protocol::analysis_v3::ReferenceState::Resolved => {
|
||||
// A resolved module target is linked through the project
|
||||
// document map; the fragment is preserved as written.
|
||||
reference.candidate_path.as_deref().and_then(|candidate| {
|
||||
crate::reader::source::SafeRelativePath::parse(candidate)
|
||||
.ok()
|
||||
.map(|target| {
|
||||
let mut href = ctx.links.document_href(current, &target);
|
||||
if let Some(fragment) = &reference.fragment {
|
||||
if !fragment.is_empty() {
|
||||
href.push('#');
|
||||
href.push_str(&percent_encode_path(fragment));
|
||||
}
|
||||
}
|
||||
href
|
||||
})
|
||||
})
|
||||
}
|
||||
crate::protocol::analysis_v3::ReferenceState::External => {
|
||||
resolve_link(url, current, model, &ctx.links)
|
||||
}
|
||||
_ => None,
|
||||
});
|
||||
let target = match reference {
|
||||
// A local target the loaded catalog did not cover is shown as
|
||||
// unverified, never as a broken link: keep the navigation href
|
||||
// only when the document is known to the project.
|
||||
Some(_reference)
|
||||
if reference_state
|
||||
== Some(crate::protocol::analysis_v3::ReferenceState::NotLoaded) =>
|
||||
{
|
||||
resolve_link(url, current, model, &ctx.links)
|
||||
}
|
||||
Some(_) => reference_href,
|
||||
None => resolve_link(url, current, model, &ctx.links),
|
||||
};
|
||||
let state = reference_state.map(|state| state.data_value());
|
||||
let state_title = match reference_state {
|
||||
Some(crate::protocol::analysis_v3::ReferenceState::NotLoaded) => {
|
||||
"未核验:当前加载目录未覆盖该本地目标"
|
||||
}
|
||||
Some(crate::protocol::analysis_v3::ReferenceState::Missing) => "引用目标缺失",
|
||||
Some(crate::protocol::analysis_v3::ReferenceState::Ambiguous) => {
|
||||
"引用目标不唯一,请检查候选"
|
||||
}
|
||||
Some(crate::protocol::analysis_v3::ReferenceState::OutsideScope) => {
|
||||
"引用目标越出项目范围,已拒绝读取"
|
||||
}
|
||||
Some(crate::protocol::analysis_v3::ReferenceState::Invalid) => "引用地址无效",
|
||||
_ => "",
|
||||
};
|
||||
let unverified = matches!(
|
||||
reference_state,
|
||||
Some(crate::protocol::analysis_v3::ReferenceState::NotLoaded)
|
||||
);
|
||||
match target {
|
||||
Some(href) => {
|
||||
let _ = write!(html, "<a href=\"{href}\"", href = escape_attr(&href));
|
||||
@@ -1323,14 +1392,27 @@ fn render_inline(
|
||||
if let Some(state) = state {
|
||||
let _ = write!(html, " data-reference-state=\"{}\"", escape_attr(state));
|
||||
}
|
||||
if unverified {
|
||||
html.push_str(" class=\"mq-link-unverified\"");
|
||||
}
|
||||
html.push('>');
|
||||
render_inlines(html, children, model, ctx, current, assets_placeholder());
|
||||
html.push_str("</a>");
|
||||
}
|
||||
None => {
|
||||
html.push_str(
|
||||
"<span class=\"mq-link-blocked\" title=\"链接地址已被安全策略移除\">",
|
||||
);
|
||||
let class = if state.is_some() {
|
||||
"mq-link-blocked mq-link-error"
|
||||
} else {
|
||||
"mq-link-blocked"
|
||||
};
|
||||
let _ = write!(html, "<span class=\"{class}\"");
|
||||
if let Some(state) = state {
|
||||
let _ = write!(html, " data-reference-state=\"{}\"", escape_attr(state));
|
||||
}
|
||||
if !state_title.is_empty() {
|
||||
let _ = write!(html, " title=\"{}\"", escape_attr(state_title));
|
||||
}
|
||||
html.push('>');
|
||||
render_inlines(html, children, model, ctx, current, assets_placeholder());
|
||||
html.push_str("</span>");
|
||||
}
|
||||
@@ -1472,14 +1554,19 @@ fn render_snapshot(html: &mut String, overlay: &super::snapshot::ExportResultOve
|
||||
} else {
|
||||
html.push_str("<p class=\"mq-colophon\">参数未包含</p>");
|
||||
}
|
||||
let trace_status = match execution.trace_status.as_str() {
|
||||
let observation_status = match execution.observation_status.as_str() {
|
||||
"verified" => "已验证",
|
||||
"truncated" => "已验证,轨迹截断",
|
||||
"truncated" => "已验证,观察截断",
|
||||
"invalid" => "无效",
|
||||
"stale" => "已过期",
|
||||
_ => "不可用",
|
||||
};
|
||||
let _ = write!(html, "<p class=\"mq-colophon\">Trace v2 {trace_status}</p>");
|
||||
if let Some(counts) = &overlay.trace_counts {
|
||||
let _ = write!(
|
||||
html,
|
||||
"<p class=\"mq-colophon\">Observation v1 {observation_status} · 捕获级别 {capture_level}</p>",
|
||||
capture_level = escape_text(&execution.capture_level),
|
||||
);
|
||||
if let Some(counts) = &overlay.observation_counts {
|
||||
html.push_str("<dl class=\"mq-snapshot-counts\">");
|
||||
for (kind, count) in counts {
|
||||
let _ = write!(html, "<dt>{}</dt><dd>{count}</dd>", escape_text(kind));
|
||||
@@ -1584,7 +1671,7 @@ fn render_run_chips(html: &mut String, model: &PresentationModel, statement_span
|
||||
};
|
||||
let _ = write!(
|
||||
html,
|
||||
"<span class=\"mq-run-chip\" data-run-seq=\"{seq}\" data-run-kind=\"{kinds}\" title=\"真实 Trace 事件:{count} 条({kinds})\">{detail}{suffix}</span>",
|
||||
"<span class=\"mq-run-chip\" data-run-seq=\"{seq}\" data-run-kind=\"{kinds}\" title=\"真实 Observation 事件:{count} 条({kinds})\">{detail}{suffix}</span>",
|
||||
seq = summary.last_seq,
|
||||
kinds = escape_attr(&summary.kinds.join(",")),
|
||||
count = summary.count,
|
||||
@@ -1596,7 +1683,7 @@ fn render_run_chips(html: &mut String, model: &PresentationModel, statement_span
|
||||
fn function_at(
|
||||
model: &PresentationModel,
|
||||
span: SourceSpan,
|
||||
) -> Option<&crate::protocol::analysis_v2::SemanticFunction> {
|
||||
) -> Option<&crate::protocol::analysis_v3::SemanticFunction> {
|
||||
model
|
||||
.semantic
|
||||
.as_ref()?
|
||||
@@ -1606,7 +1693,7 @@ fn function_at(
|
||||
}
|
||||
|
||||
fn function_call_button(
|
||||
function: &crate::protocol::analysis_v2::SemanticFunction,
|
||||
function: &crate::protocol::analysis_v3::SemanticFunction,
|
||||
label: &str,
|
||||
) -> String {
|
||||
format!(
|
||||
@@ -1616,7 +1703,7 @@ fn function_call_button(
|
||||
)
|
||||
}
|
||||
|
||||
fn function_params_json(function: &crate::protocol::analysis_v2::SemanticFunction) -> String {
|
||||
fn function_params_json(function: &crate::protocol::analysis_v3::SemanticFunction) -> String {
|
||||
serde_json::json!(function
|
||||
.signature
|
||||
.params
|
||||
|
||||
+16
-6
@@ -1,4 +1,8 @@
|
||||
//! Renderer input for one explicitly selected, already verified terminal result.
|
||||
//!
|
||||
//! The overlay is bound to the exact pre-run Analysis bytes and to the
|
||||
//! Observation v1 terminal: View never emits a result whose observation run id,
|
||||
//! capture level or truncation state disagrees with the verified run.
|
||||
|
||||
use serde::Serialize;
|
||||
use std::collections::BTreeMap;
|
||||
@@ -13,29 +17,35 @@ pub struct SnapshotSource {
|
||||
pub lock_digest: Option<String>,
|
||||
}
|
||||
|
||||
/// Exact contract revisions this overlay was produced against. There is no
|
||||
/// range negotiation: View only consumes Analysis 3 + Observation 1 + CLI Tool
|
||||
/// API revision 1.
|
||||
#[derive(Serialize)]
|
||||
pub struct SnapshotProtocols {
|
||||
pub struct SnapshotContracts {
|
||||
pub api_revision: u32,
|
||||
pub analysis: u32,
|
||||
pub trace: u32,
|
||||
pub events: u32,
|
||||
pub observation: u32,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct SnapshotExecution {
|
||||
pub included: bool,
|
||||
/// Observation v1 run id (`run.id`/`run_id`).
|
||||
pub core_run_id: String,
|
||||
pub core_version: String,
|
||||
pub target: String,
|
||||
pub status: &'static str,
|
||||
pub terminal_at: String,
|
||||
pub source_verified: bool,
|
||||
pub trace_status: String,
|
||||
/// `verified` | `truncated` | `invalid` | `stale` | `unavailable`.
|
||||
pub observation_status: String,
|
||||
pub capture_level: String,
|
||||
pub result_complete: bool,
|
||||
pub output_complete: bool,
|
||||
pub observation_truncated: bool,
|
||||
pub parameters: &'static str,
|
||||
pub mode: String,
|
||||
pub core_protocol: SnapshotProtocols,
|
||||
pub contracts: SnapshotContracts,
|
||||
}
|
||||
|
||||
pub struct ExportResultOverlay {
|
||||
@@ -45,6 +55,6 @@ pub struct ExportResultOverlay {
|
||||
pub value: Option<String>,
|
||||
pub stdout: Option<String>,
|
||||
pub stderr: Option<String>,
|
||||
pub trace_counts: Option<BTreeMap<String, u64>>,
|
||||
pub observation_counts: Option<BTreeMap<String, u64>>,
|
||||
pub arguments: Option<Vec<(String, String)>>,
|
||||
}
|
||||
+1
-1
@@ -64,7 +64,7 @@ pub fn serve(service: DocumentService, opts: &RuntimeOpts) -> ViewResult<i32> {
|
||||
.unwrap_or(0)
|
||||
);
|
||||
if let Some(version) = state.service.core_version() {
|
||||
eprintln!("core: marqdo {version} (Analysis v2/v3, Trace v2)");
|
||||
eprintln!("core: marqdo {version} (Analysis v3, Observation v1)");
|
||||
} else if let Some(note) = state.service.core_note() {
|
||||
eprintln!("core: unavailable ({note})");
|
||||
}
|
||||
|
||||
@@ -289,8 +289,8 @@ function localHostOnly(url) {
|
||||
check("run panel visible", await page.locator("#mq-run-panel").isVisible());
|
||||
check("run chips anchored", (await page.locator(".mq-run-chip").count()) > 0);
|
||||
check(
|
||||
"observed chips carry trace provenance",
|
||||
(await page.locator('.mq-run-chip[data-annotation-source="trace"]').count()) > 0
|
||||
"observed chips carry observation provenance",
|
||||
(await page.locator('.mq-run-chip[data-annotation-source="observation"]').count()) > 0
|
||||
);
|
||||
check(
|
||||
"static statement anchors carry analysis provenance",
|
||||
@@ -313,7 +313,7 @@ function localHostOnly(url) {
|
||||
}))
|
||||
);
|
||||
check(
|
||||
"trace event list rendered",
|
||||
"observation event list rendered",
|
||||
(await page.locator("#mq-run-events li").count()) > 0
|
||||
);
|
||||
check(
|
||||
@@ -366,14 +366,14 @@ function localHostOnly(url) {
|
||||
await page.click('[data-action="run-confirm"]');
|
||||
await page.waitForSelector('body[data-run-state="succeeded"]');
|
||||
check("installed tool displays the real double(5) result",
|
||||
await page.locator("#mq-run-summary").innerText().then((text) => text.includes("返回值:Int(10)")));
|
||||
await page.locator("#mq-run-summary").innerText().then((text) => text.includes("返回值:10")));
|
||||
|
||||
await page.click('.mq-tabs [data-action="functions"]');
|
||||
await call("format_arguments").click();
|
||||
await page.fill('[data-param-name="label"]', '"浏览器 "');
|
||||
await page.fill('[data-param-name="items"]', '["列表", 7]');
|
||||
await page.click('[data-action="run-confirm"]');
|
||||
await page.getByText("返回值:Text(浏览器 列表 · 7)", { exact: true }).waitFor();
|
||||
await page.getByText("返回值:浏览器 列表 · 7", { exact: true }).waitFor();
|
||||
check("CLI round-tripped Unicode Text and a List through the form", submittedRuns === 2);
|
||||
}
|
||||
|
||||
|
||||
+18
-15
@@ -26,21 +26,21 @@ impl Drop for TestServer {
|
||||
}
|
||||
|
||||
/// Start the real `marqdo-view` binary on an OS-chosen loopback port with a
|
||||
/// scripted fake Core. Golden Analysis must match the project's exact source.
|
||||
/// scripted fake Core. The Analysis golden must match the project's exact source;
|
||||
/// the optional Observation v1 goldens are the exact JSONL stream and snapshot of
|
||||
/// one execution.
|
||||
pub fn start(
|
||||
project: &str,
|
||||
analysis_golden: &str,
|
||||
run_golden: Option<&str>,
|
||||
trace_golden: Option<&str>,
|
||||
observation_golden: Option<(&str, &str)>,
|
||||
) -> TestServer {
|
||||
start_with_env(project, analysis_golden, run_golden, trace_golden, &[])
|
||||
start_with_env(project, analysis_golden, observation_golden, &[])
|
||||
}
|
||||
|
||||
pub fn start_with_env(
|
||||
project: &str,
|
||||
analysis_golden: &str,
|
||||
run_golden: Option<&str>,
|
||||
trace_golden: Option<&str>,
|
||||
observation_golden: Option<(&str, &str)>,
|
||||
envs: &[(&str, &str)],
|
||||
) -> TestServer {
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
@@ -50,11 +50,11 @@ pub fn start_with_env(
|
||||
let core = FakeCore::new(&format!("http-core-{seq}"));
|
||||
let golden = std::fs::read(repo_root.join(analysis_golden)).unwrap();
|
||||
core.set_analysis(std::str::from_utf8(&golden).unwrap());
|
||||
if let Some(run_golden) = run_golden {
|
||||
let run = std::fs::read_to_string(repo_root.join(run_golden)).unwrap();
|
||||
let trace =
|
||||
trace_golden.map(|trace| std::fs::read_to_string(repo_root.join(trace)).unwrap());
|
||||
core.set_run(0, &run, trace.as_deref());
|
||||
if let Some((jsonl_path, snapshot_path)) = observation_golden {
|
||||
let jsonl = std::fs::read_to_string(repo_root.join(jsonl_path)).unwrap();
|
||||
let snapshot = std::fs::read_to_string(repo_root.join(snapshot_path)).unwrap();
|
||||
core.set_check_json(r#"{"command":"check","diagnostics":[],"errors":0,"success":true}"#);
|
||||
core.set_observation(0, &jsonl, Some(&snapshot));
|
||||
}
|
||||
|
||||
let mut command = Command::new(view_bin());
|
||||
@@ -63,9 +63,7 @@ pub fn start_with_env(
|
||||
.args([project, "--port", "0", "--no-open", "--marqdo-bin"])
|
||||
.arg(&core.script)
|
||||
.env_remove("MARQDO_BIN")
|
||||
.env_remove("MARQDO_TOOL_PROTOCOL")
|
||||
.env_remove("MARQDO_PROTOCOL_ANALYSIS")
|
||||
.env_remove("MARQDO_PROTOCOL_TRACE")
|
||||
.env_remove("MARQDO_API_REVISION")
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::piped());
|
||||
for (key, value) in envs {
|
||||
@@ -404,7 +402,12 @@ pub fn collect_until_terminal(reader: &mut SseReader) -> Vec<SseFrame> {
|
||||
.map(|state| {
|
||||
matches!(
|
||||
state,
|
||||
"succeeded" | "failed" | "cancelled" | "timed_out" | "unavailable"
|
||||
"succeeded"
|
||||
| "failed"
|
||||
| "cancelled"
|
||||
| "timed_out"
|
||||
| "unavailable"
|
||||
| "incomplete"
|
||||
)
|
||||
})
|
||||
.unwrap_or(false);
|
||||
|
||||
+75
-24
@@ -58,6 +58,11 @@ impl TempProject {
|
||||
|
||||
/// A scriptable shell-based fake core. Every behaviour is controlled by files
|
||||
/// in its directory, so tests never mutate global environment variables.
|
||||
///
|
||||
/// The current contract is Analysis v3 (`check --emit`) plus Observation v1
|
||||
/// (`run|call --output jsonl [--observation-file PATH]`). The fake core emits the
|
||||
/// exact bytes stored in `analysis.json`, `observation.jsonl` and
|
||||
/// `observation.snapshot.json`; it never fakes a successful verification.
|
||||
pub struct FakeCore {
|
||||
pub dir: PathBuf,
|
||||
pub script: PathBuf,
|
||||
@@ -75,35 +80,34 @@ dir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
||||
} >> "$dir/argv.txt"
|
||||
case "$1" in
|
||||
--version)
|
||||
if [ -f "$dir/version" ]; then cat "$dir/version"; else printf 'marqdo 3.0.0-beta.1\n'; fi
|
||||
if [ -f "$dir/version" ]; then cat "$dir/version"; else printf 'marqdo 3.0.0-rc.4\n'; fi
|
||||
exit 0
|
||||
;;
|
||||
check)
|
||||
if [ -f "$dir/check_stderr" ]; then cat "$dir/check_stderr" >&2; fi
|
||||
if [ -f "$dir/check_json" ]; then cat "$dir/check_json"; fi
|
||||
emit=""
|
||||
prev=""
|
||||
for a in "$@"; do
|
||||
if [ "$prev" = "--emit" ]; then emit="$a"; fi
|
||||
prev="$a"
|
||||
done
|
||||
if [ -f "$dir/check_stderr" ]; then cat "$dir/check_stderr" >&2; fi
|
||||
if [ -f "$dir/check_json" ]; then cat "$dir/check_json"; fi
|
||||
if [ -f "$dir/analysis.json" ] && [ -n "$emit" ]; then cp "$dir/analysis.json" "$emit"; fi
|
||||
if [ -f "$dir/check_exit" ]; then exit "$(cat "$dir/check_exit")"; fi
|
||||
exit 0
|
||||
;;
|
||||
run|call)
|
||||
: > "$dir/run-was-called"
|
||||
if [ -f "$dir/sleep" ]; then
|
||||
sleep "$(cat "$dir/sleep")"
|
||||
fi
|
||||
trace=""
|
||||
obs=""
|
||||
prev=""
|
||||
for a in "$@"; do
|
||||
if [ "$prev" = "--trace-file" ]; then trace="$a"; fi
|
||||
if [ "$prev" = "--observation-file" ]; then obs="$a"; fi
|
||||
prev="$a"
|
||||
done
|
||||
if [ -f "$dir/trace.json" ] && [ -n "$trace" ]; then cp "$dir/trace.json" "$trace"; fi
|
||||
if [ -f "$dir/run.json" ]; then cat "$dir/run.json"; else printf '{"command":"run","success":true}\n'; fi
|
||||
if [ -f "$dir/run_stderr" ]; then cat "$dir/run_stderr" >&2; fi
|
||||
if [ -f "$dir/sleep" ]; then sleep "$(cat "$dir/sleep")"; fi
|
||||
if [ -f "$dir/observation.jsonl" ]; then cat "$dir/observation.jsonl"; fi
|
||||
if [ -f "$dir/observation.snapshot.json" ] && [ -n "$obs" ]; then cp "$dir/observation.snapshot.json" "$obs"; fi
|
||||
if [ -f "$dir/run_exit" ]; then exit "$(cat "$dir/run_exit")"; fi
|
||||
exit 0
|
||||
;;
|
||||
@@ -140,23 +144,33 @@ esac
|
||||
std::fs::write(self.dir.join("analysis.json"), analysis).expect("write analysis");
|
||||
}
|
||||
|
||||
pub fn set_run(&self, exit_code: i32, json: &str, trace: Option<&str>) {
|
||||
/// Terminal code/stderr plus the exact Observation v1 stream and snapshot.
|
||||
pub fn set_observation(&self, exit_code: i32, jsonl: &str, snapshot: Option<&str>) {
|
||||
std::fs::write(self.dir.join("run_exit"), exit_code.to_string()).expect("write run exit");
|
||||
std::fs::write(self.dir.join("run.json"), json).expect("write run json");
|
||||
match trace {
|
||||
Some(trace) => {
|
||||
std::fs::write(self.dir.join("trace.json"), trace).expect("write trace");
|
||||
std::fs::write(self.dir.join("observation.jsonl"), jsonl).expect("write observation");
|
||||
match snapshot {
|
||||
Some(snapshot) => {
|
||||
std::fs::write(self.dir.join("observation.snapshot.json"), snapshot)
|
||||
.expect("write snapshot");
|
||||
}
|
||||
None => {
|
||||
let _ = std::fs::remove_file(self.dir.join("trace.json"));
|
||||
let _ = std::fs::remove_file(self.dir.join("observation.snapshot.json"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_run_stderr(&self, stderr: &str) {
|
||||
std::fs::write(self.dir.join("run_stderr"), stderr).expect("write run stderr");
|
||||
}
|
||||
|
||||
pub fn set_sleep_seconds(&self, seconds: u32) {
|
||||
std::fs::write(self.dir.join("sleep"), seconds.to_string()).expect("write sleep");
|
||||
}
|
||||
|
||||
pub fn run_was_called(&self) -> bool {
|
||||
self.dir.join("run-was-called").exists()
|
||||
}
|
||||
|
||||
pub fn argv_lines(&self) -> Vec<String> {
|
||||
std::fs::read_to_string(self.dir.join("argv.txt"))
|
||||
.unwrap_or_default()
|
||||
@@ -190,29 +204,55 @@ pub fn run_view(args: &[&str], cwd: &Path, envs: &[(&str, Option<&str>)]) -> Out
|
||||
command.output().expect("run marqdo-view")
|
||||
}
|
||||
|
||||
/// Minimal valid Analysis v2 JSON for a single module, with a caller-provided
|
||||
/// source digest and schema version.
|
||||
pub fn minimal_analysis(relative_path: &str, source_digest: &str, schema_version: u32) -> String {
|
||||
/// Minimal valid Analysis v3 JSON for a single module, with a caller-provided
|
||||
/// schema version. The root document/unit spans cover the exact source.
|
||||
pub fn minimal_analysis(relative_path: &str, source: &str, schema_version: u32) -> String {
|
||||
let digest = sha256_hex(source.as_bytes());
|
||||
let module_id = format!("root:fixture@0.1.0::{relative_path}");
|
||||
let len = source.len() as u64;
|
||||
serde_json::json!({
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": schema_version,
|
||||
"producer": {
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-beta.1",
|
||||
"version": "3.0.0-rc.4",
|
||||
"markdown_profile": "marqdo.md.v1"
|
||||
},
|
||||
"project": {
|
||||
"root_id": "root:fixture@0.1.0",
|
||||
"identity_kind": "manifest",
|
||||
"entry_module_id": module_id,
|
||||
"lock_digest": "",
|
||||
"stdlib": null
|
||||
"manifest_digest": "",
|
||||
"stdlib": null,
|
||||
"extensions": []
|
||||
},
|
||||
"modules": [{
|
||||
"id": "root:fixture@0.1.0::index.mq.md",
|
||||
"id": module_id,
|
||||
"package_instance_id": "root:fixture@0.1.0",
|
||||
"relative_path": relative_path,
|
||||
"source_digest": source_digest,
|
||||
"units": [],
|
||||
"source_digest": digest,
|
||||
"source": source,
|
||||
"document": {
|
||||
"kind": "document",
|
||||
"span": {"start": 0, "end": len},
|
||||
"children": []
|
||||
},
|
||||
"units": [{
|
||||
"id": format!("{module_id}#"),
|
||||
"path": [],
|
||||
"parent_id": null,
|
||||
"kind": "root",
|
||||
"name": "",
|
||||
"level": 0,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "default",
|
||||
"mode_source_unit_id": format!("{module_id}#"),
|
||||
"heading_span": null,
|
||||
"span": {"start": 0, "end": len},
|
||||
"function": null
|
||||
}],
|
||||
"anchors": [],
|
||||
"functions": [],
|
||||
"imports": [],
|
||||
"references": [],
|
||||
@@ -224,6 +264,17 @@ pub fn minimal_analysis(relative_path: &str, source_digest: &str, schema_version
|
||||
.to_string()
|
||||
}
|
||||
|
||||
/// The committed golden for one example, as exact bytes.
|
||||
pub fn golden_bytes(path: &str) -> Vec<u8> {
|
||||
let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
std::fs::read(root.join(path)).unwrap_or_else(|err| panic!("read {path}: {err}"))
|
||||
}
|
||||
|
||||
/// The committed golden for one example, as text.
|
||||
pub fn golden_text(path: &str) -> String {
|
||||
String::from_utf8(golden_bytes(path)).expect("golden is UTF-8")
|
||||
}
|
||||
|
||||
pub fn sha256_hex(bytes: &[u8]) -> String {
|
||||
use sha2::{Digest, Sha256};
|
||||
let mut hasher = Sha256::new();
|
||||
|
||||
@@ -6,12 +6,7 @@ use crate::common;
|
||||
use common::run_view;
|
||||
|
||||
fn clean_env() -> Vec<(&'static str, Option<&'static str>)> {
|
||||
vec![
|
||||
("MARQDO_BIN", None),
|
||||
("MARQDO_TOOL_PROTOCOL", None),
|
||||
("MARQDO_PROTOCOL_ANALYSIS", None),
|
||||
("MARQDO_PROTOCOL_TRACE", None),
|
||||
]
|
||||
vec![("MARQDO_BIN", None), ("MARQDO_API_REVISION", None)]
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -36,7 +31,7 @@ fn version_is_the_tool_version() {
|
||||
let output = run_view(&["--version"], &cwd, &clean_env());
|
||||
assert_eq!(output.status.code(), Some(0));
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
assert!(stdout.contains("marqdo-view 0.2.0"), "{stdout}");
|
||||
assert!(stdout.contains("marqdo-view 0.3.0"), "{stdout}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+397
-112
@@ -1,5 +1,5 @@
|
||||
//! Contract tests against a real fake-core executable: argv shape, exit codes,
|
||||
//! stderr handling, temp artifacts and process-tree cleanup.
|
||||
//! stderr handling, temp artifacts and the current Analysis v3 revision.
|
||||
//!
|
||||
//! The fake core is a shell script, not a mocked Rust trait, so everything at
|
||||
//! the process boundary is exercised for real.
|
||||
@@ -7,7 +7,9 @@
|
||||
use crate::common;
|
||||
|
||||
use common::{minimal_analysis, sha256_hex, FakeCore, TempProject};
|
||||
use marqdo_view::core_client::{CheckOptions, CheckResponse, CoreClient, RunOptions};
|
||||
use marqdo_view::core_client::{
|
||||
build_call_args, build_run_args, CheckOptions, CheckResponse, CoreClient, RunOptions,
|
||||
};
|
||||
use marqdo_view::reader::source::Project;
|
||||
|
||||
fn fixture(name: &str) -> (TempProject, FakeCore) {
|
||||
@@ -17,11 +19,15 @@ fn fixture(name: &str) -> (TempProject, FakeCore) {
|
||||
(project, core)
|
||||
}
|
||||
|
||||
fn project_source(project: &TempProject) -> String {
|
||||
std::fs::read_to_string(project.path("index.mq.md")).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_returns_exact_analysis_bytes_and_digest() {
|
||||
let (project, core) = fixture("check_ok");
|
||||
let source = std::fs::read(project.path("index.mq.md")).unwrap();
|
||||
let analysis = minimal_analysis("index.mq.md", &sha256_hex(&source), 2);
|
||||
let source = project_source(&project);
|
||||
let analysis = minimal_analysis("index.mq.md", &source, 3);
|
||||
core.set_analysis(&analysis);
|
||||
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
@@ -42,15 +48,18 @@ fn check_returns_exact_analysis_bytes_and_digest() {
|
||||
let args = core.last_args();
|
||||
assert_eq!(args[0], "check");
|
||||
assert!(args.contains(&"--emit".to_string()));
|
||||
// No `--refs` unless requested.
|
||||
assert!(!args.contains(&"--refs".to_string()));
|
||||
// The retired Analysis v2 selector and trace flags never appear.
|
||||
for retired in ["--trace-file", "--event-stream"] {
|
||||
assert!(!args.contains(&retired.to_string()), "retired {retired}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_refs_is_forwarded_as_a_stricter_flag() {
|
||||
let (project, core) = fixture("check_refs");
|
||||
let source = std::fs::read(project.path("index.mq.md")).unwrap();
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &sha256_hex(&source), 2));
|
||||
let source = project_source(&project);
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &source, 3));
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
@@ -85,107 +94,105 @@ fn check_failure_preserves_core_stderr_and_code() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_returns_json_and_raw_trace() {
|
||||
let (project, core) = fixture("run_ok");
|
||||
core.set_run(
|
||||
0,
|
||||
r#"{"command":"run","success":true,"stdout":"ok","stderr":"","trace":[]}"#,
|
||||
Some(r#"{"schema":"marqdo.trace","schema_version":2,"events":[]}"#),
|
||||
fn run_and_call_argv_use_the_current_observation_flags_only() {
|
||||
let args = build_run_args(
|
||||
std::path::Path::new("/p/index.mq.md"),
|
||||
std::path::Path::new("/t/observation.json"),
|
||||
&RunOptions::default(),
|
||||
);
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let output = client
|
||||
.run(&project, &entry, &RunOptions::default())
|
||||
.unwrap();
|
||||
assert_eq!(output.exit_code, 0);
|
||||
assert_eq!(output.json["success"], true);
|
||||
let trace = output.trace_bytes.expect("trace bytes");
|
||||
assert_eq!(output.trace_sha256.unwrap(), sha256_hex(&trace));
|
||||
// Mode is always explicit; pure is the View default.
|
||||
let args = core.last_args();
|
||||
assert!(args.contains(&"--mode".to_string()));
|
||||
let mode_index = args.iter().position(|a| a == "--mode").unwrap();
|
||||
assert_eq!(args[mode_index + 1], "pure");
|
||||
assert!(args.contains(&"--json".to_string()));
|
||||
assert!(args.contains(&"--trace-file".to_string()));
|
||||
let text: Vec<String> = args
|
||||
.iter()
|
||||
.map(|arg| arg.to_string_lossy().to_string())
|
||||
.collect();
|
||||
assert_eq!(text[0], "run");
|
||||
assert!(text.contains(&"--mode".to_string()));
|
||||
assert!(text.contains(&"pure".to_string()));
|
||||
assert!(text.contains(&"--output".to_string()));
|
||||
assert!(text.contains(&"jsonl".to_string()));
|
||||
assert!(text.contains(&"--observation-file".to_string()));
|
||||
assert!(text.contains(&"--observe-max-events".to_string()));
|
||||
assert!(text.contains(&"--observe-max-bytes".to_string()));
|
||||
assert!(text.contains(&"--observe-max-value-bytes".to_string()));
|
||||
for retired in [
|
||||
"--json",
|
||||
"--trace-file",
|
||||
"--event-stream",
|
||||
"--trace-max-events",
|
||||
"--trace-max-bytes",
|
||||
"--trace-max-value-bytes",
|
||||
] {
|
||||
assert!(
|
||||
!text.contains(&retired.to_string()),
|
||||
"retired flag {retired}"
|
||||
);
|
||||
}
|
||||
assert!(!text
|
||||
.iter()
|
||||
.any(|token| token.contains(';') || token.contains('|') || token.contains('&')));
|
||||
|
||||
let args = build_call_args(
|
||||
std::path::Path::new("/p/index.mq.md"),
|
||||
"demo.calculate",
|
||||
&[("n".to_string(), "3".to_string())],
|
||||
std::path::Path::new("/t/observation.json"),
|
||||
&RunOptions::default(),
|
||||
);
|
||||
let text: Vec<String> = args
|
||||
.iter()
|
||||
.map(|arg| arg.to_string_lossy().to_string())
|
||||
.collect();
|
||||
assert_eq!(text[0], "call");
|
||||
assert!(text.contains(&"--arg".to_string()));
|
||||
assert!(text.contains(&"n=3".to_string()));
|
||||
assert!(text.contains(&"--observation-file".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_without_trace_file_reports_no_trace() {
|
||||
let (project, core) = fixture("run_no_trace");
|
||||
core.set_run(
|
||||
0,
|
||||
r#"{"command":"run","success":true,"stdout":"","stderr":"","trace":[]}"#,
|
||||
None,
|
||||
);
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let output = client
|
||||
.run(&project, &entry, &RunOptions::default())
|
||||
.unwrap();
|
||||
assert!(output.trace_bytes.is_none());
|
||||
assert!(output.trace_sha256.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_invalid_json_is_a_protocol_io_error() {
|
||||
let (project, core) = fixture("run_bad_json");
|
||||
core.set_run(0, "this is not json", None);
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let err = client
|
||||
.run(&project, &entry, &RunOptions::default())
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.io");
|
||||
assert!(err.to_string().contains("exactly one JSON"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn timeout_kills_the_process_group_and_reports_timeout() {
|
||||
let (project, core) = fixture("run_timeout");
|
||||
core.set_sleep_seconds(5);
|
||||
core.set_run(0, r#"{"command":"run","success":true}"#, None);
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let started = std::time::Instant::now();
|
||||
let err = client
|
||||
.run(
|
||||
&project,
|
||||
&entry,
|
||||
&RunOptions {
|
||||
view_timeout: Some(std::time::Duration::from_millis(300)),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap_err();
|
||||
let elapsed = started.elapsed();
|
||||
assert_eq!(err.code(), "view.core_timeout");
|
||||
assert!(
|
||||
elapsed < std::time::Duration::from_secs(3),
|
||||
"timeout took {elapsed:?}"
|
||||
fn default_run_does_not_request_variable_or_parameter_values() {
|
||||
let args = build_run_args(
|
||||
std::path::Path::new("/p/index.mq.md"),
|
||||
std::path::Path::new("/t/observation.json"),
|
||||
&RunOptions::default(),
|
||||
);
|
||||
let text: Vec<String> = args
|
||||
.iter()
|
||||
.map(|arg| arg.to_string_lossy().to_string())
|
||||
.collect();
|
||||
// Budgets are explicit, but no value name is selected by default.
|
||||
for flag in [
|
||||
"--observe-variable",
|
||||
"--observe-parameter",
|
||||
"--observe-text-values",
|
||||
] {
|
||||
assert!(!text.contains(&flag.to_string()), "default {flag}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn incompatible_product_version_is_rejected_before_any_work() {
|
||||
let (project, core) = fixture("version_old");
|
||||
core.set_version("marqdo 2.9.1\n");
|
||||
let (_project, core) = fixture("version_old");
|
||||
core.set_version("marqdo 3.0.0-rc.2\n");
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let err = client.negotiate().unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
assert_eq!(err.exit_code(), 2);
|
||||
// Only `--version` was invoked; no check/run happened.
|
||||
assert_eq!(core.last_args(), vec!["--version".to_string()]);
|
||||
let _ = project;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn current_rc_version_is_accepted() {
|
||||
let (_project, core) = fixture("version_rc4");
|
||||
core.set_version("marqdo 3.0.0-rc.4\n");
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
assert_eq!(
|
||||
client.negotiate().unwrap().version.to_string(),
|
||||
"3.0.0-rc.4"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_emit_after_success_is_an_analysis_failure() {
|
||||
// Fake core exits 0 but writes nothing: never accept a phantom analysis.
|
||||
let (project, core) = fixture("check_no_emit");
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
@@ -196,11 +203,6 @@ fn missing_emit_after_success_is_an_analysis_failure() {
|
||||
assert_eq!(err.code(), "view.analysis_failed");
|
||||
}
|
||||
|
||||
fn expect_check_ok(response: CheckResponse) -> marqdo_view::core_client::CheckOutput {
|
||||
assert!(response.success, "check failed: {:?}", response.diagnostics);
|
||||
response.analysis.expect("analysis on success")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failed_check_normalizes_diagnostics_without_absolute_paths() {
|
||||
let (project, core) = fixture("check_diagnostics");
|
||||
@@ -218,44 +220,152 @@ fn failed_check_normalizes_diagnostics_without_absolute_paths() {
|
||||
assert_eq!(response.diagnostics.len(), 1);
|
||||
assert_eq!(response.diagnostics[0].code, "sem.unclosed_control");
|
||||
assert_eq!(response.diagnostics[0].line, Some(5));
|
||||
// The raw absolute `file` field is not part of the normalized type at all.
|
||||
let rendered = serde_json::to_string(&response.diagnostics).unwrap();
|
||||
assert!(!rendered.contains("/home/secret"), "{rendered}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cli_verify_end_to_end_against_fake_core() {
|
||||
let (project, core) = fixture("verify_cli");
|
||||
let source = std::fs::read(project.path("index.mq.md")).unwrap();
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &sha256_hex(&source), 2));
|
||||
fn analysis_v2_revision_is_a_hard_protocol_error() {
|
||||
let (project, core) = fixture("analysis_v2");
|
||||
let source = project_source(&project);
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &source, 2));
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let check = expect_check_ok(
|
||||
client
|
||||
.check(&project, &entry, &CheckOptions::default())
|
||||
.unwrap(),
|
||||
);
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
&check.analysis_bytes,
|
||||
entry.as_str(),
|
||||
Some(&source),
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
assert_eq!(err.exit_code(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn retired_revision_3_shape_is_rejected_with_a_rebuild_hint() {
|
||||
let (project, core) = fixture("analysis_old_shape");
|
||||
let source = project_source(&project);
|
||||
let mut analysis: serde_json::Value =
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", &source, 3)).unwrap();
|
||||
// An old same-revision artifact has no source/document/anchors/entry id.
|
||||
let module = analysis["modules"][0].as_object_mut().unwrap();
|
||||
module.remove("source");
|
||||
module.remove("document");
|
||||
module.remove("anchors");
|
||||
analysis["project"]
|
||||
.as_object_mut()
|
||||
.unwrap()
|
||||
.remove("entry_module_id");
|
||||
core.set_analysis(&analysis.to_string());
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let check = expect_check_ok(
|
||||
client
|
||||
.check(&project, &entry, &CheckOptions::default())
|
||||
.unwrap(),
|
||||
);
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
&check.analysis_bytes,
|
||||
entry.as_str(),
|
||||
Some(&source),
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
assert!(err.to_string().contains("revision 3"), "{err}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn source_digest_mismatch_is_not_silently_accepted() {
|
||||
let (project, core) = fixture("analysis_digest_mismatch");
|
||||
let source = project_source(&project);
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", "# another document\n", 3));
|
||||
let client = CoreClient::with_bin(&core.script).unwrap();
|
||||
let project = Project::open(&project.path("index.mq.md")).unwrap();
|
||||
let entry = project.entry().relative.clone();
|
||||
let check = expect_check_ok(
|
||||
client
|
||||
.check(&project, &entry, &CheckOptions::default())
|
||||
.unwrap(),
|
||||
);
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
&check.analysis_bytes,
|
||||
entry.as_str(),
|
||||
Some(&source),
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.source_mismatch");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tool_api_revision_environment_is_an_exact_expectation() {
|
||||
// Pure validation: no process-global environment mutation (which would race
|
||||
// with tests running in parallel).
|
||||
use marqdo_view::protocol::tool_v1;
|
||||
assert!(tool_v1::validate_api_revision_env(None).is_ok());
|
||||
assert!(tool_v1::validate_api_revision_env(Some("1")).is_ok());
|
||||
let err = tool_v1::validate_api_revision_env(Some("2")).unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
assert!(tool_v1::validate_api_revision_env(Some("nope")).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn installed_tool_api_revision_is_enforced_at_the_process_boundary() {
|
||||
let (project, core) = fixture("api_revision_cli");
|
||||
core.set_analysis(&minimal_analysis(
|
||||
"index.mq.md",
|
||||
&project_source(&project),
|
||||
3,
|
||||
));
|
||||
let script = core.script.to_str().unwrap().to_string();
|
||||
let dir = project.dir.to_str().unwrap().to_string();
|
||||
let output = common::run_view(
|
||||
&["verify", "index.mq.md", "--marqdo-bin", &script],
|
||||
std::path::Path::new(&dir),
|
||||
&[
|
||||
("MARQDO_BIN", None),
|
||||
("MARQDO_TOOL_PROTOCOL", None),
|
||||
("MARQDO_PROTOCOL_ANALYSIS", None),
|
||||
("MARQDO_PROTOCOL_TRACE", None),
|
||||
],
|
||||
&[("MARQDO_BIN", None), ("MARQDO_API_REVISION", Some("2"))],
|
||||
);
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
assert_eq!(output.status.code(), Some(2), "stderr: {stderr}");
|
||||
assert!(
|
||||
stderr.contains("view.protocol_incompatible"),
|
||||
"stderr: {stderr}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cli_verify_end_to_end_against_fake_core() {
|
||||
let (project, core) = fixture("verify_cli");
|
||||
let source = project_source(&project);
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &source, 3));
|
||||
let script = core.script.to_str().unwrap().to_string();
|
||||
let dir = project.dir.to_str().unwrap().to_string();
|
||||
let output = common::run_view(
|
||||
&["verify", "index.mq.md", "--marqdo-bin", &script],
|
||||
std::path::Path::new(&dir),
|
||||
&[("MARQDO_BIN", None), ("MARQDO_API_REVISION", None)],
|
||||
);
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
assert_eq!(output.status.code(), Some(0), "stderr: {stderr}");
|
||||
assert!(stdout.contains("result: PASS"), "{stdout}");
|
||||
assert!(stdout.contains("marqdo 3.0.0-beta.1"), "{stdout}");
|
||||
assert!(stdout.contains("marqdo 3.0.0-rc.4"), "{stdout}");
|
||||
assert!(!stdout.contains(&dir), "absolute path leaked: {stdout}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cli_verify_rejects_schema_v4_and_digest_mismatch() {
|
||||
fn cli_verify_rejects_schema_v2_and_digest_mismatch() {
|
||||
let (project, core) = fixture("verify_negative");
|
||||
let source = std::fs::read(project.path("index.mq.md")).unwrap();
|
||||
let source = project_source(&project);
|
||||
let script = core.script.to_str().unwrap().to_string();
|
||||
let dir = project.dir.to_str().unwrap().to_string();
|
||||
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &sha256_hex(&source), 4));
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &source, 2));
|
||||
let output = common::run_view(
|
||||
&["verify", "index.mq.md", "--marqdo-bin", &script],
|
||||
std::path::Path::new(&dir),
|
||||
@@ -264,12 +374,187 @@ fn cli_verify_rejects_schema_v4_and_digest_mismatch() {
|
||||
assert_eq!(output.status.code(), Some(2));
|
||||
assert!(String::from_utf8_lossy(&output.stderr).contains("view.protocol_incompatible"));
|
||||
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &"0".repeat(64), 2));
|
||||
// A different, internally consistent document: the exact artifact does not
|
||||
// bind to the checked source. This is a source-mismatch, not a silent retry.
|
||||
core.set_analysis(&minimal_analysis(
|
||||
"index.mq.md",
|
||||
"# a different but internally consistent document\n",
|
||||
3,
|
||||
));
|
||||
let output = common::run_view(
|
||||
&["verify", "index.mq.md", "--marqdo-bin", &script],
|
||||
std::path::Path::new(&dir),
|
||||
&[("MARQDO_BIN", None)],
|
||||
);
|
||||
assert_eq!(output.status.code(), Some(1));
|
||||
assert!(String::from_utf8_lossy(&output.stderr).contains("view.source_mismatch"));
|
||||
assert_eq!(
|
||||
output.status.code(),
|
||||
Some(1),
|
||||
"stderr: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
assert!(
|
||||
String::from_utf8_lossy(&output.stderr).contains("view.source_mismatch"),
|
||||
"stderr: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
|
||||
// A forged source_digest is an internal artifact inconsistency.
|
||||
let mut analysis: serde_json::Value =
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", &source, 3)).unwrap();
|
||||
analysis["modules"][0]["source_digest"] = serde_json::json!("0".repeat(64));
|
||||
core.set_analysis(&analysis.to_string());
|
||||
let output = common::run_view(
|
||||
&["verify", "index.mq.md", "--marqdo-bin", &script],
|
||||
std::path::Path::new(&dir),
|
||||
&[("MARQDO_BIN", None)],
|
||||
);
|
||||
assert_eq!(
|
||||
output.status.code(),
|
||||
Some(1),
|
||||
"stderr: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
assert!(
|
||||
String::from_utf8_lossy(&output.stderr).contains("view.analysis_failed"),
|
||||
"stderr: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
}
|
||||
|
||||
fn expect_check_ok(response: CheckResponse) -> marqdo_view::core_client::CheckOutput {
|
||||
assert!(response.success, "check failed: {:?}", response.diagnostics);
|
||||
response.analysis.expect("analysis on success")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_analysis_schema_name_or_major_is_rejected() {
|
||||
// N02: an artifact with the wrong schema identity or an unknown major is a
|
||||
// protocol error; there is no guess or fallback decoder.
|
||||
let source = "# @knowledge fixture\n";
|
||||
let mut analysis: serde_json::Value =
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", source, 3)).unwrap();
|
||||
analysis["schema"] = serde_json::json!("marqdo.analysis.legacy");
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
analysis.to_string().as_bytes(),
|
||||
"index.mq.md",
|
||||
None,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
|
||||
let mut analysis: serde_json::Value =
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", source, 3)).unwrap();
|
||||
analysis["schema_version"] = serde_json::json!(5);
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
analysis.to_string().as_bytes(),
|
||||
"index.mq.md",
|
||||
None,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_required_analysis_fields_are_rejected() {
|
||||
// N03: required fields are not optional; a missing module/document/unit field
|
||||
// must never decode as an empty, successful document.
|
||||
for field in ["modules", "diagnostics"] {
|
||||
let source = "# @knowledge fixture\n";
|
||||
let mut analysis: serde_json::Value =
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", source, 3)).unwrap();
|
||||
analysis.as_object_mut().unwrap().remove(field);
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
analysis.to_string().as_bytes(),
|
||||
"index.mq.md",
|
||||
None,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible", "field {field}");
|
||||
}
|
||||
let source = "# @knowledge fixture\n";
|
||||
let mut analysis: serde_json::Value =
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", source, 3)).unwrap();
|
||||
analysis["modules"][0]
|
||||
.as_object_mut()
|
||||
.unwrap()
|
||||
.remove("functions");
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
analysis.to_string().as_bytes(),
|
||||
"index.mq.md",
|
||||
None,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_module_and_unit_references_are_rejected() {
|
||||
// N08: resolved references, imports, functions and anchors must point at
|
||||
// records that exist in the same artifact.
|
||||
let source = "# @knowledge fixture\n";
|
||||
let base = minimal_analysis("index.mq.md", source, 3);
|
||||
let module_id = serde_json::from_str::<serde_json::Value>(&base).unwrap()["modules"][0]["id"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.to_string();
|
||||
|
||||
let mut analysis: serde_json::Value = serde_json::from_str(&base).unwrap();
|
||||
analysis["modules"][0]["references"] = serde_json::json!([{
|
||||
"source": module_id,
|
||||
"source_unit": format!("{module_id}#missing"),
|
||||
"url": "./theory.mq.md",
|
||||
"span": {"start": 0, "end": 1},
|
||||
"state": "resolved",
|
||||
"target_kind": "module",
|
||||
"target_module": module_id,
|
||||
"target_unit": null,
|
||||
"candidate_package_instance_id": "root:fixture@0.1.0",
|
||||
"candidate_path": "theory.mq.md",
|
||||
"fragment": null,
|
||||
"candidates": []
|
||||
}]);
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
analysis.to_string().as_bytes(),
|
||||
"index.mq.md",
|
||||
None,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.analysis_failed");
|
||||
|
||||
let mut analysis: serde_json::Value = serde_json::from_str(&base).unwrap();
|
||||
analysis["modules"][0]["imports"] = serde_json::json!([{
|
||||
"alias": "theory",
|
||||
"target": "./theory.mq.md",
|
||||
"resolved": "root:fixture@0.1.0::theory.mq.md",
|
||||
"span": {"start": 0, "end": 1}
|
||||
}]);
|
||||
let err = marqdo_view::protocol::analysis_v3::verify_analysis(
|
||||
analysis.to_string().as_bytes(),
|
||||
"index.mq.md",
|
||||
None,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.analysis_failed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn strict_mode_run_request_is_rejected_by_view_validation() {
|
||||
// N13: View never passes a `strict` mode to the CLI. The request schema
|
||||
// rejects it before any process starts (no retry with project).
|
||||
let body = serde_json::json!({
|
||||
"document": "index.mq.md",
|
||||
"target": {"kind": "entry"},
|
||||
"analysis_digest": format!("sha256:{}", "0".repeat(64)),
|
||||
"mode": "strict",
|
||||
"grants": {"read": [], "write": []},
|
||||
"client_request_id": "strict-1"
|
||||
})
|
||||
.to_string();
|
||||
let err = marqdo_view::execution::request::validate_request(body.as_bytes()).unwrap_err();
|
||||
assert!(
|
||||
matches!(err.code(), "view.run_invalid" | "view.run_denied"),
|
||||
"strict mode must be refused before spawn, got {}",
|
||||
err.code()
|
||||
);
|
||||
assert_eq!(err.exit_code(), 2);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Contract suite: the frozen CLI black-box process contract, Analysis v2 /
|
||||
//! Trace v2 validation, the View CLI surface, and architecture/asset gates.
|
||||
//! Contract suite: the frozen CLI black-box process contract, Analysis v3 /
|
||||
//! Observation v1 validation, the View CLI surface, and architecture/asset gates.
|
||||
|
||||
#[path = "../common/mod.rs"]
|
||||
mod common;
|
||||
@@ -8,5 +8,5 @@ mod asset_integrity;
|
||||
mod cli_surface;
|
||||
mod core_contract;
|
||||
mod no_coupling;
|
||||
mod observation_contract;
|
||||
mod presentation_states;
|
||||
mod trace_contract;
|
||||
@@ -181,9 +181,66 @@ fn tool_manifest_matches_package_and_protocols() {
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
"tool.json version must match Cargo package version"
|
||||
);
|
||||
assert_eq!(tool["compatibility"]["marqdo"], ">=3.0.0-beta.1,<4.0.0");
|
||||
assert_eq!(tool["compatibility"]["analysis"], serde_json::json!([2, 3]));
|
||||
assert_eq!(tool["compatibility"]["trace"], serde_json::json!([2]));
|
||||
assert_eq!(
|
||||
tool["requires"],
|
||||
serde_json::json!({"api_revision": 1, "analysis": 3, "observation": 1}),
|
||||
"the manifest must declare exact current revisions"
|
||||
);
|
||||
assert!(
|
||||
tool.get("compatibility").is_none(),
|
||||
"the retired compatibility negotiation block must not return"
|
||||
);
|
||||
let keys: Vec<&str> = tool
|
||||
.as_object()
|
||||
.unwrap()
|
||||
.keys()
|
||||
.map(String::as_str)
|
||||
.collect();
|
||||
assert_eq!(
|
||||
keys,
|
||||
vec![
|
||||
"command",
|
||||
"entrypoint",
|
||||
"name",
|
||||
"requires",
|
||||
"schema",
|
||||
"schema_version",
|
||||
"version"
|
||||
],
|
||||
"tool.json must not carry retired fields"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn source_has_no_legacy_protocol_or_runtime_probing() {
|
||||
let root = manifest_dir();
|
||||
let mut sources = Vec::new();
|
||||
collect_files(&root.join("src"), "rs", &mut sources);
|
||||
let banned = [
|
||||
"analysis_v2",
|
||||
"trace_v2",
|
||||
"execution_events_v1",
|
||||
"MARQDO_TOOL_PROTOCOL",
|
||||
"MARQDO_PROTOCOL_ANALYSIS",
|
||||
"MARQDO_PROTOCOL_TRACE",
|
||||
"--trace-file",
|
||||
"--event-stream",
|
||||
"compatibility",
|
||||
];
|
||||
for path in sources {
|
||||
// Unit-test modules may assert that a retired flag is absent; the gate
|
||||
// scans production source only.
|
||||
let text = read(&path);
|
||||
let production = text.split("#[cfg(test)]").next().unwrap_or("").to_string();
|
||||
for needle in banned {
|
||||
assert!(
|
||||
!production.contains(needle),
|
||||
"{} still references retired contract marker {:?}",
|
||||
path.display(),
|
||||
needle
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -0,0 +1,446 @@
|
||||
//! Observation v1 contract: one JSONL event sequence decoded by one decoder,
|
||||
//! schema/lifecycle/sequence/source-binding validation, the atomic snapshot
|
||||
//! equivalence, and negative fail-closed cases.
|
||||
|
||||
use crate::common::golden_bytes;
|
||||
use marqdo_view::protocol::analysis_v3::{verify_analysis, SemanticProjection};
|
||||
use marqdo_view::protocol::observation_v1::{
|
||||
decode_snapshot, ObservationDecoder, ObservedKind, RunDisplayState,
|
||||
};
|
||||
|
||||
const ANALYSIS: &str = "tests/golden/analysis-v3/control-flow.json";
|
||||
const JSONL: &str = "tests/golden/observation-v1/control-flow.jsonl";
|
||||
const SNAPSHOT: &str = "tests/golden/observation-v1/control-flow.snapshot.json";
|
||||
const TRUNCATED_JSONL: &str = "tests/golden/observation-v1/control-flow.truncated.jsonl";
|
||||
const TRUNCATED_SNAPSHOT: &str = "tests/golden/observation-v1/control-flow.truncated.snapshot.json";
|
||||
|
||||
fn projection() -> SemanticProjection {
|
||||
verify_analysis(&golden_bytes(ANALYSIS), "index.mq.md", None)
|
||||
.expect("golden Analysis v3 verifies")
|
||||
.projection
|
||||
}
|
||||
|
||||
fn decode(jsonl: &str) -> Result<marqdo_view::protocol::observation_v1::RunProjection, String> {
|
||||
let projection = projection();
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
let frames = decoder.push(&golden_bytes(jsonl));
|
||||
if let Some(detail) = decoder.invalid() {
|
||||
return Err(detail.to_string());
|
||||
}
|
||||
assert!(!frames.is_empty(), "decoder published no browser frames");
|
||||
decoder
|
||||
.finish(0, "", false)
|
||||
.map_err(|err| format!("{}: {err}", err.code()))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn real_jsonl_stream_verifies_and_binds_to_analysis_digest() {
|
||||
let run = decode(JSONL).expect("real Observation v1 stream verifies");
|
||||
assert_eq!(run.state, RunDisplayState::Succeeded);
|
||||
assert_eq!(run.run_status, "ok");
|
||||
assert_eq!(run.exit_code, 0);
|
||||
assert!(run.source_verified);
|
||||
assert_eq!(run.analysis_digest, projection().analysis_digest);
|
||||
assert!(run.truncated.is_none());
|
||||
assert_eq!(
|
||||
run.events.first().map(|event| event.kind.clone()),
|
||||
Some(ObservedKind::StreamOpened)
|
||||
);
|
||||
assert_eq!(
|
||||
run.events.get(1).map(|event| event.kind.clone()),
|
||||
Some(ObservedKind::RunStarted)
|
||||
);
|
||||
// Terminal is unique and last.
|
||||
let terminals = run
|
||||
.events
|
||||
.iter()
|
||||
.filter(|event| {
|
||||
matches!(
|
||||
event.kind,
|
||||
ObservedKind::RunCompleted | ObservedKind::RunFailed | ObservedKind::RunRejected
|
||||
)
|
||||
})
|
||||
.count();
|
||||
assert_eq!(terminals, 1);
|
||||
assert_eq!(
|
||||
run.events.last().map(|event| event.kind.clone()),
|
||||
Some(ObservedKind::RunCompleted)
|
||||
);
|
||||
assert!(run.counts.effect > 0);
|
||||
assert!(run.counts.branch_eval > 0);
|
||||
assert!(run.counts.loop_iteration > 0);
|
||||
assert!(!run.stdout.is_empty(), "stdout chunks are decoded");
|
||||
assert_eq!(
|
||||
run.result_value.as_ref().map(|value| value.ty.as_str()),
|
||||
Some("Int")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stream_and_snapshot_of_the_same_run_agree() {
|
||||
let projection = projection();
|
||||
let from_stream = decode(JSONL).expect("stream decodes");
|
||||
let from_snapshot =
|
||||
decode_snapshot(&golden_bytes(SNAPSHOT), &projection).expect("snapshot decodes");
|
||||
assert_eq!(from_stream.run_id, from_snapshot.run_id);
|
||||
assert_eq!(from_stream.state, from_snapshot.state);
|
||||
assert_eq!(from_stream.events.len(), from_snapshot.events.len());
|
||||
for (stream, snapshot) in from_stream.events.iter().zip(from_snapshot.events.iter()) {
|
||||
assert_eq!(stream.seq, snapshot.seq);
|
||||
assert_eq!(stream.kind, snapshot.kind);
|
||||
assert_eq!(stream.span, snapshot.span);
|
||||
assert_eq!(stream.anchor_span, snapshot.anchor_span);
|
||||
assert_eq!(stream.detail, snapshot.detail);
|
||||
assert_eq!(stream.operation, snapshot.operation);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn truncated_observation_is_a_terminal_but_never_complete() {
|
||||
let run = decode(TRUNCATED_JSONL).expect("truncated stream decodes");
|
||||
assert_eq!(run.state, RunDisplayState::Truncated);
|
||||
let truncated = run.truncated.clone().expect("observation.truncated");
|
||||
assert_eq!(truncated.reason, "event_budget");
|
||||
assert_eq!(truncated.limit, 5);
|
||||
let terminals = run
|
||||
.events
|
||||
.iter()
|
||||
.filter(|event| {
|
||||
matches!(
|
||||
event.kind,
|
||||
ObservedKind::RunCompleted | ObservedKind::RunFailed | ObservedKind::RunRejected
|
||||
)
|
||||
})
|
||||
.count();
|
||||
assert_eq!(terminals, 1);
|
||||
assert!(!run.is_success() || run.state == RunDisplayState::Truncated);
|
||||
|
||||
let projection = projection();
|
||||
let snapshot = decode_snapshot(&golden_bytes(TRUNCATED_SNAPSHOT), &projection)
|
||||
.expect("truncated snapshot decodes");
|
||||
assert_eq!(snapshot.state, RunDisplayState::Truncated);
|
||||
assert_eq!(
|
||||
snapshot
|
||||
.truncated
|
||||
.as_ref()
|
||||
.map(|value| value.reason.as_str()),
|
||||
Some("event_budget")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lifecycle_negative_cases_fail_closed() {
|
||||
let projection = projection();
|
||||
let module = projection.module_id.clone();
|
||||
let digest = projection.analysis_digest.clone();
|
||||
let root = projection.project_root_id.clone();
|
||||
|
||||
let cases: Vec<(&str, Vec<serde_json::Value>)> = vec![
|
||||
("missing stream.opened", vec![started(0, &digest, &root)]),
|
||||
(
|
||||
"terminal without start",
|
||||
vec![opened(0, &module), completed(1, &module)],
|
||||
),
|
||||
(
|
||||
"unknown kind",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
started(1, &digest, &root),
|
||||
event(2, "future.event", serde_json::json!({})),
|
||||
],
|
||||
),
|
||||
(
|
||||
"sequence gap",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
started(1, &digest, &root),
|
||||
effect(3, &module),
|
||||
],
|
||||
),
|
||||
(
|
||||
"duplicate sequence",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
started(1, &digest, &root),
|
||||
effect(2, &module),
|
||||
effect(2, &module),
|
||||
],
|
||||
),
|
||||
(
|
||||
"mixed run id",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
event(
|
||||
1,
|
||||
"run.started",
|
||||
serde_json::json!({
|
||||
"entry": format!("{module}::main"),
|
||||
"mode": "pure",
|
||||
"source": {"root_id": root, "analysis_digest": digest}
|
||||
}),
|
||||
),
|
||||
event_with_run(2, "other-run", "effect", effect_payload(&module)),
|
||||
],
|
||||
),
|
||||
(
|
||||
"continued after terminal",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
started(1, &digest, &root),
|
||||
completed(2, &module),
|
||||
effect(3, &module),
|
||||
],
|
||||
),
|
||||
(
|
||||
"two terminals",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
started(1, &digest, &root),
|
||||
completed(2, &module),
|
||||
completed(3, &module),
|
||||
],
|
||||
),
|
||||
(
|
||||
"span outside source",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
started(1, &digest, &root),
|
||||
event(
|
||||
2,
|
||||
"effect",
|
||||
serde_json::json!({
|
||||
"frame_id": "f1", "operation": "fs.exists",
|
||||
"result_code": "ok", "module_id": module,
|
||||
"span": {"start": 0, "end": 999_999}
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
(
|
||||
"value without consent",
|
||||
vec![
|
||||
opened(0, &module),
|
||||
started(1, &digest, &root),
|
||||
event(
|
||||
2,
|
||||
"variable.assigned",
|
||||
serde_json::json!({
|
||||
"frame_id": "f1", "module_id": module, "name": "x",
|
||||
"value_state": "observed", "value_type": "Int",
|
||||
"span": {"start": 0, "end": 1},
|
||||
"value": {"type": "int", "decimal": "1"}
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
for (name, events) in cases {
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
let bytes = encode(&events);
|
||||
decoder.push(&bytes);
|
||||
if let Some(detail) = decoder.invalid() {
|
||||
// Push-time rejection is the expected fail-closed path.
|
||||
assert!(!detail.is_empty(), "{name}");
|
||||
continue;
|
||||
}
|
||||
let result = decoder.finish(0, "", false);
|
||||
assert!(result.is_err(), "{name} was accepted as {result:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_schema_and_revision_are_rejected() {
|
||||
let projection = projection();
|
||||
let module = projection.module_id.clone();
|
||||
let mut event = opened(0, &module);
|
||||
event["schema"] = serde_json::json!("marqdo.execution-events");
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
decoder.push(&encode(&[event]));
|
||||
assert!(decoder.invalid().is_some(), "old schema must be rejected");
|
||||
|
||||
let mut event = opened(0, &module);
|
||||
event["schema_version"] = serde_json::json!(2);
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
decoder.push(&encode(&[event]));
|
||||
assert!(
|
||||
decoder.invalid().is_some(),
|
||||
"unknown revision must be rejected"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stale_and_wrong_root_bindings_are_observation_stale() {
|
||||
let projection = projection();
|
||||
let module = projection.module_id.clone();
|
||||
let wrong_digest = format!("sha256:{}", "0".repeat(64));
|
||||
let events = vec![
|
||||
opened(0, &module),
|
||||
started(1, &wrong_digest, &projection.project_root_id),
|
||||
completed(2, &module),
|
||||
];
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
decoder.push(&encode(&events));
|
||||
let err = decoder.finish(0, "", false).unwrap_err();
|
||||
assert_eq!(err.code(), "view.observation_stale");
|
||||
assert!(!err.detail().is_empty());
|
||||
|
||||
let events = vec![
|
||||
opened(0, &module),
|
||||
started(1, &projection.analysis_digest, "root:other@0.1.0"),
|
||||
completed(2, &module),
|
||||
];
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
decoder.push(&encode(&events));
|
||||
let err = decoder.finish(0, "", false).unwrap_err();
|
||||
assert_eq!(err.code(), "view.observation_stale");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejected_before_start_is_a_valid_failed_terminal() {
|
||||
let projection = projection();
|
||||
let module = projection.module_id.clone();
|
||||
let events = vec![opened(0, &module), rejected(1, &module)];
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
decoder.push(&encode(&events));
|
||||
let run = decoder
|
||||
.finish(1, "error[sem.unclosed_control]: refusing to run", false)
|
||||
.expect("compile rejection is a valid terminal");
|
||||
assert_eq!(run.state, RunDisplayState::Failed);
|
||||
assert_eq!(run.run_status, "rejected");
|
||||
assert_eq!(run.error_code.as_deref(), Some("sem.unclosed_control"));
|
||||
assert!(!run.is_success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eof_without_terminal_is_incomplete_never_success() {
|
||||
let projection = projection();
|
||||
let module = projection.module_id.clone();
|
||||
let events = vec![
|
||||
opened(0, &module),
|
||||
started(1, &projection.analysis_digest, &projection.project_root_id),
|
||||
effect(2, &module),
|
||||
];
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
decoder.push(&encode(&events));
|
||||
let run = decoder.finish(0, "", false).expect("no terminal decodes");
|
||||
assert_eq!(run.state, RunDisplayState::Incomplete);
|
||||
assert_eq!(
|
||||
run.error_code.as_deref(),
|
||||
Some("view.observation_incomplete")
|
||||
);
|
||||
assert!(!run.is_success());
|
||||
assert!(!run.output_complete);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Synthetic Observation v1 builders (only for negative-path tests).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
fn encode(events: &[serde_json::Value]) -> Vec<u8> {
|
||||
let mut bytes = Vec::new();
|
||||
for event in events {
|
||||
bytes.extend_from_slice(event.to_string().as_bytes());
|
||||
bytes.push(b'\n');
|
||||
}
|
||||
bytes
|
||||
}
|
||||
|
||||
fn envelope(seq: u64, kind: &str, payload: serde_json::Value) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"schema": "marqdo.observation",
|
||||
"schema_version": 1,
|
||||
"run_id": "test-run-1",
|
||||
"seq": seq,
|
||||
"kind": kind,
|
||||
"payload": payload
|
||||
})
|
||||
}
|
||||
|
||||
fn event(seq: u64, kind: &str, payload: serde_json::Value) -> serde_json::Value {
|
||||
envelope(seq, kind, payload)
|
||||
}
|
||||
|
||||
fn event_with_run(
|
||||
seq: u64,
|
||||
run: &str,
|
||||
kind: &str,
|
||||
payload: serde_json::Value,
|
||||
) -> serde_json::Value {
|
||||
let mut value = envelope(seq, kind, payload);
|
||||
value["run_id"] = serde_json::json!(run);
|
||||
value
|
||||
}
|
||||
|
||||
fn opened(seq: u64, _module: &str) -> serde_json::Value {
|
||||
envelope(
|
||||
seq,
|
||||
"stream.opened",
|
||||
serde_json::json!({
|
||||
"producer": {"name": "marqdo", "version": "3.0.0-rc.4"},
|
||||
"observation": {
|
||||
"level": "structural",
|
||||
"values": false,
|
||||
"selected_variables": [],
|
||||
"selected_parameters": [],
|
||||
"allow_text_values": false
|
||||
},
|
||||
"limits": {
|
||||
"max_observation_events": 10000,
|
||||
"max_observation_bytes": 4194304,
|
||||
"max_value_bytes": 256
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
fn started(seq: u64, digest: &str, root: &str) -> serde_json::Value {
|
||||
let projection = projection();
|
||||
envelope(
|
||||
seq,
|
||||
"run.started",
|
||||
serde_json::json!({
|
||||
"entry": format!("{}::main", projection.module_id),
|
||||
"mode": "pure",
|
||||
"source": {"root_id": root, "analysis_digest": digest},
|
||||
"started_unix_ms": 1
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
fn effect(seq: u64, module: &str) -> serde_json::Value {
|
||||
event(seq, "effect", effect_payload(module))
|
||||
}
|
||||
|
||||
fn effect_payload(module: &str) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"frame_id": "f1",
|
||||
"operation": "fs.exists",
|
||||
"result_code": "ok",
|
||||
"module_id": module,
|
||||
"span": {"start": 0, "end": 1}
|
||||
})
|
||||
}
|
||||
|
||||
fn completed(seq: u64, _module: &str) -> serde_json::Value {
|
||||
envelope(
|
||||
seq,
|
||||
"run.completed",
|
||||
serde_json::json!({
|
||||
"status": "ok",
|
||||
"value": {"type": "int", "decimal": "3"},
|
||||
"value_type": "Int"
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
fn rejected(seq: u64, _module: &str) -> serde_json::Value {
|
||||
envelope(
|
||||
seq,
|
||||
"run.rejected",
|
||||
serde_json::json!({
|
||||
"status": "rejected",
|
||||
"phase": "compile",
|
||||
"error": {"code": "sem.unclosed_control", "message": "`if` is not closed"}
|
||||
}),
|
||||
)
|
||||
}
|
||||
@@ -1,11 +1,18 @@
|
||||
//! Degradation/state matrix contract (RFC-VIEW-0001 S-05..S-07, §12.3):
|
||||
//! prose stays readable while semantics become explicitly unusable.
|
||||
//! Degradation/state matrix contract: prose stays readable while semantics
|
||||
//! become explicitly unusable; run states never claim success from an incomplete or
|
||||
//! truncated observation.
|
||||
|
||||
use crate::common;
|
||||
use crate::common::{golden_bytes, minimal_analysis, FakeCore, TempProject};
|
||||
use marqdo_view::protocol::analysis_v3::{verify_analysis, SemanticProjection};
|
||||
use marqdo_view::protocol::observation_v1::{ObservationDecoder, RunDisplayState, RunProjection};
|
||||
use marqdo_view::reader::assemble::{build, BuildInput, DocumentService};
|
||||
use marqdo_view::reader::markdown::{DocumentIdentity, DocumentModel};
|
||||
use marqdo_view::reader::model::{Navigation, SourceStatus};
|
||||
use marqdo_view::reader::source::Project;
|
||||
|
||||
use common::{minimal_analysis, sha256_hex, FakeCore, TempProject};
|
||||
use marqdo_view::reader::assemble::DocumentService;
|
||||
use marqdo_view::reader::model::SourceStatus;
|
||||
const ANALYSIS: &str = "tests/golden/analysis-v3/control-flow.json";
|
||||
const JSONL: &str = "tests/golden/observation-v1/control-flow.jsonl";
|
||||
const TRUNCATED_JSONL: &str = "tests/golden/observation-v1/control-flow.truncated.jsonl";
|
||||
|
||||
fn project(name: &str) -> (TempProject, FakeCore) {
|
||||
let project = TempProject::new(name);
|
||||
@@ -14,12 +21,53 @@ fn project(name: &str) -> (TempProject, FakeCore) {
|
||||
(project, core)
|
||||
}
|
||||
|
||||
fn projection() -> SemanticProjection {
|
||||
verify_analysis(&golden_bytes(ANALYSIS), "index.mq.md", None)
|
||||
.expect("control-flow golden verifies")
|
||||
.projection
|
||||
}
|
||||
|
||||
fn decode(jsonl: &str) -> RunProjection {
|
||||
let projection = projection();
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
decoder.push(&golden_bytes(jsonl));
|
||||
assert!(decoder.invalid().is_none(), "{:?}", decoder.invalid());
|
||||
decoder
|
||||
.finish(0, "", false)
|
||||
.expect("real observation stream verifies")
|
||||
}
|
||||
|
||||
fn empty_model(
|
||||
document: DocumentModel,
|
||||
run: Option<&RunProjection>,
|
||||
) -> marqdo_view::reader::model::PresentationModel {
|
||||
build(BuildInput {
|
||||
document,
|
||||
analysis: None,
|
||||
status: SourceStatus::CoreUnavailable,
|
||||
status_note: Some("test".into()),
|
||||
diagnostics: Vec::new(),
|
||||
navigation: Navigation {
|
||||
site_title: "test".into(),
|
||||
documents: Vec::new(),
|
||||
active: None,
|
||||
welcome: false,
|
||||
},
|
||||
core_version: None,
|
||||
run,
|
||||
})
|
||||
}
|
||||
|
||||
fn document_for(relative: &str, source: &str) -> DocumentModel {
|
||||
let path = marqdo_view::reader::source::SafeRelativePath::parse(relative).unwrap();
|
||||
DocumentModel::parse(source.to_string(), DocumentIdentity::placeholder(&path))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failed_check_keeps_prose_and_shows_core_diagnostics() {
|
||||
let (project, core) = project("state-check-fail");
|
||||
let source = std::fs::read(project.path("index.mq.md")).unwrap();
|
||||
// Emit a broken analysis too; it must NOT be used after a failed check.
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &sha256_hex(&source), 2));
|
||||
let source = std::fs::read_to_string(project.path("index.mq.md")).unwrap();
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &source, 3));
|
||||
core.set_check(1, "");
|
||||
core.set_check_json(
|
||||
r#"{"command":"check","success":false,"errors":1,"diagnostics":[{"code":"sem.unclosed_control","column":1,"file":"/home/secret/index.mq.md","line":3,"message":"`if` is not closed by `end`","module":"root:fixture@0.1.0::index.mq.md","severity":"error"}]}"#,
|
||||
@@ -38,14 +86,13 @@ fn failed_check_keeps_prose_and_shows_core_diagnostics() {
|
||||
.iter()
|
||||
.any(|diagnostic| diagnostic.code == "sem.unclosed_control"));
|
||||
assert!(!model.source_status.semantics_usable());
|
||||
// Pending run state is explicit, never a success claim.
|
||||
assert_eq!(model.run_state().data_value(), "not-run");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn source_digest_mismatch_degrades_instead_of_misbinding() {
|
||||
let (project, core) = project("state-source-mismatch");
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &"0".repeat(64), 2));
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", "# 完全不同的源码\n", 3));
|
||||
let context = DocumentService::open(&project.dir, Some(&core.script)).unwrap();
|
||||
let relative = context.project().entry().relative.clone();
|
||||
let model = context.load(&relative).unwrap();
|
||||
@@ -57,8 +104,8 @@ fn source_digest_mismatch_degrades_instead_of_misbinding() {
|
||||
#[test]
|
||||
fn unknown_analysis_schema_is_a_hard_protocol_error() {
|
||||
let (project, core) = project("state-protocol");
|
||||
let source = std::fs::read(project.path("index.mq.md")).unwrap();
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &sha256_hex(&source), 4));
|
||||
let source = std::fs::read_to_string(project.path("index.mq.md")).unwrap();
|
||||
core.set_analysis(&minimal_analysis("index.mq.md", &source, 4));
|
||||
let context = DocumentService::open(&project.dir, Some(&core.script)).unwrap();
|
||||
let relative = context.project().entry().relative.clone();
|
||||
let err = context.load(&relative).unwrap_err();
|
||||
@@ -67,79 +114,69 @@ fn unknown_analysis_schema_is_a_hard_protocol_error() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_core_span_is_dropped_with_an_explicit_warning() {
|
||||
fn invalid_analysis_span_is_rejected_not_trimmed() {
|
||||
// N09: an out-of-range/negative span in a protocol artifact is a hard
|
||||
// failure; View must never clip it and claim success.
|
||||
let (project, core) = project("state-span-invalid");
|
||||
let source = std::fs::read(project.path("index.mq.md")).unwrap();
|
||||
let source = std::fs::read_to_string(project.path("index.mq.md")).unwrap();
|
||||
let mut analysis: serde_json::Value =
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", &sha256_hex(&source), 2)).unwrap();
|
||||
// A span in the middle of a multi-byte character / beyond EOF.
|
||||
serde_json::from_str(&minimal_analysis("index.mq.md", &source, 3)).unwrap();
|
||||
let module_id = analysis["modules"][0]["id"].as_str().unwrap().to_string();
|
||||
analysis["modules"][0]["units"] = serde_json::json!([{
|
||||
"id": "x", "name": "坏", "level": 1, "kind": "namespace", "function": null,
|
||||
"span": {"start": 0, "end": 999_999}
|
||||
"id": format!("{module_id}#坏"),
|
||||
"path": ["坏"],
|
||||
"parent_id": module_id,
|
||||
"kind": "namespace",
|
||||
"name": "坏",
|
||||
"level": 1,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": format!("{module_id}#坏"),
|
||||
"heading_span": {"start": 0, "end": 1},
|
||||
"span": {"start": 0, "end": 999_999},
|
||||
"function": null
|
||||
}]);
|
||||
core.set_analysis(&serde_json::to_string(&analysis).unwrap());
|
||||
let bytes = analysis.to_string().into_bytes();
|
||||
let err = verify_analysis(&bytes, "index.mq.md", Some(&source)).unwrap_err();
|
||||
assert_eq!(err.code(), "view.analysis_failed");
|
||||
|
||||
// Through the reader the prose stays readable, but no annotation may be
|
||||
// attached from the rejected artifact.
|
||||
core.set_analysis(&analysis.to_string());
|
||||
let context = DocumentService::open(&project.dir, Some(&core.script)).unwrap();
|
||||
let relative = context.project().entry().relative.clone();
|
||||
let model = context.load(&relative).unwrap();
|
||||
assert_eq!(model.source_status, SourceStatus::StaticOk);
|
||||
assert!(model.semantic.as_ref().unwrap().units.is_empty());
|
||||
assert!(model
|
||||
.warnings
|
||||
.iter()
|
||||
.any(|warning| warning.code == "view.source_span_invalid"));
|
||||
let _ = source;
|
||||
assert!(model.semantic.is_none());
|
||||
assert_eq!(model.source_status, SourceStatus::CoreError);
|
||||
assert!(model.document.plain_text().contains("正文"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_attached_to_changed_source_becomes_stale() {
|
||||
let repo_root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
let project = TempProject::new("state-stale-run");
|
||||
project.write(
|
||||
"marqdo.yaml",
|
||||
"project:\n name: control-flow\n version: 0.1.0\n",
|
||||
);
|
||||
let source =
|
||||
std::fs::read_to_string(repo_root.join("examples/control-flow/index.mq.md")).unwrap();
|
||||
let source = golden_bytes("tests/golden/analysis-v3/control-flow.json");
|
||||
let source = serde_json::from_slice::<serde_json::Value>(&source).unwrap()["modules"][0]
|
||||
["source"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.to_string();
|
||||
project.write("index.mq.md", &source);
|
||||
let core = FakeCore::new("state-stale-run-core");
|
||||
let analysis =
|
||||
std::fs::read(repo_root.join("tests/golden/analysis-v2/control-flow.json")).unwrap();
|
||||
let analysis = golden_bytes(ANALYSIS);
|
||||
core.set_analysis(std::str::from_utf8(&analysis).unwrap());
|
||||
let context = DocumentService::open(&project.dir, Some(&core.script)).unwrap();
|
||||
let relative = context.project().entry().relative.clone();
|
||||
|
||||
// Build a verified run directly from the golden trace + golden analysis.
|
||||
let source_index = marqdo_view::reader::source::SourceIndex::new(&source);
|
||||
let verified_analysis = marqdo_view::protocol::analysis_v2::verify_analysis(
|
||||
&analysis,
|
||||
&source,
|
||||
&source_index,
|
||||
"index.mq.md",
|
||||
)
|
||||
.unwrap();
|
||||
let trace =
|
||||
std::fs::read(repo_root.join("tests/golden/trace-v2/control-flow.trace.json")).unwrap();
|
||||
let run_json: serde_json::Value = serde_json::from_slice(
|
||||
&std::fs::read(repo_root.join("tests/golden/trace-v2/control-flow.run.json")).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
let run = marqdo_view::protocol::trace_v2::verify_trace(
|
||||
marqdo_view::protocol::trace_v2::TraceVerificationInput {
|
||||
trace_bytes: &trace,
|
||||
analysis_bytes: &analysis,
|
||||
semantic: &verified_analysis.projection,
|
||||
modules: &verified_analysis.projection.modules,
|
||||
source: &source,
|
||||
source_index: &source_index,
|
||||
run_json: &run_json,
|
||||
exit_code: 0,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
let run = decode(JSONL);
|
||||
let attached = context.load_with_run(&relative, Some(&run)).unwrap();
|
||||
assert_eq!(attached.run_state().data_value(), "succeeded");
|
||||
|
||||
// Change the source and rebuild through the same server path.
|
||||
// The document changed after the run; the same projection must never be
|
||||
// re-anchored to the new source.
|
||||
std::fs::write(
|
||||
project.path("index.mq.md"),
|
||||
format!("{source}\n<!-- changed -->\n"),
|
||||
@@ -156,5 +193,72 @@ fn run_attached_to_changed_source_becomes_stale() {
|
||||
if let Some(run) = &changed.run {
|
||||
assert!(run.events.iter().all(|event| event.anchor_span.is_none()));
|
||||
}
|
||||
let _ = core;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn truncated_and_incomplete_runs_never_display_as_success() {
|
||||
let run = decode(TRUNCATED_JSONL);
|
||||
assert_eq!(run.state, RunDisplayState::Truncated);
|
||||
assert!(run.truncated.is_some());
|
||||
let model = empty_model(document_for("index.mq.md", "# @knowledge x\n"), Some(&run));
|
||||
assert_eq!(model.run_state().data_value(), "truncated");
|
||||
assert!(model.run_state().is_terminal());
|
||||
assert_ne!(model.run_state().data_value(), "succeeded");
|
||||
assert_eq!(model.run_state().label(), "观察已截断");
|
||||
|
||||
// A stream that ends before its terminal event is incomplete, not success.
|
||||
let projection = projection();
|
||||
let mut decoder = ObservationDecoder::new(&projection);
|
||||
let mut lines = Vec::new();
|
||||
for line in golden_bytes(JSONL).split(|byte| *byte == b'\n') {
|
||||
if line.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let value: serde_json::Value = serde_json::from_slice(line).unwrap();
|
||||
if value["kind"] == "run.completed" {
|
||||
break;
|
||||
}
|
||||
lines.extend_from_slice(line);
|
||||
lines.push(b'\n');
|
||||
}
|
||||
decoder.push(&lines);
|
||||
let incomplete = decoder.finish(0, "", false).unwrap();
|
||||
assert_eq!(incomplete.state, RunDisplayState::Incomplete);
|
||||
assert!(!incomplete.is_success());
|
||||
let model = empty_model(
|
||||
document_for("index.mq.md", "# @knowledge x\n"),
|
||||
Some(&incomplete),
|
||||
);
|
||||
assert_eq!(model.run_state().data_value(), "incomplete");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_core_stays_readable_and_explicitly_unverified() {
|
||||
let project = TempProject::new("state-no-core");
|
||||
project.marqdo_project("# @knowledge fixture\n");
|
||||
let context = DocumentService::open(
|
||||
&project.dir,
|
||||
Some(std::path::Path::new("/definitely/missing/marqdo-frozen")),
|
||||
)
|
||||
.unwrap();
|
||||
let relative = context.project().entry().relative.clone();
|
||||
let model = context.load(&relative).unwrap();
|
||||
assert_eq!(model.source_status, SourceStatus::CoreUnavailable);
|
||||
assert!(model.semantic.is_none());
|
||||
assert!(model.status_note.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn external_projection_can_be_rendered_from_artifact_source() {
|
||||
// The artifact source is the only source used to interpret spans, even when
|
||||
// no checkout file exists for a dependency module.
|
||||
let verified = verify_analysis(&golden_bytes(ANALYSIS), "index.mq.md", None).unwrap();
|
||||
assert_eq!(
|
||||
verified.projection.source,
|
||||
verified.projection.entry_module().unwrap().source
|
||||
);
|
||||
let _ = Project::open(
|
||||
&std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("examples/control-flow"),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
@@ -1,270 +0,0 @@
|
||||
//! Trace v2 contract tests against goldens emitted by the frozen CLI. The
|
||||
//! goldens bind to the committed Analysis v2 bytes by digest, so a changed
|
||||
//! source cannot silently reuse an old trace.
|
||||
|
||||
use marqdo_view::protocol::analysis_v2 as semantic;
|
||||
use marqdo_view::protocol::trace_v2::{verify_trace, RunDisplayState, TraceVerificationInput};
|
||||
use marqdo_view::reader::source::{sha256_prefixed, SourceIndex};
|
||||
use serde_json::Value;
|
||||
|
||||
struct Fixture {
|
||||
source: String,
|
||||
index: SourceIndex,
|
||||
analysis: Vec<u8>,
|
||||
semantic: semantic::VerifiedAnalysis,
|
||||
}
|
||||
|
||||
fn fixture(analysis_golden: &str, source_path: &str) -> Fixture {
|
||||
let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
let source = std::fs::read_to_string(root.join(source_path)).unwrap();
|
||||
let index = SourceIndex::new(&source);
|
||||
let analysis = std::fs::read(root.join(analysis_golden)).unwrap();
|
||||
let semantic = semantic::verify_analysis(&analysis, &source, &index, "index.mq.md").unwrap();
|
||||
Fixture {
|
||||
source,
|
||||
index,
|
||||
analysis,
|
||||
semantic,
|
||||
}
|
||||
}
|
||||
|
||||
fn golden_json(path: &str) -> Value {
|
||||
let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
serde_json::from_slice(&std::fs::read(root.join(path)).unwrap()).unwrap()
|
||||
}
|
||||
|
||||
fn golden_bytes(path: &str) -> Vec<u8> {
|
||||
let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
std::fs::read(root.join(path)).unwrap()
|
||||
}
|
||||
|
||||
fn verify(
|
||||
fixture: &Fixture,
|
||||
trace_golden: &str,
|
||||
run_golden: &str,
|
||||
exit_code: i32,
|
||||
) -> marqdo_view::protocol::trace_v2::VerifiedRun {
|
||||
let trace = golden_bytes(trace_golden);
|
||||
let run_json = golden_json(run_golden);
|
||||
verify_trace(TraceVerificationInput {
|
||||
trace_bytes: &trace,
|
||||
analysis_bytes: &fixture.analysis,
|
||||
semantic: &fixture.semantic.projection,
|
||||
modules: &fixture.semantic.projection.modules,
|
||||
source: &fixture.source,
|
||||
source_index: &fixture.index,
|
||||
run_json: &run_json,
|
||||
exit_code,
|
||||
})
|
||||
.expect("trace verifies")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn real_control_flow_trace_binds_and_projects_events() {
|
||||
let fixture = fixture(
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
"examples/control-flow/index.mq.md",
|
||||
);
|
||||
let run = verify(
|
||||
&fixture,
|
||||
"tests/golden/trace-v2/control-flow.trace.json",
|
||||
"tests/golden/trace-v2/control-flow.run.json",
|
||||
0,
|
||||
);
|
||||
let projection = &run.projection;
|
||||
assert_eq!(projection.state, RunDisplayState::Succeeded);
|
||||
assert_eq!(projection.counts.total(), 27);
|
||||
assert_eq!(projection.entry_event_count, 27);
|
||||
assert_eq!(projection.other_event_count, 0);
|
||||
assert_eq!(projection.run_status, "ok");
|
||||
assert!(projection.truncated.is_none());
|
||||
assert_eq!(projection.stdout, "0\n0\n2\n");
|
||||
let value = projection.result_value.as_ref().expect("return value");
|
||||
assert_eq!(value.ty, "int");
|
||||
assert_eq!(value.display, "3");
|
||||
// Public JSON final value only; never a per-assignment value claim.
|
||||
assert!(projection.analysis_digest.starts_with("sha256:"));
|
||||
|
||||
// The loop header is evaluated four times (three iterations + exit).
|
||||
let loop_span = projection
|
||||
.events
|
||||
.iter()
|
||||
.find(|event| event.anchor_span.is_some() && event.detail.as_deref() == Some("exit"))
|
||||
.and_then(|event| event.anchor_span)
|
||||
.expect("loop anchor");
|
||||
let summary = projection.anchor_summary(loop_span).expect("loop summary");
|
||||
assert_eq!(summary.count, 4);
|
||||
assert_eq!(summary.detail, "loop exit");
|
||||
assert!(summary.kinds.contains(&"loop.iteration".to_string()));
|
||||
|
||||
let return_anchors: Vec<_> = projection
|
||||
.events
|
||||
.iter()
|
||||
.filter(|event| event.anchor_span.is_some())
|
||||
.collect();
|
||||
assert!(!return_anchors.is_empty());
|
||||
// Only entry-module events ever get statement anchors.
|
||||
for event in &projection.events {
|
||||
if event.anchor_span.is_some() {
|
||||
assert_eq!(
|
||||
event.module_id.as_deref(),
|
||||
Some(fixture.semantic.projection.module_id.as_str())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn truncated_trace_is_explicitly_marked() {
|
||||
let fixture = fixture(
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
"examples/control-flow/index.mq.md",
|
||||
);
|
||||
let run = verify(
|
||||
&fixture,
|
||||
"tests/golden/trace-v2/control-flow.truncated.trace.json",
|
||||
"tests/golden/trace-v2/control-flow.truncated.run.json",
|
||||
0,
|
||||
);
|
||||
let projection = &run.projection;
|
||||
assert_eq!(projection.state, RunDisplayState::Truncated);
|
||||
let truncated = projection.truncated.as_ref().expect("truncation");
|
||||
assert_eq!(truncated.reason, "event_budget");
|
||||
assert_eq!(truncated.limit, 5);
|
||||
assert_eq!(truncated.written, 5);
|
||||
assert!(truncated.label().contains("事件数量上限"));
|
||||
assert_ne!(projection.state, RunDisplayState::Succeeded);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failed_run_keeps_the_core_error_code() {
|
||||
let fixture = fixture(
|
||||
"tests/golden/analysis-v2/mixed-modes.json",
|
||||
"examples/mixed-modes/index.mq.md",
|
||||
);
|
||||
let run = verify(
|
||||
&fixture,
|
||||
"tests/golden/trace-v2/mixed-modes.arity.trace.json",
|
||||
"tests/golden/trace-v2/mixed-modes.arity.run.json",
|
||||
1,
|
||||
);
|
||||
let projection = &run.projection;
|
||||
assert_eq!(projection.state, RunDisplayState::Failed);
|
||||
assert_eq!(projection.error_code.as_deref(), Some("call.arity"));
|
||||
assert_eq!(projection.run_status, "call.arity");
|
||||
assert!(projection.result_value.is_none());
|
||||
assert_eq!(projection.state.label(), "运行失败");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stale_analysis_bytes_are_rejected() {
|
||||
let fixture = fixture(
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
"examples/control-flow/index.mq.md",
|
||||
);
|
||||
let mut tampered = fixture.analysis.clone();
|
||||
tampered.push(b' ');
|
||||
let trace = golden_bytes("tests/golden/trace-v2/control-flow.trace.json");
|
||||
let run_json = golden_json("tests/golden/trace-v2/control-flow.run.json");
|
||||
let err = verify_trace(TraceVerificationInput {
|
||||
trace_bytes: &trace,
|
||||
analysis_bytes: &tampered,
|
||||
semantic: &fixture.semantic.projection,
|
||||
modules: &fixture.semantic.projection.modules,
|
||||
source: &fixture.source,
|
||||
source_index: &fixture.index,
|
||||
run_json: &run_json,
|
||||
exit_code: 0,
|
||||
})
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.trace_stale");
|
||||
assert_eq!(err.exit_code(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_event_module_is_rejected() {
|
||||
let fixture = fixture(
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
"examples/control-flow/index.mq.md",
|
||||
);
|
||||
let mut trace: Value = golden_json("tests/golden/trace-v2/control-flow.trace.json");
|
||||
trace["events"][0]["module_id"] = Value::String("rogue::module.mq.md".to_string());
|
||||
let trace_bytes = serde_json::to_vec(&trace).unwrap();
|
||||
let run_json = golden_json("tests/golden/trace-v2/control-flow.run.json");
|
||||
let err = verify_trace(TraceVerificationInput {
|
||||
trace_bytes: &trace_bytes,
|
||||
analysis_bytes: &fixture.analysis,
|
||||
semantic: &fixture.semantic.projection,
|
||||
modules: &fixture.semantic.projection.modules,
|
||||
source: &fixture.source,
|
||||
source_index: &fixture.index,
|
||||
run_json: &run_json,
|
||||
exit_code: 0,
|
||||
})
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.trace_stale");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn non_monotonic_sequence_is_rejected() {
|
||||
let fixture = fixture(
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
"examples/control-flow/index.mq.md",
|
||||
);
|
||||
let mut trace: Value = golden_json("tests/golden/trace-v2/control-flow.trace.json");
|
||||
trace["events"][1]["seq"] = Value::Number(0.into());
|
||||
let trace_bytes = serde_json::to_vec(&trace).unwrap();
|
||||
let run_json = golden_json("tests/golden/trace-v2/control-flow.run.json");
|
||||
let err = verify_trace(TraceVerificationInput {
|
||||
trace_bytes: &trace_bytes,
|
||||
analysis_bytes: &fixture.analysis,
|
||||
semantic: &fixture.semantic.projection,
|
||||
modules: &fixture.semantic.projection.modules,
|
||||
source: &fixture.source,
|
||||
source_index: &fixture.index,
|
||||
run_json: &run_json,
|
||||
exit_code: 0,
|
||||
})
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.trace_stale");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_schema_major_is_a_protocol_error_not_a_stale_trace() {
|
||||
let fixture = fixture(
|
||||
"tests/golden/analysis-v2/control-flow.json",
|
||||
"examples/control-flow/index.mq.md",
|
||||
);
|
||||
let mut trace: Value = golden_json("tests/golden/trace-v2/control-flow.trace.json");
|
||||
trace["schema_version"] = Value::Number(3.into());
|
||||
let trace_bytes = serde_json::to_vec(&trace).unwrap();
|
||||
let run_json = golden_json("tests/golden/trace-v2/control-flow.run.json");
|
||||
let err = verify_trace(TraceVerificationInput {
|
||||
trace_bytes: &trace_bytes,
|
||||
analysis_bytes: &fixture.analysis,
|
||||
semantic: &fixture.semantic.projection,
|
||||
modules: &fixture.semantic.projection.modules,
|
||||
source: &fixture.source,
|
||||
source_index: &fixture.index,
|
||||
run_json: &run_json,
|
||||
exit_code: 0,
|
||||
})
|
||||
.unwrap_err();
|
||||
assert_eq!(err.code(), "view.protocol_incompatible");
|
||||
assert_eq!(err.exit_code(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn golden_digest_is_really_sha256_of_analysis_bytes() {
|
||||
let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
let analysis = std::fs::read(root.join("tests/golden/analysis-v2/control-flow.json")).unwrap();
|
||||
let trace: Value = golden_json("tests/golden/trace-v2/control-flow.trace.json");
|
||||
assert_eq!(
|
||||
trace["source"]["analysis_digest"].as_str().unwrap(),
|
||||
sha256_prefixed(&analysis)
|
||||
);
|
||||
assert_eq!(
|
||||
trace["source"]["root_id"].as_str().unwrap(),
|
||||
"root:control-flow@0.1.0"
|
||||
);
|
||||
}
|
||||
@@ -11,7 +11,7 @@ binary, not hand-written:
|
||||
Command shape used for every golden:
|
||||
|
||||
```bash
|
||||
"$MARQDO_BIN" check <example> --emit tests/golden/analysis-v2/<name>.json
|
||||
"$MARQDO_BIN" check <example> --emit tests/golden/analysis-v3/<name>.json
|
||||
```
|
||||
|
||||
| Golden | Input |
|
||||
|
||||
@@ -1,278 +0,0 @@
|
||||
{
|
||||
"diagnostics": [],
|
||||
"modules": [
|
||||
{
|
||||
"calls": [],
|
||||
"functions": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"arms": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "assign",
|
||||
"span": {
|
||||
"end": 422,
|
||||
"start": 406
|
||||
},
|
||||
"target": "result",
|
||||
"value": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 417,
|
||||
"start": 416
|
||||
}
|
||||
},
|
||||
"op": "mul",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "2"
|
||||
},
|
||||
"span": {
|
||||
"end": 421,
|
||||
"start": 416
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 439,
|
||||
"start": 424
|
||||
},
|
||||
"value": {
|
||||
"kind": "variable",
|
||||
"name": "result",
|
||||
"span": {
|
||||
"end": 438,
|
||||
"start": 432
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 398,
|
||||
"start": 397
|
||||
}
|
||||
},
|
||||
"op": "gt",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
},
|
||||
"span": {
|
||||
"end": 402,
|
||||
"start": 397
|
||||
}
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
},
|
||||
"span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
}
|
||||
},
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 461,
|
||||
"start": 451
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
},
|
||||
"span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "branch",
|
||||
"span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
}
|
||||
}
|
||||
],
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"heading_span": {
|
||||
"end": 259,
|
||||
"start": 246
|
||||
},
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md::演示.main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"signature": {
|
||||
"kind": "explicit",
|
||||
"params": [
|
||||
{
|
||||
"default": null,
|
||||
"name": "n",
|
||||
"required": true,
|
||||
"span": {
|
||||
"end": 274,
|
||||
"start": 268
|
||||
},
|
||||
"type": "Int"
|
||||
}
|
||||
]
|
||||
},
|
||||
"span": {
|
||||
"end": 470,
|
||||
"start": 246
|
||||
},
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main"
|
||||
}
|
||||
],
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md",
|
||||
"imports": [],
|
||||
"package_instance_id": "root:mixed-modes@0.1.0",
|
||||
"references": [],
|
||||
"relative_path": "index.mq.md",
|
||||
"resources": [],
|
||||
"source_digest": "c5fed57a716e06a29b669c334d475ec03bf08442e27983451ec8dd791dc999ea",
|
||||
"units": [
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#",
|
||||
"kind": "root",
|
||||
"level": 0,
|
||||
"name": "",
|
||||
"span": {
|
||||
"end": 470,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "计算笔记",
|
||||
"span": {
|
||||
"end": 25,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记/算法说明",
|
||||
"kind": "knowledge",
|
||||
"level": 2,
|
||||
"name": "算法说明",
|
||||
"span": {
|
||||
"end": 149,
|
||||
"start": 123
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "演示",
|
||||
"span": {
|
||||
"end": 244,
|
||||
"start": 230
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": "root:mixed-modes@0.1.0::index.mq.md::演示.main",
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示/main",
|
||||
"kind": "function",
|
||||
"level": 2,
|
||||
"name": "main",
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 246
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/用法",
|
||||
"kind": "section",
|
||||
"level": 3,
|
||||
"name": "用法",
|
||||
"span": {
|
||||
"end": 300,
|
||||
"start": 279
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": "root:mixed-modes@0.1.0::index.mq.md::演示.main",
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/计算",
|
||||
"kind": "section",
|
||||
"level": 3,
|
||||
"name": "计算",
|
||||
"span": {
|
||||
"end": 390,
|
||||
"start": 374
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"producer": {
|
||||
"markdown_profile": "marqdo.md.v1",
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-beta.1"
|
||||
},
|
||||
"project": {
|
||||
"identity_kind": "manifest",
|
||||
"lock_digest": "",
|
||||
"root_id": "root:mixed-modes@0.1.0",
|
||||
"stdlib": {
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"version": "0.1.0"
|
||||
}
|
||||
},
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 2
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
{
|
||||
"diagnostics": [],
|
||||
"modules": [
|
||||
{
|
||||
"calls": [],
|
||||
"functions": [],
|
||||
"id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"imports": [],
|
||||
"package_instance_id": "root:tables-math@0.1.0",
|
||||
"references": [
|
||||
{
|
||||
"source": "root:tables-math@0.1.0::index.mq.md",
|
||||
"span": {
|
||||
"end": 403,
|
||||
"start": 354
|
||||
},
|
||||
"state": "external",
|
||||
"target_module": null,
|
||||
"target_unit": null,
|
||||
"url": "https://github.com/cflmy/marqdo-cli"
|
||||
}
|
||||
],
|
||||
"relative_path": "index.mq.md",
|
||||
"resources": [
|
||||
{
|
||||
"content_digest": "2820951a377c18ce3e89093ca7c31c204b1196a7e571781c6080f8207524a8dc",
|
||||
"display": false,
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#resource:formula-1",
|
||||
"kind": "formula",
|
||||
"language": null,
|
||||
"module_id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"span": {
|
||||
"end": 164,
|
||||
"start": 154
|
||||
},
|
||||
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源"
|
||||
},
|
||||
{
|
||||
"content_digest": "8b1e8a7ed159e8223af79e768681907870ae7143f0b16001091377f9ff018db2",
|
||||
"display": true,
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#resource:formula-2",
|
||||
"kind": "formula",
|
||||
"language": null,
|
||||
"module_id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"span": {
|
||||
"end": 222,
|
||||
"start": 181
|
||||
},
|
||||
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源"
|
||||
},
|
||||
{
|
||||
"content_digest": "a0d49e456637468d7f594f4e2bb513321875855c1fe85d28e0ca62f1e9180d15",
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#resource:code-1",
|
||||
"kind": "code",
|
||||
"language": "python",
|
||||
"module_id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"span": {
|
||||
"end": 280,
|
||||
"start": 224
|
||||
},
|
||||
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源"
|
||||
}
|
||||
],
|
||||
"source_digest": "66ce180252d201ff0f3f831d47f7a58d7f6804cb9655898cc80ef6d2262f1ce6",
|
||||
"units": [
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#",
|
||||
"kind": "root",
|
||||
"level": 0,
|
||||
"name": "",
|
||||
"span": {
|
||||
"end": 406,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "表格、公式与惰性资源",
|
||||
"span": {
|
||||
"end": 43,
|
||||
"start": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"producer": {
|
||||
"markdown_profile": "marqdo.md.v1",
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-beta.1"
|
||||
},
|
||||
"project": {
|
||||
"identity_kind": "manifest",
|
||||
"lock_digest": "",
|
||||
"root_id": "root:tables-math@0.1.0",
|
||||
"stdlib": {
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"version": "0.1.0"
|
||||
}
|
||||
},
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 2
|
||||
}
|
||||
@@ -1,212 +0,0 @@
|
||||
{
|
||||
"diagnostics": [],
|
||||
"modules": [
|
||||
{
|
||||
"calls": [],
|
||||
"functions": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"arms": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 148,
|
||||
"start": 138
|
||||
},
|
||||
"value": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 147,
|
||||
"start": 146
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 128,
|
||||
"start": 127
|
||||
}
|
||||
},
|
||||
"op": "gt",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
},
|
||||
"span": {
|
||||
"end": 132,
|
||||
"start": 127
|
||||
}
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
},
|
||||
"span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
}
|
||||
},
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 174,
|
||||
"start": 164
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
},
|
||||
"span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "branch",
|
||||
"span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
}
|
||||
}
|
||||
],
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"heading_span": {
|
||||
"end": 98,
|
||||
"start": 85
|
||||
},
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md::演示.main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"signature": {
|
||||
"kind": "explicit",
|
||||
"params": [
|
||||
{
|
||||
"default": null,
|
||||
"name": "n",
|
||||
"required": true,
|
||||
"span": {
|
||||
"end": 115,
|
||||
"start": 109
|
||||
},
|
||||
"type": "Int"
|
||||
}
|
||||
]
|
||||
},
|
||||
"span": {
|
||||
"end": 185,
|
||||
"start": 85
|
||||
},
|
||||
"unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#演示/main"
|
||||
}
|
||||
],
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md",
|
||||
"imports": [],
|
||||
"package_instance_id": "root:unicode-spans@0.1.0",
|
||||
"references": [],
|
||||
"relative_path": "crlf.mq.md",
|
||||
"resources": [],
|
||||
"source_digest": "3d6c99d8e1666b14cc51e6774a4cf514a3a252f3b2f9f541c7cde4a090551b1f",
|
||||
"units": [
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#",
|
||||
"kind": "root",
|
||||
"level": 0,
|
||||
"name": "",
|
||||
"span": {
|
||||
"end": 185,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#CRLF 文档",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "CRLF 文档",
|
||||
"span": {
|
||||
"end": 24,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#演示",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "演示",
|
||||
"span": {
|
||||
"end": 81,
|
||||
"start": 67
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": "root:unicode-spans@0.1.0::crlf.mq.md::演示.main",
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#演示/main",
|
||||
"kind": "function",
|
||||
"level": 2,
|
||||
"name": "main",
|
||||
"span": {
|
||||
"end": 98,
|
||||
"start": 85
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"producer": {
|
||||
"markdown_profile": "marqdo.md.v1",
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-beta.1"
|
||||
},
|
||||
"project": {
|
||||
"identity_kind": "manifest",
|
||||
"lock_digest": "",
|
||||
"root_id": "root:unicode-spans@0.1.0",
|
||||
"stdlib": {
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"version": "0.1.0"
|
||||
}
|
||||
},
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 2
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
{
|
||||
"diagnostics": [],
|
||||
"modules": [
|
||||
{
|
||||
"calls": [],
|
||||
"functions": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"arms": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 271,
|
||||
"start": 261
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "1"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 253,
|
||||
"start": 252
|
||||
}
|
||||
},
|
||||
"op": "gt",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
},
|
||||
"span": {
|
||||
"end": 257,
|
||||
"start": 252
|
||||
}
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
},
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
}
|
||||
},
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 293,
|
||||
"start": 283
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "1"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
},
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "branch",
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
}
|
||||
}
|
||||
],
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"heading_span": {
|
||||
"end": 227,
|
||||
"start": 214
|
||||
},
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md::演示.main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"signature": {
|
||||
"kind": "explicit",
|
||||
"params": [
|
||||
{
|
||||
"default": null,
|
||||
"name": "n",
|
||||
"required": true,
|
||||
"span": {
|
||||
"end": 242,
|
||||
"start": 236
|
||||
},
|
||||
"type": "Int"
|
||||
}
|
||||
]
|
||||
},
|
||||
"span": {
|
||||
"end": 302,
|
||||
"start": 214
|
||||
},
|
||||
"unit_id": "root:unicode-spans@0.1.0::index.mq.md#演示/main"
|
||||
}
|
||||
],
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md",
|
||||
"imports": [],
|
||||
"package_instance_id": "root:unicode-spans@0.1.0",
|
||||
"references": [],
|
||||
"relative_path": "index.mq.md",
|
||||
"resources": [],
|
||||
"source_digest": "b4f8dd12f18a984af129974bc4dd153e97df99cc262bcafb2ae1187b6c5ce7d0",
|
||||
"units": [
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#",
|
||||
"kind": "root",
|
||||
"level": 0,
|
||||
"name": "",
|
||||
"span": {
|
||||
"end": 302,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#中文 🙂 标题",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "中文 🙂 标题",
|
||||
"span": {
|
||||
"end": 31,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#演示",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "演示",
|
||||
"span": {
|
||||
"end": 212,
|
||||
"start": 198
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": "root:unicode-spans@0.1.0::index.mq.md::演示.main",
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#演示/main",
|
||||
"kind": "function",
|
||||
"level": 2,
|
||||
"name": "main",
|
||||
"span": {
|
||||
"end": 227,
|
||||
"start": 214
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"producer": {
|
||||
"markdown_profile": "marqdo.md.v1",
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-beta.1"
|
||||
},
|
||||
"project": {
|
||||
"identity_kind": "manifest",
|
||||
"lock_digest": "",
|
||||
"root_id": "root:unicode-spans@0.1.0",
|
||||
"stdlib": {
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"version": "0.1.0"
|
||||
}
|
||||
},
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 2
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
{
|
||||
"diagnostics": [],
|
||||
"modules": [
|
||||
{
|
||||
"calls": [],
|
||||
"functions": [],
|
||||
"id": "root:welcome-demo@0.1.0::00-welcome.mq.md",
|
||||
"imports": [],
|
||||
"package_instance_id": "root:welcome-demo@0.1.0",
|
||||
"references": [
|
||||
{
|
||||
"source": "root:welcome-demo@0.1.0::00-welcome.mq.md",
|
||||
"span": {
|
||||
"end": 536,
|
||||
"start": 507
|
||||
},
|
||||
"state": "resolved",
|
||||
"target_module": "root:welcome-demo@0.1.0::guide.mq.md",
|
||||
"target_unit": null,
|
||||
"url": "./guide.mq.md"
|
||||
}
|
||||
],
|
||||
"relative_path": "00-welcome.mq.md",
|
||||
"resources": [],
|
||||
"source_digest": "879215bf0dc432b78924800a08eac37d353a9694652c5542294f4ce7fe6da173",
|
||||
"units": [
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:welcome-demo@0.1.0::00-welcome.mq.md#",
|
||||
"kind": "root",
|
||||
"level": 0,
|
||||
"name": "",
|
||||
"span": {
|
||||
"end": 659,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:welcome-demo@0.1.0::00-welcome.mq.md#欢迎来到 Marqdo",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "欢迎来到 Marqdo",
|
||||
"span": {
|
||||
"end": 32,
|
||||
"start": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"producer": {
|
||||
"markdown_profile": "marqdo.md.v1",
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-beta.1"
|
||||
},
|
||||
"project": {
|
||||
"identity_kind": "manifest",
|
||||
"lock_digest": "",
|
||||
"root_id": "root:welcome-demo@0.1.0",
|
||||
"stdlib": {
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"version": "0.1.0"
|
||||
}
|
||||
},
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 2
|
||||
}
|
||||
+645
-132
@@ -1,79 +1,591 @@
|
||||
{
|
||||
"diagnostics": [],
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 3,
|
||||
"producer": {
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-rc.4",
|
||||
"markdown_profile": "marqdo.md.v1"
|
||||
},
|
||||
"project": {
|
||||
"root_id": "root:control-flow@0.1.0",
|
||||
"identity_kind": "manifest",
|
||||
"entry_module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"lock_digest": "",
|
||||
"manifest_digest": "sha256:a317c418b2b86e74c23f5effcea3e7e4bff0d6dac4043beca78598bc8c90768d",
|
||||
"stdlib": {
|
||||
"version": "0.1.0",
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713"
|
||||
},
|
||||
"extensions": []
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"calls": [
|
||||
"id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"package_instance_id": "root:control-flow@0.1.0",
|
||||
"relative_path": "index.mq.md",
|
||||
"source_digest": "127922e228bbc7931aa8241ff69ee7df3cbc8bbaaaead143b67842a527818854",
|
||||
"source": "# @knowledge 控制流演示\n\n下面的函数可以在 `pure` 模式显式运行并产生真实 Trace。示例把 ASCII 数字和换行写入标准输出资源。\n\n# @exec 演示\n\n## @exec main\n\n`x = 0`\n\n`buffer = memory.new(1, 1)`\n\n`buffer[1] = 10`\n\n`stdout = resource.open(\"stdio\", \"stdout\", [\"write\"])`\n\n**while x < 3**\n\n**if x > 1**\n\n`buffer[0] = 48 + x`\n\n**else**\n\n`buffer[0] = 48`\n\n**end**\n\n`resource.write(stdout, buffer, 0, 2)`\n\n**x = x + 1**\n\n**end**\n\n`resource.close(stdout)`\n\n`return 3`\n",
|
||||
"document": {
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge 控制流演示",
|
||||
"span": {
|
||||
"end": 28,
|
||||
"start": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 28,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "下面的函数可以在 ",
|
||||
"span": {
|
||||
"end": 55,
|
||||
"start": 30
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "pure",
|
||||
"span": {
|
||||
"end": 61,
|
||||
"start": 55
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " 模式显式运行并产生真实 Trace。示例把 ASCII 数字和换行写入标准输出资源。",
|
||||
"span": {
|
||||
"end": 162,
|
||||
"start": 61
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 162,
|
||||
"start": 30
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec 演示",
|
||||
"span": {
|
||||
"end": 178,
|
||||
"start": 166
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 178,
|
||||
"start": 164
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec main",
|
||||
"span": {
|
||||
"end": 193,
|
||||
"start": 183
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 2,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 193,
|
||||
"start": 180
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "x = 0",
|
||||
"span": {
|
||||
"end": 202,
|
||||
"start": 195
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 202,
|
||||
"start": 195
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "buffer = memory.new(1, 1)",
|
||||
"span": {
|
||||
"end": 231,
|
||||
"start": 204
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 231,
|
||||
"start": 204
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "buffer[1] = 10",
|
||||
"span": {
|
||||
"end": 249,
|
||||
"start": 233
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 249,
|
||||
"start": 233
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "stdout = resource.open(\"stdio\", \"stdout\", [\"write\"])",
|
||||
"span": {
|
||||
"end": 305,
|
||||
"start": 251
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 305,
|
||||
"start": 251
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "while x < 3",
|
||||
"span": {
|
||||
"end": 320,
|
||||
"start": 309
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 322,
|
||||
"start": 307
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 322,
|
||||
"start": 307
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "if x > 1",
|
||||
"span": {
|
||||
"end": 334,
|
||||
"start": 326
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "buffer[0] = 48 + x",
|
||||
"span": {
|
||||
"end": 358,
|
||||
"start": 338
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 358,
|
||||
"start": 338
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "else",
|
||||
"span": {
|
||||
"end": 366,
|
||||
"start": 362
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 368,
|
||||
"start": 360
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 368,
|
||||
"start": 360
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "buffer[0] = 48",
|
||||
"span": {
|
||||
"end": 386,
|
||||
"start": 370
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 386,
|
||||
"start": 370
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "end",
|
||||
"span": {
|
||||
"end": 393,
|
||||
"start": 390
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 395,
|
||||
"start": 388
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 395,
|
||||
"start": 388
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "resource.write(stdout, buffer, 0, 2)",
|
||||
"span": {
|
||||
"end": 435,
|
||||
"start": 397
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 435,
|
||||
"start": 397
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "x = x + 1",
|
||||
"span": {
|
||||
"end": 448,
|
||||
"start": 439
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 450,
|
||||
"start": 437
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 450,
|
||||
"start": 437
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "end",
|
||||
"span": {
|
||||
"end": 457,
|
||||
"start": 454
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 459,
|
||||
"start": 452
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 459,
|
||||
"start": 452
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "resource.close(stdout)",
|
||||
"span": {
|
||||
"end": 485,
|
||||
"start": 461
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 485,
|
||||
"start": 461
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "return 3",
|
||||
"span": {
|
||||
"end": 497,
|
||||
"start": 487
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 497,
|
||||
"start": 487
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "document",
|
||||
"span": {
|
||||
"end": 498,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
"units": [
|
||||
{
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "memory"
|
||||
},
|
||||
"field": "new",
|
||||
"kind": "member"
|
||||
},
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#",
|
||||
"path": [],
|
||||
"parent_id": null,
|
||||
"kind": "root",
|
||||
"name": "",
|
||||
"level": 0,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "default",
|
||||
"mode_source_unit_id": "root:control-flow@0.1.0::index.mq.md#",
|
||||
"heading_span": null,
|
||||
"span": {
|
||||
"end": 230,
|
||||
"start": 214
|
||||
"start": 0,
|
||||
"end": 498
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "memory.new"
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "resource"
|
||||
},
|
||||
"field": "open",
|
||||
"kind": "member"
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#控制流演示",
|
||||
"path": [
|
||||
"控制流演示"
|
||||
],
|
||||
"parent_id": "root:control-flow@0.1.0::index.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "控制流演示",
|
||||
"level": 1,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:control-flow@0.1.0::index.mq.md#控制流演示",
|
||||
"heading_span": {
|
||||
"start": 0,
|
||||
"end": 28
|
||||
},
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"span": {
|
||||
"end": 304,
|
||||
"start": 261
|
||||
"start": 0,
|
||||
"end": 164
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "resource.open"
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "resource"
|
||||
},
|
||||
"field": "write",
|
||||
"kind": "member"
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#演示",
|
||||
"path": [
|
||||
"演示"
|
||||
],
|
||||
"parent_id": "root:control-flow@0.1.0::index.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "演示",
|
||||
"level": 1,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:control-flow@0.1.0::index.mq.md#演示",
|
||||
"heading_span": {
|
||||
"start": 164,
|
||||
"end": 178
|
||||
},
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
"start": 164,
|
||||
"end": 498
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "resource.write"
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "resource"
|
||||
},
|
||||
"field": "close",
|
||||
"kind": "member"
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#演示/main",
|
||||
"path": [
|
||||
"演示",
|
||||
"main"
|
||||
],
|
||||
"parent_id": "root:control-flow@0.1.0::index.mq.md#演示",
|
||||
"kind": "function",
|
||||
"name": "main",
|
||||
"level": 2,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:control-flow@0.1.0::index.mq.md#演示/main",
|
||||
"heading_span": {
|
||||
"start": 180,
|
||||
"end": 193
|
||||
},
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"span": {
|
||||
"end": 484,
|
||||
"start": 462
|
||||
"start": 180,
|
||||
"end": 498
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "resource.close"
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main"
|
||||
}
|
||||
],
|
||||
"anchors": [
|
||||
{
|
||||
"anchor": "main",
|
||||
"unit_id": "root:control-flow@0.1.0::index.mq.md#演示/main"
|
||||
},
|
||||
{
|
||||
"anchor": "控制流演示",
|
||||
"unit_id": "root:control-flow@0.1.0::index.mq.md#控制流演示"
|
||||
},
|
||||
{
|
||||
"anchor": "演示",
|
||||
"unit_id": "root:control-flow@0.1.0::index.mq.md#演示"
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"unit_id": "root:control-flow@0.1.0::index.mq.md#演示/main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"span": {
|
||||
"start": 180,
|
||||
"end": 497
|
||||
},
|
||||
"heading_span": {
|
||||
"start": 180,
|
||||
"end": 193
|
||||
},
|
||||
"signature": {
|
||||
"kind": "inferred",
|
||||
"params": []
|
||||
},
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"kind": "assign",
|
||||
@@ -437,12 +949,12 @@
|
||||
"value": true
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
"end": 368,
|
||||
"start": 360
|
||||
},
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
"end": 368,
|
||||
"start": 360
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -678,94 +1190,95 @@
|
||||
"value": "3"
|
||||
}
|
||||
}
|
||||
],
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"heading_span": {
|
||||
"end": 193,
|
||||
"start": 180
|
||||
},
|
||||
"id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"signature": {
|
||||
"kind": "inferred",
|
||||
"params": []
|
||||
},
|
||||
"span": {
|
||||
"end": 497,
|
||||
"start": 180
|
||||
},
|
||||
"unit_id": "root:control-flow@0.1.0::index.mq.md#演示/main"
|
||||
]
|
||||
}
|
||||
],
|
||||
"id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"imports": [],
|
||||
"package_instance_id": "root:control-flow@0.1.0",
|
||||
"references": [],
|
||||
"relative_path": "index.mq.md",
|
||||
"resources": [],
|
||||
"source_digest": "127922e228bbc7931aa8241ff69ee7df3cbc8bbaaaead143b67842a527818854",
|
||||
"units": [
|
||||
"calls": [
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#",
|
||||
"kind": "root",
|
||||
"level": 0,
|
||||
"name": "",
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"span": {
|
||||
"end": 497,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#控制流演示",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "控制流演示",
|
||||
"span": {
|
||||
"end": 28,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": null,
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#演示",
|
||||
"kind": "namespace",
|
||||
"level": 1,
|
||||
"name": "演示",
|
||||
"span": {
|
||||
"end": 178,
|
||||
"start": 164
|
||||
}
|
||||
"start": 214,
|
||||
"end": 230
|
||||
},
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "memory"
|
||||
},
|
||||
"field": "new",
|
||||
"kind": "member"
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "memory.new",
|
||||
"target_kind": "builtin",
|
||||
"target_owner": null,
|
||||
"reason": null
|
||||
},
|
||||
{
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"id": "root:control-flow@0.1.0::index.mq.md#演示/main",
|
||||
"kind": "function",
|
||||
"level": 2,
|
||||
"name": "main",
|
||||
"span": {
|
||||
"end": 193,
|
||||
"start": 180
|
||||
}
|
||||
"start": 261,
|
||||
"end": 304
|
||||
},
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "resource"
|
||||
},
|
||||
"field": "open",
|
||||
"kind": "member"
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "resource.open",
|
||||
"target_kind": "builtin",
|
||||
"target_owner": null,
|
||||
"reason": null
|
||||
},
|
||||
{
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"span": {
|
||||
"start": 398,
|
||||
"end": 434
|
||||
},
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "resource"
|
||||
},
|
||||
"field": "write",
|
||||
"kind": "member"
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "resource.write",
|
||||
"target_kind": "builtin",
|
||||
"target_owner": null,
|
||||
"reason": null
|
||||
},
|
||||
{
|
||||
"function": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"span": {
|
||||
"start": 462,
|
||||
"end": 484
|
||||
},
|
||||
"callee": {
|
||||
"base": {
|
||||
"kind": "ident",
|
||||
"name": "resource"
|
||||
},
|
||||
"field": "close",
|
||||
"kind": "member"
|
||||
},
|
||||
"state": "builtin",
|
||||
"target": "resource.close",
|
||||
"target_kind": "builtin",
|
||||
"target_owner": null,
|
||||
"reason": null
|
||||
}
|
||||
]
|
||||
],
|
||||
"resources": []
|
||||
}
|
||||
],
|
||||
"producer": {
|
||||
"markdown_profile": "marqdo.md.v1",
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-beta.1"
|
||||
},
|
||||
"project": {
|
||||
"identity_kind": "manifest",
|
||||
"lock_digest": "",
|
||||
"root_id": "root:control-flow@0.1.0",
|
||||
"stdlib": null
|
||||
},
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 2
|
||||
"diagnostics": []
|
||||
}
|
||||
@@ -0,0 +1,790 @@
|
||||
{
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 3,
|
||||
"producer": {
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-rc.4",
|
||||
"markdown_profile": "marqdo.md.v1"
|
||||
},
|
||||
"project": {
|
||||
"root_id": "root:mixed-modes@0.1.0",
|
||||
"identity_kind": "manifest",
|
||||
"entry_module_id": "root:mixed-modes@0.1.0::index.mq.md",
|
||||
"lock_digest": "",
|
||||
"manifest_digest": "sha256:b252a5e0d5519cfb5efe1ca7ebfe0660cc1919279fc4283cdebfb70028f5a984",
|
||||
"stdlib": {
|
||||
"version": "0.1.0",
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713"
|
||||
},
|
||||
"extensions": []
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md",
|
||||
"package_instance_id": "root:mixed-modes@0.1.0",
|
||||
"relative_path": "index.mq.md",
|
||||
"source_digest": "c5fed57a716e06a29b669c334d475ec03bf08442e27983451ec8dd791dc999ea",
|
||||
"source": "# @knowledge 计算笔记\n\n这是一份关于简单运算的知识说明。**此处加粗是知识内容,不执行。**\n\n## @knowledge 算法说明\n\n下面描述算法的含义和适用范围;此处的 `n` 是惰性正文。\n\n# @exec 演示\n\n## @exec main\n\n`params(n: Int)`\n\n### @knowledge 用法\n\n调用方提供整数 `n`。这一小节不应该执行任何语句。\n\n### @exec 计算\n\n**if n > 0**\n\n`result = n * 2`\n\n*return result*\n\n**else**\n\n`return 0`\n\n**end**\n",
|
||||
"document": {
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge 计算笔记",
|
||||
"span": {
|
||||
"end": 25,
|
||||
"start": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 25,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "这是一份关于简单运算的知识说明。",
|
||||
"span": {
|
||||
"end": 75,
|
||||
"start": 27
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "此处加粗是知识内容,不执行。",
|
||||
"span": {
|
||||
"end": 119,
|
||||
"start": 77
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 121,
|
||||
"start": 75
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 121,
|
||||
"start": 27
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge 算法说明",
|
||||
"span": {
|
||||
"end": 149,
|
||||
"start": 126
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 2,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 149,
|
||||
"start": 123
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "下面描述算法的含义和适用范围;此处的 ",
|
||||
"span": {
|
||||
"end": 206,
|
||||
"start": 151
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "n",
|
||||
"span": {
|
||||
"end": 209,
|
||||
"start": 206
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " 是惰性正文。",
|
||||
"span": {
|
||||
"end": 228,
|
||||
"start": 209
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 228,
|
||||
"start": 151
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec 演示",
|
||||
"span": {
|
||||
"end": 244,
|
||||
"start": 232
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 244,
|
||||
"start": 230
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec main",
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 249
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 2,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 246
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "params(n: Int)",
|
||||
"span": {
|
||||
"end": 277,
|
||||
"start": 261
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 277,
|
||||
"start": 261
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge 用法",
|
||||
"span": {
|
||||
"end": 300,
|
||||
"start": 283
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 3,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 300,
|
||||
"start": 279
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "调用方提供整数 ",
|
||||
"span": {
|
||||
"end": 324,
|
||||
"start": 302
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "n",
|
||||
"span": {
|
||||
"end": 327,
|
||||
"start": 324
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "。这一小节不应该执行任何语句。",
|
||||
"span": {
|
||||
"end": 372,
|
||||
"start": 327
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 372,
|
||||
"start": 302
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec 计算",
|
||||
"span": {
|
||||
"end": 390,
|
||||
"start": 378
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 3,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 390,
|
||||
"start": 374
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "if n > 0",
|
||||
"span": {
|
||||
"end": 402,
|
||||
"start": 394
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "result = n * 2",
|
||||
"span": {
|
||||
"end": 422,
|
||||
"start": 406
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 422,
|
||||
"start": 406
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "return result",
|
||||
"span": {
|
||||
"end": 438,
|
||||
"start": 425
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "emph",
|
||||
"span": {
|
||||
"end": 439,
|
||||
"start": 424
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 439,
|
||||
"start": 424
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "else",
|
||||
"span": {
|
||||
"end": 447,
|
||||
"start": 443
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 449,
|
||||
"start": 441
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 449,
|
||||
"start": 441
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "return 0",
|
||||
"span": {
|
||||
"end": 461,
|
||||
"start": 451
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 461,
|
||||
"start": 451
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "end",
|
||||
"span": {
|
||||
"end": 468,
|
||||
"start": 465
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 470,
|
||||
"start": 463
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 470,
|
||||
"start": 463
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "document",
|
||||
"span": {
|
||||
"end": 471,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
"units": [
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#",
|
||||
"path": [],
|
||||
"parent_id": null,
|
||||
"kind": "root",
|
||||
"name": "",
|
||||
"level": 0,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "default",
|
||||
"mode_source_unit_id": "root:mixed-modes@0.1.0::index.mq.md#",
|
||||
"heading_span": null,
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 471
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记",
|
||||
"path": [
|
||||
"计算笔记"
|
||||
],
|
||||
"parent_id": "root:mixed-modes@0.1.0::index.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "计算笔记",
|
||||
"level": 1,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记",
|
||||
"heading_span": {
|
||||
"start": 0,
|
||||
"end": 25
|
||||
},
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 230
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记/算法说明",
|
||||
"path": [
|
||||
"计算笔记",
|
||||
"算法说明"
|
||||
],
|
||||
"parent_id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记",
|
||||
"kind": "knowledge",
|
||||
"name": "算法说明",
|
||||
"level": 2,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记/算法说明",
|
||||
"heading_span": {
|
||||
"start": 123,
|
||||
"end": 149
|
||||
},
|
||||
"span": {
|
||||
"start": 123,
|
||||
"end": 230
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示",
|
||||
"path": [
|
||||
"演示"
|
||||
],
|
||||
"parent_id": "root:mixed-modes@0.1.0::index.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "演示",
|
||||
"level": 1,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示",
|
||||
"heading_span": {
|
||||
"start": 230,
|
||||
"end": 244
|
||||
},
|
||||
"span": {
|
||||
"start": 230,
|
||||
"end": 471
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示/main",
|
||||
"path": [
|
||||
"演示",
|
||||
"main"
|
||||
],
|
||||
"parent_id": "root:mixed-modes@0.1.0::index.mq.md#演示",
|
||||
"kind": "function",
|
||||
"name": "main",
|
||||
"level": 2,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main",
|
||||
"heading_span": {
|
||||
"start": 246,
|
||||
"end": 259
|
||||
},
|
||||
"span": {
|
||||
"start": 246,
|
||||
"end": 471
|
||||
},
|
||||
"function": "root:mixed-modes@0.1.0::index.mq.md::演示.main"
|
||||
},
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/用法",
|
||||
"path": [
|
||||
"演示",
|
||||
"main",
|
||||
"用法"
|
||||
],
|
||||
"parent_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main",
|
||||
"kind": "section",
|
||||
"name": "用法",
|
||||
"level": 3,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/用法",
|
||||
"heading_span": {
|
||||
"start": 279,
|
||||
"end": 300
|
||||
},
|
||||
"span": {
|
||||
"start": 279,
|
||||
"end": 374
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/计算",
|
||||
"path": [
|
||||
"演示",
|
||||
"main",
|
||||
"计算"
|
||||
],
|
||||
"parent_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main",
|
||||
"kind": "section",
|
||||
"name": "计算",
|
||||
"level": 3,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/计算",
|
||||
"heading_span": {
|
||||
"start": 374,
|
||||
"end": 390
|
||||
},
|
||||
"span": {
|
||||
"start": 374,
|
||||
"end": 471
|
||||
},
|
||||
"function": "root:mixed-modes@0.1.0::index.mq.md::演示.main"
|
||||
}
|
||||
],
|
||||
"anchors": [
|
||||
{
|
||||
"anchor": "main",
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main"
|
||||
},
|
||||
{
|
||||
"anchor": "演示",
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示"
|
||||
},
|
||||
{
|
||||
"anchor": "用法",
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/用法"
|
||||
},
|
||||
{
|
||||
"anchor": "算法说明",
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记/算法说明"
|
||||
},
|
||||
{
|
||||
"anchor": "计算",
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/计算"
|
||||
},
|
||||
{
|
||||
"anchor": "计算笔记",
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记"
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"id": "root:mixed-modes@0.1.0::index.mq.md::演示.main",
|
||||
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"span": {
|
||||
"start": 246,
|
||||
"end": 470
|
||||
},
|
||||
"heading_span": {
|
||||
"start": 246,
|
||||
"end": 259
|
||||
},
|
||||
"signature": {
|
||||
"kind": "explicit",
|
||||
"params": [
|
||||
{
|
||||
"name": "n",
|
||||
"required": true,
|
||||
"type": "Int",
|
||||
"default": null,
|
||||
"span": {
|
||||
"start": 268,
|
||||
"end": 274
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"arms": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "assign",
|
||||
"span": {
|
||||
"end": 422,
|
||||
"start": 406
|
||||
},
|
||||
"target": "result",
|
||||
"value": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 417,
|
||||
"start": 416
|
||||
}
|
||||
},
|
||||
"op": "mul",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "2"
|
||||
},
|
||||
"span": {
|
||||
"end": 421,
|
||||
"start": 416
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 439,
|
||||
"start": 424
|
||||
},
|
||||
"value": {
|
||||
"kind": "variable",
|
||||
"name": "result",
|
||||
"span": {
|
||||
"end": 438,
|
||||
"start": 432
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 398,
|
||||
"start": 397
|
||||
}
|
||||
},
|
||||
"op": "gt",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
},
|
||||
"span": {
|
||||
"end": 402,
|
||||
"start": 397
|
||||
}
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
},
|
||||
"span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
}
|
||||
},
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 461,
|
||||
"start": 451
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 449,
|
||||
"start": 441
|
||||
},
|
||||
"span": {
|
||||
"end": 449,
|
||||
"start": 441
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "branch",
|
||||
"span": {
|
||||
"end": 404,
|
||||
"start": 392
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"imports": [],
|
||||
"references": [],
|
||||
"calls": [],
|
||||
"resources": []
|
||||
}
|
||||
],
|
||||
"diagnostics": []
|
||||
}
|
||||
@@ -0,0 +1,549 @@
|
||||
{
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 3,
|
||||
"producer": {
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-rc.4",
|
||||
"markdown_profile": "marqdo.md.v1"
|
||||
},
|
||||
"project": {
|
||||
"root_id": "root:tables-math@0.1.0",
|
||||
"identity_kind": "manifest",
|
||||
"entry_module_id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"lock_digest": "",
|
||||
"manifest_digest": "sha256:5fd84c1306f43e9ed10a2db2b3fba6fdc67d960516bc94931ac594d21f034c05",
|
||||
"stdlib": {
|
||||
"version": "0.1.0",
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713"
|
||||
},
|
||||
"extensions": []
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"package_instance_id": "root:tables-math@0.1.0",
|
||||
"relative_path": "index.mq.md",
|
||||
"source_digest": "66ce180252d201ff0f3f831d47f7a58d7f6804cb9655898cc80ef6d2262f1ce6",
|
||||
"source": "# @knowledge 表格、公式与惰性资源\n\n| 名称 | 值 | 说明 |\n| --- | ---: | --- |\n| 甲 | 1 | 第一行 |\n| 乙 | 2 | 第二行 |\n\n行内公式 $E = mc^2$;块公式:\n\n$$\n\\sum_{i=1}^{n} i = \\frac{n(n+1)}{2}\n$$\n\n```python\nprint(\"代码围栏永远是惰性资源\")\n```\n\n- [x] 任务列表可读\n- [ ] 不会触发任何执行\n\n外部链接:[Marqdo CLI](https://github.com/cflmy/marqdo-cli)。\n",
|
||||
"document": {
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge 表格、公式与惰性资源",
|
||||
"span": {
|
||||
"end": 43,
|
||||
"start": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 43,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"alignments": [
|
||||
"none",
|
||||
"right",
|
||||
"none"
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "名称",
|
||||
"span": {
|
||||
"end": 53,
|
||||
"start": 47
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 54,
|
||||
"start": 46
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "值",
|
||||
"span": {
|
||||
"end": 59,
|
||||
"start": 56
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 60,
|
||||
"start": 55
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "说明",
|
||||
"span": {
|
||||
"end": 68,
|
||||
"start": 62
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 69,
|
||||
"start": 61
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": true,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 70,
|
||||
"start": 45
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "甲",
|
||||
"span": {
|
||||
"end": 97,
|
||||
"start": 94
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 98,
|
||||
"start": 93
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "1",
|
||||
"span": {
|
||||
"end": 101,
|
||||
"start": 100
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 102,
|
||||
"start": 99
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "第一行",
|
||||
"span": {
|
||||
"end": 113,
|
||||
"start": 104
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 114,
|
||||
"start": 103
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": false,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 115,
|
||||
"start": 92
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "乙",
|
||||
"span": {
|
||||
"end": 121,
|
||||
"start": 118
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 122,
|
||||
"start": 117
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "2",
|
||||
"span": {
|
||||
"end": 125,
|
||||
"start": 124
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 126,
|
||||
"start": 123
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "第二行",
|
||||
"span": {
|
||||
"end": 137,
|
||||
"start": 128
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 138,
|
||||
"start": 127
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": false,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 139,
|
||||
"start": 116
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table",
|
||||
"span": {
|
||||
"end": 139,
|
||||
"start": 45
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "行内公式 ",
|
||||
"span": {
|
||||
"end": 154,
|
||||
"start": 141
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"display": false,
|
||||
"kind": "math",
|
||||
"literal": "E = mc^2",
|
||||
"span": {
|
||||
"end": 164,
|
||||
"start": 154
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": ";块公式:",
|
||||
"span": {
|
||||
"end": 179,
|
||||
"start": 164
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 179,
|
||||
"start": 141
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "math_block",
|
||||
"literal": "\\sum_{i=1}^{n} i = \\frac{n(n+1)}{2}\n",
|
||||
"span": {
|
||||
"end": 222,
|
||||
"start": 181
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"fenced": true,
|
||||
"info": "python",
|
||||
"kind": "code_block",
|
||||
"literal": "print(\"代码围栏永远是惰性资源\")\n",
|
||||
"span": {
|
||||
"end": 280,
|
||||
"start": 224
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "任务列表可读",
|
||||
"span": {
|
||||
"end": 306,
|
||||
"start": 288
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 306,
|
||||
"start": 288
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "item",
|
||||
"span": {
|
||||
"end": 306,
|
||||
"start": 282
|
||||
},
|
||||
"task": true
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "不会触发任何执行",
|
||||
"span": {
|
||||
"end": 337,
|
||||
"start": 313
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 337,
|
||||
"start": 313
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "item",
|
||||
"span": {
|
||||
"end": 337,
|
||||
"start": 307
|
||||
},
|
||||
"task": false
|
||||
}
|
||||
],
|
||||
"kind": "list",
|
||||
"ordered": false,
|
||||
"span": {
|
||||
"end": 337,
|
||||
"start": 282
|
||||
},
|
||||
"start": null,
|
||||
"tight": true
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "外部链接:",
|
||||
"span": {
|
||||
"end": 354,
|
||||
"start": 339
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "Marqdo CLI",
|
||||
"span": {
|
||||
"end": 365,
|
||||
"start": 355
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "link",
|
||||
"span": {
|
||||
"end": 403,
|
||||
"start": 354
|
||||
},
|
||||
"title": "",
|
||||
"url": "https://github.com/cflmy/marqdo-cli"
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "。",
|
||||
"span": {
|
||||
"end": 406,
|
||||
"start": 403
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 406,
|
||||
"start": 339
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "document",
|
||||
"span": {
|
||||
"end": 407,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
"units": [
|
||||
{
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#",
|
||||
"path": [],
|
||||
"parent_id": null,
|
||||
"kind": "root",
|
||||
"name": "",
|
||||
"level": 0,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "default",
|
||||
"mode_source_unit_id": "root:tables-math@0.1.0::index.mq.md#",
|
||||
"heading_span": null,
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 407
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源",
|
||||
"path": [
|
||||
"表格、公式与惰性资源"
|
||||
],
|
||||
"parent_id": "root:tables-math@0.1.0::index.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "表格、公式与惰性资源",
|
||||
"level": 1,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源",
|
||||
"heading_span": {
|
||||
"start": 0,
|
||||
"end": 43
|
||||
},
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 407
|
||||
},
|
||||
"function": null
|
||||
}
|
||||
],
|
||||
"anchors": [
|
||||
{
|
||||
"anchor": "表格公式与惰性资源",
|
||||
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源"
|
||||
}
|
||||
],
|
||||
"functions": [],
|
||||
"imports": [],
|
||||
"references": [
|
||||
{
|
||||
"source": "root:tables-math@0.1.0::index.mq.md",
|
||||
"source_unit": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源",
|
||||
"url": "https://github.com/cflmy/marqdo-cli",
|
||||
"span": {
|
||||
"start": 354,
|
||||
"end": 403
|
||||
},
|
||||
"state": "external",
|
||||
"target_kind": null,
|
||||
"target_module": null,
|
||||
"target_unit": null,
|
||||
"candidate_package_instance_id": null,
|
||||
"candidate_path": null,
|
||||
"fragment": null,
|
||||
"candidates": []
|
||||
}
|
||||
],
|
||||
"calls": [],
|
||||
"resources": [
|
||||
{
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#resource:formula-1",
|
||||
"module_id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源",
|
||||
"kind": "formula",
|
||||
"span": {
|
||||
"start": 154,
|
||||
"end": 164
|
||||
},
|
||||
"content_digest": "2820951a377c18ce3e89093ca7c31c204b1196a7e571781c6080f8207524a8dc",
|
||||
"language": null,
|
||||
"display": false
|
||||
},
|
||||
{
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#resource:formula-2",
|
||||
"module_id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源",
|
||||
"kind": "formula",
|
||||
"span": {
|
||||
"start": 181,
|
||||
"end": 222
|
||||
},
|
||||
"content_digest": "8b1e8a7ed159e8223af79e768681907870ae7143f0b16001091377f9ff018db2",
|
||||
"language": null,
|
||||
"display": true
|
||||
},
|
||||
{
|
||||
"id": "root:tables-math@0.1.0::index.mq.md#resource:code-1",
|
||||
"module_id": "root:tables-math@0.1.0::index.mq.md",
|
||||
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源",
|
||||
"kind": "code",
|
||||
"span": {
|
||||
"start": 224,
|
||||
"end": 280
|
||||
},
|
||||
"content_digest": "a0d49e456637468d7f594f4e2bb513321875855c1fe85d28e0ca62f1e9180d15",
|
||||
"language": "python",
|
||||
"display": null
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"diagnostics": []
|
||||
}
|
||||
@@ -0,0 +1,495 @@
|
||||
{
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 3,
|
||||
"producer": {
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-rc.4",
|
||||
"markdown_profile": "marqdo.md.v1"
|
||||
},
|
||||
"project": {
|
||||
"root_id": "root:unicode-spans@0.1.0",
|
||||
"identity_kind": "manifest",
|
||||
"entry_module_id": "root:unicode-spans@0.1.0::crlf.mq.md",
|
||||
"lock_digest": "",
|
||||
"manifest_digest": "sha256:f0fa034f049dddbbd467d7fee6a2995c61b61ec6c075efa3650b490e45fb2b11",
|
||||
"stdlib": {
|
||||
"version": "0.1.0",
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713"
|
||||
},
|
||||
"extensions": []
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md",
|
||||
"package_instance_id": "root:unicode-spans@0.1.0",
|
||||
"relative_path": "crlf.mq.md",
|
||||
"source_digest": "3d6c99d8e1666b14cc51e6774a4cf514a3a252f3b2f9f541c7cde4a090551b1f",
|
||||
"source": "# @knowledge CRLF 文档\r\n\r\n正文包含中文与 emoji 🙂。\r\n\r\n# @exec 演示\r\n\r\n## @exec main\r\n\r\n`params(n: Int)`\r\n\r\n**if n > 0**\r\n\r\n`return n`\r\n\r\n**else**\r\n\r\n`return 0`\r\n\r\n**end**\r\n",
|
||||
"document": {
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge CRLF 文档",
|
||||
"span": {
|
||||
"end": 24,
|
||||
"start": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 24,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "正文包含中文与 emoji 🙂。",
|
||||
"span": {
|
||||
"end": 63,
|
||||
"start": 28
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 63,
|
||||
"start": 28
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec 演示",
|
||||
"span": {
|
||||
"end": 81,
|
||||
"start": 69
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 81,
|
||||
"start": 67
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec main",
|
||||
"span": {
|
||||
"end": 98,
|
||||
"start": 88
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 2,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 98,
|
||||
"start": 85
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "params(n: Int)",
|
||||
"span": {
|
||||
"end": 118,
|
||||
"start": 102
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 118,
|
||||
"start": 102
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "if n > 0",
|
||||
"span": {
|
||||
"end": 132,
|
||||
"start": 124
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "return n",
|
||||
"span": {
|
||||
"end": 148,
|
||||
"start": 138
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 148,
|
||||
"start": 138
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "else",
|
||||
"span": {
|
||||
"end": 158,
|
||||
"start": 154
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 160,
|
||||
"start": 152
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 160,
|
||||
"start": 152
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "return 0",
|
||||
"span": {
|
||||
"end": 174,
|
||||
"start": 164
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 174,
|
||||
"start": 164
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "end",
|
||||
"span": {
|
||||
"end": 183,
|
||||
"start": 180
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 185,
|
||||
"start": 178
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 185,
|
||||
"start": 178
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "document",
|
||||
"span": {
|
||||
"end": 187,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
"units": [
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#",
|
||||
"path": [],
|
||||
"parent_id": null,
|
||||
"kind": "root",
|
||||
"name": "",
|
||||
"level": 0,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "default",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#",
|
||||
"heading_span": null,
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 187
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#CRLF 文档",
|
||||
"path": [
|
||||
"CRLF 文档"
|
||||
],
|
||||
"parent_id": "root:unicode-spans@0.1.0::crlf.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "CRLF 文档",
|
||||
"level": 1,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#CRLF 文档",
|
||||
"heading_span": {
|
||||
"start": 0,
|
||||
"end": 24
|
||||
},
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 67
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#演示",
|
||||
"path": [
|
||||
"演示"
|
||||
],
|
||||
"parent_id": "root:unicode-spans@0.1.0::crlf.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "演示",
|
||||
"level": 1,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#演示",
|
||||
"heading_span": {
|
||||
"start": 67,
|
||||
"end": 81
|
||||
},
|
||||
"span": {
|
||||
"start": 67,
|
||||
"end": 187
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md#演示/main",
|
||||
"path": [
|
||||
"演示",
|
||||
"main"
|
||||
],
|
||||
"parent_id": "root:unicode-spans@0.1.0::crlf.mq.md#演示",
|
||||
"kind": "function",
|
||||
"name": "main",
|
||||
"level": 2,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#演示/main",
|
||||
"heading_span": {
|
||||
"start": 85,
|
||||
"end": 98
|
||||
},
|
||||
"span": {
|
||||
"start": 85,
|
||||
"end": 187
|
||||
},
|
||||
"function": "root:unicode-spans@0.1.0::crlf.mq.md::演示.main"
|
||||
}
|
||||
],
|
||||
"anchors": [
|
||||
{
|
||||
"anchor": "crlf-文档",
|
||||
"unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#CRLF 文档"
|
||||
},
|
||||
{
|
||||
"anchor": "main",
|
||||
"unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#演示/main"
|
||||
},
|
||||
{
|
||||
"anchor": "演示",
|
||||
"unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#演示"
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::crlf.mq.md::演示.main",
|
||||
"unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#演示/main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"span": {
|
||||
"start": 85,
|
||||
"end": 185
|
||||
},
|
||||
"heading_span": {
|
||||
"start": 85,
|
||||
"end": 98
|
||||
},
|
||||
"signature": {
|
||||
"kind": "explicit",
|
||||
"params": [
|
||||
{
|
||||
"name": "n",
|
||||
"required": true,
|
||||
"type": "Int",
|
||||
"default": null,
|
||||
"span": {
|
||||
"start": 109,
|
||||
"end": 115
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"arms": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 148,
|
||||
"start": 138
|
||||
},
|
||||
"value": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 147,
|
||||
"start": 146
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 128,
|
||||
"start": 127
|
||||
}
|
||||
},
|
||||
"op": "gt",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
},
|
||||
"span": {
|
||||
"end": 132,
|
||||
"start": 127
|
||||
}
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
},
|
||||
"span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
}
|
||||
},
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 174,
|
||||
"start": 164
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 160,
|
||||
"start": 152
|
||||
},
|
||||
"span": {
|
||||
"end": 160,
|
||||
"start": 152
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "branch",
|
||||
"span": {
|
||||
"end": 134,
|
||||
"start": 122
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"imports": [],
|
||||
"references": [],
|
||||
"calls": [],
|
||||
"resources": []
|
||||
}
|
||||
],
|
||||
"diagnostics": []
|
||||
}
|
||||
@@ -0,0 +1,638 @@
|
||||
{
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 3,
|
||||
"producer": {
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-rc.4",
|
||||
"markdown_profile": "marqdo.md.v1"
|
||||
},
|
||||
"project": {
|
||||
"root_id": "root:unicode-spans@0.1.0",
|
||||
"identity_kind": "manifest",
|
||||
"entry_module_id": "root:unicode-spans@0.1.0::index.mq.md",
|
||||
"lock_digest": "",
|
||||
"manifest_digest": "sha256:f0fa034f049dddbbd467d7fee6a2995c61b61ec6c075efa3650b490e45fb2b11",
|
||||
"stdlib": {
|
||||
"version": "0.1.0",
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713"
|
||||
},
|
||||
"extensions": []
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md",
|
||||
"package_instance_id": "root:unicode-spans@0.1.0",
|
||||
"relative_path": "index.mq.md",
|
||||
"source_digest": "b4f8dd12f18a984af129974bc4dd153e97df99cc262bcafb2ae1187b6c5ce7d0",
|
||||
"source": "# @knowledge 中文 🙂 标题\n\n正文包含 emoji 🙂 与组合字符 é,以及惰性 `代码`。**此处加粗是知识内容,不执行。**\n\n| 名称 | 值 |\n| --- | --- |\n| 甲🙂 | 1 |\n\n# @exec 演示\n\n## @exec main\n\n`params(n: Int)`\n\n**if n > 0**\n\n`return 1`\n\n**else**\n\n`return 1`\n\n**end**\n",
|
||||
"document": {
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge 中文 🙂 标题",
|
||||
"span": {
|
||||
"end": 31,
|
||||
"start": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 31,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "正文包含 emoji 🙂 与组合字符 é,以及惰性 ",
|
||||
"span": {
|
||||
"end": 91,
|
||||
"start": 33
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "代码",
|
||||
"span": {
|
||||
"end": 99,
|
||||
"start": 91
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "。",
|
||||
"span": {
|
||||
"end": 102,
|
||||
"start": 99
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "此处加粗是知识内容,不执行。",
|
||||
"span": {
|
||||
"end": 146,
|
||||
"start": 104
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 148,
|
||||
"start": 102
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 148,
|
||||
"start": 33
|
||||
}
|
||||
},
|
||||
{
|
||||
"alignments": [
|
||||
"none",
|
||||
"none"
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "名称",
|
||||
"span": {
|
||||
"end": 158,
|
||||
"start": 152
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 159,
|
||||
"start": 151
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "值",
|
||||
"span": {
|
||||
"end": 164,
|
||||
"start": 161
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 165,
|
||||
"start": 160
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": true,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 166,
|
||||
"start": 150
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "甲🙂",
|
||||
"span": {
|
||||
"end": 190,
|
||||
"start": 183
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 191,
|
||||
"start": 182
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "1",
|
||||
"span": {
|
||||
"end": 194,
|
||||
"start": 193
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 195,
|
||||
"start": 192
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": false,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 196,
|
||||
"start": 181
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table",
|
||||
"span": {
|
||||
"end": 196,
|
||||
"start": 150
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec 演示",
|
||||
"span": {
|
||||
"end": 212,
|
||||
"start": 200
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 212,
|
||||
"start": 198
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@exec main",
|
||||
"span": {
|
||||
"end": 227,
|
||||
"start": 217
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 2,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 227,
|
||||
"start": 214
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "params(n: Int)",
|
||||
"span": {
|
||||
"end": 245,
|
||||
"start": 229
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 245,
|
||||
"start": 229
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "if n > 0",
|
||||
"span": {
|
||||
"end": 257,
|
||||
"start": 249
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "return 1",
|
||||
"span": {
|
||||
"end": 271,
|
||||
"start": 261
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 271,
|
||||
"start": 261
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "else",
|
||||
"span": {
|
||||
"end": 279,
|
||||
"start": 275
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 281,
|
||||
"start": 273
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 281,
|
||||
"start": 273
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "return 1",
|
||||
"span": {
|
||||
"end": 293,
|
||||
"start": 283
|
||||
},
|
||||
"ticks": 1
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 293,
|
||||
"start": 283
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "end",
|
||||
"span": {
|
||||
"end": 300,
|
||||
"start": 297
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 302,
|
||||
"start": 295
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 302,
|
||||
"start": 295
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "document",
|
||||
"span": {
|
||||
"end": 303,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
"units": [
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#",
|
||||
"path": [],
|
||||
"parent_id": null,
|
||||
"kind": "root",
|
||||
"name": "",
|
||||
"level": 0,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "default",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::index.mq.md#",
|
||||
"heading_span": null,
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 303
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#中文 🙂 标题",
|
||||
"path": [
|
||||
"中文 🙂 标题"
|
||||
],
|
||||
"parent_id": "root:unicode-spans@0.1.0::index.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "中文 🙂 标题",
|
||||
"level": 1,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::index.mq.md#中文 🙂 标题",
|
||||
"heading_span": {
|
||||
"start": 0,
|
||||
"end": 31
|
||||
},
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 198
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#演示",
|
||||
"path": [
|
||||
"演示"
|
||||
],
|
||||
"parent_id": "root:unicode-spans@0.1.0::index.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "演示",
|
||||
"level": 1,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::index.mq.md#演示",
|
||||
"heading_span": {
|
||||
"start": 198,
|
||||
"end": 212
|
||||
},
|
||||
"span": {
|
||||
"start": 198,
|
||||
"end": 303
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md#演示/main",
|
||||
"path": [
|
||||
"演示",
|
||||
"main"
|
||||
],
|
||||
"parent_id": "root:unicode-spans@0.1.0::index.mq.md#演示",
|
||||
"kind": "function",
|
||||
"name": "main",
|
||||
"level": 2,
|
||||
"mode": "exec",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:unicode-spans@0.1.0::index.mq.md#演示/main",
|
||||
"heading_span": {
|
||||
"start": 214,
|
||||
"end": 227
|
||||
},
|
||||
"span": {
|
||||
"start": 214,
|
||||
"end": 303
|
||||
},
|
||||
"function": "root:unicode-spans@0.1.0::index.mq.md::演示.main"
|
||||
}
|
||||
],
|
||||
"anchors": [
|
||||
{
|
||||
"anchor": "main",
|
||||
"unit_id": "root:unicode-spans@0.1.0::index.mq.md#演示/main"
|
||||
},
|
||||
{
|
||||
"anchor": "中文--标题",
|
||||
"unit_id": "root:unicode-spans@0.1.0::index.mq.md#中文 🙂 标题"
|
||||
},
|
||||
{
|
||||
"anchor": "演示",
|
||||
"unit_id": "root:unicode-spans@0.1.0::index.mq.md#演示"
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"id": "root:unicode-spans@0.1.0::index.mq.md::演示.main",
|
||||
"unit_id": "root:unicode-spans@0.1.0::index.mq.md#演示/main",
|
||||
"local_name": "main",
|
||||
"namespace": "演示",
|
||||
"span": {
|
||||
"start": 214,
|
||||
"end": 302
|
||||
},
|
||||
"heading_span": {
|
||||
"start": 214,
|
||||
"end": 227
|
||||
},
|
||||
"signature": {
|
||||
"kind": "explicit",
|
||||
"params": [
|
||||
{
|
||||
"name": "n",
|
||||
"required": true,
|
||||
"type": "Int",
|
||||
"default": null,
|
||||
"span": {
|
||||
"start": 236,
|
||||
"end": 242
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"effects": [
|
||||
"unknown"
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"arms": [
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 271,
|
||||
"start": 261
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "1"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "binary",
|
||||
"left": {
|
||||
"kind": "variable",
|
||||
"name": "n",
|
||||
"span": {
|
||||
"end": 253,
|
||||
"start": 252
|
||||
}
|
||||
},
|
||||
"op": "gt",
|
||||
"right": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "0"
|
||||
},
|
||||
"span": {
|
||||
"end": 257,
|
||||
"start": 252
|
||||
}
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
},
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
}
|
||||
},
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"kind": "return",
|
||||
"span": {
|
||||
"end": 293,
|
||||
"start": 283
|
||||
},
|
||||
"value": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "int",
|
||||
"value": "1"
|
||||
}
|
||||
}
|
||||
],
|
||||
"condition": {
|
||||
"kind": "literal",
|
||||
"span": {
|
||||
"end": 0,
|
||||
"start": 0
|
||||
},
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
"condition_span": {
|
||||
"end": 281,
|
||||
"start": 273
|
||||
},
|
||||
"span": {
|
||||
"end": 281,
|
||||
"start": 273
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "branch",
|
||||
"span": {
|
||||
"end": 259,
|
||||
"start": 247
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"imports": [],
|
||||
"references": [],
|
||||
"calls": [],
|
||||
"resources": []
|
||||
}
|
||||
],
|
||||
"diagnostics": []
|
||||
}
|
||||
@@ -0,0 +1,716 @@
|
||||
{
|
||||
"schema": "marqdo.analysis",
|
||||
"schema_version": 3,
|
||||
"producer": {
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-rc.4",
|
||||
"markdown_profile": "marqdo.md.v1"
|
||||
},
|
||||
"project": {
|
||||
"root_id": "root:welcome-demo@0.1.0",
|
||||
"identity_kind": "manifest",
|
||||
"entry_module_id": "root:welcome-demo@0.1.0::00-welcome.mq.md",
|
||||
"lock_digest": "",
|
||||
"manifest_digest": "sha256:69ce9ddb5e526f335adb51f374ada998db8752185fab11f686002dbbb567b46f",
|
||||
"stdlib": {
|
||||
"version": "0.1.0",
|
||||
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713"
|
||||
},
|
||||
"extensions": []
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"id": "root:welcome-demo@0.1.0::00-welcome.mq.md",
|
||||
"package_instance_id": "root:welcome-demo@0.1.0",
|
||||
"relative_path": "00-welcome.mq.md",
|
||||
"source_digest": "879215bf0dc432b78924800a08eac37d353a9694652c5542294f4ce7fe6da173",
|
||||
"source": "# @knowledge 欢迎来到 Marqdo\n\nMarqdo 把 Markdown 当作可执行文档的语言:标题声明 `@exec` / `@knowledge` 模式,\n强调、斜体与行内代码是**等价的单语句载体**,而 `if` / `else` / `while` / `end` /\n`return` 决定真正的操作。\n\n| 阅读态 | 内容 | 是否执行 |\n| --- | --- | --- |\n| 文档 | 原始 Markdown 排版 | 否 |\n| 源码 | 逐行原文,包含全部标记 | 否 |\n| 运行 | 用户显式确认后才出现 | 是(需要确认) |\n\n继续阅读:[语法演示](./guide.mq.md)。\n\n> 这份欢迎页只是 `view.json` 显式指定的站点首页,普通 `welcome` 文件名不会自动变成 Hero。\n",
|
||||
"document": {
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "@knowledge 欢迎来到 Marqdo",
|
||||
"span": {
|
||||
"end": 32,
|
||||
"start": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "heading",
|
||||
"level": 1,
|
||||
"setext": false,
|
||||
"span": {
|
||||
"end": 32,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "Marqdo 把 Markdown 当作可执行文档的语言:标题声明 ",
|
||||
"span": {
|
||||
"end": 100,
|
||||
"start": 34
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "@exec",
|
||||
"span": {
|
||||
"end": 107,
|
||||
"start": 100
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " / ",
|
||||
"span": {
|
||||
"end": 110,
|
||||
"start": 107
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "@knowledge",
|
||||
"span": {
|
||||
"end": 122,
|
||||
"start": 110
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " 模式,",
|
||||
"span": {
|
||||
"end": 132,
|
||||
"start": 122
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "soft_break",
|
||||
"span": {
|
||||
"end": 133,
|
||||
"start": 132
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "强调、斜体与行内代码是",
|
||||
"span": {
|
||||
"end": 166,
|
||||
"start": 133
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "等价的单语句载体",
|
||||
"span": {
|
||||
"end": 192,
|
||||
"start": 168
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "strong",
|
||||
"span": {
|
||||
"end": 194,
|
||||
"start": 166
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": ",而 ",
|
||||
"span": {
|
||||
"end": 201,
|
||||
"start": 194
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "if",
|
||||
"span": {
|
||||
"end": 205,
|
||||
"start": 201
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " / ",
|
||||
"span": {
|
||||
"end": 208,
|
||||
"start": 205
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "else",
|
||||
"span": {
|
||||
"end": 214,
|
||||
"start": 208
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " / ",
|
||||
"span": {
|
||||
"end": 217,
|
||||
"start": 214
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "while",
|
||||
"span": {
|
||||
"end": 224,
|
||||
"start": 217
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " / ",
|
||||
"span": {
|
||||
"end": 227,
|
||||
"start": 224
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "end",
|
||||
"span": {
|
||||
"end": 232,
|
||||
"start": 227
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " /",
|
||||
"span": {
|
||||
"end": 234,
|
||||
"start": 232
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "soft_break",
|
||||
"span": {
|
||||
"end": 235,
|
||||
"start": 234
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "return",
|
||||
"span": {
|
||||
"end": 243,
|
||||
"start": 235
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " 决定真正的操作。",
|
||||
"span": {
|
||||
"end": 268,
|
||||
"start": 243
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 268,
|
||||
"start": 34
|
||||
}
|
||||
},
|
||||
{
|
||||
"alignments": [
|
||||
"none",
|
||||
"none",
|
||||
"none"
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "阅读态",
|
||||
"span": {
|
||||
"end": 281,
|
||||
"start": 272
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 282,
|
||||
"start": 271
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "内容",
|
||||
"span": {
|
||||
"end": 290,
|
||||
"start": 284
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 291,
|
||||
"start": 283
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "是否执行",
|
||||
"span": {
|
||||
"end": 305,
|
||||
"start": 293
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 306,
|
||||
"start": 292
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": true,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 307,
|
||||
"start": 270
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "文档",
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 330
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 337,
|
||||
"start": 329
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "原始 Markdown 排版",
|
||||
"span": {
|
||||
"end": 361,
|
||||
"start": 339
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 362,
|
||||
"start": 338
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "否",
|
||||
"span": {
|
||||
"end": 367,
|
||||
"start": 364
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 368,
|
||||
"start": 363
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": false,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 369,
|
||||
"start": 328
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "源码",
|
||||
"span": {
|
||||
"end": 378,
|
||||
"start": 372
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 379,
|
||||
"start": 371
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "逐行原文,包含全部标记",
|
||||
"span": {
|
||||
"end": 414,
|
||||
"start": 381
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 415,
|
||||
"start": 380
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "否",
|
||||
"span": {
|
||||
"end": 420,
|
||||
"start": 417
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 421,
|
||||
"start": 416
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": false,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 422,
|
||||
"start": 370
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "运行",
|
||||
"span": {
|
||||
"end": 431,
|
||||
"start": 425
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 432,
|
||||
"start": 424
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "用户显式确认后才出现",
|
||||
"span": {
|
||||
"end": 464,
|
||||
"start": 434
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 465,
|
||||
"start": 433
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "是(需要确认)",
|
||||
"span": {
|
||||
"end": 488,
|
||||
"start": 467
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table_cell",
|
||||
"span": {
|
||||
"end": 489,
|
||||
"start": 466
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": false,
|
||||
"kind": "table_row",
|
||||
"span": {
|
||||
"end": 490,
|
||||
"start": 423
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "table",
|
||||
"span": {
|
||||
"end": 490,
|
||||
"start": 270
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "继续阅读:",
|
||||
"span": {
|
||||
"end": 507,
|
||||
"start": 492
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "语法演示",
|
||||
"span": {
|
||||
"end": 520,
|
||||
"start": 508
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "link",
|
||||
"span": {
|
||||
"end": 536,
|
||||
"start": 507
|
||||
},
|
||||
"title": "",
|
||||
"url": "./guide.mq.md"
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "。",
|
||||
"span": {
|
||||
"end": 539,
|
||||
"start": 536
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 539,
|
||||
"start": 492
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": "这份欢迎页只是 ",
|
||||
"span": {
|
||||
"end": 565,
|
||||
"start": 543
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "view.json",
|
||||
"span": {
|
||||
"end": 576,
|
||||
"start": 565
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " 显式指定的站点首页,普通 ",
|
||||
"span": {
|
||||
"end": 614,
|
||||
"start": 576
|
||||
}
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "code",
|
||||
"literal": "welcome",
|
||||
"span": {
|
||||
"end": 623,
|
||||
"start": 614
|
||||
},
|
||||
"ticks": 1
|
||||
},
|
||||
{
|
||||
"children": [],
|
||||
"kind": "text",
|
||||
"literal": " 文件名不会自动变成 Hero。",
|
||||
"span": {
|
||||
"end": 659,
|
||||
"start": 623
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "paragraph",
|
||||
"span": {
|
||||
"end": 659,
|
||||
"start": 543
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "block_quote",
|
||||
"span": {
|
||||
"end": 659,
|
||||
"start": 541
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "document",
|
||||
"span": {
|
||||
"end": 660,
|
||||
"start": 0
|
||||
}
|
||||
},
|
||||
"units": [
|
||||
{
|
||||
"id": "root:welcome-demo@0.1.0::00-welcome.mq.md#",
|
||||
"path": [],
|
||||
"parent_id": null,
|
||||
"kind": "root",
|
||||
"name": "",
|
||||
"level": 0,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "default",
|
||||
"mode_source_unit_id": "root:welcome-demo@0.1.0::00-welcome.mq.md#",
|
||||
"heading_span": null,
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 660
|
||||
},
|
||||
"function": null
|
||||
},
|
||||
{
|
||||
"id": "root:welcome-demo@0.1.0::00-welcome.mq.md#欢迎来到 Marqdo",
|
||||
"path": [
|
||||
"欢迎来到 Marqdo"
|
||||
],
|
||||
"parent_id": "root:welcome-demo@0.1.0::00-welcome.mq.md#",
|
||||
"kind": "namespace",
|
||||
"name": "欢迎来到 Marqdo",
|
||||
"level": 1,
|
||||
"mode": "knowledge",
|
||||
"mode_origin": "explicit",
|
||||
"mode_source_unit_id": "root:welcome-demo@0.1.0::00-welcome.mq.md#欢迎来到 Marqdo",
|
||||
"heading_span": {
|
||||
"start": 0,
|
||||
"end": 32
|
||||
},
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 660
|
||||
},
|
||||
"function": null
|
||||
}
|
||||
],
|
||||
"anchors": [
|
||||
{
|
||||
"anchor": "欢迎来到-marqdo",
|
||||
"unit_id": "root:welcome-demo@0.1.0::00-welcome.mq.md#欢迎来到 Marqdo"
|
||||
}
|
||||
],
|
||||
"functions": [],
|
||||
"imports": [],
|
||||
"references": [
|
||||
{
|
||||
"source": "root:welcome-demo@0.1.0::00-welcome.mq.md",
|
||||
"source_unit": "root:welcome-demo@0.1.0::00-welcome.mq.md#欢迎来到 Marqdo",
|
||||
"url": "./guide.mq.md",
|
||||
"span": {
|
||||
"start": 507,
|
||||
"end": 536
|
||||
},
|
||||
"state": "not_loaded",
|
||||
"target_kind": null,
|
||||
"target_module": null,
|
||||
"target_unit": null,
|
||||
"candidate_package_instance_id": "root:welcome-demo@0.1.0",
|
||||
"candidate_path": "guide.mq.md",
|
||||
"fragment": null,
|
||||
"candidates": []
|
||||
}
|
||||
],
|
||||
"calls": [],
|
||||
"resources": []
|
||||
}
|
||||
],
|
||||
"diagnostics": []
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
{"kind":"stream.opened","payload":{"limits":{"max_observation_bytes":16777216,"max_observation_events":100000,"max_value_bytes":256},"observation":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"values":false},"producer":{"name":"marqdo","version":"3.0.0-rc.4"}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":0}
|
||||
{"kind":"run.started","payload":{"entry":"root:control-flow@0.1.0::index.mq.md::main","mode":"pure","source":{"analysis_digest":"sha256:7e8711e9cbb5d5c73369da0c6620279468fa957d5ab8af038de6dd07d23117e3","root_id":"root:control-flow@0.1.0"},"started_unix_ms":1795610282724},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":1}
|
||||
{"kind":"call.enter","payload":{"frame_id":"f1","function_id":"root:control-flow@0.1.0::index.mq.md::演示.main","module_id":"root:control-flow@0.1.0::index.mq.md","parent_frame_id":null,"span":null},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":2}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":202,"start":195},"value_state":"not_requested","value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":3}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.new","result_code":"ok","span":{"end":230,"start":214}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":4}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"buffer","span":{"end":231,"start":204},"value_state":"not_requested","value_type":"Memory"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":5}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":243,"start":234}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":6}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"resource.open","result_code":"ok","span":{"end":304,"start":261}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":7}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"stdout","span":{"end":305,"start":251},"value_state":"not_requested","value_type":"Resource"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":8}
|
||||
{"kind":"loop.iteration","payload":{"decision":"continue","frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":{"end":322,"start":307}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":9}
|
||||
{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":false,"span":{"end":336,"start":324}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":10}
|
||||
{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":true,"span":{"end":368,"start":360}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":11}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":380,"start":371}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":12}
|
||||
{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"MAo=","encoding":"base64"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":13}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"resource.write","result_code":"ok","span":{"end":434,"start":398}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":14}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":450,"start":437},"value_state":"not_requested","value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":15}
|
||||
{"kind":"loop.iteration","payload":{"decision":"continue","frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":{"end":322,"start":307}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":16}
|
||||
{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":false,"span":{"end":336,"start":324}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":17}
|
||||
{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":true,"span":{"end":368,"start":360}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":18}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":380,"start":371}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":19}
|
||||
{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"MAo=","encoding":"base64"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":20}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"resource.write","result_code":"ok","span":{"end":434,"start":398}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":21}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":450,"start":437},"value_state":"not_requested","value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":22}
|
||||
{"kind":"loop.iteration","payload":{"decision":"continue","frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":{"end":322,"start":307}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":23}
|
||||
{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":true,"span":{"end":336,"start":324}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":24}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":348,"start":339}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":25}
|
||||
{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"Mgo=","encoding":"base64"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":26}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"resource.write","result_code":"ok","span":{"end":434,"start":398}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":27}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":450,"start":437},"value_state":"not_requested","value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":28}
|
||||
{"kind":"loop.iteration","payload":{"decision":"exit","frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":{"end":322,"start":307}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":29}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"resource.close","result_code":"ok","span":{"end":484,"start":462}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":30}
|
||||
{"kind":"return","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":{"end":497,"start":487},"value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":31}
|
||||
{"kind":"call.exit","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":null,"status":"return"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":32}
|
||||
{"kind":"run.completed","payload":{"status":"ok","value":{"decimal":"3","type":"int"},"value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":33}
|
||||
@@ -0,0 +1 @@
|
||||
{"events":[{"kind":"stream.opened","payload":{"limits":{"max_observation_bytes":16777216,"max_observation_events":100000,"max_value_bytes":256},"observation":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"values":false},"producer":{"name":"marqdo","version":"3.0.0-rc.4"}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":0},{"kind":"run.started","payload":{"entry":"root:control-flow@0.1.0::index.mq.md::main","mode":"pure","source":{"analysis_digest":"sha256:7e8711e9cbb5d5c73369da0c6620279468fa957d5ab8af038de6dd07d23117e3","root_id":"root:control-flow@0.1.0"},"started_unix_ms":1795610282724},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":1},{"kind":"call.enter","payload":{"frame_id":"f1","function_id":"root:control-flow@0.1.0::index.mq.md::演示.main","module_id":"root:control-flow@0.1.0::index.mq.md","parent_frame_id":null,"span":null},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":2},{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":202,"start":195},"value_state":"not_requested","value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":3},{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.new","result_code":"ok","span":{"end":230,"start":214}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":4},{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"buffer","span":{"end":231,"start":204},"value_state":"not_requested","value_type":"Memory"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":5},{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":243,"start":234}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":6},{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"resource.open","result_code":"ok","span":{"end":304,"start":261}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":7},{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"stdout","span":{"end":305,"start":251},"value_state":"not_requested","value_type":"Resource"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":8},{"kind":"loop.iteration","payload":{"decision":"continue","frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":{"end":322,"start":307}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":9},{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":false,"span":{"end":336,"start":324}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":10},{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":true,"span":{"end":368,"start":360}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":11},{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":380,"start":371}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":12},{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"MAo=","encoding":"base64"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":13},{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"resource.write","result_code":"ok","span":{"end":434,"start":398}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":14},{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":450,"start":437},"value_state":"not_requested","value_type":"Int"},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":15},{"kind":"loop.iteration","payload":{"decision":"continue","frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","span":{"end":322,"start":307}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":16},{"kind":"branch.eval","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","result":false,"span":{"end":336,"start":324}},"run_id":"21-1795610282710646771","schema":"marqdo.observation","schema_version":1,"seq":17},{"kind":"branch.eLine truncated
|
||||
@@ -0,0 +1,12 @@
|
||||
{"kind":"stream.opened","payload":{"limits":{"max_observation_bytes":16777216,"max_observation_events":5,"max_value_bytes":256},"observation":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"values":false},"producer":{"name":"marqdo","version":"3.0.0-rc.4"}},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":0}
|
||||
{"kind":"run.started","payload":{"entry":"root:control-flow@0.1.0::index.mq.md::main","mode":"pure","source":{"analysis_digest":"sha256:7e8711e9cbb5d5c73369da0c6620279468fa957d5ab8af038de6dd07d23117e3","root_id":"root:control-flow@0.1.0"},"started_unix_ms":1795610282743},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":1}
|
||||
{"kind":"call.enter","payload":{"frame_id":"f1","function_id":"root:control-flow@0.1.0::index.mq.md::演示.main","module_id":"root:control-flow@0.1.0::index.mq.md","parent_frame_id":null,"span":null},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":2}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":202,"start":195},"value_state":"not_requested","value_type":"Int"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":3}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.new","result_code":"ok","span":{"end":230,"start":214}},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":4}
|
||||
{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"buffer","span":{"end":231,"start":204},"value_state":"not_requested","value_type":"Memory"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":5}
|
||||
{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":243,"start":234}},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":6}
|
||||
{"kind":"observation.truncated","payload":{"dropped":null,"limit":5,"reason":"event_budget","written":5},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":7}
|
||||
{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"MAo=","encoding":"base64"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":8}
|
||||
{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"MAo=","encoding":"base64"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":9}
|
||||
{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"Mgo=","encoding":"base64"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":10}
|
||||
{"kind":"run.completed","payload":{"status":"ok","value":{"decimal":"3","type":"int"},"value_type":"Int"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":11}
|
||||
@@ -0,0 +1 @@
|
||||
{"events":[{"kind":"stream.opened","payload":{"limits":{"max_observation_bytes":16777216,"max_observation_events":5,"max_value_bytes":256},"observation":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"values":false},"producer":{"name":"marqdo","version":"3.0.0-rc.4"}},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":0},{"kind":"run.started","payload":{"entry":"root:control-flow@0.1.0::index.mq.md::main","mode":"pure","source":{"analysis_digest":"sha256:7e8711e9cbb5d5c73369da0c6620279468fa957d5ab8af038de6dd07d23117e3","root_id":"root:control-flow@0.1.0"},"started_unix_ms":1795610282743},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":1},{"kind":"call.enter","payload":{"frame_id":"f1","function_id":"root:control-flow@0.1.0::index.mq.md::演示.main","module_id":"root:control-flow@0.1.0::index.mq.md","parent_frame_id":null,"span":null},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":2},{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"x","span":{"end":202,"start":195},"value_state":"not_requested","value_type":"Int"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":3},{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.new","result_code":"ok","span":{"end":230,"start":214}},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":4},{"kind":"variable.assigned","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","name":"buffer","span":{"end":231,"start":204},"value_state":"not_requested","value_type":"Memory"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":5},{"kind":"effect","payload":{"frame_id":"f1","module_id":"root:control-flow@0.1.0::index.mq.md","operation":"memory.write","result_code":"ok","span":{"end":243,"start":234}},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":6},{"kind":"observation.truncated","payload":{"dropped":null,"limit":5,"reason":"event_budget","written":5},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":7},{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"MAo=","encoding":"base64"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":8},{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"MAo=","encoding":"base64"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":9},{"kind":"stdout.chunk","payload":{"byte_count":2,"data_base64":"Mgo=","encoding":"base64"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":10},{"kind":"run.completed","payload":{"status":"ok","value":{"decimal":"3","type":"int"},"value_type":"Int"},"run_id":"28-1795610282728843625","schema":"marqdo.observation","schema_version":1,"seq":11}],"capture":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"truncated":{"dropped":null,"limit":5,"reason":"event_budget","written":5},"values":false},"run":{"id":"28-1795610282728843625","source":{"analysis_digest":"sha256:7e8711e9cbb5d5c73369da0c6620279468fa957d5ab8af038de6dd07d23117e3","root_id":"root:control-flow@0.1.0"},"status":"ok"},"schema":"marqdo.observation","schema_version":1}
|
||||
@@ -0,0 +1,3 @@
|
||||
{"kind":"stream.opened","payload":{"limits":{"max_observation_bytes":16777216,"max_observation_events":100000,"max_value_bytes":256},"observation":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"values":false},"producer":{"name":"marqdo","version":"3.0.0-rc.4"}},"run_id":"35-1795610282746900014","schema":"marqdo.observation","schema_version":1,"seq":0}
|
||||
{"kind":"run.started","payload":{"entry":"root:mixed-modes@0.1.0::index.mq.md::main","mode":"pure","source":{"analysis_digest":"sha256:fd686ba0851c34a897f3e432c579ed4c64188914e5b6aec5e24b8ee4f444b01f","root_id":"root:mixed-modes@0.1.0"},"started_unix_ms":1795610282761},"run_id":"35-1795610282746900014","schema":"marqdo.observation","schema_version":1,"seq":1}
|
||||
{"kind":"run.failed","payload":{"error":{"code":"call.arity","column":null,"frames":[],"line":null,"message":"`演示.main` is missing required argument `n`","module_id":null,"origin":"source","relative_path":null,"span":null},"status":"error"},"run_id":"35-1795610282746900014","schema":"marqdo.observation","schema_version":1,"seq":2}
|
||||
@@ -0,0 +1 @@
|
||||
{"events":[{"kind":"stream.opened","payload":{"limits":{"max_observation_bytes":16777216,"max_observation_events":100000,"max_value_bytes":256},"observation":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"values":false},"producer":{"name":"marqdo","version":"3.0.0-rc.4"}},"run_id":"35-1795610282746900014","schema":"marqdo.observation","schema_version":1,"seq":0},{"kind":"run.started","payload":{"entry":"root:mixed-modes@0.1.0::index.mq.md::main","mode":"pure","source":{"analysis_digest":"sha256:fd686ba0851c34a897f3e432c579ed4c64188914e5b6aec5e24b8ee4f444b01f","root_id":"root:mixed-modes@0.1.0"},"started_unix_ms":1795610282761},"run_id":"35-1795610282746900014","schema":"marqdo.observation","schema_version":1,"seq":1},{"kind":"run.failed","payload":{"error":{"code":"call.arity","column":null,"frames":[],"line":null,"message":"`演示.main` is missing required argument `n`","module_id":null,"origin":"source","relative_path":null,"span":null},"status":"error"},"run_id":"35-1795610282746900014","schema":"marqdo.observation","schema_version":1,"seq":2}],"capture":{"allow_text_values":false,"level":"structural","selected_parameters":[],"selected_variables":[],"truncated":null,"values":false},"run":{"id":"35-1795610282746900014","source":{"analysis_digest":"sha256:fd686ba0851c34a897f3e432c579ed4c64188914e5b6aec5e24b8ee4f444b01f","root_id":"root:mixed-modes@0.1.0"},"status":"error"},"schema":"marqdo.observation","schema_version":1}
|
||||
@@ -1,68 +0,0 @@
|
||||
{
|
||||
"command": "run",
|
||||
"diagnostics": [],
|
||||
"stderr": "",
|
||||
"stdout": "0\n0\n2\n",
|
||||
"success": true,
|
||||
"trace": [
|
||||
{
|
||||
"duration_micros": 14,
|
||||
"module": "root:control-flow@0.1.0::index.mq.md",
|
||||
"op": "resource.open",
|
||||
"result": "ok",
|
||||
"seq": 4,
|
||||
"span": {
|
||||
"end": 304,
|
||||
"start": 261
|
||||
}
|
||||
},
|
||||
{
|
||||
"duration_micros": 21,
|
||||
"module": "root:control-flow@0.1.0::index.mq.md",
|
||||
"op": "resource.write",
|
||||
"result": "kind=stdio count=2",
|
||||
"seq": 10,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"duration_micros": 0,
|
||||
"module": "root:control-flow@0.1.0::index.mq.md",
|
||||
"op": "resource.write",
|
||||
"result": "kind=stdio count=2",
|
||||
"seq": 16,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"duration_micros": 0,
|
||||
"module": "root:control-flow@0.1.0::index.mq.md",
|
||||
"op": "resource.write",
|
||||
"result": "kind=stdio count=2",
|
||||
"seq": 21,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"duration_micros": 0,
|
||||
"module": "root:control-flow@0.1.0::index.mq.md",
|
||||
"op": "resource.close",
|
||||
"result": "flushed_bytes=0",
|
||||
"seq": 24,
|
||||
"span": {
|
||||
"end": 484,
|
||||
"start": 462
|
||||
}
|
||||
}
|
||||
],
|
||||
"value": {
|
||||
"decimal": "3",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -1,316 +0,0 @@
|
||||
{
|
||||
"events": [
|
||||
{
|
||||
"detail": null,
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "call.enter",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 0,
|
||||
"span": null
|
||||
},
|
||||
{
|
||||
"detail": "initial_pages=1 max_pages=1",
|
||||
"function_id": null,
|
||||
"kind": "memory.new",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 1,
|
||||
"span": {
|
||||
"end": 230,
|
||||
"start": 214
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "byte",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "memory.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 2,
|
||||
"span": {
|
||||
"end": 243,
|
||||
"start": 234
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio descriptor=stdout",
|
||||
"function_id": null,
|
||||
"kind": "resource.open",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 3,
|
||||
"span": {
|
||||
"end": 304,
|
||||
"start": 261
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "ok",
|
||||
"duration_micros": 14,
|
||||
"kind": "effect",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"operation": "resource.open",
|
||||
"seq": 4,
|
||||
"span": {
|
||||
"end": 304,
|
||||
"start": 261
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "continue",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "loop.iteration",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 5,
|
||||
"span": {
|
||||
"end": 322,
|
||||
"start": 307
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "false",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "branch.eval",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 6,
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "true",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "branch.eval",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 7,
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "byte",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "memory.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 8,
|
||||
"span": {
|
||||
"end": 380,
|
||||
"start": 371
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio count=2",
|
||||
"function_id": null,
|
||||
"kind": "resource.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 9,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio count=2",
|
||||
"duration_micros": 21,
|
||||
"kind": "effect",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"operation": "resource.write",
|
||||
"seq": 10,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "continue",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "loop.iteration",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 11,
|
||||
"span": {
|
||||
"end": 322,
|
||||
"start": 307
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "false",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "branch.eval",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 12,
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "true",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "branch.eval",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 13,
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "byte",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "memory.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 14,
|
||||
"span": {
|
||||
"end": 380,
|
||||
"start": 371
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio count=2",
|
||||
"function_id": null,
|
||||
"kind": "resource.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 15,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio count=2",
|
||||
"duration_micros": 0,
|
||||
"kind": "effect",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"operation": "resource.write",
|
||||
"seq": 16,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "continue",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "loop.iteration",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 17,
|
||||
"span": {
|
||||
"end": 322,
|
||||
"start": 307
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "true",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "branch.eval",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 18,
|
||||
"span": {
|
||||
"end": 336,
|
||||
"start": 324
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "byte",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "memory.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 19,
|
||||
"span": {
|
||||
"end": 348,
|
||||
"start": 339
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio count=2",
|
||||
"function_id": null,
|
||||
"kind": "resource.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 20,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio count=2",
|
||||
"duration_micros": 0,
|
||||
"kind": "effect",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"operation": "resource.write",
|
||||
"seq": 21,
|
||||
"span": {
|
||||
"end": 434,
|
||||
"start": 398
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "exit",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "loop.iteration",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 22,
|
||||
"span": {
|
||||
"end": 322,
|
||||
"start": 307
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "flushed_bytes=0",
|
||||
"function_id": null,
|
||||
"kind": "resource.close",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 23,
|
||||
"span": {
|
||||
"end": 484,
|
||||
"start": 462
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "flushed_bytes=0",
|
||||
"duration_micros": 0,
|
||||
"kind": "effect",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"operation": "resource.close",
|
||||
"seq": 24,
|
||||
"span": {
|
||||
"end": 484,
|
||||
"start": 462
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "Int",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "return",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 25,
|
||||
"span": {
|
||||
"end": 497,
|
||||
"start": 487
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "return",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "call.exit",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 26,
|
||||
"span": null
|
||||
}
|
||||
],
|
||||
"limits": {
|
||||
"max_bytes": 33554432,
|
||||
"max_events": 100000
|
||||
},
|
||||
"run": {
|
||||
"entry": "root:control-flow@0.1.0::index.mq.md::main",
|
||||
"id": "29-1795354081718410176",
|
||||
"status": "ok"
|
||||
},
|
||||
"schema": "marqdo.trace",
|
||||
"schema_version": 2,
|
||||
"source": {
|
||||
"analysis_digest": "sha256:392c82598cdd9d649951133df9a364d85bca7036aa653a4139aab190e9040af4",
|
||||
"root_id": "root:control-flow@0.1.0"
|
||||
},
|
||||
"truncated": null
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"command": "run",
|
||||
"diagnostics": [],
|
||||
"stderr": "",
|
||||
"stdout": "0\n0\n2\n",
|
||||
"success": true,
|
||||
"trace": [
|
||||
{
|
||||
"duration_micros": 10,
|
||||
"module": "root:control-flow@0.1.0::index.mq.md",
|
||||
"op": "resource.open",
|
||||
"result": "ok",
|
||||
"seq": 4,
|
||||
"span": {
|
||||
"end": 304,
|
||||
"start": 261
|
||||
}
|
||||
}
|
||||
],
|
||||
"value": {
|
||||
"decimal": "3",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
{
|
||||
"events": [
|
||||
{
|
||||
"detail": null,
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "call.enter",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 0,
|
||||
"span": null
|
||||
},
|
||||
{
|
||||
"detail": "initial_pages=1 max_pages=1",
|
||||
"function_id": null,
|
||||
"kind": "memory.new",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 1,
|
||||
"span": {
|
||||
"end": 230,
|
||||
"start": 214
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "byte",
|
||||
"function_id": "root:control-flow@0.1.0::index.mq.md::演示.main",
|
||||
"kind": "memory.write",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 2,
|
||||
"span": {
|
||||
"end": 243,
|
||||
"start": 234
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "kind=stdio descriptor=stdout",
|
||||
"function_id": null,
|
||||
"kind": "resource.open",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"seq": 3,
|
||||
"span": {
|
||||
"end": 304,
|
||||
"start": 261
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "ok",
|
||||
"duration_micros": 10,
|
||||
"kind": "effect",
|
||||
"module_id": "root:control-flow@0.1.0::index.mq.md",
|
||||
"operation": "resource.open",
|
||||
"seq": 4,
|
||||
"span": {
|
||||
"end": 304,
|
||||
"start": 261
|
||||
}
|
||||
},
|
||||
{
|
||||
"detail": "event_budget",
|
||||
"kind": "trace.truncated",
|
||||
"module_id": null,
|
||||
"seq": 5,
|
||||
"span": null
|
||||
}
|
||||
],
|
||||
"limits": {
|
||||
"max_bytes": 33554432,
|
||||
"max_events": 5
|
||||
},
|
||||
"run": {
|
||||
"entry": "root:control-flow@0.1.0::index.mq.md::main",
|
||||
"id": "31-1795354081721454068",
|
||||
"status": "ok"
|
||||
},
|
||||
"schema": "marqdo.trace",
|
||||
"schema_version": 2,
|
||||
"source": {
|
||||
"analysis_digest": "sha256:392c82598cdd9d649951133df9a364d85bca7036aa653a4139aab190e9040af4",
|
||||
"root_id": "root:control-flow@0.1.0"
|
||||
},
|
||||
"truncated": {
|
||||
"limit": 5,
|
||||
"reason": "event_budget",
|
||||
"written": 5
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"command": "run",
|
||||
"error": {
|
||||
"code": "call.arity",
|
||||
"column": null,
|
||||
"file": null,
|
||||
"frames": [],
|
||||
"line": null,
|
||||
"message": "`演示.main` is missing required argument `n`",
|
||||
"module_id": null,
|
||||
"origin": "source",
|
||||
"relative_path": null,
|
||||
"span": null
|
||||
},
|
||||
"stderr": "",
|
||||
"stdout": "",
|
||||
"success": false,
|
||||
"trace": []
|
||||
}
|
||||
Loaded 100 of 108 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user