Skip to content

refactor(markdown-format): simplify markdown-check and markdown-gates git-hook code - #15073

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14655-42795293934-1
Nov 10, 2026
Merged

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14655

Summary

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

Simplified the markdown-format git-hook scripts with no behavior change. markdown-check.sh now names the markdownlint config list once (config_names), used by both the config-drift refusal and the staged-mirror walk; lint() builds its literal ':path' arguments with "${/#/:}" instead of a loop; and the local-bin lookup no longer reuses one variable for two meanings. In markdown-gates.sh, md_scan_dir's two identical first-config-wins loops became one helper, md_scan_family, called once per config family, and md_classify's two nested single-arm case blocks became plain if tests. hooks/markdown-format.sh was reviewed through the same four checks and left unchanged: its loops already do one pass per root, and the remaining helpers are calls into hook-utils.sh. Moving code between the files was out of scope.

Not verified

  • The markdown-format test suites (git-hooks/markdown-check.test.sh, hooks/markdown-format.test.sh, hooks/markdown-format-end-of-turn.test.sh) were not run: this lane runs only the named wrappers. Left to the PR's CI.
  • ci-status green on the PR: left to the PR's CI.
  • Tidy dropped both code files under its GLOBAL HARD exclusion for hook scripts and the git-hook chain (enforce mode). On the fragment it skipped the docs-hygiene and ai-slop passes because the fragment's only line is text the issue requires verbatim.
  • cant-fail-scan not run: it scans test files, and this change edits none.
  • Untracked root files (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) came from the runner environment, not this change. They were left untouched and are not part of the change.

Fix

  • plugins/markdown-format/git-hooks/markdown-check.sh: the config filename list is defined once as config_names and reused in checks_refuse_config_drift and mirror(); lint() prefixes ':' with "${/#/:}" instead of building an array in a loop; the local markdownlint-cli2 lookup uses a separate dir…
  • plugins/markdown-format/git-hooks/markdown-gates.sh: md_scan_dir delegates to a new md_scan_family helper (first present config per family, unchanged order); md_classify's nested case blocks for .markdownlint-cli2.* executables and .yaml escapes are now equivalent if tests.
  • .changes/markdown-format/work-resolve-issue-issue-14655-42795293934-1-2257c219.md: patch fragment, '### Changed' with 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 49ad042:

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

