feat(lib): SQLite DB normalization (FW-L3) & stop semantics simplification (FW-L2)

This commit is contained in:
2026-06-21 09:05:15 +00:00
parent 478be56679
commit 8097df0cbe
11 changed files with 324 additions and 200 deletions
@@ -126,7 +126,7 @@ tmux: no session
**Skip-set**: the auto-terminate only fires for sessions whose status is `running`.
Rows already in a deliberate end state — `terminated`, `archived`, or **`stopped`**
(set by `tmux-agent-orchestrate-stop --capture-id/--reason/--graceful`) — are
(set by `tmux-agent-orchestrate-stop`) — are
left untouched. This is critical: a `stopped` row keeps its `resumable: true` and
captured `*_session_id_own`, so the monitor must **not** overwrite it with
`terminated ("auto-detected")` when its tmux is (expectedly) gone.
@@ -245,6 +245,15 @@ except NameError:
conn = sqlite3.connect(db_path, timeout=10.0)
row = conn.execute('SELECT data FROM state WHERE id=1').fetchone()
if row: d = json.loads(row[0])
try:
db_sessions = []
cursor = conn.execute('SELECT data FROM sessions')
for s_row in cursor.fetchall():
db_sessions.append(json.loads(s_row[0]))
d['tmux_sessions'] = db_sessions
except sqlite3.OperationalError:
pass
conn.close()
elif os.path.exists(yaml_path):
with open(yaml_path) as f: