Skip to content

fix(sessions): export and verify delegate transcripts before cascading session deletion#71123

Open
Drexuxux wants to merge 1 commit into
NousResearch:mainfrom
Drexuxux:fix/session-export-delegate-cascade
Open

fix(sessions): export and verify delegate transcripts before cascading session deletion#71123
Drexuxux wants to merge 1 commit into
NousResearch:mainfrom
Drexuxux:fix/session-export-delegate-cascade

Conversation

@Drexuxux

Copy link
Copy Markdown
Contributor

What?

hermes sessions export --delete-after-verified previously exported and verified only the explicitly selected parent session.

It then called SessionDB.delete_session(), which intentionally cascade-deletes every delegate/subagent session associated with that parent. This meant delegate messages and transcript files could be permanently deleted even though their content was never included in the verified archive.

Fix

The export flow now discovers the complete delegate deletion set and writes each affected session to a separate Markdown/QMD file.

Every generated file must pass the existing hash, session ID, and message-count verification before deletion begins. The expected deletion set is also checked inside the SQLite write transaction. If a new delegate appears while the export is running, deletion fails closed and all sessions are preserved.

Normal session deletion behavior remains unchanged.

Related Work

These PRs introduced the affected workflow but do not handle delegate sessions that are cascade-deleted with their parent.

Tests

  • Added real SQLite and filesystem E2E coverage proving both parent and delegate transcripts are exported before deletion.
  • Added regression coverage proving a newly created delegate causes guarded deletion to preserve every session.
  • Verified transcript cleanup still happens after successful export and verification.
  • 497 passed
  • Ruff passed.
  • compileall passed.
  • git diff --check passed.

@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/cli CLI entry point, hermes_cli/, setup wizard area/sessions Session lifecycle, resume, persistence, history sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/cli CLI entry point, hermes_cli/, setup wizard P1 High — major feature broken, no workaround sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants