docs(audit): record U1 architecture baseline

Capture the replayable import/sql/path/event counts and the owned exceptions that later milestones must shrink.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
weichen
2026-09-14 13:49:54 +00:00
co-authored by Cursor
parent 312578ccd1
commit 158ce2586d
3 changed files with 72 additions and 2 deletions
@@ -0,0 +1,64 @@
---
title: "arch-check U1 可重放基线"
status: done
created: 2026-09-14
updated: 2026-09-14
severity: medium
---
# arch-check U1 可重放基线
## 现象
Wave 0 的全仓 grep 会把 Goose、`*_test.go` 和路径字面量一视同仁,无法作为生产写者门禁。U1 用 `go list` + AST/正则拆成四类规则,并给每条既有债写明 owner、原因、截止里程碑和到期日。
## 根因分析
- `document_records` 的生产写者不止 `docgov`:`docrevision.projectRootPointersTX` 与 `docduty` 职责槽位仍直接 `UPDATE`。
- `output.md` / `data/dev` / `workspaces/` 仍被 agent、bizdev、coordinator、docgov、docrevision、server、storage 用 `filepath.Join`、字符串字面量或间接常量构造。
- Goose 与测试夹具大量出现同样表名,不能算生产写者债。
## 严重度
`medium`
## 关联整改
- ADR: [../adr/2026-09-14-modular-monolith-decoupling.md](../adr/2026-09-14-modular-monolith-decoupling.md)
- 设计: [../system-design/2026-09-14-module-decoupling-architecture.md](../system-design/2026-09-14-module-decoupling-architecture.md)
- 边界: [../system-design/module-boundaries.yaml](../system-design/module-boundaries.yaml)
- 任务: [../ops/short-term/2026-09-14-document-reliability-pilot.md](../ops/short-term/2026-09-14-document-reliability-pilot.md)
## 证据
命令(2026-09-14,`refactor/document-reliability-pilot` worktree):
```
./scripts/arch-check.sh --mode warn
go test ./internal/archtest -count=1
```
可重放计数(只含生产 Go;Goose/`*_test.go` 不计):
| 规则 | 计数 | 处理 |
|------|------|------|
| import | 0 | 相对 2026-09-14 production `go list` allowlist,无新边 |
| sql_write | 5 | 例外,U3/U8 到期 |
| path | 17 | 例外,U4/U5/U8 到期 |
| event | 0 | `OnOutbox` 生产者属主为 docrevision,server/notification 为消费者 |
验证:
- `deploy/postgres/goose` 与 `*_test.go` 出现 `document_records` 不报生产写者违规。
- 迷你仓 `internal/server/rogue_write.go` 新增 `UPDATE document_records` 时 `go test ./internal/archtest` 失败并指出文件。
- `filepath.Join`、字符串拼接、间接常量构造 `output.md` 均可检出。
- 无到期日例外、过期例外立即 block。
- `baseline_counts` 锁定现有计数,只能下降。
`--mode block` 在例外清零前会失败,不得挂进集成冒烟。
## 开放问题
- U3 收口 `document_records` / `freeform_documents` 跨属主写。
- U4/U5 收口 handler 与投影路径构造。
- U8 收口 `task_runs` 终止写与 finalize `output.md`。
+6
View File
@@ -13,6 +13,12 @@
## 核心文档(按阅读顺序推荐)
### arch-check U1 可重放基线(2026-09-14)
**文件**: [2026-09-14-arch-check-baseline.md](./2026-09-14-arch-check-baseline.md)
**结论**: 四类规则(production import / SQL write / path / event)可重放。import=0,sql_write=5,path=17,event=0。Goose 与测试不计生产写者。新违规与过期例外立即 block。
### 模块解耦方案复核(2026-09-14)
**文件**: [2026-09-14-module-decoupling-plan-review.md](./2026-09-14-module-decoupling-plan-review.md)
@@ -33,8 +33,8 @@ mutex: docgov
## 步骤
1. [x] 从最新 `dev`(`a8f9451`)创建实现分支,登记 CURRENT 并确认 `docgov` mutex 已释放。
2. [ ] 为当前跨表提交、刷新读取、ETag/idempotency 和权限负例补 characterization。
3. [ ] 实现 U1–U2,验证任意属主写入/commit 故障整体回滚。
2. [x] U1:四类规则 arch-check + archtest + 可重放基线(新违规 block)。
3. [ ] 实现 U2,验证任意属主写入/commit 故障整体回滚。
4. [ ] 实现 U3,删除提交后 outbox 正确性回调。
5. [ ] 实现 U4,保证 GET 零写入和 projection 缺失不再伪装成 404。
6. [ ] 执行多实例并发、PG、真实 PI、真实浏览器和 restart/rebuild 验收。