Skip to content

fix(guard): count Grok use_tool recalls as consults; run the freshness gate in every harness (#472, #473) - #474

Merged
CryptoJones merged 2 commits into
mainfrom
fix/grok-claude-hook-consult
Oct 10, 2026
Merged

CryptoJones merged 2 commits into
mainfrom
fix/grok-claude-hook-consult

Conversation

@CryptoJones

Copy link
Copy Markdown
Owner

Closes #472. Closes #473. Version 10.3.1.

What

#472, Grok's Claude-hook fast path. A Grok recall arrives as use_tool with omi__recall-note nested inside, so the gate didn't treat it as a consult and denied the recall that would have cleared it. omi-guard.sh now unwraps use_tool / CallMcpTool and maps Grok built-ins (run_terminal_command → Bash, …). Edge cases handled:

  • the first non-empty inner name wins
  • JSON-string arguments are parsed
  • empty payloads are skipped

The Python translator matches this, and also translates snake_case Grok events on the Claude harness. A Grok Build session started this; this PR finishes and hardens it and adds the tests it lacked.

#473, the freshness gate only ran for tools named Bash. Antigravity (run_command), Gemini (run_shell_command), Hermes (terminal), OpenCode (bash), Poolside (shell) and Codex (exec_command, local_shell, …) commits never needed a fetch, and the repo-work and global-config checks were skipped too.

  • The adapter and guard.decide map guard.SHELL_TOOL_NAMES onto Bash.
  • guard.shell_command_text reads command / CommandLine / cmd (a string or an argv list), and both PreToolUse and the PostToolUse retraction use it.
  • The no-jq, no-core last resort fails closed for every shell name and any dispatcher.
  • Antigravity takes the repo from run_command's own Cwd.

Why

A live commit on ronin28 was blocked right after a clean fetch. The cause was the installed 10.0.2: it split git -C "<repo>" commit -m "…<newline>Co-Authored-By: …" at the newline inside the quotes, lost the -C path, and judged the commit against the hook cwd's repo. main already handles that, but no test pinned it. While adding that test across harnesses, the Bash-only gap above showed up.

Tests

  • Fetch, then a multi-line -m commit run from another repo's cwd, in all eight guarded harnesses. The commit before the fetch must be denied by the freshness gate specifically.
  • Failed-fetch retraction for every shell tool name.
  • decide() with each shell name.
  • The no-jq fallback list is pinned to SHELL_TOOL_NAMES.
  • jq/Python parity for dispatched recalls and dispatched shell commands.
  • Antigravity Cwd precedence and relative-path resolution.
  • A negative case: a non-shell tool with a command key is not mapped to Bash.

Each new test fails on the code before its fix.

Locally: ruff, mypy --strict and pip-audit are clean, and pytest gives 3949 passed. Two test_name_timelines decoy-ranking cases also fail on a clean main checkout here; they don't involve this change.

Review

A Flatline Roundtable panel reviewed the diff (GLM-5.3, Fable, Opus, Mistral Medium, DeepSeek V4, Nemotron, GPT-6-Astra). Confirmed findings are fixed in this PR: the fail-open last resort, retraction key coverage, the empty-name dispatcher, decide-level mapping, and Antigravity Cwd precedence. Deferred: stdin-style tools (Codex write_stdin, Antigravity send_command_input) that feed text to an already-running shell; that's a separate gap for a follow-up.

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

🤖 Generated with Claude Code

https://claude.ai/code/session_01GwidRobbpZsQUPJXNu4Hf2

…s gate in every harness (#472, #473)

Grok's Claude-hook fast path: omi-guard.sh unwraps use_tool / CallMcpTool (first non-empty inner name, JSON-string arguments parsed, empty payloads skipped), accepts camelCase, and maps Grok built-ins onto Claude names. The Python translator does the same, and translates snake_case Grok events on the Claude harness. Started by a Grok Build session; finished and hardened here.

The commit freshness gate and the other Bash-only checks matched the tool name Bash only, so Antigravity, Gemini, Hermes, OpenCode, Poolside and Codex shell tools skipped them. The adapter and guard.decide map guard.SHELL_TOOL_NAMES onto Bash, the command is read from command / CommandLine / cmd (string or argv list) on PreToolUse and in the PostToolUse retraction, and the no-jq no-core last resort fails closed for every shell name and dispatcher. Antigravity takes the repo from run_command's Cwd.

Regression tests: fetch, then a multi-line -m commit from another repo's cwd, in every guarded harness (omind 10.0.2 lost the git -C at the newline and blocked the commit). Reviewed by the Flatline Roundtable panel; its confirmed findings are fixed here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GwidRobbpZsQUPJXNu4Hf2
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 16b54ac0-386b-428e-9e23-c04698126136

📥 Commits

Reviewing files that changed from the base of the PR and between 35ecd40 and 3825dd1.


📒 Files selected for processing (1)
  • tests/test_harness.py

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 62d9d21a-fd3c-4772-9a4f-d2d0c3b45f56


📥 Commits

Reviewing files that changed from the base of the PR and between 387873f and 35ecd40.



⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock


📒 Files selected for processing (13)
  • BACKLOG.md
  • CHANGELOG.md
  • README.md
  • pyproject.toml
  • src/omind/__init__.py
  • src/omind/adapters.py
  • src/omind/guard.py
  • src/omind/harness.py
  • src/omind/omi-guard.sh
  • tests/test_adapters.py
  • tests/test_grok_client.py
  • tests/test_guard.py
  • tests/test_harness.py


Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📜 Recent review details
⏰ Context from checks skipped due to timeout. (20)
  • GitHub Check: test (ubuntu-latest, 3.12)
  • GitHub Check: test (windows-latest, 3.14)
  • GitHub Check: test (windows-latest, 3.10)
  • GitHub Check: test (ubuntu-latest, 3.11)
  • GitHub Check: Upgrade from latest (ubuntu-latest)
  • GitHub Check: Upgrade from v9.4.0 (ubuntu-latest)
  • GitHub Check: Wheel build + install smoke test (ubuntu-latest)
  • GitHub Check: test (macos-latest, 3.14)
  • GitHub Check: Upgrade from v9.4.0 (macos-latest)
  • GitHub Check: test (macos-latest, 3.10)
  • GitHub Check: Upgrade from latest (windows-latest)
  • GitHub Check: Wheel build + install smoke test (macos-latest)
  • GitHub Check: test (ubuntu-latest, 3.10)
  • GitHub Check: Upgrade from latest (macos-latest)
  • GitHub Check: test (ubuntu-latest, 3.14)
  • GitHub Check: Upgrade from v9.4.0 (windows-latest)
  • GitHub Check: test (ubuntu-latest, 3.13)
  • GitHub Check: MCP conformance (live stdio)
  • GitHub Check: Secret scan (gitleaks, full history)
  • GitHub Check: Analyze (python)


🧰 Additional context used
📚 Code guidelines (2)
CONTRIBUTING.md — auto-discovered
BACKLOG.md — auto-discovered

📓 Path-based instructions (2)
Source excerpt: The version is declared in three places that must stay in lockstep — `pyproject.toml`, `src/omind/__init__.py`, and `uv.lock` — and a test asserts `__version__` matches `pyproject.toml`, so a release can't leave one behind.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • pyproject.toml
  • src/omind/__init__.py
  • CHANGELOG.md

Source excerpt: This file and the GitHub **[Issues tab](https://github.com/CryptoJones/omind/issues)** are two views of the same list and must stay in sync.

📄 CodeRabbit inference engine (BACKLOG.md)

Files:

  • BACKLOG.md

🪛 ast-grep (0.45.3)
tests/test_adapters.py

[info] 740-740: use jsonify instead of json.dumps for JSON output
Context: json.dumps(body)
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)


[info] 769-769: use jsonify instead of json.dumps for JSON output
Context: json.dumps(event)
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)


tests/test_grok_client.py

[info] 111-111: use jsonify instead of json.dumps for JSON output
Context: json.dumps({"name": "Rules"})
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)


