Skip to content

feat(hooks): add v1.8 passive capture, bounded briefings, and multi-client hook CLI - #350

Open
Coding-Dev-Tools wants to merge 10 commits into
mainfrom
feat/v1-8-passive-capture-hooks
Open

Coding-Dev-Tools wants to merge 10 commits into
mainfrom
feat/v1-8-passive-capture-hooks

Conversation

@Coding-Dev-Tools

Copy link
Copy Markdown
Owner

Summary

Implements Release 1 (v1.8) Slice 1A for zero-friction coding-agent memory adoption:

  • Design doc (EGM-reviewed): docs/designs/v1.8-passive-capture-and-hooks.md
  • Core engine (engraphis/hooks.py):
    • Bounded turn-0 build_session_briefing() routing empty queries via recall_proactive() (with unregistered-repo fallback to workspace memories) and scoped queries via recall(..., include_untrusted=False).
    • Deterministic extract_durable_candidates() and stage_passive_capture() with control-character stripping before engraphis.core.secrets fail-closed rejection/redaction, normalized-hash dedupe across active/pending/quarantined rows, and Claude Code JSONL message unwrapping + stop_hook_active loop guard.
    • Idempotent, backup-first, BOM-safe hook installers/uninstallers for Claude Code (~/.claude/settings.json), Cursor (.cursor/hooks.json, version: 1 flat lists), and Command Code (~/.commandcode/settings.json, preserving legacy cc-engraphis-session-start).
  • Package-scoped CLI (engraphis/hooks_cli.py, wired into scripts/entry.py + pyproject.toml as engraphis hooks / engraphis-hooks):
    • Lives inside engraphis/ so target repos with ./scripts/ cannot shadow hook execution.
    • Unpacks resolve_workspace() dict cleanly, bounds --hook-mode SQLite busy_timeout to 500ms, forwards full settings service parameters, and short-circuits missing DBs on read-only briefings without creating empty files.
  • Poisoning boundary (engraphis/core/poisoning.py): Registers "passive-hook" in EXTERNAL_SOURCES (review_state="pending", prompt_eligible=False).

Verification

  • pytest tests/test_hooks_and_passive_capture.py tests/test_poisoning.py tests/test_secret_hygiene.py tests/test_secrets_edge_cases.py tests/test_session_start_hook.py tests/test_install_cc_hook.py -> 126 passed, 3 skipped (Windows POSIX-only skips; 10/10 new tests pass)
  • ruff check engraphis/hooks.py engraphis/hooks_cli.py engraphis/core/poisoning.py scripts/entry.py tests/test_hooks_and_passive_capture.py -> All checks passed
  • pyright on changed module/test files -> 0 errors
  • Python 3.9 AST parity check (ast.parse(..., feature_version=(3, 9))) -> 5/5 passed

…lient hook CLI

Adds engraphis.hooks + engraphis.hooks_cli (engraphis hooks install|briefing|capture) supporting Claude Code, Cursor, and Command Code with fail-closed secret rejection, normalized-hash workspace dedupe, and external poisoning provenance.
…NL unwrapping, BOM/control-char hardening)

Unpacks resolve_workspace dict in hooks_cli, unwraps Claude Code message JSONL blocks, bounds hook busy_timeout to 500ms, falls back on unregistered repo, strips control chars before secret scan, and adds CLI/BOM/Cursor tests.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-29T11:50:56.603446Z
We couldn’t complete this review. Comment @codex review to try again.
2b43344 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 06c55504c2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engraphis/hooks.py Resolved
Comment thread engraphis/hooks.py Resolved
…, and CodeQL gates

Register engraphis-hooks in scripts/smoke_entry_points.py, remove em dashes from
docs/designs/v1.8-passive-capture-and-hooks.md, rename the non-sensitive counter
local variable in engraphis/hooks.py to clear CodeQL py/clear-text-logging-sensitive-data,
and regenerate the SHA-256 bound offline benchmark evidence artifact and charts.
…closed on missing provenance

Resolve installed hooks to the sibling engraphis-hooks wrapper or the absolute
engraphis/hooks_cli.py file path (never adding CWD to sys.path), refuse symlinked
settings/backup paths with O_CREAT|O_EXCL atomic backup creation, fail closed in
build_session_briefing when provenance is missing, and refresh offline evidence.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad37888a5a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engraphis/hooks_cli.py Resolved
Comment thread engraphis/hooks_cli.py Resolved
…neural embedder on queryless hooks

Address all 4 review findings: respect explicit max_chars < 120, fall back to workspace
recall on ValidationError for unregistered repos, skip embed_model load on queryless
SessionStart briefings, and guard embed_dim=None.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9568de37cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engraphis/hooks.py Resolved
…ure security

Register Cursor passive capture on afterAgentResponse with workspace_roots cwd fallback and uninstall cleanup for legacy stop entries; reject shell metacharacters and quote hook commands via shlex/list2cmdline; pin hook MemoryService strictly offline (extractor/graph_extractor/retention_supervisor=none, DeterministicQueryPlanner, read_only=True for briefing); bound stdin/file/transcript reads with O_NOFOLLOW and gate hook-mode stdin on isatty; check parent symlinks; short-circuit capture before opening service when no durable candidates exist; narrow Cursor entry matching; classify noop/quarantined/secret results accurately; refresh evidence and add regression tests.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Coding-Dev-Tools

Copy link
Copy Markdown
Owner Author

2-Agent Review & Optimization Summary (c319e0d0)

