Skip to content

Memory Phase 3 — SessionStart Inject Hook

Section titled “Memory Phase 3 — SessionStart Inject Hook”

Closed the last deferred piece of KB-OS Memory v1: inject hardened from documented convention into an actual mechanism.

  • ~/ai-config/claude/hooks/session-start-inject.sh (SSOT; deploys to ~/.claude/hooks/) — a Claude Code SessionStart hook that silently injects a frozen-for-the-session snapshot:
    • Biggest Rocks table rows from Core/DASHBOARD.md
    • Open (non-✅) bullet lines from Core/_WorkingOn/Tasks/_active.md
    • Capped at 2000 chars, truncated at a line boundary, most-important-first
    • Only fires on source: startup or clear (skips resume/compact as no-ops)
    • Recursion-guarded (KB_SESSION_INJECT env var)
    • Backgrounds a detached qmd update so recall is fresh from the first query — never blocks session start
  • Registered as SessionStart in ~/ai-config/claude/settings.wsl.json, alongside the existing Stop/Notification/SessionEnd blocks.

The task’s design assumed session-digest.sh was already “SSOT in ai-config, deploys via deploy.sh” — it wasn’t. It had been hand-placed directly in ~/.claude/hooks/, was untracked by git, and deploy.sh had no hooks-copying step at all. Fixed per the SSOT hard rule (migrate first, then point):

  • Migrated session-digest.sh into ai-config/claude/hooks/ (verified byte-identical via diff before removing reliance on the old copy)
  • Added a hooks/ copy step to deploy.sh (WSL section)

Both hooks are now version-controlled and deploy correctly on every ai-config commit.

  • Fixture stdin tests: source: startup → valid JSON, additionalContext populated, contains Biggest Rocks + open tasks, capped at 1924/2000 chars (truncation triggered correctly, cut at a line boundary after the top-level Active section).
  • source: resume / source: compact → silent no-op, exit 0, no stdout.
  • Recursion guard (KB_SESSION_INJECT=1) → silent no-op.
  • bash -n syntax check on both scripts.
  • Live smoke test against the deployed copy post-commit — same result as the fixture test.
  • Not yet verified: the task’s own acceptance test (a genuinely fresh top-level session asking “what were we working on?” unprompted) — that can only be proven the next time Talbot starts a session, not from inside this one.

ai-config 6f86d15feat(hooks): SessionStart inject hook — Memory Phase 3

  • KB-OS-Context §3 (Inject row: convention → mechanism) + §5 (moved from Active tasks → Shipped ✅)
  • STATUS.md Active Work