Skip to content

Repository files navigation

hook-master banner

Tests Version Python Platform Privacy Security Consent Gate Notice Contributing Code of Conduct LLM-Guidance Code Style: Ruff Ecosystem Umbrella LLM-Ready Level 1 SBOM Verified Security SLA

hook-master

Languages: English · Deutsch

Note

This repository ships an llms.txt discovery file for AI agents and LLMs.

Local-first pointer registry and one-way materialization for agent hooks (Claude Code, Codex, Kimi, Antigravity, ...). Built as an architectural sibling to policy-registry — sharing the same pointer-only registry mechanic and optional system-gap-master transport while operating 100% standalone without network access. Because hooks are executable code rather than static text, hook-master adds an explicit, fail-closed deploy/diff/status materialization pipeline and a diagnostics doctor engine.


Quick Navigation

  1. Overview & Core Identity
  2. Target Personas & High-Intent SEO Queries
  3. Comparative Matrix vs. Alternatives
  4. Governance & Runtime Invariants Matrix
  5. Visual Architecture Topology
  6. End-to-End Execution & Lifecycle Sequence
  7. Quick Start & Common Workflows
  8. Entry Model & Pointer Specifications
  9. CLI Command Reference
  10. Hook-Doctor Diagnostic Engine
  11. First-Use Consent Gate & Allowlist (HE2)
  12. Optional Transport & Adapters
  13. Sibling Tools & Ecosystem Matrix
  14. Security Policy & Vulnerability SLAs
  15. Machine-Readable LLM Context
  16. Testing, Verification & Quality Gates
  17. Third-Party Licenses & Level 1 SBOM
  18. Statutory Notice, Liability Limitation & License (§ 521 BGB)

1. Overview & Core Identity

A hook registered in one agent's configuration can silently depend on a file that lives in a different agent's private directory. Prior to hook-master, Codex's ~/.codex/hooks.json pointed its PreToolUse guard straight at C:/Users/<user>/.claude/hooks/guards.py — a private Claude-Code path Codex has no business depending on directly.

hook-master fixes this coupling across all agent runtimes:

  1. Canonical Home (library/): Hook scripts live in a single canonical repository, pinned by SHA-256 digests.
  2. Pointer Registry: Knows every target agent consuming each hook and their target config files.
  3. One-Way Materialization: Copies canonical scripts to wherever each agent's configuration expects them (canonical → deployed, never reverse).
  4. First-Use Consent Gate: Blocks unconsented hook materialization by default (fail-closed security).
  5. Doctor Engine: Detects hash mismatches, syntax errors (py_compile), target config invalidity, and mtime drift.

2. Target Personas & High-Intent SEO Queries

hook-master is specifically architected to serve four distinct developer and operator personas:

[PERSONA-01] Autonomous AI Agent & Multi-Node Swarm Architects

  • Profile: Engineers orchestrating multi-agent systems across Claude Code, OpenAI Codex, Antigravity, Kimi, and local Ollama runtimes.
  • High-Intent Search Queries: agent hook management, multi agent hook registry, claude code hooks json isolation, cross-agent hook synchronization.
  • How hook-master Solves It: Eliminates brittle cross-agent path references by establishing a unified metadata registry and deterministic deployment pipeline.

[PERSONA-02] Local-First, Zero-Egress & Air-Gapped Tool Builders

  • Profile: Developers creating offline-capable developer tools and privacy-first automation environments.
  • High-Intent Search Queries: offline agent hook registry, zero-egress hook deployer, local-first script materialization, no network agent guard.
  • How hook-master Solves It: 100% offline execution with zero network sockets, zero telemetry, and zero third-party runtime dependencies.

[PERSONA-03] Multi-Agent Infrastructure & DevOps Engineers

  • Profile: Platform engineers responsible for workstations, developer fleet configuration parity, and preventing silent script drift.
  • High-Intent Search Queries: agent hook drift detection, fail-closed hook allowlist, prevent hook tampering, agent script integrity check.
  • How hook-master Solves It: The hook-doctor engine detects file modification time anomalies, syntax errors, and cryptographic hash divergence.

