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:
1 parent
e119727c5d
commit
e26971f489
21 files changed
+560
-36
No files matched your search
@@ -54,13 +54,25 @@ fn stdout_write_obeys_the_output_budget_atomically() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn strict_mode_refuses_every_resource_open() {
|
||||
fn strict_mode_allows_only_the_existing_stdio_console_channel() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let mut host = StdHost::new(SandboxMode::Strict, Capabilities::pure(), dir.path());
|
||||
let error = host
|
||||
.resource_open("stdio", "stdout", &["write".to_string()], &context())
|
||||
let ctx = context();
|
||||
let handle = handle(
|
||||
host.resource_open("stdio", "stdout", &["write".to_string()], &ctx)
|
||||
.unwrap(),
|
||||
);
|
||||
assert_eq!(host.resource_write(handle, b"strict", &ctx).unwrap(), 6);
|
||||
assert_eq!(host.take_output(), b"strict");
|
||||
|
||||
let file = host
|
||||
.resource_open("file", "a.txt", &["read".to_string()], &ctx)
|
||||
.unwrap_err();
|
||||
assert_eq!(error.category, ErrorCategory::PermissionDenied);
|
||||
assert_eq!(file.category, ErrorCategory::PermissionDenied);
|
||||
let socket = host
|
||||
.resource_open("socket", "example.test", &["read".to_string()], &ctx)
|
||||
.unwrap_err();
|
||||
assert_eq!(socket.category, ErrorCategory::PermissionDenied);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user