Reviewed HEAD: c319e0d05ce9fb9e2511e403c7690f497e8162d4
Base SHA: 7d0a2c8a2776b154cd431af944f159f31260dca3
Diff SHA-256: a6dd9a5ea1f281395a2e0e6a1c52d6b93d9f04db340bd3f56498a327705c01e0
GitHub CI snapshot: Analyze python:SUCCESS, export:SUCCESS, test + lint (full offline stack) (3.10):SUCCESS, Analyze javascript-typescript:SUCCESS, test + lint (full offline stack) (3.11):SUCCESS, test + lint (full offline stack) (3.12):SUCCESS, test + lint (full offline stack) (3.13):SUCCESS, test + lint (full offline stack) (3.14):SUCCESS, core + backends typecheck (Python 3.11):SUCCESS, encryption driver gate (Python 3.10):SUCCESS, encryption driver gate (Python 3.11):SUCCESS, encryption driver gate (Python 3.12):SUCCESS, encryption driver gate (Python 3.13):SUCCESS, encryption driver gate (Python 3.14):SUCCESS, core floor (numpy-only, Python 3.9):SUCCESS, coverage gate (Python 3.11):SUCCESS, repo hygiene gate (no stray DBs/logs):SUCCESS, Pi extension (ubuntu-latest, Python 3.10, Node 22.19.0):SUCCESS, Pi extension (windows-latest, Python 3.11, Node 24):SUCCESS, browser accessibility smoke:SUCCESS, docker smoke - path gate:SUCCESS, build + install wheel:SUCCESS, Installed journey (ubuntu-latest, mcp):SUCCESS, Installed journey (ubuntu-latest, server):SUCCESS, Installed journey (windows-latest, mcp):SUCCESS, Installed journey (windows-latest, server):SUCCESS, Installed journey (macos-latest, mcp):SUCCESS, Installed journey (macos-latest, server):SUCCESS, docker build + health smoke:SUCCESS, CodeQL:SUCCESS

Changes & Hardening

Switched Cursor passive capture to afterAgentResponse with workspace_roots fallback, hardened shell quoting (_quote_cmd_arg), pinned hook service strictly offline with read_only=True briefing and zero-candidate early exit, added 1 MiB bounded O_NOFOLLOW/S_ISREG reads + parent symlink checks + TTY guard + LIMIT 50000 lazy dedupe scan, narrowed Cursor entry matching, classified noop/quarantined/SecretDetectedError outcomes, and refreshed offline evidence (b8ef3dc6293a) + README pin.

Fresh 2-Agent Verdicts

  • b075bc6a-26b4-4cd7-9b48-7780e39c732c (Reviewer 1: Hook Correctness) -> APPROVE
  • ac1073c0-4951-4059-b631-e892427e9ff2 (Reviewer 2: Adversarial Security) -> APPROVE

Local Outside-Judge Verification

  • lint: python -m ruff check engraphis/hooks.py engraphis/hooks_cli.py engraphis/core/poisoning.py scripts/entry.py scripts/smoke_entry_points.py tests/test_hooks_and_passive_capture.py tests/test_benchmark_evidence.py tests/test_documentation_contracts.py tests/test_setup_plugin_distribution.py -> exit 0 (local worktree pr-350)
  • tests: python -m pytest -q tests/test_hooks_and_passive_capture.py tests/test_benchmark_evidence.py tests/test_documentation_contracts.py tests/test_setup_plugin_distribution.py tests/test_poisoning.py tests/test_session_start_hook.py tests/test_install_cc_hook.py tests/test_secret_hygiene.py tests/test_cli_entrypoints.py -> exit 0 (161 passed (3 Windows POSIX skips) + 106 passed + 52 passed)

Merge-Gate & Policy Flags

  • Operator policy gate: non-generated diff is ~1,730 lines (~2,473 total with evidence JSON) vs 1,500-line profile cap; requires operator size-cap override or split.
  • Touches pyproject.toml (+1 line engraphis-hooks console script).
  • Touches checksum-bound engraphis/**/*.py; re-export offline evidence if merged after another core PR.

Merge-Gate Readiness

Schema-v2 approval payload prepared (minReviewers: 2, blockers: 0, majors_open: 0); awaiting explicit operator merge authorization (merge-gate.ps1 not run).

The `briefing` command opened Store(read_only=True), which requires a
checkpointed database (mode=ro&immutable=1) and raises whenever the
MCP server or dashboard holds an active WAL. During a live coding
session `--hook-mode` swallowed that error into an empty briefing and
the manual CLI exited 1, so SessionStart context silently vanished.
`_is_missing_local_db()` already prevents creating a database on disk,
so open read-write instead.

Deduplication scanned every active row in the workspace, ignoring
repo and scope. A fact captured in repo "billing" therefore suppressed
the same invariant in repo "checkout", even though checkout cannot
recall billing. Restrict the scan to the same repo plus workspace-wide
rows, resolving the repo name to its id.

Also:

* `extract_durable_candidates` truncated to max_candidates before
  deduplication and secret filtering, so repeated tail lines could
  starve genuinely new candidates. Accept a wider scan pool and cap
  accepted writes at max_candidates instead.
* `briefing` parsed up to 64 KiB of transcript JSONL on every
  SessionStart only to discard the text. Add read_transcript=False so
  only the cwd/repo hints are extracted.
* Widen the Windows shell metacharacter guard to include ", !, ;, $ and
  the backtick, which cmd.exe interprets even inside list2cmdline
  quoting.
`.git-commit-msg.tmp` was picked up by `git add -A` in the previous
commit. It is a local scratch file and does not belong in the tree.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

`tests/test_benchmark_evidence.py` hashes every `.py` under `engraphis/`
and `eval/`, so the hooks and hooks_cli changes invalidated the committed
registry artifact and failed the whole Python matrix. Export a new
immutable artifact and repoint the test constants, README prefix,
BENCHMARKS.md name/sha, and the fixture-suite digest. The SVGs and PNGs
were regenerated from the new artifact so their embedded provenance
matches.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant