Skip to content

fix(plugin-quality): accept C:/ saved= paths and write the auditor ledger only with Write #5942

Closed

Description

@kyle-sexton

Problem

Two defects surfaced on 2026-10-01 while /plugin-quality:audit (0.11.1, Claude Code 2.1.286, Windows 11 Git Bash) audited harness-ops:plugins (then claude-ops:plugins). Both still hold on origin/main 0c5fd2898 (plugin-quality 0.12.2).

  1. collect-categories.sh rejects valid Windows-form saved= paths. plugins/plugin-quality/skills/audit/scripts/collect-categories.sh:74 sets DIR="$(cd "$(dirname "$NOTES")" && pwd -P)", which on Git Bash yields /c/Users/.... check_source normalizes each saved= path with realpath -m (lines 102-105), which leaves C:/Users/... in drive form, so index(path, dir "/") != 1 at line 106 fails and the record is reported as research-<label>-path-outside-packet (line 107). The research agent and the Write tool both naturally produce C:/... paths on Windows, so a correct ledger fails the gate.
  2. The auditor has no rule against writing the ledger through the shell. plugins/plugin-quality/agents/auditor.md:33-37 says Write is for packet files, but nothing says the ledger must be written with the Write tool and never by a shell heredoc, cat >, or cp. In the run the auditor's ledger exceeded the guardrails Bash command ceiling (MAX_COMMAND_LEN 16384, plugins/guardrails/README.md:63) as one heredoc, so it drafted six scratch parts, concatenated them, and cp'd the result into the packet. That sidesteps the Write-tool path the packet rules reason about (formatter PostToolUse rewrites and read-back, auditor.md:65-77), and the same session saw guardrails block a cat > heredoc as a Write/Edit bypass, so recovery depended on which shell form slipped through. The guardrails limit is working as intended; the fix is in the auditor brief.

Evidence

Verified this pass:

  • Read collect-categories.sh:60-150 on main. The path test is as described.
  • Probe in Git Bash on this host: realpath -m -- 'C:/Users/<user>/nonexistent/x' prints C:/Users/<user>/nonexistent/x; cd C:/Users/<user> && pwd -P prints /c/Users/<user>; cygpath -u 'C:/Users/<user>/x' prints /c/Users/<user>/x.
  • collect-categories.test.sh on main has no C:/ or cygpath case (its saved= fixtures at lines 161-163 use POSIX-form paths).
  • reference/categories.md:37-50 says a saved= path is "an absolute path with no spaces, inside the directory that holds the ledger", without naming which absolute form is accepted.
  • Read agents/auditor.md:26-80: Write is scoped to packet files; there is no Write-only ledger rule and no mention of the command-length ceiling.
  • guardrails README.md:56,63,557 documents the 16384-character ceiling and that it fails the command lane closed.

Reported by the producer, not reproduced here:

  • A ledger whose tier records used saved=C:/Users/... exited 1 with path-outside-packet and distinct-checked=0; rewriting every saved= path to /c/Users/... made the same ledger exit 0.
  • One finding's primary passed while its corroborators reported distinct-checked=0 with no per-source problem line. Inferred from the code: close_finding (line 141) counts a corroborator only when its normalized URL (fragment, query and trailing slashes stripped at lines 122-124) is not already in seen_url. A corroborator whose URL matches the primary or an earlier corroborator is dropped with no problem line. That fits the observation; not confirmed against the run's ledger.

Proposed approach

  1. In collect-categories.sh, normalize both sides to one form before the prefix test: when cygpath is on PATH (command -v cygpath), convert DIR and each saved= path with cygpath -u before realpath -m; elsewhere keep the current behavior. Read the file through the normalized path.
    • Rejected: "compare realpath of both sides". The probe above shows realpath -m keeps whatever drive form it is given, so a notes path and a saved= path in different forms still mismatch.
  2. In the same script, print a research-<label>-duplicate-url section=... title=... problem line when a corroborator's normalized URL is already counted, so distinct-checked=0 always has a cause on screen.
  3. In reference/categories.md, state that saved= accepts either POSIX (/c/...) or Windows drive form (C:/...) on Windows.
  4. In agents/auditor.md, add: write every packet file, including the ledger, with the Write tool; never through a shell heredoc, cat >, tee, or cp into the packet. Write has no 16384-character ceiling. If a Write is refused for a report-shaped name, the existing audit-data.md fallback (auditor.md:44-60) applies.
  5. Add tests to collect-categories.test.sh: a C:/-form saved= path inside the packet passes on Git Bash (skip visibly where cygpath is absent), a C:/ path outside the packet still fails, and a duplicate corroborator URL prints the new problem line.

Files: plugins/plugin-quality/skills/audit/scripts/collect-categories.sh, plugins/plugin-quality/skills/audit/scripts/collect-categories.test.sh, plugins/plugin-quality/skills/audit/reference/categories.md, plugins/plugin-quality/agents/auditor.md, plugins/plugin-quality/.claude-plugin/plugin.json, plugins/plugin-quality/CHANGELOG.md.

Acceptance criteria

  • On Git Bash, a ledger whose saved= paths are C:/... form and inside the packet passes collect-categories.sh.
  • A C:/... path outside the packet still fails with path-outside-packet.
  • A corroborator whose normalized URL duplicates the primary prints a duplicate-url problem line.
  • reference/categories.md names the accepted saved= path forms.
  • agents/auditor.md requires the Write tool for every packet file and forbids shell heredoc, cat >, tee, and cp into the packet.
  • collect-categories.test.sh passes on Linux and on Git Bash.
  • plugin-quality version bumped with a CHANGELOG entry; scripts/check-changelog-parity.sh --check and --check-order pass.

Constraints and gotchas

  • Do not raise or bypass the guardrails 16384-character ceiling; it is intentional (guardrails README.md:557).
  • Packet files are write-once and formatter hooks rewrite them after a Write (auditor.md:65-77); the new rule must not ask the auditor to edit a packet file in place.
  • cygpath exists only on Git Bash/MSYS/Cygwin; guard it so Linux and macOS behavior is unchanged.
  • The awk program builds a shell command from the path (realpath -m -- '<path>', quote-escaped at line 102); keep that escaping if the conversion is done inside awk.

Context

Source: local handoff item 20261001-143000-plugin-quality-audit-windows-path-and-guard-limit.md (retired into this issue and its sibling about the research seam). Related: #4239 (research-backed audit findings), #5819 (another plugin-quality Windows/locating issue), #5924 (Windows backslash paths in hook-utils, same family of path-form bugs).

Activity

  1. added
    agent-ready
    on Oct 2, 2026
  2. added a commit that references this issue on Oct 3, 2026
    34f43f0
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-ready

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions