auto-sync: 2026-05-30 10:50:48
This commit is contained in:
@@ -718,15 +718,23 @@ class Dispatcher:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def _mark_task_status(self, db_path: Path, task_id: str, status: str) -> None:
|
def _mark_task_status(self, db_path: Path, task_id: str, status: str) -> None:
|
||||||
"""更新任务状态"""
|
"""更新任务状态 + 写审计事件"""
|
||||||
try:
|
try:
|
||||||
conn = get_connection(db_path)
|
conn = get_connection(db_path)
|
||||||
try:
|
try:
|
||||||
conn.execute("BEGIN IMMEDIATE")
|
conn.execute("BEGIN IMMEDIATE")
|
||||||
|
old_row = conn.execute(
|
||||||
|
"SELECT status FROM tasks WHERE id=?", (task_id,)
|
||||||
|
).fetchone()
|
||||||
|
old_status = old_row["status"] if old_row else "unknown"
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"UPDATE tasks SET status=?, updated_at=datetime('now') WHERE id=?",
|
"UPDATE tasks SET status=?, updated_at=datetime('now') WHERE id=?",
|
||||||
(status, task_id),
|
(status, task_id),
|
||||||
)
|
)
|
||||||
|
conn.execute(
|
||||||
|
"INSERT INTO events (task_id, event_type, payload) VALUES (?, 'status_change', ?)",
|
||||||
|
(task_id, f'{{"from": "{old_status}", "to": "{status}", "source": "auto_complete"}}'),
|
||||||
|
)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
finally:
|
finally:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user