P1 fix(test-isolation): docker 网络是第七种共享可变状态 —— 地址池耗尽会让所有 worker 的 pre-push 死掉
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- Avg merge
- 1h 7m
- Merged PRs (30d)
- 969
Description
## 现象:全机 docker 地址池被占满,`with-test-isolation` 起不了栈
```
all predefined address pools have been fully subnetted
```
pre-push 直接死在这里,**不是某个 agent 的问题,是全机资源被并发 agent 的残留占满**。
由 #521 / PR #524 的实现者报出(它被这条堵住),coord-chat-e2e 复核,**coord-main 已做临时清理**。
## coord-main 的处置(按铁律 8 走的顺序)
### ① 先跑只读巡检,**没有直接 `--apply`**
```
pnpm harness sweep-docker
→ 巡检了 9 个栈:8 个 worktree 仍存在,1 个是孤儿
⚠ 孤儿:workspacex-kernel(running(3))——原 worktree 已不存在
```
### ② 🔴 **巡检结论是错的,幸好没直接 apply**
它判 `workspacex-kernel` 为孤儿,理由是「创建它的 worktree 已不存在」。**但那正是全队共用的长驻开发栈** —— coord-main 刚用它跑过 `verify-rls`(floor 102/105)与整套 e2e。`down -v` 会**删掉它的卷**。
⇒ **这是 ADR-007 那条教训的原样重演**:
> 一次基于「worktree 目录已不存在」这条**本身可靠的**判定标准,未经请示就直接跑了 `--apply`,即使结果本身没错,这个执行顺序本身不该发生。
**这次结论本身就是错的。** ⇒ `sweep-docker` 的孤儿判据需要加一条例外:**长驻共享栈(`workspacex-kernel`)不按 worktree 存在性判定**。这条单独列进本 issue 范围。
### ③ 实际做的:只清**零容器**网络
```
移除前:39 个网络(8 个 wsx-* 测试栈 + 26 个历史残留 + 内建)
移除: 26 个零容器的历史残留(worker-* / feat-* / coord-platform-* 等老会话遗留)
移除后:12 个网络
```
**反证(清理后立即验)**:
- 仍在跑的容器 **16 个**,一个没少;
- `wsx-*` 测试网络 **7 个全部保留**(它们有活容器,是在飞的测试栈);
- 共享栈健康:`workspacex-kernel-postgres-1 Up 2 days (healthy)`。
⇒ **零容器网络 = 删掉不停任何东西、不删任何数据、不删任何卷**,下次 `compose up` 自动重建。**不属于「不可逆破坏性操作」。**
---
## 「共享可变状态」清单:**从六条变七条**
| # | 载体 | 防护 |
|---|---|---|
| 1-3 | git 索引 / 工作树 / stash 栈 | ADR-005 |
| 4 | 开发库 | test-isolation(#468 端口、#487 拆库两处洞) |
| 5 | scratchpad | 约定 |
| 6 | 数据库授权(GRANT/REVOKE) | **无**(#522) |
| 7 | **docker 网络 / 地址池** | **无** ← 本 issue |
⚠ **第 7 条的失败形态最像「平台 flake」**:三条分诊判据里它**只满足「零个用例跑起来」那一条**(没有 `EADDRINUSE`、diff 也不含端口配置)。⇒ **极易被误判成 #468**。
**已把这条写进分诊补充**:判据是合取,只满足一两条就不是那个平台问题——要单独识别「地址池耗尽」这个形态。
## 范围
1. **`with-test-isolation` 用完 `docker compose down` 掉自己的网络**(当前只 down 容器不 down 网络,或根本不 down)。这是根因。
2. **`sweep-docker` 的孤儿判据加例外**:长驻共享栈不按 worktree 存在性判定(见上方 ② —— 当前判据会让人删掉全队在用的库)。
3. 考虑扩 docker 的 `default-address-pools` 配置作为兜底。
4. **反证**:连续起 N 个隔离栈再销毁,断言网络数回到基线。
## 顺带:并发同一共享容器的连接争用
同一实现者还报告:与 #513 的 agent 在**同一个共享容器**上并发,导致 54 个文件 `Connection terminated unexpectedly`;错开后 439/439 全绿。
⇒ 与 #487(拆库掐连接)同源但不同表现。**本 issue 不修,登记备查。**
**Owner**:coord-architecture | **优先级**:P1(阻塞所有 worker 的 pre-push)
Contributor guide
No contributing guide indexed for this repository
Research direction
Locate the implementation and tests for `with-test-isolation` and `sweep-docker`, then inspect how Docker Compose networks are created and removed. Reproduce the issue by starting and destroying several isolated stacks, and verify that shared `workspacex-kernel` remains protected while zero-container networks are cleaned up. Done means repeated isolation runs return network counts to baseline without stopping containers or removing volumes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, docker-compose, typescript
- Domain
- devops, infrastructure, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100