โ Before โ "did the agent ship?"
$ git -C platform log --oneline -5
$ git -C platform reflog | head -5
$ git -C platform log -1 --format='%cI %s'
$ gh pr list --repo y/p --head feat/x
$ gh pr checks 3703 --repo y/p
$ ls ~/.claude/projects/-โฆ/sessions/
โฑ 6 tool calls ยท 200+ lines ยท context bloated
Operator hesitates โ late detection โ bigger blast
โ
After
$ cat ~/.claude/state/orchestkit/platform/*.json
{
"repo": "platform",
"status": "running",
"last_heartbeat": "2026-05-20T17:42:14Z",
"last_commit": {
"sha": "3a99c20",
"msg": "feat(api): canonical seed-data migration"
},
"last_push": { "branch": "feat/x", "ref": "3a99c20" },
"last_pr": { "number": 3703, "url": "โฆ", "state": "open" }
}
โฑ 1 tool call ยท structured JSON ยท zero grep
What gets wired (2 hooks, 1 lib)
src/hooks/src/lib/session-state.ts โ schema + atomic I/O
src/hooks/src/posttool/bash/session-heartbeat-publisher โ PostToolUse[Bash], async
src/hooks/src/stop/session-heartbeat-finalizer โ SessionEnd, sync dispatcher
PUBLISHER fires on EVERY Bash, no-ops on non-structural commands.
Matches: git commit | git push | gh pr create|merge|ready
Writes to: ~/.claude/state/orchestkit/<repo>/<sid>.json (atomic, tmp+rename)
FINALIZER runs once at SessionEnd to mark status=completed.
If session is killed unsafely, last_heartbeat goes stale (proxy for stopped).
Fleet view (no new tool โ plain shell)
$ ls ~/.claude/state/orchestkit/*/*.json | xargs cat | jq -s \
'map({ repo, status, last_pr: .last_pr.number, last_commit: .last_commit.msg })'
[
{ "repo": "orchestkit", "status": "running", "last_pr": 1900, โฆ },
{ "repo": "portfolio", "status": "running", "last_pr": 223, โฆ },
{ "repo": "platform", "status": "running", "last_pr": 3703, โฆ },
{ "repo": "sanity-agency", "status": "completed", "last_pr": 16, โฆ }
]
Test coverage (Layer 1 + Layer 5)
Layer 1 โ Unit (real temp fs, no fs mocks):
โ session-state.ts 13 cases (path math + atomic I/O + merge)
โ session-heartbeat-publisher 16 cases (classifier + parsers + integration)
โ session-heartbeat-finalizer 5 cases (no-prior-state, mark complete, โฆ)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
34 / 34 passing
Layer 5 โ Full hook suite regression:
โ 8385 / 8385 (was 8351 before this PR)
โ Biome lint: clean
โ npm run build: green
โ ./bin/validate-counts.sh: PASSED