Engram · Configuration & integration

Hook payloads and feedback

All five harness spellings use the same JSON reader, not five independent native-payload adapters. Normalize the harness payload before invoking Engram. Session-start needs no stdin and returns Claude hookSpecificOutput with hookEventName: SessionStart and additionalContext; other harnesses receive the block as text. Pre/post-tool-use read to EOF; invalid JSON can silently do no event work and exit 0.

Input Consumed fields / semantics
Tool/session tool_name (fallback tool), session_id (fallback default-session for pre/post; use a real stable ID). --session only overrides session-end identity, not pre/post payload identity.
Arguments tool_input (fallback arguments), an object. Target: first nonblank file_path, path, Path, target_file, notebook_path.
Proposed text content, Content, new_string, Replacement, new_source; also array edits entries' new_string, Replacement, content, joined with newlines. It checks proposed fragments, not the final reconstructed file; absent proposed content does not run the compiled regex check.
Shell gate Argument command (fallback CommandLine, cmd); tool result tool_response.is_error boolean takes precedence over integer top-level exit_code. A pass requires an explicit success indicator, not merely absent error text.
Failure text Top-level output, then stderr, then tool_response.output / .stderr; used for diagnostic retrieval/trap guidance and potentially remote retrieval.

Synthetic pre-tool payload (use only an isolated fixture store):

{"session_id":"fixture-session","tool_name":"Write","tool_input":{"file_path":"fixtures/retry.txt","content":"synthetic replacement"}}

Mutating names are case-insensitive edit, multiedit, write, notebookedit, write_file, edit_file. Arbitrary shell file edits or unrecognized tool names do not receive the same pre-tool guard check. Matching scoped unread cues return 2 until recalled in that session. Guards enforce only where scope and proposed-content checks run. Missing globs use path-token relevance heuristics, not a universal filesystem policy.

Post-tool ignores passive/memory tools (including names containing engram and lux_ tools). A test-shaped command pass records immediate_gate_fix; a lint-shaped pass records non-consuming gate_accept. Recognized test substrings: phpunit, pest, cargo test, vitest, jest, pytest, go test, npm/pnpm/yarn test, artisan test, node --test, lint.py, validate-ote; also verify_*_slice.mjs and configured gate_commands. Lint substrings: cargo check/clippy, pint, phpstan, psalm, ruff, mypy, tsc, eslint. Test wins if both match. This is substring classification, not proof of which tests ran. Failed test-shaped gates label shadow observations; arbitrary successful tools do not create test evidence. Example post-tool input: {"session_id":"fixture-session","tool_name":"Bash","tool_input":{"command":"cargo test"},"exit_code":0}—supply it only after observing the actual result.

Pre-compact and turn-complete run consolidation; session-end additionally expires unused override tokens and sweeps unreferenced reaches for the explicit/payload session. They are not read-only notifications. Blocks and diagnostics can contain guidance/error material: route stdout/stderr only to authorized harness context/logs. Exit 0 after malformed/ignored input or internal fail-open does not establish that protection or learning occurred.