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
+18
-14
@@ -31,7 +31,13 @@ host.py、不改 codex 线程恢复:
|
||||
result_text / error_text 各截断 2000 字。记账与回 queued
|
||||
在同一事务里,记账失败不单独炸恢复循环(外层已兜底),
|
||||
但同一 (task_id, attempt_no) 重复记时 INSERT OR IGNORE
|
||||
保留第一次,不覆盖。
|
||||
保留第一次,不覆盖。表定义是统一 schema(FLAG-1,
|
||||
2026-11-05):本模块不自带一份 DDL,CREATE_TABLE_SQL
|
||||
与建表/迁移均取自 ``cloud.attempt_ledger`` 的
|
||||
``TASK_ATTEMPTS_DDL`` / ``ensure_task_attempts_table``,
|
||||
与台账写路径共用同一定义;本模块写的行 outcome 为
|
||||
NULL(恢复历史行,非台账计数行,见 attempt_ledger 对
|
||||
aggregate 的口径)。
|
||||
② 重跑前言:非 goal 平台全新重排的任务在认领时,worker
|
||||
在内存副本的 prompt 前贴一段上次尝试说明(原 prompt
|
||||
不落库,与项目/待办/记忆注入同款只改内存副本),内容
|
||||
@@ -63,25 +69,23 @@ host.py、不改 codex 线程恢复:
|
||||
|
||||
import time
|
||||
|
||||
from cloud.attempt_ledger import TASK_ATTEMPTS_DDL
|
||||
from cloud.attempt_ledger import ensure_task_attempts_table as _ensure_unified
|
||||
|
||||
ATTEMPT_TEXT_CHARS = 2000
|
||||
PREAMBLE_TEXT_CHARS = 1000
|
||||
|
||||
CREATE_TABLE_SQL = (
|
||||
"CREATE TABLE IF NOT EXISTS task_attempts("
|
||||
"task_id TEXT, "
|
||||
"attempt_no INTEGER, "
|
||||
"kind TEXT, "
|
||||
"interrupted_reason TEXT, "
|
||||
"checkpoint_round INTEGER, "
|
||||
"result_text TEXT, "
|
||||
"error_text TEXT, "
|
||||
"created_at DOUBLE PRECISION, "
|
||||
"PRIMARY KEY(task_id, attempt_no))")
|
||||
# 统一 schema:与台账共用同一定义,绝不在此另写一份 DDL
|
||||
# (历史教训:两份 DDL 同名异构,CREATE TABLE IF NOT EXISTS
|
||||
# 使后建的一方成空操作、写行报缺列)。别名保留,供旧调用
|
||||
# 方按名取定义;建表与老表迁移一律走台账的 ensure。
|
||||
CREATE_TABLE_SQL = TASK_ATTEMPTS_DDL
|
||||
|
||||
|
||||
def ensure_attempts_table(conn):
|
||||
"""幂等建尝试账本表(server/worker 两支共用同一 DDL)。"""
|
||||
conn.execute(CREATE_TABLE_SQL)
|
||||
"""幂等建尝试账本表(server/worker 两支共用同一 DDL):
|
||||
新库建统一表,老库迁移到统一列集(见 attempt_ledger)。"""
|
||||
_ensure_unified(conn)
|
||||
|
||||
|
||||
def _trunc(text, limit):
|
||||
|
||||
Reference in new issue
Block a user