fix(access): verify subscription readiness with real user keys

When subscription access is requested with an explicit access_api_key, assign the subscription to the real target user, bind that user's API key to the subscription group, and probe readiness with the same key instead of falling back to a managed synthetic user.

Update the runtime/reconcile flows, adapter tests, and source-of-truth docs so subscription_ready now reflects user-visible host access rather than managed-key-only closure success.
This commit is contained in:
phamnazage-jpg
2026-06-01 09:55:11 +08:00
parent 702ae19a61
commit c588a95c7d
11 changed files with 260 additions and 24 deletions

View File

@@ -8,6 +8,37 @@
- 当前主目录 `artifacts/real-host-acceptance/` 已只保留最终证据;历史调试样本已迁到 `artifacts/real-host-acceptance-archive/`
- access ready 语义已经收口为:`/v1/models` 命中 `smoke_test_model`,且最小 `POST /v1/chat/completions` smoke 成功;不会再出现 models-only 假 ready
- 2026-06-01 已继续收掉 `subscription_ready` 的最后一个真实闭环缺口:
- 根因不是 provider、不是前端也不是宿主随机波动而是 CRM 旧实现会在 subscription closure 里把目标用户替换成 synthetic managed user再用 managed key 做 probe
- 这样会出现“closure 返回 `subscription_ready`,但目标用户自己的 `GET /api/v1/subscriptions/active` 仍为空,`/v1/models` 仍然 `403 INSUFFICIENT_BALANCE`”的假阳性
- 最新本机真实验收已确认修复后的语义:
- 页面级 artifact`artifacts/provider-admin-matrix/1780271169_provider_admin_actions/99-summary.json`
- batch 明细:`GET /api/import-batches/5`
- `access_closure.DetailsJSON` 已切成 `effective_probe_key_source=requested_probe_api_key`
- 目标用户 `GET /api/v1/subscriptions/active` 已返回 active subscription
- 目标用户 `GET /api/v1/groups/available` 已出现 `OpenAI 中转默认分组-subscription`
- 目标用户自己的 `local-user-api-key-20260531` 直探 `/v1/models``/v1/chat/completions` 均已回到 `HTTP 200`
- 2026-06-01 已把 `self_service` 的真实前置条件正式写死:
- `self_service` 不会自动为目标用户充值
- 如果目标用户 key 有效但余额不足,宿主会直接返回 `INSUFFICIENT_BALANCE`
- 所以 `self_service_ready` 的真实验收前提仍然必须包含“用户余额已满足最小调用成本”
- 2026-05-31 已继续把 `providers.html` 的页面内显式动作收口成独立 acceptance 入口:
- 新增脚本:`scripts/acceptance/verify_provider_admin_actions.sh`
- 覆盖范围:
- `GET /api/packs`
- `GET /api/hosts`
- `GET /api/packs/{pack_id}/providers`
- `POST /api/providers/{provider_id}/preview-import`
- `POST /api/providers/{provider_id}/import`
- `POST /api/provider-drafts`
- `PUT /api/provider-drafts/{draft_id}`
- `DELETE /api/provider-drafts/{draft_id}`
- `POST /api/provider-drafts/{draft_id}/publish`
- 同轮已补本地伪远端回归:
- `scripts/test/test_real_host_scripts.sh`
- 当前结论:
- `providers.html` 不再只有动作级审计矩阵,页面内显式动作已经有可重复执行的 acceptance 入口
- `rollback / reconcile / status / import-batches` 仍不属于这页当前显式 UI 能力
- `subscription` 主链路已通过 latest fresh-host 复验:
- MiniMax 53hk`artifacts/real-host-acceptance/20260521_191418_remote43_minimax_key_import/21-summary.json`
- DeepSeek 2166`artifacts/real-host-acceptance/20260521_201509_remote43_deepseek_key_import/21-summary.json`