mindspace: guard split-service contract drift

This commit is contained in:
john
2026-07-27 17:48:34 +08:00
parent 70264a4c4c
commit 40dcdaf49f
2 changed files with 160 additions and 0 deletions
@@ -156,6 +156,37 @@ scoped 模式下 `generate_docx` / `generate_long_image` 也不得在 RPC
---
## 1.5 Split-service 契约:版本、构建与生产闸门必须成套
### 必须保留
| 位置 | 行为 |
|------|------|
| `mindspace-server-adapter-contract.mjs` | `MINDSPACE_SERVER_ADAPTER_CONTRACT_VERSION`、required capabilities 与 required bindings 是 remote/local/RPC 的共享契约 |
| `mindspace-remote-server-adapter.mjs` | `assertReady()` 必须拉取 `/mindspace/v1/contract` 并校验版本、capability 与关键 method,失败时 Portal 启动 fail-fast |
| `server/portal-domain-services-bootstrap.mjs` | bootstrap 必须 `await mindSpaceRuntimeAdapter.assertReady?.()`,禁止把 contract mismatch 延迟到用户交付链路 |
| `mindspace-service/server.mjs` + `scripts/build-mindspace-service-runtime.mjs` | standalone runtime 必须写入并读取 `build-info.json`,让 `/health``/contract` 暴露 `buildId/gitSha/builtAt` |
| `scripts/release-mindspace-service-prod.sh` | 生产启动后必须校验 `/mindspace/v1/contract` 的版本、capability、关键 method 与 runtime manifest 的 `git_head` |
| `mindspace-storage-adapter.mjs` + `mindspace-service.mjs` | storage adapter 必须先通过版本化接口契约,后续 NAS/S3 adapter 不得绕过 facade |
| `scripts/audit-conversation-packages.mjs` + `scripts/trace-mindspace-artifact.mjs` | package/artifact 诊断必须保留 read-only 默认行为;`--repair` 只能补 `public_html` artifact 记录,不得改物理文件 |
这条边界保证 split-service 不会出现“Portal 已升级、MindSpace service
还是旧 runtime”的隐性半成功状态。旧契约必须在启动时被拒绝;生产
runtime 也必须和发布 manifest 的 git commit 对齐。
### 守卫
- 单测:`mindspace-remote-server-adapter.test.mjs`
`mindspace-service/mindspace-rpc-server.test.mjs`
`mindspace-storage-adapter.test.mjs`
`mindspace-conversation-package-audit.test.mjs`
- split smoke`npm run smoke:mindspace-split-service`
- 源码 + runtime 门禁:`npm run verify:mindspace-authority-boundary`
`npm run verify:mindspace-authority-boundary:full`
- 综合验证:`npm run verify:mindspace-publish-guards`
---
## 2. 聊天 Finish:禁止清空对话 / 禁止暴露内部前缀
### 症状