Skip to content

fix(guardrails): the foreground-wait guard refuses a Monitor tool call #18858

Backlog

Description

@kyle-sexton

Steps to reproduce

  1. In an interactive Claude Code session with the guardrails plugin enabled, call the Monitor tool with a command holding an until loop, for example until [ -s <file> ]; do sleep 60; done; echo done.

Expected behavior

The call runs. Monitor is the tool the guard's own message recommends: "Run the command with run_in_background set to true, or watch it with the Monitor tool".

Actual behavior

The call is refused with PreToolUse:Monitor hook error: [command hook 10]: BLOCKED: This until loop waits in the foreground. Run the command with run_in_background set to true, or watch it with the Monitor tool, and read the result when it finishes. (observed 2026-11-23 in the Software Factory Part Two session).

Severity

Low.

Severity justification

The refusal sends a session to the tool it then refuses; a session can wait for subagent notifications instead, so nothing is lost, but a correct wait is turned away.

Suggested fix location

  • plugins/guardrails/hooks/block-foreground-wait.sh:65-66 exits unless the tool name is Bash, and hooks.json registers the hook only under Bash|PowerShell, so how the Monitor call reached it is not known: the hook payload was not visible. First step: capture the PreToolUse payload of a Monitor call and see which tool_name and fields it carries.
  • plugins/guardrails/hooks/block-foreground-wait.test.sh has no Monitor case; add one.

Environment

Claude Code with guardrails 4.2.0 (installed cache), WSL2 Ubuntu.

session: Software Factory Part Two (workshop 08 alignment pass, ledger Q2113).

Activity

  1. added
    session-owned
    and removed
    session-owned
    on Nov 24, 2026
  2. github-actions commented on Nov 24, 2026

    @github-actions
    Contributor

    The triage sweep dispatched intake triage for this issue (dispatch 1; 2 runs that reach intake, or 6 dispatches, hand it to a maintainer).

  3. github-actions commented on Nov 24, 2026

    @github-actions
    Contributor

    Size: Small
    Complexity: Low
    Uncertainty: Knowable
    Flags: none
    Blocked by: none
    Blast radius: the guardrails foreground-wait hook test file and fixture, and the hook only if a failing case shows it must change; anyone running the plugin's PreToolUse guards.
    Reversible: yes; revert the fixture, test case or hook edit.
    Claims checked:

    1. The hook exits unless tool_name is Bash, defaulting a missing tool_name to Bash: held, plugins/guardrails/hooks/block-foreground-wait.sh:64-65.
    2. hooks.json registers the foreground-wait guard only under Bash|PowerShell: held, plugins/guardrails/hooks/hooks.json:96-131. The separate Monitor matcher runs only block-pr-poller.sh (hooks.json:141-155), so a Monitor call should not reach this guard.
    3. The block message recommends the Monitor tool: held, per the refinement's read of block-foreground-wait.sh:180-184.
      Open questions: none

    The recorded decision from the issue:

    Decision recorded. Reproduce first: capture a Monitor PreToolUse payload on the current guardrails version. If the hook already exits 0 on it, close this issue as not reproducible.

    Owner, in session 2026-11-25 ~8:21 AM EST, verbatim: "/session-flow:go-with-recommendations", accepting the refinement recommendations Q1 and Q2.

    Not decided: refinement Q3 (allow when tool_name is missing). That change makes the guard fail toward allowing, which loosens it. It returns to the owner only if the reproduction shows a payload with no tool_name reaching the Bash default at plugins/guardrails/hooks/block-foreground-wait.sh:64.
    [quote truncated; the full decision is at the link]

    #18858 (comment)

    This decision settles the open questions Q1 and Q2. Q3 stays with the owner until a reproduction shows a payload with no tool_name reaching the Bash default. The work is to capture a real Monitor payload as a fixture and add a test case that asserts the hook exits 0 on it. If it already does, the issue closes as not reproducible. No duplicate or merged fix was found.

    Automated triage. A maintainer reviews it.

  4. melodic-automation-lanes commented on Nov 24, 2026

    @melodic-automation-lanes
    Contributor

    Not admitted to the issue lane: no trusted-human acceptance criteria: a listed human must put the confirmed - [ ] criteria in the body or post them as their own comment, or, on an issue a listed human filed, intake's newest refinement comment must hold them unedited. Admission takes the issue once each of those is met, when intake triages it again (.github/actions/resolve-config/admission-rules.json).

  5. melodic-automation-lanes commented on Nov 24, 2026

    @melodic-automation-lanes
    Contributor

    Refinement. A read-only run explored this repository, searched its issues and pull requests, and read the allowed docs to draft what follows. On an issue a listed human filed, it counts as the issue's spec once posted, while unedited; it is still model text, so check it.

    Intended outcome: A Monitor tool call holding an until loop is no longer refused by the foreground-wait guard, with a test case for it.

    Related work

    Open questions

    1. How does a Monitor call reach this hook? hooks.json registers it only under the Bash|PowerShell matcher, so the reproduction path is unknown and the fix cannot be specified until it is.
      RECOMMENDED: Capture a Monitor PreToolUse payload first. If the tool_name is Monitor, it came through a matcher or runner path that should be fixed. If tool_name is absent, the default to Bash at line 64 is the cause. Basis: plugins/guardrails/hooks/block-foreground-wait.sh:64-65
    2. Is the defect still present? The report was seen on guardrails 4.2.0 and the checkout is 4.4.0. The Bash|PowerShell matcher and the Bash-only check are both present in 4.4.0.
      RECOMMENDED: Treat it as unconfirmed on 4.4.0. Require a failing test (a Monitor payload that the hook must allow) before the fix, and close the issue as not reproducible if the payload already exits 0. Basis: plugins/guardrails/.claude-plugin/plugin.json:255
    3. If the payload has no tool_name, should the guard keep treating it as Bash? The line 64 default fails toward blocking for a missing field. That sits badly with the hook's stated fail-open posture.
      RECOMMENDED: Allow when tool_name is missing or is not exactly Bash, and add Monitor and missing-tool_name cases to block-foreground-wait.test.sh. Basis: plugins/guardrails/hooks/block-foreground-wait.sh:32-34

    Sources read

    • plugins/guardrails/hooks/block-foreground-wait.sh:60-65: reads .tool_name and defaults to Bash when it is missing, then exits unless it equals Bash
    • plugins/guardrails/hooks/block-foreground-wait.sh:180-184: the block message recommends the Monitor tool
    • plugins/guardrails/hooks/hooks.json:96-131: the foreground-wait guard runs inside the Bash|PowerShell matcher group via run-guards
    • plugins/guardrails/hooks/block-foreground-wait.test.sh:17-22: the test helper builds only tool_name Bash payloads, and there is no Monitor case
    • plugins/guardrails/.claude-plugin/plugin.json:255: the checkout is at guardrails 4.4.0, not the reported 4.2.0

    To answer, post a comment that starts with this line:

    **Decision recorded.** <answer>
    

    Automated refinement by the lanes App. Answer with a comment whose first line is **Decision recorded.**.

  6. kyle-sexton commented on Nov 25, 2026

    @kyle-sexton
    MemberAuthor

    Decision recorded. Reproduce first: capture a Monitor PreToolUse payload on the current guardrails version. If the hook already exits 0 on it, close this issue as not reproducible.

    Owner, in session 2026-11-25 ~8:21 AM EST, verbatim: "/session-flow:go-with-recommendations", accepting the refinement recommendations Q1 and Q2: "Capture a Monitor PreToolUse payload first" and "Treat it as unconfirmed on 4.4.0. Require a failing test (a Monitor payload that the hook must allow) before the fix, and close the issue as not reproducible if the payload already exits 0."

    Not decided: refinement Q3 (allow when tool_name is missing). That change makes the guard fail toward allowing, which loosens it. It returns to the owner only if the reproduction shows a payload with no tool_name reaching the Bash default at plugins/guardrails/hooks/block-foreground-wait.sh:64. Until then the missing-tool_name default stays as it is.

    Acceptance criteria

    • A PreToolUse payload captured from a real Monitor call holding an until loop, on the current guardrails version, is committed as a fixture for block-foreground-wait.test.sh.
    • A block-foreground-wait.test.sh case runs the hook on that fixture and asserts it exits 0.
    • If the hook already exits 0 on the fixture with no hook change, this issue is closed as not reproducible once that case lands.
    • If the hook refuses the fixture, the case fails before the fix and passes after it.
    • If the refusal comes from a missing tool_name taking the Bash default, the run stops and returns refinement Q3 to the owner without changing that default.
  7. updated Work status needs-triage and Priority medium on Nov 25, 2026
  8. melodic-automation-lanes commented on Nov 25, 2026

    @melodic-automation-lanes
    Contributor

    {"v":1,"actor_id":337595936,"title_sha256":"c4ede15ad9b8702b3233e1d93b8b8a19bf479db2ada9f56552ab1ab98bb9b52f","body_sha256":"60682d6dfc4d607c0f636bea0c49c20add941c01aaf9e83d13b42d4cacc4981f"}

  9. github-actions commented on Nov 25, 2026

    @github-actions
    Contributor
    No description provided.
  10. melodic-automation-lanes commented on Nov 25, 2026

    @melodic-automation-lanes
    Contributor

    The work-resolve-issue run that agent-ready started failed or was cancelled before it reported, or it stopped or the token broker refused it because its workflow files differ from main's. work-unblock removed and added agent-ready back to start a fresh run on main's workflow files. If this run ends the same way, it re-fires the issue again, waiting longer each time.

  11. github-actions commented on Nov 25, 2026

    @github-actions
    Contributor
    No description provided.
  12. added
    host-run
    on Nov 25, 2026
  13. melodic-automation-lanes commented on Nov 25, 2026

    @melodic-automation-lanes
    Contributor

    The work-resolve-issue lane stopped on this issue (host-only): the run reports the work needs a host run the lane cannot make.
    It added host-run and set Work status to confirmed: an agent run on a host builds it, and it waits on no decision from a person.

    In the run's words:

    host-only: the recorded decision (2026-11-25) requires reproducing first with a PreToolUse payload captured from a real Monitor tool call holding an until loop, on the current guardrails version, committed as the fixture. Capturing one needs an interactive Claude Code session with the guardrails plugin enabled and a payload-capture hook registered. This lane has no Monitor tool and cannot register a hook, since .claude/ settings are protected paths. A hand-written payload would not meet the 'captured from a real Monitor call' criterion, and the decision's next branch (close as not reproducible, fix, or return Q3 to the owner) depends on what the real payload shows.

    What the run says it did not do:

    • Acceptance criterion 1: capture a real Monitor PreToolUse payload and commit it as a fixture. This needs an interactive session with a capture hook, which this lane cannot run.
    • Acceptance criteria 2-5: the test case, and the close, fix or Q3 return it selects, all depend on the captured fixture.

    Run: https://github.com/melodic-software/claude-code-plugins/actions/runs/45628195375

    To hand it back to the lane, remove host-run and set Work status to agent-ready again.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    host-run

    Type

    Fields

    Work status

    confirmed

    Priority

    medium

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions