832dd756b9
feat(runner): add streaming execution path in docker.rs
...
run_in_container_stream: same container lifecycle + ContainerGuard
cleanup as run_in_container, but pushes output chunks to an mpsc
Sender as the log stream is read, instead of buffering until the
container exits. Also retains a full buffer for the caller to write
back to EXEC_TASKS (polling fallback path).
- OutputChunk enum: Stdout/Stderr/Done{exit_code,oom_killed,timed_out}
- client disconnect detection: tx.send fails → stops pushing but
continues draining the log stream so the container exits cleanly
- Done chunk carries terminal status for the SSE done event
- timeout/inspect/OOM logic identical to run_in_container
- run_in_container and its 4 tests left untouched
2026-07-10 11:41:37 +08:00
1584e01425
chore(deps): update all cargo and pnpm dependencies to latest versions
2026-07-09 18:12:54 +08:00
0ab3340133
fix(code-runner): allow exec on /tmp tmpfs for compiled languages
...
Docker tmpfs 挂载默认带 noexec,编译型语言(go/rust)把编译产物
落在 /tmp 后再 exec 会报 permission denied:
- rust: /tmp/main (run-rust.sh 的 rustc 输出)
- go: /tmp/go-build*/b001/exe/main (GOTMPDIR=/tmp 的链接器输出)
解释型语言(python/node)执行根文件系统里的解释器,不在 tmpfs 上,不受影响。
给 /tmp tmpfs 显式加 exec 选项。这是容器执行的固有需求——只要
沙箱支持任何编译型语言,/tmp 就必须可执行。安全模型由只读根文件系统 +
cap_drop=ALL + no-new-privileges + pids/memory/cpu 限制兜底,/tmp 可执行
不引入额外攻击面(容器内本就允许执行自身进程)。
2026-07-09 11:04:27 +08:00
a7a97fc299
fix(code-runner): 去掉 nproc ulimit,修复容器启动 EAGAIN
...
容器启动时报 'exec /bin/sh: resource temporarily unavailable',根因是
HostConfig 里的 ulimit nproc=64 与 non-root user(1000:1000) 组合:
RLIMIT_NPROC 按 UID 计数且在容器初始 exec 阶段就生效,与容器内实际进程数无关,
导致 sh 都起不来。pids_limit=64 已在 cgroup 层兜底进程数限制,nproc 是冗余且
有害的双重约束。
复现:docker run --ulimit nproc=64 --user 1000:1000 → exec 失败
去掉 nproc(保留 nofile + pids_limit + 其他沙箱约束)→ python/node 正常运行
cargo test infra::docker 全过。
2026-07-05 22:05:01 +08:00
f3eb93f320
docs(agents): document code runner and fix clippy/biome lint
...
文档:
- AGENTS.md 新增「Code Runner」架构章节(三层架构 + WASM 可见性规则 +
governor 0.8 无 per_day 的处理 + runner 镜像契约)
- Environment 段补齐 CODE_RUNNER_* 与 RATE_LIMIT_CODE_EXEC_* 环境变量
Lint 修复(clippy --all-targets --all-features -D warnings 全绿):
- runner.rs/runner.rs: use_signal 冗余闭包 → 直接传 fn
- runner_config.rs: &*RUNNER_CONFIG 去 deref;assert_eq!(...false/true) → assert!
- markdown.rs: 局部变量 /// 改 //;Option.map().flatten() → and_then
- languages.rs: 删除从未读取的 LanguageDef.name 字段(语言名即 map key)
- docker.rs: start_container if let Err → ?;timeout match → is_err();
嵌套 if 合并(修 task 2 遗留 + clippy 1.96 新 lint)
- pages/admin/posts.rs: use_signal 冗余闭包(预存 lint,顺带修绿)
- codemirror editor.ts: biome format 重排 setSchema 单行
2026-07-03 18:57:25 +08:00
5fdc88a48c
fix(runner): resolve task 2 container runner review findings
2026-07-03 18:02:56 +08:00
d8d30df80c
feat(infra): implement Docker execution layer using bollard client
2026-07-03 17:59:52 +08:00
2fba43dc3f
chore(infra): add bollard dependency and modular structure
2026-07-03 17:49:08 +08:00