[PERSONA-04] Enterprise Safety, Governance & Compliance Officers

  • Profile: Compliance auditors and enterprise security officers requiring verifiable execution controls and clear supply-chain provenance.
  • High-Intent Search Queries: agent hook security consent gate, RunAsInvoker agent hooks, level 1 sbom hook manager, audited agent tooling.
  • How hook-master Solves It: Enforces an explicit first-use consent allowlist (allowlist.json), unprivileged user-mode execution, and Level 1 SBOM transparency.

3. Comparative Matrix vs. Alternatives

The following matrix compares hook-master against four common industry alternatives across ten critical architectural and governance dimensions:

Invariant / Feature Ad-Hoc Config Edits Cross-Directory Symlinks Generic Shell / Git Hooks Heavy Daemon / Webhooks hook-master (Our Solution)
INV-LOCAL-01 100% Local-First & Zero Egress Partial Yes Yes No (requires network) PASS (100% Offline)
INV-SEC-02 Unprivileged User Execution Yes No (requires admin on Win) Yes No (service elevation) PASS (RunAsInvoker)
INV-PTR-03 Pointer-Only Registry No (inline bodies) No (raw symlinks) No No (opaque database) PASS (Pointers Only)
INV-EXEC-04 Executable Trust Class Separation No No No Partial PASS (Cryptographic SHA-256)
INV-MAT-05 One-Way Materialization No (bidirectional chaos) No (two-way mutation) No Partial PASS (Canonical -> Deployed)
INV-CONSENT-06 Fail-Closed Consent Gate No No No Complex RBAC PASS (allowlist.json Gate)
INV-DOC-07 Deep Doctor Diagnostics None None (silent breakage) Manual Telemetry Heavy PASS (AST, Hash, Drift)
INV-TRANS-08 Optional Transport Independence N/A N/A N/A Hard Network Lock-in PASS (Decoupled Adapters)
INV-LIC-09 Zero Copyleft Dependency Footprint N/A N/A N/A Heavy Dependencies PASS (Zero Runtime Deps, MIT)
INV-SLA-10 Contractual 48h Security SLA None None None Commercial Only PASS (Binding 48h SLA)

4. Governance & Runtime Invariants Matrix

hook-master enforces ten immutable design invariants that govern its execution, storage, and lifecycle:

Invariant Code Name Architectural Commitment Verification Mechanism
INV-LOCAL-01 100% Local-First & Zero-Egress Operates entirely on the local filesystem without network sockets or telemetry. Zero network imports, verified by test suite.
INV-SEC-02 Unprivileged Execution Executes under standard user permissions (RunAsInvoker) without administrative elevation. Safe filesystem permissions, non-elevated tests.
INV-PTR-03 Pointer-Only Registry registry.json stores file paths, target mappings, and hashes — never script bodies. model.py rejects script body fields.
INV-EXEC-04 Executable Trust Class Separation Treats hooks as executable code requiring cryptographic hash verification. SHA-256 digest validation on every check.
INV-MAT-05 One-Way Materialization Copies canonical source to deployed targets; never allows targets to overwrite canonical. Directional materialization in materialize.py.
INV-CONSENT-06 Fail-Closed Consent Gate Unconsented hook scripts cannot be deployed until explicitly approved in allowlist.json. Fail-closed gate in consent.py.
INV-DOC-07 Deep Doctor Diagnostics Validates canonical files, syntax executability (py_compile), and config integrity. doctor.py diagnostic engine with exit codes.
INV-TRANS-08 Optional Transport Independence Functions fully standalone; system-gap-master is purely an optional transport adapter. Graceful ImportError handling in adapters.
INV-LIC-09 Permissive Licensing Footprint 100% MIT and Python Software Foundation license stack; zero copyleft contamination. Audited Level 1 SBOM in THIRD_PARTY_LICENSES.md.
INV-SLA-10 48h Security Response SLA Public commitment to confirm security reports within 48h and complete triage in 5 days. Published SLA in SECURITY.md and README.

5. Visual Architecture Topology

Four-View Architectural Topology Projection

+-------------------------------------------------------------------------------+
|  VIEW 1: CALLER RUNTIMES, AGENT CLIENTS & ENTRYPOINTS                         |
|  - Agent Execution Runtimes: Claude Code, OpenAI Codex, Antigravity, Kimi Code |
|  - Lifecycle Hook Triggers: PreToolUse, UserPromptSubmit, SessionStart, PostTool|
|  - Developer CLI Suite: hook-master (register, deploy, diff, status, doctor)  |
|  - CI/CD Quality Gates & Automated Regression Test Suites                     |
+---------------------------------------+---------------------------------------+
                                        | invokes CLI / triggers hooks
                                        v
+-------------------------------------------------------------------------------+
|  VIEW 2: HOOK-MASTER SOVEREIGN ENGINE & DISPATCH ORCHESTRATOR                 |
|  - Manifest Parser & Entry Model Validator: hook_master.model (JSON Schema)   |
|  - Fail-Closed Consent Evaluator: hook_master.consent (allowlist.json, HE2)   |
|  - Deterministic One-Way Materializer: hook_master.materialize (one-way copy) |
|  - Cryptographic Digest Engine: SHA-256 integrity verification (hash parity)  |
|  - Diagnostic Doctor Suite: hook_master.doctor (syntax, mtime drift, configs) |
+---------------------------------------+---------------------------------------+
                                        | registers / validates & audits
                                        v
+-------------------------------------------------------------------------------+
|  VIEW 3: RUNTIME PERSISTENCE, POINTER REGISTRY & AUDIT LEDGER                 |
|  - Canonical Script Storage: library/*.py (immutable source of truth)        |
|  - Pointer Registry Ledger: ~/.hook-master/registry.json (pointers only)    |
|  - Cryptographic Consent Allowlist: ~/.hook-master/allowlist.json (HE2 state) |
|  - Target Agent Manifests: ~/.claude/hooks/, ~/.codex/hooks.json, ~/.gemini/  |
|  - Level 1 SBOM Companion Ledger: THIRD_PARTY_LICENSES.txt (Stand 2026-10-01) |
+---------------------------------------+---------------------------------------+
                                        | bounds / verifies & protects
                                        v
+-------------------------------------------------------------------------------+
|  VIEW 4: AIR-GAP DEFENSE PERIMETER, RUNASINVOKER & ZERO-EGRESS BOUNDARY       |
|  - 100% Local-First Offline Operation & Zero Network Sockets (INV-LOCAL-01)   |
|  - Unprivileged Non-Elevation Security Policy (INV-SEC-02, RunAsInvoker)     |
|  - Pointer-Only Storage Invariant (INV-PTR-03, zero inline executable bodies) |
|  - Strict One-Way Materialization Boundary (INV-MAT-05, no backward drift)    |
|  - Zero-Copyleft Isolation Guarantee: 100% MIT & Python Standard Library     |
|  - Statutory Notice § 521 BGB Gefälligkeitsrecht & 48h Security Response SLA  |
+-------------------------------------------------------------------------------+

System Architecture Flow

graph TD
    subgraph "Canonical Source Storage"
        CANON["Canonical Scripts (library/*.py)<br/>Immutable & SHA-256 Pinned"]
    end

    subgraph "Core Registry & Policy Engine"
        REG["hook-master Registry<br/>(~/.hook-master/registry.json)<br/>Pointer & Target Mapping"]
        ALLOW["Consent Allowlist (HE2)<br/>(~/.hook-master/allowlist.json)<br/>Fail-Closed Deployment Gate"]
        DOC["Hook-Doctor Engine<br/>Hash Parity & Syntax Check<br/>Drift & Runtime Timing"]
    end

    subgraph "Materialization & Delivery"
        MAT["One-Way Materializer<br/>deploy / diff / status"]
    end

    subgraph "Consumer Agent Environments"
        CLAUDE["Claude Code Target<br/>(~/.claude/hooks/)"]
        CODEX["Codex Target<br/>(~/.codex/hooks.json)"]
        AGY["Antigravity / Kimi Target<br/>(~/.gemini/hooks/)"]
        EXT["External Consumers<br/>(memoryhooker / workflowhooker)"]
    end

    subgraph "Optional Seams"
        SGM["system-gap-master Seam<br/>(adapters/system_gap.py)"]
        SYNC["Sync Hooks Adapter<br/>(.SYNC/hooks/)"]
    end

    CANON -->|"SHA-256 Hash"| REG
    REG -->|"Registered Pointers"| MAT
    ALLOW -->|"Explicit Approval Gate"| MAT
    DOC -.->|"Diagnostics & Drift Check"| MAT
    DOC -.->|"Syntax Compile Check"| CANON
    MAT ==>|"One-Way Deployment Copy"| CLAUDE
    MAT ==>|"One-Way Deployment Copy"| CODEX
    MAT ==>|"One-Way Deployment Copy"| AGY
    REG -.->|"Pointers Only"| EXT
    REG -.->|"Optional Transport"| SGM
    REG -.->|"Optional View Export"| SYNC
Loading

6. End-to-End Execution & Lifecycle Sequence

Materialization & Deployment Sequence

sequenceDiagram
    autonumber
    actor Dev as "Developer / Agent"
    participant CLI as "hook-master CLI"
    participant Reg as "Registry Store"
    participant Gate as "Consent Gate (HE2)"
    participant Mat as "Materializer"
    participant Target as "Agent Config / File"
    participant Doc as "Hook-Doctor"

    Dev->>CLI: "hook-master register entry.json"
    CLI->>Reg: "Store metadata (hash, source uri, targets)"
    Reg-->>CLI: "Entry registered (pending-consent)"

    Dev->>CLI: "hook-master deploy"
    CLI->>Gate: "Check consent state for target"
    Note over Gate,CLI: "Fail-closed: unconsented hooks are blocked"
    Gate-->>CLI: "Status: pending-consent (Skipped)"

    Dev->>CLI: "hook-master consent <hook-id>"
    CLI->>Gate: "Grant consent (allowlist updated)"
    Gate-->>CLI: "Consent recorded"

    Dev->>CLI: "hook-master deploy"
    CLI->>Gate: "Check consent state"
    Gate-->>CLI: "Status: consented (Approved)"
    CLI->>Mat: "Copy canonical -> deploy_path"
    Mat->>Target: "Write materialized hook script"
    Target-->>Mat: "File written"
    Mat-->>CLI: "Deployment complete (in-sync)"

    Dev->>CLI: "hook-master doctor"
    CLI->>Doc: "Verify canonical hash & py_compile"
    Doc->>Target: "Check mtime drift & target config validity"
    Doc-->>CLI: "Report health verdict (ok / warning / error)"
Loading

Runtime Guard Interception & Execution Sequence

sequenceDiagram
    autonumber
    actor LLM as "AI Agent (Claude / Codex / Kimi / Antigravity)"
    participant Runtime as "Agent Runtime (PreToolUse / UserPromptSubmit)"
    participant Guard as "Materialized Hook Guard (library/*.py)"
    participant State as "Local Security & Governance State"
    participant Tool as "Protected Host Tool / File System"

    LLM->>Runtime: Request Tool Call (Edit / Write / apply_patch / Bash)
    Runtime->>Guard: Invoke Interception Hook (stdin / args JSON)
    Note over Guard,State: 100% Offline Zero-Egress Boundary
    Guard->>State: Inspect Lock Status & Security Invariants
    alt Active Lock or Invariant Violation Detected
        State-->>Guard: Lock Active or Forbidden Operation
        Guard-->>Runtime: Fail-Closed Denial (Exit Code 2 or JSON Deny)
        Runtime-->>LLM: Blocked - Operation Denied with Explanation
    else Safe Execution Approved
        State-->>Guard: No Active Lock or Invariant Satisfied
        Guard-->>Runtime: Allow Execution (Exit Code 0 or JSON Allow)
        Runtime->>Tool: Execute Authorized Tool Operation
        Tool-->>Runtime: Tool Results Delivered
        Runtime-->>LLM: Complete Tool Output Returned
    end
Loading

7. Quick Start & Common Workflows

# 1. Install in editable mode
pip install -e .

# 2. Initialize default registry (~/.hook-master/registry.json)
hook-master init

# 3. Register a hook definition
hook-master register my-hook.json

# 4. Verify canonical file hashes against registry
hook-master verify

# 5. Review consent status & grant deployment consent
hook-master consent-status
hook-master consent my-hook-id

# 6. Deploy canonical scripts to registered target paths
hook-master deploy

# 7. Check deployment status and drift
hook-master diff
hook-master status

# 8. Run deep system diagnostics
hook-master doctor --timing

For Codex sessions using PowerShell on Windows, generated commandWindows entries invoke quoted executable paths with the call operator &. Bare commands such as python -m ... keep their existing form. Executable paths containing spaces are quoted automatically. These shell rules apply only to Codex; Claude and Kimi retain their provider-specific syntax. Review changed hook definitions again through Codex /hooks before using them.

Generated commandWindows entries also keep the native exit code. Codex runs Windows hooks through pwsh -Command, which reports every non-zero exit as 1. Codex treats exit 1 as a failed hook and runs the tool call anyway, so a guard that blocks with exit 2 has no effect (measured with codex-cli 0.160.0). The generated form is $global:LASTEXITCODE = 0; <command>; $hookOk = $?; if ($LASTEXITCODE) { exit $LASTEXITCODE }; if (-not $hookOk) { exit 1 }. Hand-written Codex configurations need the same wrapper. The alternative is a guard that prints {"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "deny", "permissionDecisionReason": "..."}} on stdout and exits 0. Check the result with a harmless blocked command: the Codex log must show hook: PreToolUse Blocked, not Failed.


8. Entry Model & Pointer Specifications

Every registry entry is metadata only — never executable script text (model.py rejects content/body/script_text fields outright). Two distinct kinds:

  • kind: "hook" — a concrete script. source.kind: "canonical" means the script lives in this module (source.uri + source.hash, SHA-256). Each targets[] entry names an agent, its config_path, and (for canonical hooks) a deploy_path — the materialized copy's location.
  • kind: "consumer" — a registered module that owns its own hook registration logic entirely (currently: memoryhooker, workflowhooker, both via source.kind: "external-module"). hook-master catalogues that it exists and which agents/events it covers; it never re-implements or wraps the consumer's own logic.

There is also a reserved, still-unevaluated optional doctor object per entry (exec_check, mtime_policy, allowlist) — schema-validated for shape but not read by anything. Do not confuse it with the actual Hook-Doctor + Consent-Allowlist feature ("HE2"), which ships in this release and lives entirely outside that field — see the next sections.


9. CLI Command Reference

Command Effect
init Create an empty registry at the default (or --registry) path
register <entry.json> Add or replace one metadata entry
list / get <id> / search [query] Query and inspect the registry
verify Hash-check every canonical entry's source file
deploy [--id <id>] [--dry-run] Copy canonical → deploy_path for matching consented entries
diff [--id <id>] Read-only: report in-sync / drifted / not-deployed without writes
status verify + diff combined reporting
import-sync --root <dir> --slot <slot> One-time migration: pull kind=consumer pointers from .SYNC/hooks/adoption/<slot>.json
export-sync-view --root <dir> --slot <slot> Optional: publish a metadata-only view into .SYNC/hooks/registry/<slot>.json
doctor [--id <id>] [--timing] Comprehensive diagnostics beyond verify/diff (checks hashes, syntax, drift, configs). Exit 0/1/2
consent <id> [--by <name>] [--note <text>] Grant deploy consent for one entry
consent-status [<id>] Display consent state for one or all entries
install-snippet --id <id> --provider claude|codex|kimi|agy [--script <path>] [--python <exe>] Print (never install) the hook configuration fragment for a canonical script; --id lock_edit_guard is the lock-master edit guard (see below)

Canonical Hook Library Catalog (library/)

hook-master ships a curated collection of standalone, zero-egress canonical hook scripts located in the library/ directory. Each hook is cryptographically hashed with SHA-256 upon registration:

Script Event Trigger Supported Agents Security Role & Function
guards.py PreToolUse Claude Code, Codex Base security fencing & file edit guard preventing unsafe mutations
lock_edit_guard.py PreToolUse Claude Code, Codex, Kimi Fencing connector delegating file edits to lock-master with fail-closed denial contracts
python_exec_guard.py PreToolUse Codex Defends against literal Python script execution via Windows shell file association, enforcing explicit Python interpreter flags
token_budget_guard.py UserPromptSubmit Claude Code, Antigravity Adaptive token budget and context window monitoring with 4-mode Sparmodus/Notaus state machine
token_budget_statusline.py StatusLine Claude Code Zero-egress status line renderer formatting active token consumption and budget tiers
notaus_wake_check.py SessionStart / PreInvocation All Agents Emergency stop state preservation and wake check verifying unblocked operational status
precompact_state.py PreCompact Claude Code, Antigravity Preserves critical runtime state snapshots before agent context window resets
starter_pack_hook.py SessionStart All Agents Injects bootstrap instructions and profile chains without external dependencies
backslash_guard.py PreToolUse Claude Code Stops Bash commands whose backslash content would be silently destroyed in transit (Windows paths, doubled backslashes)
mcp_update_daily_check.py SessionStart Claude Code Runs the MCP update check at most once a day in the background and reports the last result at session start

Backslash Guard for Claude Code (backslash_guard)

library/backslash_guard.py blocks Bash tool calls that contain \\ or a drive path with a backslash (C:\...).

  • Measured hazard (Claude Code Bash tool on Windows, 2026-11-07): the tool turns \\ into \ before bash runs, also inside '...' and <<'EOF'. Python then turns \r, \t, \n, \a, \b, \f in ordinary string literals into control characters without a warning, so C:\work\repos becomes C:\work<CR>epos. Doubling never protects. The PowerShell tool does not halve. Other hosts are not measured.
  • Remedy in the block message: write paths with /, put backslash content into a file with the Write tool, or use the PowerShell tool. # backslash-ok in the command bypasses the guard on purpose.
  • Fail-open: exit 2 with the reason on stderr only for a match; any internal error exits 0. It prevents silent data corruption and is not a security boundary.

Daily MCP Update Check (mcp_update_daily_check)

library/mcp_update_daily_check.py replaces the placeholder echo 'MCP update check done', which reported a check that never ran. The first real run on 2026-11-13 was red.

  • What it does: starts mcp_npm_check.py read-only (never --apply) at most once per 20 h as a detached background process, because the check takes about a minute. At session start it prints one line with the last finished result, separating locally outdated packages (fixed by --apply), MCP registry entries behind npm (publication pending) and repo versions that differ from npm (release pending).
  • Check script lookup: env MCP_UPDATE_CHECK_SCRIPT, then ../scripts/mcp_npm_check.py next to the hook, then ~/OneDrive/.SYNC/scripts/mcp_npm_check.py.
  • State and limits: host-local in ~/.claude/mcp_npm_check/, never in a synced folder. The result is replaced atomically after the run; a run is cut off after 900 s.
  • Fail-open: every error becomes one text line with exit 0; the hook never breaks session start. --selftest checks the report line, --run runs the check synchronously.

Codex Python Execution Guard (python_exec_guard)

library/python_exec_guard.py is a specialized PreToolUse guard for Codex running on Windows PowerShell and Command Prompt. It prevents accidental invocation of .py script files via Windows shell file association (e.g., executing script.py directly instead of python -X utf8 script.py).

  • Hazard Prevention: Direct shell execution of .py files on Windows bypasses interpreter flags (such as -X utf8 or environment flags) and may spawn detached interactive console windows.
  • AST and Command Token Analysis: Parses shell commands, PowerShell call operators (&), nested quotes, and here-strings to identify literal .py target files.
  • Fail-Closed Blocking: If an unhandled literal script execution is detected, the guard exits with code 2 and writes clear remediation instructions to stderr.

Token Budget & Sparmodus Guard (token_budget_guard)

library/token_budget_guard.py intercepts UserPromptSubmit events to enforce token budgets across 4 explicit operating modes:

  • off: Purely advisory warnings as token consumption crosses configured thresholds (kurztext_used_pct, sparmodus_used_pct).
  • auto-spar: Armed monitoring mode for high-load sessions; escalates to notaus if limits are exceeded and auto-recovers when reset.
  • manual-spar: Manually triggered conservative mode; automatically reverts to off once token budget fully resets.
  • notaus: Complete operational brake; halts further token consumption until the reset timestamp is reached (wake_at), preserving prior state.

Lock edit guard for Claude, Codex and Kimi (lock_edit_guard)

library/lock_edit_guard.py is the edit-side counterpart of lock_push_guard.py (push protection, repository-root locks). It is only a connector: it finds lock-master's plugin/lock_guard.py and runs it with the same arguments, so all lock semantics (file locks, fencing, team-board claims, apply_patch and Kimi file targets, the denial contract per host) live in lock-master and nowhere else. Because it executes what it finds, it only looks in places that belong to the user: ELLMOS_LOCK_MASTER (repository, plugin directory or the file; an explicit decision, not checked further), then the Claude Code plugin cache (~/.claude/plugins/cache/**/ellmos-lock-master/*/, newest version) and ~/_Local_DEV/repos/lock-master. Everything but the variable must lie under the home directory; on POSIX the file and every folder up to home must also be owned by the user and not writable by group or others. Drive roots (C:/_Local_DEV/...) are deliberately not searched, because other accounts can create folders there on Windows; on a host whose clone lives at a drive root, set ELLMOS_LOCK_MASTER (or rely on the plugin cache). On Windows the restriction to the user profile is the check: with the Windows defaults it is not writable for other standard accounts, and an owner-SID comparison would need Win32 calls without extra protection. If nothing is found it says so on stderr and exits 0, like the plugin's own launcher (the check is then inactive, and loudly so).

install-snippet --id lock_edit_guard --provider <p> prints the fragment (it never edits a host configuration). git push stays with lock_push_guard, so there is no Bash matcher:

Provider Tools the hook is bound to Denial
claude Edit, Write, MultiEdit, NotebookEdit JSON permissionDecision: deny
codex apply_patch (paths from the patch headers) exit code 2, reason on stderr (on Windows only with an exit-code-preserving commandWindows, see section 7)
kimi Write, Edit (names in the tool schema of Kimi Code CLI 0.14.2, field path), WriteFile, StrReplaceFile, DeleteFile, MoveFile exit code 2, reason on stderr
agy not possible: agy only has PreInvocation (before the model call, no tool target); install-snippet refuses with that reason n/a
hook-master install-snippet --id lock_edit_guard --provider codex

Aliases lock_guard and lock-guard resolve to the same entry. The commands use python -X utf8 "<library path>" pretooluse --actor <host>; pass --script to point at a deployed copy (for example ~/.codex/hooks/lock_edit_guard.py).

Why PreToolUse is not in the default snippets: hook_snippet() of the Claude and Codex providers asserts it never emits PreToolUse (forbidden_events; workflowhooker states the event is reserved for hard guards). It runs before every matching tool call and can block it, so it is only produced by an explicit call (pretooluse_blocker_snippet(), script_snippet(), install-snippet --id guards|lock_edit_guard), never as a side effect of registering a consumer. Shell commands are not parsed for file targets: a Bash/Shell write is not covered. The Kimi names were read from the tool schema of the installed Kimi Code CLI 0.14.2 (Write and Edit with path, shell tool Bash with command); the older WriteFile family stays bound. The fragment does not bind Kimi's Bash (no lock_push_guard for Kimi yet; adding Bash to the matcher would let the guard cover git push, proposal only).


10. Hook-Doctor Diagnostic Engine

Concept rebuild after the Hermes-Agent pattern (hermes doctor-style diagnostics + first-use consent allowlist), not a code takeover.

hook-master doctor [--id <id>] [--timing] goes beyond verify/diff:

  • For every kind=hook entry: verifies canonical-file existence, SHA-256 hash integrity, syntax executability (py_compile for .py sources), materialization state, and mtime drift (detecting direct edits to deployed copies that bypass canonical source).
  • For every target: validates that referenced agent configuration files (settings.json, hooks.json, config.toml) exist and parse cleanly.
  • kind=consumer entries (memoryhooker, workflowhooker) receive configuration parsing checks.
  • Exit severity: 0 (ok), 1 (warning), 2 (error). --timing benchmarks py_compile compilation duration.

11. First-Use Consent Gate & Allowlist (HE2)

Stored at ~/.hook-master/allowlist.json (or via HOOK_MASTER_ALLOWLIST_PATH):

  • A newly registered kind=hook entry is not materialized by deploy() until explicitly consented; it reports pending-consent and is left untouched.
  • Fail-Open Read: Missing or unparseable allowlist degrades gracefully to "nothing consented" without crashing the CLI.
  • Fail-Closed Gate: Deploy decisions treat any unconsented entry as strictly forbidden.
  • Grandfathered entries from the initial release are seeded as consented_by: "grandfathered" with full auditability.

12. Optional Transport & Adapters

adapters/system_gap.py only activates if system_gap_master is importable. The registry — and every command above — works fully offline and standalone without it, adhering to architectural decision D-20260728-001 ("system-gap-master is only an optional transport adapter"). A single-machine setup with no .SYNC folder at all is a fully supported configuration, not a degraded one.


13. Sibling Tools & Ecosystem Matrix

hook-master integrates cleanly with the broader ellmos-ai and open-bricks architecture:

Repository Role & Architectural Scope Organization
policy-registry Architectural sibling — pointer-only registry for rules and policies ellmos-ai
memoryhooker Registered consumer — long-term memory capture and retrieval hooks ellmos-ai
workflowhooker Registered consumer — pipeline interception and workflow lifecycle hooks ellmos-ai
system-gap-master Optional transport — multi-agent system diagnostics & gap auditing ellmos-ai
source-resolver Role-to-provider routing & capability resolution engine ellmos-ai
lock-master Centralized concurrency locks and multi-agent coordination ellmos-ai
ticket-master Ticket tracking and inter-agent task handoff protocol ellmos-ai
coma Local job-file protocol and agent-process start/status lookup; separate from hook registration, consent, and script materialization. ellmos-ai
DevCenter Developer workspace & centralized tooling launcher dev-bricks
CodeBox Isolated sandbox execution environment for agent scripts dev-bricks
open-bricks Umbrella organization coordinating open-source modules open-bricks

14. Security Policy & Vulnerability SLAs

Security is an architectural pillar of hook-master:

  • Zero-Egress & Local-First: Operates strictly within local process and filesystem boundaries.
  • Unprivileged User-Mode (RunAsInvoker): Never requires or requests administrative elevation.
  • Fail-Closed Consent Gate: Ensures no hook script is deployed without explicit user consent.
  • Cryptographic Pointers: Every hook is pinned by its SHA-256 hash.
  • Contractual Vulnerability SLAs: Binding commitments to acknowledge vulnerability reports within 48 hours and provide triage assessments within 5 business days via [email protected] and [email protected]. See SECURITY.md for full policy details.

15. Machine-Readable LLM Context

This repository provides a standardized llms.txt file at the repository root. Automated agents, LLM toolchains, and RAG pipelines can consume this index to understand CLI syntax, architectural constraints, key file locations, and security boundaries without ingesting unnecessary repository bloat.


16. Testing, Verification & Quality Gates

The test suite validates both functional execution and architectural contracts:

# Run full contract and unit test suite
pytest

# Enforce strict code formatting and linting
ruff check .

# Validate bytecode compilation
python -m compileall -q src tests

# Verify git whitespace hygiene
git diff --check

Detailed contribution protocols, quality gates, and Plan D local development workflows are specified in CONTRIBUTING.md.


17. Third-Party Licenses & Level 1 SBOM

hook-master maintains a complete Level 1 Software Bill of Materials (SBOM) in THIRD_PARTY_LICENSES.md and plain-text companion THIRD_PARTY_LICENSES.txt.

  • Core Runtime: 100% Python Standard Library (PSFL-2.0), zero external runtime packages.
  • Optional Adapters: Permissive MIT-licensed integrations.
  • Zero Copyleft: Strictly zero GPL, AGPL, or restrictive copyleft dependencies.
  • Formal Attribution: See NOTICE for copyright and organizational provenance.

18. Statutory Notice, Liability Limitation & License (§ 521 BGB)

Open Source License

This software is licensed under the terms of the MIT License. Formal ecosystem attribution and origin notices are declared in NOTICE. Detailed Level 1 SBOM and dependency transparency records are available in THIRD_PARTY_LICENSES.md and THIRD_PARTY_LICENSES.txt.

German Statutory Notice & Liability Limitation (§ 521 BGB Gefälligkeitsrecht)

The provision of this software and its associated documentation is gratuitous (unentgeltliche Bereitstellung). In accordance with the statutory liability regime under German Civil Law governing gratuitous services (§ 521 BGB — Haftung des Schenkers), liability for any defects of quality or title (Sach- und Rechtsmängel) is strictly limited to cases of intentional misconduct (Vorsatz) and gross negligence (grobe Fahrlässigkeit). Any broader statutory warranty or tortious liability for slight negligence is expressly excluded to the fullest extent permitted by applicable law.