Skip to content

perf(guardrails): look up stale-path-verify's warm deleted-paths cache with one awk pass - #18627

Merged
melodic-automation-lanes[bot] merged 2 commits into
mainfrom
work-resolve-issue/issue-18577-45287294256-1
Nov 24, 2026
Merged

melodic-automation-lanes[bot] merged 2 commits into
mainfrom
work-resolve-issue/issue-18577-45287294256-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Refs: #18577

Summary

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

On a warm cache, stale-path-verify no longer loads every cached deleted path into a bash associative array. The main loop now collects the candidates absent from the working tree. build_deleted_set then runs one LC_ALL=C awk call that checks the cache's shape (HEAD sha, ok, end <count> equal to the body line count, no sentinel-shaped body line) and prints only the candidates the cache lists. A miss or an awk failure falls through to the history walk, which still rebuilds the cache as before. This is the issue's step 2, first option (grep/awk lookup in place of the in-memory load), and it meets the acceptance item that no in-memory set of every deleted path is built on a warm-cache run. I chose it without step 1's measurement because that acceptance item requires it whatever the measurement shows. This lane could not run any timing, so the before/after measurements, the 2x Windows target and the batching decision stay open.

Remaining work

  • Measure reference-verify.sh --base origin/main before and after on Windows Git Bash and Linux on a 40+ file branch, put the numbers in a PR body, and confirm the 2x Windows target (acceptance items 1 and 2)
  • Decide from that measurement whether to batch the verifiers so run-guards.sh takes several payloads in one process (proposed step 3)
  • Decide whether ensure_tracked_files' full load of the tracked-files cache also needs a file lookup instead of mapfile (the rest of proposed step 2)
  • Decide separately whether --base gets the merged-branch narrowing (proposed step 4, optional)

Not verified

  • Before/after timing on Windows Git Bash and Linux on a 40+ file branch (acceptance item 1, proposed step 1): this lane cannot run bash scripts or time anything, and has no Windows host
  • The 2x wall-time target on Windows for a 44-file reference-verify.sh --base origin/main run (acceptance item 2) is unverified
  • stale-path-verify.test.sh, reference-verify.test.sh and run-guards.test.sh were not run here (the lane runs only its named wrappers); left to the PR's CI
  • The PostToolUse single-file path now starts one awk process when a cited path is absent and the cache is warm, where the old path started none but loaded the whole cache. Not measured; a small cache may be slightly slower and a large one much faster.…
  • tidy recorded as skipped: passes 1 to 4 ran (no code edits needed; the changelog fragment was reworded), but pass 5's ai-slop detector script could not run in this lane, so only the rubric read was done
  • review-venue.txt was absent, so the review ran locally in a fresh-context subagent
  • check-affected skipped typos (not installed), comment-hygiene (network fetch denied), size-check (script missing), and the validate-plugins steps that run code from the checked tree

Fix

  • plugins/guardrails/hooks/stale-path-verify.sh: new SPV_CACHE_LOOKUP awk program; build_deleted_set takes the absent candidates and looks them up in a warm cache with one awk call instead of mapfile plus a per-line DELETED fill; the candidate loop now has two passes (collect absent candidates, then…
  • plugins/guardrails/hooks/stale-path-verify.test.sh: new case where a whole cache at HEAD lists the cited path: it is reported and no history walk runs
  • .changes/guardrails/work-resolve-issue-issue-18577-45287294256-1-8c1c426b.md: patch changelog fragment for guardrails

Verification

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

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

The run reports:

  • check-changelog-fragments: all 16 fragments valid
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: first run failed shellcheck SC2016 on the single-quoted awk program and comment-lint on the PROVENANCE GATE comment I had re-indented; fixed with a shellcheck directive and by restoring the comment at its original indentation; final run 17 passed, 10 skipped, 0 failed
  • fresh-context review subagent over the whole diff: no confirmed bugs; it checked the awk shape checks against the old mapfile logic (sha string comparison, end-count, inner sentinel, empty and cut files), exit-status fallthrough, finding order, set -uo pipefail, in-process sourcing by…
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/45287294256

Left out: the items under Not verified.

Related

#18577

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

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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

Security review: PR #18627, incremental (bb841cd → dc36f10)

I found no security issues in this push. Because this lane already reviewed an earlier head, this review reported only blocking findings, and there were none.

What changed. In plugins/guardrails/hooks/stale-path-verify.sh, the awk program SPV_CACHE_LOOKUP used to be a single-quoted string with a # shellcheck disable=SC2016 suppression. Now IFS= read -r -d '' SPV_CACHE_LOOKUP <<'EOF' || true reads it from a quoted heredoc, and ${SPV_CACHE_LOOKUP%$'\n'} removes the trailing newline (L644-658).

What I checked:

  • No expansion or injection. The delimiter is quoted ('EOF'), so the shell expands nothing in the body. $0, sha and the other awk tokens stay literal, just as in the old single-quoted string. No body line is exactly EOF, so the heredoc cannot end early.
  • Same program text. The heredoc starts with a blank line, which matches the newline after the old opening quote. The trailing newline is removed, so the result ends at } as before. The awk logic is unchanged: it still checks the cache's shape and exits 1 on a bad sha, a missing ok, a wrong end <n> count or a second sentinel line. Callers still fall back to the history walk.
  • Errexit safety. read -d '' hits end of input before any NUL and returns nonzero. || true absorbs that, so set -e cannot abort the hook here.
  • Trusted paths and instruction surfaces. The file matches no trusted-path glob. The push removes only a lint suppression, not a standing instruction, block list or allowlist. It touches no plugin manifest.

