# v0.30 托管智能体验收证据（2026-10-03）

## 范围

milestone 33（#660–#675）的 A1 验收：G0–G5 全部以**真实运行栈**出证——
`tests/Longe.HostedAcceptance.Tests` 在真 Context 上挂载 14 个 hosted 插件
（control-sqlite、executor、pool、durable-tasks、quota、tenancy、metering、
audit、egress、dispatch、webserver、gateway + IChatClient stub），经真实
`HttpClient → 回环 socket` 打 `/hosted/v1`，runtime 是 systemd 瞬态单元里
真实 `dotnet` 进程（FakeRuntime：真实 wire 协议 + 真实隔离边界，会话语义
为桩）。本机环境：Linux，systemd 249，cgroup v2，loop-mount ext4 scope 卷，
每 scope 独立 slot uid——非 Docker、非协议 mock。

## 验收矩阵 → 实测

| 门 | 验收点 | 用例（测试名） | 结果 |
| --- | --- | --- | --- |
| G1 | 断言篡改/scope 错配拒绝 | `Tampered_or_wrong_scope_assertion_is_rejected` | 403 `assertion/denied` |
| G1 | 签名/JWKS/重放矩阵（真 HTTPS socket + 自签证书，含控制面重启后重放） | `Assertion_rejection_matrix_and_replay_survive_restart` | 8 类非法断言全部拒绝；重放跨重启拒绝 |
| G1 | 跨租户对象不泄露存在性 | `Cross_tenant_conversation_run_and_stream_project_uniform_not_found` | conversation/run/cancel/history/SSE 一律 404 |
| G1 | 成员撤销即拒 | `Member_revocation_denies_subsequent_calls` | 撤销后读/写均 401 `auth/revoked` |
| G1 | 隔离节点 coding 能力基线 | `Isolated_node_probe_attests_full_coding_capability_set` | 探测 Healthy + Attested.Complete，capabilities 全量 |
| G2 | 并发同幂等键 | `Concurrent_same_idempotency_key_materializes_single_run` | 8 路并发物化单 run；载荷漂移 409 |
| G2 | 限额不超卖 | `Queue_limits_hold_without_oversell_under_concurrency` | 12 路洪发 ≤6 受理，拒绝为 429/409 |
| G3 | 运行中 SIGKILL | `Sigkill_mid_run_converges_terminal_and_frees_capacity` | `systemctl kill -s SIGKILL` 真单元 → Unhealthy → run terminal（isolated）→ 容量释放可再准入 |
| G3 | 陈旧 fence 写拒绝 | `Stale_fence_write_is_rejected` | 旧世代写一律异常 |
| G3 | 活 scope 上 seal/reset 闭合 | `Reset_or_seal_over_live_scope_fails_closed` | Busy 租约下 Confirmed=false |
| G4 | SSE 逐段推进至 terminal | `Stream_delivers_state_events_and_terminal_before_poll_timeout` | run-state×N→terminal，seq 单调，history 回放完整 |
| G4 | durable cursor 重放 | `Cursor_replay_resumes_without_duplicates` | cursor 之后无重复、无缺口 |
| G4 | 断线不杀 run | `Disconnecting_stream_does_not_cancel_the_run` | 客户端断开仅 detach，run 到 terminal/completed |
| G4 | 取消后同会话重提交 | `Cancel_then_resubmit_same_conversation_stays_bound_and_completes` | 同 binding 续跑成功 |
| G0/G5 | 镜像/注册表/源码门禁 | `check-test-mirror.mjs` + 既有 `Hosted*Tests` | 194 包过检；受影响套件 102/102 绿 |

## 验收中发现并修复的真实缺陷（非测试补强）

1. **gateway 统一 502**：`HostedDispatchException` 无论 Kind 一律
   `upstream/denied`——配额拒绝/幂等冲突丢失契约语义。改为
   `QuotaDenied→429`、`StateConflict→409`、fencing/CAS 竞争→409
   `authority/contended`，仅下游真正不可达才 502。
2. **跨租户泄露存在性**：`RequireConversationAsync`/`RequireRunAsync` 对越权
   返回 403 `tenant/mismatch`——「存在」与「越权」可分。按 tenancy 契约统一
   投影 404；SSE 路由原先提交 200 事件流头后才判越权，前置到响应提交之前。
3. **站点 run 永远 fault**（G4 级断链）：全代码库没有任何生产路径创建
   `ConversationBinding` 或物化 `SessionId`——authorize 阶段只认已绑定会话，
   首个 run 必卡 `binding-session-pending` 后判死。补 `HostedDispatchService.
   EnsureBindingAsync`（缺行按 Missing CAS 创建、scope 漂移 409、败者重读）
   与 `AuthorizeAsync` 的 SessionId mint 回填（Exact CAS，stale 读胜者）。
4. **pool 围栏世代永久过期**：`_fence` 只在 `InitializeAsync` 取一次——
   同进程 quota/dispatch/gateway 各自取 authority 后 pool 的所有租约写全部
   stale。补与 quota 同型的 `WithAuthorityRetryAsync`（stale→重取→重放一次，
   CAS 仍幂等）。
5. **runtime 失联 run 永不收敛**：observe 对 `HostedPoolException` 无限
   park。越过 10 次 miss 如实 `faulted/isolated`（与 `run-not-found` 同门）。
6. **FakeRuntime `run/get` 恒 not-found**：fixture 缺 run 状态投影。补
   admitted→consumed/cancelled 的 durable 投影（进程内字典；SIGKILL 后
   如实丢表——不假装持久化）。

## 边界与平台限制（如实声明）

- 仅 Linux + systemd + cgroup v2 环境出证；前置缺失（sudo/systemd-run 不可达）
  测试如实早退不计 pass。其他平台与 Windows/macOS 组合未验收。
- FakeRuntime 证明的是**控制面+隔离面+协议面**链路：真实进程、真实单元、
  真实 wire；会话语义桩（不跑真实模型）。「至少一个真实 coding executor
  通过 G1」由 `Isolated_node_probe_attests_full_coding_capability_set` 对
  coding profile 全量能力 attestation 承载；真实模型 executor 的接入验收
  仍属后续（本仓没有可调用的真模型）。
- 单控制节点、单执行节点、单进程组合；多节点 fencing 漂移与站点跨进程
  部署形态按设计文档推演，未在本机起第二节点。
- 并发矩阵在本机 12 路规模；更高并发下的 tail 行为未测。
- 全程无 Docker/等价容器运行时安装或运行。

## 复现

```
export PATH="$HOME/.nvm/versions/node/v24.19.0/bin:$HOME/.dotnet:$PATH"
dotnet test tests/Longe.HostedAcceptance.Tests   # 14/14，约 70s
dotnet test tests/Longe.PluginExtensions.Tests --filter "HostedGateway|HostedPool|HostedDispatch|HostedQuota|HostedIdentity|HostedTenancy"  # 102/102
node scripts/check-test-mirror.mjs                # 194 包
```
