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:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user