feat: offline environment report + document-structure contract (#25/#26/#20) #27

Merged
cflmy merged 3 commits from codex/issue-25-26-environment-document-contract into master 2026-11-30 12:04:18 +08:00
Owner

概述

实现 marqdo#55/marqdo#56 在 CLI 责任仓的两个子工单,不新增文档语言语法、不新增跨仓依赖:

  • marqdo-cli#26 §9.2(P1):marqdo inspect --environment [--json] 离线诊断导出(marqdo.environment v1),并把它绑定到发行身份。
  • marqdo-cli#25:spec/document-structure.md 固化当前文稿结构与入口语义,附 6 个真实 CLI 契约测试。
  • 顺带完成 marqdo-cli#20 要求的“发行归档绑定精确源码/Bundle 输入”:package 与 smoke 都从归档自身验证。

交付

1. 环境诊断导出(#26 §9.2)

  • 新命令模式 inspect --environment:离线、与项目无关,只读取安装身份与平台事实;不加载模块、不启动 provider 会话、不打开插件、不联网、不输出绝对路径/凭据/源内容;与文档检查 flags 互斥(clap 报 usage error,退出码 2)。
  • 字段:producer 版本 + 构建内嵌源码 SHA、platform(os/arch/family/glibc 版本/真实 strict 探测/worker_processes)、相邻 marqdo-provider-worker 的版本/SHA(通过有界离线 --build-info,750ms 超时)、已验证 Bundle 的 name/version/tree digest/instance id、当前协议版本、路径自由的 diagnostics[].code。
  • 降级安装以数据报告(status: invalid + env.stdlib_*),命令仍成功;这是反馈体系需要的可脚本消费语义。
  • 新增 spec/environment.md(唯一现行契约),README/COMPATIBILITY/developers/releasing/STATUS 同步。

2. 发行身份绑定(#20)

  • crates/cli/build.rs 与 crates/marqdo-provider-worker/build.rs 在构建时嵌入 MARQDO_BUILD_SOURCE_SHA(严格 40 位小写 hex;dev 构建诚实为 null)。
  • CI build lane 在 cargo build --release 前 export MARQDO_BUILD_SOURCE_SHA="$CI_COMMIT_SHA"。
  • tools/release/package.py 在写 RELEASE_INFO.json/归档前运行暂存二进制的 inspect --environment --json,要求 CLI 与 worker 的 source SHA 等于 --source-sha、Bundle verified 且 tree digest 等于归档 Bundle;不匹配即失败。
  • tools/release/smoke.py 从解包归档再执行同一检查,禁止“归档声称未构建的源码”。

3. 文稿结构与入口语义契约(#25)

  • spec/document-structure.md:H1–H6 与 @exec/@knowledge 继承(最近祖先、绝不兄弟;仅 Exec H2 可调用)、unit 身份与同作用域重名错误、anchor slug 冲突编号、UTF-8 半开 span(BOM/CRLF/无尾换行)、index.mq.md 作为项目入口 vs 目录依赖 import 的区别、link≠import≠call、未实现项(heading annotations)显式标注、消费者可依赖的 Analysis 字段清单。
  • 只链接 mapping.md/analysis.md/references.md/package-format.md 单一事实源,不复制第二份规范。
  • crates/cli/tests/document_structure.rs 6 个真实 CLI 用例;docs_consistency 增加“单一契约 + 入口链接”断言。

验证(本地,Linux x86_64 / glibc 2.43)

cargo fmt --all -- --check                                   PASS
cargo clippy --workspace --all-targets -- -D warnings         PASS
cargo test --workspace --locked (pinned ecosystem Bundle)     638 passed, 0 failed, 2 ignored
cargo test --test docs_consistency                            9 passed
cargo test --test environment_report                         5 passed
cargo test --test document_structure                         6 passed
python3 tools/ci/check_dependency_boundaries.py               PASS
python3 tools/ci/check_engine_boundary.py                     PASS
python3 tools/ci/check_plugin_sdk.py                          PASS
python3 tools/ci/independent_build.py                         PASS
python3 -m unittest discover -s tools/ci -p 'test_*.py'       80 passed
  • Bundle 输入:python3 tools/ci/fetch_ecosystem_bundle.py --out target/ecosystem-stdlib(pin commit 与各 gitlink 固定)。
  • 归档级证据(release build + package.py + smoke.py)在本 PR 后续 docs 提交记录;若未运行会明确写 UNVERIFIED,不冒充 PASS。
  • Windows/macOS 原生 lane、strict VM 仍是 UNVERIFIED(属 #26 P2/P3 上游环境阻塞),本 PR 未改变平台支持声明。

边界

  • 无新增 builtin/HostOp/Value/顶层命令(inspect --environment 是既有 inspect 的离线模式,不进入执行路径)。
  • 不改变语言语义、Analysis/Observation/Tool 协议版本、锁格式或扩展机制。
  • 未新增 crate、无新跨仓依赖;marqdo-cli 仅新增 libc workspace 依赖(用于报告 glibc 运行时事实,已存在于 workspace lock)。

关联

refs #25 #26 #20

## 概述 实现 `marqdo#55`/`marqdo#56` 在 CLI 责任仓的两个子工单,不新增文档语言语法、不新增跨仓依赖: - `marqdo-cli#26` §9.2(P1):`marqdo inspect --environment [--json]` 离线诊断导出(`marqdo.environment` v1),并把它绑定到发行身份。 - `marqdo-cli#25`:`spec/document-structure.md` 固化当前文稿结构与入口语义,附 6 个真实 CLI 契约测试。 - 顺带完成 `marqdo-cli#20` 要求的“发行归档绑定精确源码/Bundle 输入”:package 与 smoke 都从归档自身验证。 ## 交付 ### 1. 环境诊断导出(#26 §9.2) - 新命令模式 `inspect --environment`:离线、与项目无关,只读取安装身份与平台事实;不加载模块、不启动 provider 会话、不打开插件、不联网、不输出绝对路径/凭据/源内容;与文档检查 flags 互斥(clap 报 usage error,退出码 2)。 - 字段:producer 版本 + 构建内嵌源码 SHA、platform(os/arch/family/glibc 版本/真实 strict 探测/worker_processes)、相邻 `marqdo-provider-worker` 的版本/SHA(通过有界离线 `--build-info`,750ms 超时)、已验证 Bundle 的 name/version/tree digest/instance id、当前协议版本、路径自由的 `diagnostics[].code`。 - 降级安装以数据报告(`status: invalid` + `env.stdlib_*`),命令仍成功;这是反馈体系需要的可脚本消费语义。 - 新增 `spec/environment.md`(唯一现行契约),README/COMPATIBILITY/developers/releasing/STATUS 同步。 ### 2. 发行身份绑定(#20) - `crates/cli/build.rs` 与 `crates/marqdo-provider-worker/build.rs` 在构建时嵌入 `MARQDO_BUILD_SOURCE_SHA`(严格 40 位小写 hex;dev 构建诚实为 null)。 - CI `build` lane 在 `cargo build --release` 前 `export MARQDO_BUILD_SOURCE_SHA="$CI_COMMIT_SHA"`。 - `tools/release/package.py` 在写 `RELEASE_INFO.json`/归档前运行暂存二进制的 `inspect --environment --json`,要求 CLI 与 worker 的 source SHA 等于 `--source-sha`、Bundle `verified` 且 tree digest 等于归档 Bundle;不匹配即失败。 - `tools/release/smoke.py` 从解包归档再执行同一检查,禁止“归档声称未构建的源码”。 ### 3. 文稿结构与入口语义契约(#25) - `spec/document-structure.md`:H1–H6 与 `@exec`/`@knowledge` 继承(最近祖先、绝不兄弟;仅 Exec H2 可调用)、unit 身份与同作用域重名错误、anchor slug 冲突编号、UTF-8 半开 span(BOM/CRLF/无尾换行)、`index.mq.md` 作为项目入口 vs 目录依赖 import 的区别、link≠import≠call、未实现项(heading annotations)显式标注、消费者可依赖的 Analysis 字段清单。 - 只链接 `mapping.md`/`analysis.md`/`references.md`/`package-format.md` 单一事实源,不复制第二份规范。 - `crates/cli/tests/document_structure.rs` 6 个真实 CLI 用例;`docs_consistency` 增加“单一契约 + 入口链接”断言。 ## 验证(本地,Linux x86_64 / glibc 2.43) ```text cargo fmt --all -- --check PASS cargo clippy --workspace --all-targets -- -D warnings PASS cargo test --workspace --locked (pinned ecosystem Bundle) 638 passed, 0 failed, 2 ignored cargo test --test docs_consistency 9 passed cargo test --test environment_report 5 passed cargo test --test document_structure 6 passed python3 tools/ci/check_dependency_boundaries.py PASS python3 tools/ci/check_engine_boundary.py PASS python3 tools/ci/check_plugin_sdk.py PASS python3 tools/ci/independent_build.py PASS python3 -m unittest discover -s tools/ci -p 'test_*.py' 80 passed ``` - Bundle 输入:`python3 tools/ci/fetch_ecosystem_bundle.py --out target/ecosystem-stdlib`(pin commit 与各 gitlink 固定)。 - 归档级证据(release build + package.py + smoke.py)在本 PR 后续 docs 提交记录;若未运行会明确写 UNVERIFIED,不冒充 PASS。 - Windows/macOS 原生 lane、strict VM 仍是 UNVERIFIED(属 #26 P2/P3 上游环境阻塞),本 PR 未改变平台支持声明。 ## 边界 - 无新增 builtin/HostOp/Value/顶层命令(`inspect --environment` 是既有 `inspect` 的离线模式,不进入执行路径)。 - 不改变语言语义、Analysis/Observation/Tool 协议版本、锁格式或扩展机制。 - 未新增 crate、无新跨仓依赖;`marqdo-cli` 仅新增 `libc` workspace 依赖(用于报告 glibc 运行时事实,已存在于 workspace lock)。 ## 关联 refs #25 #26 #20
cflmy added 1 commit 2026-11-30 11:35:42 +08:00
Implements the two CLI-owned P0 sub-issues of the ecosystem architecture
tickets without adding document-language syntax.

Environment report (marqdo-cli#26 §9.2, binding for #20):
- `marqdo inspect --environment [--json]` emits `marqdo.environment` v1:
  producer version and build-embedded source commit, platform/arch/glibc and
  real strict probe, adjacent provider-worker version/SHA (offline
  `--build-info`, bounded), verified Bundle identity, current protocol
  revisions and path-free diagnostics. Project-independent, offline, and
  exclusive with document inspection flags.
- Release builds embed `MARQDO_BUILD_SOURCE_SHA`; the CI `build` lane sets it.
  `tools/release/package.py` refuses to stage an archive whose binaries report
  another commit or Bundle digest, and `tools/release/smoke.py` re-verifies the
  extracted archive.
- Spec: `spec/environment.md`. Tests: `environment_report.rs` (5 cases) and
  in-module unit tests; docs/releasing/COMPATIBILITY/STATUS updated.

Document-structure contract (marqdo-cli#25):
- `spec/document-structure.md` states the current author/tool semantics once:
  heading mode inheritance (nearest ancestor, only Exec H2 callable), unit
  identity and duplicate-name rules, anchor collision numbering, byte-exact
  half-open spans, `index.mq.md` entry vs directory-dependency import meaning,
  link != import != call, Proposed annotations marked not implemented, and the
  Analysis fields consumers may rely on. It links the single authoritative
  specs instead of duplicating them.
- Tests: `document_structure.rs` (6 cases) + docs_consistency coverage.

No runtime behavior change, no new language surface, no new cross-repo
dependency. `docs_consistency` and `architecture_boundaries` remain green.
cflmy added 1 commit 2026-11-30 11:41:41 +08:00
Add the reproducible evidence record for candidate 0f87f856: pinned
ecosystem Bundle identity, the full source gate list (fmt/clippy/638
workspace tests/boundaries/independent-build), the environment-report probes,
the release archive built with the embedded source SHA (package identity check
+ smoke PASS) and the Woodpecker push/PR lanes. Windows/macOS native lanes and
the strict VM lane stay UNVERIFIED.

Links the record from docs/STATUS.md.
cflmy added 1 commit 2026-11-30 11:53:48 +08:00
cflmy merged commit 36666ab52b into master 2026-11-30 12:04:18 +08:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: cflmy/marqdo-cli#27