Files
marqdo-cli/docs/evidence/2026-11-20-stdlib-print-compat-a.md
T
cflmy 92bfbf2568 feat(rfc-cm): baseline P0-P3 compute machine, stdlib and resource slices
Implements the first vertical slices of RFC-CM-0001/0002 on top of a113d89:

- P1: opaque Memory regions (64 KiB pages, budgets, grow-only), byte
  read/write, Memory-index place assignment, wire/host-boundary rejection.
- CM-A04/A05: value-semantics List/Map/Text/Table primitives and the
  recoverable Result map convention.
- CM-A06: opaque Resource handles, resource.open/read/write/close, stdout
  write, granted project-file read and buffered write, strict fail-closed.
- CM-A07 Compat-A: explicit .mq.md format/utf8/io chain matching builtin
  print for the covered value types; builtin remains default.
- P2 fixtures: allocators, list/tree/graph/hash, integer codecs, UTF-8
  encode/decode, CSV/JSON subsets, table filter/sort/join, bytecode VM.
- ADRs 0022-0027, spec updates, evidence reports and 68 semantic goldens.

Gate: cargo fmt --check, clippy -D warnings, 407 tests passed.
2026-11-20 21:16:54 +08:00

3.6 KiB
Raw Blame History

RFC-CM CM-A07 Compat-A evidence: .mq.md print prototype

Date: 2026-11-20 (Asia/Shanghai) Repository: marqdo-cli Baseline: a113d89 plus the uncommitted RFC-CM P0–P3 changes. Decision record: ADR-0027 Related: Resource P3, file write, STATUS §5. Scope: Compat-A only. Builtin 打印 is not migrated; no alias routing and no removal of HostOp::Print.

Environment and gate

Ubuntu 26.04 development container, Linux x86_64, Rust 1.100.0.

cargo fmt --all -- --check                            PASS
cargo clippy --workspace --all-targets -- -D warnings PASS
cargo test --workspace --locked                       PASS
  407 passed, 0 failed, 2 ignored (existing plugin-sdk doc-tests)

No GitHub CI is available from this checkout; this is local evidence.

Prototype

Ordinary .mq.md modules under examples/stdlib/:

File Responsibility
format.mq.md 显示 for Unit/None/Bool/Int/Float/Text/List/Map/Table, 值显示 (repr), 转义文本, 列表显示, 映射显示, 表格显示, 连接文本
text.mq.md utf8编码(文本, 内存, 基址) — 1–4 byte UTF-8 into Memory
io.mq.md 写文本 (encode → resource.write(stdout) → close) and 写值 (format + newline)
demo.mq.md side-by-side io.写值(x) and builtin 打印(x) for a nested list and a table

The call chain is exactly the RFC target shape:

io.写值(value)
  -> format.显示(value)           # .mq.md value formatting, no Rust display()
  -> text.utf8编码(text, memory)  # .mq.md UTF-8 encoder
  -> resource.open(stdout)
  -> resource.write(memory, ...)  # bytes through Memory
  -> resource.close(stdout)

No HostOp, no new builtin, no parser change and no special stdlib dispatch. The module is loaded only through an explicit Markdown import alias.

Output comparison

$ marqdo run examples/stdlib/demo.mq.md
["文本", 2, 1.5, [3, true], {a: 1, b: "x"}, None]
["文本", 2, 1.5, [3, true], {a: 1, b: "x"}, None]
Table[名称 | 分数]{甲 | 87; 乙 | 92}
Table[名称 | 分数]{甲 | 87; 乙 | 92}

The first and third lines are io.写值; the second and fourth are builtin 打印. They are byte-identical.

CLI test: crates/cli/tests/examples_r6.rs::mqmd_stdlib_print_output_matches_builtin_print asserts exactly four lines, pairwise equality, and the exact list/table text.

Covered and uncovered values

Covered by Compat-A comparison: Unit, None, Bool, Int, Float, Text, List, Map, Table.

Not covered: Formula, Code, FunctionRef, PluginHandle. The language still has no public observation for the module/name/handle identity needed to reproduce Value::display()/repr() for those types; adding it is a CM-A04 extension, not part of this slice. This is the explicit blocker for Compat-B.

What is not migrated

  • 打印/print still resolves to the existing builtin and HostOp::Print.
  • No alias table, no bundled stdlib resolution, no std package.
  • No stdlib version/digest or offline distribution (CM-A10).
  • No Compat-B/C comparison lane or removal of the Rust Value::display() path.
  • The demo/stdlib is an examples/ prototype, not a shipped standard library.

Reproduce

export PATH=/root/.cargo/bin:$PATH
export CARGO_HOME=/root/work/marqdo-cli/.cache/cargo
export CARGO_TARGET_DIR=/root/work/marqdo-cli/.cache/target
cargo run -q -p marqdo-cli -- run examples/stdlib/demo.mq.md
cargo test -p marqdo-cli --test examples_r6
cargo test --workspace --locked