Make warn-plugin-cache-walk's fast exit test the command, not the whole payload

Ouverte
#21,023 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
70/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
bash, git, shell

Piste de recherche

Start with plugins/guardrails/hooks/warn-plugin-cache-walk.sh, especially lines 18, 23, and 26, and inspect the existing tests for this hook. Feed JSON on stdin with a realistic transcript_path under ~/.claude; verify a command without .claude/ or CLAUDE_CONFIG_DIR exits before jq and that verdicts stay unchanged. Measure per-call time before and after on Windows Git Bash and record it in the PR.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Problem

plugins/guardrails/hooks/warn-plugin-cache-walk.sh:18 is meant to exit early when a call cannot touch
~/.claude, before jq runs. It tests the whole PreToolUse payload for .claude/ or
claude_config_dir. Every payload carries transcript_path, which sits under ~/.claude/projects/,
so the test always matches and the early exit never fires. Every Bash call then pays for the jq
parse at :23; the real check on the command at :26 still decides correctly.

Evidence

  • Read on origin/main this pass: the test at :18 runs on ${INPUT,,}, the raw payload; :26
    repeats it on .tool_input.command.
  • Inferred, not measured: the per-call cost of the extra jq parse on Windows.

Proposed approach

Make the fast test ignore transcript_path and cwd (for example, match only text after
"command":), or drop :18 if it cannot be made cheaper than the jq parse. Measure before and
after on Windows Git Bash.

Acceptance criteria

  • A Bash call whose command does not mention .claude/ or CLAUDE_CONFIG_DIR exits before jq runs, with a transcript path under ~/.claude in the payload.
  • Verdicts unchanged: existing tests pass, plus a test with a realistic transcript_path.
  • Measured per-call time before and after, recorded in the PR.

Constraints and gotchas

  • Never loosen the guard; this is a speed change with verdict parity.
  • Test only by feeding JSON on stdin.

Context

Found while researching #21019 (closed). Part of the hook-speed work under #20549.

Langage dominant
Shell
Étoiles
22
Forks
2
Merge moyen
3 h 20 min
PR mergées (30 j)
956

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de melodic-software/claude-code-plugins

Toutes les issues de melodic-software/claude-code-plugins

Issues similaires

Plus d'issues Shell/Bash

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.