Skip to content

Hook if file rules never match an absolute path outside cwd on Windows (upstream candidate) #3680

Description

@kyle-sexton

This was generated by AI during attend-queue.

Summary

On Claude Code 2.1.258 (Windows, Git Bash), a hook if file rule never matches an absolute path outside the working directory. Every anchor form was probed (~/, //, drive letter, //**/, bare *.json), and each was skipped on a Write to the user-global settings file and on a Write to the managed-settings file, while the unconditioned row fired and returned ask for both. Only a settings file inside the working directory matched.

Correction (2026-09-30 probe, Claude Code 2.1.285, Windows; see the resolution comment): the path is not the cause. In a hook if, an Edit(...) rule does not match a Write tool call at any path; Write(...) and Edit(...) rules each match absolute paths outside cwd for their own tool.

Impact

Any hook that guards a user-global or managed file (the context-budget settings checkpoint is the case in this repo) cannot carry an if gate without silently dropping those checks. The hook-performance program left that row unconditioned and recorded the probe in plugins/context-budget/README.md and the program's DEVIATIONS log.

Evidence

Probe logs: hook-probe/logs/stub-userlocal.log and stub-managed.log under the session temp directory (2026-09-02). The permissions doc says //c/**/.env and //**/.env match anywhere on the drive or filesystem; the observed behaviour contradicts that for hook if rules specifically.

Ask

File upstream with a minimal reproduction (one PreToolUse hook with if: Edit(//**/settings.json) and a Write to ~/.claude/settings.json), then re-probe on each new Claude Code release; when it matches, the context-budget row can take the gate.

Split to #8985: the owner files the corrected report upstream, pastes the URL, and the per-release re-probe (owner decision 2026-10-01, option A). A one-line follow-up then adds the URL to both sections below.

Done when (this issue: the doc correction, which does not wait on the upstream URL)

Targets: plugins/context-budget/README.md (Hook section, the paragraph starting "The registration carries no if filter", around :149-158) and docs/conventions/hook-precision/README.md "Platform gap" section (around :92-108, including its Claim and Recheck bullets).

  • Both sections name Claude Code 2.1.285 and Windows.
  • Both sections state that an Edit(...) rule in a hook if does not match a Write tool call, and that Write(...) and Edit(...) rules each match absolute paths outside cwd for their own tool.
  • Neither section still attributes the skip to the absolute path: the phrase "do not match an absolute path outside the working directory" is gone from both files. Check: the reviewer confirms it in the diff.
  • The Recheck bullet names the tool-name gap and context-budget: file the corrected hook if tool-name report upstream and re-probe each release #8985.
  • The context-budget row stays unconditioned. Splitting it into gated Write/Edit rows is out of scope (separate PR, needs its own probe). Check: the PR diff touches no hooks.json.
  • A .changes/context-budget/ fragment exists, made with scripts/new-changelog-fragment.sh context-budget patch, and scripts/check-changelog-fragments.sh --check passes.
  • The PR's CI runs the markdown lint and it passes.

Activity

  1. added
    needs-triage
    on Sep 3, 2026
  2. added
    needs-human
    and removed
    needs-triage
    on Sep 23, 2026
  3. kyle-sexton commented on Sep 23, 2026

    @kyle-sexton
    MemberAuthor

    This was generated by AI during triage.

    Human-gated. Open decision: file the repro upstream (anthropics/claude-code) and re-probe each release

  4. added theissue type on Sep 23, 2026
  5. kyle-sexton commented on Sep 29, 2026

    @kyle-sexton
    MemberAuthor

    Reopened from the 2026-09-29 audit of the Cursor agent run. PR #4950 closed this as completed, but the issue's Ask was not done.

    What was asked and what exists. The acceptance was a repro filed on anthropics/claude-code plus a re-probe on each Claude Code release. Neither exists. The only record is the probe in plugins/context-budget/README.md (Hook section: 2026-09-02, Claude Code 2.1.258, Windows Git Bash) and the note in the hook-precision convention.

    What the repo already holds, so nobody redoes it. The Write|Edit hook row stays unconditioned (no if), because every anchor form was skipped for an absolute path outside the working directory. The README Hook section holds the probe. Nothing more is needed in code.

    Operator steps. These need a Windows host and an anthropics/claude-code account, so an autonomous lane cannot do them. This stays needs-human (operator action, not a decision).

    1. Search anthropics/claude-code issues for "hook if Edit absolute path outside cwd Windows". If one exists, comment the repro there and go to step 3.
    2. Otherwise file it, title Hook if file rules never match an absolute path outside the working directory on Windows. Body:
      • Claude Code version, OS, shell.
      • Minimal repro: a project-scope PreToolUse hook with matcher Write|Edit and if: "Edit(//**/settings.json)" that appends a line to a log file, then a Write to ~/.claude/settings.json. Expected: the hook fires. Actual: the rule is skipped in the hook log, while the same hook without if fires.
      • The five anchor forms tried: ~/, //, drive letter, //**/, bare *.json.
      • The permissions-page claim that //c/**/.env and //**/.env match anywhere.
    3. Paste the upstream URL on this issue and open a one-line PR adding it to the README Hook section and the hook-precision "Platform gap" Recheck line.
    4. Re-probe with the same repro on each Claude Code release and record the result here.

    Fix PR #5267 refs this issue and does not close it. Closing needs step 3 done.

  6. 3 remaining items

  7. kyle-sexton commented on Oct 1, 2026

    @kyle-sexton
    MemberAuthor

    Owner decision (2026-10-01): approved the recommendation ("go with recommended", the owner's reply to the batch decision page that listed this question and its recommendation).

    Question: should the corrected upstream report ("Hook if rule Edit(...) does not match Write tool calls") be filed on anthropics/claude-code?

    Chosen option A: the owner files the corrected draft (from the 2026-09-29 resolution comment) upstream from their own account. No Windows host is needed because the 2.1.285 probe already ran. The owner pastes the URL here.

    Next: owner files and pastes the URL. An agent then opens one PR that corrects plugins/context-budget/README.md (Hook section) and the docs/conventions/hook-precision/README.md "Platform gap" section so the cause is tool-name matching, not path, adds the URL, and closes this issue. The optional split of the Write|Edit row into gated rows goes in a separate PR. Stays open with needs-human.

  8. added
    status: confirmed
    status: ready
    and removed
    needs-human
    status: confirmed
    on Oct 22, 2026
  9. melodic-automation-lanes commented on Oct 24, 2026

    @melodic-automation-lanes
    Contributor

    Not admitted to the issue lane yet: open pull request #4950 is for it.

  10. kyle-sexton commented on Oct 24, 2026

    @kyle-sexton
    MemberAuthor

    Removed admission-deferred, which the Issue Triage session added at 16:30Z to make this issue a wave-1 canary. #4950 parked this gap until an upstream Claude Code fix, so it is not lane work. Admission waited only because it read the merged #4950 as an open closing pull request, a defect fixed separately.

  11. added
    agent-ready
    on Oct 28, 2026
  12. melodic-automation-lanes commented on Oct 29, 2026

    @melodic-automation-lanes
    Contributor

    This records a re-fire of an earlier refusal, not a new refusal. The lanes kill switch stopped run 40790190262, the work-resolve-issue run that agent-ready started, before it did any work; that run ended at 2026-10-29T01:31:17Z. work-unblock has now removed and added agent-ready back to start a fresh run. A kill-switch refusal is no fault in this issue or the lanes, so it never counts against later re-fires; after limits.limit-stops-per-issue of them since a person last added agent-ready or a run last reported, work-unblock waits longer before each one, up to 24 hours.

  13. added
    agent-ready
    and removed
    agent-ready
    on Oct 29, 2026
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

    agent-readystatus: ready

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions