refactor(print): remove HostOp::Print and legacy formatting (Compat-C)

- Delete HostOp::Print and StdHost::op_print; the print builtin only routes to
  bundled io.写值 when Program.print_override is set, otherwise returns a
  structured kernel.unavailable error (ADR-0031).
- Keep the 打印/print builtin name for arity/static validation; Value::display
  remains only for CLI result rendering, not print execution.
- Teach the direct-runtime semantic harness to mirror loader stdlib injection
  and import edges; replace runtime tests that used print with non-print
  effects.
- Update spec/security/status/changelog/README, add ADR-0031 and evidence.

Gate: fmt, clippy -D warnings, 419 tests passed.
This commit is contained in:
cflmy committed 2026-11-20 22:22:51 +08:00
1 parent e26971f489
commit 49910ece43
16 files changed
+304 -56

No files matched your search

+3
View File
@@ -108,6 +108,9 @@ currently `0.1.0`; no release tag has been cut. Dates use ISO 8601.
an `fs_write` grant, buffers in the host, flushes only on `close`, never
flushes on drop, has an 8 MiB ceiling, and is refused in pure/strict. A
`.mq.md` chunked copy loop reproduces a file without a Rust `copy_file`.
- Compat-C print completion (ADR-0031): remove `HostOp::Print` and
`StdHost::op_print`; the print builtin only routes to bundled `io.写值` or
returns `kernel.unavailable`; print traces contain only resource effects.
- Compat-B `打印`/`print` routing (ADR-0030): a `Program.print_override` sends
print calls to bundled `io.写值` when the program uses them; stdlib modules
are injected lazily, resource operations appear as trace effects and the
+3 -3
View File
@@ -102,9 +102,9 @@ executes anything.
* **Bundled stdlib + print prototype (RFC-CM CM-A07/A10)** — offline
`stdlib/` with explicit `std:io`/`std:format`/`std:text` imports, SHA-256
digest verification, Analysis identity and a frozen-CLI closure test; the
`.mq.md` print chain is the execution path for `打印`/`print` when the bundle is present (ADR-0030),
covering all 15 value types; the legacy builtin is only a no-bundle fallback
(ADR-0027/0028/0029/0030).
`.mq.md` print chain is the only execution path for `打印`/`print` on an official install (ADR-0031),
covering all 15 value types; `HostOp::Print` and the legacy formatter are
removed (ADR-0027/0028/0029/0030/0031).
* **Resource streams (RFC-CM CM-A06)** — opaque host-issued `Resource` handles;
`resource.open/read/write/close` transfer bytes through `Memory`; stdout
write in pure/project, granted project-file read, and buffered project-file
+72 -1
View File
@@ -24,7 +24,7 @@ use std::path::{Path, PathBuf};
use std::process::Command;
use marqdo_host::{Capabilities, Host, StdHost};
use marqdo_ir::ModuleId;
use marqdo_ir::{ModuleId, Program, ResolvedImport};
use marqdo_runtime::{run, EvaluatedArg};
use marqdo_sandbox::SandboxMode;
@@ -168,6 +168,7 @@ fn semantic_goldens_match_end_to_end_execution() {
let mut program = marqdo_ir::Program::default();
program.insert(analysis.module.clone());
program.main_module = Some(module_id.clone());
install_stdlib_print(&mut program);
let mut capabilities = Capabilities::pure();
if grant_foreign {
@@ -263,3 +264,73 @@ fn semantic_goldens_match_end_to_end_execution() {
fixtures.len()
);
}
/// Load the bundled stdlib print modules for direct-runtime fixtures.
///
/// The CLI loader normally injects these for Compat-B. The semantic harness
/// builds a Program directly, so it mirrors the same resolution here; without
/// it, fixtures that call `打印` would hit the Compat-C "no bundle" error.
fn install_stdlib_print(program: &mut Program) {
let root = repo_root().join("stdlib");
if !root.join("stdlib.json").is_file() {
return;
}
let mut loaded = std::collections::BTreeSet::new();
let io = match load_stdlib_module(&root, "io.mq.md", program, &mut loaded) {
Ok(id) => id,
Err(error) => panic!("cannot load bundled stdlib: {error}"),
};
let function = program
.module(&io)
.and_then(|module| module.function("写值"))
.unwrap_or_else(|| panic!("stdlib io has no 写值 function"));
program.print_override = Some(function.id.clone());
}
fn load_stdlib_module(
root: &Path,
relative: &str,
program: &mut Program,
loaded: &mut std::collections::BTreeSet<String>,
) -> Result<ModuleId, String> {
if !loaded.insert(relative.to_string()) {
return Err(format!("stdlib import cycle at `{relative}`"));
}
let path = root.join(relative);
let source = fs::read_to_string(&path)
.map_err(|error| format!("cannot read `{}`: {error}", path.display()))?;
let module_id = ModuleId::new("std:test", relative.replace('\\', "/"));
let analysis = marqdo_frontend::analyze_source(&module_id.to_string(), &source);
if analysis.has_errors() {
return Err(format!("stdlib module `{relative}` has diagnostics"));
}
let imports: Vec<(String, String)> = analysis
.document
.frontmatter()
.and_then(|frontmatter| frontmatter.imports().ok())
.map(|mapping| mapping.into_iter().collect())
.unwrap_or_default();
for (alias, target) in imports {
let target = target.strip_prefix("std:").unwrap_or(&target);
let child = if target.starts_with("./") || target.starts_with("../") {
let base = Path::new(relative)
.parent()
.unwrap_or_else(|| Path::new(""));
base.join(target)
.components()
.map(|component| component.as_os_str().to_string_lossy().to_string())
.collect::<Vec<_>>()
.join("/")
} else {
target.to_string()
};
let to = load_stdlib_module(root, &child, program, loaded)?;
program.resolved_imports.push(ResolvedImport {
from: module_id.clone(),
alias,
to,
});
}
program.insert(analysis.module);
Ok(module_id)
}
-25
View File
@@ -27,8 +27,6 @@ use marqdo_sandbox::{PlatformCapabilities, SandboxMode};
/// Host operations reachable from the language surface.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum HostOp {
/// Write a value to program stdout.
Print,
/// Parse a formula.
MathParse,
/// Evaluate a formula.
@@ -55,7 +53,6 @@ impl HostOp {
/// Stable operation name used in traces and diagnostics.
pub const fn name(self) -> &'static str {
match self {
HostOp::Print => "print",
HostOp::MathParse => "math.parse",
HostOp::MathEval => "math.eval",
HostOp::MathSubstitute => "math.substitute",
@@ -480,7 +477,6 @@ impl StdHost {
ctx: &ExecutionContext,
) -> Result<Value, RuntimeError> {
match op {
HostOp::Print => self.op_print(args, ctx),
HostOp::FsRead => self.op_fs_read(args, ctx),
HostOp::FsWrite => self.op_fs_write(args, ctx),
HostOp::MathParse
@@ -495,27 +491,6 @@ impl StdHost {
}
}
fn op_print(
&mut self,
args: Vec<Value>,
ctx: &ExecutionContext,
) -> Result<Value, RuntimeError> {
if !self.capabilities.console {
return Err(RuntimeError::new(
ErrorCategory::PermissionDenied,
ctx.span,
"program output (console) capability was not granted",
));
}
if args.len() != 1 {
return Err(arity(ctx.span, "打印", 1, args.len()));
}
let text = format!("{}\n", args[0].display());
self.budget.consume_output(text.len(), ctx.span)?;
self.output.extend_from_slice(text.as_bytes());
Ok(Value::Unit)
}
fn op_fs_read(
&mut self,
args: Vec<Value>,
+1 -1
View File
@@ -85,7 +85,7 @@ fn resource_handles_cannot_cross_the_generic_host_boundary() {
.unwrap(),
);
let error = host
.invoke(HostOp::Print, vec![Value::Resource(handle)], &ctx)
.invoke(HostOp::FsRead, vec![Value::Resource(handle)], &ctx)
.unwrap_err();
assert_eq!(error.category, ErrorCategory::Type);
assert!(error.message.contains("Resource handles"));
+2 -2
View File
@@ -517,8 +517,8 @@ pub struct Program {
/// metadata only: `check` never loads a library.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub external_callables: Vec<callable::CallableDescriptor>,
/// Compat-B `打印`/`print` destination (ADR-0030). When set, the runtime
/// calls this stdlib function instead of the legacy `HostOp::Print`.
/// Compat-B/C `打印`/`print` destination (ADR-0030/0031). When set, the
/// runtime calls this stdlib function; there is no legacy HostOp path.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub print_override: Option<FunctionId>,
}
+9 -4
View File
@@ -27,10 +27,15 @@ pub(crate) fn dispatch(
let module = frame.module().clone();
match builtin.name {
"打印" => {
let value = take(&bound, "值", builtin, span)?;
interpreter
.host_invoke(HostOp::Print, vec![value], span, &module)
.map(|_| Value::Unit)
// Compat-C (ADR-0031): the legacy HostOp::Print path is gone. On
// the official CLI the loader routes 打印/print to stdlib io.写值;
// reaching this builtin means the verified bundle was unavailable.
let _ = take(&bound, "值", builtin, span)?;
Err(RuntimeError::new(
ErrorCategory::KernelUnavailable,
span,
"打印 requires the bundled stdlib print module; install the official CLI bundle",
))
}
"长度" => {
let value = take(&bound, "值", builtin, span)?;
+18 -7
View File
@@ -70,11 +70,10 @@ fn recursion_branch_and_return() {
}
#[test]
fn loop_prints_and_returns_unit_for_fallthrough() {
let source = "## 倒计时\n\n**n = 3**\n\n- `n > 0`\n\n > 打印(n)\n\n **n = n - 1**\n";
let (result, output) = run_and_output(source, "倒计时");
fn loop_mutates_and_returns_unit_for_fallthrough() {
let source = "## 倒计时\n\n**n = 3**\n\n- `n > 0`\n\n **n = n - 1**\n";
let (result, _) = run_and_output(source, "倒计时");
assert_eq!(result.unwrap(), Value::Unit);
assert_eq!(output, "3\n2\n1\n");
}
#[test]
@@ -117,14 +116,14 @@ fn function_reference_can_be_called() {
#[test]
fn non_bool_condition_is_a_runtime_error() {
let source = "## f\n\n**x = 1**\n\n- `x`\n\n > 打印(1)\n\n*x*\n";
let source = "## f\n\n**x = 1**\n\n- `x`\n\n **x = x + 1**\n\n*x*\n";
let error = run_named(source, "f", &[]).unwrap_err();
assert_eq!(error.code(), "runtime.type");
}
#[test]
fn fuel_budget_is_enforced() {
let program = build("## f\n\n- `true`\n\n > 打印(1)\n\n*0*\n");
let program = build("## f\n\n- `true`\n\n **x = 1**\n\n*0*\n");
let mut host = StdHost::new(
SandboxMode::Project,
Capabilities::pure(),
@@ -171,6 +170,18 @@ fn ambiguous_ref_resource_is_an_error() {
assert_eq!(error.code(), "ref.ambiguous");
}
#[test]
fn print_without_the_bundled_stdlib_is_a_structured_error() {
let source = "## f\n\n> 打印(1)\n\n*None*\n";
let error = run_named(source, "f", &[]).unwrap_err();
assert_eq!(error.code(), "kernel.unavailable");
assert!(
error.message.contains("bundled stdlib"),
"unexpected message: {}",
error.message
);
}
#[test]
fn function_ref_and_resource_members_are_readable() {
let source = "## 目标\n\n*1*\n\n## main\n\n### 公式\n\n$$a = 1$$\n\n### 代码\n\n```text\nx\n```\n\n**f = ref(\"#目标\")**\n\n**g = ref(\"#公式\")**\n\n**c = ref(\"#代码\")**\n\n*[f.module, f.name, g.latex, g.display, c.language, c.source]*\n";
@@ -198,7 +209,7 @@ fn memory_region_is_shared_by_handle_identity() {
#[test]
fn memory_handle_cannot_reach_the_host_boundary() {
let source = "## f\n\n**m = memory.new(1, 1)**\n\n> 打印(m)\n\n*0*\n";
let source = "## f\n\n**m = memory.new(1, 1)**\n\n> fs.read(m)\n\n*0*\n";
let error = run_named(source, "f", &[]).unwrap_err();
assert_eq!(error.code(), "runtime.type");
assert!(
+7 -1
View File
@@ -123,6 +123,9 @@ This is still a **local VM lane**, not a self-hosted GitHub Actions security URL
(`format.显示` → UTF-8 encode → `Memory` → `resource.write(stdout)`) matches
builtin `打印` for the covered value set; builtin remains default and no
alias is routed.
- Compat-C print completion (ADR-0031): `HostOp::Print`/`op_print` removed;
the print builtin only routes to bundled `io.写值` or fails with
`kernel.unavailable`; trace has resource effects only.
- Compat-B print routing (ADR-0030): `Program.print_override` routes
`打印/print` to the bundled `io.写值` when the program uses it; stdlib
modules are injected lazily; resource operations are trace `effect` events
@@ -182,7 +185,7 @@ behavior. This table records only what is in this tree now.
| P0 freeze (ADRs, spec deltas, baseline) | **P1 + partial P2 slice done** | ADR-0022 freezes CM-A01/CM-A02/CM-A03; ADR-0023 freezes CM-A04 (minimal List/Map/Text/Table observation and construction); ADR-0024 freezes CM-A05 (recoverable `Result` map convention); `spec/expression.ebnf`, `spec/evaluation.md`, `spec/value-wire.md`, `spec/analysis-v2.md`, `spec/security.md` updated; existing AST/value goldens unchanged |
| P1 Memory + place assignment | **Implemented locally** | `Value::Memory`, run-scoped `MemoryStore` (64 KiB pages, 64 MiB total / 16 MiB region), `memory.new/size/grow`, `m[i]` read, `m[i] = byte`; semantic fixtures 45–47, runtime negatives 13–18, `examples/memory-buffer.mq.md`; evidence [`evidence/2026-11-20-memory-p1.md`](evidence/2026-11-20-memory-p1.md) |
| P2 Marqdo-written allocator/data structures + minimal structure observation | **PARTIAL, gate NOT passed** | `.mq.md`-only evidence: bump allocator with u32 codec, linked list, failed-allocation atomicity (48–50); CM-A04 structure primitives and a table filter (51–54, ADR-0023); a first-fit free-list allocator with block reuse, splitting, address-adjacent coalescing and `Result` maps (55, ADR-0024), a `Memory`-backed binary tree with recursive insert/in-order traversal (56), a `.mq.md` CSV row splitter (57), an open-addressing hash table with linear probing, update and `hash.full` (58), a `.mq.md` UTF-8 encoder over `Memory` (59), a validating UTF-8 decoder rejecting truncated, bad-continuation and surrogate/overlong input (60), a `Memory`-backed graph adjacency list (61), a recursive JSON parser for nested arrays/objects, strings with escapes, integers, booleans, null and error Results (62), a `Memory`-backed stack bytecode VM with PUSH/ADD/MUL/JMP/JZ/HALT (63), big-endian 16/32/64-bit plus LEB128 integer codecs (64), a `.mq.md` table sort rebuilding a new table from `table.row/columns/cell` (65), a table join (67), a quoted/escaped CSV row parser (68), table group (69), and an Int matrix multiply (70); the first-fit allocator also detects double free (`alloc.double_free`). Evidence: [`memory-p2-closure`](evidence/2026-11-20-memory-p2-closure.md), [`structure-api-p2`](evidence/2026-11-20-structure-api-p2.md), [`result-and-free-list-p2`](evidence/2026-11-20-result-and-free-list-p2.md). P2 remaining: publication as a separate external stdlib repository. The bundled `stdlib/` tree, `std:` imports, digest verification, Analysis identity and frozen-CLI closure test are implemented (ADR-0028). C01–C06/C11/C12 each have `.mq.md` evidence, including JSON floats and a JSON formatter. |
| P3 Resource/Stream ABI | **PARTIAL** | ADR-0025/0026 CM-A06 slices: opaque `Resource`, `resource.open/read/write/close`, stdout write in pure/project, granted project-file read and buffered project-file write in project, EOF/closed/handle errors, wire/host rejection; strict permits only stdio/stdout and refuses file/network resources. Fixture 66 + CLI/host tests. CM-A07 **Compat-B** is implemented: when a program calls `打印/print`, the loader injects the bundled `stdlib/io.mq.md` and the runtime routes to `io.写值`, which formats all 15 value types, UTF-8-encodes via `Memory` and writes via `resource.write(stdout)`; legacy `HostOp::Print` is only a no-bundle fallback. Strict permits only the existing stdio console channel. Still missing: Compat-C, directories, network, generic provider registry. |
| P3 Resource/Stream ABI | **PARTIAL** | ADR-0025/0026 CM-A06 slices: opaque `Resource`, `resource.open/read/write/close`, stdout write in pure/project, granted project-file read and buffered project-file write in project, EOF/closed/handle errors, wire/host rejection; strict permits only stdio/stdout and refuses file/network resources. Fixture 66 + CLI/host tests. CM-A07 **Compat-C** is implemented: when a program calls `打印/print`, the loader injects the bundled `stdlib/io.mq.md` and the runtime routes to `io.写值` (all 15 value types, UTF-8 via `Memory`, `resource.write(stdout)`); `HostOp::Print` and the legacy `Value::display()` print path are removed, and a missing bundle fails with `kernel.unavailable`. Strict permits only the existing stdio console channel. Still missing: directories, network, generic provider registry, Table storage, strict file/network resources. |
| P4 Table logical/physical migration | **NOT IMPLEMENTED** | `Value::Table` remains `Vec<Vec<Value>>`; no stdlib table algorithms |
| P5 third-party Provider / TCP / HTTP | **NOT IMPLEMENTED** | `fs.write`, `net.request`, `process`, `clock`, `random` remain unavailable broker services (see §4) |
| P6 performance / native backends | **NOT IMPLEMENTED** | no bytecode/JIT/GPU/QPU work |
@@ -216,6 +219,9 @@ user-written allocator is explicitly **not** claimed.
- [`evidence/2026-11-20-print-compat-b.md`](evidence/2026-11-20-print-compat-b.md)
— ADR-0030 Compat-B print routing, trace resource effects, lazy stdlib
injection and strict stdio console permission.
- [`evidence/2026-11-20-print-compat-c.md`](evidence/2026-11-20-print-compat-c.md)
— ADR-0031 removal of `HostOp::Print`, no-bundle fail-closed behavior and
embedder compatibility note.
- [`evidence/RELEASE_CANDIDATE_0.1.0_8af7262.md`](evidence/RELEASE_CANDIDATE_0.1.0_8af7262.md)
— G0..G12 matrix and RC decision.
- [`security-gate.md`](security-gate.md) — mechanism, attack matrix and strict
+2 -2
View File
@@ -77,8 +77,8 @@ resource ABI, not a new OS capability. File resources stay fail-closed.
The human-readable `checked N module(s)` count excludes stdlib modules so
bundle internals do not change the project count.
* Compat-C (removing `HostOp::Print` and `Value::display()` formatting from the
public builtin) is **not** part of this ADR. The legacy path remains the
fallback when no bundle exists.
public builtin) is **not** part of this ADR; it is implemented by ADR-0031,
which supersedes the "legacy fallback" sentence above.
## Non-goals
@@ -0,0 +1,95 @@
# ADR-0031: Compat-C — remove `HostOp::Print` and the legacy formatting path
Status: **Accepted**
Date: 2026-11-20
Relates to: `docs/MARQDO_COMPUTE_CORE_STDLIB_MIGRATION_RFC_0002.md`
(CM-A07, P3), ADR-0027, ADR-0029, ADR-0030
Specs: `spec/evaluation.md`, `spec/security.md`
Evidence: `docs/evidence/2026-11-20-print-compat-c.md`
## Context
Compat-A produced a stdlib print chain; Compat-B (ADR-0030) routed
`打印/print` to the bundled `io.写值` and proved output parity for all 15 value
types. The legacy path (`HostOp::Print` → `Value::display()` → output buffer)
remained as a no-bundle fallback and a comparison reference. Compat-C removes
the **public builtin formatting path** so a print call can no longer silently
fall back to a Rust formatter.
## Decision
### 1. Remove the host operation
* `HostOp::Print` and `StdHost::op_print` are deleted. There is no host
operation that formats a value.
* `打印/print` remains a **builtin name** for static arity validation and
compatibility diagnostics. Its implementation no longer writes anything; if
the runtime reaches it (no `Program.print_override`), it returns the
structured `kernel.unavailable` error:
"打印 requires the bundled stdlib print module; install the official CLI
bundle."
* The official CLI ships the verified bundle, so a print-using program always
loads `stdlib/io.mq.md`, sets `print_override`, and executes `io.写值`.
A CLI installed without `stdlib/` cannot print; that layout is not official.
### 2. Formatting ownership
All print formatting, UTF-8 encoding and byte output now live in `.mq.md`:
```text
打印(value)
-> stdlib/io.写值
-> stdlib/format.显示
-> stdlib/text.utf8编码
-> resource.open("stdio","stdout",["write"])
-> resource.write
-> resource.close
```
`Value::display()` still exists for CLI result rendering (`call --json`,
diagnostics), but it is **not** reachable from the print builtin. No `HostOp`
accepts a value for display.
### 3. Trace and budgets
Print produces only resource effects (`resource.open/write/close`) and stdlib
semantic events. There is no `print` effect. Output budget and console grant
are enforced at the resource/stdio boundary exactly as before.
### 4. Compatibility
* All semantic goldens, CLI print tests and the full-value formatting demo pass
unchanged.
* The runtime embedding API (`marqdo_runtime::run`) no longer prints unless the
caller installs a `Program.print_override`; a direct runtime program that
calls `打印` gets the structured no-bundle error. This is a **breaking change
for embedders** and is recorded here; the CLI loader maintains the official
behavior.
* `callable.rs` still advertises the builtin name for diagnostics and arity;
this is not a second implementation.
* Compat-A/B evidence remains as history; its "legacy fallback" wording is
superseded by this ADR.
### 5. Non-goals
* Removing the `打印/print` builtin name, alias, or arity validation.
* Removing `Value::display()` for CLI result output, diagnostics or format
helpers.
* Supporting print without the bundle; no implicit formatting fallback.
* Changing Resource ABI, strict mode or stdlib version.
## Consequences
* It is now impossible for `打印` to execute a hidden Rust formatter; the only
print implementation on an official installation is `.mq.md`.
* Embedders that build a `Program` directly must load the stdlib print module
and set `print_override` (the semantic test harness does this).
* Trace consumers see resource effects, not a print effect.
* A missing/corrupt bundle fails closed for print instead of silently using a
different implementation.
## Verification
`docs/evidence/2026-11-20-print-compat-c.md` records: no `HostOp::Print` or
`op_print` references; the no-bundle structured error; trace still shows
resource effects; all 419 tests and the full-value demo pass.
+2 -1
View File
@@ -27,7 +27,8 @@ implementation status lives in `docs/STATUS.md`; frozen behavior is in
| CM-A10 bundled stdlib / `std:` imports / digest | [0028](../adr/0028-bundled-stdlib-and-std-imports.md) | Accepted (first slice) |
| Full-value stdlib formatting / FunctionRef+PluginHandle observation | [0029](../adr/0029-full-value-formatting-and-handle-observation.md) | Accepted |
| CM-A07 Compat-B print routing | [0030](../adr/0030-print-compat-b-routing.md) | Accepted |
| CM-A07 Compat-C, Table storage, generic providers, strict file/network resources | — | Not decided; do not implement by implication |
| CM-A07 Compat-C remove legacy print formatting | [0031](../adr/0031-print-compat-c-remove-host-formatting.md) | Accepted |
| Table storage, generic providers, strict file/network resources | — | Not decided; do not implement by implication |
## What a future phase must not do
@@ -0,0 +1,75 @@
# RFC-CM CM-A07 Compat-C evidence: legacy print formatting removed
Date: 2026-11-20 (Asia/Shanghai)
Repository: `marqdo-cli`
Baseline: `e26971f` plus this step's changes.
Decision record: [ADR-0031](../adr/0031-print-compat-c-remove-host-formatting.md)
Related: [Compat-A](2026-11-20-stdlib-print-compat-a.md),
[Compat-B](2026-11-20-print-compat-b.md),
[full-value formatting](2026-11-20-full-value-formatting.md).
Scope: Compat-C removal of the public host formatting path.
## Environment and gate
Ubuntu 26.04 development container, Linux x86_64, Rust 1.100.0.
```text
cargo fmt --all -- --check PASS
cargo clippy --workspace --all-targets -- -D warnings PASS
cargo test --workspace --locked PASS
419 passed, 0 failed, 2 ignored (existing plugin-sdk doc-tests)
```
No GitHub CI is available from this checkout; this is local evidence.
## Removed
* `HostOp::Print` variant, its stable op name and `StdHost::op_print`.
* The print builtin's host dispatch. `打印/print` remains a builtin **name**
for arity validation, but it no longer formats or writes:
* with `Program.print_override` set (official CLI + bundle), the runtime calls
`stdlib/io.写值`;
* without an override, it returns `kernel.unavailable`:
"打印 requires the bundled stdlib print module; install the official CLI
bundle."
`Value::display()` remains for CLI result rendering/diagnostics but is not
reachable from the print builtin.
## Runtime/embedder behavior
`crates/marqdo-runtime/tests/interpreter.rs::print_without_the_bundled_stdlib_is_a_structured_error`
builds a Program without an override and asserts the structured error.
The semantic conformance harness builds Programs directly, so it now mirrors
the loader's Compat-B injection: it loads `stdlib/io.mq.md` (with
`format`/`text`), adds import edges and sets `print_override`. Existing print
fixtures 22/23/30/42 pass byte-identically.
## Trace and output
`crates/cli/tests/print_routing.rs` still asserts a print program's trace
contains `resource.write` and no `print` effect. The CLI loader routes official
runs through stdlib; `打印` output remains byte-identical, including the
full-value Formula/Code/FunctionRef demo.
## Compatibility notes
* Breaking for embedders that call `打印` without installing the stdlib print
module; the official CLI loader does this automatically.
* `HostOp` loses a variant; any external exhaustive match must be updated.
This is pre-1.0 and recorded in ADR-0031.
* No bundle means no print; this is fail-closed rather than a silent formatter.
* Compat-A/B evidence remains historical; their fallback wording is superseded.
## Reproduce
```bash
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 test -p marqdo-runtime --test interpreter print_without
cargo test -p marqdo-cli --test print_routing
cargo test -p marqdo-cli --test conformance_semantics
cargo test --workspace --locked
```
+9 -8
View File
@@ -257,7 +257,7 @@ host boundary. Names are stable; adding one requires a spec update.
| Name | Signature | Notes |
|---|---|---|
| `打印` / `print` | `(x) -> Unit` | writes `Value::display()` + newline to stdout |
| `打印` / `print` | `(x) -> Unit` | Compat-C: routed to bundled `io.写值`; no `HostOp` formatting path. Without the bundle, `kernel.unavailable` |
| `长度` / `len` | `(x) -> Int` | Text scalar count, List/Map/Table size |
| `类型` / `type` | `(x) -> Text` | value type name |
| `文本` / `str` | `(x) -> Text` | explicit conversion |
@@ -288,13 +288,14 @@ host boundary. Names are stable; adding one requires a spec update.
| `foreign.run/call` | see `spec/foreign.md` | P5, capability-gated |
| `fs.read/write` | see `spec/security.md` | capability-gated |
`打印/print` is **Compat-B** (ADR-0030): when the verified bundled stdlib is
available and a loaded module calls the builtin, the loader injects
`stdlib/io.mq.md` and sets a program-level `print_override`; the runtime calls
`io.写值` instead of `HostOp::Print`. The stdlib chain formats every one of the
15 value types, encodes UTF-8 into `Memory`, and writes via
`resource.write(stdout)`. The legacy builtin remains the fallback when no bundle
is available. Compat-C (removing the legacy formatting path) is not done.
`打印/print` is **Compat-C** (ADR-0031): the legacy `HostOp::Print` and its
`Value::display()` formatting path are removed. When a loaded module calls the
builtin, the loader injects `stdlib/io.mq.md` and sets a program-level
`print_override`; the runtime calls `io.写值`. The stdlib chain formats every
one of the 15 value types, encodes UTF-8 into `Memory`, and writes via
`resource.write(stdout)`. If the official bundle is unavailable, the builtin
returns a structured `kernel.unavailable` error; there is no silent formatting
fallback. The builtin name remains for arity validation and diagnostics.
The `list.*`, `map.*`, `text.*` and `table.*` entries are observation and
construction primitives, not algorithms (ADR-0023). They return new values and
+1 -1
View File
@@ -55,7 +55,7 @@ set for one run:
| Field | Default (`pure`/`project`) | Used by |
|---|---|---|
| `console: bool` | `true` | `op_print` and `resource.open("stdio","stdout",["write"])`; a missing grant is `permission.denied` and output is also bounded by the output budget |
| `console: bool` | `true` | `resource.open("stdio","stdout",["write"])` and the stdlib print chain; a missing grant is `permission.denied` and output is also bounded by the output budget |
| `math: bool` | `true` | `math.*` host ops |
| `fs_read: Vec<String>` | empty | `fs.read` and project `resource.open("file", path, ["read"])` |
| `fs_write: Vec<String>` | empty | `fs.write` and project `resource.open("file", path, ["write"])` |
+5
View File
@@ -171,6 +171,11 @@ by:
* fixture 55 additionally has a second-free detection path: freeing an
already-free block returns `{ok:false, code:"alloc.double_free"}`.
RFC-CM CM-A07 Compat-C (ADR-0031) is pinned by
`crates/marqdo-runtime/tests/interpreter.rs::print_without_the_bundled_stdlib_is_a_structured_error`
and the absence of any `HostOp::Print`/`op_print` reference. The semantic
harness mirrors the loader's stdlib injection for direct-runtime fixtures.
RFC-CM CM-A07 Compat-B (ADR-0030) is pinned by
`crates/cli/tests/print_routing.rs`: