claude-skills/engineering/agent-memory/hooks/hooks.json
Claude 9f2c50e285
fix(agent-memory): address automated review; harden the session-id fallback
Five of six findings were real. Verified each against the code rather than
taking them at face value; one was wrong and is noted below.

1. validate_examples.py carried a stale header from the spec-only phase --
   "PARKED AS AN ASSET (deliberately not .py yet)... ON IMPLEMENTATION: rename
   to skills/agent-memory/scripts/validate_examples.py". The file is already at
   exactly that path. Rewritten to describe what it now is, keeping the
   substantive part: why it exists, the seven check families, why it compares
   the doc's algorithm by source text rather than exec()-ing a code fence, and
   that nothing runs it automatically.

2. Missing shebang -- added. The same finding also claimed mode 100644; that
   half is wrong, `git ls-files -s` shows 100755 for all five scripts.

3. hooks.json's description still opened "CONTRACT ONLY -- the referenced
   scripts are not yet implemented", true of none of them now. Trimmed to keep
   only the UserPromptSubmit provisionality (9.5 is genuinely still open) and
   to record the measured latency alongside it.

4. The session-id fallback was the finding worth the most. `session_id` is the
   right key -- engineering/security-guidance's shipped hook reads the same one
   -- but the fallback was the CONSTANT "unknown-session", and sessions dedupe
   by value. Had the key ever been absent, every session would collapse onto
   one id, len(set(sessions)) would plateau at 1, and every claim would cap at
   L1 forever with no error anywhere. Now falls back to the transcript's own
   basename, which IS the session id. Verified end-to-end with session_id
   omitted from the payload: the atom records the real session UUID.

5. Dead `now` parameter on _eligible_l1 -- removed.

6. marketplace.json metadata still said 104 agents / 120 slash commands,
   pre-existing drift on a line this branch already edits. Trued up to 110/130.

Re-verified after: 69 checks 0 failures, SKILL.md 6/6 PASS, both blocking gates
still fire by name, check_paths 620 files clean, counters and plugin-json pass,
all 5 scripts --help, all 3 hooks parse.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EM5xmJ7AmTMg31rq68BCym
2026-08-24 18:45:52 +00:00

39 lines
2.1 KiB
JSON

{
"description": "Three hooks implementing the L0-L3 memory tiers. SessionStart injects L3 (global persona) + L2 (current project context). UserPromptSubmit recalls relevant L1 atoms. SessionEnd asynchronously captures L0 into L1, detects contradictions, and stages promotions for human adoption. PROVISIONAL ENTRY: the UserPromptSubmit hook is not a settled part of the design. DESIGN.md section 9.5 is an open decision whose option (c) is to drop it entirely, because its 100ms recall budget is dominated by python interpreter cold-start rather than by any work the script does. Measured on the implementation machine: spawn-to-exit p50 29ms / p95 31ms / max 35ms, of which the scoring pass over 500 atoms is 2-3ms -- so the budget IS met there, but one machine is not a portability claim and the decision stays open. SessionStart and SessionEnd are not provisional. Every hook fails open (exit 0, no memory) and never blocks. Disable individually with AGENT_MEMORY_SESSIONSTART=0, AGENT_MEMORY_USERPROMPTSUBMIT=0, AGENT_MEMORY_SESSIONEND=0. NOTE ON THE RECALL TIMEOUT: the hook 'timeout' field below is in SECONDS and 1 is its floor, so it is only a backstop against a wedged process. The real requirement is the 100ms internal self-budget that user_prompt_submit.py enforces against its own monotonic clock, returning whatever it has when the budget expires. See DESIGN.md section 5.2 -- finishing under 1s does NOT satisfy the spec.",
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/session_start.py\"",
"timeout": 5
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/user_prompt_submit.py\"",
"timeout": 1
}
]
}
],
"SessionEnd": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/session_end.py\"",
"async": true
}
]
}
]
}
}