aps-agent/docs/round-67-approval-migration...

47 lines
3.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Round 67 状态:审批迁移 Fail-Closed 与 Grant Digest 归一化(R67-B1)
日期:2026-08-20
关联:`docs/round-67-approval-migration-work-plan.md`、`docs/round-67-approval-migration-parallel-implementation-plan.md`
## 1. 结论
R67-B1 九项目标全部在本地 SQLite 闭环,最终状态 **DONE (local)**。真实跨主机停写编排与 MySQL 多主机仍属部署验收,不在本地冒充完成。
| 目标 | 状态 | 证据 |
|---|---|---|
| 1. grant 只存 `token_digest(raw)` | Done | `test_db_persists_only_digests`、`test_migrated_p3_grant_consumable_once` |
| 2. 损坏 JSON/schema/记录 fail-closed | Done | `test_corrupt_json_fails_closed`、`test_invalid_schema_and_records_fail_closed`;文件缺失空源语义保持(`test_migrate_missing_file_empty_source`) |
| 3. 规范化预检 + 终态 APPROVED request 重建 | Done | `test_migrated_p3_grant_consumable_once`(`rebuilt=1`、`migratedTerminalRequest=True`) |
| 4. 单 Session 事务 flush/commit,后段异常整体回滚 | Done | `test_late_failure_rolls_back_all`(故障注入后三表零写入) |
| 5. 不可变身份 + 单调状态幂等 | Done | `test_identity_conflict_fails_closed`、`test_monotonic_status_no_regression`、`test_source_ahead_advances_db` |
| 6. expected digest 预检、legacy raw-token 原子修复/冲突、禁二次哈希 | Done | `test_legacy_raw_token_row_repaired`、`test_legacy_raw_token_row_conflict_fails_closed`、`test_known_digest_key_never_rehashed` |
| 7. history 完整 canonical event digest 去重 | Done | `test_history_canonical_digest_preserves_near_duplicates`(近似事件保留、完全重复去重、重跑幂等) |
| 8. `APS_APPROVAL_MIGRATION_QUIESCED=1` + 同源 `.lock` + 源 SHA-256 复核 | Done | `test_migrate_requires_quiesced`、`test_source_drift_rolls_back` |
| 9. 迁移后 active P3 grant 消费一次、重放失败 | Done | `test_migrated_p3_grant_consumable_once`(第一次 True、第二次 False) |
## 2. 验证记录
- focused:`tests/golden/test_approval_migration.py` **19 passed**(原 5 项适配 quiesced 前置 + 新增 14 项)。
- 审批相关套件:migration / database_store / store / delegate / transfer / role_policies / gov_api / harness_p3 合计 **88 passed**。
- 全量黄金(154 文件分三批):**1065 passed / 1 failed**;唯一失败 `test_preference_features.py::test_extract_features_from_world` 为 DXF-01 轮已记录的既有失败(偏好特征口径,与本轮零交集)。
- ruff:本轮两文件全绿(import 排序已 `--fix`);`git diff --check` passed。
## 3. 影响分析
GitNexus MCP 工具本运行环境不可用;采用工作计划既有门禁结论(`load_file_store` LOW、`migrate_file_to_db` MEDIUM)+ 人工复核:两函数仅被迁移自身与测试调用,无网关/生产端接线;`ApprovalStore`、`DatabaseApprovalStore`、`harness` 零改动。爆炸半径 LOW。
## 4. 数据保护
全部测试使用 `tmp_path` 临时审批文件与临时 SQLite;fixture 显式 `APS_APPROVAL_MIGRATION_QUIESCED=1`。验收后 `git status -- server/data .env` 干净,现场 `approvals.json` / `master.db` 未读取后写回。
## 5. 遗留 / 边界
- R67-B2:数据库权威时钟、TTL/CAS 跨主机语义。
- 真实 MySQL 多主机、断连/死锁故障注入。
- SAP outbound P3 evidence envelope、folder.schedule TOCTOU、Automation G4 payload 绑定(下一 P0:全量 P2/P3 evidence 封套)。
- 真实跨主机停写编排属部署验收,需现场运维流程配合。
## 6. 发布动作
本地 commit(用户授权);无 push / merge / publish。