mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-11 15:39:04 +02:00
The preamble writes event:'started' to the project timeline at every skill start, but the matching 'completed' write lives in prose at the END of the skill workflow — unenforceable. An interrupted session, a context blowout, or an agent that simply stops leaked started > completed forever, and the leak was unrepairable after the fact (observed live in #2553). New hosts/claude/hooks/timeline-stop-hook (+ .ts, question-log-hook shim pattern): on Claude Code's Stop event it appends event:'completed' with outcome 'unknown' and source 'stop-hook' for every 'started' entry in the project timeline that has no matching completion. setup registers it via gstack-settings-hook add-event (Stop was already an accepted event) under its own source tag, idempotently; --no-team and gstack-uninstall remove it. FAIL-OPEN contract (F5), pinned by tests: ALWAYS exits 0 — corrupt timeline (bad lines skipped individually, valid ones still repaired), missing timeline, garbage/empty stdin, bun missing from PATH (the shim '|| true's), and an over-cap timeline (10MB skip) all repair nothing and block nothing; errors land in ~/.gstack/hook-errors.log best-effort. The write path is append-only with a ~2s internal budget, and a second Stop is a no-op (already-closed entries never re-close). Correlation is project-scoped by design — the preamble's session id is shell-local, so a concurrent same-project session's entry may close early as a traceable source:'stop-hook' row rather than a silent leak; the header documents the trade-off. Fixes #2553 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
11 lines
447 B
Bash
Executable File
11 lines
447 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Bash shim — Claude Code hooks run `command` strings via /bin/sh, so this
|
|
# wrapper makes the TypeScript hook executable via bun. Settings.json
|
|
# references this file directly.
|
|
#
|
|
# FAIL-OPEN (F5): a Stop-event telemetry repair must never block the session.
|
|
# Every failure path — bun missing, script crash — still exits 0.
|
|
HERE="$(cd "$(dirname "$0")" && pwd)" || exit 0
|
|
bun "$HERE/timeline-stop-hook.ts" || true
|
|
exit 0
|