Parent tracking issue: #2628
Related foundation: #2604
问题
anolisa system setup 和 anolisa system teardown 仍通过 Command::new("systemctl") 与本地 run_systemctl helper 直接执行 stop、daemon-reload、enable、start、restart 和 disable。它们绕过 #2604 已建立的 typed Systemd<CommandRunner> 边界,因此这些业务分支无法在不访问宿主机 systemd 的情况下做确定性测试。
teardown 还通过匹配 "not loaded" / "not found" 错误字符串判断服务是否已不存在,丢失了 spawn、non-zero exit 和 domain state 的区别。
实现边界
- 让
system setup/teardown 的服务生命周期调用经过现有 typed systemd 边界。
- 仅按本切片需要扩展
anolisa-platform::systemd::Systemd 的窄操作;production 继续使用真实 SystemCommandRunner。
- 为 setup/teardown 注入 fakeable backend,隔离验证调用顺序、参数和失败映射。
- 使用 typed evidence 判断 unit missing;production branching 不再解析 systemctl 错误文本。
- 保留 setup 初始 stop 的 best-effort 语义,以及 teardown 收集 warning 后继续清理的语义。
必须保持
- 不改变 setup 的 daemon-reload → enable → start/restart 顺序。
- 不改变 teardown 的 stop → disable → remove unit → daemon-reload → remove helper/config 顺序。
- 不改变 CLI 参数、human output、warning 文案、退出码、root 检查或 helper handshake。
- 不迁移 groupadd、usermod、chgrp、filesystem、socket、clock、UID、environment、telemetry、osbase 或 register 调用点。
- 不创建 service locator、通用 executor trait 或第二套 systemd adapter。
验收标准
commands/system.rs 的 setup/teardown 路径不再直接构造 Command::new("systemctl"),并删除本地字符串型 run_systemctl 分支。
- non-upgrade setup、upgrade setup 和 teardown 的 systemctl argv 与顺序保持不变。
- spawn failure、non-zero exit 和 missing unit 使用 typed evidence 区分。
- teardown 不再通过错误消息文本判断 missing unit,且单个 service failure 仍不会阻止后续文件清理。
- 新增隔离测试覆盖 setup 成功/失败、upgrade restart、teardown missing unit 和非 missing failure;测试不访问或修改宿主机真实 system service。
- anolisa Rust workspace 的 fmt、check、clippy、test 和 doc gates 通过。
验证计划
从 src/anolisa/ 运行:
cargo fmt --all -- --check
cargo check --locked
cargo clippy --all-targets --locked -- -D warnings
cargo test --locked
cargo doc --workspace --no-deps
同时运行新增的 system command 与 anolisa-platform::systemd focused tests,确认 fake runner 收到的 argv、调用顺序和 typed error 分类。
Parent tracking issue: #2628
Related foundation: #2604
问题
anolisa system setup和anolisa system teardown仍通过Command::new("systemctl")与本地run_systemctlhelper 直接执行 stop、daemon-reload、enable、start、restart 和 disable。它们绕过 #2604 已建立的 typedSystemd<CommandRunner>边界,因此这些业务分支无法在不访问宿主机 systemd 的情况下做确定性测试。teardown还通过匹配"not loaded"/"not found"错误字符串判断服务是否已不存在,丢失了 spawn、non-zero exit 和 domain state 的区别。实现边界
system setup/teardown的服务生命周期调用经过现有 typed systemd 边界。anolisa-platform::systemd::Systemd的窄操作;production 继续使用真实SystemCommandRunner。必须保持
验收标准
commands/system.rs的 setup/teardown 路径不再直接构造Command::new("systemctl"),并删除本地字符串型run_systemctl分支。验证计划
从
src/anolisa/运行:cargo fmt --all -- --check cargo check --locked cargo clippy --all-targets --locked -- -D warnings cargo test --locked cargo doc --workspace --no-deps同时运行新增的 system command 与
anolisa-platform::systemdfocused tests,确认 fake runner 收到的 argv、调用顺序和 typed error 分类。