refactor(lib): hash entire session dictionary to widen YAML write-gate

- Prevent YAML<->SQLite sync drift on completed jobs (R-1 Option A)
- Hash session dict to trigger YAML rewrite on any field updates
This commit is contained in:
2026-07-12 14:37:42 +09:00
parent 60f3af4af9
commit 49176b43b6
+7 -1
View File
@@ -331,7 +331,13 @@ def get_terminal_set(d):
return {s.get('name'): s.get('status') for s in d.get('tmux_sessions', []) if s.get('status') in ('stopped', 'terminated', 'archived')} return {s.get('name'): s.get('status') for s in d.get('tmux_sessions', []) if s.get('status') in ('stopped', 'terminated', 'archived')}
def get_all_sessions_status(d): def get_all_sessions_status(d):
return {s.get('name'): s.get('status') for s in d.get('tmux_sessions', [])} import hashlib
res = {}
for s in d.get('tmux_sessions', []):
name = s.get('name')
ser = json.dumps(s, sort_keys=True)
res[name] = hashlib.sha256(ser.encode('utf-8')).hexdigest()
return res
os.makedirs(os.path.dirname(db_path) or '.', exist_ok=True) os.makedirs(os.path.dirname(db_path) or '.', exist_ok=True)
conn = sqlite3.connect(db_path, timeout=60.0) conn = sqlite3.connect(db_path, timeout=60.0)