Skip to content

Commit 1394293

Browse files
committed
docs: update DESIGN.md with 3 git hooks and session lifecycle
1 parent 5846efa commit 1394293

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

docs/knowledge/DESIGN.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,15 @@ Injected via the `prepare-commit-msg` git hook, which reads the active session I
269269

270270
### Git hooks for commit integration
271271

272-
Two git hooks handle all commit-related operations:
272+
Three git hooks handle commit integration and notes sharing:
273273

274274
| Git hook | When | What it does |
275275
|---|---|---|
276-
| `prepare-commit-msg` | Before commit message editor opens | Reads `.git/agentnote/session`, appends `Agentnote-Session` trailer to message file |
277-
| `post-commit` | After commit succeeds | Calls `recordCommitEntry()` to write session data as a git note on HEAD |
276+
| `prepare-commit-msg` | Before commit message editor opens | Checks session freshness via heartbeat, appends `Agentnote-Session` trailer. Skips amend/reuse (`$2=commit`). |
277+
| `post-commit` | After commit succeeds | Reads session ID from the finalized trailer on HEAD, calls `agentnote record <session-id>` to write git note. Idempotent — skips if note already exists. |
278+
| `pre-push` | Before push to remote | Auto-pushes `refs/notes/agentnote` to the actual remote (`$1`) in background. Recursion-guarded via `AGENTNOTE_PUSHING` env var. |
278279

279-
These replaced the previous approach of using AI agent PreToolUse/PostToolUse hooks to detect `git commit` commands via pattern matching, which was fragile with chained commands (`git add && git commit`).
280+
Session freshness is verified via per-session heartbeat file (`sessions/<id>/heartbeat`). Stop writes `0` to heartbeat for immediate invalidation. Missing heartbeat in git hooks = skip (fail closed).
280281

281282
### Git hook installation
282283

0 commit comments

Comments
 (0)