feat(cli): route print through the bundled stdlib (Compat-B)

- Add Program.print_override and lazy stdlib injection: only programs that
  call 打印/print load std:io and route to io.写值 (ADR-0030).
- Record resource.open/read/write/close as trace effect events so the stdlib
  print path is auditable; HostOp::Print no longer runs on that path.
- Permit only stdio/stdout (existing console) in strict; file/network
  resource opens remain permission.denied.
- Exclude std: modules from the human-readable checked-module count; update
  the Python analysis consumer to accept std: instance ids.
- Add print-routing and strict-console tests, ADR-0030 and evidence.

Gate: fmt, clippy -D warnings, 418 tests passed.
This commit is contained in:
cflmy committed 2026-11-20 22:10:59 +08:00
1 parent e119727c5d
commit e26971f489
21 files changed
+560 -36

No files matched your search

+9 -1
View File
@@ -171,6 +171,13 @@ 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-B (ADR-0030) is pinned by
`crates/cli/tests/print_routing.rs`:
* a print program's trace contains `resource.write` and no `print` effect;
* stdlib modules are injected only for programs that call `打印/print`;
* all existing semantic/CLI print goldens still pass byte-identically.
RFC-CM CM-A10 bundled stdlib (ADR-0028) is pinned by
`crates/cli/tests/stdlib_bundle.rs` (6 tests):
@@ -192,7 +199,8 @@ RFC-CM CM-A07 Compat-A (ADR-0027) is pinned by:
* the demo covers Unit/None/Bool, Int, Float, Text, List, Map, Table,
Formula, Code and FunctionRef; PluginHandle formatting uses the same
observation members but needs a plugin to construct a value.
`打印` is not yet routed to the stdlib (Compat-B pending).
`打印` is routed to the stdlib by ADR-0030 Compat-B when the bundle is
present; this demo still calls the explicit `io.写值` to compare paths.
RFC-CM CM-A06 resource streams (ADR-0025) are pinned by:
+2 -1
View File
@@ -22,7 +22,8 @@ if not isinstance(project.get("root_id"), str) or not project["root_id"]:
functions = []
for module in analysis["modules"]:
if not module["id"].startswith("root:"):
module_id = module["id"]
if "::" not in module_id or not module_id.startswith(("root:", "dep:", "std:")):
raise SystemExit("unexpected module identity")
if not isinstance(module["source_digest"], str) or len(module["source_digest"]) != 64:
raise SystemExit("bad source digest")