The run reports:

  • check-changelog-fragments: all 1 fragment valid (run before and after tidy)
  • check-changed-skills: no changed skills, nothing to gate (run before and after tidy)
  • check-affected: 13 passed, 6 skipped over 3 changed files (run before and after tidy)
  • fresh-context review subagent over the full diff (bash 3.2, set -uo pipefail, name collisions with check-lib.sh and markdown-format.sh, ${/#/:} quoting, return statuses): no behavior difference found
  • Grep over the repo: the tests that assert on these scripts (markdown-check.test.sh, markdown-format.test.sh, markdown-format-end-of-turn.test.sh) are behavioral and match no changed source text, so no test edit was needed
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42795293934

Left out: the items under Not verified.

Related

#14655

Merge-Risk: max=MEDIUM demote=false head=49ad0424c831f08bd0c868aacd4b91faa7ffc164 rubric=8.3.3 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 49ad0424c831f08bd0c868aacd4b91faa7ffc164: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #15073 (refactor(markdown-format): simplify git-hook code)

I found nothing that should block this PR. I read every hunk of all 3 changed files, plus the head copies of markdown-check.sh and markdown-gates.sh and checks_refuse_config_drift in lib/git-hooks/check-lib.sh. I checked each rewrite against the base code to see whether behavior changed:

  • config_names array (markdown-check.sh:88-90, :165): it holds the same ten config names in the same order, and mirror() still adds .gitignore after them. The array is set after the exit 0 for an empty candidate list. mirror() only runs later, so it never reads the array before it exists. Nothing else in the plugin or in check-lib.sh uses the name.
  • Local-bin lookup (markdown-check.sh:117-120): it resolves to the same directory as before (. when the path has no slash). Replacing if ...; then ...; fi with && is harmless here: the script runs set -uo pipefail without -e, and nothing reads the exit status. The global dir it now sets is never read later at top level. lint() declares its own local dir, and checks_refuse_config_drift does too.
  • lint() and "${@/#/:}" (markdown-check.sh:147): it adds the same : prefix to each path that the old loop added. Both callers pass at least one path.
  • md_classify (markdown-gates.sh:41-55): the new if tests set MD_TRUST_BLOCK and code exactly as the old case blocks did. The .cjs/.mjs branch now skips the grep when MD_TRUST_BLOCK is already set, which changes no outcome. The new unguarded read of $MD_TRUST_BLOCK is safe under set -u, because the only caller path (md_config_state → md_scan_dir → md_scan_family → md_note_config) first sets it to "".
  • md_scan_family (markdown-gates.sh:65-80): it keeps the first-match-per-family order, and the exit status is still 0 on every path. Its local dir covers only itself; md_note_config and md_classify never read dir.

Closing issue #14655, acceptance criteria:

  • Behavior unchanged: met, as far as reading the code shows. This repository has behavioral tests for these scripts (git-hooks/markdown-check.test.sh and the hooks/ suites) that could catch a change. The author says they did not run them and left them to CI. I could not run them either (no shell).
  • Only listed files plus fragments: met. The PR changes two of the listed files plus one fragment; hooks/markdown-format.sh is left unchanged, as the PR body explains.
  • At most 400 lines and 15 files: met (3 files, about 60 changed lines).
  • ci-status green: I can't check this from here; it's up to CI.
  • Fragment: met. It has bump: patch, ### Changed and the required line word for word.

The verification commands in the PR body were run by the author and I did not repeat them. I found no instructions hidden in the PR context.

@github-actions

Copy link
Copy Markdown
Contributor

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

Security review: PR #15073 (markdown-format git-hook simplification)

No security issues found.

Scope read: I read every hunk of all 3 changed files, and the whole head copies of markdown-check.sh and markdown-gates.sh. No changed file matches a TRUSTED PATHS glob. The PR doesn't change any plugin manifest or trust control.

Why I looked closely: markdown-gates.sh is the trust gate that decides whether a markdownlint config that can run repository code (.cjs/.mjs, or the keys customRules/markdownItPlugins/outputFormatters) may run. A refactor here could weaken that gate. I checked each changed part against the base:

  • md_classify, executable cli2 config (markdown-gates.sh#L41-L44): the case became an if. It sets MD_TRUST_BLOCK=unpinnable under exactly the same conditions as before (name matches .markdownlint-cli2.*, block not already set, and the grep matches). The only difference is that the grep is skipped when a block is already set, which changes nothing. code=0 is still set for every .cjs/.mjs, so those configs are still recorded as able to run code.
  • md_classify, YAML escape/tag check (L52-L55): same test and same result (unverifiable).
  • md_scan_dir → md_scan_family (L65-L80):
    • Same config names in the same order, and the first one present in each family still wins.
    • return 0 does what the old break did, and the function exits with the same status.
    • The new local dir only hides md_config_state's dir inside the helper. md_note_config and md_classify never read dir, and the caller's walk is unaffected.
    • No other function has the name md_scan_family.
  • markdown-check.sh:
    • config_names holds the same 10 names that both the config-drift refusal and mirror() used before. It is set at L88, before mirror() is ever called.
    • "${@/#/:}" (L147) still adds the : prefix to each path as its own quoted argument. markdownlint-cli2 therefore still treats every path as a literal, not a glob.
    • The local-bin lookup (L116-L121) passes the same directory to md_local_bin. That function's in-repository node_modules check is unchanged, so PATH is only extended with a shim that passed it.
    • The new global dir collides with nothing: every other dir in check-lib.sh and markdown-gates.sh is a local.
  • Changelog fragment: text only.

critical-findings: 0

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 49ad042

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-15073-49ad0424c831f08bd0c868aacd4b91faa7ffc164, expires on 2026-12-10.

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 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 10, 2026
@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit ac61baa Nov 10, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14655-42795293934-1 branch November 10, 2026 12:33
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 git-hooks and hooks markdown-format plugin code

0 participants