Skip to content

feat: hooks for the end of a session, lane-stop and session-end (ADR-0094 addendum) - #478

Merged
7schmiede merged 1 commit into
mainfrom
feat/hooks-session-end
Nov 6, 2026
Merged

7schmiede merged 1 commit into
mainfrom
feat/hooks-session-end

Conversation

@7schmiede

Copy link
Copy Markdown
Member

What and why

A routine that belongs to the end of a session (stop a time-tracking timer, review the session) had only a prompt-submit hook matching closing words. A session that ends without one (window closed, /exit, Ctrl+C) got nothing, and a closing word mid-session fired early. Two new hook events, additive to the hooks.toml format:

  • lane-stop: after devstack lane stop (CLI) or the MCP tool lane_stop succeeded, the texts of the lane-stop hooks that apply to the lane's worktree (skill on, repository bound, upstream accepted) follow the output, every time, whoever ran it. The lane's worktree comes from GET /v1/lanes; any error gives no text and the stop stands.
  • session-end: the hub writes an entry for Claude Code's SessionEnd. devstack hook session-end prints nothing; where a session-end hook applies, it keeps that the session ended (hook-ended/ in the hub's state: session id, transcript path, time). The next session-start of the same agent in the same working tree (nearest folder with .git) gives the texts once, after a line naming the ended session and its transcript. Records not touched for seven days go.
  • Reading: a member's hub now skips a hook of an event it does not know (it looks like an event's name, a-z and -) and keeps the skill's other hooks; until 0.41.0 it left out all hooks of such a skill. The coordinator stays strict (check_files), so an author's typo still leaves the skill out, with why.
  • Codex documents no end of a session: it gets no session-end entry, and devstack doctor names the agents that get hooks but no session-end ones.
  • docs/pool.md documents both events and the advice to keep them in a skill of their own while members run releases before 0.42.0; ADR-0094 has an addendum; CHANGELOG under Added.

Review card

# Category Point Beats Reversing costs
1 contract event gets two values, lane-stop and session-end; a hub from 0.42.0 skips a hook of an event it does not know instead of leaving out the skill's hooks, a hub before it still leaves them out, so the documentation advises a skill of their own while members run older releases. A version per hook; a file of their own for the new events. The format has users outside the maintainers: additive changes only.
2 concept lane-stop: after devstack lane stop (CLI) or MCP lane_stop succeeded, devstack appends the texts of the lane-stop hooks that apply to the lane's worktree to the output, every time, whichever agent ran it. An agent hook on the shell command (Claude Code's PostToolUse only). Low.
3 concept session-end: the hub writes an entry for Claude Code's SessionEnd; the dispatcher only records the end (agent, session id, transcript path, working tree, time), and the next session-start of the same agent in the same working tree gives the texts once, with a line naming the ended session; a record older than seven days is dropped. Text at SessionEnd (it never reaches the model); the closing-words heuristic. Medium: state on disk, one more agent entry.

Approved by the owner in the conversation on 2026-11-06: points 1, 2 and 3.

Decided on my own: Codex gets no session-end (it documents no end of a session; doctor says so); lane-stop gives its texts on every stop (once does not apply); the end is recorded only where a session-end hook applies; the coordinator stays strict about unknown events.

Verified

  • Windows 11, the built binary with a temporary hub state (LOCALAPPDATA pointed at a temp folder, an agent-hooks.json with a session-start and a session-end hook): devstack hook session-end --agent claude-code from repo/apps/web printed nothing and wrote one record; devstack hook session-start in repo printed the start text, then The previous session in this working tree (session s1, transcript C:/t/s1.jsonl) ended at 2026-11-06T15:33:40+01:00. What follows was meant for its end: and the end text; a second start printed only the start text.
  • lane-stop is covered by unit tests (texts_for), not run against a real lane stop.
  • cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, tests of devstack-node, devstack-hub, devstack-skills and the devstack binary green.

Note: #477 changes how lane stop finds its lane in dispatch/lane.rs; client::lane_stop keeps its signature, so the two merge without a conflict in logic.

Closes #462

🤖 Generated with Claude Code

A pool's skill can give text at the end of the work. A lane-stop text
follows the output of `devstack lane stop` and the MCP tool lane_stop, for
the lane's worktree. A session-end text is kept when Claude Code ends a
session and given once at the next start of the same agent in the same
working tree, with a line naming the ended session. Codex reports no end
of a session and gets none. A hub now skips a hook of an event it does not
know instead of all hooks of the skill; the coordinator stays strict.

Closes #462

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@7schmiede
7schmiede force-pushed the feat/hooks-session-end branch from 943d61d to 366da26 Compare November 6, 2026 14:58
@7schmiede
7schmiede merged commit 31da5f4 into main Nov 6, 2026
@7schmiede
7schmiede deleted the feat/hooks-session-end branch November 6, 2026 15:06
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.

Hooks: an end-of-session event (lane-stop output, session-end deferred to the next start)

1 participant