From 92ed370b4a16adc432a6ebfa69be896c285f78e6 Mon Sep 17 00:00:00 2001 From: Benjamin Borbe Date: Tue, 20 Oct 2026 13:52:00 +0200 Subject: [PATCH] fix: let a handed-off session exit when claude_session_id has moved on session-self-exit.py resolved the anchor task by claude_session_id alone, so a session whose task was handed to another session matched nothing and could never exit. It now also resolves a task through metrics_sessions membership, and that branch skips the terminal check because the session's own work is already on the record. The pane-ownership and open-card guards still refuse. --- CHANGELOG.md | 4 ++ scripts/session-self-exit-test.sh | 87 +++++++++++++++++++++++++++++++ scripts/session-self-exit.py | 73 ++++++++++++++++++++------ 3 files changed, 148 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 915844ff..de3a7154 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ Please choose versions by [Semantic Versioning](http://semver.org/). * MINOR version when you add functionality in a backwards-compatible manner, and * PATCH version when you make backwards-compatible bug fixes. +## Unreleased + +- fix: `scripts/session-self-exit.py` lets a session that was handed off from a task exit. When `claude_session_id` has moved to another session, the task is resolved through its `metrics_sessions` instead, and that branch skips the terminal check — its own work is already on the record. The pane-ownership and open-card guards still refuse. + ## v0.174.1 - fix: `session-close` prints its open-goal status lines from a new `session-close-goals.sh` resolver and requires the closer to reproduce them, so a close can no longer drop the line silently. Measured 2026-10-20: one real close ran the phase's own lookup, received `status=in_progress`, and emitted no goal line at all. diff --git a/scripts/session-self-exit-test.sh b/scripts/session-self-exit-test.sh index 68c1767d..b6683d59 100644 --- a/scripts/session-self-exit-test.sh +++ b/scripts/session-self-exit-test.sh @@ -45,6 +45,43 @@ task() { # task } > "$TASKS/Anchor.md" } +handed_off_task() { # handed_off_task + local status=$1 phase=$2 owner=$3 + { + echo "---" + echo "status: $status" + echo "phase: $phase" + echo "claude_session_id: $owner" + echo "metrics_sessions:" + echo " - session_id: $SID" + echo " started_at: \"2026-10-20T11:51:47.321573+02:00\"" + echo " - session_id: $owner" + echo " started_at: \"2026-10-20T11:52:00.000000+02:00\"" + echo "---" + echo "" + echo "# Tasks" + echo "" + echo "- [ ] open" + } > "$TASKS/Anchor.md" +} + +other_owner_task() { # other_owner_task — no handoff record for $SID + { + echo "---" + echo "status: in_progress" + echo "phase: execution" + echo "claude_session_id: $1" + echo "metrics_sessions:" + echo " - session_id: $1" + echo " started_at: \"2026-10-20T11:52:00.000000+02:00\"" + echo "---" + echo "" + echo "# Tasks" + echo "" + echo "- [ ] open" + } > "$TASKS/Anchor.md" +} + cards() { # cards printf '%s' "$1" > "$TMP/store/api/1.0/attention" } @@ -68,6 +105,22 @@ run() { # run