Skip to content

Fix handoff capturing grep shell-code lines as file paths (3.0.2)#6

Merged
koenvdheide merged 3 commits into
mainfrom
fix-handoff-grep-path-extraction
Jun 5, 2026
Merged

Fix handoff capturing grep shell-code lines as file paths (3.0.2)#6
koenvdheide merged 3 commits into
mainfrom
fix-handoff-grep-path-extraction

Conversation

@koenvdheide

Copy link
Copy Markdown
Owner

What

The Stop hook's Tier-B path extractor captured grep/glob result lines that carry shell code as if they were file paths. A grep context line like 357-SKILL="$SCRIPT_DIR/../skills/prep-compact/SKILL.md" (no : to split on, so the whole line became the candidate) was stored verbatim in the handoff's recent_files/cumulative_files. Spotted in a live handoff while dogfooding 3.0.1.

Fix

first_path_token now rejects a candidate containing any shell/glob punctuation (" ' ` = $ < > | * ?) — a resolved path token never carries those. Clean paths are unaffected: src/foo.ts from src/foo.ts:42:match, bare glob results, etc.

Testing

bash test/run-tests.sh: 129 assertions, green on Windows Git Bash. New regression test T-56 (junk line rejected, real path kept); existing T-28b (legit grep/glob extraction) still passes unchanged.

Notes

  • Reviewed by Codex (diff-review: "sound for the reported regression") and the reviewer agent (0 errors).
  • Deliberately not rejecting whitespace (would false-drop legit paths with spaces, e.g. My Documents/report.docx) or stripping the <num>- grep prefix (would corrupt date-prefixed filenames like 2026-05-23-foo.md). Tier-B is best-effort with Tier-A Read/Edit as the backstop.
  • Version bumped 3.0.1 -> 3.0.2.

🤖 Generated with Claude Code

koenvdheide and others added 2 commits June 5, 2026 22:29
A grep context line carrying shell code (e.g. SKILL="$DIR/x.sh") was captured whole as a handoff file path. A resolved path token never contains quote/$/=/redirect/glob chars; reject candidates that do. Regression test T-56.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@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: f1b676518c

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

Comment thread hooks/update-handoff.sh
Comment on lines +216 to +217
if any(ch in _PATH_TOKEN_JUNK for ch in candidate):
return None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve valid path punctuation in grep results

When a Glob/Grep result contains a real filename with characters such as = or ' (for example fixtures/a=b.json or docs/John's-note.md), this new blanket check drops the candidate even though those are valid path characters on normal filesystems. That regresses Tier-B handoff coverage for repos with generated/config files that commonly include = in names; the shell-junk filter should target assignment/code-shaped lines without rejecting all legitimate paths containing these characters.

Useful? React with 👍 / 👎.

Codex PR review: = and the single-quote char are valid in real filenames (e.g. a=b.json); the blanket denylist over-dropped them. Keep only quote/backtick/$/redirect/glob, which still catch the observed shell-junk. T-56 now also asserts a real =-named path is kept.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@koenvdheide koenvdheide merged commit 4b8f30e into main Jun 5, 2026
2 checks passed
@koenvdheide koenvdheide deleted the fix-handoff-grep-path-extraction branch June 5, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant