⚠️ HISTORICAL SNAPSHOT — annotation added 2026-09-24 (task #122, following the #109 audit)
This is a point-in-time test-verification snapshot; all test results, commands, and output are preserved verbatim and untouched. The old CLI name
sbox(and~/.sbox/, old brandserverless-sandbox) shown here reflects the state at that time and is nowabx/agent-sandbox; see ADR2026-09-09-brand-rename-sbox-to-abx.md. For current state, rely on the latestverify/reports,AGENTS.md, anddocs/.
Server Framework Refactoring — Full Test Suite Verification
Date: 2026-09-08
Scope: PR #114–#119 server 框架重构全量验证
Runtime: Python 3.11.15, pytest 9.1.1, macOS darwin 15.7.7
Overall Summary
| Metric | Value |
|---|---|
| Total Tests | 1550 |
| Passed | 1539 |
| Failed | 11 |
| Errors | 0 |
| Warnings | 61 (RuntimeWarning: coroutine never awaited — mock related) |
| Duration | ~20s |
| Overall | ⚠️ CONDITIONAL PASS |
11 failures 全部为 golden-file evidence 快照过期 (10) + CLI root exit-code 断言 (1)。
核心 SDK 逻辑 0 failure。
Module Breakdown
| Module | Tests | Passed | Failed | Status |
|---|---|---|---|---|
| test_server/ | 30 | 30 | 0 | ✅ PASS |
| test_declarative/ | 116 | 116 | 0 | ✅ PASS |
| test_templates/ | 407 | 407 | 0 | ✅ PASS |
| test_api/ | 243 | 243 | 0 | ✅ PASS |
| test_models/ | 96 | 96 | 0 | ✅ PASS |
| test_transport/ | 109 | 109 | 0 | ✅ PASS |
| test_protocol/ | 97 | 97 | 0 | ✅ PASS |
| test_agent/ | 105 | 105 | 0 | ✅ PASS |
| test_utils/ | 66 | 66 | 0 | ✅ PASS |
| test_cli/ | 141 | 140 | 1 | ⚠️ FAIL |
| test_cli_evidence/ | 77 | 67 | 10 | ⚠️ FAIL |
| test_integrations/ | 13 | 13 | 0 | ✅ PASS |
| test_extensions/ | 9 | 9 | 0 | ✅ PASS |
| test_session/ | 21 | 21 | 0 | ✅ PASS |
| test_compat/ | 0 | — | — | ⏭️ SKIP (no tests) |
Import Checks
| Check | Result | Output |
|---|---|---|
serverless_sandbox.sandbox type |
✅ PASS | <class 'serverless_sandbox.declarative.decorator._SandboxFactory'> |
sandbox.server exists |
✅ PASS | True |
sandbox.register exists |
✅ PASS | True |
from serverless_sandbox.server import SandboxServer, start |
✅ PASS | server OK |
Lint (ruff)
| Metric | Value |
|---|---|
| Status | ⚠️ 343 errors (184 auto-fixable) |
| Top categories | F841 (unused var) ×75, F401 (unused import) ×67, N815 (camelCase) ×31, ANN (annotations) ×24, TC003 (typing-only) ×14, N806 ×10 |
大部分为 style/convention 类问题 (unused imports, camelCase field names, type annotations)。
无语法错误或逻辑错误。
Type Check (mypy)
| Metric | Value |
|---|---|
| Status | ⚠️ 120 errors in 32 files (78 files checked) |
| Top categories | union-attr (StreamReader/ProcessResult) ×~20, untyped-decorator (Click decorators) ×~12, no-untyped-def / arg-type ×misc |
主要来源:
1. Click decorator 导致函数签名 untyped
2.ProcessResult | StreamReader[ProcessChunk]union 需要 isinstance guard
3.import-not-foundfortomllib/tomli(3.10 compat shim)
无新增 mypy 错误与 server 模块直接相关。
Failed Tests Detail
1. test_cli/test_main.py::TestCLIRoot::test_no_args_shows_help
Root Cause: CLI root sbox 无参调用返回 exit_code=2 (Click 8.5 invoke_without_command 行为变更),测试断言 exit_code == 0。
assert 2 == 0
分类: CLI 行为断言过期 — Click 8.5 兼容修复引起的预期行为变更,需更新测试断言。
2–11. test_cli_evidence/test_evidence_snapshots.py — 10 golden-file 不匹配
| Case ID | Mismatch Pattern |
|---|---|
| config-get-unknown | 输出重复(stdout + stderr 均含错误信息) |
| create-env-invalid | 同上 |
| kill-no-id | 同上 |
| exec-nonzero | 同上 |
| run-unknown-command | 同上 |
| run-invalid-arg | 同上 |
| error-auth | 同上 |
| error-template-not-found | 同上 |
| error-quota | 同上 |
| error-timeout | 同上 |
Root Cause: CLI 错误输出格式变化 — 错误信息同时输出到 stdout 和 stderr,导致 format_result() 捕获到双份输出,与旧 golden file 不匹配。
修复: 运行 SBOX_UPDATE_EVIDENCE=1 pytest tests/test_cli_evidence/ 重新生成 golden files。
New Module: serverless_sandbox.server (30/30 ✅)
| Test Class | Tests | Status |
|---|---|---|
| TestHealthCheck | 2 | ✅ |
| TestListCommands | 2 | ✅ |
| TestRunCommand | 4 | ✅ |
| TestUploadDownload | 2 | ✅ |
| TestShell | 3 | ✅ |
| TestAuth | 4 | ✅ |
| TestBuiltinToggle | 5 | ✅ |
| TestSandboxServerClass | 3 | ✅ |
| TestEdgeCases | 5 | ✅ |
Decorator Rework: test_declarative (116/116 ✅)
覆盖: @sandbox.register, sandbox.server, ServerProxy, upload/download builtins, serializers。
Template Tests (407/407 ✅)
覆盖: 10 模板 YAML 校验、capability 声明、commands.py 存在性、ports 配置、catalog 交叉引用、README 文档一致性。
Recommended Actions
-
P0 — 更新 golden files:
bash SBOX_UPDATE_EVIDENCE=1 python -m pytest tests/test_cli_evidence/ -v -
P0 — 修复
test_no_args_shows_help:
更新断言为assert result.exit_code == 2或调整 CLI root 的invoke_without_command行为。 -
P1 — Lint 清理:
bash ruff check src/ tests/ --fix然后手动处理--unsafe-fixes类别。 -
P2 — mypy 清理:
添加isinstanceguards forProcessResult | StreamReaderunion 访问,补充 Click decorator type stubs。
Conclusion
Overall: ⚠️ CONDITIONAL PASS
核心 SDK 功能(server 模块、decorator 返工、模板、API、transport、protocol、agent、session)全部 0 failure。11 个失败均为 CLI 输出格式 / golden-file 快照过期,属于预期的重构副作用,可通过重新生成 evidence 和更新 1 个断言修复。无逻辑错误、无运行时异常、无导入失败。