mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-04 07:31:58 +00:00
feat(kanban): archive --rm to hard-delete archived tasks
Salvages #19964 by @Beandon13. Adds `hermes kanban archive --rm` to permanently remove already-archived tasks with cascading cleanup of links, comments, events, runs, and notify-subs. Safety guard: only archived tasks can be deleted; active/blocked/done must be archived first. Cherry-picked from #19964 onto current main (severe stale base, applied manually to preserve substance only).
This commit is contained in:
parent
06161c6ed8
commit
bde6313e34
4 changed files with 110 additions and 2 deletions
|
|
@ -761,6 +761,37 @@ def test_cli_archive_bulk(kanban_home):
|
|||
conn.close()
|
||||
|
||||
|
||||
def test_cli_archive_rm_deletes_archived_tasks(kanban_home):
|
||||
conn = kb.connect()
|
||||
try:
|
||||
tid = kb.create_task(conn, title="gone")
|
||||
assert kb.archive_task(conn, tid)
|
||||
finally:
|
||||
conn.close()
|
||||
out = run_slash(f"archive --rm {tid}")
|
||||
assert f"Deleted {tid}" in out
|
||||
conn = kb.connect()
|
||||
try:
|
||||
assert kb.get_task(conn, tid) is None
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
def test_cli_archive_rm_rejects_live_tasks(kanban_home):
|
||||
conn = kb.connect()
|
||||
try:
|
||||
tid = kb.create_task(conn, title="still-live")
|
||||
finally:
|
||||
conn.close()
|
||||
out = run_slash(f"archive --rm {tid}")
|
||||
assert "cannot delete" in out.lower()
|
||||
conn = kb.connect()
|
||||
try:
|
||||
assert kb.get_task(conn, tid) is not None
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
def test_cli_unblock_bulk(kanban_home):
|
||||
conn = kb.connect()
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -534,6 +534,37 @@ def test_archive_hides_from_default_list(kanban_home):
|
|||
assert len(kb.list_tasks(conn, include_archived=True)) == 1
|
||||
|
||||
|
||||
def test_delete_archived_task_removes_related_rows(kanban_home):
|
||||
with kb.connect() as conn:
|
||||
parent = kb.create_task(conn, title="parent")
|
||||
tid = kb.create_task(conn, title="child", parents=[parent], assignee="worker")
|
||||
kb.add_comment(conn, tid, "user", "cleanup me")
|
||||
kb.claim_task(conn, tid)
|
||||
kb.complete_task(conn, tid, result="done")
|
||||
assert kb.archive_task(conn, tid)
|
||||
conn.execute(
|
||||
"INSERT INTO kanban_notify_subs(task_id, platform, chat_id, thread_id, user_id, created_at, last_event_id) "
|
||||
"VALUES (?, 'telegram', '123', '', 'u', 0, 0)",
|
||||
(tid,),
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
assert kb.delete_archived_task(conn, tid) is True
|
||||
assert kb.get_task(conn, tid) is None
|
||||
assert conn.execute("SELECT COUNT(*) FROM task_links WHERE child_id = ? OR parent_id = ?", (tid, tid)).fetchone()[0] == 0
|
||||
assert conn.execute("SELECT COUNT(*) FROM task_comments WHERE task_id = ?", (tid,)).fetchone()[0] == 0
|
||||
assert conn.execute("SELECT COUNT(*) FROM task_events WHERE task_id = ?", (tid,)).fetchone()[0] == 0
|
||||
assert conn.execute("SELECT COUNT(*) FROM task_runs WHERE task_id = ?", (tid,)).fetchone()[0] == 0
|
||||
assert conn.execute("SELECT COUNT(*) FROM kanban_notify_subs WHERE task_id = ?", (tid,)).fetchone()[0] == 0
|
||||
|
||||
|
||||
def test_delete_archived_task_rejects_non_archived_rows(kanban_home):
|
||||
with kb.connect() as conn:
|
||||
tid = kb.create_task(conn, title="live")
|
||||
assert kb.delete_archived_task(conn, tid) is False
|
||||
assert kb.get_task(conn, tid) is not None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Comments / events / worker context
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue