Skip to content

fix(init): PostToolUse matcher omitted ReportFindings, so review evidence was never recorded (item 610) - #788

Merged
getappz merged 1 commit into
masterfrom
task/610-completion-gate-s-review-evidence-can-ne
Sep 21, 2026
Merged

getappz merged 1 commit into
masterfrom
task/610-completion-gate-s-review-evidence-can-ne

Conversation

@getappz

@getappz getappz commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

What

Fixes agentflare item 610 (a tracker item, not a GitHub issue): the completion gate's review evidence could never be recorded, so item done / check_merge was unsatisfiable for every caller.

Root cause

The PostToolUse matcher written for hook post-tool-use did not name ReportFindings, so the harness never ran the hook for that tool. hook_completion_gate::post_tool_use already handles is_review_completion, but it was never invoked, so last_review stayed unset and completion_gate_reason always failed its review check. The review half of the gate landed with tests that call post_tool_use directly, which bypasses the matcher, so nothing caught it.

Changes

  • src/init.rs: build the matcher in one place (post_tool_use_matcher()) from the same constants the hook branches on. It now includes ReportFindings, plus the ctx_shell and gateway tool names the hook also handles.
  • add_hook_entry now rewrites a stale matcher on an already-wired entry instead of skipping it, so existing installs pick up the widened matcher.
  • New test wire_claude_code_post_tool_use_matcher_covers_every_tool_the_hook_handles pins the matcher to the hook's tool names so the two cannot drift again.
  • src/hook_redirect.rs: GATEWAY_TOOL_NAME made pub(crate) so the matcher can reuse it. src/optimize/runtime.rs: small supporting change (8 lines).

Notes for review

  • Existing installs get the corrected matcher the next time agentflare init runs; until then their ~/.claude/settings.json keeps the old one.
  • The matcher now also names the ctx_shell and gateway tools. That goes slightly beyond the item text but follows its "cover every tool the hook branches on" requirement; please confirm it is intended.
  • The optional doctor/startup warning for a stale matcher is not included.
  • Not run locally by the person opening this PR; CI is the check.

Opened by claude-code for item #610 (pushed from a PM session because the agent's own job was orphaned by a daemon restart).

Summary by CodeRabbit

  • Bug Fixes
    • Updated existing Claude hook configurations when their matchers are outdated.
    • Expanded tool-hook matching to consistently cover gateway, review completion, item, shell, and mutating tool actions.
    • Preserved unrelated hooks while refreshing only the relevant configuration.
    • Improved recognition of review-completion actions so related hooks trigger consistently.

…ence was never recorded (#610)

The installed matcher for 'hook post-tool-use' did not name ReportFindings,
so the harness never ran the hook for it and last_review stayed unset --
'item done' was unsatisfiable. Build the matcher from the same constants the
hook branches on (adding ReportFindings and the ctx_shell/gateway names),
have add_hook_entry rewrite a stale matcher on an already-wired install, and
pin matcher-vs-hook coverage with a test.

Agentflare-Agent: claude-code
Agentflare-Branch: task/610-completion-gate-s-review-evidence-can-ne
Agentflare-Item: 610
Agentflare-Session: 0cc647e2-235a-450f-aabb-4e8fd8c75259
@getappz

getappz commented Sep 21, 2026

Copy link
Copy Markdown
Owner Author

Tracking this PR for automated review (flared:c997d745ae66).

@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: getappz/agentflare/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: 3f40d783-1506-432b-bc8a-02712c91eb25

📥 Commits

Reviewing files that changed from the base of the PR and between 4423c7f and 9c4e86d.

📒 Files selected for processing (3)
  • src/hook_redirect.rs
  • src/init.rs
  • src/optimize/runtime.rs

Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.


📝 Walkthrough

Walkthrough

The change shares tool identifiers, centralizes the Claude PostToolUse matcher, refreshes stale matching hook entries, and adds tests for coverage and preservation of unrelated hooks.

Changes

Claude hook matcher synchronization

Layer / File(s) Summary
Shared tool identifiers
src/hook_redirect.rs, src/optimize/runtime.rs
GATEWAY_TOOL_NAME is crate-visible. REVIEW_COMPLETION_TOOL is shared and set to "ReportFindings".
Matcher construction and hook updates
src/init.rs
PostToolUse matching now includes gateway, review-completion, item, shell, and mutating tools. Existing matching entries update when their matcher differs. Claude wiring uses the centralized matcher.
Matcher synchronization tests
src/init.rs
Tests verify matcher coverage, stale matcher updates, and preservation of unrelated or existing entries.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: correcting the PostToolUse matcher to include ReportFindings so review evidence is recorded.
Description check ✅ Passed The description provides a clear summary, root cause, implementation details, risks, backward-compatibility notes, and validation status. It does not use the template headings or list the requested te…
Docstring Coverage ✅ Passed Docstring coverage is 90.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 3 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

@getappz
getappz merged commit 8ee1473 into master Sep 21, 2026
18 checks passed
@getappz
getappz deleted the task/610-completion-gate-s-review-evidence-can-ne branch September 21, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant