---
created: 2026-04-20T09:48:39.474Z
promoted: 2026-05-10
promoted_to: Phase 29 (v1.7 Seamlessification)
title: Auto-fire echo commune on SessionStart and wrapper self-exit
area: psyche
files:
  - src/owl/echo_commune.rs
  - src/owl/hook_idle.rs
  - src/live/wrapper/echo_fire.rs
  - src/live/wrapper/orphan.rs
  - plugin/spt/hooks/hooks.json
---

## Problem

Two situations currently lose Self-side delta context that would be valuable for Psyche continuity:

1. **SessionStart on existing perch:** When a Claude Code session restarts (e.g. after `/clear`) against a Self perch that is still running, the fresh session has no memory of prior turns. The pre-`/clear` jsonl session history holds the delta that Psyche needs. No automatic mechanism triggers an echo-commune at that boundary to summarize "what happened before this reset."

2. **Psyche wrapper self-exit on orphaned Self:** When the Psyche wrapper detects Self is missing (orphan check in `src/live/wrapper/orphan.rs`), it sends INIT_SIGNOFF and exits. It does NOT first run an echo-commune to capture any uncommuned delta from Self's most recent session — that context is lost when the wrapper goes down.

Both gaps mean real work performed by Self disappears from Psyche's rolling context across session boundaries that the wrapper itself handles.

## Solution

TBD — design notes:

- **(1) SessionStart auto-fire:** Add logic to the SessionStart hook (or a wrapper-side trigger keyed on session-id change) that detects "existing perch + new Claude Code session = potential /clear boundary" and invokes `_echo-commune` against the PRIOR session uuid (from the jsonl directory under `~/.claude/projects/<cwd-encoded>/`). The haiku subprocess would summarize the pre-clear delta and deliver via `deliver_body_anonymous` to the Psyche as usual.
  - Challenge: distinguishing a `/clear` (where prior jsonl is still on disk and relevant) from a fresh session start (where there is nothing to commune). Heuristic: prior jsonl mtime < N minutes + session-id differs from info.json = /clear-like boundary.
  - Depends on: resolved Phase 18.8 (echo-commune fresh-session refactor) — auto-fire is especially risky under the Self-session-contention race class 18.8 is fixing. If 18.8 migrates haiku to a fresh session with jsonl excerpt as input, this auto-fire becomes trivial and safe.

- **(2) Pre-orphan echo-commune:** In `orphan.rs`, before sending INIT_SIGNOFF and exiting, fire `_echo-commune` against Self's last known session uuid and wait (or short-timeout) for its [COMMUNE] delivery to land in Psyche's inbox. Same `should_fire` gate as normal echo-commune + force-fire flag for orphan path (don't gate on sentinel staleness when we're literally going down forever).
  - Challenge: bounded wait on subprocess output before exit so orphan detection doesn't stall indefinitely. Reasonable cap: 60-90s.

Both require Phase 18.8 echo-commune path to be hardened first (stderr capture + fresh-session refactor) — otherwise we just multiply the silent-failure surface.
