Skip to content

refactor(guardrails): simplify the hardcoded-path detection library - #15402

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14488-43068230007-1
Nov 11, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14488-43068230007-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14488

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Simplified plugins/guardrails/lib/path-detection/hardcoded-path-patterns.sh without changing behavior. The three Windows-context case arms are now one arm. The macOS and Linux blocks share one cands local and one re local instead of separate per-block locals and repeated boundary+body strings. Violation blocks append with +=. The ends of hpp::scan_text and hpp::resolve_scan_root use short \[\[ ... \]\] || forms, and three long rationale comments are condensed with every constraint kept. machine-path-patterns.sh is left unchanged. It is a standards-managed file (listed in .github/workflows/pr-check-managed-files-hosted.yml; ADR-0007 requires it to be byte-exact with its melodic-software/standards source), so a downstream edit would fail the managed-files guard and be overwritten by the next sync.

Not verified

  • machine-path-patterns.sh (listed in the issue) was not simplified: it is a sync-managed file that must be byte-exact with its standards source, so any change belongs upstream in melodic-software/standards
  • guardrails shell test suites (hooks/hardcoded-path-check.test.sh, git-hooks/*-content.test.sh, git-hooks-notice.test.sh) were not run: this lane cannot execute test runners; left to the PR's CI
  • ci-status green is a PR CI check, left to the PR's CI
  • tidy pass 5 (ai-slop:audit fix) skipped: the lane's Bash allows only the named wrappers, so detect.sh and the fix-flow scripts could not run; the one-line fragment was read against the rubric by hand with no findings

Fix

  • plugins/guardrails/lib/path-detection/hardcoded-path-patterns.sh: merged the Windows-context case arms; folded locals into one declaration (cands, re, nl; single-line _posix_boundary); replaced violations="${violations}..." with violations+=; reused one regex local per macOS and Linux…
  • .changes/guardrails/work-resolve-issue-issue-14488-43068230007-1-0d4287a7.md: new guardrails patch fragment, ### Changed / - Internal simplification, no behavior change.

Verification

The runner ran each check from the base copy against e8a2059:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • check-changelog-fragments: all 13 fragments valid (run before and after tidy and review fixes)
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: 13 passed, 6 skipped, rest CI-only, over 2 changed files (run before and after tidy and review fixes)
  • fresh-context review subagent over the full diff against HEAD: no behavior difference under set -e, set -u, pipefail or bash 3.2. It raised one unreachable set -u edge (dropped empty initializers in resolve_scan_root), one lost mechanism detail in the here-string comment, and one stale path; all…
  • tidy-diff on the 16 changed hunks: no further code or comment edits; the markdown passes left the issue-mandated fragment text unchanged
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/43068230007

Left out: the items under Not verified.

Related

#14488

Merge-Risk: max=MEDIUM demote=false head=e8a2059092bb38c148797f9664a80dd906e40fec rubric=8.4.2 rater=claude-opus-5-5 checker=claude-opus-5-5

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed e8a2059092bb38c148797f9664a80dd906e40fec: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

I read every hunk of both changed files: plugins/guardrails/lib/path-detection/hardcoded-path-patterns.sh and the new changelog fragment .changes/guardrails/work-resolve-issue-issue-14488-43068230007-1-0d4287a7.md. I also read the head version of the library around the changed functions.

Behavior check (by reading the code; I ran nothing):

  • Windows case arms: the three arms merge into one alternation that matches the same patterns. They all set the same flag, so the order they're checked in can't change the result.
  • Locals: _cands and _lcands become cands, and re is now declared once at the top of the function. Bash local applies to the whole function, so declaring it inside the if blocks made no difference before. hpp::_drop_exempt declares its own local cands and uses regex, not re, so reusing these names in the calling function can't leak into it.
  • local _posix_boundary="…" on one line: this assigns a literal, not a command substitution, so local can't hide a failing command's exit status.
  • violations+=: the same as violations="${violations}…".
  • End of hpp::scan_text: [[ -n "$violations" ]] || return 0 followed by printf and return 1 gives the same output and exit codes as before, and it is safe under set -e because [[ … ]] sits to the left of ||.
  • hpp::resolve_scan_root: SCAN_ROOT is already "" on entry, so dropping the explicit SCAN_ROOT="" branch changes nothing. The new [[ cond ]] || SCAN_ROOT="$root" returns 0 on both paths, the same as the old if/else assignment, and errexit doesn't fire on a test to the left of ||. Moving the tl_norm="" and home_norm="" initializers into the local line keeps them set before hook::normalize_path_to runs.
  • Comment path: the reworded comment now points to hooks/hook-utils.sh, which exists at plugins/guardrails/hooks/hook-utils.sh.
  • Shortened comments: they keep the rules that matter: the prefilter must never be tighter than the detailed patterns, why <<< and printf | grep -q are banned, the set -e fail-open note, and the bash 3.2 tr note. They drop some measurement detail (22s to 288s) and the explicit line that process substitution keeps the writer out of the pipeline, which is still implied. Not blocking.

Closing issue #14488 acceptance criteria:

  • Behavior unchanged: yes, by my reading above. Existing suites that call hpp::scan_text / hpp::resolve_scan_root would catch a regression (plugins/guardrails/hooks/hardcoded-path-check.test.sh, plugins/guardrails/hooks/secret-pattern-detection.test.sh). The author says they did not run these, and I could not run them either. That is left to CI.
  • Only listed files plus fragments edited: met.
  • Within 400 changed lines and 15 files: met.
  • ci-status green: a CI check, not something I can judge here.
  • Fragment with ### Changed / "Internal simplification, no behavior change.": met, with bump: patch.
  • machine-path-patterns.sh was left alone. The PR says it is a standards-managed file that must stay byte-exact. No acceptance criterion requires editing it, so this is not a finding.

No plugin manifest changed. No embedded instructions were found in the PR context. This is the first review of this PR, so it is a full review, not blocking-only.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed e8a2059092bb38c148797f9664a80dd906e40fec: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15402 (head e8a2059)

I found no security issues.

I read the whole change in both files: plugins/guardrails/lib/path-detection/hardcoded-path-patterns.sh and the new changelog fragment .changes/guardrails/work-resolve-issue-issue-14488-43068230007-1-0d4287a7.md.

What I checked

The library is a guard. When it drops a match by mistake, the hook lets a write through, so I checked each simplification for a fail-open:

  • Windows-context case arms. The three arms are now one arm with the same globs and the same windows_context=1 result. No pattern was dropped.
  • violations+=. This works the same as violations="${violations}..." in every bash, 3.2 included.
  • Shared cands / re locals. Both are declared at function scope on L182 and set before each use.
    • In both the macOS and Linux blocks, cands=$(...) || true is still in place (L270, L282), so the set -e fail-open is still prevented.
    • re is set again before the Linux block uses it, so that block never sees the macOS regex.
    • hpp::_drop_exempt declares its own local cands, so dynamic scoping cannot clobber the caller's value.
    • No other file reads the removed _cands / _lcands names.
  • End of hpp::scan_text. [[ -n "$violations" ]] || return 0; printf; return 1 keeps the same exit status in both cases. A violation still returns 1.
  • End of hpp::resolve_scan_root. SCAN_ROOT is still set to "" first. The new [[ cond ]] || SCAN_ROOT="$root" sets the root only when the home/ancestor check fails, which is the same logic as before. The function still returns 0 under set -e. The empty initializers moved into the local line, so set -u still holds.
  • The pre-filter gate. Its code is unchanged: the edit only shortens its comment. The process-substitution rule (no <<<, no printf | grep -q) is still stated in the shortened comment.
  • Comments. The edited rationale comments are developer notes inside a shell library, not instructions a model follows. Shortening them weakens no enforcement.

Not applicable

  • No trusted paths, plugin manifests, workflows or userConfig keys changed, so there are no manifest lines.
  • Owner friction-hold removals: none.
  • Spend: none.
  • The PR context file had no embedded instructions.

critical-findings: 0

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head e8a2059092bb38c148797f9664a80dd906e40fec. No person needs to act: a lane clears this reason, and the next scheduled run judges it again.

pr-merge's gate refuses its verifier verdict (verify:missing)

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head e8a2059092bb38c148797f9664a80dd906e40fec, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for e8a2059

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-15402-e8a2059092bb38c148797f9664a80dd906e40fec, expires on 2026-12-11.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit 1feb847 Nov 11, 2026
70 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14488-43068230007-1 branch November 11, 2026 18:10
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 1feb8473f341be6e3fe536a10196de5d1459fb9e; later checks count it verified from this comment.

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.

Simplify the path-detection guardrails plugin code

0 participants