Cost: none. The push changes no billing, plan, resource or workflow setting.

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

claude-review: 1 inline finding(s) on bb841cd2f83fd0256e63f79565164ab0ce0252d8; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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

Code review (incremental, blocking only): bb841cd2f → dc36f103e

No blocking findings in this push. This lane already reviewed an earlier head (blocking only: yes), so this pass reported blocking findings only.

Scope. This push changes one file, plugins/guardrails/hooks/stale-path-verify.sh. I read all of its hunks in .claude-lane/incremental.diff, plus lines 630–709 of the file at head for context.

Prior finding resolved. My earlier inline finding was that the # shellcheck disable=SC2016 suppression loosened a check (thread). This push removes the suppression. SPV_CACHE_LOOKUP is now assigned from a quoted heredoc (stale-path-verify.sh:644-658). There is no loosened check left to report.

The awk program text is unchanged. I compared the old and new values of SPV_CACHE_LOOKUP:

  • Leading newline. The old single-quoted string began with a newline right after the opening '. The blank first line of the heredoc keeps that newline.
  • Trailing newline. The old string ended at } with no newline. ${SPV_CACHE_LOOKUP%$'\n'} strips the one newline the heredoc adds after }.
  • No trimming or escape handling. IFS= stops read from trimming leading or trailing whitespace. -r stops it from processing backslashes, and -d '' reads to end of input.
  • Exit status. read returns 1 at end of input because it never finds a NUL. || true absorbs that, which matters only for an ERR trap or errexit. The script runs under set -uo pipefail without -e, so either way it would not stop.
  • Quoting. The 'EOF' delimiter is quoted, so $0 and the other $ fields are not expanded.

The only consumer, the awk call at L698, gets the same program as before.

Not verified. I ran nothing. Whether shellcheck now passes, and whether stale-path-verify.test.sh passes, is for CI to show.

Other checks.

  • Loosened checks. Loosened checks would be marked: fail (default; the prompt has no loosened_check_verdict: or loosened_check_patterns: line); patterns: 0. The prompt has no loosened_check_decision_record: line, so the citation requirement was not checked. This push adds no loosening.
  • Closing issue. The PR only says Refs: #18577 and has no closing-issue section, so there are no acceptance criteria to check.
  • Other inputs. No plugin manifest changed. No settled-threads file was named. The PR context has no embedded directives.

Verifier dropped 0 of 0 candidates.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head bb841cd2f83fd0256e63f79565164ab0ce0252d8. 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)

Assign SPV_CACHE_LOOKUP from a quoted heredoc instead of a single-quoted
string, so shellcheck's SC2016 no longer fires, and delete the disable
directive. The assigned string is byte-identical to the old one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UJUn7JtHsXahAvMdb4rCk1
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path is about to arm native auto-merge at head dc36f103e5a8218a0218f9252b930ee81d9ea1ac, the head its arming checks judged. The arm fails if the head moves first.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit fa30e3c Nov 24, 2026
60 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-18577-45287294256-1 branch November 24, 2026 01:56
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit fa30e3cdf779fe243efb47cdfe4da5f2ebd89285; 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.

1 participant