Skip to content

The agent that grows with you

refactor(sessions): drop dead whole_lineages from the open-session count

kshitijk4poor1d2b573739b6
diff --git a/hermes_cli/sessions_cmd.py b/hermes_cli/sessions_cmd.py
index 54e132803f0..a17459d2bae 100644
--- a/hermes_cli/sessions_cmd.py
+++ b/hermes_cli/sessions_cmd.py
@@ -687,7 +687,7 @@ def _cmd_prune_or_archive(db, args, action):
candidates = db.list_prune_candidates(**filters, whole_lineages=prune)
# Archive expands each matched tip to its compression lineage, so a direct-open count would
# misdescribe its effect.
- skipped_open = db.count_open_prune_matches(**filters, whole_lineages=True) if prune else 0
+ skipped_open = db.count_open_prune_matches(**filters) if prune else 0
if skipped_open:
print(f"Note: {skipped_open} open session{'' if skipped_open == 1 else 's'} also match these filters but "
"will be skipped because prune only deletes ended sessions. Use `hermes sessions delete <id>` "
diff --git a/hermes_cli/web_routers/sessions.py b/hermes_cli/web_routers/sessions.py
index 417e47cf624..77919e3e7fd 100644
--- a/hermes_cli/web_routers/sessions.py
+++ b/hermes_cli/web_routers/sessions.py
@@ -95,9 +95,9 @@ def _prune_sessions(body: SessionPrune):
"archived": None if body.include_archived else False,
**{f: (getattr(body, f) or None) for f in _PRUNE_STR_FILTERS},
**{f: getattr(body, f) for f in _PRUNE_NUM_FILTERS}}
- # Same whole-lineage selection prune_sessions applies, so the preview lists what it deletes.
- skipped_open = db.count_open_prune_matches(**filters, whole_lineages=True)
+ skipped_open = db.count_open_prune_matches(**filters)
if body.dry_run:
+ # Same whole-lineage selection prune_sessions applies, so the preview lists what it deletes.
rows = db.list_prune_candidates(**filters, whole_lineages=True)
return {
"ok": True,
diff --git a/hermes_state_maintenance.py b/hermes_state_maintenance.py
index 4d687c0e273..1bec2dda49d 100644
--- a/hermes_state_maintenance.py
+++ b/hermes_state_maintenance.py
@@ -256,10 +256,10 @@ class SessionMaintenanceMixin:
where, params = self._prune_where(older_than_days, source, filters)
return int(self._read_one(f"SELECT COUNT(*) FROM sessions s WHERE {where}", params)[0])
- def count_open_prune_matches(self, older_than_days: Optional[float] = None, source: str = None, *,
- whole_lineages: bool = False, **filters) -> int:
+ def count_open_prune_matches(self, older_than_days: Optional[float] = None, source: str = None,
+ **filters) -> int:
"""Count open sessions a matching prune skips (``ended_at`` guard inverted); visibility-only."""
- where, params = self._prune_where(older_than_days, source, filters, whole_lineages=whole_lineages)
+ where, params = self._prune_where(older_than_days, source, filters)
ended_guard = "s.ended_at IS NOT NULL"
if not where.startswith(ended_guard):
raise RuntimeError("prune filter lost its ended-session safety guard")