claude-code - 💡(How to fix) Fix Glob tool false-negative on recently-created files (10 instances) [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#53710Fetched 2026-04-28 06:49:07
View on GitHub
Comments
2
Participants
3
Timeline
6
Reactions
0
Timeline (top)
labeled ×4commented ×2

Claude Code's Glob tool returned "No files found" for patterns that matched files demonstrably present on disk with correct permissions. The audit trusted the Glob output and did not fall back to Read verification, producing false-negative verdicts in a production audit used for un-pause gating decisions.

Root Cause

Hypothesis on root cause (not a diagnosis; insufficient evidence)

Fix Action

Fix / Workaround

Mitigation deployed locally (documented for upstream context)

Added a protocol requirement to the audit-brief template mitigation: any audit criterion that asserts absence of files MUST (a) run Glob against the expected pattern, (b) if Glob returns empty AND the criterion would produce FAIL or NOT VERIFIED, fall back to direct Read attempts at the expected absolute paths, (c) cite both Glob result and Read fallback result before claiming absence.

This is a local workaround, not a fix. Upstream repair needed so the tool's primary purpose (find files matching a pattern) does not silently fail on recently-created files.

Code Example

$ ls -la /home/alfred/.openclaw/workspace/scripts/lib/*.test.js
-rw------- 1 alfred alfred 16104 Apr 22 15:29 breaking-alert-detection.test.js
-rw------- 1 alfred alfred 16176 Apr 22 14:39 email-escalation.test.js
-rw------- 1 alfred alfred 13438 Apr 22 15:14 pending-sweep.test.js
-rw------- 1 alfred alfred  7425 Apr 22 13:55 state-atomic.test.js
-rw------- 1 alfred alfred 11861 Apr 22 15:23 task-queue-stall.test.js

---

2026-04-22T09:02:19Z  Read /home/alfred/.openclaw/workspace/scripts/lib/email-escalation.test.js   → SUCCESS
2026-04-22T09:02:20Z  Read /home/alfred/.openclaw/workspace/scripts/lib/pending-sweep.test.js     → SUCCESS
2026-04-22T09:02:21Z  Read /home/alfred/.openclaw/workspace/scripts/lib/task-queue-stall.test.js  → SUCCESS
2026-04-22T09:02:21Z  Read /home/alfred/.openclaw/workspace/scripts/lib/breaking-alert-detection.test.js → SUCCESS

---

$ node scripts/lib/state-atomic.test.js
...
Tests: 25 passed, 0 failed
✅ All tests pass

---

-rw------- email-escalation.js        → readable by Claude Code ✓
-rw------- email-escalation.test.js   → Glob: No files found ✗, Read: success ✓
RAW_BUFFERClick to expand / collapse

Glob tool false-negative on recently-created files (10 instances)

This issue is being filed as part of a batch of related upstream submissions discovered during architectural review of OpenClaw deployment. Filed locally 2026-04-22; submitted upstream 2026-04-27. See "Related issues (batch)" section at end for batch context.

Suggested labels (Mike to choose from labels actually available in target repo at submission time): bug, severity:high, area:tools, tool:Glob, has-repro

Severity: HIGH — caused two false FAIL/NOT-VERIFIED verdicts in a live architectural audit Upstream project: Anthropic Claude Code SDK (tool: Glob)

Summary

Claude Code's Glob tool returned "No files found" for patterns that matched files demonstrably present on disk with correct permissions. The audit trusted the Glob output and did not fall back to Read verification, producing false-negative verdicts in a production audit used for un-pause gating decisions.

Environment

  • Host: DESKTOP-CB8PBCM (Ubuntu 24.04, WSL2 on Windows 11 Pro)
  • Claude Code session transport: OpenClaw ACP plugin (runtime=acp, agentId=claude)
  • Session cwd: /home/alfred/.openclaw/workspace/claude (empty directory; absolute paths used for all reads/writes)
  • User: alfred:alfred, UID/GID match owner of target files
  • Node runtime: v22.22.1 via nvm
  • Date: 2026-04-22 AEST (sessions at 19:02, 19:11, 19:21 AEST)

Evidence — Glob invocations with false-negative results

Native Claude Code session logs at ~/.claude/projects/-home-alfred--openclaw-workspace-claude/. Each row cites the source session file and the exact tool_use entry.

#SessionTimestamp (UTC)Glob patternGlob resultGround truth at time of call
13ea9461009:02:19scripts/lib/*.test.jsNo files found5 files present (born 13:55–15:29 AEST same day)
23ea9461009:02:19scripts/**/*.test.jsNo files found5 files present
33ea9461009:02:20scripts/tmpdir-fixture-heartbeat-test.jsNo files foundFile present
4b123ff7109:11scripts/lib/*.test.jsNo files found5 files present
5b123ff7109:11scripts/**/*.test.jsNo files found5 files present
6b123ff7109:11scripts/**/*test*No files found5 files present
7b123ff7109:11scripts/*fixture*No files foundtmpdir-fixture-heartbeat-test.js present
8b123ff7109:11scripts/tmpdir*No files foundtmpdir-fixture-heartbeat-test.js present
9a787786509:21:53scripts/lib/*.test.jsNo files found5 files present
10a787786509:22:04scripts/**/*.test.*No files found5 files present

Total: 10 false-negative Glob results across 3 distinct Claude Code sessions.

Evidence — files actually existed, were readable

Ground-truth verification at 2026-04-22 20:47 AEST:

$ ls -la /home/alfred/.openclaw/workspace/scripts/lib/*.test.js
-rw------- 1 alfred alfred 16104 Apr 22 15:29 breaking-alert-detection.test.js
-rw------- 1 alfred alfred 16176 Apr 22 14:39 email-escalation.test.js
-rw------- 1 alfred alfred 13438 Apr 22 15:14 pending-sweep.test.js
-rw------- 1 alfred alfred  7425 Apr 22 13:55 state-atomic.test.js
-rw------- 1 alfred alfred 11861 Apr 22 15:23 task-queue-stall.test.js

File births (all before any Glob call that missed them):

  • state-atomic.test.js — 2026-04-22 13:55:33 AEST (5h 07m before first Glob call at 19:02)
  • email-escalation.test.js — 14:39:55
  • pending-sweep.test.js — 15:14:48
  • task-queue-stall.test.js — 15:23:40
  • breaking-alert-detection.test.js — 15:29:14 AEST (3h 33m before first Glob call)

Permissions: 0600, owner alfred:alfred — identical to the rule .js files (e.g. email-escalation.js) that Claude Code Read successfully in the same sessions. Files are readable by the user Claude Code runs as.

Evidence — Reads succeeded on the same files in the same sessions

Session 3ea94610 demonstrated that the files Glob failed to find were readable:

2026-04-22T09:02:19Z  Read /home/alfred/.openclaw/workspace/scripts/lib/email-escalation.test.js   → SUCCESS
2026-04-22T09:02:20Z  Read /home/alfred/.openclaw/workspace/scripts/lib/pending-sweep.test.js     → SUCCESS
2026-04-22T09:02:21Z  Read /home/alfred/.openclaw/workspace/scripts/lib/task-queue-stall.test.js  → SUCCESS
2026-04-22T09:02:21Z  Read /home/alfred/.openclaw/workspace/scripts/lib/breaking-alert-detection.test.js → SUCCESS

Four Reads succeeded in the same session the Glob returned empty. Session 3ea94610 subsequently wrote an audit stating "4 of 5 test files exist" — closer to reality than the later sessions which trusted Glob alone and claimed 0 of 5.

Ground-truth test run

Live test invocation at 2026-04-22 20:48 AEST:

$ node scripts/lib/state-atomic.test.js
...
Tests: 25 passed, 0 failed
✅ All tests pass

Files are real, readable, and runnable.

Permission-isolation hypothesis ruled out

All .test.js files have 0600 perms identical to the companion rule .js files:

-rw------- email-escalation.js        → readable by Claude Code ✓
-rw------- email-escalation.test.js   → Glob: No files found ✗, Read: success ✓

Same user, same perms, same directory, different Glob outcome.

Hypothesis on root cause (not a diagnosis; insufficient evidence)

Glob appears to use an index, cache, or traversal that either:

  1. Was built before the session's working directory was fully walked, and is not refreshed on subsequent calls.
  2. Has a path-normalisation bug such that scripts/lib/*.test.js does not resolve even though scripts/lib/*.js resolves in the same session.
  3. Excludes files based on a property that correlates with creation time — recently-created files (same calendar day as session start) are systematically missed.

Evidence is insufficient to discriminate. Every *.test.* and *test* variant failed across all three sessions; every non-test pattern in the same sessions succeeded.

Impact on a live audit (observed)

Session a7877865 (19:26 AEST, which produced the active Phase 2 audit at docs/audit-PHASE-2-AUDIT-2026-04-22.md) trusted the Glob empty result and produced two false verdicts:

  1. Criterion (e) Non-negotiable adherence — FAIL — "Zero of 5 expected per-rule test files exist. This is the most significant gap in the Phase 2 as-shipped deliverable." Actual state: 5 of 5 exist with 236 total assertions.

  2. Criterion (c) Gate 7 reality check — NOT VERIFIED — "No per-rule Gate 7 tests exist. CAS+wx mechanisms are in place but untested under concurrent execution." Actual state: Gate 7 sibling-race tests present in all 4 rule test files using spawnSync (e.g. email-escalation.test.js:228-301).

The audit has since been annotated with a header note (docs/audit-PHASE-2-AUDIT-2026-04-22.md, edit 2026-04-22 20:50 AEST) documenting that these two verdicts are Glob-false-negatives. Verdicts on criteria (a), (b), (d), and (f) did not depend on Glob and stand as written.

Reproduction steps (best effort)

Cannot produce a deterministic repro script without access to Claude Code internals. The pattern observed:

  1. Start Claude Code ACP session (Anthropic Claude Code CLI via OpenClaw acpx plugin).
  2. From within that session, Glob for a pattern matching files created earlier the same calendar day (at least 3 hours prior, in our case).
  3. Observe Glob returns "No files found" even though ls and Read show the files exist with the session user's read permissions.

Cannot yet confirm whether: (a) file age is the trigger, (b) session ordering matters, (c) cwd-vs-absolute-path matters, (d) some other cache-staleness trigger exists.

Mitigation deployed locally (documented for upstream context)

Added a protocol requirement to the audit-brief template mitigation: any audit criterion that asserts absence of files MUST (a) run Glob against the expected pattern, (b) if Glob returns empty AND the criterion would produce FAIL or NOT VERIFIED, fall back to direct Read attempts at the expected absolute paths, (c) cite both Glob result and Read fallback result before claiming absence.

This is a local workaround, not a fix. Upstream repair needed so the tool's primary purpose (find files matching a pattern) does not silently fail on recently-created files.

Related workspace artefacts

  • friday-reaudit-input/2026-04-22-claude-code-glob-false-negative.md — original incident record
  • docs/audit-PHASE-2-AUDIT-2026-04-22.md — audit carrying the two false-negative verdicts with header annotation
  • memory/lessons-learned.md — verifier-coupling pattern entry (6 instances, 2026-04-22; this Glob issue is instance 6)
  • Session transcripts: ~/.claude/projects/-home-alfred--openclaw-workspace-claude/{3ea94610,b123ff71,a7877865}*.jsonl

Related issues (batch)

This issue is filed as part of a batch of related upstream submissions:

  • [#53710] F12-A: Glob tool false-negative on recently-created files — Anthropic Claude Code repo
  • [openclaw/openclaw#72541] F11-C: Gateway completeness check false-negative on pure-relay agents — OpenClaw repo
  • [openclaw/openclaw#72540] Opus 4.7: supportsAdaptiveThinking allowlist missing claude-opus-4-7 — OpenClaw repo
  • [openclaw/openclaw#72539] Sub-B-FAR: Plugin SDK MessagePreSent outbound hook missing — OpenClaw repo

extent analysis

TL;DR

The Glob tool's false-negative results on recently-created files can be mitigated by falling back to direct Read attempts when Glob returns empty.

Guidance

  • Verify that the issue is specific to recently-created files by testing Glob patterns on older files.
  • Implement a fallback mechanism to use direct Read attempts when Glob returns empty, as described in the mitigation deployed locally.
  • Investigate the possibility of a cache or index issue with the Glob tool, and consider refreshing the cache or index before making Glob calls.
  • Test the Glob tool with different patterns and file ages to determine if the issue is specific to certain conditions.

Example

No code snippet is provided as the issue is related to the Glob tool's behavior, which is not explicitly defined in the provided text.

Notes

The root cause of the issue is unclear, and further investigation is needed to determine the exact cause. The mitigation deployed locally is a workaround, and a proper fix is required to resolve the issue.

Recommendation

Apply the workaround by implementing a fallback mechanism to use direct Read attempts when Glob returns empty, as this will help mitigate the issue until a proper fix is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING