code-to10 v6 A7: unify row_get on peer_messages

- peer_messages.row_get gains default=None (was None-only); the
  three old variants agree on all real row types (None / dict /
  sqlite3.Row): auto_memory's old default was already None, and
  lifecycle's old None special-case and dict .get give identical
  results on those types, so no call-site behavior changes and no
  call site passes a non-None default.
- auto_memory and lifecycle delete their private _row_get copies
  and import peer_messages.row_get as _row_get (precedent: server,
  worker, handler_project, handler_support already do this);
  peer_messages imports no cloud modules, so no import cycle.
  lifecycle's old broad-Exception catch differs only for pathological
  __getitem__ inputs, which are not DB rows and are out of contract;
  this is documented on row_get, not left as a second story.
- Scope note: other modules' own row_get copies (approvals,
  automations, marker_tools, todos, wait_ops) are out of this item's
  stated scope and are untouched.
- Also drops auto_memory's unused 'import os' (pre-existing F401),
  so touched files are ruff E,F clean.
- Tests: cloud/tests/test_row_get_unified.py locks the identity
  (both aliases ARE row_get), the real-row-type matrix, the
  None-default fallback, and snapshot_to_dict via the unified path.

(cherry picked from commit 1644a0b837bfefb13cdc3c93d87fc1b246026607)
This commit is contained in:
host committed 2026-11-03 02:49:26 +00:00
1 parent c33bfd240e
commit be2962525b
4 files changed
+116 -24

No files matched your search

+7 -11
View File
@@ -31,6 +31,13 @@ import json
import time
import uuid
# 行取值统一走 peer_messages.row_get(A7):本模块旧私有版在
# 真实行类型(None / dict / sqlite3.Row)下与之结果完全一致
# (None 特判、dict .get、缺列回 None),调用处仍用 _row_get
# 别名,行为不变;旧版宽 Exception 兜底的病态行不在契约内,
# 见 peer_messages.row_get docstring。
from cloud.peer_messages import row_get as _row_get
SNAPSHOT_STATUS_LIMIT = 4000
SNAPSHOT_DIFF_LIMIT = 20000
REF_LIMIT = 2000
@@ -39,17 +46,6 @@ REF_KINDS = ("doc", "build", "external", "pr", "file")
BINDING_MODES = ("heartbeat", "cron")
def _row_get(row, name):
if row is None:
return None
if isinstance(row, dict):
return row.get(name)
try:
return row[name]
except Exception:
return None
# -- worktree 快照 ------------------------------------------------------
def ensure_snapshots_table(conn):