Implement marqdo-cli#24 (AI-U1): ordinary .mq.md programs can read the
document snapshot that `prepare` already loaded, without a parser, host paths
or a second knowledge body.
- marqdo-host-contract gains the neutral read-only DocumentModule/DocumentUnit
projection (canonical ids, path/parent/level/mode/anchors, exact section and
heading spans, source digest, exact source) and two default-unavailable Host
methods.
- The composition root builds the snapshot from the same load as Analysis
(entry + explicit import closure only; no extra reads) and attaches it to the
native host. StdHost only slices the immutable source; it never executes
project code, loads modules, parses Markdown or touches the network.
- New builtins: document.outline(module?, parent?, limit?) and
document.read(module, unit, expected_digest?, max_bytes?). Expected states
(not loaded, unknown unit, stale source, over budget, invalid span) are
structured result maps with stable document.* codes, so ordinary control flow
can branch instead of crashing.
- Specification: spec/document-access.md, spec/evaluation.md §8, ADR-0074,
README/developers/STATUS links and a docs-consistency gate for the single
current contract.
- Tests: document_access.rs checks byte-exact agreement with check --emit
Analysis (module/unit ids, digests, spans, cross-module anchor read) and all
failure codes; the ADR-0064 builtin review table records the two additions.
Binary budgets are explicit (snapshot 128 modules/16 MiB; outline 1024/4096;
read 256 KiB/1 MiB) and over-budget requests report document.too_large rather
than truncating.
The evidence consistency gate requires a commit/security SHA in every
docs/evidence Markdown file; record the Bundle-0.3.0 baseline commit so the
document-access evidence passes the same gate as the other records.
cflmy
merged commit afea4f9474 into master2026-11-30 15:52:09 +08:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
概述
实现
marqdo-cli#24(AI-U1):普通.mq.md程序可通过document.outline/document.read读取prepare已加载的文稿快照(精确 unit、anchor、UTF-8 byte span、source digest 与原文),不复制 Markdown 解析器、不读宿主文件路径、不执行文稿;预期失败是结构化 result map,不是崩溃。设计
marqdo-host-contract:新增只读DocumentModule/DocumentUnit快照类型 + 两个默认不可用 Host 方法(document_outline/document_read)。引擎仍只依赖中立 contract(ADR-0071)。crates/cli/src/document_snapshot.rs:从与 Analysis 相同的prepare加载构建快照(入口 + 显式导入闭包),携带 canonical module/unit id、path/parent/level/mode/anchors、完整 section span、heading span、source digest、exact source。document.outline(module?, parent?, limit?)、document.read(module, unit, expected_digest?, max_bytes?);结果{ok:true,...}或稳定失败码document.not_loaded/document.unknown_unit/document.stale_source/document.too_large/document.invalid_request。spec/document-access.md、spec/evaluation.md§8、ADR-0074;README/developers/STATUS 链接;docs_consistency 单一契约门禁;builtin 评审表更新。document.too_large不静默裁剪。验证(真实,Linux x86_64 / glibc 2.43;Bundle 0.3.0)
document_access.rs与check --emitAnalysis 3 逐字节比对:module/unit id、source_digest、section span、跨模块 anchor 读取;负例覆盖 not_loaded/unknown_unit/stale_source/too_large;同名标题 anchor(说明/说明-2)可区分。证据:docs/evidence/2026-11-30-cli-document-runtime-access.md。边界 / 未验证
check/inspect不执行,故不暴露读取;strict 子进程按同一 prepare 重建快照。refs #24 #13