tests/test_guard.py

[info] 1510-1510: use jsonify instead of json.dumps for JSON output
Context: json.dumps({"name": _RULES})
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)


[info] 1588-1588: use jsonify instead of json.dumps for JSON output
Context: json.dumps({"command": _DISPATCHED})
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)


🪛 markdownlint-cli2 (0.23.3)
CHANGELOG.md

[warning] 12-12: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 54-54: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)




🔇 Additional comments (13)
BACKLOG.md (1)

82-93: LGTM!


CHANGELOG.md (1)

10-62: LGTM!


README.md (1)

674-677: LGTM!


src/omind/harness.py (1)

400-440: LGTM!

Also applies to: 474-480, 494-506, 521-524, 548-562, 582-583


src/omind/omi-guard.sh (1)

47-51: LGTM!

Also applies to: 58-110


tests/test_grok_client.py (1)

108-146: LGTM!


tests/test_guard.py (1)

1126-1140: LGTM!

Also applies to: 1335-1373, 1493-1623, 2618-2648


pyproject.toml (1)

3-3: LGTM!


src/omind/__init__.py (1)

5-5: LGTM!


src/omind/adapters.py (1)

56-62: LGTM!

Also applies to: 97-98


src/omind/guard.py (1)

514-535: LGTM!

Also applies to: 563-565, 1328-1345, 4680-4683


tests/test_adapters.py (1)

682-803: LGTM!


tests/test_harness.py (1)

11-12: LGTM!

Also applies to: 369-397





📝 Summary

Summary by CodeRabbit

  • New Features
    • Grok and Claude-hook events now recognize wrapped tool calls and OMI recall consults.
    • Shell commands from supported harnesses now receive consistent safety and repository-freshness checks, including when commands use multiline commit messages.
    • Antigravity command events now resolve working directories from tool-call paths, including relative paths.
  • Bug Fixes
    • Improved handling of empty dispatcher fields and fallback blocking when event details are incomplete.
  • Documentation
    • Updated hook setup guidance and release notes for version 10.3.1.
📝 Summary

Walkthrough

This release updates Grok event normalization and applies shell-command checks across supported harnesses. It also resolves Antigravity command directories from tool-call arguments and adds regression tests for cross-harness commit freshness.

Changes

Grok event handling

Layer / File(s) Summary
Normalize Grok hook and dispatcher events
src/omind/omi-guard.sh, src/omind/harness.py, tests/test_grok_client.py, tests/test_guard.py, README.md, CHANGELOG.md, BACKLOG.md
The hook and Python translator handle Grok dispatcher payloads, including camelCase and snake_case fields and JSON-string arguments. Dispatcher calls can be unwrapped to their inner tool and arguments. Tests cover recall consults, terminal commands, and unchanged ordinary Claude events. Documentation records the shipped changes.

Cross-harness shell checks

Layer / File(s) Summary
Apply shell checks across harnesses
src/omind/adapters.py, src/omind/guard.py, src/omind/harness.py, tests/test_adapters.py, tests/test_guard.py, tests/test_harness.py, pyproject.toml, src/omind/__init__.py, CHANGELOG.md, BACKLOG.md
Recognized harness shell tools map to Bash when a command is present. Shared command extraction accepts strings and argument lists; freshness outcomes use the same shell-tool names. Antigravity resolves command Cwd values, including relative and JSON-quoted paths. Tests cover fetch-then-commit behavior and repository selection. The project version changes to 10.3.1.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium



Merge Risk: ⚪ Minimal · up to 35ecd

No confirmed issue remains that should block merging after normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 73.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 45 functions across 9 files. (4 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the two primary changes: Grok use_tool recalls count as consults, and freshness checks run across harnesses.
Description check Passed The description directly explains issues #472 and #473, the implementation changes, test coverage, validation results, and deferred scope.
Linked Issues check Passed The PR addresses the coding requirements in [#472] and [#473]. The Grok path unwraps use_tool and CallMcpTool, selects the first non-empty inner payload, parses JSON-string arguments, and translat…
Out of Scope Changes check Passed The changes remain within [#472] and [#473]. Source changes implement event translation, shell-tool normalization, command extraction, fallback behavior, freshness handling, and Antigravity directory …


Full details: Docstring Coverage

Explanation

Docstring coverage is 73.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 45 functions across 9 files. (4 skipped: 4 unsupported.)




✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR



🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR



  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…Windows)

On Windows /w/repo is drive-relative, so the code correctly treated it as relative to the workspace root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GwidRobbpZsQUPJXNu4Hf2
@CryptoJones
CryptoJones merged commit 8901566 into main Oct 10, 2026
23 checks passed
@CryptoJones
CryptoJones deleted the fix/grok-claude-hook-consult branch October 10, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant