Skip to content

feat(session-flow): count guardrails hook blocks per arm in the resume-eval report - #17918

Merged
kyle-sexton merged 3 commits into
mainfrom
feat/resume-eval-hook-blocks
Nov 21, 2026
Merged

kyle-sexton merged 3 commits into
mainfrom
feat/resume-eval-hook-blocks

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #17874

Summary

Resume-eval readers keep the owner's guardrails hooks loaded (R5). Until now, a reader that a
guardrails hook refused (block-cd-prefix.sh in the #17677 smoke test) was graded as a plain
denied tool calls: ['Bash'] non-delivery. This PR gives that case its own result and counts it
per arm.

Fix

  • exclusion_reason returns the new hook-blocked kind when every permission denial's
    tool_use_id matches a tool result carrying a PreToolUse hook refusal. Any denial left
    unmatched keeps the run a plain denied. Evidence that a hook refusal lands in
    permission_denials under the same id: the smoke1-before run 1 reader events, where
    refusal toolu_01Rm2eWtM485WSWBgDjBvSwX appears in the first result's permission_denials.
  • How the hook is named: <plugin> PreToolUse:<tool>: <refusal line>, for example
    guardrails@melodic-software PreToolUse:Bash: BLOCKED: Run \git -C ...`. Claude Code's refusal text names the plugin and the event, and its bracket lists every guard the hook ran, not only the one that refused. The refusal line is what identifies the guard, which is block-cd-prefix.sh` here.
  • A hook-blocked row carries hook_blocked next to nondelivery, so it scores no accuracy.
    Every reader row also records hook_blocks, the hooks that refused any of its calls,
    whether or not the run delivered.
  • The report prints N hook-blocked, a hook refused a call in K runs on each group line and on
    a new per-pair hooks line.
  • Gate change: hook-blocked runs no longer count toward the non-delivery rate or
    --nondelivery-margin, per the issue's "apart from the accuracy and non-delivery rates"
    (owner: keep the hook, count it). A format that pushes more readers into a hook now shows up
    on the hooks line instead of failing the non-delivery gate.

Verification

  • uv run --no-project --with pytest python -m pytest -q plugins/session-flow/scripts/harness/:
    238 passed.
  • New tests: a reader transcript carrying the real block-cd-prefix.sh refusal text is
    hook-blocked under the hook's name. Mixed and unmatched denials stay denied. A refusal the
    reader recovered from still delivers. The report counts hook-blocked runs apart from
    non-delivery.
  • hook_blocks run over the two real refused after-arm transcripts from the smoke test returns
    the guardrails block-cd-prefix refusal for each.

Related

🤖 Generated with Claude Code

…e-eval report

A reader whose every permission denial matches, by tool use id, a plugin
PreToolUse hook's refusal is now hook-blocked, named by the hook's plugin,
event and refusal line, instead of a plain denial. Every reader run records
the hooks that refused its calls. The report prints hook-blocked runs and
runs with any hook refusal per group and per pair, apart from accuracy and
the non-delivery rate.

Closes #17874

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T10:20:49.558293Z a88ecdf PR opened
ℹ️ 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: a88ecdf054

ℹ️ 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".

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-refine/fix-docs

Run 44893418079, attempt 1

Field Value
Model rung 0
Leg handoff
Run job success
Activity step success
Commits pushed none (read lane)
Run 44893418079

Failed GitHub API calls

No failed call recorded by the run job's scripts.

A follow-up turn that a hook refused was classified hook-blocked while its
refusal never reached `hook_blocks`, so the report could print
"1 hook-blocked, a hook refused a call in 0 runs". The follow-up events now
travel with the exclusion and count with the main turn's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 6a8c8e5e2619f65a56de3c011aa2114a1551af63: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Security review (incremental, blocking only): no security issues found

Scope: this review covers only what changed since a37fb832, the head this lane last reviewed. I read every hunk of the three changed files in the incremental diff:

  • plugins/session-flow/evals/resume-eval.md
  • plugins/session-flow/scripts/harness/resume_eval.py
  • plugins/session-flow/scripts/harness/test_resume_eval.py

None of the three matches a trusted-path glob. This lane already reviewed an earlier head, so the review was blocking only: it would report only CRITICAL and IMPORTANT findings.

What changed:

  • exclusion_reason takes a new hooks flag.
  • exclusion sets that flag only when the source is in READER_TURNS (Source.READER, Source.FOLLOW_UP). A writer refused by a PreToolUse hook therefore stays a plain denied result instead of being classed hook-blocked.
  • The eval doc says the same thing in words, and a new unit test covers the follow-up case and the writer case.

Why this raises no security concern:

  • The change only narrows how the eval harness labels its own local runs. Its inputs are the eval's own run events.
  • None of those values reaches a shell, a path, a URL or an evaluated expression.
  • It touches no tokens, secrets, workflows, permissions, trusted actors, kill switches, merge holds, plugin manifests or standing instructions. The doc edit adds a scoping detail and removes no rule.

Spend: nothing new beyond the eval's current usage.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 6a8c8e5e2619f65a56de3c011aa2114a1551af63: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #17918, incremental (a37fb83 → 6a8c8e5)

This review covers only what changed since the last one: resume-eval.md, resume_eval.py and test_resume_eval.py. This lane already reviewed an earlier head, so it reports blocking findings only.

The earlier blocking finding is fixed. It said writer refusals were also being classed as hook-blocked.

  • exclusion() now passes hooks=source in READER_TURNS to exclusion_reason (resume_eval.py#L815, #L829-L836).
  • READER_TURNS holds Source.READER and Source.FOLLOW_UP.
  • exclusion_reason returns Kind.HOOK_BLOCKED only when that flag is set (#L934).

So a writer is now always a plain Kind.DENIED when a hook refuses its call. That covers the interrupt, focus, resume, owner-turn and main writer calls at L1178–L1328. A refused writer is therefore never marked hook_blocked, and it stays in the non-delivery rate as it did before this PR. The flag defaults to False, which keeps the direct exclusion_reason callers in the tests unchanged.

The doc change at resume-eval.md L153–L154 states the same rule: readers' main turns and follow-ups only, and a writer refused this way stays a plain denial. The new test_only_the_readers_turns_are_hook_blocked checks three things:

  • A refused follow-up is HOOK_BLOCKED.
  • A refused writer is DENIED with cause BEHAVIOR.
  • mark_excluded on that writer sets nondelivery and no hook_blocked.

Inside the hook-blocked branch, the local hooks = sorted(...) reuses the parameter's name. It runs only after the check and returns at once, so behaviour is unaffected. It is not a blocking issue.

Closing-issue criteria (#17874): all three are still met and tested, as in earlier rounds:

  • The hook-blocked kind is recorded with the hook's name.
  • The report prints per-arm counts.
  • A test covers a reader transcript with a block-cd-prefix.sh refusal.

The owner's "239 harness tests pass" is their claim; I did not run the tests.

Settled thread (follow-up refusals in hook_blocks, original line 1642): it was fixed at a37fb83. This push does not reopen it.

Other notes:

  • Loosened checks: the prompt gave no loosened_check_verdict:, loosened_check_patterns: or decision-record lines. I used fail with no consumer entries and did not check the citation requirement. This push loosens no check: it narrows when hook-blocked applies.
  • Manifests: this push changes no plugin manifest.
  • Spend: none. The push adds no runs or model calls.

Verifier dropped 0 of 0 candidates.

`exclusion_reason` is shared by every stage, so a writer refused by a hook
was also marked hook-blocked and left the non-delivery gate. Only the
reader's main turn and follow-up are now hook-blocked; a writer refused
this way stays a plain denial and still counts as non-delivery.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton

Copy link
Copy Markdown
Member Author

claude-review finding (hook-blocked catches writer refusals): correct. Fixed in 6a8c8e5. Only the reader's main turn and follow-up can be hook-blocked now (exclusion_reason(..., hooks=source in READER_TURNS)). A writer refused by a hook stays denied and still counts as non-delivery. The follow-up's refusals also count toward hook_blocks (a37fb83), so the two counts agree. New test test_only_the_readers_turns_are_hook_blocked; 240 harness tests pass.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit f53c921 Nov 21, 2026
45 checks passed
@kyle-sexton
kyle-sexton deleted the feat/resume-eval-hook-blocks branch November 21, 2026 10:42
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(session-flow): count guardrails hook blocks per arm in the resume-eval report

1 participant