Skip to content

refactor(harness-memory): simplify audit spine and memory scripts - #15523

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14505-43145490461-1
Nov 12, 2026
Merged

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14505

Summary

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

Simplified 8 of the 14 listed harness-memory scripts without changing outputs, exit codes, flags or any name another file calls (net -37 lines). The main changes: nested-agents-check walks each AGENTS.md's ancestors once instead of twice (blocked and wired decided in one pass); file-provenance shares one local-exit path (exit "$quiet") and drops a redundant guard; resolve-memory-dir names its repeated cygpath fallback and slug sed as two small helpers; instruction-load-stats resolves the user import root once instead of per root; one-call rule-scope wrappers in orphan-rule-check and instruction-load-stats are inlined. The other 6 files (topic-count.sh, test-helpers.sh, lib/agents-md.sh, lib/imports.sh, lib/rule-scope.sh, memory-dir-stats.sh) were reviewed and left as they are: each is already minimal, or its shape is deliberate (rule-scope's here-string avoids SIGPIPE under pipefail; test-helpers is a per-plugin copy by design).

Not verified

  • The harness-memory *.test.sh suites (audit-spine, discover-instruction-surfaces, file-provenance, instruction-load-stats, memory-index-refs-check, nested-agents-check, orphan-rule-check, memory-dir-stats) were not run directly: this lane's Bash runs only the named wrappers. Left to the PR's CI
  • ci-status green is a PR CI check; left to the PR's CI
  • Row 42 of .claude/cutover-pathdet-ack.txt quotes the removed is_blocked line in nested-agents-check.sh and is now stale. cutover-check.sh condition 4 does not check for stale rows, so nothing fails. The file is a protected .claude/ path this lane cannot edit; a person can drop the row
  • Tidy partly skipped: passes 1-4 ran and found nothing to change. Pass 5 (ai-slop:audit fix) on the changelog fragment was a manual read only, because the lane cannot run the ai-slop detector script; the fragment text comes verbatim from the issue and has no tells
  • Build/lint beyond the repository checks: shellcheck/shfmt were not invoked directly (not available as lane wrappers); check-affected covers what it selects for changed .sh files

Fix

  • plugins/harness-memory/skills/audit/scripts/nested-agents-check.sh: is_blocked and is_wired merged into one is_unwired walk with the same verdict; the doc pointer block is kept
  • plugins/harness-memory/skills/audit/scripts/file-provenance.sh: emit_local helper exits "$quiet" (1 under --synced, else 0) in place of two copies of the same three lines; the upstream default moved into ${upstream:-unknown}; the redundant -n "$last" guard is dropped
  • plugins/harness-memory/skills/audit/scripts/resolve-memory-dir.sh: windows_path and slug helpers replace three copies of the cygpath fallback and two copies of the sed slug
  • plugins/harness-memory/skills/audit/scripts/instruction-load-stats.sh: is_unscoped_rule inlined; a case with an empty default became a guard; the user dir and its realpath are computed once
  • plugins/harness-memory/skills/audit/scripts/orphan-rule-check.sh: is_always_loaded/has_description wrappers inlined; basename subprocess replaced with ${file##*/}
  • plugins/harness-memory/skills/audit/scripts/memory-index-refs-check.sh: basename subprocess in the topic-file loop replaced with ${file##*/}
  • plugins/harness-memory/skills/audit/scripts/audit-spine.sh: findings case statement and rules-scoped if collapsed to one-line guards
  • plugins/harness-memory/skills/audit/scripts/discover-instruction-surfaces.sh: emit's two empty case arms merged; canon_file's temp variable dropped; the user-side canon values are inlined into the overlap tests. Lines that .claude/cutover-pathdet-ack.txt quotes keep their exact text
  • .changes/harness-memory/work-resolve-issue-issue-14505-43145490461-1-357e1272.md: new patch fragment, '### Changed' / 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 7cb8ffe:

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

The run reports:

  • check-changelog-fragments: all 17 fragments valid (run before and after the review fix)
  • check-changed-skills: plugins/harness-memory/skills/audit PASS, 0 errors, 3 pre-existing warnings about description length, body length and a missing Gotchas section (run twice)
  • check-affected: 13 passed, 6 skipped over 9 changed files (run twice)
  • fresh-context review subagent over the whole diff: no runtime behavior change found; removed functions have no callers, test suites included. It flagged two discover-instruction-surfaces.sh lines whose new text no longer matched the reviewed rows 35 and 36 in .claude/cutover-pathdet-ack.txt, which…
  • Checked by hand that no changed line matches plan-migration.sh's PATHDET_PATTERN beyond the acknowledged ones
  • Diff size: 8 code files, 58 added / 95 removed lines plus a 7-line fragment, within the issue's 400-line / 15-file limit
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/43145490461

Left out: the items under Not verified.

Related

#14505

Merge-Risk: max=MEDIUM demote=false head=7cb8ffe231df3eb8237de008984b28db4029ef96 rubric=8.4.8 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-security-review reviewed 7cb8ffe231df3eb8237de008984b28db4029ef96: read 9 of 9 changed file(s); 0 finding(s), 0 as inline comments.

Security review of PR #15523 at 7cb8ffe2: no security issues found.

I read every hunk of all 9 changed files. The PR refactors eight local harness-memory audit shell scripts (audit-spine.sh, discover-instruction-surfaces.sh, file-provenance.sh, instruction-load-stats.sh, memory-index-refs-check.sh, nested-agents-check.sh, orphan-rule-check.sh, resolve-memory-dir.sh) and adds one changelog fragment. None of these files matches a trusted-path glob. None is a trust control (trusted-trigger check, lane token, kill switch, token broker, merge holds or other .github/actions/). The PR changes no plugin manifest or userConfig key.

What I checked:

  • Quoting and injection: every changed line that builds a command or path keeps its quotes. Examples: the new windows_path/slug helpers in resolve-memory-dir.sh, "$(canon_dir "$config_root/rules")" inlined into the comparisons in discover-instruction-surfaces.sh, ${file##*/} replacing basename, and git grep -F -- in orphan-rule-check.sh. The PR adds no new eval, unquoted expansion or command built from file content.
  • Data flow: the values that reach paths still come from the same places as before (CLAUDE_CONFIG_DIR/HOME, git rev-parse output, the working tree). The file-provenance.sh upstream value is still limited by the same [A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+ regex and is only printed.
  • Exit status and verdicts: emit_local exits "$quiet", nested-agents-check.sh now decides blocked and wired in one walk (is_unwired), and audit-spine.sh uses guard-style loops. These affect only what the local audit reports. None of them gates a CI lane, a merge, credentials or a token.
  • Instruction-surface lens: the PR deletes or weakens no standing instruction (no CLAUDE.md, AGENTS.md, rule, skill or agent body, or hook allowlist). Only script comments moved, so the instruction-exception register did not apply.
  • Embedded text in the PR context: none tells the lane to pass the PR, skip a check or post elsewhere. The note that row 42 of .claude/cutover-pathdet-ack.txt is now stale describes repository upkeep, not an instruction to this lane.

critical-findings: 0

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15523, refactor(harness-memory): simplify audit spine and memory scripts

No findings. I read every hunk of all 9 changed files and checked each rewrite against its base form for any change in output, exit code or side effect. All of these scripts run under set -uo pipefail with no set -e, so swapping if/case for &&/|| guards cannot change error handling.

  • audit-spine.sh: the && guard counts rules the same way. The FAIL*/WARN* filter keeps the same lines.
  • discover-instruction-surfaces.sh: all | "$scope") matches what the two old arms matched. canon_dir and canon_file run their cd in a subshell, have no side effects and always return 0. Inlining the user-side value into the second operand of && only skips a call whose result was never used. user_rules_canon and user_md_canon have no other readers.
  • file-provenance.sh: quiet is only ever 0 or 1, so exit "$quiet" behaves like the old two-line exit. The commit-signal branch could only reach upstream=unknown, so the literal unknown is the same value. The dropped -n "$last" guard was redundant: an empty last leaves author and subject empty, and neither pattern matches an empty string.
  • instruction-load-stats.sh: il_realpath always returns 0 and has no side effects (lib/imports.sh:48). Computing USER_IL_ROOT once, after the same cd, gives the value the old code computed for each root. The || form prints the same rows as the old is_unscoped_rule && form.
  • nested-agents-check.sh: is_unwired gives the same verdict as the old is_blocked && ! is_wired. It returns 1 as soon as any existing entry reaches the file, and otherwise returns 0 only if at least one entry existed on the path. It walks the same entries and stops at . as before.
  • orphan-rule-check.sh, memory-index-refs-check.sh: the inlined wrappers keep the same skip logic. ${file##*/} equals basename for these glob-produced paths.
  • resolve-memory-dir.sh: windows_path and slug reproduce the old fallbacks exactly, including the old pwd fallback outside a repo.

Closing issue #14505 acceptance criteria

  • Behavior unchanged: met, from my reading. Each changed script has an existing *.test.sh suite that would catch a regression. The author says they did not run these suites, and I could not run them either; that is left to CI.
  • Only the listed files plus a changelog fragment are edited: met (8 listed scripts and 1 fragment).
  • Within 400 lines and 15 files: met.
  • ci-status green: not checked here (no CI access).
  • Fragment with ### Changed and "Internal simplification, no behavior change.": met, with bump: patch.

Note (not a finding, disclosed by the author): this PR removes nested-agents-check.sh's is_blocked line, so row 42 of .claude/cutover-pathdet-ack.txt now quotes text that no longer exists. The PR body says no check fails on a stale row. A person can drop the row in a follow-up.

No plugin manifest changed, so there are no manifest lines. No embedded instructions were found in the PR context.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 7cb8ffe

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-15523-7cb8ffe231df3eb8237de008984b28db4029ef96, expires on 2026-12-12.

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 12, 2026
Merged via the queue into main with commit 2e3a04a Nov 12, 2026
65 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14505-43145490461-1 branch November 12, 2026 04:32
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 lib, scripts and audit harness-memory plugin code

0 participants