Skip to content

prepare-commit-msg hook not executed after session restart (ended → idle) #411

@hyunjae-labs

Description

@hyunjae-labs

Hi Entire team,

Thank you for creating such a useful tool for tracking AI agent sessions. I've encountered what appears to be a bug in version 0.4.4 and wanted to report it with detailed reproduction steps and evidence.

Summary

The prepare-commit-msg hook is not executed when a session restarts from "ended" state, causing checkpoint creation to fail.

Environment

  • Entire CLI Version: 0.4.4 (2f0ad9a)
  • OS: Linux (WSL2)
  • Claude Code: 2.1.44
  • Strategy: auto-commit

Bug Behavior

Expected

When a Claude Code session is active and a git commit is made:

  1. prepare-commit-msg hook executes
  2. entire hooks git prepare-commit-msg is called
  3. Entire-Checkpoint trailer is added to commit message
  4. Event is logged to .entire/logs/entire.log

Actual

After a session transitions from "ended" → "idle":

  1. prepare-commit-msg hook executes (Git side)
  2. But entire hooks git prepare-commit-msg produces no output
  3. No Entire-Checkpoint trailer added
  4. No event logged to .entire/logs/entire.log

Reproduction Steps

Step 1: Setup

cd /home/devuser/projects/atlas
entire status
# Output shows: Active Session 2c4172e4

Step 2: Session State Transitions (from entire.log)

2026-02-18 00:32:09 - SessionStop (idle → ended)
2026-02-18 00:32:20 - SessionStart (ended → idle)  ← Session restarted!

Step 3: Git Commit After Restart

# Time: 00:33:00 (10 seconds after session restart)
git add . && git commit -m "feat: some feature"

Step 4: Check Results

# Check commit
git log -1 --format=fuller
# ❌ No Entire-Checkpoint trailer

# Check entire.log
grep "prepare-commit-msg" .entire/logs/entire.log | tail -1
# Last event: 23:45:53 (BEFORE session restart)
# No event at 00:33:00

Evidence

Timeline Analysis

Atlas Project (.entire/logs/entire.log):

23:45:53 - prepare-commit-msg executed ✅
          (last event before session restart)

00:32:09 - SessionStop (idle → ended)
00:32:20 - SessionStart (ended → idle)

00:44:25 - Git commit
00:45:39 - Git commit
00:46:32 - Git commit
00:48:30 - Git commit
00:58:27 - Git commit
01:00:51 - Git commit
          ❌ NO prepare-commit-msg events

11:06:01 - Git commit
11:06:25 - Git commit
11:06:50 - Git commit
11:07:25 - Git commit
          ❌ NO prepare-commit-msg events

Total: 10 git commits after session restart, 0 prepare-commit-msg events

Git Commits Without Checkpoints

All commits after "ended" → "idle" transition lack Entire-Checkpoint:

git log --format="%H %ci %s" --after="2026-02-18 00:32:20" --before="2026-02-18 01:10"

c5c814b 2026-02-18 00:58:27 feat(providers): embedding provider ❌
6857040 2026-02-18 01:00:51 feat(tools): semantic search MCP tool ❌
[... 8 more commits, all missing Entire-Checkpoint]

Comparison: Normal Session

Before session restart (same project, same session ID):

23:14:00 - Git commit
23:14:00 - prepare-commit-msg executed ✅

23:22:43 - Git commit
23:22:43 - prepare-commit-msg executed ✅

23:45:53 - Git commit
23:45:53 - prepare-commit-msg executed ✅

Root Cause Analysis

SessionStart Event Difference

Normal session start ("" → "idle"):

{"event":"SessionStart","from":"","to":"idle"}
→ prepare-commit-msg works ✅

Restarted session ("ended" → "idle"):

{"event":"SessionStart","from":"ended","to":"idle"}
→ prepare-commit-msg fails ❌

Hypothesis

entire hooks git prepare-commit-msg may not recognize sessions that were restarted from "ended" state, causing it to:

  • Execute but produce no output
  • Skip checkpoint creation
  • Skip logging

Context: When Does This Happen?

This affects any workflow that causes session restarts:

  1. Ralph Loop: Uses Stop hook to restart sessions repeatedly
  2. Manual session restart: User stops and resumes work
  3. Any Stop hook that blocks session termination

Impact

  • Checkpoints not created for substantial work
  • Session history incomplete
  • entire explain shows gaps

Workaround

None found. Once a session restarts from "ended" state, all subsequent commits in that session will lack checkpoints.

Suggested Fix

Ensure entire hooks git prepare-commit-msg recognizes and handles sessions that transitioned from "ended" → "idle", not just fresh sessions.

Additional Information

System State

$ entire status
Enabled (auto-commit)

Active Sessions:
  /home/devuser/projects/atlas (master)
    [Claude Code] 2c4172e4   started 11h ago

Session IS registered but prepare-commit-msg doesn't work.

Hook Files

$ ls -la .git/hooks/prepare-commit-msg
-rwxr-xr-x 1 user user 95 Feb 18 11:33 .git/hooks/prepare-commit-msg

$ cat .git/hooks/prepare-commit-msg
#!/bin/sh
# Entire CLI hooks
entire hooks git prepare-commit-msg "$1" "$2" 2>/dev/null || true

Hook file is correct and executable.

Manual Hook Test

$ echo "test" > /tmp/msg.txt
$ .git/hooks/prepare-commit-msg /tmp/msg.txt "message"
$ cat /tmp/msg.txt
test

# No trailer added
# No log entry created

Even manual execution fails after session restart.


I can provide full .entire/logs/entire.log and session transcripts if needed for debugging. Please let me know if you need any additional information.

Thank you for looking into this issue!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions