FLAG-1 unified task_attempts schema (single canonical DDL + 3-shape migration)
User decision 2026-11-05: unified schema, rejecting the rehearsal runtime column-union workaround and a ledger rename. One definition (cloud.attempt_ledger.TASK_ATTEMPTS_DDL, 12 columns) shared by cloud.attempts and cloud.db.POSTGRES_SCHEMA; ensure builds the unified table fresh and migrates old resume, gap-3 ledger, and rehearsal shapes in place with rows intact. aggregate counts ledger rows only (outcome NULL = resume row, never counted). SQLite verified by 8 new tests; Postgres real-DB upgrade path explicitly NOT verified (see batch summary). Local commit only: no merge, no push, no deploy.
This commit is contained in:
1 parent
6d009af48f
commit
6a70775ad9
6 files changed
+467
-113
No files matched your search
+17
-12
@@ -21,9 +21,10 @@
|
||||
报告:表齐但钩子关 ≠ 就绪,钩子开但表不齐 ≠ 就绪。
|
||||
3. DDL 清单不另造:清单直接引用 attempt_ledger.PG_DDL
|
||||
与 attempt_hook.PG_MARKER_DDL 两个常量(本模块不
|
||||
复制 DDL 文本,复制就会漂移)。另含 gap 3 旧表升级句
|
||||
attempt_ledger.OLD_TABLE_ALTER(仅当旧 DDL 建过表时
|
||||
需要;gap 3 未合并,生产尚无旧表,属防御项)。
|
||||
复制 DDL 文本,复制就会漂移)。老形态表升级走
|
||||
attempt_ledger.ensure_task_attempts_table 的统一列补齐
|
||||
(仅当老形态建过表时需要;属防御项,PG 真实库升级
|
||||
路径未实证)。
|
||||
4. 校验函数 verify_ledger_ready(conn):只读探针——查两
|
||||
张表的存在与必需列,不建表、不写行(读路径绝不改
|
||||
schema,与 metrics-report 端点的只读纪律一致)。
|
||||
@@ -42,11 +43,14 @@ from cloud.attempt_hook import PG_MARKER_DDL as _PG_MARKER_DDL
|
||||
from cloud.attempt_ledger import OLD_TABLE_ALTER as _OLD_TABLE_ALTER
|
||||
from cloud.attempt_ledger import PG_DDL as _LEDGER_PG_DDL
|
||||
|
||||
# 必需列:缺任一列即视为表不齐(旧 DDL 建的表缺
|
||||
# corrects_attempt_no 时走 OLD_TABLE_ALTER 补列)。
|
||||
# 必需列:统一 schema 的全部 12 列;缺任一列即视为表
|
||||
# 不齐(老形态建的表由 ensure_task_attempts_table 补齐
|
||||
# 缺失列后复核,不再只补 corrects_attempt_no 一列)。
|
||||
LEDGER_REQUIRED_COLUMNS = (
|
||||
"task_id", "attempt_no", "outcome", "is_defect",
|
||||
"defect_category", "created_at", "corrects_attempt_no",
|
||||
"defect_category", "corrects_attempt_no", "kind",
|
||||
"interrupted_reason", "checkpoint_round", "result_text",
|
||||
"error_text", "created_at",
|
||||
)
|
||||
MARKER_REQUIRED_COLUMNS = ("task_id", "origin", "queued_at")
|
||||
|
||||
@@ -72,12 +76,13 @@ LEDGER_DDL_CHECKLIST = (
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"action": "仅当表由 gap 3 旧 DDL 建过时:执行"
|
||||
" attempt_ledger.OLD_TABLE_ALTER 补"
|
||||
" corrects_attempt_no 列(gap 3 未合并,"
|
||||
"生产正常路径跳过此步)",
|
||||
"ddl_source": "cloud.attempt_ledger.OLD_TABLE_ALTER",
|
||||
"verify": "task_attempts 含 corrects_attempt_no 列",
|
||||
"action": "仅当表已由老形态(旧恢复 DDL、gap 3 台账 DDL"
|
||||
" 或演练形态)建过时:经 attempt_ledger."
|
||||
"ensure_task_attempts_table 补齐缺失的统一列"
|
||||
"(SQLite 已实测;PG 真实库升级路径未实证,"
|
||||
"生产 PG 上执行前须先在真实 PG 上验证)",
|
||||
"ddl_source": "cloud.attempt_ledger.TASK_ATTEMPTS_DDL",
|
||||
"verify": "task_attempts 含统一 schema 全部 12 列",
|
||||
},
|
||||
{
|
||||
"step": 4,
|
||||
|
||||
Reference in new issue
Block a user