Skip to content

Retire ended harness sessions through lifecycle hooks - #87

Draft
mostlydev wants to merge 4 commits into
masterfrom
fix/session-lifecycle-cleanup
Draft

mostlydev wants to merge 4 commits into
masterfrom
fix/session-lifecycle-cleanup

Conversation

@mostlydev

@mostlydev mostlydev commented Sep 18, 2026

Copy link
Copy Markdown
Owner

After /clear, a harness can keep running while its session identity changes, leaving the old session in the room. Add SessionStart/SessionEnd hooks that retire only the exact ended session, revoke its lease and wake registrations, and prevent stale listeners from rejoining. Explicit resume permits that session to join again. Concurrent sessions sharing a process remain separate.

The installer preserves existing hooks and adds Codex hook-trust guidance. Claude reports the old session ending immediately on /clear; Codex does not, so immediate Codex clear cleanup remains unsupported and waits for its authoritative end event. Existing ghosts from before hook installation are not inferred away.

Validation: 657 tests passed, one skipped; typecheck and build passed. Disposable lifecycle probes verified Claude clear/resume ordering and Codex delayed end behavior. Grok event spelling is normalized and covered by a native snake-case lifecycle regression. Independent compiled-hook verification passed in a disposable Claude session: clear retirement, stale-ID rejoin rejection, successor join, and resume of the original ID. A separate probe confirmed clear and exit retirement. Claude and Grok reviewed and agreed on the implementation. Draft pending operator acceptance; not merged or released. Lifecycle hooks have been enabled locally in Claude/Codex/Grok settings, with backups and structural verification that prior settings are preserved; Codex still requires its /hooks trust review. Historical pre-install ghost members remain unchanged.

The plan listed compiled-hook live verification as pending. Record what
the disposable Claude 2.1.277 run against f8d500e actually showed:
/clear retires the old session, that session's ID is refused when it
tries to rejoin from the same process, the new session joins, and
/resume retires the successor and readmits the original ID.

Also record what was not proven live: the independent fixture run did
not exercise resume because its session was empty, and lease release
rests on the regression suite.
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