Skip to content

SessionStart catch-up for force-killed sessions (release 0.2.6) - #7

Merged
ericwalisko merged 2 commits into
mainfrom
ericwalisko/sessionstart-catchup
Sep 4, 2026
Merged

SessionStart catch-up for force-killed sessions (release 0.2.6)#7
ericwalisko merged 2 commits into
mainfrom
ericwalisko/sessionstart-catchup

Conversation

@ericwalisko

Copy link
Copy Markdown
Owner

The problem (found by testing your actual workflow)

Deleting an Orca worktree SIGKILLs the process group — proven two ways:

  • Empirical: a signal-trap script running in an Orca worktree logged only STARTED when the worktree was deleted — none of its SIGTERM/SIGHUP/SIGINT/SIGQUIT traps fired, and even bash's EXIT trap didn't run. That's an untrappable kill.
  • Code: Orca's own teardown calls process.kill(-pgid, "SIGKILL").

A SIGKILL cannot run any hook, so the plugin's SessionEnd sync and backup never fire when a worktree is deleted (the common flow — nobody types /quit first). Consequence: a short session that never hits /compact is never indexed (its PreCompact never runs either). Raw transcripts stay safe on disk, but recall falls behind.

The fix — move the safety net to SessionStart

SessionStart always runs, so it can catch up whatever the previous force-killed session missed:

  • New bare-sync mode: memware sync with no path (and not --from-hook) now indexes the configured backup.transcript_src (default ~/.claude/projects). Useful on its own; it's what the hook calls.
  • New SessionStart hook: runs that catch-up sync + a throttled memware backup --if-stale 20, backgrounded (nohup … &) so startup is never delayed and nothing lands in the new session's context.
  • Kept SessionEnd/PreCompactSessionEnd still fires on clean exits, so this is belt-and-suspenders.

Net: the previous session is indexed at the next start even when its SessionEnd was skipped.

Tests

  • test_bare_sync_catches_up_configured_transcript_srcmemware sync with no path indexes the configured source.
  • Existing sync tests unaffected (all pass a path or --from-hook).

Bumps to 0.2.6 (package + both manifests, enforced by the drift-guard test). Full suite, ruff, format, mypy, and a hooks.json JSON-validity check all green locally.

🤖 Generated with Claude Code

ericwalisko and others added 2 commits September 3, 2026 20:43
Some environments force-kill Claude Code instead of ending it cleanly: a
worktree/pane manager (e.g. Orca) SIGKILLs the process group when you delete a
worktree, and a SIGKILL cannot run any hook. Verified empirically — a signal-trap
process inside an Orca worktree got no trappable signal and its EXIT trap never
ran when the worktree was deleted — and in Orca's own code (process.kill(-pgid,
"SIGKILL")). So the SessionEnd sync + backup silently never fire in that flow;
only sessions that hit PreCompact get indexed. Raw transcripts stay durable on
disk, but the searchable index falls behind.

Fix by moving the safety net to SessionStart, which always runs:
- New: bare `memware sync` (no path, not --from-hook) catches up the configured
  backup.transcript_src (default ~/.claude/projects), so it indexes whatever the
  last force-killed session left unsynced.
- New SessionStart hook runs that catch-up sync plus a throttled
  `memware backup --if-stale 20`, backgrounded (nohup … &) so session startup is
  never delayed and nothing is injected into context.
- SessionEnd/PreCompact are kept — SessionEnd still fires on clean exits.

Bumps to 0.2.6 (package + both manifests, per the guard test). Docs (README,
integrations.md) and CHANGELOG updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NnaQwZUSDRbVUNh8fsdksD
The SessionStart catch-up runs sync + backup in the background on every start, so
several memware processes can now touch the store at once (SessionStart catch-up,
a session-end sync, the backup cron). WAL permits one writer at a time; without a
busy timeout a concurrent write fails immediately with "database is locked".
Wait-and-retry instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NnaQwZUSDRbVUNh8fsdksD
@ericwalisko
ericwalisko merged commit e7cf087 into main Sep 4, 2026
6 checks passed
@ericwalisko
ericwalisko deleted the ericwalisko/sessionstart-catchup branch September 4, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant